sf_quant.data.load_exposures#

sf_quant.data.load_exposures(start: date, end: date, in_universe: bool, columns: list) DataFrame#

Load a Polars DataFrame of factor exposures 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. If False, include all assets.

columnslist of str

List of column names to include in the result.

Returns#

polars.DataFrame

A DataFrame containing factor exposures 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 = [
...     "date",
...     "barrid",
...     "USSLOWL_MOMENTUM",
...     "USSLOWL_VALUE"
... ]
>>> df = sfd.load_exposures(
...     start=start, 
...     end=end, 
...     in_universe=True,
...     columns=columns
... )
>>> df.head()
shape: (5, 4)
┌────────────┬─────────┬──────────────────┬───────────────┐
│ date       ┆ barrid  ┆ USSLOWL_MOMENTUM ┆ USSLOWL_VALUE │
│ ---        ┆ ---     ┆ ---              ┆ ---           │
│ date       ┆ str     ┆ f64              ┆ f64           │
╞════════════╪═════════╪══════════════════╪═══════════════╡
│ 2024-01-02 ┆ USA06Z1 ┆ 1.39             ┆ -0.724        │
│ 2024-01-03 ┆ USA06Z1 ┆ 1.417            ┆ -0.718        │
│ 2024-01-04 ┆ USA06Z1 ┆ 1.308            ┆ -0.709        │
│ 2024-01-05 ┆ USA06Z1 ┆ 1.359            ┆ -0.71         │
│ 2024-01-08 ┆ USA06Z1 ┆ 1.36             ┆ -0.706        │
└────────────┴─────────┴──────────────────┴───────────────┘