TWS API reqMktData doesn't work properly

Discussion in 'Interactive Brokers' started by dakr, Mar 16, 2020.

  1. dakr

    dakr

    Used the API to request streaming last price market data as follows.

    session.eClientSocket.reqMktData(200,contract,'5',false,false,[ ])

    Contract is for currency pair:
    conid 14433401
    symbol AUD
    secType CASH
    strike 0.0
    exchange IDEALPRO

    Got the error that the last price is not a valid tick. See error message below. However I have no problem getting the ask/bid/last price using this function: https://au.mathworks.com/help/trading/ibtws.realtime.html

    Can someone else give this a try? Thanks.

    Error validating request:-'bW' : cause - Incorrect generic tick list of 5. Legal ones for (CASH) are: 100(Option Volume),101(Option Open Interest),105(Average Opt Volume),106(impvolat),107(climpvlt),125(Bond analytic data),165(Misc. Stats),221/220(Creditman Mark Price),225(Auction),232/221(Pl Price),233(RTVolume),236(inventory),258/47(Fundamentals),291(ivclose),292(Wide_news),293(TradeCount),294(TradeRate),295(VolumeRate),318(LastRTHTrade),370(ParticipationMonitor),370(ParticipationMonitor),375(RTTrdVolume),377(CttTickTag),377(CttTickTag),381(IB Rate),384(RfqTickRespTag),384(RfqTickRespTag),387(DMM),388(Issuer Fundamentals),391(IBWarrantImpVolCompeteTick),407(FuturesMargins),411(rthistvol),439(MonitorTickTag),439(MonitorTickTag),459(RTCLOSE),460(Bond Factor Multiplier),499(Fee and Rebate Rate),511(hvolrt10 (per-underlying)),512(hvolrt30 (per-underlying)),513(hvolrt50 (per-underlying)),514(hvolrt75 (per-underlying)),515(hvolrt100 (per-underlying)),516(hvolrt150 (per-underlying)),517(hvolrt200 (per-underlying)),521(fzmidptiv),545(vsiv),576(EtfNavBidAsk(navbidask)),577(EtfNavLast(navlast)),578(EtfNavClose(navclose)),584(Average Opening Vol.),585(Average Closing Vol.),587(Pl Price Delayed),588(Futures Open Interest),608(EMA N),614(EtfNavMisc(hight/low)),619(Creditman Slow Mark Price),623(EtfFrozenNavLast(fznavlast)),645/428(Monetary Close Price),658(avgv1min),661(ivrank),662(ivpercntl),663(ivhilo),664(hvrank),665(hvpercntl),666(hvhilo),669(historical ratios),674(mpmidptiv),680(awvnoib)
     
  2. You seem to be asking data for tick type 5. The error messages states that this tick type is not available. What kind of streaming data are you hoping to receive?
     
  3. dakr

    dakr

  4. In that case you are doing it incorrect. You need to subscribe to the instrument by using:
    Code:
    session.eClientSocket.reqMktData(200,contract,"",false,false,[ ])
    and then filter the data which is being returned in method tickPrice() by overwriting this. For example in Java:
    Code:
      @Override
      public void tickPrice(int tickerID, int field, double price, int canAutoExecute){
      if (field == 4) LatestBid = price; //or whatever you want to do with the received price
      }
    
     
  5. dakr

    dakr

    Thank you, now I understand the doc.
     
  6. You're welcome. Good luck.
     
  7. B.T

    B.T

    Sorry, are you able to help me do this in Python?

    This is my relevant code so far:

    class IBapi(EWrapper, EClient):
    def __init__(self):
    EClient.__init__(self, self)

    def tickPrice(self, reqId, tickType, price, attrib):
    if tickType == 2 and reqId == 1: # I'd like to keep this as it is used to print the price of something else
    print(price)

    app.reqMktData(1, spystock_contract, "", False, False, [])
     
  8. What have you tried? What were the results? And what error messages did you receive?
    Simply dumping a few lines of code here won't get your problem solved.