I am requesting BidAsk and Last price data with?reqTickByTickData. In both requests I set ignoreSize = False. In what arrives I only see one entry for last price and everything else is BidAsk data. I think there should more entries with Last price data. I am not sure what it is happening here. I am curious what ignoreSize parameter means. I am guessing it only matters for BidAsk requests where if ignoreSize = True, then only updates in price are returned back.
Here is my code below
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import Contract
from ibapi.ticktype import TickTypeEnum
import time
import datetime
import threading
?
class TestApp(EWrapper, EClient):
? ? def __init__(self):
? ? ? ? EClient.__init__(self, self)
? ? ? ? ? ? ? ?
?
? ? def error(self, reqId, errorCode, errorString):
? ? ? ? print("Error: ", reqId, " ", errorCode, " ", errorString)
?
? ? def tickByTickBidAsk(self, reqId, time, bidPrice, askPrice,
? ? ? ? ?bidSize, askSize, tickAttribBidAsk):
? ? ? ? super().tickByTickBidAsk(reqId, time, bidPrice, askPrice, bidSize,
? ? ? ? ? ? askSize, tickAttribBidAsk)
? ? ? ? print("BidAsk. ReqId:", reqId,
? ? ? ? ? ? "Time:", datetime.datetime.fromtimestamp(time).strftime("%Y%m%d %H:%M:%S"),
? ? ? ? ? ? "BidPrice:", bidPrice, "AskPrice:", askPrice, "BidSize:", bidSize,
? ? ? ? ? ? "AskSize:", askSize, "BidPastLow:", tickAttribBidAsk.bidPastLow,?
? ? ? ? ? ? ? "AskPastHigh:", tickAttribBidAsk.askPastHigh)? ??
? ? ? ? print("_______________________\n")
? ??
? ? def tickByTickAllLast(self, reqId, tickType, time, price, size, tickAtrribLast,
? ? ? ? ? ? ? ? ? ? ? ? ? exchange, specialConditions):
? ? ? ??
? ? ? ? super().tickByTickAllLast(reqId, tickType, time, price, size, tickAtrribLast,
? ? ? ? ? ? ? ? exchange, specialConditions)
? ? ? ??
? ? ? ? print("Tick Price. Ticker Id:", reqId, "tickType:", TickTypeEnum.to_str(tickType),
? ? ? ? ? ? ? "tickTypeNumeric:", tickType,
? ? ? ? ? ? ? "Price:", price,
? ? ? ? ? ? ? "Size:", size,
? ? ? ? ? ? ? "Exchange", exchange,
? ? ? ? ? ? ? "market_time_unix:", time,?
? ? ? ? ? ? ? "Time:", datetime.datetime.fromtimestamp(time).strftime("%Y%m%d %H:%M:%S.%f'"),
? ? ? ? ? ? ? "market_time:", datetime.datetime.fromtimestamp(time) ,? "server time :", datetime.datetime.now(),
? ? ? ? ? ? ? ? "tickAtrribLast:", tickAtrribLast, "specialConditions:", specialConditions,? end=' ')
? ? ? ? print("_______________________\n")
? ? ? ??
? ??
contract2 = Contract()
contract2.symbol = "JETS"
contract2.secType = "STK"
contract2.exchange = "SMART"
contract2.currency = "USD"
contract2.primaryExchange = "ARCA"
app = TestApp()
app.connect("127.0.0.1", 4002, 0)
time.sleep(1)
app.reqTickByTickData(1 ,contract2, "Last", 0, False)
app.reqTickByTickData(2 ,contract2, "BidAsk", 0, False)
api_thread = threading.Thread(target=app.run)
api_thread.start()
time.sleep(35)
app.cancelTickByTickData(1)
app.cancelTickByTickData(2)
?
app.disconnect()
? ??