From 41f5437f09c0f98b36004c482962d1d0c9bd5c93 Mon Sep 17 00:00:00 2001 From: dimxy Date: Fri, 19 Apr 2019 14:26:14 +0500 Subject: [PATCH] define for 10000 factor added --- src/cc/CCPrices.h | 1 + src/cc/prices.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cc/CCPrices.h b/src/cc/CCPrices.h index 62da19aab..1402a995c 100644 --- a/src/cc/CCPrices.h +++ b/src/cc/CCPrices.h @@ -34,6 +34,7 @@ int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblo #define PRICES_MMD (KOMODO_MAXPRICES * 6) // 0011 0000 0000 0000 #define PRICES_MMM (KOMODO_MAXPRICES * 7) // 0011 1000 0000 0000 #define PRICES_DDD (KOMODO_MAXPRICES * 8) // 0100 0000 0000 0000 +#define PRICES_NORMFACTOR 10000 bool PricesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 51f4d7ddf..4454c4d0d 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -630,8 +630,8 @@ int64_t prices_syntheticprofits(int64_t &costbasis, int32_t firstheight, int32_t } // clear lowest positions: - price /= 10000; - price *= 10000; + price /= PRICES_NORMFACTOR; + price *= PRICES_NORMFACTOR; if (minmax) { // if we are within day window, set costbasis to max or min price value if (leverage > 0 && price > costbasis) { @@ -655,17 +655,17 @@ int64_t prices_syntheticprofits(int64_t &costbasis, int32_t firstheight, int32_t } - profits = costbasis > 0 ? ( ((price / 10000 * SATOSHIDEN) / costbasis) - SATOSHIDEN / 10000 ) : 0; - std::cerr << "prices_syntheticprofits() (price /10000 * SATOSHIDEN)=" << (price /10000 * SATOSHIDEN) << std::endl; - std::cerr << "prices_syntheticprofits() (price /10000 * SATOSHIDEN)/costbasis=" << (price /10000 * SATOSHIDEN)/costbasis << std::endl; + profits = costbasis > 0 ? ((price / PRICES_NORMFACTOR * SATOSHIDEN) / costbasis) - SATOSHIDEN / PRICES_NORMFACTOR : 0; + std::cerr << "prices_syntheticprofits() test value1 (price/PRICES_NORMFACTOR * SATOSHIDEN)=" << (price / PRICES_NORMFACTOR * SATOSHIDEN) << std::endl; + std::cerr << "prices_syntheticprofits() test value2 (price/PRICES_NORMFACTOR * SATOSHIDEN)/costbasis=" << (price / PRICES_NORMFACTOR * SATOSHIDEN)/costbasis << std::endl; - std::cerr << "prices_syntheticprofits() profits1=" << profits << std::endl; + std::cerr << "prices_syntheticprofits() fract profits=" << profits << std::endl; //std::cerr << "prices_syntheticprofits() profits double=" << (double)price / (double)costbasis -1.0 << std::endl; //double dprofits = (double)price / (double)costbasis - 1.0; profits *= leverage * positionsize; //dprofits *= leverage * positionsize; - std::cerr << "prices_syntheticprofits() profits2=" << profits << std::endl; + std::cerr << "prices_syntheticprofits() val profits=" << profits << std::endl; //std::cerr << "prices_syntheticprofits() dprofits=" << dprofits << std::endl;