Exemple #1
0
 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)
Exemple #2
0
 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)
Exemple #3
0
 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)
Exemple #4
0
 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)
Exemple #5
0
 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)
Exemple #6
0
 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)
Exemple #7
0
 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)
Exemple #9
0
    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))
Exemple #10
0
 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)
Exemple #13
0
 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)
Exemple #14
0
 def on_market_depth(self, market_depth: MarketDepth) -> None:
     logger.debug("[%s] %s" % (self.__class__.__name__, market_depth))
Exemple #15
0
 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)
Exemple #16
0
 def on_quote(self, quote: Quote) -> None:
     logger.debug("[%s] %s" % (self.__class__.__name__, quote))
Exemple #17
0
 def on_trade(self, trade: Trade) -> None:
     logger.debug("[%s] %s" % (self.__class__.__name__, trade))
Exemple #18
0
 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)
Exemple #19
0
 def on_bar(self, bar: Bar) -> None:
     logger.debug("[%s] %s" % (self.__class__.__name__, bar))
Exemple #20
0
 def on_portf_upd(self, portf_upd: PortfolioUpdate) -> None:
     logger.debug("[%s] %s" % (self.__class__.__name__, portf_upd))
Exemple #21
0
 def on_error(self, err):
     logger.debug("[%s] Error: %s" % (self.__class__.__name__, err))
Exemple #22
0
 def on_exec_report(self, exec_report: ExecutionReport) -> None:
     logger.debug("[%s] %s" % (self.__class__.__name__, exec_report))
Exemple #23
0
 def on_acc_upd(self, acc_upd: AccountUpdate) -> None:
     logger.debug("[%s] %s" % (self.__class__.__name__, acc_upd))
Exemple #24
0
 def on_ord_upd(self, ord_upd: OrderStatusUpdate) -> None:
     logger.debug("[%s] %s" % (self.__class__.__name__, ord_upd))
Exemple #25
0
 def nextValidId(self, orderId):
     """
     OrderId orderId
     """
     logger.debug("nextValidId, orderId=%s", orderId)
Exemple #26
0
 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)
Exemple #27
0
 def tickGeneric(self, tickerId, tickType, value):
     """
     TickerId tickerId, TickType tickType, double value
     """
     logger.debug("tickGeneric, tickerId=%s tickType=%s value=%s", tickerId, tickType, value)
Exemple #28
0
 def on_completed(self):
     logger.debug("[%s] Completed" % self.__class__.__name__)
Exemple #29
0
 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)
Exemple #30
0
 def updateAccountTime(self, timeStamp):
     """
     IBString const & timeStamp
     """
     logger.debug("updateAccountTime, timeStamp=%s", timeStamp)