Public API¶
Root-level exports
This page covers the main objects re-exported from option_pricing.
Use it to find the shared public types before diving into the dedicated pricer, curves, or volatility reference pages.
Core types¶
These are the root-level typed containers used throughout the convenience API and as bridges into the richer market-context workflows.
OptionType ¶
Bases: StrEnum
Option type enumeration.
Attributes:
| Name | Type | Description |
|---|---|---|
CALL |
European or American call option. |
|
PUT |
European or American put option. |
MarketData
dataclass
¶
Flat market data container.
Primarily a convenience structure for common Black-Scholes and binomial tree scenarios.
For richer market structures (term structures, stochastic rates), use
PricingContext instead.
Attributes:
| Name | Type | Description |
|---|---|---|
spot |
float
|
Spot price at valuation time. |
rate |
float
|
Continuously-compounded domestic risk-free rate. |
dividend_yield |
float
|
Continuously-compounded dividend yield (default: 0.0). |
df ¶
df(T: float, t: float = 0.0) -> float
Discount factor from time t to T.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T
|
float
|
Maturity time. |
required |
t
|
float
|
Valuation time (default: 0.0). |
0.0
|
Returns:
| Type | Description |
|---|---|
float
|
Discount factor P(0, T-t) = exp(-r * tau). |
forward ¶
forward(T: float, t: float = 0.0) -> float
Forward price from time t for delivery at T.
Uses the cost-of-carry model: F(t,T) = S(t) * exp((r - q) * (T - t)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T
|
float
|
Maturity time. |
required |
t
|
float
|
Valuation time (default: 0.0). |
0.0
|
Returns:
| Type | Description |
|---|---|
float
|
Forward price. |
to_context ¶
to_context() -> PricingContext
Convert to a PricingContext.
Returns:
| Type | Description |
|---|---|
PricingContext
|
Curves-first market container with flat discount and forward curves. |
OptionSpec
dataclass
¶
Specification of a vanilla option.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
OptionType
|
Option type (call or put). |
strike |
float
|
Strike price. |
expiry |
float
|
Expiry time in years. In the legacy |
PricingInputs
dataclass
¶
All inputs needed to price an option.
Generic over the option specification (vanilla, digital, etc.).
Attributes:
| Name | Type | Description |
|---|---|---|
spec |
SpecT
|
Option specification ( |
market |
MarketData
|
Market data ( |
sigma |
float
|
Implied volatility. |
t |
float
|
Current valuation time (default: 0.0). |
Notes
PricingInputs follows the legacy flat-input convention where
spec.expiry is the absolute expiry T and tau = T - t.
Instrument layer¶
The instrument workflow is the recommended public path because the contract carries payoff and exercise semantics explicitly.
Lightweight instrument interfaces.
The library exposes both a "PricingInputs" API (flat, tutorial-friendly) and an instrument-based API for pricers that operate on terminal payoffs.
Only a small subset is required by the pricers in this repository: - an exercise style (European/American) - a time-to-expiry (tau) - a vectorizable payoff function of the terminal underlying price
ExerciseStyle ¶
Bases: StrEnum
Exercise style for vanilla options.
Vanilla (call/put) instruments and payoffs.
This module provides two small building blocks:
VanillaPayoff: a vectorized terminal payoff (call/put)VanillaOption: an instrument wrapper bundling expiry + exercise + payoff
VanillaPayoff
dataclass
¶
Callable, vectorized call/put payoff.
__call__ ¶
__call__(ST: float) -> float
__call__(ST: FloatArray) -> FloatArray
__call__(ST: float | FloatArray) -> float | FloatArray
Evaluate payoff at terminal price(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ST
|
float | FloatArray
|
Terminal price(s). |
required |
Returns:
| Type | Description |
|---|---|
float or FloatArray
|
Option payoff(s) at maturity. |
VanillaOption
dataclass
¶
Vanilla option instrument.
Notes
expiry is interpreted as time to expiry (tau).
payoff
property
¶
payoff: TerminalPayoff
Terminal payoff function.
Returns:
| Type | Description |
|---|---|
TerminalPayoff
|
A callable |
intrinsic_value ¶
intrinsic_value(spot: float) -> float
intrinsic_value(spot: FloatArray) -> FloatArray
intrinsic_value(spot: float | FloatArray) -> float | FloatArray
Intrinsic value at a given spot price.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spot
|
float | FloatArray
|
Current spot price(s). |
required |
Returns:
| Type | Description |
|---|---|
float or FloatArray
|
Intrinsic value(s) at current spot. |
Market context and curves¶
These names are re-exported from the package root so callers can move from flat inputs to explicit market curves without changing namespaces.
PricingContextDiscountCurveForwardCurveFlatDiscountCurveFlatCarryForwardCurve
See the dedicated Curves-first API page for the canonical class documentation.
Configuration and solver selection¶
These configuration types control Monte Carlo sampling and implied-vol inversion behavior without being tied to a single pricing style.
RandomConfig
dataclass
¶
Random number generator configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
seed |
int
|
Seed value for reproducibility (default: 0). |
rng_type |
RngType
|
RNG algorithm: 'pcg64', 'mt19937', or 'sobol' (default: 'pcg64'). |
MCConfig
dataclass
¶
Monte Carlo pricing configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
n_paths |
int
|
Number of Monte Carlo paths (default: 100,000). |
antithetic |
bool
|
Use antithetic variates for variance reduction (default: False). |
random |
RandomConfig
|
Random number generator configuration ( |
rng |
Generator | None
|
Optional pre-constructed numpy RandomGenerator. If None, one is created from the random config. |
ImpliedVolConfig
dataclass
¶
Configuration for implied volatility (IV) solvers.
Controls root-finding algorithm, bounds, seeding strategy, and numerical tolerances.
Attributes:
| Name | Type | Description |
|---|---|---|
root_method |
RootMethod
|
Root-finding method from |
sigma_lo |
float
|
Lower volatility bound (default: 1e-8). |
sigma_hi |
float
|
Upper volatility bound (default: 5.0). |
bounds_eps |
float
|
Slack for bracket bounds (default: 1e-12). |
seed_strategy |
SeedStrategy
|
Initial guess strategy from |
numerics |
NumericsConfig
|
Numerical solver configuration ( |
RootMethod ¶
Bases: StrEnum
Supported root-finding methods.
Notes
This enum is used to select a concrete solver from the internal registry
(:data:ROOT_METHODS). Using an enum avoids "magic strings" and makes
method selection type-safe.
Volatility objects¶
The package root keeps the common smile and surface objects close to the pricing API, while the broader volatility namespace carries the heavier calibration stack.
VolSurfaceSmile
See the dedicated Volatility page for the canonical class documentation.
The broader volatility namespace option_pricing.vol also exposes the eSSVI toolbox, including:
ESSVIImpliedSurfaceESSVINodalSurfaceESSVISmoothedSurfacecalibrate_essviproject_essvi_nodes