From eb515ba1ab6ba953638191fc206b90a17edd9668 Mon Sep 17 00:00:00 2001 From: dimxy Date: Sat, 27 Apr 2019 13:32:07 +0500 Subject: [PATCH] add norm to average costbasis --- src/cc/prices.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 4c83fd72b..da1098d50 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -1337,12 +1337,12 @@ UniValue PricesInfo(uint256 bettxid, int32_t refheight) for (auto b : bets) { totalbets += b.amount; totalprofits += b.profits; - costbasis += b.amount * b.costbasis; + costbasis += b.amount * b.costbasis / PRICES_NORMFACTOR; // prevent overflow std::cerr << "PricesInfo() acc costbasis=" << costbasis << " b.amount=" << b.amount << " b.costbasis=" << b.costbasis << std::endl; } int64_t equity = totalbets + totalprofits; - costbasis /= totalbets; + costbasis /= totalbets * PRICES_NORMFACTOR; int64_t liqprice = costbasis - costbasis / leverage;