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
7 changes: 0 additions & 7 deletions datamaxi/_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,13 +1355,6 @@
"enum": ["USD", "USDT"],
"description": "Specifies conversion base applied to price values",
},
"include_source": {
"required": False,
"in": "query",
"type": "bool",
"default": False,
"description": "When true, include the frame's transport source (ws|rest) in the response.",
},
},
},
"ticker_exchanges": {
Expand Down
3 changes: 0 additions & 3 deletions datamaxi/_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,16 +1253,13 @@ class TickerResponse:
currency: str = ""
data: Optional[TickerView] = None
market: str = ""
# Source is populated only when ?include_source=true; omitempty drops the key for default callers, preserving the pre-Phase-1 JSON byte shape (strict-decoder safe).
src: Any = None

@classmethod
def from_dict(cls, data: dict) -> TickerResponse:
return cls(
currency=data.get("currency", ""),
data=_as_model(TickerView, data.get("data")),
market=data.get("market", ""),
src=data.get("src"),
)


Expand Down
2 changes: 1 addition & 1 deletion datamaxi/aio/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def request_endpoint(self, op_id, **params):

async def send_request(self, method, url_path, payload=None):
# str()-encode scalars so bools match the sync client's urlencode
# output (e.g. include_source -> "True", not httpx's "true").
# output (e.g. a bool param -> "True", not httpx's "true").
params = {k: str(v) for k, v in (payload or {}).items() if v is not None}
attempt = 0
while True:
Expand Down
2 changes: 0 additions & 2 deletions datamaxi/aio/cex.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ async def get(
market: Market,
currency: Optional[str] = None,
conversion_base: Optional[str] = None,
include_source: bool = False,
pandas: bool = True,
) -> Union[pd.DataFrame, TickerResponse]:
"""Fetch ticker data (async). See ``datamaxi.Datamaxi.cex.ticker``."""
Expand All @@ -120,7 +119,6 @@ async def get(
market=market,
currency=currency,
conversion_base=conversion_base,
include_source=include_source,
)

if pandas:
Expand Down
4 changes: 0 additions & 4 deletions datamaxi/resources/cex_ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def get(
market: Market,
currency: Optional[str] = None,
conversion_base: Optional[str] = None,
include_source: bool = False,
pandas: bool = True,
) -> Union[pd.DataFrame, TickerResponse]:
"""Fetch ticker data
Expand All @@ -45,8 +44,6 @@ def get(
market (str): Market type (spot/futures)
currency (str): Price currency
conversion_base (str): Conversion base currency
include_source (bool): Include the frame's transport source
(``ws``|``rest``) in the response
pandas (bool): Return data as pandas DataFrame

Returns:
Expand All @@ -71,7 +68,6 @@ def get(
market=market,
currency=currency,
conversion_base=conversion_base,
include_source=include_source,
)

if pandas:
Expand Down
22 changes: 0 additions & 22 deletions tests/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,6 @@ async def run():
assert res == _CANDLE


def test_async_ticker_forwards_bool_param_like_sync():
seen = {}

def handler(request):
seen.update(dict(request.url.params))
return httpx.Response(200, json=_TICKER)

async def run():
async with _client(handler) as c:
return await c.cex.ticker.get(
exchange="binance",
market="spot",
symbol="BTC-USDT",
include_source=True,
)

df = _run(run())
assert isinstance(df, pd.DataFrame)
# bool encoded as "True" (matches the sync urlencode output), not "true"
assert seen["include_source"] == "True"


def test_async_last_response_populated():
headers = {"x-ratelimit-remaining": "42"}

Expand Down
18 changes: 0 additions & 18 deletions tests/test_cex_ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,6 @@ def test_ticker_get_sends_query_params():
assert qs["conversion_base"] == ["USDT"]


@responses.activate
def test_ticker_get_forwards_include_source():
responses.add(
responses.GET,
re.compile(".*/api/v1/ticker.*"),
json=_TICKER,
status=200,
)
_client().get(
exchange="binance",
market="spot",
symbol="BTC-USDT",
include_source=True,
)
qs = _qs(responses.calls[0])
assert qs["include_source"] == ["True"]


def test_ticker_invalid_market_raises_value_error():
with pytest.raises(ValueError):
_client().get(exchange="binance", market="bogus", symbol="BTC-USDT")
Expand Down
Loading