ByPeriod#

class backtest_lib.market.ByPeriod#

Period-axis accessor for a PastView.

Provides indexing by period position and slicing by range. A single period access returns a UniverseMapping, while slicing returns a new PastView.

abstract property plot: ByPeriodPlotAccessor#

Return the plotting accessor for this axis view.

abstractmethod to_dataframe(*, show_securities: bool = False, lazy: Literal[False] = False, backend: Literal['polars']) pl.DataFrame#
abstractmethod to_dataframe(*, show_securities: bool = False, lazy: Literal[False] = False, backend: Literal['pandas']) pd.DataFrame
abstractmethod to_dataframe(*, show_securities: bool = False, lazy: Literal[True], backend: Literal['polars']) pl.LazyFrame
abstractmethod to_dataframe(*, show_securities: bool = False, lazy: bool = False, backend: Literal['pandas']) pd.DataFrame

Convert the view to a DataFrame.

Parameters:
  • show_securities – Whether to include the security labels as a column.

  • lazy – Whether to return a lazy frame for supported backends.

  • backend – Target DataFrame backend.

Returns:

DataFrame containing the per-period values.