From 87571e8457baa577388c461ac6355d42f18696b3 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 27 Apr 2019 15:37:58 +0500 Subject: [PATCH] corr totalbets normalization --- src/cc/prices.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 620188ddb..b18a25243 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -1343,12 +1343,14 @@ UniValue PricesInfo(uint256 bettxid, int32_t refheight) int64_t equity = totalbets + totalprofits; std::cerr << "PricesInfo() " << " totalbets=" << (totalbets / PRICES_NORMFACTOR) << std::endl; - if (totalbets / PRICES_NORMFACTOR != 0) //prevent zero div - costbasis /= (totalbets / PRICES_NORMFACTOR); + if (totalbets != 0) { //prevent zero div + costbasis /= totalbets; + costbasis /= PRICES_NORMFACTOR; //denormalization + } else costbasis = 0; int64_t liqprice; - if (leverage != 0) + if (leverage != 0) // prevent zero div liqprice = costbasis - costbasis / leverage; else liqprice = 0;