Gapless Crypto Data
Cryptocurrency OHLCV data collection with gap-free guarantee. Retrieves microstructure-enriched kline data from Binance Public Data Repository with automatic gap detection and filling.
Installation
# UV (recommended)
uv add gapless-crypto-data
# pip
pip install gapless-crypto-data
Quick Start
import gapless_crypto_data as gcd
# Fetch historical data
df = gcd.download("BTCUSDT", timeframe="1h", start="2024-01-01", end="2024-06-30")
# Fetch recent data with limit
df = gcd.fetch_data("ETHUSDT", timeframe="4h", limit=1000)
# Get available symbols and timeframes
symbols = gcd.get_supported_symbols()
timeframes = gcd.get_supported_timeframes()
# Fill gaps in existing data directory
results = gcd.fill_gaps("./data")
Data Format
Returns pandas DataFrames with microstructure columns:
| Column | Type | Description |
|---|---|---|
date |
datetime64 | Period open timestamp |
open, high, low, close |
float64 | OHLC prices |
volume |
float64 | Base asset volume |
close_time |
datetime64 | Period close timestamp |
quote_asset_volume |
float64 | Quote asset volume |
number_of_trades |
int64 | Trade count |
taker_buy_base_asset_volume |
float64 | Taker buy volume (base) |
taker_buy_quote_asset_volume |
float64 | Taker buy volume (quote) |
See Data Format Specification for column semantics and constraints.
Supported Timeframes
All Binance spot kline intervals. Query dynamically:
import gapless_crypto_data as gcd
print(gcd.get_supported_timeframes())
API Reference
Function-based API
import gapless_crypto_data as gcd
# Primary collection function
df = gcd.download(symbol, timeframe, start, end)
df = gcd.fetch_data(symbol, timeframe, limit=None, start=None, end=None)
# Gap filling
results = gcd.fill_gaps(directory, symbols=None)
# Discovery
symbols = gcd.get_supported_symbols()
timeframes = gcd.get_supported_timeframes()
Class-based API
from gapless_crypto_data import BinancePublicDataCollector, UniversalGapFiller
# Data collection with full control
collector = BinancePublicDataCollector(
symbol="BTCUSDT",
start_date="2024-01-01",
end_date="2024-12-31"
)
result = collector.collect_timeframe_data("1h")
df = result["dataframe"]
# Gap detection and filling
gap_filler = UniversalGapFiller()
gaps = gap_filler.detect_all_gaps(csv_file, timeframe)
result = gap_filler.process_file(csv_file, timeframe)
Full API documentation: Python API Reference
Data Sources
| Source | Method | Use Case |
|---|---|---|
| Binance Public Data Repository | Monthly/daily ZIP archives | Historical bulk collection |
| Binance REST API | Per-request klines | Gap filling, recent data |
Collection strategy: Repository archives for bulk historical data, API for gaps and recent periods. See Data Collection Guide.
AI Agent Integration
Programmatic discovery via __probe__ module:
import gapless_crypto_data
probe = gapless_crypto_data.__probe__
# API discovery
probe.discover_api()
probe.get_capabilities()
probe.get_task_graph()
See Probe Usage for AI agent integration patterns.
Development
Setup
git clone https://github.com/terrylica/gapless-crypto-data.git
cd gapless-crypto-data
uv venv && source .venv/bin/activate
uv sync --dev
uv run pre-commit install
Commands
| Task | Command |
|---|---|
| Run tests | uv run pytest |
| Format | uv run ruff format . |
| Lint | uv run ruff check --fix . |
| Type check | uv run mypy src/ |
| Build | uv build |
Project Structure
src/gapless_crypto_data/
├── __init__.py # Package exports
├── api.py # Function-based API
├── __probe__.py # AI agent discovery
├── collectors/ # Data collection
├── gap_filling/ # Gap detection/filling
└── validation/ # Data validation
Full development guide: Development Setup
Architecture
- BinancePublicDataCollector: Bulk data retrieval from public repository
- UniversalGapFiller: Gap detection and API-based filling
- AtomicCSVOperations: Corruption-proof file operations
- ValidationStorage: DuckDB-backed validation persistence
Architecture documentation: Overview
License
MIT License - see LICENSE
Links
Metadata
Release files for gapless-crypto-data 5.0.3
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_crypto_data-5.0.3.tar.gz | 3.4 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gapless_crypto_data-5.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.6 MB
Release files / gapless_crypto_data-5.0.3.tar.gz
| Download URL | gapless_crypto_data-5.0.3.tar.gz |
|---|---|
| Size | 3.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67710c75e71ec7d92b304c376fdea18a26641bc6abba9c078d346072f417d8d1
|
|
BLAKE2b-256 checksum How to use checksums |
0f834672898b5998d5e632bf8f8c02cdc54b971438b4ef418e4041782e2effdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / gapless_crypto_data-5.0.3-py3-none-any.whl
| Download URL | gapless_crypto_data-5.0.3-py3-none-any.whl |
|---|---|
| Size | 159.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
83679cf6ff417a0e947edc1a5efeb070b3f1958af95d08f6e348cec4961e615e
|
|
BLAKE2b-256 checksum How to use checksums |
512e4de2af65cd4da181bd8e7af767a37682ab3ab076829b2cbd1c0d4b24879a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency log