diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index e68d4fbc..631cd945 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -33,7 +33,7 @@ import { sellBet } from '../lib/firebase/api-call' import { ConfirmationButton } from './confirmation-button' import { OutcomeLabel, YesLabel, NoLabel } from './outcome-label' -type BetSort = 'newest' | 'profit' | 'resolved' +type BetSort = 'newest' | 'profit' | 'resolved' | 'value' export function BetsList(props: { user: User }) { const { user } = props @@ -41,7 +41,7 @@ export function BetsList(props: { user: User }) { const [contracts, setContracts] = useState([]) - const [sort, setSort] = useState('profit') + const [sort, setSort] = useState('value') useEffect(() => { const loadedBets = bets ? bets : [] @@ -104,6 +104,8 @@ export function BetsList(props: { user: User }) { contracts, (c) => -1 * (contractsCurrentValue[c.id] - contractsInvestment[c.id]) ) + } else if (sort === 'value') { + sortedContracts = _.sortBy(contracts, (c) => -contractsCurrentValue[c.id]) } const [resolved, unresolved] = _.partition( @@ -161,6 +163,7 @@ export function BetsList(props: { user: User }) { value={sort} onChange={(e) => setSort(e.target.value as BetSort)} > + @@ -280,6 +283,10 @@ export function MyBetsSummary(props: { calculatePayout(contract, bet, 'NO') ) + const p = getProbability(contract.totalShares) + + const expectation = p * yesWinnings + (1 - p) * noWinnings + const marketWinnings = _.sumBy(excludeSales, (bet) => calculatePayout(contract, bet, 'MKT') ) @@ -330,6 +337,14 @@ export function MyBetsSummary(props: { payoutCol ) : ( <> + +
+ Expectation +
+
+ {formatMoney(expectation)} +
+
Payout if