trader.simulation.runner module¶
Bundles the simulator’s collaborators so run_once can trigger it without importing simulation/, persistence/simulation.py, or SimulationSettings directly (issue #33) — the CLI builds one SimulationRunner and passes it in, keeping the pipeline layer’s import surface unchanged for a feature it merely triggers.
- class trader.simulation.runner.SimulationRunner(settings, pipeline_config, discovery_settings, fixed_symbols, bar_repository, decision_repository, simulation_repository)[source]¶
Bases:
objectSteps every configured strategy’s shadow portfolio forward one cycle.
Since issue #42, that is two portfolios per strategy id: the normal one (its own sell decisions honoured) and an Always-be-Buying (AbB) variant that reads the same decisions with sell signals ignored, so only the trailing stop can close a position — isolating whether the sell side is what costs performance, independent of whether the entries are any good.
- Parameters:
settings (SimulationSettings)
pipeline_config (PipelineConfig)
discovery_settings (DiscoverySettings)
fixed_symbols (Collection[str])
bar_repository (BarRepository)
decision_repository (DecisionRepository)
simulation_repository (SimulationRepository)
- settings: SimulationSettings¶
- pipeline_config: PipelineConfig¶
- discovery_settings: DiscoverySettings¶
- fixed_symbols: Collection[str]¶
- bar_repository: BarRepository¶
- decision_repository: DecisionRepository¶
- simulation_repository: SimulationRepository¶
- run(*, strategy_ids, now)[source]¶
Advance both of one strategy’s portfolios per id, all four* failure points isolated from each other.
(*) two per strategy, times as many strategies as strategy_ids holds. One variant of one strategy raising (a malformed inputs_json, a repository error) must not stop its own sibling variant, another strategy’s either variant, or the real cycle this was called from — the same per-unit isolation discipline discover_symbols uses per-theme.
- Parameters:
strategy_ids (Sequence[str])
now (datetime)
- Return type:
None