Connect and disconnect frequency

Discussion in 'Interactive Brokers' started by purrfessor, Dec 27, 2019.

  1. I’m about to start trading with IB through the python API. It will check on prices every half hour and possibly trade, depending on situations.

    should I open a connection to TWS once and close at end of the day, or should I open and close as needed, likely every 1/2 hour?

    thanks
     
    murray t turtle likes this.
  2. %%
    I like to leave stuff open;
    if it dosent slam jam you up...........................................................................
     
  3. IB API isn't a sensitive little girl. It will be fine if you reconnect once every half hour.
     
    murray t turtle likes this.
  4. Thanks guys. I’ll conclude there’s no hard and fast rule, based on the two responses.
     
    murray t turtle likes this.
  5. Disconnecting, then waiting half an hour, followed by reconnecting is no problem. You can do this, or leave the connection open the entire day (or week).
    However, IB advises against immediately reconnecting after disconnecting (when using the same session id). I have had issues by doing so, after which IB gave me that advice. IB told me that their servers need some time to process the disconnect, cancelling any remaining streaming market data subscriptions and so on. The server may end up in an unclear state if you reconnect while this process is still ongoing.
    If, for some reason, you do want to reconnect immediately after a disconnect it is advisable to use a unique session id, different from the one you've previously used.
     
  6.  
  7. Very helpful. Thanks
     
    Nobert likes this.
  8. You're welcome.
     
    Nobert likes this.