Portfolio Strategy Restart Can Recompute Targets from Historical Bars
Summary
This community post describes a restart issue in a portfolio strategy. A position and target are saved when the system shuts down, then restored during startup; however, historical bars are replayed through the strategy’s bar handler during initialization. That replay can recalculate position targets without incorporating the still-open position from the previous session. The post reports that the newly calculated target may therefore appear inconsistent with the restored position and existing orders once live bars arrive.
The author traces the sequence by logging values in the bar handler and identifies the ordering of historical-bar replay and state restoration as the suspected cause. It asks how to investigate and resolve the behavior for particular versions of the platform and portfolio strategy package, but offers no confirmed fix or test results. The account is useful as a debugging pattern: inspect initialization callbacks, historical-data replay, persisted state, and the timing of live subscriptions. It is a single reported scenario, so it does not establish that all restarts or strategies behave this way.
Key ideas
- Portfolio strategy state may be persisted at shutdown and restored during startup.
- Historical bars can invoke the strategy’s bar handler before persisted positions and targets are restored.
- Replayed bars may generate targets that do not reflect an existing live position.
- Logging initialization callbacks can help identify when strategy calculations and state restoration occur.
- The post reports a suspected lifecycle issue but does not provide a verified solution.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.