IB API (Python) returning -1 for option ask/bid

Discussion in 'Interactive Brokers' started by sacbnc, Dec 29, 2020.

  1. sacbnc

    sacbnc

    So I'm playing around with IBsync to create a spread scanner.

    I'm at the point of retrieving the option chain for a given expiration successfully, where bids and asks are populated for both calls and puts.

    Suddenly however each bid and ask is then returned at "-1" at opposed to the true value. I'd made no substantial changes to the code, and even after reverting to a working version, I'm getting "-1".

    Is this a common problem? Why would this happen?
     
  2. "-1" is usually an indication that there is something wrong. A valid reason for it could be if you ask the price for something for which no price is available. You can easily verify by looking in TWS whether the instrument you are interested in has a bid and/or ask price.
    Other reasons could be that somehow you are sending the price request for the incorrect instrument. You can verify this by submitting a request for instrument details before submitting the price request.
     
  3. sef88

    sef88

    Could be out of market hours
     
  4. sacbnc

    sacbnc

    It is out of market hours, but doesn't explain why they appeared and no longer do. And on TWS the quotes are still displayed
     
  5. In that case I fear that something is going wrong in resolving the contract's code number ("conid" in IB's terminology).
     
  6. sef88

    sef88

    I think that's how it works. You can assume that when -1, it's out of market hours.
     
  7. sacbnc

    sacbnc

    Okay, I guess that the prices it initially pulled were buffered by my TWS instance then