def tickByTickBidAsk( self, reqId: int, time: int, bidPrice: float, askPrice: float, bidSize: float, askSize: float, tickAttribBidAsk: TickAttribBidAsk): ticker = self.reqId2Ticker.get(reqId) if not ticker: self._logger.error(f'tickByTickBidAsk: Unknown reqId: {reqId}') return if bidPrice != ticker.bid: ticker.prevBid = ticker.bid ticker.bid = bidPrice if bidSize != ticker.bidSize: ticker.prevBidSize = ticker.bidSize ticker.bidSize = bidSize if askPrice != ticker.ask: ticker.prevAsk = ticker.ask ticker.ask = askPrice if askSize != ticker.askSize: ticker.prevAskSize = ticker.askSize ticker.askSize = askSize tick = TickByTickBidAsk( self.lastTime, bidPrice, askPrice, bidSize, askSize, tickAttribBidAsk) ticker.tickByTicks.append(tick) self.pendingTickers.add(ticker)
def tickByTickBidAsk(self, reqId, time, bidPrice, askPrice, bidSize, askSize, attribs): ticker = self.reqId2Ticker.get(reqId) if not ticker: self._logger.error(f'tickByTickBidAsk: Unknown reqId: {reqId}') return attribs = TickAttrib(**attribs.__dict__) tick = TickByTickBidAsk(self.lastTime, bidPrice, askPrice, bidSize, askSize, attribs) ticker.tickByTicks.append(tick) self.pendingTickers.add(ticker)