Skip to main content

Module finite_difference

Module finite_difference 

Source
Expand description

Finite difference pricer for the backward pricing PDE in log-spot.

Features:

  • theta-scheme (Crank-Nicolson with a Rannacher fully-implicit start), cell-averaged terminal conditions (kinks and digital jumps), generic Dirichlet boundaries.
  • Per-node, per-step coefficient assembly: supports the Dupire local vol model (mc_model: "local_vol" applies to this engine too) and term-structure-consistent rates (each time step discounts and drifts at the curve’s forward rate for its own calendar interval). This assembly structure is the 1-D basis a stochastic vol (ADI) solver will extend.
  • American exercise via Brennan-Schwartz (projection inside the tridiagonal solve, swept from the out-of-the-money side).
  • Barrier options: knock-out via an absorbing boundary with the grid edge placed exactly at the barrier; knock-in by parity (European).
  • Greeks from the grid: delta/gamma from a local quadratic fit at the spot, theta from the last two time layers — one solve yields npv/delta/gamma/theta; vega and rho are bump-and-resolve.

Grid sizes are configurable per contract (fd_spot_steps, fd_time_steps in JSON).

Re-exports§

pub use crate::core::fd_solvers::thomas_algorithm;

Structs§

FdConfig
FdSolution
One solve returns the value and the grid Greeks.

Functions§

charm
Charm from the spot derivative of the grid’s calendar theta.
delta
gamma
npv
pricing_result
Value and all nine reported Greeks from a shared set of grid solves instead of a re-solve per Greek: the base solve yields the price plus delta/gamma/theta for free, the two vol-bumped solves yield vega, vanna and zomma together, two rate bumps yield rho, and two spot-bumped solves yield charm — nine solves in total. Each number is produced by exactly the same solves and arithmetic as its accessor above.
rho
solution
Value and grid Greeks in a single solve (two for knock-ins).
theta
vanna
Vanna from the change in the grid delta under a parallel vol bump.
vega
volga
Volga as the second price derivative under a parallel vol bump. A larger step than the first-order Greeks tempers the roundoff amplification of a second difference against the grid’s own discretization error.
zomma
Zomma from the change in the grid gamma under a parallel vol bump.