pqf.utils

Functions

forward_returns(prices, date_column, assets, ...)

Calculate the N period forward log returns as percent change for each requested asset.

pqf.utils.forward_returns(prices: LazyFrame | DataFrame, date_column: str, assets: list[str], periods: list[int], log: bool = True) LazyFrame | DataFrame[source]

Calculate the N period forward log returns as percent change for each requested asset.

Input data is expected to be pricing data.

Parameters:
  • data (pl.LazyFrame) – Underlying data containing (date_column, [ASSETS])

  • date_column (str) – The time column by name

  • factors (list[str]) – A list of factor column names

  • assets (list[str]) – A list of asset names

  • periods (list[int]) – The periods to calculate forward returns for

  • log (bool) – Return log returns instead of simple returns. Default: True

  • prices (LazyFrame | DataFrame)

Returns:

Dataframe containing the log forward returns

Return type:

pl.LazyFrame | pl.DataFrame