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
Metadata
Release files for gapless-deribit-clickhouse 2.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gapless_deribit_clickhouse-2.2.0.tar.gz | 223.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gapless_deribit_clickhouse-2.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 281.7 kB
Release files / gapless_deribit_clickhouse-2.2.0.tar.gz
| Download URL | gapless_deribit_clickhouse-2.2.0.tar.gz |
|---|---|
| Size | 223.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a30f0b06f6915904d2da1522150113fddbe840a34c38f0ee2d322699eedb3e3d
|
|
BLAKE2b-256 checksum How to use checksums |
caf5d6dc1251f038df97dd7da0a6ecbb5d6383223c782ce14ecafe626e2b5377
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / gapless_deribit_clickhouse-2.2.0-py3-none-any.whl
| Download URL | gapless_deribit_clickhouse-2.2.0-py3-none-any.whl |
|---|---|
| Size | 57.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1bf58ed3bab956b4ad39cbaa244bcf35cfe5049896c43d734df2428719ee445d
|
|
BLAKE2b-256 checksum How to use checksums |
b789888b8ba931431f043a7aa2ae6289ef9a2ba8e1c8f79354e6d7f214a51592
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|