For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

IB realtimeBar subscription stops during the trading session due to bust events

  • Please see my post in "TWS API Users Group":

    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:

    (bwt this PR also fixes the issue with multiple strategies and data feeds:, although it could be separated into its own PR if at all)


  • @vladisld

    Very well done! May I suggest throttling the requests as well to reduce the number of disconnection/reconnections required?

Log in to reply