The math of edge
“Edge” is not a vibe — it is a number. It is the expected value of one trade, measured in units of risk. This chapter defines it precisely, shows why it is invisible until you have taken many trades, and then confronts the harder question the beginner never asks: given a real edge, how much should you bet? The answers are less aggressive than intuition suggests.
R-multiples — the unit of edge#
Dollars are a bad unit for comparing trades, because a $500 win on a $5,000 risk is nothing like a $500 win on a $50 risk. The fix is the R-multiple: express every outcome as a multiple of the amount you risked on that trade ( = your initial stop distance in dollars).
A trade stopped out for its full risk is ; one that makes three times its risk is . R-multiples make trades of different sizes and different instruments directly comparable, and they are the native language of edgekit.metrics — trade_stats takes an array of per-trade R and gives you everything else.
Expectancy#
Suppose a strategy wins with probability , and on a win it makes (in R) while on a loss it gives back (in R, positive). Its expectancy is the expected R per trade:
Model one trade as a random variable that takes the value with probability and with probability . By the definition of expected value — the probability-weighted sum of the outcomes —
Short proof via linearity. Write the outcome with two indicator variables, , where on a win and otherwise. The expectation of an indicator is just the probability of its event, . Linearity of expectation — , which holds with no independence assumption — then gives .
Why it matters for trading. The formula is exact for a single trade and assumes nothing about independence or identical distribution — those enter only when you average many trades (below). So expectancy is well-defined even for a strategy whose trades are correlated or whose payoff shape drifts; it is the one number that tells you whether the game is worth playing at all.
This is the single most important formula in trading. It is just the expected value from Probability & distributions applied to a trade. If you have an edge; if no amount of clever money management can save you. edgekit reports this as ev_r.
| Win rate p | Avg win W | Avg loss L | Expectancy E[R] | Edge? |
|---|---|---|---|---|
| 0.40 | 2.0R | 1.0R | +0.20R | Yes — low win rate, big winners |
| 0.60 | 1.0R | 1.0R | +0.20R | Yes — same edge, different shape |
| 0.70 | 0.5R | 1.5R | −0.10R | No — high win rate, still loses |
| 0.50 | 1.0R | 1.0R | 0.00R | Coin flip — no edge |
Payoff ratio#
The payoff ratio is the average win divided by the average loss. It lets you find the breakeven win rate for any payoff — the win rate at which :
Breakeven is the win rate at which the edge vanishes, so set and solve for :
Why it matters for trading. This is the bar the real hit rate must clear after costs. Costs act by shrinking every and enlarging every , which lowers and raises — the reason a gross edge so often turns into a net loss. Choosing a target R is therefore not a preference; it is a commitment to beat a specific, computable win rate.
With a 2:1 payoff you only need to win a third of the time to break even; with a 1:2 payoff you need to win two-thirds. This is the trade-off every strategy design negotiates: wider targets buy you a lower required win rate but a lower hit rate to go with it. In edgekit, an ORB(or_bars=30, target_r=2.0) is picking a 2R payoff and therefore a ~33% breakeven — everything hinges on whether the real hit rate clears it once costs are paid.
The law of large numbers#
Expectancy is a statement about the average of many trades — and here is the catch that ruins undercapitalised traders: over a small number of trades, expectancy is invisible. The law of large numbers says the sample average converges to the true expectancy only as the number of trades grows:
Assume the trades are independent with common mean and variance . Linearity gives (the sample average is unbiased), and because variance of independent sums adds,
A random variable with a fixed mean and a variance collapsing to zero concentrates on that mean (Chebyshev: ). That is the weak law. Why it matters for trading: the standard error of your measured edge shrinks only as — the square-root-of-n law. Halving your uncertainty needs four times the trades; a edge with per-trade noise needs on the order of a hundred trades before the signal clears the noise. This is precisely why a losing month tells you almost nothing.
The word converges hides a slow, noisy reality. A genuine edge can sit underwater for dozens of trades in a row; a losing streak of 8–10 is routine even for a good system. Early on, luck dominates skill — the running average staggers around before it settles. This is the mathematical reason a losing month tells you almost nothing.

