Browse Source

Test

etomic
jl777 7 years ago
parent
commit
1766ca95ab
  1. 12
      iguana/exchanges/LP_tradebots.c

12
iguana/exchanges/LP_tradebots.c

@ -280,7 +280,7 @@ void LP_tradebot_timeslice(void *ctx,struct LP_tradebot *bot)
printf("%s\n",jprint(LP_tradebot_json(bot),1)); printf("%s\n",jprint(LP_tradebot_json(bot),1));
} else printf("didnt get any trade pending %s\n",bot->name); } else printf("didnt get any trade pending %s\n",bot->name);
free_json(pending); free_json(pending);
} } else printf("%s\n",retstr);
free(retstr); free(retstr);
} }
} }
@ -418,9 +418,9 @@ char *LP_tradebot_buy(int32_t dispdir,char *base,char *rel,double maxprice,doubl
free_json(array); free_json(array);
} }
txfees = 10 * relcoin->txfee; txfees = 10 * relcoin->txfee;
printf("%s inventory balance %.8f, relvolume %.8f + txfees %.8f\n",rel,dstr(abalance),relvolume,dstr(txfees));
if ( dstr(abalance) < relvolume + dstr(txfees) ) if ( dstr(abalance) < relvolume + dstr(txfees) )
{ {
printf("%s inventory balance only %.8f, less than relvolume %.8f + txfees %.8f\n",rel,dstr(abalance),relvolume,dstr(txfees));
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
jaddstr(retjson,"error","not enough funds"); jaddstr(retjson,"error","not enough funds");
jaddstr(retjson,"coin",rel); jaddstr(retjson,"coin",rel);
@ -429,7 +429,7 @@ char *LP_tradebot_buy(int32_t dispdir,char *base,char *rel,double maxprice,doubl
jaddnum(retjson,"txfees",dstr(txfees)); jaddnum(retjson,"txfees",dstr(txfees));
shortfall = (relvolume + dstr(txfees)) - dstr(balance); shortfall = (relvolume + dstr(txfees)) - dstr(balance);
jaddnum(retjson,"shortfall",shortfall); jaddnum(retjson,"shortfall",shortfall);
if ( (balance= LP_RTsmartbalance(relcoin)) > abalance+SATOSHIDEN*shortfall ) if ( (balance= LP_RTsmartbalance(relcoin)) > abalance+SATOSHIDEN*(shortfall+relvolume/77.) )
{ {
char *withdrawstr; cJSON *outputjson,*withdrawjson,*outputs,*item; char *withdrawstr; cJSON *outputjson,*withdrawjson,*outputs,*item;
outputjson = cJSON_CreateObject(); outputjson = cJSON_CreateObject();
@ -440,6 +440,12 @@ char *LP_tradebot_buy(int32_t dispdir,char *base,char *rel,double maxprice,doubl
item = cJSON_CreateObject(); item = cJSON_CreateObject();
jaddnum(item,relcoin->smartaddr,(relvolume+dstr(txfees))/777); jaddnum(item,relcoin->smartaddr,(relvolume+dstr(txfees))/777);
jaddi(outputs,item); jaddi(outputs,item);
item = cJSON_CreateObject();
jaddnum(item,relcoin->smartaddr,(relvolume+dstr(txfees))/777);
jaddi(outputs,item);
item = cJSON_CreateObject();
jaddnum(item,relcoin->smartaddr,(relvolume+dstr(txfees))/777);
jaddi(outputs,item);
jadd(outputjson,"outputs",outputs); jadd(outputjson,"outputs",outputs);
if ( (withdrawstr= LP_withdraw(relcoin,outputjson)) != 0 ) if ( (withdrawstr= LP_withdraw(relcoin,outputjson)) != 0 )
{ {

Loading…
Cancel
Save