Skip to content

Commit d04b630

Browse files
committed
docs: add FDM operators and schemes to API reference and changelog
1 parent cc335ce commit d04b630

2 files changed

Lines changed: 338 additions & 1 deletion

File tree

docs/api/methods.md

Lines changed: 308 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,313 @@ mesher.getFdm1dMeshers() # underlying 1D meshers
409409

410410
Helper for applying quanto adjustments in FDM pricing.
411411

412+
## FDM Boundary Conditions
413+
414+
### BoundaryConditionSide
415+
416+
```{eval-rst}
417+
.. autoclass:: pyquantlib.BoundaryConditionSide
418+
:members:
419+
:undoc-members:
420+
```
421+
422+
Side of the domain for boundary conditions: `None_`, `Upper`, `Lower`.
423+
424+
### FdmBoundaryCondition
425+
426+
```{eval-rst}
427+
.. autoclass:: pyquantlib.FdmBoundaryCondition
428+
```
429+
430+
Abstract boundary condition for FDM operators. Used in boundary condition sets passed to schemes.
431+
432+
## FDM Operators
433+
434+
### Building Block Operators
435+
436+
#### TripleBandLinearOp
437+
438+
```{eval-rst}
439+
.. autoclass:: pyquantlib.TripleBandLinearOp
440+
```
441+
442+
Tridiagonal (triple-band) linear operator on one grid dimension.
443+
444+
```python
445+
mesher = ql.FdmMesherComposite(ql.Uniform1dMesher(0.0, 1.0, 10))
446+
op = ql.TripleBandLinearOp(0, mesher)
447+
448+
result = op.apply(array)
449+
result = op.solve_splitting(rhs, a, b)
450+
op2 = op.mult(array)
451+
op3 = op.add(other_op)
452+
```
453+
454+
#### FirstDerivativeOp
455+
456+
```{eval-rst}
457+
.. autoclass:: pyquantlib.FirstDerivativeOp
458+
```
459+
460+
Central first-derivative operator (inherits from `TripleBandLinearOp`).
461+
462+
```python
463+
d_dx = ql.FirstDerivativeOp(0, mesher)
464+
gradient = d_dx.apply(values)
465+
```
466+
467+
#### SecondDerivativeOp
468+
469+
```{eval-rst}
470+
.. autoclass:: pyquantlib.SecondDerivativeOp
471+
```
472+
473+
Central second-derivative operator (inherits from `TripleBandLinearOp`).
474+
475+
```python
476+
d2_dx2 = ql.SecondDerivativeOp(0, mesher)
477+
laplacian = d2_dx2.apply(values)
478+
```
479+
480+
#### NinePointLinearOp
481+
482+
```{eval-rst}
483+
.. autoclass:: pyquantlib.NinePointLinearOp
484+
```
485+
486+
Nine-point cross-derivative operator on two grid dimensions.
487+
488+
#### SecondOrderMixedDerivativeOp
489+
490+
```{eval-rst}
491+
.. autoclass:: pyquantlib.SecondOrderMixedDerivativeOp
492+
```
493+
494+
Second-order mixed partial derivative operator (inherits from `NinePointLinearOp`).
495+
496+
```python
497+
d2_dxdy = ql.SecondOrderMixedDerivativeOp(0, 1, mesher)
498+
```
499+
500+
### Process Operators
501+
502+
Process-specific PDE operators, all inheriting from `FdmLinearOpComposite`. These encode the drift, diffusion, and cross terms for a given stochastic process. Constructed from a mesher and the corresponding process; the inherited methods (`size`, `setTime`, `apply`, `apply_mixed`, `apply_direction`, `solve_splitting`, `preconditioner`) are called internally by FDM schemes.
503+
504+
#### FdmBlackScholesOp
505+
506+
```{eval-rst}
507+
.. autoclass:: pyquantlib.FdmBlackScholesOp
508+
```
509+
510+
Black-Scholes PDE operator.
511+
512+
```python
513+
op = ql.FdmBlackScholesOp(mesher, process, strike=100.0)
514+
```
515+
516+
#### FdmBlackScholesFwdOp
517+
518+
```{eval-rst}
519+
.. autoclass:: pyquantlib.FdmBlackScholesFwdOp
520+
```
521+
522+
Black-Scholes forward (Fokker-Planck) operator.
523+
524+
#### Fdm2dBlackScholesOp
525+
526+
```{eval-rst}
527+
.. autoclass:: pyquantlib.Fdm2dBlackScholesOp
528+
```
529+
530+
Two-dimensional correlated Black-Scholes operator.
531+
532+
#### FdmHestonOp
533+
534+
```{eval-rst}
535+
.. autoclass:: pyquantlib.FdmHestonOp
536+
```
537+
538+
Heston stochastic volatility PDE operator.
539+
540+
```python
541+
op = ql.FdmHestonOp(mesher, heston_process)
542+
```
543+
544+
#### FdmHestonFwdOp
545+
546+
```{eval-rst}
547+
.. autoclass:: pyquantlib.FdmHestonFwdOp
548+
```
549+
550+
Heston forward (Fokker-Planck) operator.
551+
552+
#### FdmHestonHullWhiteOp
553+
554+
```{eval-rst}
555+
.. autoclass:: pyquantlib.FdmHestonHullWhiteOp
556+
```
557+
558+
Three-factor Heston plus Hull-White operator.
559+
560+
#### FdmBatesOp
561+
562+
```{eval-rst}
563+
.. autoclass:: pyquantlib.FdmBatesOp
564+
```
565+
566+
Bates (Heston + jumps) PDE operator.
567+
568+
#### FdmHullWhiteOp
569+
570+
```{eval-rst}
571+
.. autoclass:: pyquantlib.FdmHullWhiteOp
572+
```
573+
574+
Hull-White short-rate PDE operator.
575+
576+
#### FdmG2Op
577+
578+
```{eval-rst}
579+
.. autoclass:: pyquantlib.FdmG2Op
580+
```
581+
582+
Two-factor Gaussian short-rate (G2) PDE operator.
583+
584+
#### FdmCEVOp
585+
586+
```{eval-rst}
587+
.. autoclass:: pyquantlib.FdmCEVOp
588+
```
589+
590+
Constant Elasticity of Variance PDE operator.
591+
592+
#### FdmSabrOp
593+
594+
```{eval-rst}
595+
.. autoclass:: pyquantlib.FdmSabrOp
596+
```
597+
598+
SABR stochastic volatility PDE operator.
599+
600+
#### FdmLocalVolFwdOp
601+
602+
```{eval-rst}
603+
.. autoclass:: pyquantlib.FdmLocalVolFwdOp
604+
```
605+
606+
Local volatility forward (Fokker-Planck) operator.
607+
608+
#### FdmSquareRootFwdOp
609+
610+
```{eval-rst}
611+
.. autoclass:: pyquantlib.FdmSquareRootFwdOp
612+
```
613+
614+
Square-root (CIR) forward operator, used in Heston SLV calibration.
615+
616+
#### FdmOrnsteinUhlenbeckOp
617+
618+
```{eval-rst}
619+
.. autoclass:: pyquantlib.FdmOrnsteinUhlenbeckOp
620+
```
621+
622+
Ornstein-Uhlenbeck mean-reverting PDE operator.
623+
624+
## FDM Schemes
625+
626+
Time-stepping schemes for evolving the PDE solution backward (or forward) in time. All schemes share the same interface:
627+
628+
```python
629+
scheme.setStep(dt) # set time step size
630+
array = scheme.step(array, t) # advance one step from time t
631+
```
632+
633+
The `step` method returns the modified array (Python copy semantics).
634+
635+
### ExplicitEulerScheme
636+
637+
```{eval-rst}
638+
.. autoclass:: pyquantlib.ExplicitEulerScheme
639+
```
640+
641+
Forward Euler (explicit) time stepping.
642+
643+
### ImplicitEulerScheme
644+
645+
```{eval-rst}
646+
.. autoclass:: pyquantlib.ImplicitEulerScheme
647+
```
648+
649+
Backward Euler (implicit) time stepping with iterative solver.
650+
651+
```python
652+
scheme = ql.ImplicitEulerScheme(op, relTol=1e-8)
653+
scheme.numberOfIterations() # solver iterations from last step
654+
```
655+
656+
#### ImplicitEulerSolverType
657+
658+
```{eval-rst}
659+
.. autoclass:: pyquantlib.ImplicitEulerSolverType
660+
:members:
661+
:undoc-members:
662+
```
663+
664+
Iterative solver for implicit schemes: `BiCGstab`, `GMRES`.
665+
666+
### CrankNicolsonScheme
667+
668+
```{eval-rst}
669+
.. autoclass:: pyquantlib.CrankNicolsonScheme
670+
```
671+
672+
Crank-Nicolson (theta = 0.5) time stepping.
673+
674+
```python
675+
scheme = ql.CrankNicolsonScheme(0.5, op)
676+
scheme.numberOfIterations()
677+
```
678+
679+
### DouglasScheme
680+
681+
```{eval-rst}
682+
.. autoclass:: pyquantlib.DouglasScheme
683+
```
684+
685+
Douglas ADI time-stepping scheme.
686+
687+
### CraigSneydScheme
688+
689+
```{eval-rst}
690+
.. autoclass:: pyquantlib.CraigSneydScheme
691+
```
692+
693+
Craig-Sneyd ADI time-stepping scheme.
694+
695+
### HundsdorferScheme
696+
697+
```{eval-rst}
698+
.. autoclass:: pyquantlib.HundsdorferScheme
699+
```
700+
701+
Hundsdorfer ADI time-stepping scheme.
702+
703+
### ModifiedCraigSneydScheme
704+
705+
```{eval-rst}
706+
.. autoclass:: pyquantlib.ModifiedCraigSneydScheme
707+
```
708+
709+
Modified Craig-Sneyd ADI time-stepping scheme.
710+
711+
### MethodOfLinesScheme
712+
713+
```{eval-rst}
714+
.. autoclass:: pyquantlib.MethodOfLinesScheme
715+
```
716+
717+
Method of lines (Runge-Kutta) time-stepping scheme.
718+
412719
```{note}
413-
Abstract base classes `BrownianGenerator`, `BrownianGeneratorFactory`, and `FdmMesher` are available in `pyquantlib.base` for type checking.
720+
Abstract base classes `FdmLinearOp`, `FdmLinearOpComposite`, `BrownianGenerator`, `BrownianGeneratorFactory`, and `FdmMesher` are available in `pyquantlib.base` for type checking.
414721
```

