def process_tick(self, msg): data = msg["data"] tb = tob() tb.exchange = "emx" tb.product = data["contract_code"] tb.best_bid_price = float(data["quote"]["bid"]) tb.best_bid_qty = float(data["quote"]["bid_size"]) tb.best_ask_price = float(data["quote"]["ask"]) tb.best_ask_qty = float(data["quote"]["ask_size"]) tb.timestamp = datetime.datetime.utcnow() return tb
async def test_maker_rounding_tob_based(cfg_strategy_fixture): try: strategy = market_maker(cfg_strategy_fixture, bittest_adapter()) except Exception: assert False _tob = tob() _tob.exchange = "test_exchange" _tob.product = "test-perp" _tob.best_bid_price = 99.0 _tob.best_bid_qty = 1 _tob.best_ask_price = 101.0 _tob.best_ask_qty = 1 _tob.timestamp = 0.0 strategy.tob = _tob orders = strategy.generate_orders() assert orders[0].price == _tob.best_ask_price assert orders[1].price == _tob.best_bid_price