Data

q.data collects everything data-related under one namespace:

Submodule What it is
q.data.clean canonicalize and validate OHLCV frames, normalize timestamps, resolve duplicates, and detect regular-frequency gaps
q.data.datasets prepackaged sample OHLCV data (AAPL, SPY, BTC-USD), works offline
q.data.local (q.data.load/q.data.save) load/save local parquet or csv files
q.data.sources downloadable market data vendors and generic backends, one submodule each

For time-series OHLCV tables, the pandas index identifies observation rows, normally by datetime. Downstream indicators preserve this index, so columns computed from the same observations align naturally in pandas operations.

Cleaning market data

q.data.clean.canonicalize_ohlcv converts common column names such as Ticker and Date to the canonical symbol and datetime names, coerces OHLCV values to numeric types, normalizes timestamps to UTC, keeps the last duplicate entity/time observation, sorts each entity, and validates OHLCV price and volume invariants.

clean = q.data.clean.canonicalize_ohlcv(raw_prices)
gaps = q.data.clean.detect_gaps(clean, "1D")

The individual normalize_timestamps, deduplicate, detect_gaps, and validate_ohlcv operations are available when a pipeline needs explicit control. Gap detection follows a regular pandas frequency; exchange-session semantics remain the responsibility of q.calendar.

Pages:

  • Sample datasets — the bundled offline OHLCV history and demo strategy trade logs.
  • Data schemas — the canonical OHLCV-bars and trades-format layouts everything else relies on.
  • Local filesq.data.load/q.data.save for parquet/csv.
  • Market data sources — Yahoo Finance, Binance, and DuckDB backends.
Back to top