Browse Source

Test

etomic
jl777 8 years ago
parent
commit
28e7f8b5c1
  1. 2
      basilisk/basilisk_DEX.c
  2. 4
      basilisk/basilisk_tradebot.c
  3. 19
      basilisk/tradebots_liquidity.c

2
basilisk/basilisk_DEX.c

@ -162,7 +162,7 @@ cJSON *basilisk_requestjson(struct basilisk_request *rp)
{
//jadd64bits(item,"destamount",rp->destamount);
jadd64bits(item,"destsatoshis",rp->destamount);
printf("DESTSATOSHIS.%llu\n",(long long)rp->destamount);
//printf("DESTSATOSHIS.%llu\n",(long long)rp->destamount);
}
jaddnum(item,"quotetime",rp->quotetime);
jaddnum(item,"timestamp",rp->timestamp);

4
basilisk/basilisk_tradebot.c

@ -230,7 +230,7 @@ struct basilisk_request *basilisk_parsejson(struct basilisk_request *rp,cJSON *r
rp->minamount = j64bits(reqjson,"minamount");
//rp->destamount = j64bits(reqjson,"destamount");
rp->destamount = j64bits(reqjson,"destsatoshis");
printf("parse DESTSATOSHIS.%llu (%s)\n",(long long)rp->destamount,jprint(reqjson,0));
//printf("parse DESTSATOSHIS.%llu (%s)\n",(long long)rp->destamount,jprint(reqjson,0));
requestid = juint(reqjson,"requestid");
quoteid = juint(reqjson,"quoteid");
//if ( jstr(reqjson,"relay") != 0 )
@ -319,7 +319,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk
// MVP -> USD myrequest.0 pendingid.0 noquoteflag.1 havequoteflag.0 maxi.-1 0.00000000
double retvals[4],refprice=0.,profitmargin,aveprice,destvolume; cJSON *retjson; char *retstr;
destvolume = dstr(maxamount);
printf("destvolume <- %.8f\n",dstr(destvolume));
//printf("destvolume <- %.8f\n",dstr(destvolume));
if ( fabs(destvolume) < SMALLVAL )
{
if ( (destvolume= dstr(minamount)) == 0 )

19
basilisk/tradebots_liquidity.c

@ -991,10 +991,21 @@ void _default_liquidity_command(struct supernet_info *myinfo,char *base,bits256
printf("ERROR: too many linfos %d\n",i);
}
int32_t _default_volume_ok(struct supernet_info *myinfo,struct liquidity_info *li,int32_t dir,double volume)
int32_t _default_volume_ok(struct supernet_info *myinfo,struct liquidity_info *li,int32_t dir,double volume,double price)
{
printf("minvol %f maxvol %f vs volume %f\n",li->minvol,li->maxvol,volume);
if ( (li->minvol == 0 || volume >= li->minvol) && (li->maxvol == 0 || volume <= li->maxvol) )
double minvol,maxvol;
if ( dir > 0 )
{
minvol = li->minvol;
maxvol = li->maxvol;
}
else
{
minvol = price * li->minvol;
maxvol = price * li->maxvol;
}
printf("dir.%d minvol %f maxvol %f vs (%f %f) volume %f price %f\n",dir,li->minvol,li->maxvol,minvol,maxvol,volume,price);
if ( (minvol == 0. || volume >= minvol) && (maxvol == 0. || volume <= maxvol) )
return(0);
else return(-1);
}
@ -1018,7 +1029,7 @@ double _default_liquidity_active(struct supernet_info *myinfo,double *refpricep,
printf("continue %s %s/%s [%d] dir.%d vs %s %s/%s\n",exchange,base,rel,i,dir,refli.exchange,refli.base,refli.rel);
continue;
}
if ( _default_volume_ok(myinfo,&refli,dir,destvolume) == 0 )
if ( _default_volume_ok(myinfo,&refli,dir,destvolume,dir > 0 ? refli.bid : refli.ask) == 0 )
{
if ( refli.profit != 0. )
*refpricep = refli.refprice;

Loading…
Cancel
Save