|
@ -553,10 +553,10 @@ char *LP_autotrade(char *myipaddr,int32_t mypubsock,double profitmargin,char *ba |
|
|
metric = price / bestprice; |
|
|
metric = price / bestprice; |
|
|
if ( (butxo= LP_utxofind(1,txid,vout)) != 0 && metric < 1.2 && vol*SATOSHIDEN == butxo->payment.value && LP_isavailable(butxo) > 0 && LP_ismine(butxo) == 0 ) |
|
|
if ( (butxo= LP_utxofind(1,txid,vout)) != 0 && metric < 1.2 && vol*SATOSHIDEN == butxo->payment.value && LP_isavailable(butxo) > 0 && LP_ismine(butxo) == 0 ) |
|
|
{ |
|
|
{ |
|
|
if ( (destsatoshis= (butxo->payment.value * price)) > autxo->payment.value-desttxfee && destsatoshis > 2*desttxfee ) |
|
|
if ( (destsatoshis= (butxo->S.satoshis * price)) > autxo->payment.value-desttxfee && destsatoshis > 2*desttxfee ) |
|
|
{ |
|
|
{ |
|
|
destsatoshis *= ((double)autxo->payment.value / (destsatoshis - desttxfee*2)); |
|
|
destsatoshis *= ((double)autxo->payment.value / (destsatoshis - desttxfee*2)); |
|
|
if ( destsatoshis > desttxfee && destsatoshis-desttxfee > (autxo->payment.value >> 1) && destsatoshis/price-txfee > (butxo->payment.value >> 1) ) |
|
|
if ( destsatoshis > desttxfee && destsatoshis-desttxfee > (autxo->payment.value >> 1) && destsatoshis/price-txfee > (butxo->S.satoshis >> 1) ) |
|
|
{ |
|
|
{ |
|
|
printf("price %.8f/%.8f best %.8f destsatoshis %.8f * metric %.8f -> (%f)\n",price,bestprice,bestmetric,dstr(destsatoshis),metric,dstr(destsatoshis) * metric * metric * metric); |
|
|
printf("price %.8f/%.8f best %.8f destsatoshis %.8f * metric %.8f -> (%f)\n",price,bestprice,bestmetric,dstr(destsatoshis),metric,dstr(destsatoshis) * metric * metric * metric); |
|
|
metric = dstr(destsatoshis) * metric * metric * metric; |
|
|
metric = dstr(destsatoshis) * metric * metric * metric; |
|
@ -568,7 +568,7 @@ char *LP_autotrade(char *myipaddr,int32_t mypubsock,double profitmargin,char *ba |
|
|
bestmetric = metric; |
|
|
bestmetric = metric; |
|
|
printf("set best!\n"); |
|
|
printf("set best!\n"); |
|
|
} |
|
|
} |
|
|
} else printf("skip.(%d %d) destsatoshis %.8f value %.8f destvalue %.8f txfees %.8f %.8f\n",destsatoshis > (autxo->payment.value >> 1) ,destsatoshis/price > (butxo->payment.value >> 1),dstr(destsatoshis),dstr(butxo->payment.value),dstr(autxo->payment.value),dstr(txfee),dstr(desttxfee)); |
|
|
} else printf("skip.(%d %d) destsatoshis %.8f value %.8f destvalue %.8f txfees %.8f %.8f\n",destsatoshis > (autxo->payment.value >> 1) ,destsatoshis/price > (butxo->S.satoshis >> 1),dstr(destsatoshis),dstr(butxo->S.satoshis),dstr(autxo->payment.value),dstr(txfee),dstr(desttxfee)); |
|
|
} |
|
|
} |
|
|
} else printf("cant find butxo.%p or value mismatch %.8f != %.8f\n",butxo,vol,butxo!=0?dstr(butxo->payment.value):0); |
|
|
} else printf("cant find butxo.%p or value mismatch %.8f != %.8f\n",butxo,vol,butxo!=0?dstr(butxo->payment.value):0); |
|
|
} |
|
|
} |
|
|