Skip to main content

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 2024
  • ETH-28MAR25-5000-P - ETH put, $5k strike, expires Mar 28 2025

Configuration

Credentials

Set ClickHouse credentials via one of:

  1. Environment variables:

    export CLICKHOUSE_HOST_READONLY=<host>
    export CLICKHOUSE_USER_READONLY=<user>
    export CLICKHOUSE_PASSWORD_READONLY=<password>
    
  2. .env file in project root

  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gapless_deribit_clickhouse-2.2.0.tar.gz (223.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gapless_deribit_clickhouse-2.2.0-py3-none-any.whl (57.8 kB view details)

Uploaded Python 3

File details

Details for the file gapless_deribit_clickhouse-2.2.0.tar.gz.

File metadata

  • Download URL: gapless_deribit_clickhouse-2.2.0.tar.gz
  • Upload date:
  • Size: 223.9 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

Hashes for gapless_deribit_clickhouse-2.2.0.tar.gz
Algorithm Hash digest
SHA256 a30f0b06f6915904d2da1522150113fddbe840a34c38f0ee2d322699eedb3e3d
MD5 069ad8919bc51b49129ed8c42c5d9501
BLAKE2b-256 caf5d6dc1251f038df97dd7da0a6ecbb5d6383223c782ce14ecafe626e2b5377

See more details on using hashes here.

File details

Details for the file gapless_deribit_clickhouse-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: gapless_deribit_clickhouse-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 57.8 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

Hashes for gapless_deribit_clickhouse-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1bf58ed3bab956b4ad39cbaa244bcf35cfe5049896c43d734df2428719ee445d
MD5 0f0191c2e66ecd9d5806a5d70fbdf198
BLAKE2b-256 b789888b8ba931431f043a7aa2ae6289ef9a2ba8e1c8f79354e6d7f214a51592

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page