|
|
@ -327,11 +327,14 @@ char *LP_myprices() |
|
|
|
return(jprint(array,1)); |
|
|
|
} |
|
|
|
|
|
|
|
int32_t LP_mypriceset(char *base,char *rel,double price) |
|
|
|
int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price) |
|
|
|
{ |
|
|
|
struct LP_priceinfo *basepp,*relpp; struct LP_pubkeyinfo *pubp; |
|
|
|
*changedp = 0; |
|
|
|
if ( base != 0 && rel != 0 && price > SMALLVAL && (basepp= LP_priceinfofind(base)) != 0 && (relpp= LP_priceinfofind(rel)) != 0 ) |
|
|
|
{ |
|
|
|
if ( fabs(basepp->myprices[relpp->ind] - price) > SMALLVAL ) |
|
|
|
*changedp = 1; |
|
|
|
basepp->myprices[relpp->ind] = price; // ask
|
|
|
|
//relpp->myprices[basepp->ind] = (1. / price); // bid
|
|
|
|
if ( (pubp= LP_pubkeyadd(LP_mypub25519)) != 0 ) |
|
|
@ -670,7 +673,7 @@ int32_t LP_autoprice(char *base,char *rel,double minprice,double margin) |
|
|
|
void prices_loop(void *ignore) |
|
|
|
{ |
|
|
|
//{"success":true,"message":"","result":[{"MarketName":"BTC-KMD","High":0.00040840,"Low":0.00034900,"Volume":328042.46061669,"Last":0.00037236,"BaseVolume":123.36439511,"TimeStamp":"2017-07-15T13:50:21.87","Bid":0.00035721,"Ask":0.00037069,"OpenBuyOrders":343,"OpenSellOrders":1690,"PrevDay":0.00040875,"Created":"2017-02-11T23:04:01.853"},
|
|
|
|
int32_t i,n; double margin,price; struct LP_priceinfo *coinpp,*btcpp; char *retstr,*name; cJSON *retjson,*array,*item; |
|
|
|
int32_t i,n,changed; double margin,price; struct LP_priceinfo *coinpp,*btcpp; char *retstr,*name; cJSON *retjson,*array,*item; void *ctx = bitcoin_ctx(); |
|
|
|
while ( 1 ) |
|
|
|
{ |
|
|
|
if ( LP_autoprices == 0 ) |
|
|
@ -715,14 +718,15 @@ void prices_loop(void *ignore) |
|
|
|
coinpp->prevday = jdouble(item,"PrevDay"); |
|
|
|
if ( (margin= coinpp->margins[btcpp->ind]) > SMALLVAL ) |
|
|
|
{ |
|
|
|
price = coinpp->bid * (1. - margin); |
|
|
|
LP_mypriceset("BTC",name,1. / price); |
|
|
|
|
|
|
|
price = 1. / coinpp->bid * (1. - margin); |
|
|
|
LP_mypriceset(&changed,"BTC",name,price); |
|
|
|
LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,"BTC",name,price); |
|
|
|
} |
|
|
|
if ( (margin= btcpp->margins[coinpp->ind]) > SMALLVAL ) |
|
|
|
{ |
|
|
|
price = coinpp->ask * (1. + margin); |
|
|
|
LP_mypriceset(name,"BTC",price); |
|
|
|
LP_mypriceset(&changed,name,"BTC",price); |
|
|
|
LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,name,"BTC",price); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|