def updateMktDepthL2(self, id, position, marketMaker, operation, side, price, size): """ TickerId id, int position, IBString marketMaker, int operation, int side, double price, int size """ logger.debug("updateMktDepthL2, id=%s position=%s marketMaker=%s operation=%s side=%s price=%s size=%s", id, position, marketMaker, operation, side, price, size)
def tickOptionComputation(self, tickerId, tickType, impliedVol, delta, optPrice, gamma, vega, theta, undPrice): """ TickerId tickerId, TickType tickType, double impliedVol, double delta, double optPrice, double pvDividend, double gamma, double vega, double theta, double undPrice """ logger.debug( "tickOptionComputation, tickerId=%s tickType=%s simpliedVol=%s delta=%s optPrice=%s, gamma=%s, vega=%s, theta=%s, undPrice=%s", tickerId, tickType, impliedVol, delta, optPrice, gamma, vega, theta, undPrice)
def scannerData(self, reqId, rank, contractDetails, distance, benchmark, projection, legsStr): """ int reqId, int rank, ContractDetails contractDetails, IBString const & distance, IBString const & benchmark, IBString const & projection, IBString const & legsStr """ logger.debug( "scannerData, reqId=%s, rank=%s, contractDetails=%s, distance=%s, benchmark=%s, projection=%s, legsStr=%s", reqId, rank, contractDetails, distance, benchmark, projection, legsStr)
def realtimeBar(self, reqId, time, open, high, low, close, volume, wap, count): """ TickerId reqId, long time, double open, double high, double low, double close, long volume, double wap, int count """ logger.debug("realtimeBar, reqId=%s time=%s open=%s high=%s low=%s close=%s volume=%s wap=%s count=%s", reqId, time, open, high, low, close, volume, wap, count)
def updatePortfolio(self, contract, position, marketPrice, marketValue, averageCost, unrealizedPNL, realizedPNL, accountName): """ Contract contract, int position, double marketPrice, double marketValue, double averageCost, double unrealizedPNL, double realizedPNL, IBString const & accountName """ logger.debug( "updatePortfolio, contract=%s position=%s marketPrice=%s marketValue=%s averageCost=%s, unrealizedPNL=%s, realizedPNL=%s, accountName=%s", contract, position, marketPrice, marketValue, averageCost, unrealizedPNL, realizedPNL, accountName)
def orderStatus(self, id, status, filled, remaining, avgFillPrice, permId, parentId, lastFilledPrice, clientId, whyHeld): """ OrderId orderId, IBString const & status, int filled, int remaining, double avgFillPrice, int permId, int parentId, double lastFillPrice, int clientId, IBString const & whyHeld """ logger.debug( "orderStatus, id=%s, status=%s, filled=%s, remaining=%s, avgFillPrice=%s, permId=%s, parentId=%s, lastFilledPrice=%s, clientId=%s, whyHeld=%s", id, status, filled, remaining, avgFillPrice, permId, parentId, lastFilledPrice, clientId, whyHeld)
def tickEFP(self, tickerId, tickType, basisPoints, formattedBasisPoints, totalDividends, holdDays, futureExpiry, dividendImpact, dividendsToExpiry): """ EWrapper self, TickerId tickerId, TickType tickType, double basisPoints, IBString const & formattedBasisPoints, double totalDividends, int holdDays, IBString const & futureExpiry, double dividendImpact, double dividendsToExpiry """ logger.debug( "tickEFP, tickerId=%s tickType=%s basisPoints=%s formattedBasisPoints=%s totalDividends=%s, holdDays=%s, futureExpiry=%s, dividendImpact=%s, dividendsToExpiry=%s", tickerId, tickType, basisPoints, formattedBasisPoints, totalDividends, holdDays, futureExpiry, dividendImpact, dividendsToExpiry)
def on_trade(self, trade): logger.debug("[%s] %s" % (self.__class__.__name__, trade)) self.__trade_dict[trade.inst_id] = trade self.get_series(get_series_id(trade)).add(timestamp=trade.timestamp, data={ "price": trade.price, "size": trade.size }) if self._is_realtime_persist(): self.store.save_trade(trade)
def on_new_ord_req(self, new_ord_req): logger.debug("[%s] %s" % (self.__class__.__name__, new_ord_req)) self.clordid_ordid_map self.__add_order(new_ord_req) self.__send_exec_report(new_ord_req, 0, 0, Submitted) fill_info = self.fill_strategy.process_new_order(new_ord_req) executed = self.execute(new_ord_req, fill_info) if executed: self.__remove_order(new_ord_req) logger.debug("[%s] %s" % (self.__class__.__name__, new_ord_req))
def historicalData(self, reqId, date, open, high, low, close, volume, barCount, WAP, hasGaps): """ TickerId reqId, IBString const & date, double open, double high, double low, double close, int volume, int barCount, double WAP, int hasGaps) """ logger.debug( "historicalData, reqId=%s date=%s open=%s high=%s low=%s close=%s volume=%s barCount=%s WAP=%s hasGaps=%s", reqId, date, open, high, low, close, volume, barCount, WAP, hasGaps)
def on_bar(self, bar): logger.debug("[%s] %s" % (self.__class__.__name__, bar)) self.__bar_dict[bar.inst_id] = bar self.get_series(get_series_id(bar)).add(timestamp=bar.timestamp, data={ "open": bar.open, "high": bar.high, "low": bar.low, "close": bar.close, "vol": bar.vol }) if self._is_realtime_persist(): self.store.save_bar(bar)
def on_quote(self, quote): logger.debug("[%s] %s" % (self.__class__.__name__, quote)) self.__quote_dict[quote.inst_id] = quote self.get_series(get_series_id(quote)).add(timestamp=quote.timestamp, data={ "bid": quote.bid, "ask": quote.ask, "bid_size": quote.bid_size, "ask_size": quote.ask_size }) if self._is_realtime_persist(): self.store.save_quote(quote)
def tickString(self, tickerId, tickType, value): """ TickerId tickerId, TickType tickType, IBString const & value """ logger.debug("tickString, tickerId=%s tickType=%s value=%s", tickerId, tickType, value)
def on_market_depth(self, market_depth: MarketDepth) -> None: logger.debug("[%s] %s" % (self.__class__.__name__, market_depth))
def updateAccountValue(self, key, val, currency, accountName): """ IBString const & key, IBString const & val, IBString const & currency, IBString const & accountName """ logger.debug("updateAccountValue, key=%s val=%s currency=%s accountName=%s", key, val, currency, accountName)
def on_quote(self, quote: Quote) -> None: logger.debug("[%s] %s" % (self.__class__.__name__, quote))
def on_trade(self, trade: Trade) -> None: logger.debug("[%s] %s" % (self.__class__.__name__, trade))
def on_new_ord_req(self, new_ord_req: NewOrderRequest) -> None: logger.debug("[%s] %s" % (self.__class__.__name__, new_ord_req)) self.send_order(new_ord_req)
def on_bar(self, bar: Bar) -> None: logger.debug("[%s] %s" % (self.__class__.__name__, bar))
def on_portf_upd(self, portf_upd: PortfolioUpdate) -> None: logger.debug("[%s] %s" % (self.__class__.__name__, portf_upd))
def on_error(self, err): logger.debug("[%s] Error: %s" % (self.__class__.__name__, err))
def on_exec_report(self, exec_report: ExecutionReport) -> None: logger.debug("[%s] %s" % (self.__class__.__name__, exec_report))
def on_acc_upd(self, acc_upd: AccountUpdate) -> None: logger.debug("[%s] %s" % (self.__class__.__name__, acc_upd))
def on_ord_upd(self, ord_upd: OrderStatusUpdate) -> None: logger.debug("[%s] %s" % (self.__class__.__name__, ord_upd))
def nextValidId(self, orderId): """ OrderId orderId """ logger.debug("nextValidId, orderId=%s", orderId)
def on_ord_replace_req(self, ord_replace_req: OrderReplaceRequest) -> None: logger.debug("[%s] %s" % (self.__class__.__name__, ord_replace_req)) self.replace_order(ord_replace_req)
def tickGeneric(self, tickerId, tickType, value): """ TickerId tickerId, TickType tickType, double value """ logger.debug("tickGeneric, tickerId=%s tickType=%s value=%s", tickerId, tickType, value)
def on_completed(self): logger.debug("[%s] Completed" % self.__class__.__name__)
def on_ord_cancel_req(self, ord_cancel_req: OrderCancelRequest) -> None: logger.debug("[%s] %s" % (self.__class__.__name__, ord_cancel_req)) self.cancel_order(ord_cancel_req)
def updateAccountTime(self, timeStamp): """ IBString const & timeStamp """ logger.debug("updateAccountTime, timeStamp=%s", timeStamp)