|
|
@ -969,9 +969,10 @@ char *LP_orderbook(char *base,char *rel,int32_t duration) |
|
|
|
return(jprint(retjson,1)); |
|
|
|
} |
|
|
|
|
|
|
|
double LP_fomoprice(char *base,char *rel,double relvolume) |
|
|
|
double LP_fomoprice(char *base,char *rel,double *relvolumep) |
|
|
|
{ |
|
|
|
char *retstr; cJSON *retjson,*asks,*item; int32_t i,numasks; double biggest,price,fomoprice = 0.; |
|
|
|
char *retstr; cJSON *retjson,*asks,*item; int32_t i,numasks; double maxvol=0.,relvolume,biggest,price,fomoprice = 0.; |
|
|
|
relvolume = *relvolumep; |
|
|
|
if ( (retstr= LP_orderbook(base,rel,0)) != 0 ) |
|
|
|
{ |
|
|
|
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|
|
@ -983,13 +984,24 @@ double LP_fomoprice(char *base,char *rel,double relvolume) |
|
|
|
item = jitem(asks,i); |
|
|
|
biggest = jdouble(item,"maxvolume"); |
|
|
|
price = jdouble(item,"price"); |
|
|
|
printf("fomoprice (%.8f) i.%d %.8f vol %.8f\n",relvolume,i,price,biggest); |
|
|
|
if ( biggest > maxvol ) |
|
|
|
{ |
|
|
|
maxvol = biggest; |
|
|
|
fomoprice = price; |
|
|
|
} |
|
|
|
printf("fomoprice (%.8f) i.%d %.8f vol %.8f [max %.8f @ %.8f]\n",relvolume,i,price,biggest,maxvol,fomoprice); |
|
|
|
} |
|
|
|
} |
|
|
|
free_json(retjson); |
|
|
|
} |
|
|
|
free(retstr); |
|
|
|
} |
|
|
|
if ( maxvol > 0. && maxvol < relvolume && fomoprice > 0. ) |
|
|
|
{ |
|
|
|
relvolume = maxvol * 0.98; |
|
|
|
fomoprice /= 0.99; |
|
|
|
} else *fomoprice = 0.; |
|
|
|
*relvolumep = relvolume; |
|
|
|
return(fomoprice); |
|
|
|
} |
|
|
|
|
|
|
|