Skip to content

Commit 35cb025

Browse files
committed
FEATURE: changing methods to protected
1 parent 94bd867 commit 35cb025

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

pdesolvers/solvers/black_scholes_solvers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ def solve(self):
6363
V[i, tau] = V[i, tau + 1] - (theta[i, tau] * dt)
6464

6565
# setting boundary conditions
66-
lower, upper = utility.BlackScholesHelper.set_boundary_conditions(self.equation, T, tau)
66+
lower, upper = utility.BlackScholesHelper._set_boundary_conditions(self.equation, T, tau)
6767
V[0, tau] = lower
6868
V[self.equation.s_nodes, tau] = upper
6969

70-
delta, gamma, theta = utility.BlackScholesHelper.calculate_greeks_at_boundary(self.equation, delta, gamma, theta, tau, V, S, ds)
70+
delta, gamma, theta = utility.BlackScholesHelper._calculate_greeks_at_boundary(self.equation, delta, gamma, theta, tau, V, S, ds)
7171

7272
end = time.perf_counter()
7373
duration = end - start
@@ -137,7 +137,7 @@ def solve(self):
137137
gamma[1:-1, tau] = (V[2:, tau] - 2 * V[1:-1, tau] + V[:-2, tau]) / (ds**2)
138138
theta[1:-1, tau] = -0.5 * (self.equation.sigma**2) * (S[1:-1]**2) * gamma[1:-1, tau] - self.equation.rate * S[1:-1] * delta[1:-1, tau] + self.equation.rate * V[1:-1, tau]
139139

140-
delta, gamma, theta = utility.BlackScholesHelper.calculate_greeks_at_boundary(self.equation, delta, gamma, theta, tau, V, S, ds)
140+
delta, gamma, theta = utility.BlackScholesHelper._calculate_greeks_at_boundary(self.equation, delta, gamma, theta, tau, V, S, ds)
141141

142142
end = time.perf_counter()
143143
duration = end - start

pdesolvers/solvers/heat_solvers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def solve(self):
8282
u[:, 0] = self.equation.get_left_boundary(t)
8383
u[:, -1] = self.equation.get_right_boundary(t)
8484

85-
lhs = utility.Heat1DHelper.build_tridiagonal_matrix(a, b, c, self.equation.x_nodes - 2)
85+
lhs = utility.Heat1DHelper._build_tridiagonal_matrix(a, b, c, self.equation.x_nodes - 2)
8686
rhs = np.zeros(self.equation.x_nodes - 2)
8787

8888
for tau in range(0, self.equation.t_nodes - 1):

pdesolvers/utils/utility.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class Heat1DHelper:
99

1010
@staticmethod
11-
def build_tridiagonal_matrix(a, b, c, nodes):
11+
def _build_tridiagonal_matrix(a, b, c, nodes):
1212
"""
1313
Initialises the tridiagonal matrix on the LHS of the equation
1414
@@ -31,7 +31,7 @@ def build_tridiagonal_matrix(a, b, c, nodes):
3131
class BlackScholesHelper:
3232

3333
@staticmethod
34-
def calculate_greeks_at_boundary(equation, delta, gamma, theta, tau, V, S, ds):
34+
def _calculate_greeks_at_boundary(equation, delta, gamma, theta, tau, V, S, ds):
3535
delta[0, tau] = (V[1, tau+1] - V[0, tau+1]) / ds
3636
delta[equation.s_nodes, tau] = (V[equation.s_nodes, tau+1] - V[equation.s_nodes-1, tau+1]) / ds
3737

@@ -44,7 +44,7 @@ def calculate_greeks_at_boundary(equation, delta, gamma, theta, tau, V, S, ds):
4444
return delta, gamma, theta
4545

4646
@staticmethod
47-
def set_boundary_conditions(equation, T, tau):
47+
def _set_boundary_conditions(equation, T, tau):
4848
"""
4949
Sets the boundary conditions for the Black-Scholes Equation based on option type
5050

0 commit comments

Comments
 (0)