Files
ferro-ta/docs/derivatives-analytics.md
T
Pratik Bhadane 602d675749 feat: add full derivatives analytics layer (options + futures)
Implements all phases of the derivatives expansion plan:

Rust core (crates/ferro_ta_core/src/options/, src/futures/):
- BSM and Black-76 pricing (scalar + vectorized batch)
- Greeks: delta, gamma, vega, theta, rho
- Implied volatility solver (Newton + bisection fallback)
- Smile/skew metrics: ATM IV, 25-delta RR/BF, skew slope, convexity
- Chain helpers: moneyness labels, strike selection by offset or delta
- Synthetic forwards, basis, annualized basis, implied carry, carry spread
- Continuous contract stitching: weighted, back-adjusted, ratio-adjusted
- Curve analytics: calendar spreads, slope, contango/backwardation summary

PyO3 bindings (src/options/, src/futures/):
- All Rust functions registered and exposed via _ferro_ta extension

Python API (python/ferro_ta/analysis/):
- options.py: pricing, greeks, IV, smile, chain, legacy iv_rank/percentile/zscore
- futures.py: basis, carry, curve, roll, synthetic, continuous contracts
- options_strategy.py: typed strategy schemas (expiry/strike selectors, leg presets, risk controls, simulation limits)
- derivatives_payoff.py: multi-leg payoff aggregation and Greeks aggregation

Bug fix: wrap _to_f64 calls in iv_rank/iv_percentile/iv_zscore to raise
FerroTAInputError (not plain ValueError) for 2D array input.

Docs: derivatives.rst, derivatives-analytics.md, options-volatility.md,
quickstart.rst, index.rst, api/analysis.rst all updated.

Tests: 2053 pass, 12 skipped. All CI checks pass locally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 02:41:50 +05:30

2.5 KiB

Derivatives Analytics

ferro-ta now includes a Rust-backed derivatives analytics layer focused on research, simulation, and risk analysis.

Modules

  • ferro_ta.analysis.options
    • Black-Scholes-Merton and Black-76 pricing
    • Delta, gamma, vega, theta, rho
    • Implied volatility inversion with guarded Newton + bisection fallback
    • IV rank / percentile / z-score
    • Smile metrics: ATM IV, 25-delta risk reversal, butterfly, skew slope, convexity
    • Chain helpers: moneyness labels and strike selection by offset or delta
  • ferro_ta.analysis.futures
    • Synthetic forwards and parity diagnostics
    • Basis, annualized basis, implied carry, carry spread
    • Continuous contract stitching: weighted, back-adjusted, ratio-adjusted
    • Curve analytics: calendar spreads, slope, contango summary
  • ferro_ta.analysis.options_strategy
    • Typed strategy schemas for expiry selectors, strike selectors, multi-leg presets, risk controls, cost assumptions, and simulation limits
  • ferro_ta.analysis.derivatives_payoff
    • Multi-leg payoff aggregation
    • Portfolio-level Greeks aggregation across option and futures legs

Model conventions

  • model="bsm" expects the underlying input to be spot and carry to represent a continuous dividend yield or generic carry term.
  • model="black76" expects the underlying input to be the forward price.
  • Volatility and rates use decimal units:
    • 0.20 means 20% annualized volatility
    • 0.05 means 5% annualized rate
  • time_to_expiry is expressed in years.

Quick examples

from ferro_ta.analysis.options import greeks, implied_volatility, option_price

price = option_price(100.0, 100.0, 0.05, 1.0, 0.20, option_type="call")
iv = implied_volatility(price, 100.0, 100.0, 0.05, 1.0, option_type="call")
g = greeks(100.0, 100.0, 0.05, 1.0, 0.20, option_type="call")
print(price, iv, g.delta)
from ferro_ta.analysis.futures import basis, curve_summary

print(basis(100.0, 103.0))
print(curve_summary(100.0, [0.1, 0.5, 1.0], [101.0, 102.0, 104.0]))
from ferro_ta.analysis.derivatives_payoff import PayoffLeg, strategy_payoff

legs = [
    PayoffLeg("option", "long", option_type="call", strike=100.0, premium=5.0),
    PayoffLeg("future", "long", entry_price=100.0),
]
grid = [90.0, 100.0, 110.0]
print(strategy_payoff(grid, legs=legs))

Notes

  • Existing iv_rank, iv_percentile, and iv_zscore names are preserved.
  • The derivatives layer is analytics-only: there is no broker connectivity, order routing, or execution workflow in this API.