Skip to main content

Python SDK for accessing cryptocurrency high-frequency trading data

Project description

CryptoHFTData Python SDK

PyPI version Python versions License: MIT Documentation Status

A Python SDK for accessing cryptocurrency high-frequency trading data with a simple and intuitive API.

Installation

pip install cryptohftdata

Quick Start

Authenticated downloads require an API key. Either export CRYPTOHFTDATA_API_KEY or configure the default client before calling the convenience helpers.

import cryptohftdata as chd

chd.configure_client(api_key="your-api-key")

# Get kline/OHLCV data
klines = chd.get_klines("BTCUSDT", chd.exchanges.BINANCE_FUTURES, "2025-08-01", "2025-08-02")

# Get trade data
trades = chd.get_trades("BTCUSDT", chd.exchanges.BINANCE_FUTURES, "2025-08-01", "2025-08-02")

# Get orderbook data
orderbook = chd.get_orderbook("ETHUSDT", chd.exchanges.BYBIT_SPOT, "2025-08-01", "2025-08-02")

# Get ticker data
ticker = chd.get_ticker("BTCUSDT", chd.exchanges.BINANCE_SPOT, "2025-08-01", "2025-08-02")

# All methods return pandas DataFrames ready for analysis
print(trades.head())
print(f"Total trades: {len(trades)}")

Discover available symbols

Before requesting market data you can query which symbols are currently downloadable for every exchange without scanning object storage yourself. Use the list_symbols helper, optionally filtering by data type when you only care about trades, orderbooks, klines, etc. Results are served from the API's 24-hour edge cache, so repeated calls stay fast and inexpensive while still picki ng up new listings once per day.

import cryptohftdata as chd

# Fetch every Bybit spot symbol supported by the dataset
symbols = chd.list_symbols("bybit_spot")

# Optionally narrow to a specific data type such as orderbooks
orderbook_symbols = chd.list_symbols("binance_futures", data_type="orderbook")

print(f"Found {len(symbols)} Bybit spot markets")

Features

  • Simple API: Clean and intuitive interface for accessing cryptocurrency market data
  • Direct pandas Integration: All methods return pandas DataFrames ready for analysis
  • Parquet Support: Efficient data transfer using parquet files for large datasets
  • Multiple Exchanges: Support for Binance, Bybit, Kraken, OKX, Bitget, Hyperliquid, Lighter, Aster, and BitMEX
  • Multiple Data Types: Access to klines, orderbook, trades, ticker, mark price, funding rates, open interest, and liquidations data
  • High Performance: Optimized for handling large datasets efficiently with pandas and pyarrow
  • Type Safety: Full type hints for better IDE support and code quality
  • Async Support: Both synchronous and asynchronous APIs available
  • Flexible Date Handling: Support for various date formats and timezones

Supported Exchanges

  • Binance (Spot & Futures)
  • Bybit (Spot & Futures)
  • Kraken (Spot & Derivatives)
  • OKX (Spot & Futures)
  • Bitget (Spot & Futures)
  • Hyperliquid (Spot & Futures)
  • Lighter (Perpetuals)
  • Aster (Futures)
  • BitMEX (Futures)

More exchanges coming soon...

Documentation

Full documentation is available at cryptohftdata.com/docs

Examples

See the examples directory for more detailed usage examples.

Development

Setting up the development environment

git clone https://github.com/cryptohftdata/sdk.git
cd sdk/python
pip install -e ".[dev]"

Running tests

To run the test suite, navigate to the sdk/python directory and use one of the following commands:

Using pytest (recommended):

pytest

This command will automatically use the configurations specified in pyproject.toml, including test paths and coverage options.

If you need to target a specific test file or directory, you can do so, but be mindful of the addopts in pyproject.toml:

pytest tests/test_client.py

Tip: Always install the SDK in editable mode before running tests so the suite exercises your local code: pip install -e ".[dev]". This also ensures the bundled coverage configuration works because pytest-cov is available.

If you don't have pytest or prefer to use the built-in unittest module:

python -m unittest discover tests

Make sure you have an active virtual environment with development dependencies installed. Some tests might require a CRYPTOHFTDATA_API_KEY environment variable to be set for tests that interact with the live API.

Code formatting

black cryptohftdata tests
isort cryptohftdata tests

Type checking

mypy cryptohftdata

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

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

cryptohftdata-0.1.9.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

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

cryptohftdata-0.1.9-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file cryptohftdata-0.1.9.tar.gz.

File metadata

  • Download URL: cryptohftdata-0.1.9.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for cryptohftdata-0.1.9.tar.gz
Algorithm Hash digest
SHA256 aa85c2e7993587ff7bd02db7f7fa4bc17b1c791536806ca34dae6660c75da745
MD5 d27b03dee31387006a3e4272df7a0517
BLAKE2b-256 23aff899487415941a8b343354026f0682f5ad588b1e5576722979532af9aeb9

See more details on using hashes here.

File details

Details for the file cryptohftdata-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: cryptohftdata-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for cryptohftdata-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 dec7488d757c8a9f6890ad436c41a0b3feb9463ae9b59a2085e061c36bdcaf71
MD5 63d0599262cceb166bde3dad459bdd2c
BLAKE2b-256 878ecbd41b68b65efcfee709a3110dd66e7c26a788a3439411f169ed3d24ec7c

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