Engine#
- class backtest_lib.engine.Engine(planner: PlanGenerator[TPlanOp], executor: PlanExecutor[TPlanOp], universe: Iterable[str])#
Coordinate plan generation and execution for a universe.
The engine wires a
PlanGeneratorand aPlanExecutorto execute strategy decisions against a consistent security universe.- execute_strategy(strategy: Strategy, portfolio: Portfolio, market: MarketView, ctx: StrategyContext, prices: UniverseMapping) ExecutionResult#
Run a strategy once and execute its resulting plan.
- Parameters:
strategy –
Strategycallable producing a decision.portfolio –
Portfolioto update.market –
MarketViewproviding historical context.ctx –
StrategyContextpassed to the strategy.prices –
UniverseMappingof current prices used for planning.
- Returns:
ExecutionResultafter applying the plan.
|
Create an engine from a planner and an executor. |