Market data sources

Each vendor/backend is its own submodule under q.data.sources, all returning the same lowercase-column OHLCV DataFrame layout consumed by q.feature and q.stats. These examples hit the network, so they’re shown but not executed here:

# Yahoo Finance — cached locally as parquet after the first call
ohlc = q.data.sources.yfinance.read("AAPL", "2024-01-01", "2025-01-01", "1d")

# Binance futures — daily trade dumps aggregated into OHLC bars, also cached
ohlc = q.data.sources.binance.read("BTCUSDT", "2025-01-01", "2025-01-07", "1h")

q.data.sources.duckdb is different: rather than a fixed schema/vendor, it reads and writes arbitrary tables in a DuckDB database, keyed by symbol and datetime. It works offline (:memory: by default), so we can run it live:

import qrt as q

aapl = q.data.datasets.load("aapl")
table = aapl.tail(30).reset_index()
table.insert(1, "symbol", "AAPL")

db = q.data.sources.duckdb.connect()  # in-memory
db.write(table)
db.read("AAPL", table["datetime"].min(), table["datetime"].max()).tail()
datetime symbol open high low close volume
25 2026-07-13 AAPL 317.019989 323.450012 315.779999 317.309998 43257800
26 2026-07-14 AAPL 313.760010 316.190002 311.910004 314.859985 36336800
27 2026-07-15 AAPL 317.619995 328.730011 317.320007 327.500000 60957600
28 2026-07-16 AAPL 328.010010 334.679993 326.790009 333.260010 62970600
29 2026-07-17 AAPL 331.980011 334.989990 329.000000 333.739990 63365300
Back to top