Browse Source

Test

etomic
jl777 7 years ago
parent
commit
897afd3a6b
  1. 4
      iguana/exchanges/LP_RTmetrics.c
  2. 7
      iguana/exchanges/LP_tradebots.c

4
iguana/exchanges/LP_RTmetrics.c

@ -272,13 +272,13 @@ cJSON *LP_RTmetrics_sort(char *base,char *rel,cJSON *rawasks,int32_t numasks,dou
item = jitem(rawasks,i);
LP_RTmetric_calc(sortbuf,i,item,bestprice,maxprice,relvolume,prevdepth);
prevdepth = jdouble(item,"depth");
printf("%.8f ",sortbuf[i].metric);
//printf("%.8f ",sortbuf[i].metric);
}
qsort(&sortbuf[0].metric,groupi+1,sizeof(*sortbuf),_increasing_metrics);
array = cJSON_CreateArray();
for (i=0; i<=groupi; i++)
{
printf("(%d -> %d %.3f) ",i,sortbuf[i].ind,sortbuf[i].metric);
printf("(%d <- %d %.3f) ",i,sortbuf[i].ind,sortbuf[i].metric);
item = jitem(rawasks,sortbuf[i].ind);
jaddi(array,jduplicate(item));
}

7
iguana/exchanges/LP_tradebots.c

@ -259,7 +259,7 @@ struct LP_tradebot_trade *LP_tradebot_pending(struct LP_tradebot *bot,cJSON *pen
void LP_tradebot_timeslice(void *ctx,struct LP_tradebot *bot)
{
double remaining; uint32_t tradeid; bits256 destpubkey; char *retstr,*liststr; cJSON *retjson,*retjson2,*pending;
double remaining; int32_t i,maxiters = 10; uint32_t tradeid; bits256 destpubkey; char *retstr,*liststr; cJSON *retjson,*retjson2,*pending;
memset(destpubkey.bytes,0,sizeof(destpubkey));
if ( bot->dead == 0 && bot->pause == 0 && bot->numtrades < sizeof(bot->trades)/sizeof(*bot->trades) )
{
@ -272,7 +272,8 @@ void LP_tradebot_timeslice(void *ctx,struct LP_tradebot *bot)
remaining = bot->totalrelvolume - (bot->relsum + bot->pendrelsum);
printf("try autobuy %s/%s remaining %.8f maxprice %.8f\n",bot->base,bot->rel,remaining,bot->maxprice);
tradeid = rand();
if ( (retstr= LP_autobuy(ctx,LP_myipaddr,LP_mypubsock,bot->base,bot->rel,bot->maxprice,remaining,0,0,G.gui,0,destpubkey,tradeid)) != 0 )
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 )
{
@ -285,7 +286,7 @@ void LP_tradebot_timeslice(void *ctx,struct LP_tradebot *bot)
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("%s\n",retstr);
} else printf("iter.%d/%d %s\n",i,maxiters,retstr);
free(retstr);
}
}

Loading…
Cancel
Save