docs/changelog.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
118118
- `FdmMesher` ABC for multi-dimensional FDM meshers
119119
- `FdmMesherComposite` composite multi-dimensional mesher built from 1D meshers (1D-4D convenience constructors)
120120
- `FdmQuantoHelper` helper for FDM quanto adjustment with scalar and Array overloads
121+
- `FdmBoundaryCondition` ABC for FDM boundary conditions with `BoundaryConditionSide` enum (None\_, Upper, Lower)
122+
- `FdmLinearOp` ABC with `apply()` for polymorphic operator calls
123+
- `FdmLinearOpComposite` ABC with `size`, `setTime`, `apply_mixed`, `apply_direction`, `solve_splitting`, `preconditioner`
124+
- `TripleBandLinearOp` tridiagonal operator with `apply`, `solve_splitting`, `mult`, `multR`, `add`, `axpyb`
125+
- `FirstDerivativeOp` central first-derivative operator
126+
- `SecondDerivativeOp` central second-derivative operator
127+
- `NinePointLinearOp` nine-point cross-derivative operator with `apply`, `mult`
128+
- `SecondOrderMixedDerivativeOp` second-order mixed partial derivative operator
129+
- `FdmBlackScholesOp` Black-Scholes PDE operator
130+
- `FdmBlackScholesFwdOp` Black-Scholes forward (Fokker-Planck) operator
131+
- `Fdm2dBlackScholesOp` two-dimensional correlated Black-Scholes operator
132+
- `FdmHestonOp` Heston stochastic volatility PDE operator
133+
- `FdmHestonFwdOp` Heston forward (Fokker-Planck) operator
134+
- `FdmHestonHullWhiteOp` three-factor Heston + Hull-White operator
135+
- `FdmBatesOp` Bates (Heston + jumps) PDE operator
136+
- `FdmHullWhiteOp` Hull-White short-rate PDE operator
137+
- `FdmG2Op` two-factor Gaussian short-rate (G2) PDE operator
138+
- `FdmCEVOp` Constant Elasticity of Variance PDE operator
139+
- `FdmSabrOp` SABR stochastic volatility PDE operator
140+
- `FdmLocalVolFwdOp` local volatility forward (Fokker-Planck) operator
141+
- `FdmSquareRootFwdOp` square-root (CIR) forward operator with `lowerBoundaryFactor`, `upperBoundaryFactor`, `v`
142+
- `FdmOrnsteinUhlenbeckOp` Ornstein-Uhlenbeck mean-reverting PDE operator
143+
- `ExplicitEulerScheme` forward Euler time stepping
144+
- `ImplicitEulerScheme` backward Euler time stepping with `ImplicitEulerSolverType` enum (BiCGstab, GMRES) and `numberOfIterations`
145+
- `CrankNicolsonScheme` Crank-Nicolson time stepping with `numberOfIterations`
146+
- `DouglasScheme` Douglas ADI time-stepping scheme
147+
- `CraigSneydScheme` Craig-Sneyd ADI time-stepping scheme
148+
- `HundsdorferScheme` Hundsdorfer ADI time-stepping scheme
149+
- `ModifiedCraigSneydScheme` Modified Craig-Sneyd ADI time-stepping scheme
150+
- `MethodOfLinesScheme` method of lines (Runge-Kutta) time-stepping scheme
121151

122152
#### Random Number Generators
123153
- `MersenneTwisterUniformRng` (MT19937) with seed and vector-seed constructors

0 commit comments

Comments
 (0)