sf_quant.data.load_crsp_daily#
- sf_quant.data.load_crsp_daily(start: date, end: date, columns: list[str]) DataFrame#
Load a Polars DataFrame of CRSP daily 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 daily 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, 1, 31) >>> columns = ["permno", "date", "ret"] >>> df = sfd.load_crsp_daily( ... start=start, ... end=end, ... columns=columns ... ) >>> df.head() shape: (5, 3) ┌────────────┬────────┬───────┐ │ date ┆ permno ┆ ret │ │ --- ┆ --- ┆ --- │ │ date ┆ i64 ┆ f64 │ ╞════════════╪════════╪═══════╡ │ 2024-01-02 ┆ 10001 ┆ 0.002 │ │ 2024-01-03 ┆ 10001 ┆ -0.001│ │ 2024-01-04 ┆ 10001 ┆ 0.003 │ │ 2024-01-05 ┆ 10001 ┆ 0.000 │ │ 2024-01-08 ┆ 10001 ┆ -0.004│ └────────────┴────────┴───────┘