From 9ae73e9219fac7bfbfd35860503faf2b52143aeb Mon Sep 17 00:00:00 2001 From: dimxy Date: Fri, 3 May 2019 10:43:07 +0500 Subject: [PATCH] added COSTBASIS_PERIOD var --- src/cc/prices.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 0b7c8a873..cefc8c4e0 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -1086,16 +1086,19 @@ int64_t prices_syntheticprice(std::vector vec, int32_t height, int32_t int32_t prices_syntheticprofits(int64_t &costbasis, int32_t firstheight, int32_t height, int16_t leverage, std::vector vec, int64_t positionsize, int64_t &profits, int64_t &outprice) { int64_t price; +#ifndef TESTMODE + const int32_t COSTBASIS_PERIOD = PRICES_DAYWINDOW; +#else + const int32_t COSTBASIS_PERIOD = 7; +#endif + if (height < firstheight) { fprintf(stderr, "requested height is lower than bet firstheight.%d\n", height); return -1; } -#ifndef TESTMODE - int32_t minmax = (height < firstheight + PRICES_DAYWINDOW); // if we are within 24h then use min or max value -#else - int32_t minmax = (height < firstheight + 7); // if we are within 24h then use min or max value -#endif + + int32_t minmax = (height < firstheight + COSTBASIS_PERIOD); // if we are within 24h then use min or max value if ((price = prices_syntheticprice(vec, height, minmax, leverage)) < 0) { @@ -1122,12 +1125,12 @@ int32_t prices_syntheticprofits(int64_t &costbasis, int32_t firstheight, int32_t //} } else { - if (height == firstheight + PRICES_DAYWINDOW) { + if (height == firstheight + COSTBASIS_PERIOD) { // if costbasis not set, just set it //costbasis = price; // use calculated minmax costbasis - std::cerr << "prices_syntheticprofits() use permanent costbasis=" << costbasis << " height=" << height << std::endl; + std::cerr << "prices_syntheticprofits() use permanent costbasis=" << costbasis << " at height=" << height << std::endl; } }