Quantitative Finance
in Python
PART I
I Observing Prices
I Pricing Theory
I Derivatives
I Black-Scholes model
PART I PART II
I Derivatives
I Black-Scholes model
Some teaching, a lot of coding . . .
Key concepts:
- asset - arbitrage
• stocks
• bonds
• commodities
LA >>> display financial quotes
• commodities
Forward = agreement to trade in the future
Characteristics:
Example:
Characteristics:
Example:
Example:
Example:
• no transaction fees,
• no bid-ask spread,
• no dividends,
• no cost of carry.
Recap.. .
• asset,
• derivative,
• arbitrage,
Key concepts:
Note:
• scale-free → comparable
Observations suggest:
ri ∼ N (µi , σi2 )
Model the log-returns as normally distributed
Observations suggest:
ri ∼ N (µi , σi2 )
Remarks:
Observations suggest:
• log-returns,
• LogNormal model.
I.III Pricing Theory
I.III Pricing Theory
Key concepts:
1
Here, the discounting factor is Φr (0, 1) = 1.05 .
How much would you pay to play?
• £10 if head,
• £0 if tail.
£3 = (£5) − (£2)
Interpreting the price in a risk-neutral world
Interpretation 1:
£3 = (£5) − (£2)
£3 = (£5) − (£2)
Interpretation 2:
With it, you can price any asset depending on the same source
of randomness and guarantee there will not be an arbitrage.
Example: introducing another game. . .
Now what?
uS0 Vu
S0 Φr 1 V0
dS0 Vd
Replication in a simple market model. . .
Model the evolution over one time-step a stock, a bank account and
a derivative as:
uS0 Vu
S0 Φr 1 V0
dS0 Vd
αuS0 + β
αS0 + βΦr
αdS0 + β
Replication in a simple market model. . . 2
αuS0 + β Vu
αS0 + βΦr V0
αdS0 + β Vd
Then, V0 = α? S0 + β ? Φr .
Replication in a simple market model. . . 2
αuS0 + β Vu
αS0 + βΦr V0
αdS0 + β Vd
Then, V0 = α? S0 + β ? Φr .
• discounting,
• risk-neutral probabilities,
• risk-neutral pricing,
• replication pricing.
I.IV Derivatives
I.IV Derivatives
Key concepts:
VTfwd = (ST − K)
Recall that
• unlimited upside
• limited downside
• bullish
Characterising the long forward
• unlimited upside
• limited downside
• bullish
The payoff is also used to compute the price (on the board)
Options = right to buy/sell
Call
• unlimited upside
• no downside
• bullish
VTcall = max{ST − K, 0}
Characterising options
• unlimited upside
• no downside
• bullish
VTcall = max{ST − K, 0}
Payoff curve for the put
Characterising options
• no downside • no downside
• bullish • bearish
• no downside • no downside
• bullish • bearish
Consider a call...
Consider a call...
You have £10k to invest. Assume you invest everything in either the
call or the underlying and that, at maturity, the spot price is at £1k.
What was the best choice?
Example: a golden call 2
Scenario 1: investment in the underlying
Long call and short put with the same strike and expiry then:
Long call and short put with the same strike and expiry then:
Therefore, if you can price a call, you can also price a put:
• payoff curve,
• leverage,
• put-call parity.
I.V Black-Scholes model
I.V Black-Scholes model
Key concepts:
E? [St+τ ]
= exp(rτ )
St
Modification: µ → r − 0.5σ 2
The LogNormal model in the risk-neutral world
LogNormal model:
St+τ
∼ LogNormal(µτ, σ 2 τ )
St
E? [St+τ ]
= exp(rτ )
St
• Risk-neutral price:
• Risk-neutral price:
with Z x
1 1 2
F (x) = √ exp − t dt
2π −∞ 2
log(St /K) + (r ± 0.5σ 2 )τ
d1,2 = √
σ τ
and τ = (T − t).
LA >>> coding Black-Scholes
√
and d1,2 = (log(St /K) + (r ± 0.5σ 2 )τ )/σ τ , use norm.cdf for F.
The Greeks: a way to quantify risk
Defined as:
∂V V(S + ∆S) − V(S)
∆= ≈
∂S ∆S
Defined as:
∂V V(S + ∆S) − V(S)
∆= ≈
∂S ∆S
Current workflow:
log-returns
Using Black-Scholes to get the implied volatility
Current workflow:
log-returns Volatility
Using Black-Scholes to get the implied volatility
Current workflow:
Current workflow:
Current workflow:
Current workflow:
24
22
Implied Volatility [%]
20
18
Workarounds?
Workarounds?
Workarounds?
• Black-Scholes formula,
• implied volatility,
• volatility smile.
PART II – The binomial model
PART II – The binomial model
Key concepts:
- calibrating a BT
Binomial tree = market as a branching process
uS0
S0
dS0
Binomial tree = market as a branching process
u2 S0
uS0
S0 udS0
dS0
d2 S0
Binomial tree = market as a branching process
u2 S0 p2
uS0 p
S0 udS0 1 2pq
dS0 q
d2 S0 q2
Φ−1
r (t, t + ∆t) − d exp(r∆t) − d
p? = = .
u−d u−d
Pricing with a BT? use risk-neutral pricing. . . 2
104.04
102
100 100.98
99
98.01
Example: European call in a BT 2
104.04 5.04
100.98 1.98
98.01 0.00
Example: European call in a BT 3
1−d
• risk neutral probability: p? = u−d = 31 ,
1−d
• risk neutral probability: p? = u−d = 31 ,
5.04
3.00
1.98 1.44
0.66
0.00
Forward
100
[ 99. 102.]
[ 98.01 100.98 104.04]
Backward
[ 0. 1.98 5.04]
[ 0.66 3. ]
1.44
Set u, d so that BT matches LogNormal model
√ 1
u = exp(σ ∆t), and d = ,
u
the BT converges to the same LogNormal model than the one
observed empirically, in the risk-neutral world.
Recap.. .
• recombining BT,
• calibration of a BT,
Key concepts:
• more flexible
Pricing in a TT = similar than in BT
Vi+1,j Vi+1,j+1
Vi,j Vi,j+1
Vi−1,j Vi−1,j+1
V:j = T V:j+1
where V:j refers to the jth column of the grid and T is a tridiagonal
matrix. You may recognise the particular form of a finite-difference
solver used to solve Partial differential equations (PDE).
The Black-Scholes PDE for pricing. . .
• solving the PDE yields the full evolution of the price of the
option.
• crucial to be competitive!
Recap.. .
• recombining TT,
Spot Price