data

data

Data access: loading/saving local files, downloading from market data sources, and prepackaged sample datasets – everything data-related lives under this subpackage.

import qrt as q

df = q.data.load("ohlc.parquet")
q.data.save(df, "ohlc.parquet")

ohlc = q.data.sources.yfinance.read("AAPL", "2024-01-01", "2025-01-01", "1d")

spy = q.data.datasets.load("spy")  # prepackaged, works offline

Functions

Name Description
load Load a local data file into a DataFrame.
load_ohlc_timeseries_range Load daily trade CSV files and aggregate them into OHLC bars.
save Save a DataFrame to a local file.

load

data.load(path, index=None)

Load a local data file into a DataFrame.

Dispatches on the file suffix: .parquet is read via DuckDB (see :func:~qrt.data.sources._util.cached for why), .csv via pandas.

Parameters

Name Type Description Default
path str | Path File to load. required
index str | None Column to set as the index, if any. None

Returns

Name Type Description
pd.DataFrame The loaded DataFrame.

Raises

Name Type Description
ValueError If the file suffix isn’t .parquet or .csv.

load_ohlc_timeseries_range

data.load_ohlc_timeseries_range(
    sym,
    time_interval,
    start_date,
    end_date,
    data_path='./cache',
)

Load daily trade CSV files and aggregate them into OHLC bars.

Expects daily files named like {sym}-trades-YYYY-MM-DD.csv, e.g. BTCUSDT-trades-2025-09-22.csv, containing at least a datetime and a price column. A qty column, if present, is summed into a volume column.

Parameters

Name Type Description Default
sym str Symbol prefix (e.g. "BTCUSDT"). required
time_interval str Pandas offset alias (e.g. "1h", "5min"). required
start_date datetime Start datetime (inclusive). required
end_date datetime End datetime (inclusive). required
data_path str | Path Directory containing the cached trade CSV files. './cache'

Returns

Name Type Description
pd.DataFrame DataFrame indexed by datetime with columns
pd.DataFrame open, high, low, close (and volume if available).

save

data.save(df, path, index=False)

Save a DataFrame to a local file.

Dispatches on the file suffix: .parquet is written via DuckDB, .csv via pandas.

Parameters

Name Type Description Default
df pd.DataFrame DataFrame to save. required
path str | Path Destination file. Parent directories are created if needed. required
index bool Whether to keep the DataFrame index as a leading column. False

Raises

Name Type Description
ValueError If the file suffix isn’t .parquet or .csv.
Back to top