Course A · Introduction to Quant Finance

Formula sheet

A1 Expectancy: why win rate isn't the point

Expectancy, and why it decides the long run

E = p × W − (1 − p) × L
total ≈ n × E
p* = L ÷ (W + L)
p
the win rate, as a share (0.9 for 90%); 1 − p is the loss rate
W
the average win, in R
L
the average loss, in R, as a positive size (10, not −10)
E
the expectancy: the average result per trade, in R
n
the number of trades
p*
the break-even win rate: the p at which E = 0

A2 Random walks: can prices be predicted?

The random walk and the square-root rule

Pn = P0 + x1 + x2 + … + xn
dn = s × √n
Pn
the price after n steps; P0 is where it started
x1 … xn
the steps, each +s or −s
s
the step size
n
the number of steps (days)
dn
the typical distance from the start after n steps: the square root of the average squared distance (lesson A9 gives it its textbook name, the standard deviation)

A3 What quants do

Expected value after costs

Enet = p × W − (1 − p) × L − c
total ≈ n × Enet
p
the win rate, as a share (0.5 for 50%); 1 − p is the loss rate
W
the average win, in R
L
the average loss, in R, as a positive size (1.1, not −1.1)
c
the cost per trade, in R
Enet
the expected value per trade after costs, in R
n
the number of trades

A4 Probability with coins

Independent chances multiply

P(A and B) = P(A) × P(B)
P(k in a row) = pk
P(the next one, after any streak) = p
P(…)
the chance of what is in the brackets, from 0 (never) to 1 (always)
A, B
two independent events
p
the chance of one event, as a share: ½ for heads, 0.6 for a trading rule that wins 60% of its trades
k
how many in a row
pk
p multiplied by itself k times: (½)3 = ½ × ½ × ½ = ⅛

A4 Probability with coins

How long the longest streak gets

streaks of k or more ≈ n × (½)k
longest streak ≈ log₂ n
n
the number of flips (or of trades that win or lose 50–50)
k
a streak length
log₂ n
the power of 2 that gives n: 210 = 1,024, so log₂ 1,024 = 10

A5 The bell curve

Why the bell keeps appearing

σtotal = σ × √n
σtotal
the standard deviation of the total: how far luck typically puts it from the mean (σ is the Greek letter sigma)
σ
the standard deviation of one trade. A trade that is always +1 or −1 lands exactly 1 from its average of 0, so its σ is 1
n
the number of trades (pegs) added up

A5 The bell curve

How far is far: the z-score

z = (x − μ) ÷ σtotal
x
the result you are judging
μ
the mean of the no-edge bell: 0 here (μ is the Greek letter mu)
σtotal
the standard deviation of the total, from the last step

A6 Fat tails

A fat-tailed curve with a fixed standard deviation

r = σ × t ÷ √(ν ÷ (ν − 2))
t
a draw from Student's t distribution with ν degrees of freedom
ν
"nu", the degrees of freedom, above 2: small for fat tails, large for close to a bell
σ
the standard deviation the days should have (1% in this lesson)
r
the day's return, with standard deviation σ

A6 Fat tails

One number for the tails: excess kurtosis

