sf_quant.data.load_fama_french#

sf_quant.data.load_fama_french(start: date, end: date) DataFrame#

Load Fama-French 5-factor data between two dates from the database.

This function loads the Fama-French factors (mkt_rf, smb, hml, rmw, cma, rf) from the pre-configured database table.

Parameters#

startdatetime.date

Start date (inclusive) of the data frame.

enddatetime.date

End date (inclusive) of the data frame.

Returns#

polars.DataFrame

A DataFrame containing Fama-French factor data between the specified dates, with columns: date, mkt_rf, smb, hml, rmw, cma, rf.

Examples#

>>> import sf_quant.data as sfd
>>> import datetime as dt
>>> start = dt.date(2024, 1, 1)
>>> end = dt.date(2024, 12, 31)
>>> ff_data = sfd.load_fama_french(start=start, end=end)
>>> ff_data.head()
shape: (5, 7)
┌────────────┬────────┬────────┬────────┬────────┬────────┬────────┐
│ date       ┆ mkt_rf ┆ smb    ┆ hml    ┆ rmw    ┆ cma    ┆ rf     │
│ ---        ┆ ---    ┆ ---    ┆ ---    ┆ ---    ┆ ---    ┆ ---    │
│ date       ┆ f64    ┆ f64    ┆ f64    ┆ f64    ┆ f64    ┆ f64    │
╞════════════╪════════╪════════╪════════╪════════╪════════╪════════╡
│ 2024-01-02 ┆ 0.0123 ┆ 0.0045 ┆ -0.002 ┆ 0.0010 ┆ 0.0008 ┆ 0.0001 │
└────────────┴────────┴────────┴────────┴────────┴────────┴────────┘