forked from Michalos88/Quant-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHo-Lee.py
More file actions
50 lines (39 loc) · 1.03 KB
/
Copy pathHo-Lee.py
File metadata and controls
50 lines (39 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Michal Lyskawinski
# Date: 11/28/2016
# Ho-Lee Model
from math import *
from scipy.stats import norm
# interest rate parameters:
r = 0.04
r1 = 0.04
sigma = 0.01
# Option parameters: European Call
OM = 2 # Option Maturity in years
OBM = 6 # Option's Bond Maturity in years
K = 0.73
# Bond parameters:
T = 1
s = 2 # Bond Maturity in years
t = 0 # Present time
dB = s - T # difference
dt = 0.1
def PDB(r,M):
P = exp(-r*M)
return P
# Pricing the Bond:
P5 = PDB(r,s)
P1 = PDB(r,T)
Slope = (log(PDB(r,T+dt))-log(PDB(r,T-dt)))/(2*dt)
lnA = log(P5/P1) - dB*(Slope) - 0.5*(sigma**2)*(T-t)*dB**2
BP = exp(lnA)*PDB(r1,dB)
print('Price of the bond =',BP)
# Pricing the European Call Option:
PO = PDB(r,OM)
POB = PDB(r,OBM)
# K = POB/PO # If no K
sigmaP = sigma*(dB)*sqrt(T-t)
d1 = ((log((POB)/(K*P1)))/(sigmaP)) + (sigmaP*0.5)
d2 = d1 - sigmaP
c = POB*norm.cdf(d1) - K*PO*norm.cdf(d2) # call
p = PO*K*norm.cdf(-d2) - POB*norm.cdf(-d1) # put
print('Price of the European Call =',c)