corr errors after rebase
added comments
This commit is contained in:
@@ -101,7 +101,7 @@ int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
|
|||||||
int8_t komodo_segid(int32_t nocache,int32_t height);
|
int8_t komodo_segid(int32_t nocache,int32_t height);
|
||||||
int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight);
|
int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight);
|
||||||
char *komodo_pricename(char *name,int32_t ind);
|
char *komodo_pricename(char *name,int32_t ind);
|
||||||
int32_t komodo_priceind(char *symbol);
|
int32_t komodo_priceind(const char *symbol);
|
||||||
int32_t komodo_pricesinit();
|
int32_t komodo_pricesinit();
|
||||||
int64_t komodo_priceave(int64_t *tmpbuf,int64_t *correlated,int32_t cskip);
|
int64_t komodo_priceave(int64_t *tmpbuf,int64_t *correlated,int32_t cskip);
|
||||||
int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth);
|
int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth);
|
||||||
|
|||||||
@@ -2448,6 +2448,7 @@ int32_t komodo_priceind(const char *symbol)
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns price value which is in a 10% interval for more than 50% points for the preceding 24 hours
|
||||||
int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth)
|
int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth)
|
||||||
{
|
{
|
||||||
int32_t i,j,k,n,iter,correlation,maxcorrelation=0; int64_t firstprice,price,sum,den,mult,refprice,lowprice,highprice;
|
int32_t i,j,k,n,iter,correlation,maxcorrelation=0; int64_t firstprice,price,sum,den,mult,refprice,lowprice,highprice;
|
||||||
@@ -2486,7 +2487,7 @@ int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int
|
|||||||
//fprintf(stderr,"%.1f ",(double)price/10000);
|
//fprintf(stderr,"%.1f ",(double)price/10000);
|
||||||
sum += price;
|
sum += price;
|
||||||
correlation++;
|
correlation++;
|
||||||
if ( correlation > (PRICES_DAYWINDOW>>1) )
|
if ( correlation > (PRICES_DAYWINDOW>>1) ) // if there are more than 50% raw price values lay within +/-5% interval from the refprice picked from random pos
|
||||||
{
|
{
|
||||||
if ( nonzprices == 0 )
|
if ( nonzprices == 0 )
|
||||||
return(refprice * mult);
|
return(refprice * mult);
|
||||||
|
|||||||
@@ -43,6 +43,9 @@
|
|||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
|
#include "cc/CCinclude.h"
|
||||||
|
#include "cc/CCPrices.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
|
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
|
||||||
@@ -1165,7 +1168,7 @@ UniValue paxprice(const UniValue& params, bool fHelp)
|
|||||||
return(-1);
|
return(-1);
|
||||||
for (i=0; i<width; i++)
|
for (i=0; i<width; i++)
|
||||||
{
|
{
|
||||||
if ( (n= komodo_heightpricebits(&ignore,rawprices,firstheight + numblocks - 1 - i)) < 0 )
|
if ( (n= komodo_heightpricebits(&ignore,rawprices,firstheight + numblocks - 1 - i)) < 0 ) // stores raw prices in backward order
|
||||||
return(-1);
|
return(-1);
|
||||||
if ( numpricefeeds < 0 )
|
if ( numpricefeeds < 0 )
|
||||||
numpricefeeds = n;
|
numpricefeeds = n;
|
||||||
@@ -1176,15 +1179,17 @@ UniValue paxprice(const UniValue& params, bool fHelp)
|
|||||||
ptr[1] = rawprices[0]; // timestamp
|
ptr[1] = rawprices[0]; // timestamp
|
||||||
}
|
}
|
||||||
rngval = seed;
|
rngval = seed;
|
||||||
for (i=0; i<numblocks+PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH; i++)
|
for (i=0; i<numblocks+PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH; i++) // calculates +PRICES_DAYWINDOW more correlated values
|
||||||
{
|
{
|
||||||
rngval = (rngval*11109 + 13849);
|
rngval = (rngval*11109 + 13849);
|
||||||
ptr = (uint32_t *)&pricedata[i*3];
|
ptr = (uint32_t *)&pricedata[i*3];
|
||||||
if ( (pricedata[i*3+1]= komodo_pricecorrelated(rngval,ind,(uint32_t *)&pricedata[i*3],6,0,PRICES_SMOOTHWIDTH)) < 0 )
|
// takes previous PRICES_DAYWINDOW raw prices and calculates correlated price value
|
||||||
|
if ( (pricedata[i*3+1]= komodo_pricecorrelated(rngval,ind,(uint32_t *)&pricedata[i*3],6,0,PRICES_SMOOTHWIDTH)) < 0 ) // skip is 6 == sizeof(int64_t)/sizeof(int32_t)*3
|
||||||
return(-3);
|
return(-3);
|
||||||
}
|
}
|
||||||
tmpbuf = (int64_t *)calloc(sizeof(int64_t),2*PRICES_DAYWINDOW);
|
tmpbuf = (int64_t *)calloc(sizeof(int64_t),2*PRICES_DAYWINDOW);
|
||||||
for (i=0; i<numblocks; i++)
|
for (i=0; i<numblocks; i++)
|
||||||
|
// takes previous PRICES_DAYWINDOW correlated price values and calculates smoothed value
|
||||||
pricedata[i*3+2] = komodo_priceave(tmpbuf,&pricedata[i*3+1],3);
|
pricedata[i*3+2] = komodo_priceave(tmpbuf,&pricedata[i*3+1],3);
|
||||||
free(tmpbuf);
|
free(tmpbuf);
|
||||||
return(0);
|
return(0);
|
||||||
@@ -1315,7 +1320,6 @@ UniValue prices(const UniValue& params, bool fHelp)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t komodo_d_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight);
|
|
||||||
// pricesbet rpc implementation
|
// pricesbet rpc implementation
|
||||||
UniValue pricesbet(const UniValue& params, bool fHelp)
|
UniValue pricesbet(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
@@ -1388,6 +1392,7 @@ UniValue pricessetcostbasis(const UniValue& params, bool fHelp)
|
|||||||
return PricesSetcostbasis(txfee, bettxid);
|
return PricesSetcostbasis(txfee, bettxid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pricescashout rpc implementation
|
||||||
UniValue pricescashout(const UniValue& params, bool fHelp)
|
UniValue pricescashout(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
@@ -1407,6 +1412,7 @@ UniValue pricescashout(const UniValue& params, bool fHelp)
|
|||||||
return PricesCashout(txfee, bettxid);
|
return PricesCashout(txfee, bettxid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pricesrekt rpc implementation
|
||||||
UniValue pricesrekt(const UniValue& params, bool fHelp)
|
UniValue pricesrekt(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 2)
|
if (fHelp || params.size() != 2)
|
||||||
@@ -1428,6 +1434,7 @@ UniValue pricesrekt(const UniValue& params, bool fHelp)
|
|||||||
return PricesRekt(txfee, bettxid, height);
|
return PricesRekt(txfee, bettxid, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UniValue gettxout(const UniValue& params, bool fHelp)
|
UniValue gettxout(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 2 || params.size() > 3)
|
if (fHelp || params.size() < 2 || params.size() > 3)
|
||||||
|
|||||||
Reference in New Issue
Block a user