From 1f7d117738c2f1fdd51beeade13a49c4417be543 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 17 Oct 2017 20:40:37 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_portfolio.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/iguana/exchanges/LP_portfolio.c b/iguana/exchanges/LP_portfolio.c index b2ec8ff2a..3e56b9fbb 100644 --- a/iguana/exchanges/LP_portfolio.c +++ b/iguana/exchanges/LP_portfolio.c @@ -265,7 +265,7 @@ int32_t LP_autoprice(char *base,char *rel,cJSON *argjson) void LP_autopriceset(void *ctx,int32_t dir,struct LP_priceinfo *basepp,struct LP_priceinfo *relpp,double price,char *refbase,char *refrel) { - double margin,minprice,oppomargin,factor,offset; double bid,ask; int32_t changed; + double margin,minprice,newprice,oppomargin,factor,offset; double bid,ask; int32_t changed; margin = basepp->margins[relpp->ind]; oppomargin = relpp->margins[basepp->ind]; if ( margin != 0. || oppomargin != 0. ) @@ -288,15 +288,17 @@ void LP_autopriceset(void *ctx,int32_t dir,struct LP_priceinfo *basepp,struct LP 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 ) - price = 1. / (price * (1. - margin)); - else price = (price * (1. - margin)); + //if ( dir > 0 ) + // price = 1. / (price * (1. - margin)); + //else price = (price * (1. - margin)); + + newprice = (price * (1. - margin)); if ( (minprice= basepp->minprices[relpp->ind]) == 0. || price >= minprice ) { - LP_mypriceset(&changed,relpp->symbol,basepp->symbol,price); - //printf("changed.%d\n",changed); + LP_mypriceset(&changed,relpp->symbol,basepp->symbol,newprice); + printf("changed.%d %s/%s <- %.8f\n",changed,basepp->symbol,relpp->symbol,newprice); if ( changed != 0 ) - LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,relpp->symbol,basepp->symbol,price); + LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,relpp->symbol,basepp->symbol,newprice); } } } @@ -378,7 +380,7 @@ double LP_pricesparse(void *ctx,int32_t trexflag,char *retstr,struct LP_priceinf //printf("have trex: iter.%d trexflag.%d %s %.8f %.8f\n",iter,trexflag,symbol,coinpp->bid[1],coinpp->ask[1]); continue; } - LP_autopriceset(ctx,1,coinpp,refpp,price,0,0); + //LP_autopriceset(ctx,1,coinpp,refpp,price,0,0); LP_autopriceset(ctx,-1,refpp,coinpp,price,0,0); } } @@ -438,7 +440,7 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp) { //printf("(%s %.8f %.8f) ",CURRENCIES[i],jdouble(retjson,"price"),jdouble(retjson,"invprice")); price = jdouble(retjson,"price"); - LP_autopriceset(ctx,1,fiatpp,kmdpp,price,0,0); + //LP_autopriceset(ctx,1,fiatpp,kmdpp,price,0,0); LP_autopriceset(ctx,-1,kmdpp,fiatpp,price,0,0); free_json(retjson); } @@ -462,7 +464,7 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp) if ( bidsatoshis != 0 && asksatoshis != 0 ) price = 0.5 * dstr(bidsatoshis + asksatoshis) * nxtkmd; } - LP_autopriceset(ctx,1,nxtpp,kmdpp,price,0,0); + //LP_autopriceset(ctx,1,nxtpp,kmdpp,price,0,0); LP_autopriceset(ctx,-1,kmdpp,nxtpp,price,0,0); //printf("%s %s -> (%s) nxtkmd %.8f %.8f %.8f\n",assetids[i][1],assetids[i][0],jprint(retjson,0),nxtkmd,0.5*dstr(bidsatoshis + asksatoshis),price); free_json(retjson); @@ -475,7 +477,7 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp) basepp = LP_priceinfofind(LP_autorefs[i].base); relpp = LP_priceinfofind(LP_autorefs[i].rel); if ( basepp != 0 && relpp != 0 ) - LP_autopriceset(ctx,1,basepp,relpp,0,LP_autorefs[i].refbase,LP_autorefs[i].refrel); + LP_autopriceset(ctx,-1,basepp,relpp,0,LP_autorefs[i].refbase,LP_autorefs[i].refrel); } }