Browse Source

Test

etomic
jl777 7 years ago
parent
commit
86b70bc3af
  1. 13
      iguana/exchanges/LP_portfolio.c
  2. 6
      iguana/exchanges/LP_prices.c

13
iguana/exchanges/LP_portfolio.c

@ -534,7 +534,7 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
newprice = (1. / price) * (1. + margin);
if ( LP_autorefs[i].lastbid < SMALLVAL )
LP_autorefs[i].lastbid = newprice;
else LP_autorefs[i].lastbid = (LP_autorefs[i].lastbid * 0.5) + (0.5 *newprice);
else LP_autorefs[i].lastbid = (LP_autorefs[i].lastbid * 0.9) + (0.1 *newprice);
newprice = LP_autorefs[i].lastbid;
LP_mypriceset(&changed,rel,base,newprice);
LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,rel,base,newprice);
@ -547,7 +547,7 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
newprice = (price * (1. + margin));
if ( LP_autorefs[i].lastask < SMALLVAL )
LP_autorefs[i].lastask = newprice;
else LP_autorefs[i].lastask = (LP_autorefs[i].lastask * 0.5) + (0.5 *newprice);
else LP_autorefs[i].lastask = (LP_autorefs[i].lastask * 0.9) + (0.1 *newprice);
newprice = LP_autorefs[i].lastask;
LP_mypriceset(&changed,base,rel,newprice);
LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,base,rel,newprice);
@ -596,7 +596,14 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
void LP_autoprices_update(char *method,char *base,double basevol,char *rel,double relvol)
{
//printf("%s: autoprice update %s/%s %.8f\n",method,base,rel,relvol/basevol);
int32_t changed; double price,myprice,bid,ask,newprice;
if ( basevol > 0. && relvol > 0 && (myprice= LP_myprice(&bid,&ask,base,rel)) > SMALLVAL )
{
price = relvol/basevol;
newprice = (myprice * 0.95) + (0.05 * price);
printf("%s: autoprice update %s/%s %.8f vs myprice %.8f -> %.8f\n",method,base,rel,price,myprice,newprice);
LP_mypriceset(&changed,base,rel,newprice);
}
}
int32_t LP_autoprice(void *ctx,char *base,char *rel,cJSON *argjson)

6
iguana/exchanges/LP_prices.c

@ -516,7 +516,6 @@ int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price)
if ( price == 0. || fabs(basepp->myprices[relpp->ind] - price)/price > 0.001 )
*changedp = 1;
basepp->myprices[relpp->ind] = price; // ask
if ( price == 0. )
{
relpp->minprices[basepp->ind] = 0.;
@ -525,6 +524,11 @@ int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price)
relpp->offsets[basepp->ind] = 0.;
relpp->factors[basepp->ind] = 0.;
}
else if ( basepp->myprices[relpp->ind] > SMALLVAL )
{
price = (basepp->myprices[relpp->ind] * 0.9) + (0.1 * price);
}
basepp->myprices[relpp->ind] = price; // ask
//printf("LP_mypriceset base.%s rel.%s <- price %.8f\n",base,rel,price);
//relpp->myprices[basepp->ind] = (1. / price); // bid
if ( (pubp= LP_pubkeyadd(G.LP_mypub25519)) != 0 )

Loading…
Cancel
Save