sf_quant.data.load_factors#
- sf_quant.data.load_factors(start: date, end: date, factors: list[str] | None = None) DataFrame#
Load a Polars DataFrame of factor returns(%) between two dates.
Parameters#
- startdatetime.date
Start date (inclusive) of the data frame.
- enddatetime.date
End date (inclusive) of the data frame.
- factorslist of str, optional
List of factor names to select. - If provided, only the specified factors are included in the output. - If None (default), all available factors are included.
Returns#
- polars.DataFrame
A DataFrame containing factor returns(%) between the specified dates.
Examples#
>>> import sf_quant.data as sfd >>> import datetime as dt >>> start = dt.date(2024, 1, 1) >>> end = dt.date(2024, 12, 31) >>> df = sfd.load_factors( ... start=start, ... end=end ... ) >>> df.head() shape: (5, 78) ┌────────────┬─────────────────┬──────────────────┬──────────────────┬───┐ │ date ┆ USSLOWL_AERODEF ┆ USSLOWL_AIRLINES ┆ USSLOWL_ALUMSTEL ┆ … ┆ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ │ date ┆ f64 ┆ f64 ┆ f64 ┆ ┆ ╞════════════╪═════════════════╪══════════════════╪══════════════════╪═══╡ │ 2024-01-02 ┆ -0.265309 ┆ -0.791378 ┆ 0.156503 ┆ … ┆ │ 2024-01-03 ┆ -0.498421 ┆ -2.233705 ┆ 0.8307382 ┆ … ┆ │ 2024-01-04 ┆ 0.086316 ┆ 2.365157 ┆ -0.328195 ┆ … ┆ │ 2024-01-05 ┆ -0.209432 ┆ 2.549703 ┆ -0.18945 ┆ … ┆ │ 2024-01-08 ┆ -1.414716 ┆ 0.6914087 ┆ -0.973735 ┆ … ┆ └────────────┴─────────────────┴──────────────────┴──────────────────┴───┘