From 5a66a5bc6ab212c708635adfd2aedf5fd6e9497a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 29 Sep 2016 12:47:12 -0300 Subject: [PATCH] test --- basilisk/basilisk_swap.c | 2 +- basilisk/basilisk_tradebot.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 7031bc857..9a9ff0819 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -1869,6 +1869,7 @@ void basilisk_swaploop(void *_swap) for (i=0; i<32; i++) printf("%02x",swap->pubB1.bytes[i]); printf(" <- pubB1\n");*/ + basilisk_txlog(myinfo,swap,0,-1); if ( swap->I.iambob != 0 ) { if ( basilisk_bobscripts_set(myinfo,swap,1,1) < 0 ) @@ -1901,7 +1902,6 @@ void basilisk_swaploop(void *_swap) { swap->I.statebits |= basilisk_swapdata_rawtxsend(myinfo,swap,0x80,data,maxlen,&swap->myfee,0x40); iguana_unspents_mark(myinfo,swap->I.iambob!=0?swap->bobcoin:swap->alicecoin,swap->myfee.vins); - basilisk_txlog(myinfo,swap,0,-1); basilisk_txlog(myinfo,swap,&swap->myfee,-1); } else diff --git a/basilisk/basilisk_tradebot.c b/basilisk/basilisk_tradebot.c index d1df0d80d..558f03d3c 100755 --- a/basilisk/basilisk_tradebot.c +++ b/basilisk/basilisk_tradebot.c @@ -17,7 +17,7 @@ void basilisk_swap_balancingtrade(struct supernet_info *myinfo,struct basilisk_swap *swap,int32_t iambob) { // update balance, compare to target balance, issue balancing trade via central exchanges, if needed - double price,volume,srcamount,destamount,profitmargin,dir=0.; + double price,volume,srcamount,destamount,profitmargin,dir=0.,dotrade=1.; char base[64],rel[64]; srcamount = swap->I.req.srcamount; destamount = swap->I.req.destamount; profitmargin = (double)swap->I.req.profitmargin / 1000000.; @@ -26,14 +26,17 @@ void basilisk_swap_balancingtrade(struct supernet_info *myinfo,struct basilisk_s printf("illegal amount for balancing %f %f\n",srcamount,destamount); return; } + strcpy(rel,"BTC"); if ( strcmp(swap->I.req.src,"BTC") == 0 ) { + strcpy(base,swap->I.req.dest); price = (srcamount / destamount); volume = destamount / SATOSHIDEN; dir = -1.; } else if ( strcmp(swap->I.req.dest,"BTC") == 0 ) { + strcpy(base,swap->I.req.src); price = (destamount / srcamount); volume = srcamount / SATOSHIDEN; dir = 1.; @@ -46,6 +49,9 @@ void basilisk_swap_balancingtrade(struct supernet_info *myinfo,struct basilisk_s if ( iambob != 0 ) { printf("BOB: price %f * vol %f -> %s newprice %f margin %.2f%%\n",price,volume,dir < 0. ? "buy" : "sell",price + dir * price * profitmargin,100*profitmargin); + if ( dir < 0. ) + InstantDEX_buy(myinfo,0,0,0,"poloniex",base,rel,price,volume,dotrade); + else InstantDEX_sell(myinfo,0,0,0,"poloniex",base,rel,price,volume,dotrade); } else {