Skip to main content

OHLCV data fetching and processing tool

Project description

ohlcv-hub

A small dataset builder for US stocks and ETFs: fetch daily OHLCV bars from Alpaca, optionally resample to weekly, validate, and export to Parquet or CSV with a validation report (missing days, duplicates, OHLC sanity).

Features

  • Daily bars (1d): Fetch historical daily bars from Alpaca Market Data API; normalize, validate, and export.
  • Weekly bars (1w): Resample daily bars to weekly (Monday 00:00 UTC); same validation and export.
  • Validation: Duplicate detection, monotonic timestamps, OHLC sanity, volume checks; missing trading days (NYSE calendar).
  • Output: Parquet (default) or CSV; optional validation_report.json.
  • Rate limiting: Proactive throttling and 429 retry with backoff; optional --verbose debug logging.

Quickstart

Install

From PyPI (once published):

pip install ohlcv-hub

For local development:

pip install -e ".[dev]"

Environment

Set your Alpaca credentials:

  • ALPACA_API_KEY — required
  • ALPACA_API_SECRET — required
  • ALPACA_DATA_BASE_URL — optional (default: https://data.alpaca.markets)

Example commands

# Check configuration
ohlcv-hub doctor

# Fetch daily bars (default feed: iex)
ohlcv-hub fetch --symbols SPY,QQQ --start 2024-01-01 --end 2024-02-01 --tf 1d --out ./data

# Fetch weekly bars (resampled from daily)
ohlcv-hub fetch --symbols SPY --start 2024-01-01 --end 2024-02-01 --tf 1w --out ./data

# Use a different feed: --feed iex | sip | boats | otc
ohlcv-hub fetch --symbols SPY --start 2024-01-01 --end 2024-01-10 --tf 1d --out ./data --feed sip

Output

  • Daily: <out>/ohlcv_1d_<YYYYMMDD>_<YYYYMMDD>.parquet (or .csv)
  • Weekly: <out>/ohlcv_1w_<YYYYMMDD>_<YYYYMMDD>.parquet (or .csv)
  • Report (if --report): <out>/validation_report.json (missing days, issues summary)

Schema

Column Description
symbol Ticker (e.g. SPY)
timeframe 1d or 1w
ts Bar timestamp (UTC)
open, high, low, close OHLC
volume Volume
source Data source
currency Currency (e.g. USD)
adjustment Adjustment (e.g. raw)

Notes / Limitations (MVP)

  • No intraday: Daily and weekly bars only; no minute or realtime data.
  • No strategies: Fetch, validate, and export only; no backtesting or signals.
  • Alpaca: Requires an Alpaca account and data subscription. Free tier often includes IEX; SIP may require a paid plan. Use --feed iex (default) or --feed sip as appropriate.

Development

pip install -e ".[dev]"
pytest -q
bandit -r ohlcv_hub -x tests -q

For dependency auditing (Python 3.10+): pip install -e ".[audit]" then pip-audit.

Internal release and security notes live under docs/internal/.

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

ohlcv_hub-0.1.0.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

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

ohlcv_hub-0.1.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file ohlcv_hub-0.1.0.tar.gz.

File metadata

  • Download URL: ohlcv_hub-0.1.0.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ohlcv_hub-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fcce361375d144c6fa37d8bd4b7b1da9dfe8632dfe6119a05b0c1b590937800f
MD5 f9f7ac6424fb25a4cdfcaccd883de996
BLAKE2b-256 75727ca82bb674f129a27e1c3a0eb41f8b7601e10a0ff1359d6a76b9eddb4b13

See more details on using hashes here.

Provenance

The following attestation bundles were made for ohlcv_hub-0.1.0.tar.gz:

Publisher: publish.yml on Vallehtelia/ohlcv-hub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ohlcv_hub-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ohlcv_hub-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ohlcv_hub-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7aea83d96f7ce24414bea03d61dea305ce5ad0b70a408745ea7bb01dfaa85a75
MD5 731006ebefa6f2ec371d97695068050c
BLAKE2b-256 190eaa2e0e0f76d837b177479f9365e405d840288bb5cfdcb6e51202f5be7fd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ohlcv_hub-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Vallehtelia/ohlcv-hub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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