From 9ee579f784515926ec0a0eb6185562f9b01a2eed Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 25 Jan 2018 10:39:30 +0400 Subject: [PATCH] Test --- iguana/exchanges/LP_portfolio.c | 32 ++------------------------------ iguana/exchanges/LP_prices.c | 15 ++++++++++++++- iguana/exchanges/auto_chipskmd | 2 +- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/iguana/exchanges/LP_portfolio.c b/iguana/exchanges/LP_portfolio.c index 7601761fa..f53e89939 100644 --- a/iguana/exchanges/LP_portfolio.c +++ b/iguana/exchanges/LP_portfolio.c @@ -547,36 +547,6 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp) LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,base,rel,askprice); //printf("price %.8f -> %.8f %.8f\n",price,bidprice,askprice); } - /*if ( LP_autorefs[i].fundbid[0] != 0 && (price= jdouble(fundjson,LP_autorefs[i].fundbid)) > SMALLVAL ) - { - printf("%s/%s %s %.8f -> %.8f or %.8f",base,rel,LP_autorefs[i].fundbid,price,(1. / (price * (1. + buymargin))),(1. / (price * (1. - buymargin)))); - if ( tickerjson != 0 && LP_autorefs[i].count == 0 ) - price = LP_tickered_price(0,base,rel,price,tickerjson); - newprice = (1. / (price * (1. + buymargin))); - //if ( LP_autorefs[i].lastbid < SMALLVAL ) - LP_autorefs[i].lastbid = newprice; - //else LP_autorefs[i].lastbid = (LP_autorefs[i].lastbid * 0.9) + (0.1 *newprice); - newprice = LP_autorefs[i].lastbid; - LP_mypriceset(&changed,rel,base,newprice); - LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,rel,base,newprice); - printf("fundbid %.8f margin %.8f newprice %.8f\n",price,buymargin,newprice); - } - if ( LP_autorefs[i].fundask[0] != 0 && (price= jdouble(fundjson,LP_autorefs[i].fundask)) > SMALLVAL ) - { - printf("%s/%s %s %.8f -> ",base,rel,LP_autorefs[i].fundask,price); - if ( tickerjson != 0 && LP_autorefs[i].count == 0 ) - price = LP_tickered_price(1,base,rel,price,tickerjson); - newprice = (price * (1. + sellmargin)); - //if ( LP_autorefs[i].lastask < SMALLVAL ) - LP_autorefs[i].lastask = newprice; - //else LP_autorefs[i].lastask = (LP_autorefs[i].lastask * 0.9) + (0.1 *newprice); - if ( LP_autorefs[i].lastbid < SMALLVAL || LP_autorefs[i].lastask >= LP_autorefs[i].lastbid/(1. + sellmargin) ) - newprice = LP_autorefs[i].lastask; - else newprice = LP_autorefs[i].lastbid * (1. + sellmargin); - LP_mypriceset(&changed,base,rel,newprice); - LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,base,rel,newprice); - printf("fundask %.8f margin %.8f newprice %.8f\n",price,sellmargin,newprice); - }*/ LP_autorefs[i].count++; } free_json(fundjson); @@ -681,6 +651,8 @@ int32_t LP_autoprice(void *ctx,char *base,char *rel,cJSON *argjson) fixedprice = jdouble(argjson,"fixed"); basepp->fixedprices[relpp->ind] = fixedprice; basepp->minprices[relpp->ind] = minprice; + if ( jobj(argjson,"maxprice") != 0 ) + relpp->minprices[basepp->ind] = 1. / jdouble(argjson,"maxprice"); basepp->buymargins[relpp->ind] = buymargin; basepp->sellmargins[relpp->ind] = sellmargin; basepp->offsets[relpp->ind] = offset; diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 7807f8eaf..bbfa42f36 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -511,7 +511,7 @@ char *LP_myprices() int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price) { - struct LP_priceinfo *basepp,*relpp; struct LP_pubkey_info *pubp; + struct LP_priceinfo *basepp,*relpp; struct LP_pubkey_info *pubp; double minprice,maxprice; *changedp = 0; //if ( strcmp("DEX",base) == 0 || strcmp("DEX",rel) == 0 ) // printf("%s/%s setprice %.8f\n",base,rel,price); @@ -529,6 +529,19 @@ int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price) relpp->offsets[basepp->ind] = 0.; relpp->factors[basepp->ind] = 0.; } + else if ( (minprice= basepp->minprices[relpp->ind]) > SMALLVAL && price < minprice ) + { + printf("%s/%s price %.8f less than minprice %.8f\n",base,rel,price,minprice); + price = minprice; + } + else if ( (maxprice= relpp->minprices[basepp->ind]) > SMALLVAL ) + { + if ( price < (1. / maxprice) ) + { + printf("%s/%s price %.8f more than maxprice %.8f, less than %.8f\n",base,rel,price,maxprice,1./maxprice); + price = maxprice; + } + } /*else if ( basepp->myprices[relpp->ind] > SMALLVAL ) { price = (basepp->myprices[relpp->ind] * 0.9) + (0.1 * price); diff --git a/iguana/exchanges/auto_chipskmd b/iguana/exchanges/auto_chipskmd index aee6c0548..c259a8cff 100755 --- a/iguana/exchanges/auto_chipskmd +++ b/iguana/exchanges/auto_chipskmd @@ -1,2 +1,2 @@ source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"KMD\",\"margin\":0.05,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}" +curl --url "http://127.0.0.1:7783" --data "{\"minprice\":0.04,\"maxprice\":0.1,\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"KMD\",\"margin\":0.05,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}"