From a3d045234a8e4e49985077319ccd6b7b7fdd4f5d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Dec 2016 15:15:03 +0200 Subject: [PATCH] test --- iguana/dpow/dpow_network.c | 2 +- iguana/iguana_exchanges.c | 50 ++++++++++++++++++++++++++++---------- iguana/main.c | 2 +- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 6f2895f6b..7587de146 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -442,7 +442,7 @@ void dpow_bestconsensus(struct dpow_block *bp) bp->notaries[bp->myind].bestk = bp->bestk = bestks[besti]; //printf("set best.%d to (%d %llx) recv.%llx\n",best,bp->bestk,(long long)bp->bestmask,(long long)recvmask); } - bp->recvmask = recvmask; + bp->recvmask |= recvmask; if ( bp->bestmask == 0 )//|| (time(NULL) / 180) != bp->lastepoch ) { bp->bestmask = dpow_notarybestk(bp->recvmask,bp,&bp->bestk); diff --git a/iguana/iguana_exchanges.c b/iguana/iguana_exchanges.c index 47384fbc2..697e45484 100755 --- a/iguana/iguana_exchanges.c +++ b/iguana/iguana_exchanges.c @@ -22,16 +22,18 @@ //char *Exchange_names[] = { "poloniex", "bittrex", "btc38", "huobi", "bitstamp", "bitfinex", "btce", "coinbase", "okcoin", "lakebtc", "quadriga", "truefx", "ecb", "instaforex", "fxcm", "yahoo" }; -int32_t instantdex_updatesources(struct exchange_info *exchange,struct exchange_quote *sortbuf,int32_t n,int32_t max,int32_t ind,int32_t dir,struct exchange_quote *quotes,int32_t numquotes) +int32_t instantdex_updatesources(struct exchange_info *exchange,struct exchange_quote *sortbuf,int32_t n,int32_t max,int32_t ind,int32_t dir,struct exchange_quote *quotes,int32_t numquotes,double offset) { int32_t i; struct exchange_quote *quote; - printf("instantdex_updatesources.%s update dir.%d numquotes.%d\n",exchange->name,dir,numquotes); + //printf("instantdex_updatesources.%s update dir.%d numquotes.%d offset %.6f\n",exchange->name,dir,numquotes,offset); for (i=0; iprice,quote->volume); if ( quote->price > SMALLVAL ) { + //printf("%s n.%d ind.%d i.%d dir.%d price %.8f vol %.8f offset %.6f\n",exchange->name,n,ind,i,dir,quote->price+offset,quote->volume,offset); + quote->price += offset; + quote->satoshis = quote->price * SATOSHIDEN; sortbuf[n] = *quote; sortbuf[n].val = ind; sortbuf[n].exchangebits = exchange->exchangebits; @@ -45,7 +47,7 @@ int32_t instantdex_updatesources(struct exchange_info *exchange,struct exchange_ double instantdex_aveprice(struct supernet_info *myinfo,struct exchange_quote *sortbuf,int32_t max,double *totalvolp,char *base,char *rel,double basevolume,cJSON *argjson) { - char *str; double totalvol,pricesum; uint32_t timestamp; + char *str; double totalvol,pricesum,hblas[64][2],refbid,refask; uint32_t timestamp; struct exchange_quote quote; int32_t i,n,dir,num,depth = 100; struct exchange_info *exchange; struct exchange_request *req,*active[64]; if ( myinfo == 0 ) @@ -86,33 +88,55 @@ double instantdex_aveprice(struct supernet_info *myinfo,struct exchange_quote *s } } } - for (i=0; inumbids > 0 && active[i]->numasks > 0 ) + for (i=0; inumbids > 0 && active[i]->numasks > 0 ) + { + hblas[i][0] = active[i]->bidasks[0].price; + hblas[i][1] = active[i]->bidasks[1].price; + if ( active[i]->exchange != 0 && strcmp("poloniex",active[i]->exchange->name) == 0 ) + refbid = active[i]->bidasks[0].price, refask = active[i]->bidasks[1].price; + //printf("(%6f %.6f) ",hblas[i][0],hblas[i][1]); + } } + //printf(" refbid %.6f refask %.7f\n",refbid,refask); + if ( refbid != 0. && refask != 0. ) + { + for (i=0; inumbids > 0 ) - n = instantdex_updatesources(active[i]->exchange,sortbuf,n,max,i,1,active[i]->bidasks,active[i]->numbids); + n = instantdex_updatesources(active[i]->exchange,sortbuf,n,max,i,1,active[i]->bidasks,active[i]->numbids,hblas[i][0]); else if ( dir > 0 && active[i]->numasks > 0 ) - n = instantdex_updatesources(active[i]->exchange,sortbuf,n,max,i,-1,&active[i]->bidasks[1],active[i]->numasks); + n = instantdex_updatesources(active[i]->exchange,sortbuf,n,max,i,-1,&active[i]->bidasks[1],active[i]->numasks,hblas[i][1]); } - printf("numexchanges.%d dir.%d %s/%s numX.%d n.%d\n",myinfo->numexchanges,dir,base,rel,num,n); + //printf("numexchanges.%d dir.%d %s/%s numX.%d n.%d\n",myinfo->numexchanges,dir,base,rel,num,n); if ( dir < 0 ) revsort64s(&sortbuf[0].satoshis,n,sizeof(*sortbuf)); else sort64s(&sortbuf[0].satoshis,n,sizeof(*sortbuf)); - for (totalvol=pricesum=i=0; iexchange->name,pricesum/totalvol,totalvol); + //printf("dir.%d i.%d of %d %12.8f vol %.8f %s | aveprice %.8f total vol %.8f\n",dir,i,n,sortbuf[i].price,quote.volume,active[quote.val]->exchange->name,pricesum/totalvol,totalvol); } } if ( totalvol > 0. ) diff --git a/iguana/main.c b/iguana/main.c index a6710261a..81d0500b0 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -1627,7 +1627,7 @@ void iguana_main(void *arg) myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("coinbase"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("lakebtc"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("quadriga"),0); - myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("okcoin"),0); + // prices reversed? myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("okcoin"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("btce"),0); myinfo->tradingexchanges[myinfo->numexchanges++] = exchange_create(clonestr("bitstamp"),0); #endif