sf_quant.data.load_assets#
- sf_quant.data.load_assets(start: date, end: date, columns: list[str], in_universe: bool | None = None) DataFrame#
Load a Polars DataFrame of assets data between two dates.
Parameters#
- startdatetime.date
Start date (inclusive) of the data frame.
- enddatetime.date
End date (inclusive) of the data frame.
- in_universebool
If
True, restrict to assets that are in the universe. IfFalse, include all assets.- columnslist of str
List of column names to include in the result.
Returns#
- polars.DataFrame
A DataFrame containing asset data between the specified dates, filtered by universe membership if requested, with only the selected columns.
Examples#
>>> import sf_quant.data as sfd >>> import datetime as dt >>> start = dt.date(2024, 1, 1) >>> end = dt.date(2024, 12, 31) >>> columns = ["barrid", "date", "price"] >>> df = sfd.load_assets( ... start=start, ... end=end, ... in_universe=True, ... columns=columns ... ) >>> df.head() shape: (5, 3) ┌────────────┬─────────┬───────┐ │ date ┆ barrid ┆ price │ │ --- ┆ --- ┆ --- │ │ date ┆ str ┆ f64 │ ╞════════════╪═════════╪═══════╡ │ 2024-01-02 ┆ USA06Z1 ┆ 7.87 │ │ 2024-01-03 ┆ USA06Z1 ┆ 7.775 │ │ 2024-01-04 ┆ USA06Z1 ┆ 7.76 │ │ 2024-01-05 ┆ USA06Z1 ┆ 7.8 │ │ 2024-01-08 ┆ USA06Z1 ┆ 8.22 │ └────────────┴─────────┴───────┘