Pricers¶
Execution layer
The library exposes parallel entry points for the three supported usage styles: compact PricingInputs wrappers, curves-first functions, and instrument-based functions.
This page stays reference-first. Use the section headings to jump to the interface style you are calling.
Black-Scholes / Black-76 with PricingInputs¶
These are the compact wrappers for one-container inputs.
bs_price ¶
bs_price(p: PricingInputs) -> float
European option price from PricingInputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
PricingInputs
|
Pricing inputs ( |
required |
Returns:
| Type | Description |
|---|---|
float
|
Option price. |
bs_greeks ¶
bs_greeks(p: PricingInputs) -> dict[str, float]
European option Greeks from PricingInputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
PricingInputs
|
Pricing inputs ( |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dictionary of Greeks: delta, gamma, vega, theta, rho, etc. |
Monte Carlo with PricingInputs¶
Use this path when you want the compact workflow but still need simulation-based pricing.
mc_price ¶
mc_price(p: PricingInputs, *, cfg: MCConfig | None = None) -> tuple[float, float]
Price a European vanilla option using Monte Carlo simulation under a GBM model.
This function builds a McGBMModel from the market/model inputs in p,
simulates terminal prices, evaluates the corresponding vanilla payoff, and
returns the Monte Carlo estimator along with its sampling uncertainty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
PricingInputs
|
Pricing inputs containing (at least) the spot |
required |
cfg
|
MCConfig or None
|
Monte Carlo configuration (path count, variance reduction, RNG policy).
If |
None
|
Returns:
| Type | Description |
|---|---|
(price, stderr) : tuple[float, float]
|
|
Notes
- The option is European and depends only on the terminal underlying price.
- The simulation is performed under the risk-neutral measure with continuous
dividend yield
q. - Reproducibility is controlled via
cfg.random.seed(default 0) or by passing an explicitcfg.rng.
See Also
McGBMModel.price_european : Prices a European payoff via Monte Carlo. make_vanilla_payoff : Constructs the call/put payoff function.
Examples:
>>> from option_pricing.config import MCConfig, RandomConfig
>>> cfg = MCConfig(n_paths=200_000, antithetic=True, random=RandomConfig(seed=123))
>>> price, err = mc_price(p, cfg=cfg)
>>> price, err
(10.42, 0.03)
Binomial CRR with PricingInputs¶
This is the compact tree-based pricing entry point for the flat-input style.
binom_price ¶
binom_price(p: PricingInputs, n_steps: int, *, american: bool = False, method: Literal['tree', 'closed_form'] = 'tree') -> float
Generic binomial pricing using p.spec.kind (CALL/PUT).
method: - "tree": backward induction (Euro or American) - "closed_form": Euro-only binomial sum (fast, no early exercise)
Curves-first pricers¶
These functions keep the market structure explicit through PricingContext and curve objects.
bs_price_from_ctx ¶
bs_price_from_ctx(*, kind: OptionType, strike: float, sigma: float, tau: float, ctx: PricingContext) -> float
European option price using Black-Scholes-Merton model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
OptionType
|
Option type: CALL or PUT. |
required |
strike
|
float
|
Strike price. |
required |
sigma
|
float
|
Implied volatility. |
required |
tau
|
float
|
Time to expiry. |
required |
ctx
|
PricingContext
|
Pricing context providing discount and forward curves. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Option price. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If option kind is not supported. |
bs_greeks_from_ctx ¶
bs_greeks_from_ctx(*, kind: OptionType, strike: float, sigma: float, tau: float, ctx: PricingContext) -> dict[str, float]
European option Greeks using Black-Scholes-Merton model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
OptionType
|
Option type: CALL or PUT. |
required |
strike
|
float
|
Strike price. |
required |
sigma
|
float
|
Implied volatility. |
required |
tau
|
float
|
Time to expiry. |
required |
ctx
|
PricingContext
|
Pricing context providing discount and forward curves. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dictionary of Greeks: delta, gamma, vega, theta, rho, etc. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If option kind is not supported. |
mc_price_from_ctx ¶
mc_price_from_ctx(*, ctx: PricingContext, kind: OptionType, strike: float, sigma: float, tau: float, cfg: MCConfig | None = None) -> tuple[float, float]
Monte Carlo GBM pricer using curves-first inputs.
Notes
The internal GBM model still needs single-number (r, q) inputs. For a curves-first
context we use the average rates consistent with df(tau) and fwd(tau):
r_avg = -log(df)/tau(r-q)_avg = log(F/S)/tau->q_avg = r_avg - (r-q)_avg
This is exact for flat curves and provides a reasonable reduction for deterministic term structures when using a terminal-only (European) GBM simulator.
binom_price_from_ctx ¶
binom_price_from_ctx(*, kind: OptionType, strike: float, sigma: float, tau: float, ctx: PricingContext, n_steps: int, american: bool = False, method: Literal['tree', 'closed_form'] = 'tree') -> float
Binomial (CRR) price from curves-first inputs.
Parameters are expressed in time-to-expiry tau. Discounting and forward
information is supplied via ctx (discount and forward curves).
Instrument-based pricers¶
This is the recommended public layer because the reusable contract object carries payoff and exercise semantics directly.
bs_price_instrument ¶
bs_price_instrument(inst: VanillaOption, *, market: MarketData | PricingContext, sigma: float) -> float
Convenience wrapper accepting flat MarketData.
bs_price_instrument_from_ctx ¶
bs_price_instrument_from_ctx(*, inst: VanillaOption, sigma: float, ctx: PricingContext) -> float
Black-76 price for a vanilla instrument using curves-first inputs.
Notes
inst.expiryis interpreted as time-to-expiry (tau).- Only European exercise is supported by this closed-form pricer.
bs_greeks_instrument ¶
bs_greeks_instrument(inst: VanillaOption, *, market: MarketData | PricingContext, sigma: float) -> dict[str, float]
Convenience wrapper accepting flat MarketData.
bs_greeks_instrument_from_ctx ¶
bs_greeks_instrument_from_ctx(*, inst: VanillaOption, sigma: float, ctx: PricingContext) -> dict[str, float]
Black-76 Greeks for a vanilla instrument using curves-first inputs.
mc_price_instrument ¶
mc_price_instrument(inst: TerminalInstrument, *, market: MarketData | PricingContext, sigma: float, cfg: MCConfig | None = None) -> tuple[float, float]
Convenience wrapper accepting flat MarketData.
mc_price_instrument_from_ctx ¶
mc_price_instrument_from_ctx(*, ctx: PricingContext, inst: TerminalInstrument, sigma: float, cfg: MCConfig | None = None) -> tuple[float, float]
Monte Carlo GBM pricer for a terminal-payoff instrument.
This is the instrument-based equivalent of mc_price_from_ctx.
Notes
inst.expiryis interpreted as time-to-expiry (tau).- Only European exercise is supported by this terminal-only GBM simulator.
binom_price_instrument ¶
binom_price_instrument(inst: TerminalInstrument, *, market: MarketData | PricingContext, sigma: float, n_steps: int, method: Literal['tree', 'closed_form'] = 'tree') -> float
Convenience wrapper accepting flat MarketData.
binom_price_instrument_from_ctx ¶
binom_price_instrument_from_ctx(*, ctx: PricingContext, inst: TerminalInstrument, sigma: float, n_steps: int, method: Literal['tree', 'closed_form'] = 'tree') -> float
Binomial (CRR) price for a terminal-payoff instrument.
Notes
inst.expiryis interpreted as time-to-expiry (tau).- If
inst.exerciseis American,methodmust be "tree".
Notes¶
mc_price*functions return(price, std_error).- Black-Scholes closed-form instrument pricers support European exercise only.
- Tree-based instrument pricers can use the instrument's exercise style, including American exercise where supported.