z = (x − μ) ÷ σ
K = (z1⁴ + z2⁴ + … + zn⁴) ÷ n − 3
x
one return; there are n of them
μ
"mu", the mean (average) of the returns
σ
their standard deviation (given in this lesson's examples; a later lesson, Volatility, works it out)
z
the return's distance from the mean, in standard deviations
K
the excess kurtosis: 0 for a bell, above 0 for fatter tails

A7 Returns, three ways

Simple returns multiply, log returns add

r = P1 ÷ P0 − 1
ℓ = ln(P1 ÷ P0)
r = eℓ − 1   (the way back)
ℓtotal = ℓ1 + ℓ2 + … + ℓn
Pn ÷ P0 = eℓtotal
P0, P1
the price, or the account, at the start and at the end of one period (a day, or a trade)
P1 ÷ P0
the growth factor of that period
r
the simple return, as a decimal: 0.5 is +50%
ℓ
the log return of one period (ℓ is a handwritten l, for log). For small moves ℓ ≈ r: a +1% day (r = 0.01) has ℓ = 0.00995
ln
the natural logarithm: the ln key
ℓ1 … ℓn
the log returns of n periods in a row
ℓtotal
the log return from the first price, P0, to the last, Pn
ex
the eˣ key, which undoes ln (e is a fixed number, about 2.718)

A7 Returns, three ways

The R-multiple

risk = N × (Pbuy − Pstop)
result in R = result ÷ risk
result = result in R × risk
N
the number of shares bought
Pbuy
the buy price
Pstop
the stop: the price at which the trade will sell if it goes wrong
risk
the dollars lost if the price falls to the stop and the trade sells there
result
what the trade made or lost in dollars: what came back minus what went in
result in R
the R-multiple: +2R made twice the risk; −1R lost exactly the risk

A8 Volatility: how wide is luck?

Variance and standard deviation

σ² = [(x1 − μ)² + (x2 − μ)² + … + (xn − μ)²] ÷ n
σ = √σ²
s = √( same sum of squares ÷ (n − 1) )
x1 … xn
the numbers, for example daily returns; n is how many there are
μ
"mu", their mean (average): add them up, divide by n
σ²
the variance, in squared units
σ
"sigma", the standard deviation, in the numbers' own unit
s
the sample standard deviation, for a few numbers standing in for many

A8 Volatility: how wide is luck?

From daily to yearly volatility

σyear = σday × √252
σday
the daily volatility
252
trading days in a year, the count most people agree to use; √252 ≈ 15.87
σyear
the yearly (annualised) volatility

A9 Monte Carlo: answer a question by simulating it

The error of a Monte Carlo answer

error = σ ÷ √N  ·  σ = √(p × (1 − p))
error
the standard error: how far a simulated answer typically lands from the answer that endless runs of the same model would give
N
the number of runs
σ
the standard deviation of one run's score (σ is the Greek letter sigma); for a run that scores 1 or 0 it is √(p × (1 − p))
p
the chance of a hit, as a share: 0.518 for 51.8%

A10 Sample size: why 10 trades say little

How far luck moves an average

σaverage = σ ÷ √n
σaverage
the standard deviation of a sample's average: how far luck typically puts the average of n trades from the true average (textbooks call it the standard error)
σ
the standard deviation of one trade's result (σ is the Greek letter sigma)
n
the sample size: the number of trades in the sample

A10 Sample size: why 10 trades say little

The band for a win rate

band ≈ p ± 100 ÷ √n points
p
the true win rate, in percent
n
the sample size: the number of trades in the sample
100 ÷ √n
the margin of error, in points: how far either side of p the win rates of about 95 samples in 100 land (± means that far above and that far below). A rule of thumb for win rates from about 30% to 70%

A11 Correlation and diversification

Covariance and correlation

cov = [(x1 − μx)(y1 − μy) + … + (xn − μx)(yn − μy)] ÷ (n − 1)
ρ = cov ÷ (sx × sy)
x1 … xn, y1 … yn
the paired numbers, one pair a day; n is how many pairs
μx, μy
"mu", the average: their averages
sx, sy
their sample standard deviations: how far each typically lands from its average, dividing by n − 1
cov
the covariance: the average product of the two distances from the averages, dividing by n − 1
ρ
"rho", the correlation: from −1 to +1; it measures a straight-line link only

A11 Correlation and diversification

The volatility of a 50/50 mix

σmix = √(¼σ1² + ¼σ2² + ½ρσ1σ2)
σ1, σ2
"sigma", the two assets' volatilities: the standard deviations of their returns
ρ
the correlation of their returns
σmix
the volatility of a mix holding half of each, if ρ is the same throughout

A12 Markets and prices

A candle is four numbers

O = p1
H = max(p1, …, pn)
L = min(p1, …, pn)
C = pn
n
the number of trades in the window
p1 … pn
their prices, first to last: p1 is the first trade's price, pn the last one's
max, min
the highest and the lowest of the prices in the brackets
O, H, L, C
the window's open, high, low and close

A12 Markets and prices

The spread and the mid

s = a − b
m = (a + b) ÷ 2
round-trip cost = s × q
a
the ask: the lowest price a waiting seller accepts, which you pay to buy now
b
the bid: the highest price a waiting buyer pays, which you get to sell now
s
the spread, per share
m
the mid, halfway between the bid and the ask
q
the number of shares bought and then sold

A13 Orders: market, limit and stop

The three fill rules

market order:
  fill now, at the other side's best price

limit order at L:
  if the other side's best price is L or better:
      fill, at L or better
  else: wait (it may never fill)

stop order at S:
  if the price has reached S:
      become a market order
  else: wait
the other side's best price
for a buy, the best ask; for a sell, the best bid
L
the limit price. "L or better" means L or lower for a buy, L or higher for a sell
S
the stop price. "Reached S" here means the best bid falls to S or below for a sell stop, or the best ask rises to S or above for a buy stop

A13 Orders: market, limit and stop

Slippage: planned price against filled price

slippage = fill − intended
total slippage = slippage × shares
fill
the price your order actually traded at
intended
the price you planned on: for a stop, the stop price; for a limit, the limit; for a market order, the best price on offer (the ask for a buy, the bid for a sell) when you decided. For a buy a positive slippage is the worse price; for a sell, a negative one
shares
how many shares the order traded

A14 Compounding and the asymmetry of losses

Returns multiply: compounding

end = start × (1 + r1) × (1 + r2) × … × (1 + rn)
compound return = (1 + r1) × … × (1 + rn) − 1
G = 1 ÷ (1 − L) − 1
r1 … rn
each period's return as a decimal: +10% is 0.10, a 10% fall is −0.10
n
the number of periods (months, in the lesson's example)
L
the fall, as a decimal: a 30% fall is 0.30
G
the gain that gets back to the start, as a decimal: 1.00 is +100%

A14 Compounding and the asymmetry of losses

Swings cost growth: volatility drag

g = (end ÷ start)1 ÷ n − 1
g ≈ a − s2 ÷ 2
g
the geometric mean: the growth per period you actually get
end ÷ start
how many times the account multiplied over all n periods
1 ÷ n
the n-th root: the number that, multiplied by itself n times, gives end ÷ start (on a calculator, the x^y key with y = 1 ÷ n)
a
the arithmetic mean: the plain average return per period
s
the swing: how far a typical period's return sits from the average. Its textbook name is the standard deviation (lesson A8, Volatility)
s2
s multiplied by itself
≈
about equal: the rule is an approximation, close when the swings are small

A15 Time value, interest rates and bonds

Present value: bring every amount to today

FV = PV × (1 + r)t
PV = FV ÷ (1 + r)t
PV
the present value: the amount today
FV
the future value: the amount at the later date
r
the interest rate per year, as a decimal: 5% is 0.05
t
the number of years between today and the later date
(1 + r)t
(1 + r) multiplied by itself t times: 1.053 = 1.05 × 1.05 × 1.05 = 1.157625 (on a calculator, the x^y key)

A15 Time value, interest rates and bonds

A bond's price is the sum of its present values

P = C ÷ (1 + y) + C ÷ (1 + y)2 + … + (C + N) ÷ (1 + y)T
P
the bond's price today
C
the coupon, paid at the end of each year
N
the face value: the amount repaid at the end, with the last coupon
T
the number of years left, so the number of payments
y
the yearly rate: the going rate when you work out a price; the yield when the price is given

A16 Costs

What is left after costs, and why more trades make it certain

g = p × W − (1 − p) × L
Average net total = n × (g − c)
σtotal = σ × √n
p* = (L + c) ÷ (W + L)
n
the number of trades
g
the gross edge: the average profit of one trade before costs
p
the win rate: the share of trades that win
c
the cost of one trade, paid win or lose. At c = g the net is $0: the break-even cost
σtotal
luck: the standard deviation of a trader's total, how far it typically lands from the average net total
σ
the standard deviation (sigma) of one trade's result. For a trade that wins or loses the same amount, σ is about that amount (in the lesson's example, $100)
W, L
what a win makes and a loss takes, before costs
p*
the break-even win rate. After costs a win makes W − c and a loss takes L + c. Break-even: p × (W − c) = (1 − p) × (L + c); the c's cancel in the sum, (W − c) + (L + c) = W + L, so p* = (L + c) ÷ (W + L)

A17 Drawdown

Drawdown and maximum drawdown

peakt = the highest of V0, V1, …, Vt
DDt = (peakt − Vt) ÷ peakt
MDD = the largest of DD1, DD2, …, DDn
time under water = (how many DDt are above 0) ÷ n
Vt
the account's value at step t: after month t, or after trade t
V0
the account's starting value, before the first step, when there is one: the €10,000 before trade 1
n
how many steps there are
peakt
the peak at step t: the highest value so far, the starting value and Vt included
DDt
the drawdown at step t, as a decimal: 0.20 is 20%. It is 0 at a new peak
MDD
the maximum drawdown over all n steps

A17 Drawdown

Is the worst still to come?

chance the deepest drawdown is still to come ≈ k ÷ (k + 1)
k
how many times as long as the backtest the trading after it lasts: 750 trades after a 250-trade backtest is k = 3. At k = 1 the chance is 1 ÷ 2: a coin flip
k + 1
the number of equal stretches, the backtest included; each is equally likely to hold the deepest drawdown
≈
about equal: after the backtest, drawdowns that run from one stretch into the next push the chance a little higher

A18 Position sizing

Fixed amount and fixed fraction

fixed amount: Vt = Vt−1 + A × Rt
fixed fraction: Vt = Vt−1 × (1 + f × Rt)
Vt
the account after trade t, with no money added or taken out; V0 is its starting value
Vt−1
the account before trade t
Rt
the result of trade t in R: −1 for a trade sold at its stop, +2 for one that made twice its risk
A
the fixed amount: the money risked on every trade
f
the fixed fraction: the share of the account risked on every trade, as a decimal: 2% is 0.02

A18 Position sizing

From risk to shares

N = (f × V) ÷ (Pbuy − Pstop)
position size = N × Pbuy
N
the number of shares to buy, rounded down to a whole number so the trade never risks more than f × V
V
the account before the trade
f
the share of the account to risk on the trade, as a decimal: 1% is 0.01
f × V
the trade's risk in money
Pbuy
the price paid for one share
Pstop
the stop, below the buy price: the price at which the trade is sold if it goes wrong
Pbuy − Pstop
what one share loses if the trade is sold at its stop, with no gap and no cost

A19 Ruin: why doubling down goes broke

The martingale, for any account

L = 1 + 2 + … + 2k−1 = 2k − 1
P = (½)k, one round in 2k
r = the largest k with 2k − 1 ≤ B
Pbroke = (½)r+1, one round in 2r+1
average of a trade = ½ × s − ½ × s = 0
k
losses in a row, counted from the round's first 1R stake
L
what those k losses lose together, in R
P
the chance that a round starts with k losses in a row, on a fair coin
B
the account at the start of the round, in R
r
the rungs the account pays for in full
Pbroke
the chance a round ends broke: its r rungs and the all-in trade all lose. (If B is exactly 2r − 1, nothing is left for an all-in trade and Pbroke = (½)r.)
s
the stake of one trade, in R

A20 Rules as risk limits

Where each line sits

static line = V0 − M
trailing line = peak − M
daily line = B − D
V0
the account's starting value
M
the maximum loss, in money
peak
the account's highest value so far, its starting value included; it never moves down
B
the account's value when the day began
D
the daily loss limit, in money
line
breached when the account, valued after every finished trade, is at or below it

A20 Rules as risk limits

No edge: which line comes first?

P = M ÷ (T + M)
P
the share of accounts that reach the target first, as a decimal (0.75 is 75 in 100), for a trading rule with no edge and no other way to stop
T
the gain that reaches the target, in money
M
the loss that reaches the maximum loss, in money

A21 What is a backtest?

The recipe of every backtest

r = S × (Psell ÷ Pbuy − 1) − c
Ak = A0 + r1 + … + rk
r
the result of one trade, in dollars (not a percentage)
S
the position size: dollars put into the trade
Pbuy, Psell
the price at the buy and at the sell
c
the costs of that trade
A0
the account at the start
r1 … rk
the first trade's result, the second's, and so on up to the k-th
Ak
the account after k trades: one point of the account line

A22 Regression

Slope and intercept from scratch

b = cov(x, y) ÷ var(x)
a = ȳ − b × x̄
x, y
the paired numbers, n pairs (here the market's and the stock's returns)
x̄, ȳ
their averages
cov(x, y)
the sum of (x − x̄)(y − ȳ), divided by n − 1
var(x)
the sum of (x − x̄)², divided by n − 1: the square of x's standard deviation
b, a
the slope and the intercept of the least-squares line

A22 Regression

R²: the share of the spread the line removes

R² = 1 − [sum of (y − ŷ)²] ÷ [sum of (y − ȳ)²]
ŷ
"y-hat", the line's value, a + b × x; so y − ŷ are its misses
y − ȳ
the distances from y's average: the flat line's misses
R²
for a least-squares line with an intercept, on the data it was fitted to: from 0 (no better than the average) to 1 (every dot on the line); with one input it equals the correlation squared

A23 Forwards, futures and options

Payoffs at the end, and put–call parity

forward, long: S − F  ·  short: F − S
call: max(S − K, 0)  ·  put: max(K − S, 0)
option buyer's result = payoff − premium
max(S − K, 0) − max(K − S, 0) = S − K
S
the price of the underlying on delivery day (forward) or at expiry (option)
F
the forward's agreed price
K
the option's strike: the price at which it lets its buyer buy (call) or sell (put)
premium
what the option's buyer paid the seller up front
max(a, b)
the larger of the two numbers

A25 Getting in, and what to learn next

Average waiting time, one try at a time

Es = 1 + Σj ps→j × Ej, with E = 0 at the goal
one event, chance p each try: E = 1 + (1 − p) × E, so E = 1 ÷ p
s, j
states: the situations that decide what can happen next
Es
the expected waiting time from state s: the average number of tries still needed
ps→j
the chance that one try takes you from state s to state j
Σj
add up over every state j
p
the chance of the event on each try