Skip to main content

groai-fi-datastore-shared

PyPI version Python 3.9+ License: Apache 2.0 CI

Shared datastore utilities for GroAI.fi — Binance market data downloading, partitioned Parquet storage, order execution, and backtesting infrastructure.


Features

  • Market Data Downloading — Incremental Binance Spot OHLCV, USD-M Futures extended klines, and funding rate history with automatic catch-up from where you left off
  • Parquet Storage — Hive-partitioned Parquet files (exchange=X/symbol=Y/part.N.parquet) powered by Dask / PyArrow (local) and PyArrow / DuckDB HTTPFS (S3)
  • File Locking — Safe concurrent writes via .write.lock file with stale-lock detection (Local filesystem only)
  • Order Execution — BinanceOrder, BinanceClient with spot and margin support
  • Backtesting — BacktestOrder, BacktestOrderData for strategy simulation
  • CLI Suite — 17 distinct CLI commands enabling both isolated local-filesystem and cloud-native S3 workflows

Installation

# Using pip
pip install groai-fi-datastore-shared

# Using uv (recommended)
uv add groai-fi-datastore-shared

Environment Variables

The following environment variables are used across modules:

Variable Required Description
BINANCE_API_KEY Yes (trading/download) Your Binance API key
BINANCE_API_SECRET Yes (trading/download) Your Binance API secret
S3_ENDPOINT_URL Yes (if S3) Your object storage endpoint (e.g. https://t3.storageapi.dev)
S3_BUCKET_NAME Yes (if S3) The target bucket name
S3_ACCESS_KEY_ID Yes (if S3) S3 access key ID
S3_SECRET_ACCESS_KEY Yes (if S3) S3 standard secret access key
BINANCE_API_KEY_TEST No Testnet API key
BINANCE_API_SECRET_TEST No Testnet API secret
SEND_MAIL_RECEIVER No Email address for trade alerts

Create a .env file in your project root and load it with python-dotenv or export variables in your shell.


CLI Usage

The package exposes identical pipelines for Local Filesystems and S3 Storage.

Local Storage Commands

Run data engineering workflows directly onto a mounted drive via Dask and PyArrow files:

# 1. Download
binance-download-price --symbol BTCUSDT --tframe 1m --path /path/to/prices_v3.parquet --start_date 2024/01/01
# 2. Merge shards (Spot-only — DO NOT run on usdm_perp_1m_v3.parquet or usdm_perp_funding_v3.parquet)
binance-merge-parquet --exchange Binance --symbol BTCUSDT --path /path/to/prices_v3.parquet --interval_base 1m
# 3. Auto-catchup all tracked symbols (Spot-only — prices_v3.parquet / exchange=Binance)
# Skips delisted/inactive symbols via Binance exchangeInfo (use --skip-symbols or --include-inactive to override)
binance-auto-update --exchange Binance --path /path/to/prices_v3.parquet --tframe 1m
# 4. View tracked symbols
binance-list-symbols --path /path/to/prices_v3.parquet
# 5. Clean / remove
binance-remove-symbol --symbol BTCUSDT --path /path/to/prices_v3.parquet --yes
# 6. Download USD-M Perpetual extended 1m klines (Parquet v3, 1m-only, exchange=BinanceUSDM)
binance-download-usdm-perp-1m --symbol BTCUSDT --path /path/to/usdm_perp_1m_v3.parquet --start-date 2020/01/01 --pause 0.15 --chunk-rows 100000
# 7. Download USD-M Perpetual funding rates (Parquet v3, exchange=BinanceUSDM)
binance-download-usdm-perp-funding --symbol BTCUSDT --path /path/to/usdm_perp_funding_v3.parquet --start-date 2019/09/01 --pause 0.1 --chunk-rows 100000
# 8. Resample USD-M Perpetual 1m klines + summed funding into 15m/1h/4h/1d bars (local or S3 via --bucket)
binance-resample-usdm --symbol BTCUSDT --timeframe 1h --start-utc 2025-01-01T00:00:00Z --end-utc 2026-11-28T00:00:00Z --kline-root /path/to/usdm_perp_1m_v3.parquet --funding-root /path/to/usdm_perp_funding_v3.parquet --output-csv candles_1h_BTC.csv

S3 Storage Commands (Native)

Run structurally identical commands operating directly on object storage leveraging DuckDB HTTPFS. Local storage volumes are not required.

# S3 1. Download
binance-download-price-s3 --symbol BTCUSDT --tframe 1m --bucket my-bucket
# S3 2. Merge shards (Stages to .staging.part.<ts_ms>.parquet + validates COUNT & MIN/MAX before promoting to part.00000.parquet)
binance-merge-parquet-s3 --exchange Binance --symbol BTCUSDT --bucket my-bucket
# e.g. compact USD-M perp 1m klines or funding rates:
# binance-merge-parquet-s3 --price-root usdm_perp_1m_v3.parquet --exchange BinanceUSDM --symbol BTCUSDT --bucket my-bucket
# binance-merge-parquet-s3 --price-root usdm_perp_funding_v3.parquet --exchange BinanceUSDM --symbol BTCUSDT --bucket my-bucket
# S3 3. Auto-catchup all tracking (Spot-only — DO NOT run on usdm_perp_1m_v3.parquet or usdm_perp_funding_v3.parquet)
# Skips delisted/inactive symbols via Binance exchangeInfo (use --skip-symbols or --include-inactive to override)
binance-auto-update-s3 --exchange Binance --bucket my-bucket --tframe 1m
# S3 4. View S3 inventory
binance-list-symbols-s3 --bucket my-bucket
# S3 5. Clean / remove (whole symbol or validated UTC date range; supports --dry-run)
binance-remove-symbol-s3 --symbol BTCUSDT --bucket my-bucket --yes
# e.g. preview / delete a UTC date range without wiping the whole symbol:
# binance-remove-symbol-s3 --symbol BTCUSDT --bucket my-bucket --start-date 2026/01/01 --end-date 2026/01/02 --dry-run
# S3 6. Download USD-M Perpetual extended 1m klines (1m-only; supports --end-date, --pause, --chunk-rows)
binance-download-usdm-perp-1m-s3 --symbol BTCUSDT --bucket my-bucket --price-root usdm_perp_1m_v3.parquet --start-date 2020/01/01 --exchange BinanceUSDM
# S3 7. Download USD-M Perpetual funding rates (supports --end-date, --pause, --chunk-rows)
binance-download-usdm-perp-funding-s3 --symbol BTCUSDT --bucket my-bucket --funding-root usdm_perp_funding_v3.parquet --start-date 2019/09/01 --exchange BinanceUSDM
# S3 8. Auto-catchup all tracked USD-M Perpetual symbols (1m klines + funding rates, skips delisted contracts)
binance-auto-update-usdm-s3 --bucket my-bucket --dataset all
# S3 9. One-shot Spot backfill schema fixer (Spot-only; snapshots old parts & promotes validated staging to part.00000.parquet)
binance-backfill-fix-s3 --bucket my-bucket --dry-run

USD-M Perpetual & Funding Rate Defaults

CLI Command Default Root / Path Default --exchange Parquet v3 File Columns (date is UTC index)
binance-download-usdm-perp-1m / binance-download-usdm-perp-1m-s3 usdm_perp_1m_v3.parquet (S3, 1m-only) BinanceUSDM yymm, open, high, low, close, volume, quote_asset_volume, number_of_trades, taker_buy_base_asset_volume, taker_buy_quote_asset_volume
binance-download-usdm-perp-funding / binance-download-usdm-perp-funding-s3 usdm_perp_funding_v3.parquet (S3) BinanceUSDM yymm, funding_rate, mark_price

Python API

# Market data downloading
from groai_fi_datastore_shared.Binance import BinanceMarketDataDownloader
from datetime import datetime

logger = ...  # your logger

BinanceMarketDataDownloader.catchup_price_binance(
    symbol="BTCUSDT",
    kline_tframe="1m",
    default_download_start_date=datetime(2024, 1, 1),
    price_root_dir="/data/prices_v3.parquet",
    logger=logger,
)

# Reading config from environment
from groai_fi_datastore_shared.Binance.config import BinanceConfig
config = BinanceConfig.from_env()

# Trading client
from groai_fi_datastore_shared.Binance import BinanceClient
client = BinanceClient(config.api_key, config.api_secret)

Development

# Clone
git clone https://github.com/groai-fi/datastore.shared.git
cd datastore.shared

# Install with dev extras
make install-dev

# Run tests
make test

# Lint
make lint

Publishing

# Build wheel + sdist
make build

# Publish to PyPI (requires UV_PUBLISH_TOKEN in env)
make publish

# Publish to TestPyPI first
make publish-test

To release a new version:

  1. Bump version in pyproject.toml and __version__ in src/groai_fi_datastore_shared/__init__.py
  2. Update CHANGELOG.md (and PRICE_PARQUET_V3_SPEC.md if schemas or CLI contracts changed)
  3. Run make lint && make test
  4. Commit and push
  5. Tag: git tag v0.3.2 && git push origin v0.3.2
  6. GitHub Actions will automatically build and publish to PyPI

License

Apache License 2.0

Metadata

Release files for groai-fi-datastore-shared 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for groai-fi-datastore-shared 0.3.2
File Size Uploaded Provenance Actions
groai_fi_datastore_shared-0.3.2.tar.gz 120.4 kB Without provenance Details for groai_fi_datastore_shared-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for groai-fi-datastore-shared 0.3.2
File Interpreter ABI Platform Actions
groai_fi_datastore_shared-0.3.2-py3-none-any.whl Python 3 none any Details for groai_fi_datastore_shared-0.3.2-py3-none-any.whl

Total release size: 267.6 kB

Release files / groai_fi_datastore_shared-0.3.2.tar.gz

Download URL groai_fi_datastore_shared-0.3.2.tar.gz
Size 120.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d601cb4077c32acdd4405844e6fa0c9c04a7edb2f498b84b474c625d46997d01
BLAKE2b-256 checksum
How to use checksums
4a728503cfb5c3d35c9f3e672d4e248a87582c6062adb68bb9e72807acfd56ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / groai_fi_datastore_shared-0.3.2-py3-none-any.whl

Download URL groai_fi_datastore_shared-0.3.2-py3-none-any.whl
Size 147.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7e9cbd54459a31fde27f1a37c39716fe067e13545863c0f446d87eb34faab99
BLAKE2b-256 checksum
How to use checksums
315f0eccae890f2e3643ffdfabe076a3dad8f3bc650ba268bf43b2b8b4ec3e1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for groai-fi-datastore-shared 0.3.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page