Search code examples
python-3.xinteractive-brokers

Error : -1 2108 Market data connection inactive


Every evening I get error 2103 Market data connection is broken

I then receive 2108 market data farm connection is inactive but should be available upon demand.cashfarm

-followed by 2104 Market data connection OK problem is that it hangs my python code and I have to manually restart the program. Is there a way to avoid having to do this every night? This happens regardless of using TWS or IBgateway.

thank you for any help

Update

def error(self, reqId:TickerId, errorCode:int, errorString:str):
    print("Error: ", reqId, "", errorCode, "", errorString)

So something like if statement referencing the errorCode variable to restart the script or sleep for 5 min then restart?


Solution

  • The data connection will be lost at least once per day because of the nightly server reset; unfortunately theres no way this can be avoided. However it should certainly not cause your API program to hang... its best to design the API program to handle the data interruption gracefully by monitoring for the common status codes and acting accordingly.

    API Message Codes