-
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.
* chore: update cex comments * feat: unified candle data api * fix: pass missing exchange parameter * feat: simplify Datamaxi import * fix: noqa: F401 for auxiliary class import
- Loading branch information
1 parent
eaf7b78
commit 769f304
Showing
9 changed files
with
99 additions
and
14 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from datamaxi.datamaxi import Datamaxi # noqa: F401 |
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,84 @@ | ||
from typing import Any, List, Union | ||
import pandas as pd | ||
from datamaxi.api import API | ||
from datamaxi.lib.utils import check_required_parameter | ||
from datamaxi.lib.utils import check_required_parameters | ||
from datamaxi.lib.utils import postprocess | ||
from datamaxi.lib.constants import BASE_URL | ||
|
||
|
||
class Datamaxi(API): | ||
"""Client to fetch unified data from DataMaxi+ API.""" | ||
|
||
def __init__(self, api_key=None, **kwargs: Any): | ||
"""Initialize the object. | ||
Args: | ||
api_key (str): The DataMaxi+ API key | ||
**kwargs: Keyword arguments used by `datamaxi.api.API`. | ||
""" | ||
if "base_url" not in kwargs: | ||
kwargs["base_url"] = BASE_URL | ||
|
||
super().__init__(api_key, **kwargs) | ||
|
||
def symbols(self, exchange: str) -> List[str]: | ||
"""Supported symbols by given exchange | ||
`GET /v1/symbols` | ||
<https://docs.datamaxiplus.com/symbols> | ||
Args: | ||
exchange (str): Exchange name | ||
Returns: | ||
List of supported symbols | ||
""" | ||
check_required_parameter(exchange, "exchange") | ||
params = {"exchange": exchange} | ||
url_path = "/v1/symbols" | ||
return self.query(url_path, params) | ||
|
||
def intervals(self, exchange: str) -> List[str]: | ||
"""Supported intervals by given exchange | ||
`GET /v1/intervals` | ||
<https://docs.datamaxiplus.com/intervals> | ||
Args: | ||
exchange (str): Exchange name | ||
Returns: | ||
List of supported intervals | ||
""" | ||
check_required_parameter(exchange, "exchange") | ||
params = {"exchange": exchange} | ||
url_path = "/v1/intervals" | ||
return self.query(url_path, params) | ||
|
||
@postprocess() | ||
def candle( | ||
self, exchange: str, symbol: str, interval: str = "1d", pandas: bool = True | ||
) -> Union[List, pd.DataFrame]: | ||
"""Get candle data | ||
`GET /v1/candle` | ||
<https://docs.datamaxiplus.com/candle> | ||
Args: | ||
exchange (str): Exchange name | ||
symbol (str): Symbol name | ||
interval (str): Candle interval | ||
pandas (bool): Return data as pandas DataFrame | ||
Returns: | ||
Candle data for a given symbol and interval in pandas DataFrame | ||
""" | ||
check_required_parameters( | ||
[[exchange, "exchange"], [symbol, "symbol"], [interval, "interval"]] | ||
) | ||
params = {"exchange": exchange, "symbol": symbol, "interval": interval} | ||
return self.query("/v1/candle", 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
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