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

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 (https://groups.io/g/twsapi/topic/6374066#38957), 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)


Log in to reply
 

});