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.2.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.2-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ohlcv_hub-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 16cc8cb8233e5ba8b382fc70d45e576e2a7667e2ae573ad5ff37a39f10d44365
MD5 b50485a23db5b8fc46cb18d5a5867235
BLAKE2b-256 50662b53378dac524097c4e943afc41f1c1e8a36977961be95d2c98548a350c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for ohlcv_hub-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: ohlcv_hub-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bb4227964c951431c477f42e821bd97c7e9dc6775c4c073cb652e69008a935a7
MD5 8e19fdbebeab5dfc649c5caf8e849536
BLAKE2b-256 8b34cbd96d802900cb0467d741ceccb3aca89e33ac079726b4651ce886e14ef0

See more details on using hashes here.

Provenance

The following attestation bundles were made for ohlcv_hub-0.1.2-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