In [1]:
using Dates, Distributions
include("jlFiles/printmat.jl")
include("jlFiles/printTable.jl")
Out[1]:
In [2]:
using Plots
#pyplot(size=(600,400))
gr(size=(480,320))
default(fmt = :svg)
"Delta hedging" is based on the idea that we can approximate the change in the option price by
$C_{t+h}-C_{t}\approx \Delta_t \left( S_{t+h}-S_{t}\right)$,
where $\Delta_t$ is the derivative of the call option price wrt. the underlying asset price.
In the Black-Scholes model, the Delta of a call option is
$\Delta=\frac{\partial C}{\partial S}=e^{-\delta m}\Phi\left( d_{1}\right),$
where $d_1$ is the usual term in Black-Scholes.
Similarly, the Delta of a put option is
$\frac{\partial P}{\partial S}=e^{-\delta m}[\Phi\left( d_{1}\right)-1]$.
The file included in the next cell contains the functions Φ()
and OptionBlackSPs()
from the chapter on the Black-Scholes model.
The subsequent cell defines a function for the $\Delta$ of the Black-Scholes model.
In [3]:
include("jlFiles/OptionsCalculations.jl")
Out[3]:
In [4]:
"""
Calculate the Black-Scholes delta
"""
function OptionDelta(S,K,m,y,σ,δ=0,PutIt=false)
d1 = ( log(S/K) + (y-δ+0.5*σ^2)*m ) / (σ*sqrt(m))
d2 = d1 - σ*sqrt(m)
if PutIt
Δ = exp(-δ*m)*(Φ(d1)-1)
else
Δ = exp(-δ*m)*Φ(d1)
end
return Δ
end
Out[4]:
In [5]:
(S,K,m,y,σ) = (42,42,0.5,0.05,0.2)
Δc = OptionDelta(S,K,m,y,σ) #call
Δp = OptionDelta(S,K,m,y,σ,0,true) #put
printlnPs("Δ:")
printTable([Δc Δp (Δc-Δp)],["call","put","difference"],[" "],width=12)
In [6]:
S_range = 30:60 #different spot prices
Δc_S_range = OptionDelta.(S_range,K,m,y,σ)
plot( S_range,Δc_S_range,
linecolor = :red,
legend = false,
title = "Black-Scholes call option delta",
xlabel = "current asset price",
ylabel = "option price" )
Out[6]:
In [7]:
(S₀,S₁,K,m,y,σ) = (42,43,42,0.5,0.05,0.2)
C₀ = OptionBlackSPs(S₀,K,m,y,σ) #option price at S₀
Δ₀ = OptionDelta(S₀,K,m,y,σ) #Delta at S₀
M₀ = C₀ - Δ₀*S₀ #on money market account
C₁ = OptionBlackSPs(S₁,K,m-1/252,y,σ) #option price at S₁ (it's one day later)
dC = C₁ - C₀ #change of option value
dV = Δ₀*(S₁-S₀) - (C₁-C₀) #change of hedge portfolio value
xy = [S₀,Δ₀,C₀,M₀,S₁,C₁,dC,dV]
printTable(xy,[" "],["S₀","Δ₀","C₀","M₀","S₁","C₁","dC","dV"])
printblue("\nV changes much less in value than the option (abs(dV) < abs(dC)):
the hedge helps")
In [ ]: