calculateMoneyRatio

This commit is contained in:
mantikoros 2022-01-13 20:52:03 -06:00
parent 1c74afd741
commit 3cffccdd3f

View File

@ -69,15 +69,11 @@ export function calculateRawShareValue(
} }
export function calculateMoneyRatio(contract: Contract) { export function calculateMoneyRatio(contract: Contract) {
const { totalShares, phantomShares, pool } = contract const { totalShares, pool } = contract
const [yesShares, noShares] = [totalShares.YES, totalShares.NO] const p = getProbability(totalShares)
const { YES: yesFake, NO: noFake } = phantomShares
const actual = pool.YES + pool.NO const actual = pool.YES + pool.NO
const expected = p * contract.totalBets.YES + (1 - p) * contract.totalBets.NO
const expected = Math.sqrt(
(yesShares - yesFake) ** 2 + (noShares - noFake) ** 2
)
return expected === 0 ? 0 : actual / expected return expected === 0 ? 0 : actual / expected
} }