diff --git a/iguana/exchanges/LP_stats.c b/iguana/exchanges/LP_stats.c index 02ef164f0..4478b00ba 100644 --- a/iguana/exchanges/LP_stats.c +++ b/iguana/exchanges/LP_stats.c @@ -516,26 +516,30 @@ struct LP_ohlc double high,low,open,close,relsum,basesum; }; -cJSON *LP_ohlc_json(struct LP_ohlc *bar) +cJSON *LP_ohlc_json(struct LP_ohlc *bar,struct LP_ohlc *prevbar) { - cJSON *item; - //if ( bar->numtrades != 0 && bar->relsum > SMALLVAL && bar->basesum > SMALLVAL ) + cJSON *item; struct LP_ohlc tmp; + memset(&tmp,0,sizeof(tmp)); + if ( bar->numtrades == 0 ) { - item = cJSON_CreateArray(); - jaddinum(item,bar->timestamp); - jaddinum(item,bar->high); - jaddinum(item,bar->low); - jaddinum(item,bar->open); - jaddinum(item,bar->close); - jaddinum(item,bar->relsum); - jaddinum(item,bar->basesum); - if ( bar->basesum != 0 ) - jaddinum(item,bar->relsum / bar->basesum); - else jaddinum(item,0); - jaddinum(item,bar->numtrades); - return(item); - } - return(0); + tmp = *prevbar; + tmp.numtrades = 0; + tmp.relsum = tmp.basesum = 0.; + } else tmp = *bar; + bar = &tmp; + item = cJSON_CreateArray(); + jaddinum(item,bar->timestamp); + jaddinum(item,bar->high); + jaddinum(item,bar->low); + jaddinum(item,bar->open); + jaddinum(item,bar->close); + jaddinum(item,bar->relsum); + jaddinum(item,bar->basesum); + if ( bar->basesum != 0 ) + jaddinum(item,bar->relsum / bar->basesum); + else jaddinum(item,0); + jaddinum(item,bar->numtrades); + return(item); } void LP_ohlc_update(struct LP_ohlc *bar,uint32_t timestamp,double basevol,double relvol) @@ -567,7 +571,7 @@ void LP_ohlc_update(struct LP_ohlc *bar,uint32_t timestamp,double basevol,double cJSON *LP_tradesarray(char *base,char *rel,uint32_t starttime,uint32_t endtime,int32_t timescale) { - struct LP_ohlc *bars; cJSON *array,*item,*statsjson,*swaps; uint32_t timestamp; bits256 zero; int32_t i,n,numbars,bari; + struct LP_ohlc *bars,nonz; cJSON *array,*item,*statsjson,*swaps; uint32_t timestamp; bits256 zero; int32_t i,n,numbars,bari; if ( timescale < 60 ) return(cJSON_Parse("{\"error\":\"one minute is shortest timescale\"}")); memset(zero.bytes,0,sizeof(zero)); @@ -596,9 +600,16 @@ cJSON *LP_tradesarray(char *base,char *rel,uint32_t starttime,uint32_t endtime,i free_json(statsjson); } array = cJSON_CreateArray(); + memset(&nonz,0,sizeof(nonz)); for (bari=0; bari 0 ) + nonz = bars[bari]; + } + } free(bars); return(array); } diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 599794ddc..9579c5474 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -427,7 +427,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) { struct LP_address *ap; struct LP_address_utxo *up,*tmp; int32_t i,n,m,vout,height; cJSON *array,*item,*txobj; int64_t value; bits256 txid; uint32_t now; LP_address(coin,coin->smartaddr); - printf("call listunspent issue %s (%s)\n",coin->symbol,coin->smartaddr); + //printf("call listunspent issue %s (%s)\n",coin->symbol,coin->smartaddr); LP_listunspent_issue(coin->symbol,coin->smartaddr,2); if ( (ap= LP_addressfind(coin,coin->smartaddr)) == 0 ) { @@ -463,7 +463,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin) printf("couldnt find just added %s/%d ht.%d %.8f\n",bits256_str(str,txid),vout,height,dstr(value)); else m++; } - printf("added %d from listunspents\n",m); + //printf("added %d from listunspents\n",m); } free_json(array); }