From 3d2c1ea5e062c92f3b578693d10cd68091e58774 Mon Sep 17 00:00:00 2001 From: dimxy Date: Fri, 19 Apr 2019 03:15:55 +0500 Subject: [PATCH] calc costbasis for firstheight --- src/cc/prices.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 4579371fc..bcd9ee497 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -1038,8 +1038,13 @@ UniValue PricesInfo(uint256 bettxid, int32_t refheight) costbasis = prices_costbasis(bettx, costbasistxid); addedbets = prices_batontxid(batontxid, bettx, bettxid); - bool calcCostbasis = costbasis == 0 ? true : false; - if ((profits = prices_syntheticprofits(calcCostbasis, costbasis, firstheight, refheight, leverage, vec, positionsize, addedbets)) < 0) + if( costbasis == 0 && prices_syntheticprofits(true, costbasis, firstheight, firstheight, leverage, vec, positionsize, addedbets) < 0) { + result.push_back(Pair("result", "error")); + result.push_back(Pair("error", "cannot calculate costbasis")); + return(result); + } + + if ((profits = prices_syntheticprofits(false, costbasis, firstheight, refheight, leverage, vec, positionsize, addedbets)) < 0) { result.push_back(Pair("rekt", 1)); result.push_back(Pair("rektfee", (positionsize + addedbets) / 500));