Python Programming in Finance
Futures & Options
Zheng-Liang Lu
Department of Computer Science & Information Engineering National Taiwan University
Online Course
Introduction
• A derivative is a financial instrument whose value depends on (or derives from) the values of other, more basic, underlying assets.
• Four major types of derivatives are forwards1,futures2, options3, andswaps4.
1See https://en.wikipedia.org/wiki/Forward_contract.
2See https://en.wikipedia.org/wiki/Futures_contract and https://www.cmegroup.com/education/courses/
introduction-to-futures.html.
3See https://www.cmegroup.com/education/courses/
introduction-to-options.html.
4See https://en.wikipedia.org/wiki/Swap_(finance).
Zheng-Liang Lu Python Programming in Finance 1
Futures Contracts
• A futures contract is an agreement between two parties to buy or sell an asset at a certain time in the future for a certain price.
• For example, index futures (say TX5 and S&P 500 E-Mini6), equity futures7, commodity futures8 (say crude oil, gold, corn, and cocoa), weather futures9, and cryptocurrency futures (say, Bitcoin10).
5See https://www.taifex.com.tw/cht/2/tX.
6See https://www.investing.com/indices/us-spx-500-futures.
7See https://pchome.megatime.com.tw/group/mkt5/cidE008.html.
8See https://www.cnbc.com/futures-and-commodities/ and http://www.stockq.org/market/commodity.php.
9See https://www.cmegroup.com/trading/weather/files/
weather-futures-and-options-fact-card.pdf.
10See https:
//www.cmegroup.com/markets/cryptocurrencies/bitcoin/bitcoin.html.
Zheng-Liang Lu Python Programming in Finance 2
Payoff of Futures
80 90 100 110 120 Price of Underlying Asset 20
10 0 10 20
Payoff
Long position Short position
Zheng-Liang Lu Python Programming in Finance 3
One of Applications: Hedging
80 90 100 110 120 Price of Underlying Asset 20
10 0 10 20
Payoff
Long position Short position Hedging: long + short
Zheng-Liang Lu Python Programming in Finance 4
Futures Contracts (Cont’d)
• A contract’sexpiration date is the last day you can trade that contract.
• For example, the expiration date of TX contracts is the 3rd Wednesday each month.
• Futures margin is an amount of capital one needs to deposit to control a futures contract.
• Be responsible for assuring that adequate funds are on deposit with the brokerage firm for margin purposes.11
• If not, you cannot trade any futures.
• It is called themargin trading.
11See https://www.taifex.com.tw/cht/5/indexMarging.
Zheng-Liang Lu Python Programming in Finance 5
Futures Contracts (Concluded)
• An index futures is a cash-settledfutures contract while a commodity futures may be settled by physical delivery.
• For example, WTI crude oil futures.12
• Further information about futures could be found in the footnote.13
• For example, futures markets provide aprice discovery mechanism, especially when trading in the off-market hours.14
12See https://www.oilandgas360.com/
wti-crude-oil-futures-prices-fell-below-zero-because-of-low-liquidity-and-limited-available-storage/.
13See https://www.yuantafutures.com.tw/futureinvest_01, https://rich01.com/futures-least-margin-100/, and https://zerodha.com/varsity/module/futures-trading/.
14See https://www.cmegroup.com/education/courses/
introduction-to-futures/price-discovery.html.
Zheng-Liang Lu Python Programming in Finance 6
News: Crude Oil Futures Prices Turn Negative
1515See https://crsreports.congress.gov/product/pdf/IN/IN11354.
Zheng-Liang Lu Python Programming in Finance 7
Futures Pricing
• Let S0 be the spot price, and F0 be the futures price at time 0.
• The (theoretical) futures price is
F0= S0ecT, (1)
where T is the time to maturity, and c is thecost of carry for the futures contract.
• For a non-dividend-paying stock, c = r where r is the risk-free interest rate.
• For a dividend-paying stock, c = r − q where q is the dividend yield rate.
• For a commodity requiring storage costs at rate u, c = r + u.
• The situation of F0> S0 is called contango;backwardation when F0 < S0.
Zheng-Liang Lu Python Programming in Finance 8
Example
• Assume that the current market index is 17000 with r = 3%
and q = 5%.
• Then the resulting price of the near-month(T = 1 / 12) futures is
17000 × e−0.02/12= 16971.69.
• For the next-month(T = 1 / 6) futures, its price is 16943.43.
Zheng-Liang Lu Python Programming in Finance 9
Convergence between Spot Price and Futures Price
16• By equation (1), the futures price always converges upon the spot price on the day of the expiry.
2021-07-01 2021-07-08 2021-07-15 2021-07-22 2021-08-01 2021-08-08 2021-08-15 16600
16800 17000 17200 17400 17600 17800 18000
Price
TWIITX (202107) TX (202108)
16You can find the historical futures priceshere.
Zheng-Liang Lu Python Programming in Finance 10
2021-07-01 2021-07-08 2021-07-15 2021-07-22 2021-08-01 2021-08-08 2021-08-15 300
250 200 150 100 50 0
Price Difference
202107 202108
2021-07-01 2021-07-08 2021-07-15 2021-07-22 2021-08-01 2021-08-08 2021-08-15 1.50
1.25 1.00 0.75 0.50 0.25 0.00 0.25
Price Difference (%)
202107 202108
Zheng-Liang Lu Python Programming in Finance 11
Option Contracts
18• A call/putoption gives the holder to the right tobuy/sell an asset bythe expiration (or maturity) date, denoted by T , for the exercise (or strike) price, denoted by X .
• European options can be exercised only on the expiration date itself, whereas American optionscan be exercised at any time up to the expiration date.
• For example, index options (say TXO17) and foreign exchange options, options on futures.
17See https://www.taifex.com.tw/cht/2/tXO.
18You may also hear about thewarrantcontracts. See
http://www.differencebetween.net/business/finance-business-2/
difference-between-warrants-and-options.
Zheng-Liang Lu Python Programming in Finance 12
Zheng-Liang Lu Python Programming in Finance 13
Payoff for Call & Put
80 90 100 110 120
Stock Price 0
5 10 15 20 25
Payoff
Call Put
Zheng-Liang Lu Python Programming in Finance 14
Moneyness
• Take a call option as an example:
80 90 100 110 120
Stock Price 0
5 10 15 20 25
Payoff
In-The-Money (ITM) Out-of-The-Money (OTM)
At-The-Money (ATM)
Zheng-Liang Lu Python Programming in Finance 15
Long/Short Position in Call/Put
80 90 100 110 120 30
20 10 0 10 20 30
Payoff
Long Call
80 90 100 110 120 30
20 10 0 10 20 30
Payoff
Short Call
80 90 100 110 120 Stock Price 30
20 10 0 10 20 30
Payoff
Long Put
80 90 100 110 120 Stock Price 30
20 10 0 10 20 30
Payoff
Short Put
Zheng-Liang Lu Python Programming in Finance 16
!!! WARNING !!!
• Buying a call/put option offers limited risk and unlimited reward.19
• Selling a naked call/put option, however, has limited reward, andunlimited risk!20
19See https://finance.ettoday.net/news/1999215.
20See https://www.peopo.org/news/379679.
Zheng-Liang Lu Python Programming in Finance 17
Example: 3300% Rate of Return?
Zheng-Liang Lu Python Programming in Finance 18
Hedging: Protective Put
80 90 100 110 120 Stock Price
20 10 0 10 20
Payoff
Stock Put Stock + Put
Zheng-Liang Lu Python Programming in Finance 19
Put-Call Parity
futures call put
long position S − X (S − X )+ (X − S )+ short position −(S − X ) −(S − X )+ −(X − S)+
• Note that (·)+ denotes max(0, ·).
• It is clear that
long futures = long call + short put because S − X = (S − X )+− (X − S)+.21
21More precisely, the best bid of futures could be the best ask of put minus the best bid of call while the best ask of futures could be the best ask of call minus the best bid of put.
Zheng-Liang Lu Python Programming in Finance 20
Illustration
80 90 100 110 120 Stock Price
20 10 0 10 20
Payoff
Long a call (C) Short a put (P)
80 90 100 110 120 Stock Price
20 10 0 10
20 Long a stock S = C P + X
Zheng-Liang Lu Python Programming in Finance 21
Time Value
80 90 100 110 120
Stock Price 5
0 5 10 15 20 25 30
Payoff
Call option at expiration
Call option before expiration (1 mo)
Option value =intrinsic value + time value
Zheng-Liang Lu Python Programming in Finance 22
Premium: There is No Free Lunch
80 90 100 110 120
Stock Price 5
0 5 10 15 20 25 30
Payoff
Call option at expiration
Call option before expiration (1 mo)
• In this case, the option holder (buyer) pays $3.87 to the option writer (seller).
Zheng-Liang Lu Python Programming in Finance 23
Long/Short Position in Call/Put (Revisited)
80 90 100 110 120 30
20 10 0 10 20 30
Payoff
Long Call
80 90 100 110 120 30
20 10 0 10 20 30
Payoff
Short Call
80 90 100 110 120 Stock Price 30
20 10 0 10 20 30
Payoff
Long Put
80 90 100 110 120 Stock Price 30
20 10 0 10 20 30
Payoff
Short Put
Zheng-Liang Lu Python Programming in Finance 24
Selected Trading Strategies with Options: Illustration
90 95 100 105 110
6 4 2 0 2 4 6
Payoff
Long Straddle Call (X = 100) Put (X = 100) Straddle = C + P
90 95 100 105 110
6 4 2 0 2 4 6
Long Strangle Call (X = 105) Put (X = 95) Strangle = C + P
90 95 100 105 110
10 5 0 5
Long Butterfly
CL (X = 95) C (X = 100) CH (X = 105) Butterfly = CL + CH 2 C
90 95 100 105 110
Stock Price 6
4 2 0 2 4 6
Payoff
Short Straddle
Call (X = 100) Put (X = 100) Straddle = C P
90 95 100 105 110
Stock Price 6
4 2 0 2 4 6
Short Strangle Call (X = 105) Put (X = 95) Strangle = C P
90 95 100 105 110
Stock Price 5
0 5 10
Short Butterfly CL (X = 95) C (X = 100) CH (X = 105) Butterfly = 2 C CL CH
Zheng-Liang Lu Python Programming in Finance 25
Arbitrage
• Let VΠ0 = 0 be the initial value of the portfolio Π at time 0.
• Then Π is arbitrageous if Pr(VΠ1 ≥ 0) = 1.
• Simply put, Π is asure win.
• This is called arbitrage, a process that you make a profit without bearing any risk.
• The arbitrage-free principle is the central concept of option pricing.22
22Also see the arbitrage pricing theory.
Zheng-Liang Lu Python Programming in Finance 26
Example 1: Protective Put (Revisited)
• To hedge your long position in stock XYZ, you decide to buy its put option with the strike price $100.
• For simplicity, one option contract covers one stock share.
• Now you have 1000 shares of XYZ.
• Assume that the stock price will be $150 or $50.
• How many contracts of this put option you need to buy?
Zheng-Liang Lu Python Programming in Finance 27
• Let x be the number of option contracts to protect one share.
• Then the final value of the portfolio (XYZ + protective put) should be
150 +0x = 50 +50x ,
• It is clear that x = 2 and the final value is $150,000.
• So we need 2000 contracts of this put option.
Zheng-Liang Lu Python Programming in Finance 28
Example 2: Pricing
• Assume that the initial stock price is $100 and the risk-free rate for one period is 5%.
• Let P be the put price.
• The initial portfolio value is
(100 + 2P) × 1000.
• By the arbitrage-free principle, 100 + 2P = 150
1.05 = 142.86.
• So it is clear that P = 21.43.
• You need $42,860 (= P × 2000) to buy protective puts.23
23You need to pay (insurance) premium to acquire protection.
Zheng-Liang Lu Python Programming in Finance 29
Example 3: Mispricing
• If the put price is overpriced, say P′ = 25, then you could now sellthe portfolio and buyto close the short position in the end:
(100 + 2 × 25)× 1.05 −150> 0.
• If the put price is underpriced, say P′′= 20, then you could play the previous strategy in opposite direction:
150−(100 + 2 × 20)× 1.05 > 0.
• The above two cases show the presence of arbitrage.
• Hence P = 21.43 is the fair priceof this put option.
Zheng-Liang Lu Python Programming in Finance 30
The 1
stand 2
ndTheorem of Asset Pricing
• Fundamental Theorem of Arbitrage Pricing: there exists a risk-neutral probability measure if and only if arbitrages do not exist.
• An arbitrage-free market may admit more than one risk-neutral probability measure.
• Economists call such markets incomplete.24
• Completeness Theorem: a complete market is one that has a unique equilibrium measure.
• In a complete market, any derivative security can behedged by replicatingthe portfolio from the market.
24It could be said that there are necessarily derivative securities that cannot be hedged.
Zheng-Liang Lu Python Programming in Finance 31
Pricing ↔ Replication ↔ Hedging
Zheng-Liang Lu Python Programming in Finance 32
Binomial Option Pricing Model (BOPM)
One-Period Case
• Let X be the strike price and r be the risk-free interest rate.
• Let S be the price at time 0.
• Let u and d be the jump size for the up and down movement at time T .25
• Let pu and pd denote the transitional probability for Su and Sd , respectively.
25It could be proved that 0 < d ≤ u is equivalent to the arbitrage-free principle.
Zheng-Liang Lu Python Programming in Finance 33
Binomial Tree
S
Sd
pd pu
Su
• For a fair bet, solve the following simultaneous equations (pu+ pd = 1,
puSu + pdSd = SerT.
Zheng-Liang Lu Python Programming in Finance 34
• It is easy to see that
pu= erT − d u − d .
• If 0 ≤ pu, pd ≤ 1, then the call price C is
C = e−rTpu(Su − X )++ pd(Sd − X )+ .
• Note that puand pd are so-called therisk-neutralprobabilities.
• Under this risk-neutral probability measure,
C = e−rTEQ (ST− X )+ . (2)
• This equality also holds for continuous-time cases.
Zheng-Liang Lu Python Programming in Finance 35
BOPM: A 3-Period Case
• A non-dividend-paying stock is selling for $160.
• Assume that u = 1.5, d = 0.5, and r = 18.232% per period (R = e0.18232= 1.2).
• Hence the probability of an up move is p = R − d
u − d = 0.7.
• Consider a European call on this stock with X = 150.
• The call value is $85.069 by backward induction.
Zheng-Liang Lu Python Programming in Finance 36
Zheng-Liang Lu Python Programming in Finance 37
1 import numpy as np
2
3 s0 = 160 # spot price
4 X = 150 # strike price
5 n = 3 # periods
6 R = 1.2 # gross return for each period
7 u = 1.5 # size of up move
8 d = 0.5 # size of down move
9
10 p = (R − d) / (u − d) # probability of up move
11
12 # generate the forward price tree
13 tree = np.zeros([n + 1, n + 1])
14 tree[0, 0] = s0
15 for period in range(1, n + 1):
16 for level in range(period + 1):
17 tree[level, period] = s0 * u ** (period − level) * d **
level
18
19 # see the next page
Zheng-Liang Lu Python Programming in Finance 38
1 # calculate the payoff at expiration
2 for level in range(n + 1):
3 payoff = tree[level, n] − X
4 tree[level, n] = payoff if payoff> 0 else 0
5
6 # calculate the option price at time 0 by backward induction
7 for period in range(n − 1, −1, −1):
8 for level in range(period + 1):
9 tree[level, period] = (p * tree[level, period + 1] + (1
− p) * tree[level + 1, period + 1]) / R
10
11 print(tree)
12 print("c =", round(tree[0, 0], 2)) # output 85.07
Zheng-Liang Lu Python Programming in Finance 39
Risk-Neutral Valuation
26for Call Options
26Also calledmartingale pricing. See
https://en.wikipedia.org/wiki/Martingale_pricing.
Zheng-Liang Lu Python Programming in Finance 40
Remarks
• The arbitrage-free principle determines the fair price of options.
• The fair price is the discounted payoff of the contingency claim under the risk-neutral probability measure.
• A further question is,
How does the price evolve over time?
Zheng-Liang Lu Python Programming in Finance 41
Geometric Brownian Motion
29• Let µ be the expected return rate, σ be the annual volatility, and T be the time to maturity.
• Then we assume that the return rate of St follows dSt
St = µdt + σdWt, (3)
where Wt ∼ N(0, T ) is the Wiener process.27
• By Itˆo’s lemma28, the stock price at time T is ST = S0e(µ−σ2/2)T +σWT, where S0 is the spot price.
27See https://en.wikipedia.org/wiki/Wiener_process.
28Itˆo (1944). See https://en.wikipedia.org/wiki/Ito’s_lemma.
29See https://en.wikipedia.org/wiki/Brownian_motion.
Zheng-Liang Lu Python Programming in Finance 42
Generalized Wiener Process: Illustration
300 50 100 150 200 250 Time
0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5
X
t= 1
= 1
0= 2
= 0
= 2
W
tt + W
tt +
0W
t30
Zheng-Liang Lu Python Programming in Finance 43
Example: Price Path Simulation
310 50 100 150 200 250
Date 90
100 110 120 130 140 150 160
Price
Path 1 Path 2 Path 3
31S0= 100, µ = 0.1, σ = 0.3, T = 1, N = 250.
Zheng-Liang Lu Python Programming in Finance 44
Example: Monte Carlo Method for European Options
0 50 100 150 200 250
Date 50
100 150 200 250 300 350
Price
0 20 40 60
Frequency 50
100 150 200 250 300 350
Zheng-Liang Lu Python Programming in Finance 45
0 100 200 300 400 Stock Price
0 2000 4000 6000 8000
Frequency
C = 16.76 P = 7.31
• The number of simulation paths can be determined by its standard error of the estimator.
Zheng-Liang Lu Python Programming in Finance 46
1 import numpy as np
2
3 S0 = 100
4 X = 100
5 r = 0.1
6 v = 0.3
7 T = 1
8
9 N = 100000 # for example
10 Z = np.random.normal(size = (N, 1))
11 S = S0 * np.exp((r − 0.5 * v ** 2) * T + v * np.sqrt(T) * Z)
12 C = np.sum(S[S> X] − X) / N / np.exp(r * T)
13 P = np.sum(X − S[X> S]) / N / np.exp(r * T)
Zheng-Liang Lu Python Programming in Finance 47
From BOPM to Black-Scholes Formula
• Consider the log price ln St.
• By Itˆo’s lemma, it can be shown that d ln St = rdt + σdWt, where r = µ −σ2
2 .
• To match the mean and the variance of the above equation, (quln u + (1 − qu) ln d = r ∆t,
quln2u + (1 − qu) ln2d = r2∆t2+ σ2∆t.
Zheng-Liang Lu Python Programming in Finance 48
• Choosing ud = 1, it can be shown that
u = eσ
√
∆t, qu= 1 2 +r√
∆t 2σ .
• It is worth to mention that
pu= er ∆t− d u − d → qu as ∆t → 0.
• This is well known as the CRR binomial model32, which is proved to converge to the Black-Scholes formula.
32Cox, Ross and Rubinstein (1979).
Zheng-Liang Lu Python Programming in Finance 49
Black-Scholes Formula for European Options
34• Insert equation (3) into equation (2).
• Then we could drive the famous option pricing formula
C (S , X , r , σ, T ) = SN(d1) − Xe−rTN(d2), (4) where N(·) is the normal cdf, d1 = (ln(S/X )+(r +σ2/2)T )
σ√
T and
d2= d1− σ√ T .33
• By the put-call parity,
P = C − S + Xe−rT.
33Try https://www.taifex.com.tw/cht/9/calOptPrice.
34Black and Scholes (1973), Merton (1973). Scholes and Merton are awarded with the Nobel Prize in Economic Sciences in 1997 for a new method of determining the value of derivatives. See https:
//www.nobelprize.org/prizes/economic-sciences/1997/summary/.
Zheng-Liang Lu Python Programming in Finance 50
Example
1 import numpy as np
2 import scipy.stats
3
4 s0 = 100
5 X = 100
6 r = 0.1
7 v = 0.3
8 T = 1
9
10 d1 = (np.log(s0 / X) + (r + 0.5 * v ** 2)) / np.sqrt(T) / v
11 d2 = d1 − np.sqrt(T) * v
12 C = s0 * scipy.stats.norm.cdf(d1) − X * np.exp(−r * T) * scipy.
stats.norm.cdf(d2)
13 print(C)
Zheng-Liang Lu Python Programming in Finance 51
Trading Volatility
• Options are a popular vehicle forspeculation.
• Speculative trades would arguably be more inclined to buy a call than to buy its stock if the stock is bullish and expected high future volatility.
• Buying options is buying volatilityandselling options is selling volatility.
Zheng-Liang Lu Python Programming in Finance 52
Historical/Implied Volatility
• Historical volatility (HV) is the annualized standard deviation of daily returns.
• Implied volatility (IV) is the volatility input in a pricing model that, in conjunction with the other four inputs, returns the theoretical value of an option matching the market price.
• What is the difference between HV and IV?
• HV: what has happened.
• IV: derived from the market’s expectation for future volatility.
Zheng-Liang Lu Python Programming in Finance 53
How to Use IV?
• You could deannualize IV to the daily IV by
√IV
256 = 1-day expected σ.
• For example, assume that the period in question is one month and there are 22 business days remaining in that month.
• The ATM call for the$100 stock is traded at 32% IV.
• Then it has a one-month volatility
√0.32 256×√
22 = 9.38%.
• It is equivalent to say that there is 68% chance of the stock’s closing between $90.62 and $109.38.
Zheng-Liang Lu Python Programming in Finance 54
How to Calculate IV?
• We know the spot price S , the time to maturity T , the risk-free rate r , and also the option price C with the strike price X .
• The only unobservable parameter is the volatility σ.
• We invert equation (4) to calculate (more precisely, estimate) σ by the Newton’s method.35
• This resulting volatility is called the implied volatility because the volatility is impliedby the Black-Scholes formula with the market prices.
35You may also use the bisection method in this problem.
Zheng-Liang Lu Python Programming in Finance 55
Newton’s Method
36• Let f (x ) be the target function and x∗ be the root of f .
• Then x∗ could be found by using the iterative formula xk+1 ← xk − f
f′, where f′ = df
dx at xk.
• The loop halts when the convergence criteria is satisfied, say
| xk+1− xk| < ε for a constant ε small enough.
36See https://en.wikipedia.org/wiki/Newton’s_method.
Zheng-Liang Lu Python Programming in Finance 56
How to Calculate IV? (Concluded)
• Now consider the European call C = f (S , X , r , σ, T ).
• Then
σk+1 ← σk +C − f (S , X , r , σk, T )
ν ,
where ν = ∂f
∂σ is called the vega.
• Note that the vega of European options is ν = SN(d1)
√ T > 0.
• The higher the volatility input, the higher the theoretical value, holding all other variables constant.
Zheng-Liang Lu Python Programming in Finance 57
Examples
8000 9000 10000 11000 12000 13000 Strike Price
10 15 20 25 30 35 40 45 50
Implied Volatility (%)
Evaluation Date: 2019-8-30 Maturity Date: 2019-9-18
TXO Call TXO Put
Zheng-Liang Lu Python Programming in Finance 58
14000 15000 16000 17000 18000 19000 Strike Price
30 35 40 45 50 55 60 65
Implied Volatility (%)
Evaluation Date: 2021-05-12 Maturity Date: 2021-05-19
TXO Call TXO Put
Zheng-Liang Lu Python Programming in Finance 59
Case Study: CBOE VIX Index
3737See https://www.cboe.com/tradable_products/vix/.
Zheng-Liang Lu Python Programming in Finance 60
1992 1996 2000 2004 2008 2012 2016 2020 Date (year)
10 20 30 40 50 60 70 80
CBOE Volatility Index
6.0 6.5 7.0 7.5 8.0 8.5
S&P 500 Index (log scale)
Zheng-Liang Lu Python Programming in Finance 61
20 0 20 40 60 80 100 120 Return Rate of VIX Index (%)
10 5 0 5 10
Return Rate of S&P 500 Index (%)
Correlation = 0.707678
Zheng-Liang Lu Python Programming in Finance 62
Beyond the Black-Scholes Formula
• As we can see, the IV curve violets the assumption of constant volatility.38
• Empirically, stock returns tend to havefat tails, inconsistent with the Black-Scholes model’s assumptions.
• Later, the stochastic volatility models and thejump-diffusion modelsare proposed to tackle with this issue.
• In the time series analysis, the ARCH modeland its variants are also used to estimate the volatility, especially in risk management.39
38This is called thevolatility smile (smirk). See
https://en.wikipedia.org/wiki/Volatility_smile. Also see https://en.wikipedia.org/wiki/Volatility_clustering and https://www.investopedia.com/terms/a/assymetricvolatility.asp.
39See https://en.wikipedia.org/wiki/Autoregressive_conditional_
heteroskedasticity.
Zheng-Liang Lu Python Programming in Finance 63
Cox-Ingersoll-Ross (CIR) Model
40• The CIR Model is a square-root mean reverting process following
drt= κ(θ − rt)dt + σ√ rtdWt,
where rt is the interest rate at time t, κ is the mean-reverting rate, θ is the long-term mean of rt, σ is the volatility of rt, and dWt is a Wiener process.
• The CIR model is widely used in modeling interest rate, commoditiy price, and price volatility (or variance).
40Cox, Ingersoll, Ross (1985).
Zheng-Liang Lu Python Programming in Finance 64
Illustration
410 50 100 150 200 250
Time 4
5 6 7 8 9 10
Interest Rate (%)
41r0= 4%, θ = 8%, κ = 2, σ = 10%, T = 1, N = 250.
Zheng-Liang Lu Python Programming in Finance 65
Heston Model
• Heston (1993) exploits the CIR model to capture the dynamic of price volatility:
dS
S = µdt +√
vtdW1,t, dvt = κ(θ − vt)dt + σ√
vtdW2,t,
where vr is the price variance of St and dW1,t × dW2,t = ρ.
• In particular, ρ is typically negative in the stock market.
Zheng-Liang Lu Python Programming in Finance 66
Illustration
420 50 100 150 200 250
90 100
Price
0 50 100 150 200 250
Time 20
30
Volatility (%)
Path 1 Path 2 Path 3
42S0= 100, r = 1%, v0= 0.09, θ = 0.04, κ = 3, σ = 0.3, ρ = −0.7, N = 250.
Zheng-Liang Lu Python Programming in Finance 67
Merton’s Jump-Diffusion Model
• Merton (1976) superimposes a jump component on a diffusion component.
• The jump component is composed of lognormal jumps driven by a Poisson process.43
• It models the sudden changes in the stock price because of the arrival of important new information.
• The risk-neutral jump-diffusion process follows dSt
St = (r − λκ)dt + σdWt+ κdqt,
where qt is compound Poisson process with intensity λ, where κ denotes the magnitude of the random jump.
43See https://en.wikipedia.org/wiki/Poisson_point_process.
Zheng-Liang Lu Python Programming in Finance 68
Illustration
0 50 100 150 200 250
Time 80
85 90 95 100 105 110 115 120
Price
Path 1 Path 2
Zheng-Liang Lu Python Programming in Finance 69