From ac363f189878a070a35f2c811d1ff4a55ebc245a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 20 Jul 2017 12:48:49 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_portfolio.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_portfolio.c b/iguana/exchanges/LP_portfolio.c index 90ce1671d..664935955 100644 --- a/iguana/exchanges/LP_portfolio.c +++ b/iguana/exchanges/LP_portfolio.c @@ -400,7 +400,7 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp) void prices_loop(void *ignore) { - char *buycoin,*sellcoin,*retstr,*retstr2; double bid,ask,maxprice; struct iguana_info *buy,*sell; cJSON *retjson; struct LP_priceinfo *btcpp; void *ctx = bitcoin_ctx(); + char *buycoin,*sellcoin,*retstr,*retstr2; double bid,ask,maxprice,relvolume; struct iguana_info *buy,*sell; uint32_t requestid,quoteid; cJSON *retjson,*retjson2; struct LP_priceinfo *btcpp; void *ctx = bitcoin_ctx(); while ( 1 ) { if ( (btcpp= LP_priceinfofind("BTC")) == 0 ) @@ -420,10 +420,26 @@ void prices_loop(void *ignore) printf("base buy.%s force %f, rel sell.%s force %f relvolume %f maxprice %.8f (%.8f %.8f)\n",buycoin,jdouble(retjson,"buyforce"),sellcoin,jdouble(retjson,"sellforce"),sell->relvolume,maxprice,bid,ask); if ( maxprice > SMALLVAL ) { - if ( (retstr2= LP_autotrade(ctx,"127.0.0.1",-1,buycoin,sellcoin,maxprice,sell->relvolume,60,24*3600)) != 0 ) + relvolume = sell->relvolume; + while ( relvolume > 0.0001 ) { - printf("LP_autotrade.(%s)\n",retstr2); - free(retstr2); + requestid = quoteid = 0; + if ( (retstr2= LP_autotrade(ctx,"127.0.0.1",-1,buycoin,sellcoin,maxprice,sell->relvolume,60,24*3600)) != 0 ) + { + if ( (retjson2= cJSON_Parse(retstr2)) != 0 ) + { + if ( (requestid= juint(retjson2,"requestid")) != 0 && (quoteid= juint(retjson2,"quoteid")) != 0 ) + { + + } + free_json(retjson2); + } + printf("relvolume %.8f LP_autotrade.(%s)\n",relvolume,retstr2); + free(retstr2); + } + if ( requestid != 0 && quoteid != 0 ) + break; + relvolume *= 0.1; } } else