create_rolling_chart_using_benchmark

qf_lib.plotting.helpers.create_rolling_chart_using_benchmark.create_rolling_chart_using_benchmark(series: Union[QFSeries, List[QFSeries]], benchmark_series: QFSeries, func: Callable[[Union[QFSeries, ndarray], Union[QFSeries, ndarray]], float], func_name: str, window_size: int = 126, step: int = 20, oos_date: Optional[str] = None) LineChart[source]

Creates a new line chart and adds the rolling window for each of the specified series to it. The func function is fed data for each window and whatever it returns is added to the resulting rolled series.

For example:

The example above will return beta of every rolling window

Parameters:
  • series (QFSeries, List[QFSeries]) – One or more series to apply the rolling window transformation on add to the resulting chart.

  • benchmark_series (QFSeries) – benchmark for every series passed as a first argument

  • func (RollingWindowFunction) – Called for each window. Takes two arguments (series_window, benchmark_window). Returns a float.

  • func_name (str) – Used in the title to specify the function that was called.

  • window_size (int) –

  • step (int) – determines by how many steps we shift the rolling window

  • oos_date (str) – only the OOS date of the first series in the list will be taken into account

Return type:

LineChart