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
19 changes: 9 additions & 10 deletions datamaxi/datamaxi/cex_announcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,15 @@ def __call__(
if sort not in [ASC, DESC]:
raise ValueError("sort must be either asc or desc")

params = {
"page": page,
"limit": limit,
"sort": sort,
"key": key,
"exchange": exchange,
"category": category,
}

res = self.query("/api/v1/cex/announcements", params)
res = self.request_endpoint(
"cex_announcements",
page=page,
limit=limit,
sort=sort,
key=key,
exchange=exchange,
category=category,
)
if res["data"] is None:
raise ValueError("no data found")

Expand Down
19 changes: 3 additions & 16 deletions datamaxi/datamaxi/cex_fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ def __call__(
Returns:
Trading fee data
"""
params = {}
if exchange:
params["exchange"] = exchange
if symbol:
params["symbol"] = symbol

url_path = "/api/v1/cex/fees"
return self.query(url_path, params)
return self.request_endpoint("cex_fees", exchange=exchange, symbol=symbol)

def exchanges(self) -> List[str]:
"""Fetch supported exchanges for fee data.
Expand All @@ -52,8 +45,7 @@ def exchanges(self) -> List[str]:
Returns:
List of supported exchanges
"""
url_path = "/api/v1/cex/fees/exchanges"
return self.query(url_path)
return self.request_endpoint("cex_fees_exchanges")

def symbols(self, exchange: str) -> List[str]:
"""Fetch supported symbols for fee data.
Expand All @@ -70,9 +62,4 @@ def symbols(self, exchange: str) -> List[str]:
"""
check_required_parameter(exchange, "exchange")

params = {
"exchange": exchange,
}

url_path = "/api/v1/cex/fees/symbols"
return self.query(url_path, params)
return self.request_endpoint("cex_fees_symbols", exchange=exchange)
35 changes: 12 additions & 23 deletions datamaxi/datamaxi/cex_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ def metadata(

`GET /api/v1/cex/symbol/metadata`
"""
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/metadata", params)
return self.request_endpoint(
"cex_symbol_metadata", exchange=exchange, base=base
)

def tags(
self, exchange: Optional[str] = None, base: Optional[str] = None
Expand All @@ -35,12 +32,7 @@ def tags(

`GET /api/v1/cex/symbol/tags`
"""
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/tags", params)
return self.request_endpoint("cex_symbol_tags", exchange=exchange, base=base)

def cautions(
self, exchange: Optional[str] = None, base: Optional[str] = None
Expand Down Expand Up @@ -85,10 +77,7 @@ def oi(self, base: str, exchange: Optional[str] = None) -> Dict[str, Any]:

`GET /api/v1/cex/symbol/oi`
"""
params: Dict[str, Any] = {"base": base}
if exchange is not None:
params["exchange"] = exchange
return self.query("/api/v1/cex/symbol/oi", params)
return self.request_endpoint("cex_symbol_oi", base=base, exchange=exchange)

def oi_stats(
self,
Expand All @@ -107,10 +96,12 @@ def oi_stats(
"""
if currency not in ("USD", "KRW"):
raise ValueError("currency must be either USD or KRW")
params: Dict[str, Any] = {"base": base, "currency": currency}
if exchange is not None:
params["exchange"] = exchange
return self.query("/api/v1/cex/symbol/oi-stats", params)
return self.request_endpoint(
"cex_symbol_oi_stats",
base=base,
exchange=exchange,
currency=currency,
)

def liquidation(self, base: str, window: str = "24h") -> Dict[str, Any]:
"""Per-exchange long / short liquidation aggregates over a window.
Expand All @@ -121,6 +112,4 @@ def liquidation(self, base: str, window: str = "24h") -> Dict[str, Any]:
base (str): Base asset (e.g. ``BTC``).
window (str): Time window (``1h``, ``24h``, ``7d`` — server caps at 30d).
"""
return self.query(
"/api/v1/cex/symbol/liquidation", {"base": base, "window": window}
)
return self.request_endpoint("cex_symbol_liquidation", base=base, window=window)
36 changes: 10 additions & 26 deletions datamaxi/datamaxi/cex_ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,14 @@ def get(
if market not in [SPOT, FUTURES]:
raise ValueError("market must be either spot or futures")

params = {
"exchange": exchange,
"symbol": symbol,
"market": market,
}

if currency is not None:
params["currency"] = currency

if conversion_base is not None:
params["conversion_base"] = conversion_base

res = self.query("/api/v1/ticker", params)
res = self.request_endpoint(
"ticker",
exchange=exchange,
symbol=symbol,
market=market,
currency=currency,
conversion_base=conversion_base,
)

if pandas:
df = pd.DataFrame([res["data"]])
Expand Down Expand Up @@ -101,12 +96,7 @@ def exchanges(
if market not in [SPOT, FUTURES]:
raise ValueError("market must be either spot or futures")

params = {
"market": market,
}

url_path = "/api/v1/ticker/exchanges"
return self.query(url_path, params)
return self.request_endpoint("ticker_exchanges", market=market)

def symbols(
self,
Expand Down Expand Up @@ -136,10 +126,4 @@ def symbols(
if market not in [SPOT, FUTURES]:
raise ValueError("market must be either spot or futures")

params = {
"exchange": exchange,
"market": market,
}

url_path = "/api/v1/ticker/symbols"
return self.query(url_path, params)
return self.request_endpoint("ticker_symbols", exchange=exchange, market=market)
18 changes: 3 additions & 15 deletions datamaxi/datamaxi/cex_wallet_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@ def __call__(
]
)

params = {
"exchange": exchange,
"asset": asset,
}

url_path = "/api/v1/wallet-status"
res = self.query(url_path, params)
res = self.request_endpoint("wallet_status", exchange=exchange, asset=asset)
if pandas:
df = pd.DataFrame(res)
df = df.set_index("network")
Expand All @@ -68,8 +62,7 @@ def exchanges(self) -> List[str]:
Returns:
List of supported exchange
"""
url_path = "/api/v1/wallet-status/exchanges"
return self.query(url_path)
return self.request_endpoint("wallet_status_exchanges")

def assets(self, exchange: str) -> List[str]:
"""Fetch supported assets for wallet status data.
Expand All @@ -86,9 +79,4 @@ def assets(self, exchange: str) -> List[str]:
"""
check_required_parameter(exchange, "exchange")

params = {
"exchange": exchange,
}

url_path = "/api/v1/wallet-status/assets"
return self.query(url_path, params)
return self.request_endpoint("wallet_status_assets", exchange=exchange)
9 changes: 2 additions & 7 deletions datamaxi/datamaxi/forex.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ def __call__(
"""
check_required_parameter(symbol, "symbol")

params = {
"symbol": symbol,
}

res = self.query("/api/v1/forex", params)
res = self.request_endpoint("forex", symbol=symbol)

if pandas:
return pd.DataFrame([res])
Expand All @@ -60,5 +56,4 @@ def symbols(self) -> List[str]:
Returns:
List of supported symbols
"""
url_path = "/api/v1/forex/symbols"
return self.query(url_path)
return self.request_endpoint("forex_symbols")
27 changes: 11 additions & 16 deletions datamaxi/datamaxi/funding_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,15 @@ def history(
if sort not in [ASC, DESC]:
raise ValueError("sort must be either asc or desc")

params = {
"exchange": exchange,
"symbol": symbol,
"page": page,
"limit": limit,
"from": fromDateTime,
"to": toDateTime,
"sort": sort,
}

res = self.query("/api/v1/funding-rate/history", params)
res = self.request_endpoint(
"funding_rate_history",
exchange=exchange,
symbol=symbol,
page=page,
limit=limit,
sort=sort,
**{"from": fromDateTime, "to": toDateTime},
)
if res["data"] is None or len(res["data"]) == 0:
raise ValueError("no data found")

Expand Down Expand Up @@ -159,8 +157,7 @@ def exchanges(self) -> List[str]:
Returns:
List of supported exchanges
"""
url_path = "/api/v1/funding-rate/exchanges"
return self.query(url_path)
return self.request_endpoint("funding_rate_exchanges")

def symbols(self, exchange: str) -> List[str]:
"""Fetch supported symbols for funding rate endpoints.
Expand All @@ -176,6 +173,4 @@ def symbols(self, exchange: str) -> List[str]:
List of supported symbols
"""
check_required_parameter(exchange, "exchange")
params = {"exchange": exchange}
url_path = "/api/v1/funding-rate/symbols"
return self.query(url_path, params)
return self.request_endpoint("funding_rate_symbols", exchange=exchange)
33 changes: 16 additions & 17 deletions datamaxi/datamaxi/liquidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ def __call__(
"""
if limit < 1:
raise ValueError("limit must be greater than 0")
params = {"exchange": exchange, "symbol": symbol, "limit": limit}
return self.query("/api/v1/liquidation", params)
return self.request_endpoint(
"liquidation", exchange=exchange, symbol=symbol, limit=limit
)

def feed(self, limit: int = 100) -> Dict[str, Any]:
"""Firehose: most recent liquidation events across every symbol.
Expand All @@ -47,7 +48,7 @@ def feed(self, limit: int = 100) -> Dict[str, Any]:
"""
if limit < 1:
raise ValueError("limit must be greater than 0")
return self.query("/api/v1/liquidation/feed", {"limit": limit})
return self.request_endpoint("liquidation_feed", limit=limit)

def heatmap(
self,
Expand All @@ -64,9 +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, "top_n": topN}
)
return self.request_endpoint("liquidation_heatmap", window=window, top_n=topN)

def map(
self,
Expand All @@ -83,8 +82,9 @@ def map(
exchange (str): Exchange (default ``binance``).
quote (str): Quote asset (default ``USDT``).
"""
params = {"base": base, "exchange": exchange, "quote": quote}
return self.query("/api/v1/liquidation/map", params)
return self.request_endpoint(
"liquidation_map", base=base, exchange=exchange, quote=quote
)

def symbol_history(
self,
Expand All @@ -106,12 +106,11 @@ def symbol_history(
interval (str): Bucket interval (``5m``, ``15m``, or ``1h``).
window (str): Lookback window (``24h``, ``72h``, or ``7d``).
"""
params = {
"symbol": symbol,
"quote": quote,
"interval": interval,
"window": window,
}
if exchange is not None:
params["exchange"] = exchange
return self.query("/api/v1/liquidation/symbol-history", params)
return self.request_endpoint(
"liquidation_symbol_history",
symbol=symbol,
quote=quote,
exchange=exchange,
interval=interval,
window=window,
)
Loading
Loading