From 0aea4588a4a389c1a1ad2298ed29ae73b5e5d71f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Aug 2015 23:49:18 -0500 Subject: [PATCH 1/2] test --- libjl777/plugins/InstantDEX/InstantDEX_main.c | 5 +++-- libjl777/plugins/InstantDEX/orderbooks.h | 20 +++++++++---------- libjl777/plugins/common/prices777.c | 2 +- libjl777/plugins/includes/portable777.h | 3 ++- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/libjl777/plugins/InstantDEX/InstantDEX_main.c b/libjl777/plugins/InstantDEX/InstantDEX_main.c index f501a9e6..209385b6 100644 --- a/libjl777/plugins/InstantDEX/InstantDEX_main.c +++ b/libjl777/plugins/InstantDEX/InstantDEX_main.c @@ -315,7 +315,7 @@ char *InstantDEX(char *jsonstr,char *remoteaddr,int32_t localaccess) retstr = InstantDEX_tradesequence(json); else if ( strcmp(method,"makebasket") == 0 ) { - if ( (prices= prices777_makebasket(0,json,1)) != 0 ) + if ( (prices= prices777_makebasket(0,json,1,"basket")) != 0 ) retstr = clonestr("{\"result\":\"basket made\"}"); else retstr = clonestr("{\"error\":\"couldnt make basket\"}"); } @@ -486,13 +486,14 @@ void init_exchanges(cJSON *json) find_exchange(0,INSTANTDEX_NXTAEUNCONF); find_exchange(0,INSTANTDEX_NXTAENAME); find_exchange(0,INSTANTDEX_BASKETNAME); + find_exchange(0,INSTANTDEX_ACTIVENAME); for (i=0; i>>>> (%s/%s).%s %llu %llu\n",refbase,refrel,"basket",(long long)refbaseid,(long long)refrelid); - InstantDEX_name(key,&keysize,"basket",refname,refbase,&refbaseid,refrel,&refrelid); + printf(">>>>> (%s/%s).%s %llu %llu\n",refbase,refrel,typestr,(long long)refbaseid,(long long)refrelid); + InstantDEX_name(key,&keysize,typestr,refname,refbase,&refbaseid,refrel,&refrelid); if ( addbasket != 0 ) { - prices777_addbundle(&valid,0,0,"basket",refbaseid,refrelid); - printf("<<<<< valid.%d refname.(%s) (%s/%s).%s %llu %llu\n",valid,refname,refbase,refrel,"basket",(long long)refbaseid,(long long)refrelid); + prices777_addbundle(&valid,0,0,typestr,refbaseid,refrelid); + printf("<<<<< valid.%d refname.(%s) (%s/%s).%s %llu %llu\n",valid,refname,refbase,refrel,typestr,(long long)refbaseid,(long long)refrelid); } else valid = 0; if ( valid >= 0 ) { - if ( (prices = prices777_createbasket(addbasket,refname,refbase,refrel,refbaseid,refrelid,basket,n)) != 0 ) + if ( (prices = prices777_createbasket(addbasket,refname,refbase,refrel,refbaseid,refrelid,basket,n,typestr)) != 0 ) { if ( addbasket != 0 ) BUNDLE.ptrs[BUNDLE.num++] = prices; @@ -1026,7 +1026,7 @@ char *prices777_activebooks(char *name,char *_base,char *_rel,uint64_t baseid,ui cJSON *basketjson,*array,*item,*item2; struct prices777 *active; uint64_t mgwbase,mgwrel; int32_t inverted,exchangeid; char numstr[64],base[64],rel[64],*retstr = 0; strcpy(base,_base), strcpy(rel,_rel); - if ( (active= prices777_find(&inverted,baseid,relid,"basket")) == 0 ) + if ( (active= prices777_find(&inverted,baseid,relid,(tradeable != 0) ? "active" : "basket")) == 0 ) { basketjson = cJSON_CreateObject(), array = cJSON_CreateArray(); jaddstr(basketjson,"name",name), jaddstr(basketjson,"base",base), jaddstr(basketjson,"rel",rel); @@ -1062,7 +1062,7 @@ char *prices777_activebooks(char *name,char *_base,char *_rel,uint64_t baseid,ui } } jadd(basketjson,"basket",array); - if ( (active= prices777_makebasket(0,basketjson,1)) != 0 ) + if ( (active= prices777_makebasket(0,basketjson,1,(tradeable != 0) ? "active" : "basket")) != 0 ) { prices777_basket(active,maxdepth); retstr = prices777_orderbook_jsonstr(0,SUPERNET.my64bits,active,&active->O,maxdepth,allflag); diff --git a/libjl777/plugins/common/prices777.c b/libjl777/plugins/common/prices777.c index 7505c152..82c2af5c 100644 --- a/libjl777/plugins/common/prices777.c +++ b/libjl777/plugins/common/prices777.c @@ -899,7 +899,7 @@ struct prices777 *prices777_poll(char *_exchangestr,char *_name,char *_base,uint if ( valid >= 0 ) { _set_assetname(&mult,name,0,refbaseid), strcat(name,"/"), _set_assetname(&mult,name+strlen(name),0,refrelid); - BUNDLE.ptrs[BUNDLE.num++] = prices = prices777_createbasket(1,name,_base,_rel,refbaseid,refrelid,basket,2); + BUNDLE.ptrs[BUNDLE.num++] = prices = prices777_createbasket(1,name,_base,_rel,refbaseid,refrelid,basket,2,"basket"); //prices->lastprice = prices777_basket(prices,MAX_DEPTH); printf("updating basket(%s) lastprice %f changed.%p %d\n",prices->contract,prices->lastprice,&prices->changed,prices->changed); printf("B total polling.%d added.(%s) (%s/%s) {%s && %s}\n",BUNDLE.num,prices->contract,_base,_rel,firstprices->contract,basket[1].prices->contract); diff --git a/libjl777/plugins/includes/portable777.h b/libjl777/plugins/includes/portable777.h index a260304b..cc01829c 100644 --- a/libjl777/plugins/includes/portable777.h +++ b/libjl777/plugins/includes/portable777.h @@ -163,6 +163,7 @@ void set_best_amounts(uint64_t *baseamountp,uint64_t *relamountp,double price,do #define INSTANTDEX_NXTAENAME "nxtae" #define INSTANTDEX_NXTAEUNCONF "unconf" #define INSTANTDEX_BASKETNAME "basket" +#define INSTANTDEX_ACTIVENAME "active" #define INSTANTDEX_EXCHANGEID 0 #define INSTANTDEX_UNCONFID 1 #define INSTANTDEX_NXTAEID 2 @@ -224,7 +225,7 @@ char *prices777_activebooks(char *name,char *base,char *rel,uint64_t baseid,uint struct prices777 *prices777_initpair(int32_t needfunc,double (*updatefunc)(struct prices777 *prices,int32_t maxdepth),char *exchange,char *base,char *rel,double decay,char *name,uint64_t baseid,uint64_t relid,int32_t basketsize); double prices777_price_volume(double *volumep,uint64_t baseamount,uint64_t relamount); -struct prices777 *prices777_makebasket(char *basketstr,cJSON *basketjson,int32_t addbasket); +struct prices777 *prices777_makebasket(char *basketstr,cJSON *basketjson,int32_t addbasket,char *typestr); char *InstantDEX(char *jsonstr,char *remoteaddr,int32_t localaccess); //cJSON *prices777_InstantDEX_json(char *_base,char *_rel,int32_t depth,int32_t invert,int32_t localaccess,uint64_t *baseamountp,uint64_t *relamountp,struct InstantDEX_quote *iQ,uint64_t refbaseid,uint64_t refrelid,uint64_t jumpasset); uint64_t calc_baseamount(uint64_t *relamountp,uint64_t assetid,uint64_t qty,uint64_t priceNQT); From b789db009b8b0aa685d1f9c55d690c0679f133aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Aug 2015 23:58:24 -0500 Subject: [PATCH 2/2] test --- libjl777/Makefile.win64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libjl777/Makefile.win64 b/libjl777/Makefile.win64 index 6db95276..0c258932 100644 --- a/libjl777/Makefile.win64 +++ b/libjl777/Makefile.win64 @@ -19,7 +19,7 @@ endif PATH := $(PWD)/mxe/usr/bin:$(PATH) -PLIBS := ../libs/libjl777-win64.a ../libs/libminiupnpc-win64.a ../libs/libnanomsg-win64.a -lpthread -lcurl -lm -liphlpapi -lws2_32 -lwsock32 ../libs/libmman.a -lz -lssp -D_win64 -DNN_EXPORTS -DNN_HAVE_MINGW -DNN_HAVE_WINDOWS -DNN_USE_LITERAL_IFADDR=1 -DSTATICLIB -DCURL_STATICLIB +PLIBS := -DMINGW_HAS_SECURE_API=1 ../libs/libjl777-win64.a ../libs/libminiupnpc-win64.a ../libs/libnanomsg-win64.a -lpthread -lcurl -lm -liphlpapi -lws2_32 -lwsock32 ../libs/libmman.a -lz -lssp -D_win64 -DNN_EXPORTS -DNN_HAVE_MINGW -DNN_HAVE_WINDOWS -DNN_USE_LITERAL_IFADDR=1 -DSTATICLIB -DCURL_STATICLIB LIBS= libs/libjl777-win64.a libs/libnanomsg-win64.a libs/libminiupnpc-win64.a -lpthread -lcurl -lm -liphlpapi -lws2_32 -lwsock32 libs/libmman.a -lz -lssp