sf_quant.data.load_crsp_monthly#
- sf_quant.data.load_crsp_monthly(start: date, end: date, columns: list[str]) DataFrame#
Load a Polars DataFrame of CRSP monthly data between two dates.
Parameters#
- startdatetime.date
Start date (inclusive) of the data frame.
- enddatetime.date
End date (inclusive) of the data frame.
- columnslist of str
List of column names to include in the result.
Returns#
- polars.DataFrame
A DataFrame containing CRSP monthly data between the specified dates, sorted by
permnoanddate, 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 = ["permno", "date", "ret"] >>> df = sfd.load_crsp_monthly( ... start=start, ... end=end, ... columns=columns ... ) >>> df.head() shape: (5, 3) ┌────────────┬────────┬───────┐ │ date ┆ permno ┆ ret │ │ --- ┆ --- ┆ --- │ │ date ┆ i64 ┆ f64 │ ╞════════════╪════════╪═══════╡ │ 2024-01-02 ┆ 10001 ┆ 0.02 │ │ 2024-01-03 ┆ 10001 ┆ -0.01 │ │ 2024-01-04 ┆ 10001 ┆ 0.03 │ │ 2024-01-05 ┆ 10001 ┆ 0.00 │ │ 2024-01-08 ┆ 10001 ┆ -0.02 │ └────────────┴────────┴───────┘