Browse Source

setprice 0

added a destpubkey field to the buy/sell trade api, this allows to
ordermatch to a specific entry in the orderbook. I will also be adding
a "depth" field to the orderbook, which will just be the sum of the max
size utxo from each orderbook entry. alternatively I could sum the
total balance at each orderbook entry, though at any given time you can
only buy one utxo. i guess it should be easy enough for the GUI to sum
the max utxo size, so I will make the depth the theoretical max depth,
summing the entire balances

I also now added automated broadcast of any setprices, which will occur
automatically when you do a buy/sell for the coin you are buying with,
as long as you are not using electrum. to be a bob, you need the native
coin. with the pruning of the orderbook to most recent 2 minutes, it
required the setprice to be called regularly. I have internalized that
so a single setprice is all that is needed. If you want to "cancel" it
you can setprice to 0
etomic
jl777 7 years ago
parent
commit
978d8fc999
  1. 3
      iguana/exchanges/LP_commands.c
  2. 2
      iguana/exchanges/LP_prices.c

3
iguana/exchanges/LP_commands.c

@ -241,15 +241,12 @@ stop()\n\
return(clonestr("{\"error\":\"at least one of coins disabled\"}"));
price = jdouble(argjson,"price");
if ( strcmp(method,"setprice") == 0 )
{
if ( price > SMALLVAL )
{
if ( LP_mypriceset(&changed,base,rel,price) < 0 )
return(clonestr("{\"error\":\"couldnt set price\"}"));
//else if ( LP_mypriceset(&changed,rel,base,1./price) < 0 )
// return(clonestr("{\"error\":\"couldnt set price\"}"));
else return(LP_pricepings(ctx,myipaddr,LP_mypubsock,base,rel,price * LP_profitratio));
} else return(clonestr("{\"error\":\"no price\"}"));
}
else if ( strcmp(method,"autoprice") == 0 )
{

2
iguana/exchanges/LP_prices.c

@ -485,7 +485,7 @@ 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 && LP_pricevalid(price) > 0 && (basepp= LP_priceinfofind(base)) != 0 && (relpp= LP_priceinfofind(rel)) != 0 )
if ( base != 0 && rel != 0 && (basepp= LP_priceinfofind(base)) != 0 && (relpp= LP_priceinfofind(rel)) != 0 )
{
if ( fabs(basepp->myprices[relpp->ind] - price) > SMALLVAL )

Loading…
Cancel
Save