Skip to main content

derivatives

Python library for equity derivatives pricing and risk analytics: GARCH volatility estimation, Black–Scholes pricing, Greeks, and implied-volatility surface construction. Part of the QFIN workspace alongside fixed-income, equity, and risk.

Roadmap

Phase Scope Status
I Repo skeleton, package layout, CI scripts Done
II Dataset management (via datasets package + domain chain builder) Done
III Models (GARCH, Black–Scholes, Greeks, IV surface) Done
IV Charts, Dash dashboards, Tableau exports Done

Capabilities (target)

Capability Status
GARCH(1,1) volatility forecast Implemented ([models] extra)
Black–Scholes European pricer Implemented
Analytical Greeks (Δ, Γ, Θ, ν, ρ) Implemented
IV surface via BS inversion Implemented
Massive.com data ingest (stocks, options, Treasury yields) Implemented ([data] extra, backed by datasets)
Plotly Dash risk monitor Implemented ([viz] extra)
Tableau Hyper/CSV exports + workbook templates Implemented ([tableau] extra)

Install

python3 -m pip install -e .

Optional extras:

python3 -m pip install -e '.[data]'      # datasets[data], requests, pandas, python-dotenv
python3 -m pip install -e '.[models]'    # arch (GARCH)
python3 -m pip install -e '.[viz]'       # plotly, dash, matplotlib, …
python3 -m pip install -e '.[tableau]'   # pyarrow, pantab
python3 -m pip install -e '.[dev]'       # pytest, ruff, build
python3 -m pip install -e '.[dev,data,models,viz,tableau]'

Quickstart

Runnable end-to-end script (from repo root, with .env set):

conda activate fixed_income   # or your env with derivatives installed
cd derivatives
python3 -m pip install -e '.[data,models,viz,tableau]'

python3 scripts/quickstart.py                    # full pipeline (~12 API calls)
python3 scripts/quickstart.py --skip-options     # stock + treasury only (~2 calls)
python3 scripts/quickstart.py --serve            # + Dash risk monitor
from datetime import date
from derivatives.data import (
    CachedDataSource,
    MassiveStockHistorySource,
    MassiveTreasuryYieldsSource,
    load_project_dotenv,
)

load_project_dotenv()
stock = CachedDataSource(MassiveStockHistorySource("SPY")).fetch(as_of=date.today())
treasury = CachedDataSource(MassiveTreasuryYieldsSource()).fetch(as_of=date.today())
print(stock.spot(), treasury.latest_point().yield_10_year)

Price a chain with GARCH + Black–Scholes:

from derivatives import price_option_chain
from derivatives.data import MassiveOptionChainSource

chain = MassiveOptionChainSource("SPY", max_contracts=20).fetch(as_of=date.today())
result = price_option_chain(chain, stock, treasury)
print(result.garch_sigma, len(result.surface.points))

Ingest to Parquet:

python3 scripts/ingest_market_data.py --as-of 2026-06-06 --underlying SPY --skip-options

Dash risk monitor

from derivatives.dashboards import create_risk_monitor_app

app = create_risk_monitor_app(result, chain, stock)
app.run(debug=True)

Tableau export

from derivatives.dashboards import export_tableau_bundle

export_tableau_bundle(result, chain, stock)
# → data/processed/{as_of}/tableau/*.hyper and *.csv

Project layout

derivatives/
├── derivatives/          # Python package
│   ├── data/             # DataSource adapters, cache, types
│   ├── models/           # GARCH, Black–Scholes, IV surface
│   ├── charts/           # Plotly figures
│   └── dashboards/       # Dash apps + Tableau exports
├── data/
│   ├── raw/              # Manual CSV fallbacks (gitignored)
│   └── processed/        # Parquet snapshots (gitignored)
├── scripts/              # ingest_market_data.py, build scripts
├── tests/
├── docs/
└── examples/             # Jupyter notebooks (Phase IV)

Development

bash scripts/build_test.sh

Data access details: docs/data_access.md.

Release files for qfin-derivatives 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qfin-derivatives 0.1.0
File Size Uploaded
qfin_derivatives-0.1.0.tar.gz 52.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qfin-derivatives 0.1.0
File Interpreter ABI Platform
qfin_derivatives-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size:96.6 kB

Release files / qfin_derivatives-0.1.0.tar.gz

Download URL qfin_derivatives-0.1.0.tar.gz
Size 52.4 kB
Tags Source
SHA-256 checksum
How to use checksums
083eb610c5948a50a66d628ed567a618081babaf491812cd4e98e61831022cf5
BLAKE2b-256 checksum
How to use checksums
43e289e84559ad26da6388681183c70e26d4909015ab5ab6c96ac0b90f0a2f84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / qfin_derivatives-0.1.0-py3-none-any.whl

Download URL qfin_derivatives-0.1.0-py3-none-any.whl
Size 44.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c648d46e6b755ad3a8353deed07e08784cbfbb821741bd7cc09da9c193c1ccc1
BLAKE2b-256 checksum
How to use checksums
ed3a9c604fa6767455aba8a8396a73ee92b98b67652ae8452d40eb2f5e594db3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page