diff --git a/py_clob_client/clob_types.py b/py_clob_client/clob_types.py index 6eab47c..058d77e 100644 --- a/py_clob_client/clob_types.py +++ b/py_clob_client/clob_types.py @@ -142,6 +142,7 @@ def json(self): class OrderBookSummary: market: str = None asset_id: str = None + timestamp: str = None bids: list[OrderSummary] = None asks: list[OrderSummary] = None hash: str = None diff --git a/py_clob_client/utilities.py b/py_clob_client/utilities.py index b542777..10c8af1 100644 --- a/py_clob_client/utilities.py +++ b/py_clob_client/utilities.py @@ -15,6 +15,7 @@ def parse_raw_orderbook_summary(raw_obs: any) -> OrderBookSummary: orderbookSummary = OrderBookSummary( market=raw_obs["market"], asset_id=raw_obs["asset_id"], + timestamp=raw_obs["timestamp"], bids=bids, asks=asks, hash=raw_obs["hash"], diff --git a/setup.py b/setup.py index b6c5229..fe9ab30 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="py_clob_client", - version="0.17.5", + version="0.18.0", author="Polymarket Engineering", author_email="engineering@polymarket.com", maintainer="Polymarket Engineering", diff --git a/tests/test_utilities.py b/tests/test_utilities.py index ec77d0e..027bad4 100644 --- a/tests/test_utilities.py +++ b/tests/test_utilities.py @@ -31,6 +31,7 @@ def test_parse_raw_orderbook_summary(self): ], "asks": [], "hash": "9d6d9e8831a150ac4cd878f99f7b2c6d419b875f", + "timestamp": "123456789", } orderbook_summary = parse_raw_orderbook_summary(raw_obs) @@ -46,6 +47,7 @@ def test_parse_raw_orderbook_summary(self): self.assertEqual( orderbook_summary.hash, "9d6d9e8831a150ac4cd878f99f7b2c6d419b875f" ) + self.assertEqual(orderbook_summary.timestamp, "123456789") self.assertIsNotNone(orderbook_summary.asks) self.assertIsNotNone(orderbook_summary.bids) @@ -68,6 +70,7 @@ def test_parse_raw_orderbook_summary(self): "bids": [], "asks": [], "hash": "7f81a35a09e1933a96b05edb51ac4be4a6163146", + "timestamp": "123456789", } orderbook_summary = parse_raw_orderbook_summary(raw_obs) @@ -83,6 +86,7 @@ def test_parse_raw_orderbook_summary(self): self.assertEqual( orderbook_summary.hash, "7f81a35a09e1933a96b05edb51ac4be4a6163146" ) + self.assertEqual(orderbook_summary.timestamp, "123456789") self.assertIsNotNone(orderbook_summary.asks) self.assertIsNotNone(orderbook_summary.bids) @@ -103,21 +107,23 @@ def test_generate_orderbook_summary_hash(self): {"price": "0.7", "size": "100"}, ], "hash": "", + "timestamp": "123456789", } orderbook_summary = parse_raw_orderbook_summary(raw_obs) self.assertEqual( generate_orderbook_summary_hash(orderbook_summary), - "b8b72c72c6534d1b3a4e7fb47b81672d0e94d5a5", + "5489da29343426f88622d61044975dc5fd828a27", ) self.assertEqual( orderbook_summary.hash, - "b8b72c72c6534d1b3a4e7fb47b81672d0e94d5a5", + "5489da29343426f88622d61044975dc5fd828a27", ) raw_obs = { "market": "0xaabbcc", "asset_id": "100", + "timestamp": "123456789", "bids": [ {"price": "0.3", "size": "100"}, {"price": "0.4", "size": "100"}, @@ -126,22 +132,23 @@ def test_generate_orderbook_summary_hash(self): {"price": "0.6", "size": "100"}, {"price": "0.7", "size": "100"}, ], - "hash": "b8b72c72c6534d1b3a4e7fb47b81672d0e94d5a5", + "hash": "5489da29343426f88622d61044975dc5fd828a27", } orderbook_summary = parse_raw_orderbook_summary(raw_obs) self.assertEqual( generate_orderbook_summary_hash(orderbook_summary), - "b8b72c72c6534d1b3a4e7fb47b81672d0e94d5a5", + "5489da29343426f88622d61044975dc5fd828a27", ) self.assertEqual( orderbook_summary.hash, - "b8b72c72c6534d1b3a4e7fb47b81672d0e94d5a5", + "5489da29343426f88622d61044975dc5fd828a27", ) raw_obs = { "market": "0xaabbcc", "asset_id": "100", + "timestamp": "", "bids": [], "asks": [], "hash": "", @@ -150,11 +157,11 @@ def test_generate_orderbook_summary_hash(self): orderbook_summary = parse_raw_orderbook_summary(raw_obs) self.assertEqual( generate_orderbook_summary_hash(orderbook_summary), - "7f81a35a09e1933a96b05edb51ac4be4a6163146", + "6d754a2f0304a83544f91a076fa3faa9cbfb9f63", ) self.assertEqual( orderbook_summary.hash, - "7f81a35a09e1933a96b05edb51ac4be4a6163146", + "6d754a2f0304a83544f91a076fa3faa9cbfb9f63", ) def test_order_to_json_0_1(self):