From 8c6b9b8de054edf70012ff27559c83040cc3da30 Mon Sep 17 00:00:00 2001 From: Martin Kersner Date: Wed, 1 Jul 2026 13:15:05 +0900 Subject: [PATCH 1/2] convert funding_rate.latest, cex_token.updates, cex_symbol volume/cautions/delistings onto request_endpoint drop dead kwargs: latest sort/limit, updates sort, volume exchange, cautions/delistings base. snake_case wire params from registry. update over-specified mocked tests to real contract. --- datamaxi/datamaxi/cex_symbol.py | 33 ++++++++----------------------- datamaxi/datamaxi/cex_token.py | 18 +++-------------- datamaxi/datamaxi/funding_rate.py | 22 +++------------------ tests/test_cex_symbol.py | 5 ++--- tests/test_cex_token.py | 1 - 5 files changed, 16 insertions(+), 63 deletions(-) diff --git a/datamaxi/datamaxi/cex_symbol.py b/datamaxi/datamaxi/cex_symbol.py index 35c79dd..76e7385 100644 --- a/datamaxi/datamaxi/cex_symbol.py +++ b/datamaxi/datamaxi/cex_symbol.py @@ -34,43 +34,26 @@ def tags( """ return self.request_endpoint("cex_symbol_tags", exchange=exchange, base=base) - def cautions( - self, exchange: Optional[str] = None, base: Optional[str] = None - ) -> Dict[str, Any]: + def cautions(self, exchange: Optional[str] = None) -> Dict[str, Any]: """Active caution / investment-warning flags per symbol. `GET /api/v1/cex/symbol/cautions` """ - params: Dict[str, Any] = {} - if exchange is not None: - params["exchange"] = exchange - if base is not None: - params["base"] = base - return self.query("/api/v1/cex/symbol/cautions", params) - - def delistings( - self, exchange: Optional[str] = None, base: Optional[str] = None - ) -> Dict[str, Any]: + return self.request_endpoint("cex_symbol_cautions", exchange=exchange) + + def delistings(self, exchange: Optional[str] = None) -> Dict[str, Any]: """Scheduled delistings with timestamps. `GET /api/v1/cex/symbol/delistings` """ - params: Dict[str, Any] = {} - if exchange is not None: - params["exchange"] = exchange - if base is not None: - params["base"] = base - return self.query("/api/v1/cex/symbol/delistings", params) - - def volume(self, base: str, exchange: Optional[str] = None) -> Dict[str, Any]: + return self.request_endpoint("cex_symbol_delistings", exchange=exchange) + + def volume(self, base: str) -> Dict[str, Any]: """Per-exchange 24h volume for a single base asset. `GET /api/v1/cex/symbol/volume` """ - params: Dict[str, Any] = {"base": base} - if exchange is not None: - params["exchange"] = exchange - return self.query("/api/v1/cex/symbol/volume", params) + return self.request_endpoint("cex_symbol_volume", base=base) def oi(self, base: str, exchange: Optional[str] = None) -> Dict[str, Any]: """Per-exchange Open Interest for a single base asset. diff --git a/datamaxi/datamaxi/cex_token.py b/datamaxi/datamaxi/cex_token.py index a46c5e2..b77a49e 100644 --- a/datamaxi/datamaxi/cex_token.py +++ b/datamaxi/datamaxi/cex_token.py @@ -1,6 +1,5 @@ from typing import Any, Dict, Optional, Tuple, Callable from datamaxi.api import API -from datamaxi.lib.constants import DESC, ASC class CexToken(API): @@ -20,7 +19,6 @@ def updates( page: int = 1, limit: int = 1000, type: Optional[str] = None, - sort: str = DESC, ) -> Tuple[Dict[str, Any], Callable]: """Get token update data @@ -31,7 +29,6 @@ def updates( Args: page (int): Page number limit (int): Limit of data - sort (str): Sort order type (str): Update type Returns: @@ -43,20 +40,12 @@ def updates( if limit < 1: raise ValueError("limit must be greater than 0") - if sort not in [ASC, DESC]: - raise ValueError("sort must be either asc or desc") - if type is not None and type not in ["listed", "delisted"]: raise ValueError("type must be either listed or delisted when set") - params = { - "page": page, - "limit": limit, - "type": type, - "sort": sort, - } - - res = self.query("/api/v1/cex/token/updates", params) + res = self.request_endpoint( + "cex_token_updates", page=page, limit=limit, type=type + ) if res["data"] is None: raise ValueError("no data found") @@ -65,7 +54,6 @@ def next_request(): type=type, page=page + 1, limit=limit, - sort=sort, ) return res, next_request diff --git a/datamaxi/datamaxi/funding_rate.py b/datamaxi/datamaxi/funding_rate.py index f8e7d7a..579ded2 100644 --- a/datamaxi/datamaxi/funding_rate.py +++ b/datamaxi/datamaxi/funding_rate.py @@ -104,8 +104,6 @@ def latest( self, exchange: str = None, symbol: str = None, - sort: str = None, - limit: int = None, pandas: bool = True, ) -> Union[Dict, pd.DataFrame]: """Fetch latest funding rate data @@ -117,28 +115,14 @@ def latest( Args: exchange (str): exchange name symbol (str): Symbol name - sort (str): Sort data by `asc` or `desc` - limit (int): Limit number of data to return pandas (bool): Return data as pandas DataFrame Returns: Latest funding rate data in pandas DataFrame or dict response """ - params = {} - - if exchange is not None: - params["exchange"] = exchange - - if symbol is not None: - params["symbol"] = symbol - - if sort is not None: - params["sort"] = sort - - if limit is not None: - params["limit"] = limit - - res = self.query("/api/v1/funding-rate/latest", params) + res = self.request_endpoint( + "funding_rate_latest", exchange=exchange, symbol=symbol + ) if pandas: df = pd.DataFrame([res]) diff --git a/tests/test_cex_symbol.py b/tests/test_cex_symbol.py index 3587178..c3f5a99 100644 --- a/tests/test_cex_symbol.py +++ b/tests/test_cex_symbol.py @@ -49,7 +49,7 @@ def test_tags_returns_dict(): @mock_http_response(responses.GET, "/api/v1/cex/symbol/cautions", {"BTC": []}) def test_cautions_returns_dict(): - assert _client().cautions(base="BTC") == {"BTC": []} + assert _client().cautions(exchange="binance") == {"BTC": []} @mock_http_response(responses.GET, "/api/v1/cex/symbol/delistings", {"BTC": []}) @@ -65,10 +65,9 @@ def test_volume_sends_base_param(): json={"BTC": {"binance": "100"}}, status=200, ) - res = _client().volume(base="BTC", exchange="binance") + res = _client().volume(base="BTC") qs = _qs(responses.calls[0]) assert qs["base"] == ["BTC"] - assert qs["exchange"] == ["binance"] assert res == {"BTC": {"binance": "100"}} diff --git a/tests/test_cex_token.py b/tests/test_cex_token.py index 7f8c42c..f6ce5a3 100644 --- a/tests/test_cex_token.py +++ b/tests/test_cex_token.py @@ -42,7 +42,6 @@ def test_token_updates_sends_query_params(): assert qs["page"] == ["3"] assert qs["limit"] == ["10"] assert qs["type"] == ["listed"] - assert qs["sort"] == ["desc"] def test_token_updates_invalid_type_raises_value_error(): From f888333f543f550c08614d24dcfe84f325400e62 Mon Sep 17 00:00:00 2001 From: Martin Kersner Date: Wed, 1 Jul 2026 14:07:29 +0900 Subject: [PATCH 2/2] test(integration): drop updates(sort) + latest(sort/limit) cases for removed kwargs --- tests/test_integration.py | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/tests/test_integration.py b/tests/test_integration.py index 90c4e5d..1208b8f 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -428,18 +428,6 @@ def test_updates_type_delisted(self, datamaxi): assert isinstance(result, dict) assert "data" in result - def test_updates_sort_asc(self, datamaxi): - """Test token updates with sort=asc.""" - result, _ = datamaxi.cex.token.updates(sort="asc", limit=10) - assert isinstance(result, dict) - assert "data" in result - - def test_updates_sort_desc(self, datamaxi): - """Test token updates with sort=desc.""" - result, _ = datamaxi.cex.token.updates(sort="desc", limit=10) - assert isinstance(result, dict) - assert "data" in result - def test_updates_invalid_type(self, datamaxi): """Test that invalid type raises ValueError.""" with pytest.raises( @@ -575,26 +563,6 @@ def test_latest_basic(self, datamaxi): assert isinstance(result, pd.DataFrame) assert len(result) == 1 - @_FLAKY_PROD_DATA_XFAIL - def test_latest_with_sort(self, datamaxi): - """Test latest funding rate with sort parameter.""" - result = datamaxi.funding_rate.latest( - exchange="binance", - symbol="BTC-USDT", - sort="asc", - ) - assert isinstance(result, pd.DataFrame) - - @_FLAKY_PROD_DATA_XFAIL - def test_latest_with_limit(self, datamaxi): - """Test latest funding rate with limit parameter.""" - result = datamaxi.funding_rate.latest( - exchange="binance", - symbol="BTC-USDT", - limit=5, - ) - assert isinstance(result, pd.DataFrame) - @_FLAKY_PROD_DATA_XFAIL def test_latest_pandas_false(self, datamaxi): """Test latest funding rate with pandas=False."""