Deribit options data pipeline with ClickHouse storage
Project description
gapless-deribit-clickhouse
Deribit options data pipeline with ClickHouse storage.
Features
- Historical trades: Backfillable from 2018 via
history.deribit.com - Ticker snapshots: Point-in-time OI + Greeks (forward-only collection)
- Schema-first: YAML schemas generate types, DDL, and documentation
- Python API: Clean interface for querying options data
Installation
pip install gapless-deribit-clickhouse
Quick Start
import gapless_deribit_clickhouse as gdch
# Fetch historical trades
df = gdch.fetch_trades(
underlying="BTC",
start="2024-01-01",
end="2024-01-31",
option_type="C" # Calls only
)
# Fetch ticker snapshots (OI + Greeks)
df = gdch.fetch_ticker_snapshots(
underlying="BTC",
start="2024-12-01"
)
# Get active instruments
instruments = gdch.get_active_instruments(underlying="BTC")
Data Sources
Trades Table
| Field | Type | Description |
|---|---|---|
| trade_id | String | Unique trade identifier |
| instrument_name | String | e.g., BTC-27DEC24-100000-C |
| timestamp | DateTime64 | Trade time (ms precision) |
| price | Float64 | Trade price in USD |
| amount | Float64 | Contract amount |
| direction | String | buy or sell |
| iv | Float64 | Implied volatility |
| underlying | String | BTC or ETH (derived) |
| expiry | Date | Option expiration (derived) |
| strike | Float64 | Strike price (derived) |
| option_type | String | C or P (derived) |
Ticker Snapshots Table
| Field | Type | Description |
|---|---|---|
| instrument_name | String | e.g., BTC-27DEC24-100000-C |
| timestamp | DateTime64 | Snapshot time (ms precision) |
| open_interest | Float64 | Current OI in contracts |
| delta | Float64 | Option delta (-1 to 1) |
| gamma | Float64 | Option gamma |
| vega | Float64 | Option vega |
| theta | Float64 | Option theta |
| mark_iv | Float64 | Mark implied volatility |
IMPORTANT: Open Interest cannot be reconstructed from trades. The ticker_snapshots table requires forward-only collection.
Instrument Name Format
{UNDERLYING}-{DDMMMYY}-{STRIKE}-{TYPE}
Examples:
BTC-27DEC24-100000-C- BTC call, $100k strike, expires Dec 27 2024ETH-28MAR25-5000-P- ETH put, $5k strike, expires Mar 28 2025
Configuration
Credentials
Set ClickHouse credentials via one of:
-
Environment variables:
export CLICKHOUSE_HOST_READONLY=<host> export CLICKHOUSE_USER_READONLY=<user> export CLICKHOUSE_PASSWORD_READONLY=<password>
-
.envfile in project root -
Doppler (recommended for production):
doppler setup --project gapless-deribit-clickhouse --config prd
Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run linting
ruff check src/
Architecture
๐ Deribit Options Data Pipeline
โโโโโโโโโโโโโโโโโโโโโโโ
โ history.deribit.com โ โโ
โ /get_last_trades โ โ
โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โจ โ
โโโโโโโโโโโโโโโโโโโโโโโ โ
โ TradesCollector โ โ Historical
โ (Historical) โ โ Backfill
โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โจ โ
โโโโโโโโโโโโโโโโโโโโโโโ โ
โ deribit_options โ <โโ
โ .trades โ
โโโโโโโโโโโโโโโโโโโโโโโ
โ
โจ
โญโโโโโโโโโโโโโโโโโโโโโโฎ
โ Python API โ
โ fetch_trades() โ
โ fetch_snapshots() โ
โฐโโโโโโโโโโโโโโโโโโโโโโฏ
โง
โ
โโโโโโโโโโโโโโโโโโโโโโโ
โ deribit_options โ <โโ
โ .ticker_snapshots โ โ
โโโโโโโโโโโโโโโโโโโโโโโ โ
โง โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโ โ
โ TickerCollector โ โ Forward-Only
โ (Forward-Only) โ โ Collection
โโโโโโโโโโโโโโโโโโโโโโโ โ
โง โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโ โ
โ www.deribit.com โ โโ
โ /ticker โ
โโโโโโโโโโโโโโโโโโโโโโโ
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gapless_deribit_clickhouse-0.1.0.tar.gz.
File metadata
- Download URL: gapless_deribit_clickhouse-0.1.0.tar.gz
- Upload date:
- Size: 115.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14703a89381a82d29e635541afad8f04a0aa29ab6829eac34fdc055fa01b7bd3
|
|
| MD5 |
63afd6ad9d142343a615d18e7d033685
|
|
| BLAKE2b-256 |
ae51ebea1d9e4e3bd4527127dd5b6b52c5724d6ce061d3b1c532c343b3d7cd71
|
File details
Details for the file gapless_deribit_clickhouse-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gapless_deribit_clickhouse-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cde23dfab905edeb93f75ad1db4625a53ec9e33fb312fad90036ce37df26b87e
|
|
| MD5 |
7ec33eb73a5c3616e97429c22bd4b7fc
|
|
| BLAKE2b-256 |
9a65808d0da8b083c8412da70925ebf1bdade594b7082a993a2a96931f796683
|