From fc1d374ed1e45aeaca7da85c68d7a995e5a1b784 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 2 Nov 2017 17:50:11 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_RTmetrics.c | 10 +++++----- iguana/exchanges/LP_tradebots.c | 26 ++++++++++++++------------ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/iguana/exchanges/LP_RTmetrics.c b/iguana/exchanges/LP_RTmetrics.c index e38ed8861..e8d0ba09e 100644 --- a/iguana/exchanges/LP_RTmetrics.c +++ b/iguana/exchanges/LP_RTmetrics.c @@ -184,28 +184,28 @@ double _LP_RTmetric_calc(struct LP_metricinfo *mp,double bestprice,double maxpri metric = origmetric; if ( mp->numutxos == 0 || relvolume == 0. || mp->maxvol == 0. || mp->balance == 0. ) { - printf("skip i.%d as no info\n",mp->ind); + //printf("skip i.%d as no info\n",mp->ind); return(metric * 100.); } if ( relvolume < mp->minvol ) { metric *= (mp->minvol / relvolume); - printf("relvolume < minvol %.8f\n",(mp->minvol / relvolume)); + //printf("relvolume < minvol %.8f\n",(mp->minvol / relvolume)); } else if ( relvolume > mp->maxvol ) { metric *= (relvolume / mp->maxvol); - printf("relvolume > minvol %.8f\n",(relvolume / mp->maxvol)); + //printf("relvolume > minvol %.8f\n",(relvolume / mp->maxvol)); } if ( relvolume < mp->balance/LP_MINVOL ) { metric *= (mp->balance / relvolume); - printf("relvolume < balance %.8f\n",(mp->balance / relvolume)); + //printf("relvolume < balance %.8f\n",(mp->balance / relvolume)); } else if ( relvolume > mp->balance/mp->numutxos ) { metric *= (relvolume / (mp->balance/mp->numutxos)); - printf("relvolume < ave %.8f\n",(relvolume / (mp->balance/mp->numutxos))); + //printf("relvolume < ave %.8f\n",(relvolume / (mp->balance/mp->numutxos))); } if ( mp->age > LP_ORDERBOOK_DURATION*0.8 ) metric *= 2; diff --git a/iguana/exchanges/LP_tradebots.c b/iguana/exchanges/LP_tradebots.c index f3b5b35fb..69ada5bd1 100644 --- a/iguana/exchanges/LP_tradebots.c +++ b/iguana/exchanges/LP_tradebots.c @@ -273,21 +273,23 @@ void LP_tradebot_timeslice(void *ctx,struct LP_tradebot *bot) printf("try autobuy %s/%s remaining %.8f maxprice %.8f\n",bot->base,bot->rel,remaining,bot->maxprice); tradeid = rand(); for (i=1; i<=maxiters; i++) - if ( (retstr= LP_autobuy(ctx,LP_myipaddr,LP_mypubsock,bot->base,bot->rel,bot->maxprice,remaining/i,0,0,G.gui,0,destpubkey,tradeid)) != 0 ) { - if ( (retjson2= cJSON_Parse(retstr)) != 0 ) + if ( (retstr= LP_autobuy(ctx,LP_myipaddr,LP_mypubsock,bot->base,bot->rel,bot->maxprice,remaining/i,0,0,G.gui,0,destpubkey,tradeid)) != 0 ) { - if ( (pending= jobj(retjson2,"pending")) != 0 && juint(pending,"tradeid") == tradeid ) + if ( (retjson2= cJSON_Parse(retstr)) != 0 ) { - bot->trades[bot->numtrades++] = LP_tradebot_pending(bot,pending,tradeid); - if ( bot->relsum >= 0.99*bot->totalrelvolume-SMALLVAL || bot->basesum >= 0.99*bot->totalbasevolume-SMALLVAL ) - bot->dead = (uint32_t)time(NULL); - else if ( (bot->pendrelsum+bot->relsum) >= 0.99*bot->totalrelvolume-SMALLVAL || (bot->basesum+bot->pendbasesum) >= 0.99*bot->totalbasevolume-SMALLVAL ) - bot->pause = (uint32_t)time(NULL); - } else printf("didnt get any trade pending %s %s\n\n",bot->name,retstr); - free_json(retjson2); - } else printf("iter.%d/%d %s\n",i,maxiters,retstr); - free(retstr); + if ( (pending= jobj(retjson2,"pending")) != 0 && juint(pending,"tradeid") == tradeid ) + { + bot->trades[bot->numtrades++] = LP_tradebot_pending(bot,pending,tradeid); + if ( bot->relsum >= 0.99*bot->totalrelvolume-SMALLVAL || bot->basesum >= 0.99*bot->totalbasevolume-SMALLVAL ) + bot->dead = (uint32_t)time(NULL); + else if ( (bot->pendrelsum+bot->relsum) >= 0.99*bot->totalrelvolume-SMALLVAL || (bot->basesum+bot->pendbasesum) >= 0.99*bot->totalbasevolume-SMALLVAL ) + bot->pause = (uint32_t)time(NULL); + } else printf("iter.%d/%d %.8f didnt get any trade pending %s %s\n\n",i,maxiters,remaining/i,bot->name,retstr); + free_json(retjson2); + } else printf("iter.%d/%d %.8f %s\n",i,maxiters,remaining/i,retstr); + free(retstr); + } } } free_json(retjson);