def process(self, order): if isinstance(order, types.IOrder): BookBase.process(self, order) else: # if 'callback' in dir(order): # order.callback = _(self, order.callback)._sendToDownLink self._upLink.send(_(self._book, order).process)
def __init__(self, tickSize=1, _digitsToShow = None, label="", timeseries = [], marketOrderFee = None, # optional function (order, book)-> price to calculate fee for a market order limitOrderFee = None, cancelOrderFee = None): """ Initializes empty order book with given tick size """ BookBase.__init__(self, Bids(tickSize, self), Asks(tickSize, self), label, timeseries) self._digitsToShow = _digitsToShow if self._digitsToShow is None: nDigits = 0 d = 1. while tickSize * d < 1: nDigits += 1 d *= 10 self._digitsToShow = nDigits self._tickSize = tickSize self._marketOrderFee = marketOrderFee self._limitOrderFee = limitOrderFee self._cancelOrderFee = cancelOrderFee
def __init__(self, orderbook, link): BookBase.__init__(self, # TODO: dependency tracking Queue(orderbook.bids, self, link.down), Queue(orderbook.asks, self, link.down), orderbook.label) self.link = link self._book = orderbook self._digitsToShow = self._book._digitsToShow