-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
e0944e7
commit 10cffbb
Showing
17 changed files
with
242 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.19.0" | ||
__version__ = "0.20.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.