backtest_lib.backtest.schedule.decision_schedule_factory#

backtest_lib.backtest.schedule.decision_schedule_factory(factory: Callable[[], Iterator], start: I | None = None, end: I | None = None, *, inclusive_end: bool = True) DecisionSchedule#

Create a decision schedule from a factory of iterators.

Example

>>> import datetime as dt
>>> from backtest_lib.backtest.schedule import decision_schedule_factory
>>> def factory():
...     yield from [
...         dt.datetime(2025, 1, 1),
...         dt.datetime(2025, 1, 2),
...     ]
>>> schedule = decision_schedule_factory(factory)
>>> list(schedule)
[datetime.datetime(2025, 1, 1, 0, 0), datetime.datetime(2025, 1, 2, 0, 0)]
Parameters:
  • factory – Callable that returns a fresh iterator of schedule values.

  • start – Optional start value for bounds checking.

  • end – Optional end value used to truncate the schedule.

  • inclusive_end – Whether the end bound is inclusive.

Returns:

DecisionSchedule built from the factory.