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,16 +1179,18 @@ 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++)
|
||||||
pricedata[i*3+2] = komodo_priceave(tmpbuf,&pricedata[i*3+1],3);
|
// takes previous PRICES_DAYWINDOW correlated price values and calculates smoothed value
|
||||||
|
pricedata[i*3+2] = komodo_priceave(tmpbuf,&pricedata[i*3+1],3);
|
||||||
free(tmpbuf);
|
free(tmpbuf);
|
||||||
return(0);
|
return(0);
|
||||||
}*/
|
}*/
|
||||||
@@ -1315,21 +1320,20 @@ 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)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 3)
|
if (fHelp || params.size() != 3)
|
||||||
throw runtime_error("pricesbet amount leverage \"synthetic-expression\"\n");
|
throw runtime_error("pricesbet amount leverage \"synthetic-expression\"\n");
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
UniValue ret(UniValue::VOBJ);
|
UniValue ret(UniValue::VOBJ);
|
||||||
|
|
||||||
if (ASSETCHAINS_CBOPRET == 0)
|
if (ASSETCHAINS_CBOPRET == 0)
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices");
|
||||||
|
|
||||||
CAmount txfee = 10000;
|
CAmount txfee = 10000;
|
||||||
CAmount amount = atoll(params[0].get_str().c_str());
|
CAmount amount = atoll(params[0].get_str().c_str());
|
||||||
int16_t leverage = (int16_t) atoi(params[1].get_str().c_str());
|
int16_t leverage = (int16_t)atoi(params[1].get_str().c_str());
|
||||||
|
|
||||||
std::string sexpr = params[2].get_str();
|
std::string sexpr = params[2].get_str();
|
||||||
std::vector<std::string> vexpr;
|
std::vector<std::string> vexpr;
|
||||||
@@ -1349,7 +1353,7 @@ UniValue pricesaddfunding(const UniValue& params, bool fHelp)
|
|||||||
{
|
{
|
||||||
if (fHelp || params.size() != 2)
|
if (fHelp || params.size() != 2)
|
||||||
throw runtime_error("pricesaddfunding bettxid amount\n"
|
throw runtime_error("pricesaddfunding bettxid amount\n"
|
||||||
"where amount is in satoshis\n");
|
"where amount is in satoshis\n");
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
UniValue ret(UniValue::VOBJ);
|
UniValue ret(UniValue::VOBJ);
|
||||||
|
|
||||||
@@ -1358,11 +1362,11 @@ UniValue pricesaddfunding(const UniValue& params, bool fHelp)
|
|||||||
|
|
||||||
CAmount txfee = 10000;
|
CAmount txfee = 10000;
|
||||||
uint256 bettxid = Parseuint256(params[0].get_str().c_str());
|
uint256 bettxid = Parseuint256(params[0].get_str().c_str());
|
||||||
if( bettxid.IsNull() )
|
if (bettxid.IsNull())
|
||||||
throw runtime_error("invalid bettxid\n");
|
throw runtime_error("invalid bettxid\n");
|
||||||
|
|
||||||
CAmount amount = atoll(params[1].get_str().c_str());
|
CAmount amount = atoll(params[1].get_str().c_str());
|
||||||
if( amount <= 0 )
|
if (amount <= 0)
|
||||||
throw runtime_error("invalid amount\n");
|
throw runtime_error("invalid amount\n");
|
||||||
|
|
||||||
return PricesAddFunding(txfee, bettxid, amount);
|
return PricesAddFunding(txfee, bettxid, amount);
|
||||||
@@ -1380,7 +1384,7 @@ UniValue pricessetcostbasis(const UniValue& params, bool fHelp)
|
|||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "only -ac_cbopret chains have prices");
|
||||||
|
|
||||||
uint256 bettxid = Parseuint256(params[0].get_str().c_str());
|
uint256 bettxid = Parseuint256(params[0].get_str().c_str());
|
||||||
if( bettxid.IsNull() )
|
if (bettxid.IsNull())
|
||||||
throw runtime_error("invalid bettxid\n");
|
throw runtime_error("invalid bettxid\n");
|
||||||
|
|
||||||
int64_t txfee = 10000;
|
int64_t txfee = 10000;
|
||||||
@@ -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)
|
||||||
@@ -2057,4 +2064,4 @@ void RegisterBlockchainRPCCommands(CRPCTable &tableRPC)
|
|||||||
{
|
{
|
||||||
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
|
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
|
||||||
tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
|
tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user