Implementing Delays Without Blocking Strategy Callbacks
Summary
The discussion addresses a developer’s wish to pause for five seconds inside an on-bar callback without delaying other callbacks. A community reply warns that sleeping within a callback blocks the core thread, which can prevent the rest of the strategy from processing events while it waits. The suggested alternative for live trading is to track tick timestamps in the on-tick callback and use them to implement delay logic.
This is a brief implementation pointer rather than a full example: it does not explain how to store timing state, handle missing or irregular ticks, or coordinate delayed actions with other events. The advice specifically mentions live trading and does not compare timer mechanisms or describe behavior in a backtest. Its central lesson is to represent a wait as nonblocking logic driven by event timestamps instead of pausing the callback thread.
Key ideas
- Sleeping inside a strategy callback can block the core thread and delay other callback processing.
- For live trading, tick timestamps can be tracked to implement delay logic.
- The discussion does not provide a complete implementation or cover timer behavior in backtests.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.