def __init__(self): """ Initializes an empty queue with given tickSize and remembers order book the queue belong to if any """ from marketsim.gen._out.orderbook._lasttradeimpl import LastTradeImpl self.lastTrade = LastTradeImpl() self.reset() from marketsim.gen._out.orderbook._bestpriceimpl import BestPriceImpl self.bestPrice = BestPriceImpl(self)
class Queue_Impl(Queue_Base): def __init__(self): self.queue.bestPrice += _(self)._onBestChanged self.bestPrice = BestPriceImpl(self) self.lastTrade = LastTradeImpl() self.queue.lastTrade += _(self)._onTraded self.reset() def reset(self): self._best = self.queue.best self._lastT = 0 @property def side(self): return self.queue.side @property def lastPrice(self): return self._best.price if self._best is not None else None def _update(self, best): self._best = best self.bestPrice.fire(self) def _onTraded(self, value): self.link.send(_(self.lastTrade, value).set) def _onBestChanged(self, queue): best = queue.best self.link.send(_(self, best)._update) @property def best(self): return self._best @property def empty(self): return self._best is None
def __init__(self): self.queue.bestPrice += _(self)._onBestChanged self.bestPrice = BestPriceImpl(self) self.lastTrade = LastTradeImpl() self.queue.lastTrade += _(self)._onTraded self.reset()