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

IB Data subscriptions stop working upon 2105/2106 errors during live trading in paper account

  • TWS API defines the following warning message codes that application (Backtrader in this case) may usually safely ignore:

    * 2105	A historical data farm is disconnected.	
    Indicates a connectivity problem to an IB server. Outside of the nightly IB server reset, this typically indicates an underlying ISP connectivity issue.
    * 2106	A historical data farm is connected. 	
    A notification that connection to the market data server is ok. This is a notification and not a true error condition, and is expected on first establishing connection. 

    However in some circumstances the 2105 error may cause all data subscriptions (realtimeBar subscriptions in particular) to stop working. One such scenario is described in the following TWSAPI group post (, and it happens in my case as well.

    Upon running the Backtrader strategy in live mode using IB paper account, the above error notification may be sent by IB in case another connection to the corresponding IB live account is established (probably from another machine or even mobile phone). In this case all the data subscriptions stop working for the paper account session even if the live session was ended. Usually the 2105 error is followed by 2106 error message right away:

    <error id=-1, errorCode=2105, errorMsg=HMDS data farm connection is broken:ushmds>
    <error id=-1, errorCode=2106, errorMsg=HMDS data farm connection is OK:ushmds>
    *** no more data notifications are received from this point on

    Currently IBStore implementation in Backtrader just ignores such error messages. So I wonder whether the above scenario is severe enough to add a support in IBStore/IBData ? (I'll upload the PR if there is a consensus)

  • Hi @vladisld ,

    I am facing the same issue. Is there any fix for this yet?

  • Unfortunately the fix wasn't as trivial - since the error codes 2105/2016 were sent in other scenarios as well - so since nobody was interested I've just abandoned the fix. Currently I'm just making my best to avoid such double connections :-(

Log in to reply