Skip to main content

Equity derivatives analytics in Python (FST solver, Heston, vol surfaces).

Project description

cedardev-equity-derivatives

Equity derivatives analytics in Python.

v0.5.0 — Track A buildout: Black-Scholes, Heston, Carr-Madan FFT pricer, analytic & numerical Greeks, implied vol, SVI smile calibration, market curves. v0.4.0 — Track B: Fourier Space Time-stepping (FST) solver — six Lévy models with European, American, and barrier pricers.

Status

Companion to cedardev-fixed-income.

Track Module What's inside
A cedardev.equity.models BlackScholes, Heston (with char_function)
A cedardev.equity.pricers VanillaOption, CarrMadanPricer
A cedardev.equity.greeks bsm_greeks (analytic), numerical_greeks (FD)
A cedardev.equity.vol implied_vol, VolSurface, SVIParams
A cedardev.equity.calibration fit_svi_slice
A cedardev.equity.market DiscountCurve, DividendCurve, forward
B cedardev.equity.solvers.fst 6 Lévy models, FSTEuropean, FSTAmerican, FSTBarrier

Installation

pip install cedardev-equity-derivatives

Optional extras:

pip install "cedardev-equity-derivatives[fft]"   # adds pyfftw
pip install "cedardev-equity-derivatives[dev]"   # pytest, ruff, mypy, build, twine
pip install "cedardev-equity-derivatives[docs]"  # mkdocs + mkdocs-material

Quick start — Track A

Black-Scholes with Greeks

from cedardev.equity.models import BlackScholes
from cedardev.equity.pricers import VanillaOption
from cedardev.equity.greeks import bsm_greeks

m = BlackScholes(spot=100, r=0.03, q=0.01, sigma=0.20)
opt = VanillaOption(strike=100, expiry=1.0, option_type="call")
print(opt.price(m))                              # 8.8273
print(bsm_greeks(m, K=100, T=1.0, option_type="call"))

Heston with Carr-Madan FFT

from cedardev.equity.models import Heston
from cedardev.equity.pricers import VanillaOption

heston = Heston(spot=100, r=0.03, q=0.01,
                v0=0.04, kappa=2.0, theta=0.04, sigma_v=0.5, rho=-0.7)
print(VanillaOption(100, 1.0, "call").price(heston))   # 8.2535
print(heston.feller_satisfied())                       # False -> watch v

Implied vol

from cedardev.equity.vol import implied_vol

iv = implied_vol(market_price=12.50, spot=100, K=95,
                 r=0.03, q=0.01, T=1.0, option_type="call")

SVI smile calibration

import numpy as np
from cedardev.equity.calibration import fit_svi_slice
from cedardev.equity.vol import svi_implied_vol
from cedardev.equity.market import DiscountCurve, DividendCurve, forward

F = forward(100, 1.0, DiscountCurve(0.03), DividendCurve(0.01))
K  = np.array([60, 80, 100, 120, 140])
iv = np.array([0.32, 0.26, 0.22, 0.21, 0.23])

fit = fit_svi_slice(K, iv, T=1.0, forward=F)
fit_iv = svi_implied_vol(fit, np.log(K / F), T=1.0)

Quick start — Track B (FST)

European under Variance Gamma

from cedardev.equity.solvers.fst import VarianceGamma, FSTEuropean

m = VarianceGamma(spot=100, r=0.03, q=0.01, sigma=0.2, nu=0.2, theta=-0.1)
print(FSTEuropean(m).price(100, 1.0, "call"))

American put under Merton jump diffusion

from cedardev.equity.solvers.fst import MertonJD, FSTAmerican

m = MertonJD(spot=100, r=0.05, q=0.0,
             sigma=0.15, lam=0.3, mu_j=-0.1, sigma_j=0.2)
am_put = FSTAmerican(m, n_grid=2 ** 13, n_time=300).price(100, 1.0, "put")

Up-and-out call under Kou (continuously monitored)

from cedardev.equity.solvers.fst import Kou, FSTBarrier

