From 45f9773c4dccc3cbf7a7ed5a5e2d0dfb22e99937 Mon Sep 17 00:00:00 2001 From: Nick Harder Date: Wed, 11 Dec 2024 16:16:31 +0100 Subject: [PATCH] move the warning and check before clearing --- assume/markets/base_market.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/assume/markets/base_market.py b/assume/markets/base_market.py index 769ce204..e658c753 100644 --- a/assume/markets/base_market.py +++ b/assume/markets/base_market.py @@ -610,6 +610,12 @@ async def clear_market(self, market_products: list[MarketProduct]): Args: market_products (list[MarketProduct]): The products to be traded. """ + if not self.all_orders: + logger.warning( + f"[{self.context.current_timestamp}] The order book for market {self.marketconfig.market_id} with products {market_products} is empty. No orders were found." + ) + return + try: (accepted_orderbook, rejected_orderbook, market_meta, flows) = self.clear( self.all_orders, market_products @@ -670,12 +676,7 @@ async def clear_market(self, market_products: list[MarketProduct]): receiver_addr=agent, ) # store order book in db agent - all_orders = accepted_orderbook + rejected_orderbook - if not all_orders: - logger.warning( - f"[{self.context.current_timestamp}] The combined order book for market {self.marketconfig.market_id} with products {market_products} is empty. No accepted or rejected orders were found." - ) - await self.store_order_book(all_orders) + await self.store_order_book(accepted_orderbook + rejected_orderbook) for meta in market_meta: logger.debug(