Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Avhz RustQuant Black Scholes Merton Pricing

From Leeroopedia


Knowledge Sources
Domains Option_Pricing, Quantitative_Finance
Last Updated 2026-02-07 19:00 GMT

Overview

Concrete tool for pricing European options using the generalised Black-Scholes-Merton model with full Greeks computation provided by the RustQuant library.

Description

This module implements the generalised Black-Scholes-Merton (BSM) European option pricing model via the BlackScholesMerton struct. By varying the cost-of-carry parameter b, it supports five sub-models:

  • b = r -- Black-Scholes 1973 stock option model
  • b = r - q -- Merton 1973 stock option model with continuous dividend yield
  • b = 0 -- Black 1976 futures option model
  • b = 0, r = 0 -- Asay 1982 margined futures option model
  • b = r_d - r_f -- Garman-Kohlhagen 1983 currency option model

The struct implements the Instrument trait and provides methods for the option price plus a comprehensive set of Greeks: delta, gamma, vega, theta, rho, vanna, charm, lambda (elasticity), zomma, speed, colour, vomma, ultima, vega bleed, phi, zeta, strike delta, and strike gamma. It also provides an implied_volatility() method that delegates to the Let's Be Rational algorithm. Date handling uses the time crate with the Actual/365.25 day count convention via a builder pattern (derive_builder).

Usage

Use when pricing European call or put options under the generalised BSM framework, or when computing any first-, second-, or third-order Greeks analytically.

Code Reference

Source Location

Signature

#[derive(derive_builder::Builder)]
pub struct BlackScholesMerton {
    pub cost_of_carry: f64,
    pub underlying_price: f64,
    pub strike_price: f64,
    pub volatility: f64,
    pub risk_free_rate: f64,
    pub evaluation_date: Option<Date>,
    pub expiration_date: Date,
    pub option_type: TypeFlag,
}

impl BlackScholesMerton {
    pub fn new(
        cost_of_carry: f64,
        underlying_price: f64,
        strike_price: f64,
        volatility: f64,
        risk_free_rate: f64,
        evaluation_date: Option<Date>,
        expiration_date: Date,
        option_type: TypeFlag,
    ) -> Self

    pub fn price(&self) -> f64
    pub fn implied_volatility(&self, price: f64) -> f64
    pub fn delta(&self) -> f64
    pub fn gamma(&self) -> f64
    pub fn vega(&self) -> f64
    pub fn theta(&self) -> f64
    pub fn rho(&self) -> f64
    pub fn vanna(&self) -> f64
    pub fn charm(&self) -> f64
    pub fn lambda(&self) -> f64
    pub fn zomma(&self) -> f64
    pub fn speed(&self) -> f64
    pub fn colour(&self) -> f64
    pub fn vomma(&self) -> f64
    pub fn ultima(&self) -> f64
    pub fn vega_bleed(&self) -> f64
    pub fn phi(&self) -> f64
    pub fn zeta(&self) -> f64
    pub fn strike_delta(&self) -> f64
    pub fn strike_gamma(&self) -> f64
}

Import

use RustQuant::instruments::{BlackScholesMerton, TypeFlag};

I/O Contract

Inputs

Name Type Required Description
cost_of_carry f64 Yes Cost of carry factor (b); determines the sub-model
underlying_price f64 Yes Current price of the underlying asset (S)
strike_price f64 Yes Option strike price (K)
volatility f64 Yes Volatility of the underlying (sigma)
risk_free_rate f64 Yes Risk-free interest rate (r)
evaluation_date Option<Date> No Valuation date; defaults to today
expiration_date Date Yes Option expiration date
option_type TypeFlag Yes Call or Put

Outputs

Name Type Description
price f64 The BSM European option price
greeks f64 Individual Greek values from their respective methods

Usage Examples

use RustQuant::instruments::{BlackScholesMerton, TypeFlag};
use time::Duration;
use RustQuant::time::today;

let bsm = BlackScholesMerton::new(
    0.08,           // cost_of_carry (b = r for BS73 stock model)
    60.0,           // underlying_price
    65.0,           // strike_price
    0.3,            // volatility
    0.08,           // risk_free_rate
    None,           // evaluation_date (defaults to today)
    today() + Duration::days(91),  // expiration_date
    TypeFlag::Call,
);

let price = bsm.price();
let delta = bsm.delta();
let gamma = bsm.gamma();
let vega  = bsm.vega();
let theta = bsm.theta();

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment