Skip to content

Commit 1d832c1

Browse files
committed
Added framework for LSM and FD
Least-square Monte-Carlo, Finite difference method applied to Black-Scholes model
1 parent 8b6035f commit 1d832c1

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

FD.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class LSM(object):
2+
def __init__(self, option_type, S0, strike, T, M, r, sigma, div):
3+
"""
4+
Input:
5+
option_type [string]: type of option (i.e. American, European, Asian)
6+
S0 [float]: current value of stock
7+
strike [float]: strike price
8+
T [float]: expiration date
9+
M [int]: number of mesh grid in time domain
10+
r [float]: riskfree rate (i.e. similar to discount factor)
11+
div [float]: dividend yield
12+
"""
13+
self.parameters = {} # use appropriate date structure to keep track of parameters
14+
raise NotImplementedError
15+
16+
def simulate():
17+
""" Given current price, strike, T and other parameters of the option, find its valuation by solving PDE
18+
Some reference: https://towardsdatascience.com/option-pricing-using-the-black-scholes-model-without-the-formula-e5c002771e2f
19+
or https://github.com/wessle/option_pricer/blob/master/fin_diffs.py
20+
"""
21+
raise NotImplementedError

LSM.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class LSM(object):
2+
def __init__(self, option_type, S0, strike, T, M, r, sigma, div, N):
3+
"""
4+
Input:
5+
option_type [string]: type of option (i.e. American, European, Asian)
6+
S0 [float]: current value of stock
7+
strike [float]: strike price
8+
T [float]: expiration date
9+
M [int]: number of mesh grid in time domain
10+
r [float]: riskfree rate (i.e. similar to discount factor)
11+
div [float]: dividend yield
12+
13+
N [int]: number of simulations
14+
15+
Some reference: https://github.com/jpcolino/IPython_notebooks/blob/master/Least%20Square%20Monte%20Carlo%20Implementation%20in%20a%20Python%20Class.ipynb
16+
or https://cran.r-project.org/web/packages/LSMRealOptions/vignettes/LSMRealOptions.html#:~:text=The%20Least%2DSquares%20Monte%20Carlo,option%20at%20discrete%20observation%20points.
17+
"""
18+
self.parameters = {} # use appropriate date structure to keep track of parameters
19+
raise NotImplementedError
20+
21+
def train():
22+
""" Given a trajectory object, find fitted parameters based on the trajectory.
23+
"""
24+
raise NotImplementedError
25+
26+
def price():
27+
""" Given current price, strike, and other parameters of option, find its valuation using the fitted parameters
28+
"""
29+
raise NotImplemented

0 commit comments

Comments
 (0)