Quantitative Python engine for pricing, implied volatility analysis, volatility surface construction, risk measurement, mispricing detection, and simple backtesting for equity options.
- Data ingestion with two providers:
syntheticfor deterministic local developmentyahooviayfinancewhen optional market-data dependencies are installedalpha_vantagefor historical options chains on specific dates when an API key is availablecsvfor local historical vendor exports or manually supplied datasets
- Pricing models:
- Black-Scholes
- Binomial tree
- Heston stochastic volatility model
- Implied volatility solver using Newton-Raphson with bisection fallback
- Volatility surface builder from contract-level IV observations
- Greeks and portfolio-level risk aggregation
- Heston calibration against observed option prices
- Mispricing detection engine with ranked trade signals
- Backtesting module for convergence-style signal evaluation
- CLI entrypoint for running the full workflow end-to-end
src/equity_options_engine/
cli.py
pipeline.py
models.py
implied_vol.py
surface.py
calibration.py
signals.py
portfolio.py
backtest.py
data/providers.py
pricing/
black_scholes.py
binomial.py
heston.py
Create a virtual environment and install the package:
python3 -m venv .venv
source .venv/bin/activate
pip install -e .To enable Yahoo Finance ingestion as well:
pip install -e ".[market-data]"Run the full engine with synthetic market data:
eovre --symbol SPY --source syntheticPrint JSON output:
eovre --symbol AAPL --source synthetic --jsonTry Yahoo Finance data when dependencies are available:
eovre --symbol SPY --source yahooRun a historical stress-period pricing study with local CSV data:
eovre study --source csv --csv-path data/your_historical_options.csv --covid-2020 --symbols SPY AAPL MSFT QQQ IWMCSV columns expected by the engine are shown in historical_options_template.csv. Minimum useful fields per row are:
quote_dateunderlyingunderlying_priceexpirationoption_typestrikebidasklast
If available, also include:
implied_volatilityvolumeopen_interestrisk_free_ratedividend_yield
The predefined --covid-2020 study uses these exact stress-session dates:
2020-02-24, 2020-02-27, 2020-03-09, 2020-03-12, 2020-03-16, 2020-03-18, 2020-03-20, 2020-03-23, 2020-03-24, 2020-03-26, 2020-04-01, 2020-04-06
The full pipeline in pipeline.py performs the following steps:
- Load an options chain and underlying spot snapshot.
- Solve implied volatility for each option contract.
- Build an interpolated implied volatility surface.
- Calibrate Heston parameters to market option prices.
- Reprice the chain with the calibrated model.
- Flag mispricings above a threshold.
- Aggregate portfolio Greeks for the top signals.
- Run a simple convergence-style backtest.
The historical study mode additionally:
- Pulls full historical chains for each requested symbol/date.
- Filters invalid contracts and counts total coverage.
- Prices each contract with Black-Scholes, binomial, and Heston-style models.
- Compares model prices with observed market prices.
- Reports MAE, RMSE, MAPE, and the share of contracts priced within 5% and 10%.
Run the smoke tests with:
python3 -m pytest- The synthetic provider makes the project runnable without API keys or internet access.
- Alpha Vantage's historical options endpoint is a premium API, so the most practical route is often importing a reputable vendor CSV instead.
- The file at
data/historical_options_template.csvis only a schema template, not real market data. - The Heston implementation is designed for research and prototyping rather than low-latency production trading.
- The backtest is intentionally simple and should be extended with transaction costs, liquidity filters, holding rules, and risk limits before real use.