Skip to content

Commit

Permalink
Include new endpoints (#60)
Browse files Browse the repository at this point in the history
* feat: include new endpoints

* fix: new line at the end of the file

* fix: black reformatting

* docs: add missing comment

* fix: fix wrong function usage

* docs: fix misconfigured urls
  • Loading branch information
nick-bisonai authored Oct 10, 2024
1 parent e0944e7 commit 10cffbb
Show file tree
Hide file tree
Showing 17 changed files with 242 additions and 49 deletions.
2 changes: 1 addition & 1 deletion datamaxi/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.19.0"
__version__ = "0.20.0"
2 changes: 1 addition & 1 deletion datamaxi/announcement/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get(
`GET /api/v1/announcements`
<https://docs.datamaxiplus.com/api/datasets/announcements>
<https://docs.datamaxiplus.com/rest/announcements>
Args:
category (str): announcement category
Expand Down
8 changes: 4 additions & 4 deletions datamaxi/datamaxi/cex_candle.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get(
`GET /api/v1/cex/candle`
<https://docs.datamaxiplus.com/api/datasets/cex-candle/candle>
<https://docs.datamaxiplus.com/rest/cex/candle/data>
Args:
exchange (str): Exchange name
Expand Down Expand Up @@ -121,7 +121,7 @@ def exchanges(self, market: str = "spot") -> List[str]:
`GET /api/v1/cex/candle/exchanges`
<https://docs.datamaxiplus.com/api/datasets/cex-candle/exchanges>
<https://docs.datamaxiplus.com/rest/cex/candle/exchanges>
Args:
market (str): Market type (spot/futures)
Expand All @@ -145,7 +145,7 @@ def symbols(self, exchange: str = None, market: str = None) -> List[Dict]:
`GET /api/v1/cex/candle/symbols`
<https://docs.datamaxiplus.com/api/datasets/cex-candle/symbols>
<https://docs.datamaxiplus.com/rest/cex/candle/symbols>
Args:
exchange (str): Exchange name
Expand Down Expand Up @@ -173,7 +173,7 @@ def intervals(self, exchange: str, market: str = "spot") -> List[str]:
`GET /api/v1/candle/intervals`
<https://docs.datamaxiplus.com/api/datasets/cex-candle/intervals>
<https://docs.datamaxiplus.com/rest/cex/candle/intervals>
Args:
exchange (str): Exchange name
Expand Down
10 changes: 5 additions & 5 deletions datamaxi/datamaxi/dex_candle.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get(
`GET /api/v1/dex/candle`
<https://docs.datamaxiplus.com/api/datasets/dex-candle/candle>
<https://docs.datamaxiplus.com/rest/dex/candle/data>
Args:
chain (str): Chain name
Expand Down Expand Up @@ -117,7 +117,7 @@ def chains(self) -> List[str]:
`GET /api/v1/dex/candle/chains`
<https://docs.datamaxiplus.com/api/datasets/dex-candle/chains>
<https://docs.datamaxiplus.com/rest/dex/candle/chains>
Returns:
List of supported chains
Expand All @@ -133,7 +133,7 @@ def exchanges(self) -> List[str]:
`GET /api/v1/dex/candle/exchanges`
<https://docs.datamaxiplus.com/api/datasets/dex-candle/exchanges>
<https://docs.datamaxiplus.com/rest/dex/candle/exchanges>
Returns:
List of supported exchanges
Expand All @@ -149,7 +149,7 @@ def pools(self, exchange: str = None, chain: str = None) -> List[Dict]:
`GET /api/v1/dex/candle/pools`
<https://docs.datamaxiplus.com/api/datasets/dex-candle/poolsx>
<https://docs.datamaxiplus.com/rest/dex/candle/pools>
Args:
exchange (str): Exchange name
Expand All @@ -174,7 +174,7 @@ def intervals(self) -> List[str]:
`GET /api/v1/dex/candle/intervals`
<https://docs.datamaxiplus.com/api/datasets/dex-candle/intervals>
<https://docs.datamaxiplus.com/rest/dex/candle/intervals>
Returns:
List of supported intervals
Expand Down
8 changes: 4 additions & 4 deletions datamaxi/datamaxi/dex_trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get(
`GET /api/v1/dex/trade`
<https://docs.datamaxiplus.com/api/datasets/dex-trade/trade>
<https://docs.datamaxiplus.com/rest/dex/trade/data>
Args:
chain (str): Chain name
Expand Down Expand Up @@ -111,7 +111,7 @@ def chains(self) -> List[str]:
`GET /api/v1/dex/trade/chains`
<https://docs.datamaxiplus.com/api/datasets/dex-trade/chains>
<https://docs.datamaxiplus.com/rest/dex/trade/chains>
Returns:
List of supported chains
Expand All @@ -127,7 +127,7 @@ def exchanges(self) -> List[str]:
`GET /api/v1/dex/trade/exchanges`
<https://docs.datamaxiplus.com/api/datasets/dex-trade/exchanges>
<https://docs.datamaxiplus.com/rest/dex/trade/exchanges>
Returns:
List of supported exchanges
Expand All @@ -142,7 +142,7 @@ def pools(self, exchange: str = None, chain: str = None) -> List[Dict]:
`GET /api/v1/dex/trade/pools`
<https://docs.datamaxiplus.com/api/datasets/dex-trade/pools>
<https://docs.datamaxiplus.com/rest/dex/trade/pools>
Args:
exchange (str): Exchange name
Expand Down
4 changes: 2 additions & 2 deletions datamaxi/datamaxi/forex.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get(
`GET /api/v1/forex`
<https://docs.datamaxiplus.com/api/datasets/forex/forex>
<https://docs.datamaxiplus.com/rest/forex/forex>
Args:
symbol (str): Symbol name
Expand Down Expand Up @@ -56,7 +56,7 @@ def symbols(self) -> List[str]:
`GET /api/v1/forex/symbols`
<https://docs.datamaxiplus.com/api/datasets/forex/symbols>
<https://docs.datamaxiplus.com/rest/forex/symbols>
Returns:
List of supported symbols
Expand Down
8 changes: 4 additions & 4 deletions datamaxi/datamaxi/funding_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get(
`GET /api/v1/funding-rate`
<https://docs.datamaxiplus.com/api/datasets/funding-rate/historical-funding-rate>
<https://docs.datamaxiplus.com/rest/funding-rate/historical-funding-rate>
Args:
exchange (str): Exchange name
Expand Down Expand Up @@ -113,7 +113,7 @@ def getLatest(
`GET /api/v1/funding-rate/latest`
<https://docs.datamaxiplus.com/api/datasets/funding-rate/latest-funding-rate>
<https://docs.datamaxiplus.com/rest/funding-rate/latest-funding-rate>
Args:
sort (str): Sort data by `asc` or `desc`
Expand Down Expand Up @@ -155,7 +155,7 @@ def exchanges(self) -> List[str]:
`GET /api/v1/funding-rate/exchanges`
<https://docs.datamaxiplus.com/api/datasets/funding-rate/exchanges>
<https://docs.datamaxiplus.com/rest/funding-rate/exchanges>
Returns:
List of supported exchanges
Expand All @@ -170,7 +170,7 @@ def symbols(self, exchange: str, market: str = "spot") -> List[str]:
`GET /api/v1/funding-rate/symbols`
<https://docs.datamaxiplus.com/api/datasets/funding-rate/symbols>
<https://docs.datamaxiplus.com/rest/funding-rate/symbols>
Args:
exchange (str): Exchange name
Expand Down
95 changes: 95 additions & 0 deletions datamaxi/datamaxi/orderbook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
from typing import Any, List, Dict, Union
import pandas as pd
from datamaxi.api import API
from datamaxi.lib.utils import check_required_parameters
from datamaxi.lib.utils import check_required_parameter


class Orderbook(API):
"""Client to fetch orderbook data from DataMaxi+ API."""

def __init__(self, api_key=None, **kwargs: Any):
"""Initialize orderbook client.
Args:
api_key (str): The DataMaxi+ API key
**kwargs: Keyword arguments used by `datamaxi.api.API`.
"""
super().__init__(api_key, **kwargs)

def get(
self,
exchange: str,
symbol: str,
pandas: bool = True,
) -> Union[Dict, pd.DataFrame]:
"""Fetch orderbook data
`GET /api/v1/orderbook`
<https://docs.datamaxiplus.com/rest/orderbook/orderbook>
Args:
exchange (str): Exchange name
symbol (str): symbol name
pandas (bool): Return data as pandas DataFrame
Returns:
Orderbook data in pandas DataFrame
"""

check_required_parameters(
[
[exchange, "exchange"],
[symbol, "symbol"],
]
)

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

res = self.query("/api/v1/orderbook", params)
if pandas:
df = pd.DataFrame(res)
df = df.set_index("d")
return df

return res

def exchanges(self) -> List[str]:
"""Fetch supported exchanges accepted by
[datamaxi.Orderbook.get](./#datamaxi.datamaxi.Orderbook.get)
API.
`GET /api/v1/orderbook/exchanges`
<https://docs.datamaxiplus.com/rest/orderbook/exchanges>
Returns:
List of supported exchange
"""
url_path = "/api/v1/orderbook/exchanges"
return self.query(url_path)

def symbols(self, exchange: str) -> List[str]:
"""Fetch supported symbols accepted by
[datamaxi.Orderbook.get](./#datamaxi.datamaxi.Orderbook.get)
API.
`GET /api/v1/orderbook/symbols`
<https://docs.datamaxiplus.com/rest/orderbook/symbols>
Args:
exchange (str): Exchange name
Returns:
List of supported symbols
"""
check_required_parameter(exchange, "exchange")

params = {
"exchange": exchange,
}

url_path = "/api/v1/orderbook/symbols"
return self.query(url_path, params)
6 changes: 3 additions & 3 deletions datamaxi/datamaxi/premium.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get(
"""Fetch premium data
`GET /api/v1/premium`
<https://docs.datamaxiplus.com/api/datasets/premium/premium>
<https://docs.datamaxiplus.com/rest/premium/premium>
Args:
sort (str): Sort data by `asc` or `desc`
Expand Down Expand Up @@ -74,7 +74,7 @@ def exchanges(self) -> List[str]:
`GET /api/v1/Premium/exchanges`
<https://docs.datamaxiplus.com/api/datasets/Premium/exchanges>
<https://docs.datamaxiplus.com/rest/Premium/exchanges>
Returns:
List of supported exchange
Expand All @@ -89,7 +89,7 @@ def symbols(self, sourceExchange: str, targetExchange: str) -> List[str]:
`GET /api/v1/premium/symbols`
<https://docs.datamaxiplus.com/api/datasets/premium/symbols>
<https://docs.datamaxiplus.com/rest/premium/symbols>
Args:
sourceExchange (str): Source exchange name
Expand Down
6 changes: 3 additions & 3 deletions datamaxi/datamaxi/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get(
`GET /api/v1/ticker`
<https://docs.datamaxiplus.com/api/datasets/ticker/ticker>
<https://docs.datamaxiplus.com/rest/ticker/ticker>
Args:
exchange (str): Exchange name
Expand Down Expand Up @@ -66,7 +66,7 @@ def exchanges(self) -> List[str]:
`GET /api/v1/ticker/exchanges`
<https://docs.datamaxiplus.com/api/datasets/ticker/exchanges>
<https://docs.datamaxiplus.com/rest/ticker/exchanges>
Returns:
List of supported exchange
Expand All @@ -81,7 +81,7 @@ def symbols(self, exchange: str) -> List[str]:
`GET /api/v1/ticker/symbols`
<https://docs.datamaxiplus.com/api/datasets/ticker/symbols>
<https://docs.datamaxiplus.com/rest/ticker/symbols>
Args:
exchange (str): Exchange name
Expand Down
Loading

0 comments on commit 10cffbb

Please sign in to comment.