IB API

Discussion in 'Interactive Brokers' started by pam00312, Oct 25, 2021.

  1. pam00312

    pam00312

    Hello,

    I'm a new user of IB API. I'm trying to download price data using python through TWS. The code worked fine for a month. Suddenly it stops working in the middle of today.

    Connections to TWS looks ok, with the following message:

    ERROR -1 2104 Market data farm connection is OK:usfarm.nj
    ERROR -1 2104 Market data farm connection is OK:hfarm
    ERROR -1 2104 Market data farm connection is OK:usfuture
    ERROR -1 2104 Market data farm connection is OK:jfarm
    ERROR -1 2104 Market data farm connection is OK:eufarm
    ERROR -1 2104 Market data farm connection is OK:afarm
    ERROR -1 2104 Market data farm connection is OK:cashfarm
    ERROR -1 2104 Market data farm connection is OK:usfarm
    ERROR -1 2106 HMDS data farm connection is OK:euhmds
    ERROR -1 2106 HMDS data farm connection is OK:hkhmds
    ERROR -1 2106 HMDS data farm connection is OK:fundfarm
    ERROR -1 2106 HMDS data farm connection is OK:ushmds
    ERROR -1 2158 Sec-def data farm connection is OK:secdefil


    But no price data was returned. Data in TWS is still updating as normal.

    Is there a way to see if it's a connection issues / coding issues / server issues?

    Cheers
     
  2. KevinBB

    KevinBB

    What time is the "middle of today"? Both the Gateway and TWS APIs can be very slow during the server update periods.

    The live TWS API is fairly reliable, you just have to wait, but (to me) the demo account is particularly unreliable during the server resets. I ended up having to restart Gateway (logged into the demo account) because of data farm connection problems between about 9am to 12pm US Eastern today. The live TWS API was working with no problems during this time.

    KH
     
    pam00312 likes this.
  3. pam00312

    pam00312

    Thanks, KH.

    I was having problems during the regular trading hours in my market.

    I think the problem comes from my coding. I was waiting the data for a fixed period of time (5 secs), which became insufficient yesterday. If I change the waiting period to 30 secs, it works but becomes laggy.

    A more preferable way would be to wait until the connection is established and the data comes in.

    Do you know any good reference sources for codes?