PyMPDATA_examples.Arabas_and_Farhat_2020.setup1_european_corridor

 1import numpy as np
 2import PyMPDATA_examples.Arabas_and_Farhat_2020.Black_Scholes_1973 as BS73
 3from pystrict import strict
 4
 5
 6@strict
 7class Settings:
 8    S0 = 55
 9    T = 0.5
10    amer = False
11    S_min = 10
12    S_max = 2000
13    sigma = 0.6
14    r = 0.008
15    K1 = 75
16    K2 = 175
17    S_match = 175
18
19    def __init__(self, *, n_iters: int = 2, l2_opt: int = 2, C_opt: float = 0.034):
20        self.n_iters = n_iters
21        self.l2_opt = l2_opt
22        self.C_opt = C_opt
23
24    def payoff(self, S: np.ndarray):
25        return np.exp(-self.r * self.T) * (
26            np.maximum(0, self.K2 - S) - np.maximum(0, self.K1 - S)
27        )
28
29    def analytical_solution(self, S: np.ndarray):
30        return BS73.p_euro(
31            S, K=self.K2, T=self.T, r=self.r, b=self.r, sgma=self.sigma
32        ) - BS73.p_euro(S, K=self.K1, T=self.T, r=self.r, b=self.r, sgma=self.sigma)
@strict
class Settings:
 7@strict
 8class Settings:
 9    S0 = 55
10    T = 0.5
11    amer = False
12    S_min = 10
13    S_max = 2000
14    sigma = 0.6
15    r = 0.008
16    K1 = 75
17    K2 = 175
18    S_match = 175
19
20    def __init__(self, *, n_iters: int = 2, l2_opt: int = 2, C_opt: float = 0.034):
21        self.n_iters = n_iters
22        self.l2_opt = l2_opt
23        self.C_opt = C_opt
24
25    def payoff(self, S: np.ndarray):
26        return np.exp(-self.r * self.T) * (
27            np.maximum(0, self.K2 - S) - np.maximum(0, self.K1 - S)
28        )
29
30    def analytical_solution(self, S: np.ndarray):
31        return BS73.p_euro(
32            S, K=self.K2, T=self.T, r=self.r, b=self.r, sgma=self.sigma
33        ) - BS73.p_euro(S, K=self.K1, T=self.T, r=self.r, b=self.r, sgma=self.sigma)
Settings(*, n_iters: int = 2, l2_opt: int = 2, C_opt: float = 0.034)
20    def __init__(self, *, n_iters: int = 2, l2_opt: int = 2, C_opt: float = 0.034):
21        self.n_iters = n_iters
22        self.l2_opt = l2_opt
23        self.C_opt = C_opt
S0 = 55
T = 0.5
amer = False
S_min = 10
S_max = 2000
sigma = 0.6
r = 0.008
K1 = 75
K2 = 175
S_match = 175
n_iters
l2_opt
C_opt
def payoff(self, S: numpy.ndarray):
25    def payoff(self, S: np.ndarray):
26        return np.exp(-self.r * self.T) * (
27            np.maximum(0, self.K2 - S) - np.maximum(0, self.K1 - S)
28        )
def analytical_solution(self, S: numpy.ndarray):
30    def analytical_solution(self, S: np.ndarray):
31        return BS73.p_euro(
32            S, K=self.K2, T=self.T, r=self.r, b=self.r, sgma=self.sigma
33        ) - BS73.p_euro(S, K=self.K1, T=self.T, r=self.r, b=self.r, sgma=self.sigma)