Browse Source

Test

etomic
jl777 8 years ago
parent
commit
88d4fbe3c7
  1. 11
      iguana/exchanges/LP_commands.c
  2. 9
      iguana/exchanges/LP_nativeDEX.c
  3. 2
      iguana/exchanges/LP_network.c
  4. 31
      iguana/exchanges/LP_portfolio.c
  5. 6
      iguana/exchanges/goal

11
iguana/exchanges/LP_commands.c

@ -96,6 +96,8 @@ char *stats_JSON(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,char *r
available localhost RPC commands:\n \
setprice(base, rel, price)\n\
autoprice(base, rel, price, margin, type)\n\
autofill(base, rel, price, relvolume)\n\
goal(coin, perc)\n\
myprice(base, rel)\n\
enable(coin)\n\
disable(coin)\n\
@ -108,6 +110,7 @@ swapstatus()\n\
swapstatus(requestid, quoteid)\n\
public API:\n \
getcoins()\n\
portfolio()\n\
getpeers()\n\
getutxos()\n\
getutxos(coin, lastn)\n\
@ -180,6 +183,12 @@ trust(pubkey, trust)\n\
return(clonestr("{\"error\":\"couldnt set autoprice\"}"));
else return(clonestr("{\"result\":\"success\"}"));
}
else if ( strcmp(method,"autofill") == 0 )
{
if ( LP_autofill(base,rel,price,jdouble(argjson,"relvolume")) < 0 )
return(clonestr("{\"error\":\"couldnt set autofill\"}"));
else return(clonestr("{\"result\":\"success\"}"));
}
else if ( strcmp(method,"myprice") == 0 )
{
if ( LP_myprice(&bid,&ask,base,rel) > SMALLVAL )
@ -259,7 +268,7 @@ trust(pubkey, trust)\n\
}
else if ( strcmp(method,"goal") == 0 )
{
return(LP_portfolio_goal(coin,jdouble(argjson,"goal")));
return(LP_portfolio_goal(coin,jdouble(argjson,"perc")));
}
}
else if ( strcmp(method,"swapstatus") == 0 )

9
iguana/exchanges/LP_nativeDEX.c

@ -19,21 +19,14 @@
//
// new features:
// stats
// autofill
// autoutxo
// fixes:
// -wiftaddr and no flag for importprivkey (XVG)
// -avoid redundant importprivkey
// -put Atxfee and Btxfee into rememberfiles
// bugs:
// false detection of bobreclaim
// unduplicated bugs:
// swap cancel should cleanly cancel
// multiple smartaddresses? enable/disable causes? 250 KMD bounty
// verify bid volumes
// multiple smartaddresses? enable/disable causes?
#include <stdio.h>
#include "LP_include.h"

2
iguana/exchanges/LP_network.c

@ -134,7 +134,7 @@ void queue_loop(void *ignore)
if ( duplicate > 0 )
{
LP_Qfound++;
if ( (LP_Qenqueued % 10) == 0 )
if ( (LP_Qfound % 10) == 0 )
printf("found.%u Q.%d err.%d match.%d\n",ptr->crc32,LP_Qenqueued,LP_Qerrors,LP_Qfound);
flag = 1;
}

31
iguana/exchanges/LP_portfolio.c

@ -64,7 +64,7 @@ uint64_t LP_balance(uint64_t *valuep,int32_t iambob,char *symbol,char *coinaddr)
char *LP_portfolio()
{
double goalsum = 0.; uint64_t kmdsum = 0; int32_t iter; cJSON *retjson,*array; struct iguana_info *coin,*tmp;
double strongest = 0.,goalsum = 0.; uint64_t kmdsum = 0; int32_t iter; cJSON *retjson,*array; struct iguana_info *coin,*tmp,*strongestcoin=0;
array = cJSON_CreateArray();
retjson = cJSON_CreateObject();
for (iter=0; iter<2; iter++)
@ -97,6 +97,11 @@ char *LP_portfolio()
if ( (coin->force= (coin->goalperc - coin->perc)) < 0. )
coin->force *= -coin->force;
else coin->force *= coin->force;
if ( fabs(coin->force) > fabs(strongest) )
{
strongest = coin->force;
strongestcoin = coin;
}
} else coin->goalperc = coin->force = 0.;
jaddi(array,LP_portfolio_entry(coin));
}
@ -104,6 +109,11 @@ char *LP_portfolio()
}
jaddstr(retjson,"result","success");
jaddnum(retjson,"kmd_equiv",dstr(kmdsum));
if ( strongestcoin != 0 )
{
jaddstr(retjson,"strongest",strongestcoin->symbol);
jaddnum(retjson,"force",strongest);
}
jadd(retjson,"portfolio",array);
return(jprint(retjson,1));
}
@ -118,7 +128,7 @@ char *LP_portfolio_goal(char *symbol,double goal)
} else return(clonestr("{\error\":\"cant set goal for inactive coin\"}"));
}
int32_t LP_autoprices;
int32_t LP_autoprices,LP_autofills;
int32_t LP_autofill(char *base,char *rel,double maxprice,double totalrelvolume)
{
@ -127,6 +137,7 @@ int32_t LP_autofill(char *base,char *rel,double maxprice,double totalrelvolume)
{
basepp->maxprices[relpp->ind] = maxprice;
basepp->relvols[relpp->ind] = totalrelvolume;
LP_autofills++;
return(0);
}
return(-1);
@ -344,6 +355,22 @@ void prices_loop(void *ignore)
}
}
}
if ( LP_autofills > 0 )
{
char *strongest; struct iguana_info *coin;
if ( (retstr= LP_portfolio()) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( (strongest= jstr(retjson,"strongest")) != 0 && (coin= LP_coinfind(strongest)) != 0 )
{
printf("strongest.%s force %f\n",strongest,jdouble(retjson,"force"));
}
free_json(retjson);
}
free(retstr);
}
}
sleep(60);
}
}

6
iguana/exchanges/goal

@ -1,4 +1,4 @@
source userpass
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"goal\",\"coin\":\"KMD\",\"goal\":99}"
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"goal\",\"coin\":\"BTC\",\"goal\":10}"
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"goal\",\"coin\":\"REVS\",\"goal\":1}"
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"goal\",\"coin\":\"KMD\",\"perc\":99}"
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"goal\",\"coin\":\"BTC\",\"perc\":10}"
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"goal\",\"coin\":\"REVS\",\"perc\":1}"

Loading…
Cancel
Save