-
Notifications
You must be signed in to change notification settings - Fork 29
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationpriority-lowNice-to-have improvementsNice-to-have improvements
Description
Issue #14: Improve documentation for metrics modules
Title
docs: Add comprehensive documentation for metrics modules
Labels
documentationpriority-low
Description
The new metrics modules (composite/, liquidity/, stress/, temporal/) need more comprehensive documentation with examples.
Current State
- Basic documentation exists
- Limited examples
- Mathematical background could be expanded
Target State
- All public items have documentation
- Examples are runnable
- Mathematical formulas are explained
Tasks
- Add module-level documentation with overview for:
src/metrics/composite/(Vanna-Volga, Delta-Gamma, Smile Dynamics)src/metrics/liquidity/(Bid-Ask Spread, Volume Profile, Open Interest)src/metrics/stress/(Volatility Sensitivity, Time Decay, Price Shock)src/metrics/temporal/(Theta, Charm, Color)
- Add examples for each trait implementation
- Add mathematical background where appropriate
- Add usage examples in doc comments
- Verify examples compile with
cargo test --doc - Run
make lint-fixandmake pre-pushto verify
Acceptance Criteria
- All public items have documentation
- Examples are runnable (
cargo test --docpasses) - Mathematical formulas are explained
- Documentation follows library style
Technical Notes
Documentation Template
/// # Vanna-Volga Hedge Surface
///
/// Computes the Vanna-Volga hedge cost surface across price and volatility.
///
/// ## Mathematical Background
///
/// The Vanna-Volga method adjusts Black-Scholes prices to account for
/// the volatility smile using three benchmark options:
///
/// ```text
/// Price_VV = Price_BS + Vanna × (σ_market - σ_ATM) × S × √T
/// + 0.5 × Volga × (σ_market - σ_ATM)²
/// ```
///
/// ## Example
///
/// ```rust
/// use optionstratlib::prelude::*;
/// use optionstratlib::metrics::VannaVolgaSurface;
///
/// let chain = OptionChain::new("SPY", pos!(450.0), "2024-12-31".to_string(), None, None);
/// let price_range = (pos!(400.0), pos!(500.0));
/// let vol_range = (pos!(0.10), pos!(0.40));
///
/// let surface = chain.vanna_volga_surface(price_range, vol_range, 20, 20)?;
/// println!("Surface has {} points", surface.points.len());
/// # Ok::<(), optionstratlib::error::SurfaceError>(())
/// ```
///
/// ## Returns
///
/// A `Surface` where:
/// - **X-axis**: Underlying price in currency units
/// - **Y-axis**: Implied volatility as a decimal
/// - **Z-axis**: Vanna-Volga hedge cost/adjustment
pub trait VannaVolgaSurface {
// ...
}Files to Update
src/metrics/composite/mod.rssrc/metrics/composite/vanna_volga.rssrc/metrics/composite/delta_gamma_profile.rssrc/metrics/composite/smile_dynamics.rssrc/metrics/liquidity/mod.rssrc/metrics/liquidity/bid_ask_spread.rssrc/metrics/liquidity/volume_profile.rssrc/metrics/liquidity/open_interest.rssrc/metrics/stress/mod.rssrc/metrics/stress/volatility_sensitivity.rssrc/metrics/stress/time_decay.rssrc/metrics/stress/price_shock.rssrc/metrics/temporal/mod.rssrc/metrics/temporal/theta.rssrc/metrics/temporal/charm.rssrc/metrics/temporal/color.rs
Estimated Effort
Low (2-4 hours)
Dependencies
None
Related Issues
None
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationpriority-lowNice-to-have improvementsNice-to-have improvements