m = Kou(spot=100, r=0.03, q=0.01, sigma=0.15,
        lam=1.0, p=0.4, eta1=10.0, eta2=5.0)
uo = FSTBarrier(m, n_grid=2 ** 13, n_time=400) \
        .price(K=100, T=1.0, option_type="call",
               barrier=130, barrier_type="UO", monitoring="continuous")

Lévy catalog (Track B)

Model Class Parameters
Black-Scholes-Merton BSMLevy sigma
Merton (1976) jump-diffusion MertonJD sigma, lam, mu_j, sigma_j
Kou (2002) double-exponential Kou sigma, lam, p, eta1, eta2
Variance Gamma VarianceGamma sigma, nu, theta
Normal Inverse Gaussian NIG alpha, beta, delta
CGMY CGMY C, G, M, Y

All satisfy the risk-neutral martingale condition psi(-i) = r - q.

Repository layout

cedardev-equity-derivatives/
├── cedardev/
│   └── equity/
│       ├── models/          # BlackScholes, Heston       (Track A)
│       ├── pricers/         # VanillaOption, CarrMadan   (Track A)
│       ├── vol/             # implied vol, surface, SVI  (Track A)
│       ├── calibration/     # SVI slice fit              (Track A)
│       ├── greeks/          # analytic + numerical       (Track A)
│       ├── market/          # DiscountCurve, etc.        (Track A)
│       ├── utils/           # BSM helper formulas        (Track A)
│       ├── risk/            # placeholder for future
│       └── solvers/
│           └── fst/         # FST + 6 Levy models        (Track B)
├── tests/
├── pyproject.toml
├── README.md
├── LICENSE
└── CHANGELOG.md

Development

git clone https://github.com/cedardev-capital/cedardev-equity-derivatives.git
cd cedardev-equity-derivatives
pip install -e ".[dev]"
pytest                          # 98 tests
ruff check .
mypy cedardev

Citation

@software{cedardev_equity_derivatives,
  author  = {CedarDev Capital Management LLC},
  title   = {cedardev-equity-derivatives: Equity Derivatives Analytics in Python},
  year    = {2026},
  url     = {https://github.com/cedardev-capital/cedardev-equity-derivatives}
}

References

  • Black, F., & Scholes, M. (1973). The Pricing of Options and Corporate Liabilities. JPE.
  • Heston, S. (1993). A Closed-Form Solution for Options with Stochastic Volatility... RFS.
  • Carr, P., & Madan, D. (1999). Option Valuation Using the Fast Fourier Transform. JCF.
  • Albrecher, H., et al. (2007). The Little Heston Trap. Wilmott.
  • Gatheral, J. (2004). A parsimonious arbitrage-free implied volatility parameterization (SVI).
  • Surkov, V. (2009). Option Pricing using Fourier Space Time-stepping Framework. PhD thesis, U. Toronto. SSRN 1479738.

License

MIT — see LICENSE.

Disclaimer

This library is provided for research, education, and infrastructure prototyping. It is not a production trading system and carries no warranty. Use at your own risk.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cedardev_equity_derivatives-0.5.0.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cedardev_equity_derivatives-0.5.0-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

Details for the file cedardev_equity_derivatives-0.5.0.tar.gz.

File metadata

File hashes

Hashes for cedardev_equity_derivatives-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a0c1e4b59b1141c8e07fe30a2c163666084ce634847d546d1d9cfc058776f085
MD5 85254c37cb5d16e078e08deab007cbf3
BLAKE2b-256 20923e03024c042a0f07fa44e77042ad5033664b09ee361d5726305bca048d56

See more details on using hashes here.

File details

Details for the file cedardev_equity_derivatives-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cedardev_equity_derivatives-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1ee5c0f4f0b47cc9a3ac3eab3e4ebb5bfe85c5d1f683dd9e820634365a878c8
MD5 fec7c3981a1358685ff545dc96e67195
BLAKE2b-256 062fb034ddaf55909cfbd3b7393a749eebc400595bdeeb96022fd84a6d7d4689

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page