From 978d8fc999a8ec07b6278f1ef6be1eb51b1e106e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 27 Oct 2017 12:31:25 +0300 Subject: [PATCH] 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 --- iguana/exchanges/LP_commands.c | 13 +++++-------- iguana/exchanges/LP_prices.c | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 312d97813..731b0a835 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -242,14 +242,11 @@ stop()\n\ 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\"}")); + 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 if ( strcmp(method,"autoprice") == 0 ) { diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 167e08236..cf9679bf3 100644 --- a/iguana/exchanges/LP_prices.c +++ b/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 )