Normalize all prices

This commit is contained in:
jl777
2019-04-02 02:05:27 -11:00
parent 041bf3b1aa
commit b5af10d99f
2 changed files with 6 additions and 5 deletions

View File

@@ -2228,15 +2228,16 @@ int64_t komodo_pricesmoothed(int64_t *correlated,int32_t numprices)
return(correlated[0]);
}
int64_t komodo_pricecorrelated(uint32_t *rawprices,int32_t numprices)
int64_t komodo_pricecorrelated(int32_t ind,uint32_t *rawprices,int32_t numprices)
{
int32_t i; int64_t price,sum = 0;
for (i=0; i<numprices; i++)
{
if ( (price= rawprices[i]) == 0 )
return(0);
//fprintf(stderr,"%.0f ",(double)price/10000);
sum += price * 10000;
if ( ind >= 36 )
price *= 10000;
sum += price;
}
//fprintf(stderr," ave %.8f [%d]\n",((double)sum/numprices)/COIN,numprices);
return(sum / numprices);

View File

@@ -1246,8 +1246,8 @@ UniValue prices(const UniValue& params, bool fHelp)
smoothed = komodo_pricesmoothed(&correlated[i],daywindow);
UniValue parr(UniValue::VARR);
parr.push_back(ValueFromAmount((int64_t)prices[offset]));
parr.push_back(ValueFromAmount(correlated[i]/10000));
parr.push_back(ValueFromAmount(smoothed/10000));
parr.push_back(ValueFromAmount(correlated[i]));
parr.push_back(ValueFromAmount(smoothed));
p.push_back(parr);
}
item.push_back(Pair("prices",p));