Browse Source

Test

etomic
jl777 7 years ago
parent
commit
1d11d9a78f
  1. 10
      iguana/exchanges/LP_tradebots.c

10
iguana/exchanges/LP_tradebots.c

@ -476,13 +476,14 @@ char *LP_tradebot_buy(int32_t dispdir,char *base,char *rel,double maxprice,doubl
free(retstr); free(retstr);
txfee = LP_txfeecalc(relcoin,0,0); txfee = LP_txfeecalc(relcoin,0,0);
txfees = 10 * txfee; txfees = 10 * txfee;
printf("%s inventory balance %.8f, relvolume %.8f + txfees %.8f\n",rel,dstr(abalance),relvolume,dstr(txfees));
if ( dstr(abalance) < relvolume + dstr(txfees) )
{
retjson = cJSON_CreateObject();
if ( relcoin->electrum != 0 ) if ( relcoin->electrum != 0 )
balance = LP_unspents_load(relcoin->symbol,relcoin->smartaddr); balance = LP_unspents_load(relcoin->symbol,relcoin->smartaddr);
else balance = LP_RTsmartbalance(relcoin); else balance = LP_RTsmartbalance(relcoin);
sum = (relvolume+2*dstr(txfees)) + 3 * ((relvolume+2*dstr(txfees))/777);
printf("%s inventory balance %.8f, relvolume %.8f + txfees %.8f, utxobal %.8f sum %.8f\n",rel,dstr(abalance),relvolume,dstr(txfees),dstr(balance),dstr(sum));
if ( dstr(abalance) < relvolume + dstr(txfees) && balance > sum+txfee )
{
retjson = cJSON_CreateObject();
jaddstr(retjson,"error","not enough funds"); jaddstr(retjson,"error","not enough funds");
jaddstr(retjson,"coin",rel); jaddstr(retjson,"coin",rel);
jaddnum(retjson,"abalance",dstr(abalance)); jaddnum(retjson,"abalance",dstr(abalance));
@ -491,7 +492,6 @@ 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);
sum = (relvolume+2*dstr(txfees)) + 3 * ((relvolume+2*dstr(txfees))/777);
if ( balance >= sum+txfee ) if ( balance >= sum+txfee )
{ {
char *withdrawstr; cJSON *outputjson,*withdrawjson,*outputs,*item; char *withdrawstr; cJSON *outputjson,*withdrawjson,*outputs,*item;

Loading…
Cancel
Save