Random walks and the martingale baseline#
What does no edge look like in the language of probability? It is a martingale: a process whose best forecast of its next value, given everything you know, is simply its current value.
A price that is a pure random walk is a martingale, and it is a theorem (the optional-stopping theorem) that no trading rule — no stop, target, or clever entry timing — can manufacture positive expectancy from a martingale: every strategy inherits before costs, and a loss after them. An edge is precisely a departure from the martingale property: means the game, in your direction, is a submartingale — the conditional expectation drifts up, not flat. Everything in this course is an attempt to establish, honestly, that a given series is not a martingale.
The Kelly criterion#
Given a real edge, how much of your capital should you risk per trade? Bet too little and you leave growth on the table; bet too much and volatility drag (from Returns & compounding) — or ruin — eats you alive. The Kelly criterion is the bet fraction that maximises the long-run geometric growth rate. For a payoff ratio and win probability :
Why log growth? Because wealth compounds multiplicatively: after bets your capital is a product of per-bet multipliers, and the log turns that product into a sum whose long-run average is governed by the law of large numbers. Maximising the expected log return per bet, , therefore maximises the long-rungeometric growth rate. Let the per-unit outcome be on a win (probability ) and on a loss (probability ), and stake fraction :
Differentiate and set to zero (the game is concave in , so this is the max):
Collect the terms — the right-side factors combine:
The second derivative everywhere, confirming is a maximum, not a saddle. Notice the numerator is exactly the expectancy per unit staked: no edge, no bet.
Full Kelly maximises the expected log-growth, but it says nothing about its variance, which at is punishingly large — full-Kelly equity swings routinely halve the account. Because is concave, a second-order expansion around the optimum,
shows growth falls off only quadratically as you back away from while volatility falls linearly. That asymmetry is the whole case for fractional Kelly: betting keeps roughly three-quarters of the growth for about half the volatility. Since and are themselvesestimated with the sampling error above, betting a fraction also hedges the very real chance you have over-estimated your edge.
The numerator is just the expectancy per unit staked, so Kelly scales your bet with your edge and shrinks it with the payoff’s riskiness. A strategy with and gives — risk 10% of capital per bet to grow fastest. The growth-rate curve peaks at and falls off on both sides; push past it and growth actually turns negative despite the positive edge.

Why full-Kelly is too aggressive#
Nobody serious bets full Kelly. Three reasons, all fatal in practice:
- The curve is flat on top but a cliff on the right. Half-Kelly captures about 75% of the growth for roughly half the volatility — a wonderful trade. Over-betting is punished far more harshly than under-betting.
- Your edge is estimated, not known. and come from a finite sample with the standard error of the last chapter. If you have over-estimated your edge, full-Kelly on the true (smaller) edge is already over-betting.
- Full-Kelly drawdowns are brutal. The expected worst drawdown at full Kelly routinely exceeds 50% — deeper than almost any real account (or prop-firm rule) can tolerate.
The standard practice is fractional Kelly — a quarter to a half of . edgekit sidesteps the fragile point-estimate of Kelly entirely for deployment: rather than bet a fraction of a guessed edge, edgekit.sizing sizes against a hard drawdown budget, which is the constraint that actually binds a real account.
from edgekit import trade_stats, sizing
# 1) measure the edge, in R
st = trade_stats(trades.r, dates=trades.date)
print(st["ev_r"], st["win_rate"], st["pf"]) # is E[R] > 0 with enough trades?
# 2) size to a drawdown budget rather than a full-Kelly guess
res = sizing.size_to_dd(daily_r, dd_budget=0.095, account=100_000)
res["dollar_per_r"] # dollars to risk per 1R so historical max DD == 9.5%
res["binding"] # which constraint set the sizeRisk of ruin#
The flip side of Kelly. Risk of ruin is the probability that a string of losses drags your account below a threshold you cannot come back from — before the edge has time to pay out. For a simplified even-money game with win probability and units of capital, the classic gambler’s-ruin result is:
Track capital in whole units and let be the probability of eventual ruin (hitting ) starting from units, with win probability and loss probability per bet. Condition on the first bet — this is first-step analysis, an application of the law of total probability:
This linear recurrence has characteristic equation , whose roots are and . The general solution is therefore . With a positive edge the ruin probability must stay bounded and tend to as capital grows, forcing ; the boundary forces . Hence , and starting from units,
Why it matters for trading. A drawdown limit — a prop-firm rule, or the level below which you quit — is exactly a lower absorbing barrier on this walk. The exponent is how many units of risk your capital represents, and you set it with bet size: risk 1% per trade and ; risk 10% and . Because ruin decays geometrically in , over-betting shrinks the exponent and drives — a positive edge with too large a bet is almost sure to be ruined before the law of large numbers can pay it out. Edge sets the base ; sizing sets the exponent — and the exponent wins.
Two levers control it: the size of your edge ( above 0.5) and how many units of risk your capital represents (, which you set by bet size). Even a solid edge combined with an over-sized bet gives a frightening probability of ruin — and once ruined, the positive expectancy is worthless because you are no longer in the game.

Next: we have the math to define and size an edge — so why do so many backtests show edges that evaporate live? Why most backtests lie.


