Skip to content

Repository files navigation

quant-options-engine

A real-time options mispricing and volatility-surface engine for crypto options (Deribit / Binance). It inverts every live quote to its implied volatility, fits an arbitrage-checked volatility surface, compares each quote against a model fair value, and surfaces only those dislocations that survive transaction costs.

The design premise: a signal means "this quote is off the arbitrage-checked smile its own market implies" — a self-contained dislocation detector that needs no external calibration target. A calibrated Heston or Merton fair-IV function can be substituted instead.

Status: research prototype, actively being built. It is a research and analytics tool — it places no orders and connects to no broker.

What is implemented

Layer Contents
models/ Black–Scholes with full Greeks, implied-volatility inversion, Heston, Merton jump-diffusion, SABR
surface/ SVI volatility-surface calibration per expiry, with a spline fallback and fit diagnostics
signals/no_arbitrage.py Put–call parity, vertical monotonicity, butterfly convexity and calendar-spread checks, reported as explicit violations
signals/engine.py Mispricing engine, cost-aware edge computation, and a Bayesian reliability score per pricing model that drives adaptive model selection
backtest/ Signal-level backtest harness with exit resolution and cost-aware P&L attribution
data/ Deribit and Binance adapters, a synthetic chain generator for tests, and SQLite storage
dashboard/ Streamlit dashboard over the live pipeline
config.py Every threshold, cost assumption and convention in one auditable place

Design decisions worth noting

  • Edge is always net of costs. The cost model encodes the Deribit taker fee (min(3 bps of underlying, 12.5% of premium)) plus the actual half bid–ask spread of the quote, and a candidate is never surfaced if its edge sits inside costs.
  • No-arbitrage checks run before signals. A smile that violates butterfly convexity or parity is reported as a data/market-structure problem rather than silently priced.
  • ACT/365 day count throughout (crypto trades continuously), with a minimum time-to-expiry floor below which IV inversion is numerically unstable.
  • Every knob lives in config.py so a run is reproducible and auditable.

Quickstart

python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

# Dashboard. Defaults to the synthetic feed, so it runs with zero network access.
streamlit run dashboard/app.py

Programmatic use — the feed is an async chain stream, and analysis is a pure function of a chain:

import asyncio
from quant_options_engine.config import DEFAULT_CONFIG
from quant_options_engine.data.deribit import DeribitFeed
from quant_options_engine.pipeline import analyze_chain

async def main():
    feed = DeribitFeed(currency="BTC")
    await feed.connect()
    async for chain in feed.stream_chains():
        analysis = analyze_chain(chain, DEFAULT_CONFIG)
        for s in analysis.signals[:10]:
            print(s)
        break
    await feed.close()

asyncio.run(main())

analyze_chain fits the surface, runs the no-arbitrage suite and generates cost-netted signals; pass fair_iv_fn=heston_fair_iv(...) to price against a calibrated model instead of the market's own smile.

Layout

models/     pricing models + Greeks + IV inversion
surface/    SVI calibration and surface diagnostics
signals/    no-arbitrage suite, mispricing engine, model selection
backtest/   signal backtest harness
data/       exchange adapters, synthetic generator, SQLite storage
dashboard/  Streamlit app
pipeline.py chain -> market IVs -> fitted surface -> ranked signals
config.py   thresholds, cost model, conventions

Roadmap

  • Persist full surface history for term-structure and skew time-series research
  • Walk-forward validation of the mispricing signal with multiple-testing correction
  • Delta-hedged P&L attribution (separating vol edge from directional drift)

Author

Chirag Agarwal — CFA Level I passed, Level II candidate. LinkedIn

License

MIT — see LICENSE.

About

Crypto options pricing and volatility-surface engine: Black-Scholes/Heston/Merton/SABR, Gatheral SVI calibration, model-free no-arbitrage checks, and mispricing signals netted against costs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages