示例#1
0
 def historicalTicksBidAsk(self, reqId, ticks, done):
     self._results[reqId] += [
         HistoricalTickBidAsk(
             datetime.datetime.fromtimestamp(t.time, datetime.timezone.utc),
             TickAttribBidAsk(**t.tickAttribBidAsk.__dict__), t.priceBid,
             t.priceAsk, t.sizeBid, t.sizeAsk) for t in ticks
     ]
     if done:
         self._endReq(reqId)
示例#2
0
 def tickByTickBidAsk(self, reqId, time, bidPrice, askPrice, bidSize,
                      askSize, tickAttribBidAsk):
     ticker = self.reqId2Ticker.get(reqId)
     if not ticker:
         self._logger.error(f'tickByTickBidAsk: Unknown reqId: {reqId}')
         return
     attribs = TickAttribBidAsk(**tickAttribBidAsk.__dict__)
     tick = TickByTickBidAsk(self.lastTime, bidPrice, askPrice, bidSize,
                             askSize, attribs)
     ticker.tickByTicks.append(tick)
     self.pendingTickers.add(ticker)
示例#3
0
 def tickByTickBidAsk(self, reqId, time, bidPrice, askPrice, bidSize,
                      askSize, 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
     attribs = TickAttribBidAsk(**tickAttribBidAsk.__dict__)
     tick = TickByTickBidAsk(self.lastTime, bidPrice, askPrice, bidSize,
                             askSize, attribs)
     ticker.tickByTicks.append(tick)
     self.pendingTickers.add(ticker)