From ec6b2ed203360727bcc5781ac8dbf5cee0c9114b Mon Sep 17 00:00:00 2001 From: Masanori HIRANO Date: Sun, 7 Apr 2024 17:42:51 +0900 Subject: [PATCH] add coverage --- tests/pams/test_market.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/pams/test_market.py b/tests/pams/test_market.py index 83e35ba3..9a2afe19 100644 --- a/tests/pams/test_market.py +++ b/tests/pams/test_market.py @@ -13,6 +13,7 @@ from pams import Cancel from pams import Market from pams import Order +from pams.logs.base import ExpirationLog from pams.logs.base import Logger from pams.simulator import Simulator @@ -749,3 +750,29 @@ def test_execution_order_pattern10(self) -> None: assert market.remain_executable_orders() logs = market._execution() assert len(logs) == 2 + + def test_expiration_orrder(self) -> None: + logger = Logger() + market = self.base_class( + market_id=0, + prng=random.Random(42), + logger=logger, + simulator=Simulator(prng=random.Random(42)), + name="test", + ) + market._update_time(1.0) + market._is_running = True + order = Order( + agent_id=0, market_id=0, is_buy=False, kind=MARKET_ORDER, volume=2, ttl=1 + ) + market._add_order(order) + order = Order( + agent_id=0, market_id=0, is_buy=True, kind=MARKET_ORDER, volume=1, ttl=1 + ) + market._add_order(order) + market._update_time(1.0) + market._update_time(1.0) + assert ( + len([log for log in logger.pending_logs if isinstance(log, ExpirationLog)]) + == 2 + )