Implementation:Avhz RustQuant AnalyticOptionPricer Greeks
| Knowledge Sources | |
|---|---|
| Domains | Derivatives, Risk_Management, Option_Pricing |
| Last Updated | 2026-02-07 20:00 GMT |
Overview
Concrete tool for computing option price sensitivities (Greeks) through the AnalyticOptionPricer engine provided by the RustQuant instruments crate.
Description
When AnalyticOptionPricer is specialized with EuropeanVanillaOption and a GBSM model, the european_vanilla_option_gbsm! macro generates 14 Greek computation methods plus a report() method. Each method extracts strike, time-to-expiry (via year_fraction), and type flag from the option, then delegates to the model's corresponding pricing formula.
For Heston93, a subset of Greeks (price, delta, gamma, rho) is available. For Bachelier, price, delta, gamma, theta, vega, and implied volatility methods are provided.
Usage
After creating an AnalyticOptionPricer, call individual Greek methods or use report() to print all available Greeks at once.
Code Reference
Source Location
- Repository: RustQuant
- File: crates/RustQuant_instruments/src/options/vanilla.rs
- Lines: L68-375 (Greek methods for all model variants)
- File: crates/RustQuant_instruments/src/options/option_models.rs
- Lines: L304-1146 (underlying BSM, Heston, Bachelier formulas)
Signature
// For GBSM models (BlackScholes73, Merton73, Black76, Asay82, GarmanKohlhagen83):
impl AnalyticOptionPricer<EuropeanVanillaOption, BlackScholes73> {
pub fn price(&self) -> f64
pub fn delta(&self) -> f64
pub fn gamma(&self) -> f64
pub fn theta(&self) -> f64
pub fn vega(&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 color(&self) -> f64
pub fn vomma(&self) -> f64
pub fn ultima(&self) -> f64
pub fn report(&self) // prints HashMap of all Greeks
}
// For Heston93:
impl AnalyticOptionPricer<EuropeanVanillaOption, Heston93> {
pub fn price(&self) -> f64
pub fn delta(&self) -> f64
pub fn gamma(&self) -> f64
pub fn rho(&self) -> f64
pub fn report(&self)
}
// For Bachelier:
impl AnalyticOptionPricer<EuropeanVanillaOption, Bachelier> {
pub fn price(&self) -> f64
pub fn delta(&self) -> f64
pub fn gamma(&self) -> f64
pub fn theta(&self) -> f64
pub fn vega(&self) -> f64
pub fn atm_price(&self) -> f64
pub fn atm_vol(&self, price: f64) -> f64
pub fn iv(&self, price: f64) -> f64
pub fn report(&self)
}
Import
use RustQuant::instruments::AnalyticOptionPricer;
// Greek methods are available directly on the pricer instance
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| self | AnalyticOptionPricer<EuropeanVanillaOption, Model> | Yes | The pricer with option and model already set |
Outputs
| Name | Type | Description |
|---|---|---|
| price() | f64 | Option price |
| delta() | f64 | First derivative with respect to spot price |
| gamma() | f64 | Second derivative with respect to spot price |
| theta() | f64 | Derivative with respect to time (time decay) |
| vega() | f64 | Derivative with respect to volatility |
| rho() | f64 | Derivative with respect to interest rate |
| vanna() | f64 | Cross-derivative: delta w.r.t. volatility |
| charm() | f64 | Cross-derivative: delta w.r.t. time |
| lambda() | f64 | Leverage ratio (elasticity) |
| zomma() | f64 | Derivative of gamma w.r.t. volatility |
| speed() | f64 | Derivative of gamma w.r.t. spot |
| color() | f64 | Derivative of gamma w.r.t. time |
| vomma() | f64 | Derivative of vega w.r.t. volatility |
| ultima() | f64 | Derivative of vomma w.r.t. volatility |
| report() | () | Prints HashMap of all available Greeks to stdout |
Usage Examples
Computing Individual Greeks
use RustQuant::instruments::{
AnalyticOptionPricer, BlackScholes73,
EuropeanVanillaOption, TypeFlag,
};
use time::macros::date;
let option = EuropeanVanillaOption::new(100.0, date!(2025 - 12 - 31), TypeFlag::Call);
let model = BlackScholes73::new(100.0, 0.05, 0.20);
let pricer = AnalyticOptionPricer::new(option, model);
println!("Price: {:.4}", pricer.price());
println!("Delta: {:.4}", pricer.delta());
println!("Gamma: {:.6}", pricer.gamma());
println!("Theta: {:.4}", pricer.theta());
println!("Vega: {:.4}", pricer.vega());
println!("Rho: {:.4}", pricer.rho());
println!("Vanna: {:.6}", pricer.vanna());
println!("Vomma: {:.6}", pricer.vomma());
Full Report
// Prints all Greeks as a formatted HashMap
pricer.report();
// Output:
// Model: BlackScholes73 { s: 100.0, r: 0.05, v: 0.2 }
// Option: EuropeanVanillaOption { strike: 100.0, ... }
// { "price": ..., "delta": ..., "gamma": ..., ... }