Browse Source

Test

etomic
jl777 8 years ago
parent
commit
033a5664d6
  1. 4
      iguana/exchanges/LP_nativeDEX.c
  2. 2
      iguana/exchanges/LP_signatures.c
  3. 12
      iguana/exchanges/LP_tradebots.c

4
iguana/exchanges/LP_nativeDEX.c

@ -236,8 +236,8 @@ char *LP_process_message(void *ctx,char *typestr,char *myipaddr,int32_t pubsock,
else else
{ {
memset(zero.bytes,0,sizeof(zero)); memset(zero.bytes,0,sizeof(zero));
if ( (method= jstr(reqjson,"method")) != 0 && (strcmp(method,"request") == 0 || strcmp(method,"requested") == 0 || strcmp(method,"connect") == 0 || strcmp(method,"connected") == 0) ) /*if ( (method= jstr(reqjson,"method")) != 0 && (strcmp(method,"request") == 0 || strcmp(method,"requested") == 0 || strcmp(method,"connect") == 0 || strcmp(method,"connected") == 0) )
printf("broadcast.(%s)\n",Broadcaststr); printf("broadcast.(%s)\n",Broadcaststr);*/
LP_reserved_msg("","",zero,jprint(reqjson,0)); LP_reserved_msg("","",zero,jprint(reqjson,0));
} }
retstr = clonestr("{\"result\":\"success\"}"); retstr = clonestr("{\"result\":\"success\"}");

2
iguana/exchanges/LP_signatures.c

@ -35,7 +35,7 @@ struct basilisk_request *LP_requestinit(struct basilisk_request *rp,bits256 srch
rp->desthash = desthash; rp->desthash = desthash;
rp->destamount = destsatoshis; rp->destamount = destsatoshis;
rp->quoteid = basilisk_quoteid(rp); rp->quoteid = basilisk_quoteid(rp);
printf("r.%u %u, q.%u %u: %s %.8f -> %s %.8f\n",rp->timestamp,rp->requestid,rp->quotetime,rp->quoteid,rp->src,dstr(rp->srcamount),rp->dest,dstr(rp->destamount)); //printf("r.%u %u, q.%u %u: %s %.8f -> %s %.8f\n",rp->timestamp,rp->requestid,rp->quotetime,rp->quoteid,rp->src,dstr(rp->srcamount),rp->dest,dstr(rp->destamount));
return(rp); return(rp);
} }

12
iguana/exchanges/LP_tradebots.c

@ -142,9 +142,9 @@ cJSON *LP_tradebot_json(struct LP_tradebot *bot)
jaddnum(json,"maxprice",bot->maxprice); jaddnum(json,"maxprice",bot->maxprice);
jaddnum(json,"totalrelvolume",bot->totalrelvolume); jaddnum(json,"totalrelvolume",bot->totalrelvolume);
jaddnum(json,"totalbasevolume",bot->totalbasevolume); jaddnum(json,"totalbasevolume",bot->totalbasevolume);
if ( (vol= bot->relsum) > SMALLVAL ) if ( (vol= bot->relsum) > SMALLVAL && bot->basesum > SMALLVAL )
{ {
jaddnum(json,"aveprice",bot->basesum/vol); jaddnum(json,"aveprice",vol/bot->basesum);
jaddnum(json,"volume",vol); jaddnum(json,"volume",vol);
} }
} }
@ -157,9 +157,9 @@ cJSON *LP_tradebot_json(struct LP_tradebot *bot)
jaddnum(json,"minprice",aveprice); jaddnum(json,"minprice",aveprice);
jaddnum(json,"totalbasevolume",bot->totalrelvolume); jaddnum(json,"totalbasevolume",bot->totalrelvolume);
jaddnum(json,"totalrelvolume",basevolume); jaddnum(json,"totalrelvolume",basevolume);
if ( (vol= bot->relsum) > SMALLVAL ) if ( (vol= bot->relsum) > SMALLVAL && bot->basesum > SMALLVAL )
{ {
aveprice = LP_pricevol_invert(&basevolume,bot->basesum / vol,vol); aveprice = LP_pricevol_invert(&basevolume,vol/bot->basesum,vol);
jaddnum(json,"aveprice",aveprice); jaddnum(json,"aveprice",aveprice);
jaddnum(json,"volume",basevolume); jaddnum(json,"volume",basevolume);
} }
@ -279,9 +279,9 @@ void LP_tradebot_timeslice(void *ctx,struct LP_tradebot *bot)
if ( (pending= jobj(retjson2,"pending")) != 0 && juint(pending,"tradeid") == tradeid ) if ( (pending= jobj(retjson2,"pending")) != 0 && juint(pending,"tradeid") == tradeid )
{ {
bot->trades[bot->numtrades++] = LP_tradebot_pending(bot,pending,tradeid); bot->trades[bot->numtrades++] = LP_tradebot_pending(bot,pending,tradeid);
if ( bot->relsum >= bot->totalrelvolume-SMALLVAL || bot->basesum >= bot->totalbasevolume-SMALLVAL ) if ( bot->relsum >= 0.99*bot->totalrelvolume-SMALLVAL || bot->basesum >= 0.99*bot->totalbasevolume-SMALLVAL )
bot->dead = (uint32_t)time(NULL); bot->dead = (uint32_t)time(NULL);
else if ( (bot->pendrelsum+bot->relsum) >= bot->totalrelvolume-SMALLVAL || (bot->basesum+bot->pendbasesum) >= bot->totalbasevolume-SMALLVAL ) 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); bot->pause = (uint32_t)time(NULL);
} else printf("didnt get any trade pending %s %s\n\n",bot->name,retstr); } else printf("didnt get any trade pending %s %s\n\n",bot->name,retstr);
free_json(retjson2); free_json(retjson2);

Loading…
Cancel
Save