abaquant.derivatives.vanilla¶
Import path: abaquant.derivatives.vanilla
Domain: Derivative pricing, simulation, calibration, diagnostics, and strategy analysis.
Purpose¶
Vanilla option pricing and Greeks under Black–Scholes–Merton and Black–76.
When to use it¶
Use this package when valuing contingent claims, calculating Greeks, building option strategies, simulating stochastic processes, or fitting models to market observations.
Public objects¶
function:
bsm_option_prices— Compute Black–Scholes-style call and put prices and the intermediate d statistics.function:
bsm_greeks— Compute first-order Black–Scholes-style Greeks for calls and puts.function:
black_scholes— Price a European option under the Black–Scholes–Merton model.function:
vanilla_intrinsic_value— Return the immediate-exercise value of a vanilla option.function:
vanilla_extrinsic_value— Return option value in excess of immediate-exercise value.function:
black_76— Price a European option on a forward or futures price under Black–76.function:
bsm_d1_d2— Compute the Black–Scholes–Merton d1 and d2 statistics.function:
calculate_greeks— Return the standard Black–Scholes–Merton Greeks for one option type.function:
second_order_greeks— Compute selected second-order Black–Scholes–Merton sensitivity measures.function:
implied_volatility_bsm— Solve for Black–Scholes–Merton implied volatility with Brent root finding.
Detailed reference¶
Vanilla option pricing and Greeks under Black–Scholes–Merton and Black–76.
Purpose¶
The module prices European calls and puts, computes first- and selected second-order Greeks, and inverts a Black–Scholes–Merton premium for implied volatility.
Conventions¶
Spot, strike, and option value share currency units. Maturity is in years. Rates and continuous yields are continuously compounded decimal annual rates; volatility is annualized decimal volatility.
Scope and limitations¶
The analytical formulas assume lognormal diffusion with constant model inputs and European exercise.
References
[ 1 ] Black, F., and M. Scholes (1973), “The Pricing of Options and Corporate Liabilities”; Merton, R. C. (1973), “Theory of Rational Option Pricing”.
- abaquant.derivatives.vanilla.black_76(F0, K, r, sigma, T, is_call=True)¶
Price a European option on a forward or futures price under Black–76.
- Parameters:
F0 (float) – Current futures or forward price, in currency units.
K (float) – Option strike price in the same currency units as the underlying.
r (float) – Continuously compounded risk-free annual rate in decimal units.
sigma (float) – Annualized lognormal volatility in decimal units; for example,
0.20denotes 20%.T (float) – Time to maturity in years.
is_call (bool, default=True) – Whether the instrument is a call; false selects a put.
- Returns:
Computed black 76 as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.derivatives.vanilla.black_scholes(S, K, r, sigma, T, is_call=True, q=0.0)¶
Price a European option under the Black–Scholes–Merton model.
- Parameters:
S (float) – Current underlying spot price in currency units.
K (float) – Option strike price in the same currency units as the underlying.
r (float) – Continuously compounded risk-free annual rate in decimal units.
sigma (float) – Annualized lognormal volatility in decimal units; for example,
0.20denotes 20%.T (float) – Time to maturity in years.
is_call (bool, default=True) – Whether the instrument is a call; false selects a put.
q (float, default=0.0) – Continuous dividend or carry yield in decimal annual units.
- Returns:
Computed black scholes as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.derivatives.vanilla.bsm_d1_d2(S, K, r, q, sigma, T)¶
Compute the Black–Scholes–Merton d1 and d2 statistics.
- Parameters:
S (float) – Current underlying spot price in currency units.
K (float) – Option strike price in the same currency units as the underlying.
r (float) – Continuously compounded risk-free annual rate in decimal units.
q (float) – Continuous dividend or carry yield in decimal annual units.
sigma (float) – Annualized lognormal volatility in decimal units; for example,
0.20denotes 20%.T (float) – Time to maturity in years.
- Returns:
(d1, d2)for the stated Black–Scholes–Merton inputs.- Return type:
tuple[float, float]
Notes
Model inputs are interpreted according to the module-level rate, maturity, and volatility conventions. Numerical outputs depend on the validity of those assumptions.
- abaquant.derivatives.vanilla.bsm_greeks(model_type, S, K, T, r, sigma, extra=0.0)¶
Compute first-order Black–Scholes-style Greeks for calls and puts.
- Parameters:
model_type (str) – Legacy model selector controlling the Black–Scholes-style carry convention.
S (float) – Current underlying spot price in currency units.
K (float) – Option strike price in the same currency units as the underlying.
T (float) – Time to maturity in years.
r (float) – Continuously compounded risk-free annual rate in decimal units.
sigma (float) – Annualized lognormal volatility in decimal units; for example,
0.20denotes 20%.extra (float, default=0.0) – Model-specific carry, income, cost, or yield adjustment.
- Returns:
(delta_call, delta_put, gamma, vega, theta_call, theta_put, rho_call, rho_put)under the module scaling convention.- Return type:
tuple[float, float, float, float, float, float, float, float]
Notes
Model inputs are interpreted according to the module-level rate, maturity, and volatility conventions. Numerical outputs depend on the validity of those assumptions.
- abaquant.derivatives.vanilla.bsm_option_prices(model_type, S, K, T, r, sigma, extra=0.0)¶
Compute Black–Scholes-style call and put prices and the intermediate d statistics.
- Parameters:
model_type (str) – Legacy model selector controlling the Black–Scholes-style carry convention.
S (float) – Current underlying spot price in currency units.
K (float) – Option strike price in the same currency units as the underlying.
T (float) – Time to maturity in years.
r (float) – Continuously compounded risk-free annual rate in decimal units.
sigma (float) – Annualized lognormal volatility in decimal units; for example,
0.20denotes 20%.extra (float, default=0.0) – Model-specific carry, income, cost, or yield adjustment.
- Returns:
(call, put, d1, d2)in positional order. Prices use the same currency units as the underlying and strike.- Return type:
tuple[float, float, float, float]
Notes
Model inputs are interpreted according to the module-level rate, maturity, and volatility conventions. Numerical outputs depend on the validity of those assumptions.
- abaquant.derivatives.vanilla.calculate_greeks(S, K, r, sigma, T, is_call=True, q=0.0)¶
Return the standard Black–Scholes–Merton Greeks for one option type.
- Parameters:
S (float) – Current underlying spot price in currency units.
K (float) – Option strike price in the same currency units as the underlying.
r (float) – Continuously compounded risk-free annual rate in decimal units.
sigma (float) – Annualized lognormal volatility in decimal units; for example,
0.20denotes 20%.T (float) – Time to maturity in years.
is_call (bool, default=True) – Whether the instrument is a call; false selects a put.
q (float, default=0.0) – Continuous dividend or carry yield in decimal annual units.
- Returns:
Dictionary of named model outputs, metrics, or workflow results defined by the current public schema.
- Return type:
dict[str, object]
Notes
Model inputs are interpreted according to the module-level rate, maturity, and volatility conventions. Numerical outputs depend on the validity of those assumptions.
- abaquant.derivatives.vanilla.implied_volatility_bsm(market_price, S, K, r, T, is_call=True, q=0.0, lower=1e-6, upper=10.0)¶
Solve for Black–Scholes–Merton implied volatility with Brent root finding.
- Parameters:
market_price (float) – Observed option premium in the same currency units as spot and strike.
S (float) – Current underlying spot price in currency units.
K (float) – Option strike price in the same currency units as the underlying.
r (float) – Continuously compounded risk-free annual rate in decimal units.
T (float) – Time to maturity in years.
is_call (bool, default=True) – Whether the instrument is a call; false selects a put.
q (float, default=0.0) – Continuous dividend or carry yield in decimal annual units.
lower (float, default=1e-06) – Lower root-search or interval bound.
upper (float, default=10.0) – Upper root-search or interval bound.
- Returns:
Computed implied volatility bsm as a dimensionless decimal quantity.
- Return type:
float
Notes
Model inputs are interpreted according to the module-level rate, maturity, and volatility conventions. Numerical outputs depend on the validity of those assumptions.
- abaquant.derivatives.vanilla.second_order_greeks(S, K, r, q, sigma, T, is_call=True)¶
Compute selected second-order Black–Scholes–Merton sensitivity measures.
- Parameters:
S (float) – Current underlying spot price in currency units.
K (float) – Option strike price in the same currency units as the underlying.
r (float) – Continuously compounded risk-free annual rate in decimal units.
q (float) – Continuous dividend or carry yield in decimal annual units.
sigma (float) – Annualized lognormal volatility in decimal units; for example,
0.20denotes 20%.T (float) – Time to maturity in years.
is_call (bool, default=True) – Whether the instrument is a call; false selects a put.
- Returns:
Dictionary of named model outputs, metrics, or workflow results defined by the current public schema.
- Return type:
dict[str, object]
Notes
Model inputs are interpreted according to the module-level rate, maturity, and volatility conventions. Numerical outputs depend on the validity of those assumptions.
- abaquant.derivatives.vanilla.vanilla_extrinsic_value(option_price, S, K, is_call=True)¶
Return option value in excess of immediate-exercise value.
- Parameters:
option_price (float) – Model or market option premium in currency units.
S (float) – Current underlying spot price in currency units.
K (float) – Option strike price in the same currency units as the underlying.
is_call (bool, default=True) – Whether the instrument is a call; false selects a put.
- Returns:
Option premium minus intrinsic value. Negative values are preserved to expose inconsistent inputs rather than silently truncating the result.
- Return type:
float
- abaquant.derivatives.vanilla.vanilla_intrinsic_value(S, K, is_call=True)¶
Return the immediate-exercise value of a vanilla option.
- Parameters:
S (float) – Current underlying spot price in currency units.
K (float) – Option strike price in the same currency units as the underlying.
is_call (bool, default=True) – Whether the instrument is a call; false selects a put.
- Returns:
max(S-K, 0)for a call andmax(K-S, 0)for a put.- Return type:
float