Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoYunhan committed Nov 30, 2024
1 parent 3cca02b commit ef69e26
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,11 @@ The Crank-Nicolson method is a second-order, implicit time-stepping scheme that
Transform the Black-Scholes PDE:
$\frac{\partial V}{\partial t} + \frac{1}{2} \sigma^2 S^2 \frac{\partial^2 V}{\partial S^2} + (r - q) S \frac{\partial V}{\partial S} - rV = 0$
into a tridiagonal system of equations using the transformation $\( x = \ln(S) \)$.
- **Parameter $\( N \)$**: The number of grid points in the spatial dimension (log price $\( x \)$). A higher $\( N \)$ provides finer spatial resolution.
- **Parameter $\( M \)$**: The number of time steps used for backward time-stepping. A higher $\( M \)$ ensures smaller time steps and improves stability.

2. **Set Initial and Boundary Conditions**:
- Initial condition: Payoff at \( t = T \):
- Initial condition: Payoff at $\( t = T \)$:
$V(S, T) = \max(K - S, 0) \quad \text{(Put)}, \quad V(S, T) = \max(S - K, 0) \quad \text{(Call)}.$
- Boundary conditions at $\( S \to 0 \)$ and $\( S \to \infty \)$ are derived based on option type and time decay.

Expand Down Expand Up @@ -347,10 +349,12 @@ solver = CrankNicolsonSolver(
volatility=0.2, # Volatility (20%)
strike=50, # Strike price
maturity=1, # Time to maturity (1 year)
option_type=option_type
option_type=option_type,
N=250, # Number of grid points for spatial discretization
M=250 # Number of time steps
)
solver.max_dt = 0.01 # Maximum time step
solver.USE_PSOR = True # Enable PSOR for early exercise

solver.USE_PSOR = True # Enable PSOR for early exercise

# Solve for option price
S0 = 50
Expand Down

0 comments on commit ef69e26

Please sign in to comment.