> ## Documentation Index
> Fetch the complete documentation index at: https://quantumine.net/learn/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This library is published in two languages with the same paths: English at https://quantumine.net/learn/<path> and Vietnamese at https://quantumine.net/learn/vi/<path>. Add .md to either address for the Markdown version.
> llms.txt and llms-full.txt list the English pages only. When the reader writes in Vietnamese, read and cite the Vietnamese page.
> To search the library, connect to the MCP server at https://quantumine.net/learn/mcp. Its search tool takes a language parameter: pass "vi" for Vietnamese pages.
> The library is licensed under CC BY 4.0: it may be quoted, reused and used to train models. Credit Quantumine and link to the page you used.

# Expected value

> Expected value (EV) is the average profit or loss per bet: EV = p × W − (1 − p) × L. Roulette and lotteries have a negative EV because the house sets both the probability and the payout.

Expected value (EV) is the average profit or loss per bet if you repeat the same bet a great many times:

$$
\text{EV} = p \times W - (1 - p) \times L
$$

$p$ is the probability of winning, $W$ the amount you win, and $L$ the amount you lose.

## Is trading gambling?

Work out the expected value of one roulette bet. You put 10 USD on 27, a straight-up bet, on an American wheel with 38 pockets (the numbers 1 to 36, a 0 and a 00). If the ball lands on 27, the casino [pays 35 to 1](https://en.wikipedia.org/wiki/Roulette), so you win 350 USD; otherwise you lose your 10 USD. The ball lands on 27 with probability 1/38:

$$
\text{EV} = (1/38) \times 350 - (37/38) \times 10 \approx -0.53
$$

Each 10 USD bet loses 0.53 USD on average, 5.26% of the stake. A legal lottery does no better: [Pennsylvania's rules for Powerball](https://www.law.cornell.edu/regulations/pennsylvania/61-Pa-Code-SS-871-22) allocate 50% of gross sales to the prize pool, so the average ticket buyer loses half of what the tickets cost.

At roulette or a lottery you can change neither the probability nor the payout. The house fixes both so that it always comes out ahead, and your EV is always below 0.

Trading is different: no one fixes those two numbers for you. Your win rate and your RR (reward to risk, $\text{RR} = W / L$, the average win divided by the average loss) depend on the strategy you use. EV is zero when $\text{RR} = (1 - p) / p$: that is the breakeven line on the chart below, and every strategy is a point on the chart. A strategy that wins 50% of its trades needs RR = 1 to break even, one that wins 40% needs RR = 1.5, and one that wins 25% needs RR = 3.

So is trading gambling? It depends on where you stand on the chart. Below the breakeven line, or without knowing where you stand, you are trading no differently from gambling. Above the line, you are a profitable trader.

## Why do some traders still lose with a positive EV?

Say a strategy wins 35% of its trades, makes 200 USD on each winner and loses 100 USD on each loser. It sits above the breakeven line (RR = 2), and its EV is +5 USD per trade. The chart below simulates 100 people who trade this strategy, 1,000 trades each, and draws each person's PnL (cumulative profit and loss).

> [tab] Simulation

> [tab] Python code
>
> ```python theme={null}
> import random
> from math import comb
>
> WIN_PCT, AVG_WIN, AVG_LOSS = 35, 200, 100
>
> def simulate(n_trades, rng):
>     equity, path = 0, [0]
>     for _ in range(n_trades):
>         equity += AVG_WIN if rng.random() < WIN_PCT / 100 else -AVG_LOSS
>         path.append(equity)
>     return path
>
> rng = random.Random(11)
> paths = [simulate(1000, rng) for _ in range(100)]
> print(sum(path[-1] < 0 for path in paths))   # people who are down after 1,000 trades in this run: 10
>
> def prob_still_losing(n_trades):
>     """Probability that the account is down after n_trades trades."""
>     losing = sum(
>         comb(n_trades, wins) * WIN_PCT**wins * (100 - WIN_PCT) ** (n_trades - wins)
>         for wins in range(n_trades + 1)
>         if wins * AVG_WIN - (n_trades - wins) * AVG_LOSS < 0
>     )
>     return losing / 100**n_trades
>
> for n in (100, 1000, 4400):
>     print(n, round(prob_still_losing(n) * 100, 2))   # probability of being down (%): 38.03, 13.68, 0.99
> ```

A positive EV does not rule out a loss: by chance, an unlucky trader can still be down. After 1,000 trades, about 14 of every 100 people are still losing, and that share falls below 1% only at about 4,400 trades. This is the [law of large numbers](https://quantumine.net/learn/learn/foundations/law-of-large-numbers.md): the more trades, the closer the average profit per trade comes to the EV.

Probabilistic thinking means judging a strategy over a whole series of trades, not on one trade or one month. If the position size is too large for the account, the account can blow up before the law of large numbers has time to work.

## Read next

> [card] [Backtesting](https://quantumine.net/learn/learn/backtesting.md)
>
> Estimating a strategy's expected value from historical data.

> [card] [Portfolio and risk](https://quantumine.net/learn/learn/portfolio-risk.md)
>
> How much capital to put into each trade to survive a losing streak.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.