From bc454e89ba928a32484f95dff0e03efe3af86fa9 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Wed, 12 Jan 2022 23:43:07 -0600 Subject: [PATCH] calculateMoneyRatio --- common/calculate.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/calculate.ts b/common/calculate.ts index b8a88012..5c169367 100644 --- a/common/calculate.ts +++ b/common/calculate.ts @@ -69,12 +69,17 @@ export function calculateRawShareValue( } export function calculateMoneyRatio(contract: Contract) { - const { totalShares, pool } = contract + const { totalShares, phantomShares, pool } = contract const [yesShares, noShares] = [totalShares.YES, totalShares.NO] + const { YES: yesFake, NO: noFake } = phantomShares const actual = pool.YES + pool.NO - const expected = Math.sqrt(yesShares ** 2 + noShares ** 2) - return actual / expected + + const expected = Math.sqrt( + (yesShares - yesFake) ** 2 + (noShares - noFake) ** 2 + ) + + return expected === 0 ? 0 : actual / expected } export function calculateShareValue(contract: Contract, bet: Bet) {