Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:Avhz RustQuant Volatility Surface

From Leeroopedia


Knowledge Sources
Domains Volatility_Modeling, Derivatives_Pricing
Last Updated 2026-02-07 21:00 GMT

Overview

Volatility surface construction and term structure management for multi-dimensional financial data indexed by time and maturity.

Description

The Volatility Surface in RustQuant provides a two-dimensional data structure for storing and querying financial data that varies across two axes, typically strike/moneyness and expiry time. The Surface struct is built on top of the library's curve and term structure primitives.

The Surface struct stores its data as a BTreeMap<u64, TermStructure>, where the outer key represents a time dimension (e.g., expiry or tenor) and each value is a TermStructure -- an ordered map from Date to f64 rate values. The BTreeMap ensures that nodes are maintained in sorted order, enabling efficient lookups and range queries.

Key operations on the Surface include:

  • new() -- Create an empty surface.
  • add_node(time, term_structure) -- Insert a term structure at a given time index.
  • get_term_structure(time) -- Retrieve the term structure for a specific time, returning Option<&TermStructure>.

The surface builds on the broader data module's curve infrastructure, which supports multiple curve types (Flat, Spot, Forward, Discount) and interpolation methods. Curves in the data module can be fit to Nelson-Siegel-Svensson models via particle swarm optimization and support lazy fitting -- the model is only calibrated when a rate is requested for a date not present in the original data.

Usage

Use the Volatility Surface principle when modeling implied volatility across multiple strikes and expiries, constructing interest rate surfaces (e.g., swaption volatility cubes), or any financial application requiring two-dimensional interpolation of market data. The surface is typically populated with market-observed data and then queried to retrieve term structures for specific time points.

Theoretical Basis

A volatility surface σ(K,T) maps each combination of strike K and time to expiry T to an implied volatility. In practice, the surface is constructed from a discrete set of market observations and interpolated or fitted to a parametric model.

The surface can be viewed as a collection of volatility smiles (cross-sections at fixed T) or as a collection of term structures (cross-sections at fixed K):

σ(K,T)=Surface[{TiTermStructurei(K)}i=1n]

The underlying TermStructure stores date-value pairs in a BTreeMap<Date, f64>, maintaining chronological ordering. When combined with the library's curve fitting capabilities (Nelson-Siegel-Svensson model), the surface supports smooth interpolation between observed market points.

The Nelson-Siegel-Svensson model for term structures is:

r(τ)=β0+β11eτ/λ1τ/λ1+β2(1eτ/λ1τ/λ1eτ/λ1)+β3(1eτ/λ2τ/λ2eτ/λ2)

Related Pages

Implemented By

Page Connections

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