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 - Schema-first: YAML schemas generate types, DDL, and documentation
- Python API: Clean interface for querying options data
- BTC + ETH options: Focused on Deribit options trading 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
)
# Collect trades to ClickHouse
gdch.collect_trades(
underlying="BTC",
start="2024-01-01"
)
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) |
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
+---------------------+
| history.deribit.com |
| /get_last_trades |
+---------------------+
|
v
+---------------------+
| TradesCollector | Historical
| (Backfill) | Backfill
+---------------------+
|
v
+=====================+
| deribit |
| .options_trades |
+=====================+
|
v
+---------------------+
| Python API |
| fetch_trades() |
| collect_trades() |
+---------------------+
ADR: 2025-12-08-clickhouse-naming-convention
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-2.1.0.tar.gz.
File metadata
- Download URL: gapless_deribit_clickhouse-2.1.0.tar.gz
- Upload date:
- Size: 197.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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 |
af3c47c796c20119327e78990e766032f3fb59a8cccfd4b7b989f131bc4782ae
|
|
| MD5 |
b46fc5b9247cf5bbd50b063f90d4a349
|
|
| BLAKE2b-256 |
ecae91189365f4d17d77156b2438d97b1ec555602a11001283f7cc0a298e57f6
|
File details
Details for the file gapless_deribit_clickhouse-2.1.0-py3-none-any.whl.
File metadata
- Download URL: gapless_deribit_clickhouse-2.1.0-py3-none-any.whl
- Upload date:
- Size: 42.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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 |
896f60a3cd09df9fa8802ea6c1fe6eb311b1aa8dd47bcfffb4674a0218e457ee
|
|
| MD5 |
fcceaedf1f866b44de2d1c1ea7250427
|
|
| BLAKE2b-256 |
c6b535bf06b5c12445500cdbadfefec27de6230c9da5551930d8879acc70cc63
|