Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions datamaxi/_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@
"type": "str",
"description": "Base asset filter (case-insensitive)",
},
"minVolumeUsd": {
"min_volume_usd": {
"required": False,
"type": "float",
"description": "Minimum VolumeUsd filter",
Expand Down Expand Up @@ -817,7 +817,7 @@
"enum": ["1h", "4h", "24h"],
"description": "Rolling window",
},
"topN": {
"top_n": {
"required": False,
"type": "int",
"default": 10,
Expand Down Expand Up @@ -872,7 +872,7 @@
"type": "str",
"description": "Exchange filter",
},
"minVolumeUsd": {
"min_volume_usd": {
"required": False,
"type": "float",
"description": "Minimum VolumeUsd filter",
Expand Down Expand Up @@ -1089,7 +1089,7 @@
"requires_auth": True,
"group": "open_interest",
"params": {
"topN": {
"top_n": {
"required": False,
"type": "int",
"default": 10,
Expand Down
2 changes: 1 addition & 1 deletion datamaxi/datamaxi/liquidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def heatmap(
if topN < 1 or topN > 30:
raise ValueError("topN must be between 1 and 30")
return self.query(
"/api/v1/liquidation/heatmap", {"window": window, "topN": topN}
"/api/v1/liquidation/heatmap", {"window": window, "top_n": topN}
)

def map(
Expand Down
2 changes: 1 addition & 1 deletion datamaxi/datamaxi/open_interest.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def summary(self, topN: int = 10) -> Dict[str, Any]:
"""
if topN < 1 or topN > 30:
raise ValueError("topN must be between 1 and 30")
return self.query("/api/v1/open-interest/summary", {"topN": topN})
return self.query("/api/v1/open-interest/summary", {"top_n": topN})

def history_aggregated(
self,
Expand Down
51 changes: 51 additions & 0 deletions tests/test_query_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""
Offline unit tests asserting the wire query-string keys for snake_case
public params (top_n / min_volume_usd).

Backend migrated these public params to snake_case canonical (dual-read).
These tests pin that the SDK sends the snake_case keys on the wire, and
that the user-facing ``topN`` kwarg stays accepted (non-breaking).
"""

import re
import responses
from urllib.parse import urlparse, parse_qs

from datamaxi.datamaxi.liquidation import Liquidation
from datamaxi.datamaxi.open_interest import OpenInterest

BASE_URL = "https://api.datamaxiplus.com"


def _query_of(call):
return parse_qs(urlparse(call.request.url).query)


@responses.activate
def test_liquidation_heatmap_sends_top_n():
responses.add(
responses.GET,
re.compile(".*/api/v1/liquidation/heatmap.*"),
json={},
status=200,
)
Liquidation(api_key="k", base_url=BASE_URL).heatmap(window="4h", topN=5)

qs = _query_of(responses.calls[0])
assert qs["top_n"] == ["5"]
assert "topN" not in qs


@responses.activate
def test_open_interest_summary_sends_top_n():
responses.add(
responses.GET,
re.compile(".*/api/v1/open-interest/summary.*"),
json={},
status=200,
)
OpenInterest(api_key="k", base_url=BASE_URL).summary(topN=7)

qs = _query_of(responses.calls[0])
assert qs["top_n"] == ["7"]
assert "topN" not in qs
Loading