|
|
@ -400,7 +400,7 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp) |
|
|
|
|
|
|
|
void prices_loop(void *ignore) |
|
|
|
{ |
|
|
|
char *buycoin,*sellcoin,*retstr,*retstr2; double bid,ask,maxprice; struct iguana_info *buy,*sell; cJSON *retjson; struct LP_priceinfo *btcpp; void *ctx = bitcoin_ctx(); |
|
|
|
char *buycoin,*sellcoin,*retstr,*retstr2; double bid,ask,maxprice,relvolume; struct iguana_info *buy,*sell; uint32_t requestid,quoteid; cJSON *retjson,*retjson2; struct LP_priceinfo *btcpp; void *ctx = bitcoin_ctx(); |
|
|
|
while ( 1 ) |
|
|
|
{ |
|
|
|
if ( (btcpp= LP_priceinfofind("BTC")) == 0 ) |
|
|
@ -420,10 +420,26 @@ void prices_loop(void *ignore) |
|
|
|
printf("base buy.%s force %f, rel sell.%s force %f relvolume %f maxprice %.8f (%.8f %.8f)\n",buycoin,jdouble(retjson,"buyforce"),sellcoin,jdouble(retjson,"sellforce"),sell->relvolume,maxprice,bid,ask); |
|
|
|
if ( maxprice > SMALLVAL ) |
|
|
|
{ |
|
|
|
if ( (retstr2= LP_autotrade(ctx,"127.0.0.1",-1,buycoin,sellcoin,maxprice,sell->relvolume,60,24*3600)) != 0 ) |
|
|
|
relvolume = sell->relvolume; |
|
|
|
while ( relvolume > 0.0001 ) |
|
|
|
{ |
|
|
|
printf("LP_autotrade.(%s)\n",retstr2); |
|
|
|
free(retstr2); |
|
|
|
requestid = quoteid = 0; |
|
|
|
if ( (retstr2= LP_autotrade(ctx,"127.0.0.1",-1,buycoin,sellcoin,maxprice,sell->relvolume,60,24*3600)) != 0 ) |
|
|
|
{ |
|
|
|
if ( (retjson2= cJSON_Parse(retstr2)) != 0 ) |
|
|
|
{ |
|
|
|
if ( (requestid= juint(retjson2,"requestid")) != 0 && (quoteid= juint(retjson2,"quoteid")) != 0 ) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
free_json(retjson2); |
|
|
|
} |
|
|
|
printf("relvolume %.8f LP_autotrade.(%s)\n",relvolume,retstr2); |
|
|
|
free(retstr2); |
|
|
|
} |
|
|
|
if ( requestid != 0 && quoteid != 0 ) |
|
|
|
break; |
|
|
|
relvolume *= 0.1; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|