IB realtimeBar subscription stops during the trading session due to bust events
vladisld last edited by
Please see my post in "TWS API Users Group": https://groups.io/g/twsapi/topic/69943076
Up to the TWS API v972, IB realtimeBar subscriptions could stop working during the trading session and no error notification was sent to the application. This happens because of what's called 'busts' events.
Quoting the response in "TWS API Users Group" question:
"The busts occur when the datastream is interrupted or modified in the middle of a bar and the subscription is cancelled by the backend. They should be relatively uncommon but unfortunately no can't be avoided completely"
In TWS API v978,a special error code was added to notify the application about the bust event so that the subscription could be renewed. Below is the example of such error message (from TWS Gateway API logs):
15:24:00:896 -> 4-2-16777221-10225-Bust event occurred, current subscription is deactivated. Please resubscribe real-time bars immediately.-
Currently backtrader doesn't process the bust event error code (10225).
I've submitted PR with a fix: https://github.com/mementum/backtrader/pull/396
(bwt this PR also fixes the issue with multiple strategies and data feeds: https://community.backtrader.com/topic/2122/live-trading-multiple-strategies-each-one-on-a-separate-data-feed, although it could be separated into its own PR if at all)
bigdavediode last edited by
Very well done! May I suggest throttling the requests as well to reduce the number of disconnection/reconnections required?