|
|
@ -253,7 +253,7 @@ int32_t LP_autoprice(char *base,char *rel,cJSON *argjson) |
|
|
|
safecopy(LP_autorefs[num_LP_autorefs].refrel,refrel,sizeof(LP_autorefs[num_LP_autorefs].refrel)); |
|
|
|
safecopy(LP_autorefs[num_LP_autorefs].base,base,sizeof(LP_autorefs[num_LP_autorefs].base)); |
|
|
|
safecopy(LP_autorefs[num_LP_autorefs].rel,rel,sizeof(LP_autorefs[num_LP_autorefs].rel)); |
|
|
|
printf("%d Using ref %s/%s for %s/%s %.8f %.8f\n",num_LP_autorefs,refbase,refrel,base,rel,factor,offset); |
|
|
|
printf("%d Using ref %s/%s for %s/%s factor %.8f, offset %.8f, margin %.8f\n",num_LP_autorefs,refbase,refrel,base,rel,factor,offset,margin); |
|
|
|
num_LP_autorefs++; |
|
|
|
} |
|
|
|
} |
|
|
@ -275,28 +275,28 @@ void LP_autopriceset(void *ctx,int32_t dir,struct LP_priceinfo *basepp,struct LP |
|
|
|
if ( fabs(price) < SMALLVAL && refbase != 0 && refrel != 0 ) |
|
|
|
{ |
|
|
|
price = LP_myprice(&bid,&ask,refbase,refrel); |
|
|
|
printf("%s/%s USE ref %s/%s %.8f factor %.8f offset %.8f margin %.8f\n",basepp->symbol,relpp->symbol,refbase,refrel,price,factor,offset,margin); |
|
|
|
//printf("%s/%s USE ref %s/%s %.8f factor %.8f offset %.8f margin %.8f\n",basepp->symbol,relpp->symbol,refbase,refrel,price,factor,offset,margin);
|
|
|
|
} |
|
|
|
if ( LP_pricevalid(price) > 0 ) |
|
|
|
{ |
|
|
|
if ( factor > SMALLVAL ) |
|
|
|
{ |
|
|
|
double tmp = (price * factor) + offset; |
|
|
|
printf("price %.8f -> %.8f factor %.8f offset %.8f margin %.8f [%.8f %.8f] [%.8f %.8f]\n",price,tmp,factor,offset,margin,(tmp * (1. + margin)),1./(tmp * (1. - margin)),(tmp * (1. - margin)),1./(tmp * (1. + margin))); |
|
|
|
//double tmp = (price * factor) + offset;
|
|
|
|
//printf("price %.8f -> %.8f factor %.8f offset %.8f margin %.8f [%.8f %.8f] [%.8f %.8f]\n",price,tmp,factor,offset,margin,(tmp * (1. + margin)),1./(tmp * (1. - margin)),(tmp * (1. - margin)),1./(tmp * (1. + margin)));
|
|
|
|
price = (price * factor) + offset; |
|
|
|
} |
|
|
|
if ( margin == 0. ) |
|
|
|
margin = oppomargin; |
|
|
|
//printf("min %.8f %s/%s %.8f dir.%d margin %.8f (%.8f %.8f)\n",basepp->minprices[relpp->ind],relpp->symbol,basepp->symbol,price,dir,margin,1. / (price * (1. - margin)),(price * (1. + margin)));
|
|
|
|
if ( dir > 0 ) |
|
|
|
newprice = 1. / (price * (1. - margin)); |
|
|
|
newprice = 1. / (price * (1. + margin)); |
|
|
|
else newprice = (price * (1. - margin)); |
|
|
|
|
|
|
|
//newprice = 1. / (price * (1. - margin));
|
|
|
|
if ( (minprice= basepp->minprices[relpp->ind]) == 0. || price >= minprice ) |
|
|
|
{ |
|
|
|
LP_mypriceset(&changed,relpp->symbol,basepp->symbol,newprice); |
|
|
|
printf("changed.%d %s/%s <- %.8f\n",changed,basepp->symbol,relpp->symbol,price); |
|
|
|
//printf("changed.%d %s/%s <- %.8f\n",changed,basepp->symbol,relpp->symbol,price);
|
|
|
|
if ( changed != 0 ) |
|
|
|
LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,relpp->symbol,basepp->symbol,newprice); |
|
|
|
} |
|
|
|