data.datasets
data.datasets
Prepackaged sample datasets shipped with qrt for offline use – handy for tests, demos, and tutorials without hitting yfinance every time you just need some SPY or AAPL data on hand.
Two kinds of datasets are bundled:
Daily OHLCV price history (
"aapl","spy","btcusd"), indexed bydatetime.Demo strategy trade logs in qrt’s canonical trades format (
"spy_ema_cross","spy_rsi2","spy_random","spy_breakout") – one row per round-trip trade with entry/exit time, price and reason, direction (1= long,-1= short), direction-adjusted decimalreturn, MAE/MFE, and per-strategy entry-time feature snapshots. Generated deterministically from the bundled SPY data bytools/gen_demo_strategies.py.import qrt as q
spy = q.data.datasets.load(“spy”) trades = q.data.datasets.load(“spy_rsi2”)
The bundled parquet files are refreshed via :func:refresh (see tools/update_datasets.py, wired into make datasets / make publish) so released versions of qrt always ship reasonably current data – but they are not guaranteed to be fully up to date for a given install. Fetch live data via :mod:qrt.data.sources if you need the latest bar.
Functions
| Name | Description |
|---|---|
| load | Load a bundled sample dataset (offline, no network required). |
| refresh | Re-download bundled OHLCV datasets from Yahoo Finance and overwrite their parquet files. |
load
data.datasets.load(name)Load a bundled sample dataset (offline, no network required).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| name | str | One of :data:AVAILABLE – a daily OHLCV dataset ("aapl", "btcusd", "spy") or a demo strategy trade log (see :data:TRADE_LOGS). |
required |
Returns
| Name | Type | Description |
|---|---|---|
| pd.DataFrame | For OHLCV datasets, a daily OHLCV DataFrame indexed by | |
| pd.DataFrame | datetime. For trade logs, a trades-format DataFrame (one row |
|
| pd.DataFrame | per trade, plain integer index). |
Raises
| Name | Type | Description |
|---|---|---|
| KeyError | If name isn’t a bundled dataset. |
refresh
data.datasets.refresh(names=None, end_date=None)Re-download bundled OHLCV datasets from Yahoo Finance and overwrite their parquet files.
Trade-log datasets (:data:TRADE_LOGS) are not refreshed here – they are regenerated from the bundled SPY data by tools/gen_demo_strategies.py (run it after refreshing).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| names | list[str] | None | OHLCV dataset names to refresh (default: all of them). | None |
| end_date | str | date | None | Last date to fetch, YYYY-MM-DD (default: today). |
None |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If names contains a non-OHLCV dataset name. |