Skip to content

Commit

Permalink
feat: Support for /api/v1/dex/trade/symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkersner committed Sep 2, 2024
1 parent 9ab0b12 commit 9371ed4
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 12 deletions.
2 changes: 1 addition & 1 deletion datamaxi/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.17.1"
__version__ = "0.18.0"
23 changes: 13 additions & 10 deletions datamaxi/datamaxi/candle.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def exchanges(self, market: str = "spot") -> List[str]:
url_path = "/api/v1/candle/exchanges"
return self.query(url_path, params)

def symbols(self, exchange: str, market: str = "spot") -> List[str]:
def symbols(
self, exchange: str = None, market: str = None, chain: str = None
) -> List[Dict]:
"""Fetch supported symbols accepted by
[datamaxi.Candle.get](./#datamaxi.datamaxi.Candle.get)
API.
Expand All @@ -150,21 +152,22 @@ def symbols(self, exchange: str, market: str = "spot") -> List[str]:
Args:
exchange (str): Exchange name
market (str): Market type (spot/futures)
chain (str): Chain name (applied to DEX only)
Returns:
List of supported symbols
"""
check_required_parameters(
[
[exchange, "exchange"],
[market, "market"],
]
)

if market not in ["spot", "futures"]:
if market is not None and market not in ["spot", "futures"]:
raise ValueError("market must be either spot or futures")

params = {"exchange": exchange, "market": market}
params = {}
if exchange is not None:
params["exchange"] = exchange
if market is not None:
params["market"] = market
if chain is not None:
params["chain"] = chain

url_path = "/api/v1/candle/symbols"
return self.query(url_path, params)

Expand Down
33 changes: 33 additions & 0 deletions datamaxi/datamaxi/dex_trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,36 @@ def exchanges(self) -> List[str]:
"""
url_path = "/api/v1/dex/trade/exchanges"
return self.query(url_path)

def symbols(
self, exchange: str = None, market: str = None, chain: str = None
) -> List[Dict]:
"""Fetch supported symbols accepted by
[datamaxi.Candle.get](./#datamaxi.datamaxi.Candle.get)
API.
`GET /api/v1/dex/trade/symbols`
<https://docs.datamaxiplus.com/api/datasets/dex-trade/symbols>
Args:
exchange (str): Exchange name
market (str): Market type (spot/futures)
chain (str): Chain name
Returns:
List of supported symbols
"""
if market is not None and market not in ["spot", "futures"]:
raise ValueError("market must be either spot or futures")

params = {}
if exchange is not None:
params["exchange"] = exchange
if market is not None:
params["market"] = market
if chain is not None:
params["chain"] = chain

url_path = "/api/v1/dex/trade/symbols"
return self.query(url_path, params)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "datamaxi"
version = "0.17.1"
version = "0.18.0"
authors = [
{ name="Bisonai", email="[email protected]" },
]
Expand Down

0 comments on commit 9371ed4

Please sign in to comment.