Skip to content

Asian option pricing using 2D PDE (and Monte-Carlo) example #514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 90 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
18b5e84
analytic solution for fixed asian geometric option
pawelmagnu Nov 23, 2024
be18bae
fix to asian option price analytic formula
pawelmagnu Nov 24, 2024
8336875
asian opt more plots
pawelmagnu Dec 1, 2024
b6b0300
Merge branch 'open-atmos:main' into asian-option
pawelmagnu Dec 1, 2024
f85d468
pylint fix
pawelmagnu Dec 1, 2024
43a8fad
devops tests fix
pawelmagnu Dec 1, 2024
187b096
add colab magic
pawelmagnu Dec 1, 2024
9a69d98
asian opt refactor
pawelmagnu Dec 16, 2024
81ece2a
asian opt first approach
pawelmagnu Dec 16, 2024
31724f6
more experiments
pawelmagnu Dec 18, 2024
f33a939
failing boundary conditions
pawelmagnu Dec 18, 2024
58cf0d0
Merge branch 'open-atmos:main' into asian-option
pawelmagnu Dec 23, 2024
dd129a7
rerun experiment
pawelmagnu Jan 10, 2025
bda2ba2
added comparison against some tables in zvan 1988
pawelmagnu Jan 11, 2025
47fd31b
moved black-scholes eq to a different folder; added test for BS with …
pawelmagnu Jan 15, 2025
a23a42b
added closed form solution to asian average price options + tests
pawelmagnu Jan 15, 2025
edf568a
added closed form solution to asian average strike options + tests
pawelmagnu Jan 15, 2025
50563cc
moving changes to another branch
pawelmagnu Jan 15, 2025
b2b1904
moving changes to another branch
pawelmagnu Jan 15, 2025
5fef693
Merge branch 'open-atmos:main' into asian-option
pawelmagnu Jan 15, 2025
5b7bf3d
changed naming convention
pawelmagnu Jan 22, 2025
9a2f765
changed naming convention fo asian option setup; first try at 2d adve…
pawelmagnu Jan 22, 2025
0a27914
attempt at fixing simulation for geometric options
pawelmagnu Jan 27, 2025
91497e3
Merge branch 'open-atmos:main' into asian-option
pawelmagnu Jan 27, 2025
8452b2e
tries to get mpdata working with asian opt
pawelmagnu Jan 29, 2025
56b4904
changed axes ordering, fixed A velocity calculation
pawelmagnu Jan 30, 2025
981cd3e
yet another attempt at fixing diffusion bug
pawelmagnu Jan 31, 2025
ef9f9c8
changed timestep
pawelmagnu Feb 12, 2025
514775a
Merge branch 'open-atmos:main' into asian-option
pawelmagnu Feb 12, 2025
8e99da5
Merge remote-tracking branch 'origin/asian-option' into asian-option
pawelmagnu Feb 12, 2025
09a6fcf
changed intial condition
pawelmagnu Feb 13, 2025
e1d1d7a
friday fixes
pawelmagnu Feb 15, 2025
233a6a8
add test for 2D extrapolated bc (scalar logic passing, vector logic f…
slayoo Feb 16, 2025
8300cb3
move quick-look utility to a separate file, introduce proper implemen…
slayoo Feb 16, 2025
7b9b980
address pylint hints
slayoo Feb 16, 2025
551e220
Merge branch 'bc_extrapol_2d' into HEAD
slayoo Feb 16, 2025
610cc79
remove debug leftover
slayoo Feb 16, 2025
8b224b8
code cleanups
slayoo Feb 16, 2025
c787547
Merge pull request #2 from slayoo/asian-option
pawelmagnu Feb 16, 2025
a831090
Merge branch 'open-atmos:main' into asian-option
pawelmagnu Feb 16, 2025
f9790d8
more code cleanups, plot fine tuning, changing instrument parameters …
slayoo Feb 16, 2025
0c3d4e5
removing commented-out code and adding reference name for Asian optio…
slayoo Feb 16, 2025
ab0bcd2
more cleanups, employing the new quick_looks (with fixes),
slayoo Feb 17, 2025
9132a19
further cleanups, custom boundary condition at S=0
slayoo Feb 17, 2025
caa6a8a
redefine velocity field as in Mkhize/Meyer
slayoo Feb 17, 2025
cb12352
add diagonal line to imshow plot, re-enable custom bc, alter instrume…
slayoo Feb 17, 2025
9fc8460
Merge pull request #3 from slayoo/asian-option
pawelmagnu Feb 18, 2025
d271d25
source term + lucky option parameters :)
slayoo Feb 20, 2025
6776959
Merge pull request #4 from slayoo/asian-option
pawelmagnu Feb 21, 2025
e7838ea
fix to rhs bug
pawelmagnu Feb 26, 2025
fdad6fd
removed dynamic calculation of dx, dy, dt
pawelmagnu Feb 27, 2025
3bc7031
corridor, geometric opt
pawelmagnu Feb 28, 2025
fc6ab26
fixed units in the plots; try with put instead of call; a case where …
slayoo Mar 1, 2025
9cebd29
add European option as a third case
slayoo Mar 1, 2025
128a4a2
change asian option closed form to kemna vorst version
pawelmagnu Mar 2, 2025
3a2db1e
add American option as a fourth case, fix payoff discounting
slayoo Mar 2, 2025
0bd92ce
Merge branch 'asian-option' of github.com:pawelmagnu/PyMPDATA into HEAD
slayoo Mar 2, 2025
7511aab
K&V label, fix colorscale range
slayoo Mar 2, 2025
1a17311
Merge pull request #5 from slayoo/asian-option
pawelmagnu Mar 2, 2025
1a7937b
experimental mathematics...
slayoo Mar 3, 2025
bc840a3
Merge pull request #6 from slayoo/asian-option
pawelmagnu Mar 3, 2025
06fe889
wednesday works
pawelmagnu Mar 5, 2025
e4f3b0c
monte carlo for asian options
pawelmagnu Mar 5, 2025
a83c12e
breakthrough
pawelmagnu Mar 12, 2025
2797fbb
minor updates to mc' comparison against mc
pawelmagnu Mar 13, 2025
2d01641
fixup to analytic solution notebook
pawelmagnu Mar 16, 2025
4c007a0
minor changes to analytic solution
pawelmagnu Mar 19, 2025
c242d7e
super lucky parameters
pawelmagnu Mar 19, 2025
f7fe269
approach at cleaning code
pawelmagnu Mar 19, 2025
3fe348b
more experiments
pawelmagnu Mar 20, 2025
5a1f59f
more experiments
pawelmagnu Mar 21, 2025
8e1cb17
more experiments.
pawelmagnu Mar 21, 2025
0bf5223
more experiments.
pawelmagnu Mar 22, 2025
0acb998
more experiments.
pawelmagnu Mar 22, 2025
df76226
more experiments.
pawelmagnu Mar 22, 2025
9e53caf
more experiments.
pawelmagnu Mar 23, 2025
8c86932
numba mc
pawelmagnu Mar 26, 2025
f83e2e7
further works on table
pawelmagnu Mar 27, 2025
56edf4e
further works on table
pawelmagnu Mar 27, 2025
c2c440b
further works on table
pawelmagnu Mar 27, 2025
757f2f8
last experiments with call option
pawelmagnu Mar 27, 2025
dc044cb
put
pawelmagnu Mar 30, 2025
08c9c24
Merge branch 'open-atmos:main' into asian-option
pawelmagnu Apr 2, 2025
bb5c61c
change to boundary condition
pawelmagnu Apr 3, 2025
72f5a66
rerun put
pawelmagnu Apr 3, 2025
af6a5b7
rerun put
pawelmagnu Apr 3, 2025
08ef722
wednesday progress
pawelmagnu Apr 16, 2025
5693aed
better plots
pawelmagnu Apr 19, 2025
ab56bf0
wednesday shenanigans
pawelmagnu Apr 23, 2025
3dabfa7
friday shenanigans
pawelmagnu Apr 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"outputs": [],
"source": [
"S = simulation.S\n",
"psi_T = simulation.terminal_value()\n",
"psi_T = simulation.state()\n",
"psi_0 = simulation.run(n_iters=2)\n",
"psi_a = settings.analytical_solution(S)"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ def __init__(self, *, n_iters: int = 2, l2_opt: int = 2, C_opt: float = 0.034):
self.l2_opt = l2_opt
self.C_opt = C_opt

def terminal_condition(self, S: np.ndarray):
return np.exp(-self.r * self.T) * self.payoff(S)

def payoff(self, S: np.ndarray):
return np.exp(-self.r * self.T) * (
np.maximum(0, self.K2 - S) - np.maximum(0, self.K1 - S)
)
return np.maximum(0, self.K2 - S) - np.maximum(0, self.K1 - S)

def analytical_solution(self, S: np.ndarray):
return BS73.p_euro(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@ def call(self, psi, step):

return self.solvers[n_iters].advectee.get()

def terminal_value(self):
def state(self):
"""returns the state for MPDATA solution"""
return self.solvers[1].advectee.get()
11 changes: 11 additions & 0 deletions examples/PyMPDATA_examples/Magnuszewski_et_al_2025/Mkhize_2007.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import numpy as np
from scipy.stats import norm

def geometric_mkhize(s_t=100, K=100, r=0.008, sigma=0.2, T=30, T_0=0):
d_1 = (np.log(s_t / K) + 0.5 * (r + (sigma ** 2) / 6) * (T - T_0)) / (sigma * np.sqrt((T - T_0) / 3))
d_2 = d_1 - sigma * np.sqrt((T - T_0) / 3)
C_0 = s_t * np.exp(-0.5 * (r + (sigma ** 2) / 6) * (T - T_0)) * norm.cdf(d_1) - K * np.exp(
-r * (T - T_0)) * norm.cdf(d_2)
P_0 = K * np.exp(-r * (T - T_0)) * norm.cdf(-d_2) - s_t * np.exp(
-0.5 * (r + (sigma ** 2) / 6) * (T - T_0)) * norm.cdf(-d_1)
return C_0
Empty file.

Large diffs are not rendered by default.

Loading
Loading