Theta Curve vs Charm Surface in Optionstratlib: Temporal Greeks Analysis
Theta Curve generates a two-dimensional view of daily time decay across strike prices, while Charm Surface produces a three-dimensional grid tracking how delta sensitivity drifts across both underlying price and time to expiration.
The joaquinbejar/optionstratlib crate provides sophisticated temporal metrics for options analysis through its src/metrics/temporal module. When analyzing time-sensitive Greek exposures, understanding the distinction between theta curve and charm surface is essential for selecting the appropriate risk visualization for your trading strategy.
Understanding Theta Curve (2D Time Decay)
Theta Curve represents the Θ (Theta) Greek, measuring the daily time decay of an option's price. Implemented in src/metrics/temporal/theta.rs, this metric generates a 2D curve (Curve<Point2D>) mapping strike prices to their corresponding theta values.
Implementation and Return Type
In src/chains/chain.rs, the theta_curve() method evaluates option.theta() for each strike in the chain and returns Result<Curve, CurveError>. The resulting structure contains points where the x-coordinate represents the strike price and the y-coordinate represents the theta value (typically negative for long options).
Practical Use Cases
Traders utilize theta curves to identify strikes with the highest time decay, making them invaluable for option-selling strategies. By locating the most negative theta values across the strike spectrum using theta_curve().points.iter().min_by(), you can optimize premium collection while managing assignment risk.
Understanding Charm Surface (3D Delta Decay)
Charm Surface visualizes ψ (Charm), also known as delta decay or DdeltaDtime. This second-order Greek measures how an option's delta changes as time passes. Defined in src/metrics/temporal/charm.rs, it produces a 3D surface (Surface<Point3D>) spanning underlying price, days-to-expiry, and charm magnitude.
Implementation and Return Type
The charm_surface() method in src/chains/chain.rs iterates over a price grid and vector of expiration dates, applying a time-decay scaling factor of sqrt(30 / days) before computing option.charm(). This returns Result<Surface, SurfaceError>, with axes representing underlying price (x), days to expiration (y), and charm value (z).
Practical Use Cases
Charm surfaces enable dynamic hedging schedule optimization by revealing how delta exposure drifts across the price-time plane. This proves critical for maintaining delta-neutral positions as expiration approaches, particularly when managing large portfolios where delta decay risk concentrates in specific time-to-expiration buckets.
Key Technical Differences
The fundamental distinction between these temporal metrics lies in their dimensionality and sensitivity type:
- Theta Curve: One independent variable (strike) yielding a line of points measuring pure time decay via
Curve<Point2D> - Charm Surface: Two independent variables (price and time) yielding a grid measuring delta sensitivity drift via
Surface<Point3D>
While theta_curve() answers "how fast does this option lose value?", charm_surface() answers "how will my hedge ratio change as time passes?"
Working with Temporal Metrics in Rust
Both metrics integrate directly with the OptionChain struct. The following example demonstrates practical usage of each temporal analysis tool:
use optionstratlib::chains::chain::OptionChain;
use optionstratlib::metrics::{ThetaCurve, CharmSurface};
use positive::pos_or_panic;
// Load an option chain from JSON
let chain = OptionChain::load_from_json("options.json")?;
// Generate 2D theta curve for strike analysis
let theta_curve = chain.theta_curve()?;
let most_negative = theta_curve.points.iter()
.min_by(|a, b| a.y.partial_cmp(&b.y).unwrap());
println!(
"Maximum decay strike: {} (θ = {})",
most_negative.unwrap().x,
most_negative.unwrap().y
);
// Generate 3D charm surface for delta drift analysis
let price_range = (pos_or_panic!(400.0), pos_or_panic!(500.0));
let days = vec![
pos_or_panic!(7.0),
pos_or_panic!(14.0),
pos_or_panic!(30.0),
];
let charm_surface = chain.charm_surface(price_range, days, 20)?;
// Query specific point on surface
let target = charm_surface.points.iter()
.find(|p| (p.x - 450.0).abs() < 1e-6 && (p.y - 14.0).abs() < 1e-6);
println!("Charm at 450.0 and 14 days: {}", target.unwrap().z);
Source Code Architecture
The temporal metrics subsystem spans several key files according to the repository structure:
src/metrics/temporal/theta.rs: Defines theThetaCurvetrait and theta calculation logicsrc/metrics/temporal/charm.rs: Defines theCharmSurfacetrait and charm computation algorithmssrc/chains/chain.rs: Implements concrete methodstheta_curve()andcharm_surface()onOptionChainsrc/curves/curve.rs: Provides theCurve<Point2D>type for 2D temporal datasrc/surfaces/surface.rs: Provides theSurface<Point3D>type for 3D Greek visualizationexamples/examples_metrics/src/bin/: Contains example binaries demonstrating visualization output
Summary
- Theta Curve provides 2D visualization of daily time decay (Θ) across strike prices, returning
Result<Curve, CurveError>viasrc/metrics/temporal/theta.rs - Charm Surface generates 3D grids of delta decay (ψ) across price and time dimensions, returning
Result<Surface, SurfaceError>viasrc/metrics/temporal/charm.rs - Theta analysis suits option-selling strategies targeting premium decay, while Charm analysis supports dynamic hedging and delta-neutral portfolio management
- Both metrics integrate through
OptionChainmethods that evaluate underlying Greek functions and apply appropriate dimensional transformations
Frequently Asked Questions
Can I generate a Theta Surface instead of just a Curve?
Yes. The library also implements ThetaSurface in src/metrics/temporal/theta.rs, which creates a 3D surface similar to Charm Surface but mapping theta values across price and time rather than strike alone. This provides a more comprehensive view of time decay evolution across multiple dimensions.
Why does Charm Surface use a sqrt(30 / days) scaling factor?
The scaling factor normalizes charm calculations across different time-to-expiration buckets, ensuring consistent risk measurement when comparing near-term versus far-term options. This adjustment accounts for the non-linear acceleration of delta decay as expiration approaches, as implemented in src/metrics/temporal/charm.rs.
Which temporal metric should I use for short-term option selling?
For short-term premium collection strategies, the Theta Curve is typically more relevant. It directly identifies which strikes offer the highest daily time decay (most negative theta) through the theta_curve() method, allowing you to maximize income from rapid premium erosion without the complexity of multi-dimensional delta drift analysis.
How do I visualize these metrics once generated?
The library includes example binaries in examples/examples_metrics/src/bin/ that demonstrate rendering curves and surfaces to HTML and PNG formats. The generated surfaces can be plotted using the visualization utilities referenced in the crate documentation, enabling graphical analysis of both 2D theta curves and 3D charm surfaces.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →