async def book_callback(self, book_type: str, book: OrderBook, receipt_timestamp: float, timestamp=None, raw=None, sequence_number=None, checksum=None, delta=None): if self.cross_check: self.check_bid_ask_overlapping(book) book.timestamp = timestamp book.raw = raw book.sequence_number = sequence_number book.delta = delta book.checksum = checksum await self.callback(book_type, book, receipt_timestamp)
def test_order_book(): ob = OrderBook('COINBASE', 'BTC-USD', bids={ 100: 1, 200: 2, 300: 3, 400: 4, 500: 5 }, asks={ 600: 6, 700: 7, 800: 8, 1000: 10 }) ob.timestamp = time() d = ob.to_dict() ob2 = OrderBook.from_dict(d) assert ob.book.to_dict() == ob2.book.to_dict() assert ob == ob2