diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index 30f81cec..7af046c5 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -33,7 +33,7 @@ import { ConfirmationButton } from './confirmation-button' import { OutcomeLabel, YesLabel, NoLabel } from './outcome-label' import { filterDefined } from '../../common/util/array' -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)} > + @@ -287,6 +290,9 @@ 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') ) @@ -337,6 +343,14 @@ export function MyBetsSummary(props: { payoutCol ) : ( <> + {/* +
+ Expectation +
+
+ {formatMoney(expectation)} +
+ */}
Payout if diff --git a/web/pages/home.tsx b/web/pages/home.tsx index 802493d5..1568b778 100644 --- a/web/pages/home.tsx +++ b/web/pages/home.tsx @@ -30,6 +30,10 @@ export async function getStaticProps() { listAllFolds().catch(() => []), ]) + // TODO(James): Remove this line. We are filtering out non-binary contracts so that + // branches other than free-response work. + contracts = contracts.filter((contract) => contract.outcomeType === 'BINARY') + const [contractBets, contractComments] = await Promise.all([ Promise.all(contracts.map((contract) => listAllBets(contract.id))), Promise.all(contracts.map((contract) => listAllComments(contract.id))),