From 79faec209b7513c6ddc5a76db9caf7a175b3048d Mon Sep 17 00:00:00 2001 From: Martin Kersner Date: Sun, 2 Jun 2024 20:19:42 +0900 Subject: [PATCH 1/5] chore: update cex comments --- datamaxi/binance/__init__.py | 4 ++-- datamaxi/bithumb/__init__.py | 4 ++-- datamaxi/bybit/__init__.py | 4 ++-- datamaxi/coinone/__init__.py | 4 ++-- datamaxi/huobi/__init__.py | 4 ++-- datamaxi/okx/__init__.py | 4 ++-- datamaxi/upbit/__init__.py | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/datamaxi/binance/__init__.py b/datamaxi/binance/__init__.py index 994a2bd..c7bfdee 100644 --- a/datamaxi/binance/__init__.py +++ b/datamaxi/binance/__init__.py @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any): super().__init__(api_key, **kwargs) def symbols(self) -> List[str]: - """Supported Binance supported symbols + """Binance supported symbols `GET /v1/raw/binance/symbols` @@ -35,7 +35,7 @@ def symbols(self) -> List[str]: return self.query(url_path) def intervals(self) -> List[str]: - """Supported Binance supported intervals + """Binance supported intervals `GET /v1/raw/binance/intervals` diff --git a/datamaxi/bithumb/__init__.py b/datamaxi/bithumb/__init__.py index 15f4150..e9b6839 100644 --- a/datamaxi/bithumb/__init__.py +++ b/datamaxi/bithumb/__init__.py @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any): super().__init__(api_key, **kwargs) def symbols(self) -> List[str]: - """Supported Bithumb supported symbols + """Bithumb supported symbols `GET /v1/raw/bithumb/symbols` @@ -35,7 +35,7 @@ def symbols(self) -> List[str]: return self.query(url_path) def intervals(self) -> List[str]: - """Supported Bithumb supported intervals + """Bithumb supported intervals `GET /v1/raw/bithumb/intervals` diff --git a/datamaxi/bybit/__init__.py b/datamaxi/bybit/__init__.py index 9b833b8..b5f8a7a 100644 --- a/datamaxi/bybit/__init__.py +++ b/datamaxi/bybit/__init__.py @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any): super().__init__(api_key, **kwargs) def symbols(self) -> List[str]: - """Supported Bybit supported symbols + """Bybit supported symbols `GET /v1/raw/bybit/symbols` @@ -35,7 +35,7 @@ def symbols(self) -> List[str]: return self.query(url_path) def intervals(self) -> List[str]: - """Supported Bybit supported intervals + """Bybit supported intervals `GET /v1/raw/bybit/intervals` diff --git a/datamaxi/coinone/__init__.py b/datamaxi/coinone/__init__.py index 55f218e..a41326d 100644 --- a/datamaxi/coinone/__init__.py +++ b/datamaxi/coinone/__init__.py @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any): super().__init__(api_key, **kwargs) def symbols(self) -> List[str]: - """Supported Coinone supported symbols + """Coinone supported symbols `GET /v1/raw/coinone/symbols` @@ -35,7 +35,7 @@ def symbols(self) -> List[str]: return self.query(url_path) def intervals(self) -> List[str]: - """Supported Coinone supported intervals + """Coinone supported intervals `GET /v1/raw/coinone/intervals` diff --git a/datamaxi/huobi/__init__.py b/datamaxi/huobi/__init__.py index c56ea0f..7f0ea72 100644 --- a/datamaxi/huobi/__init__.py +++ b/datamaxi/huobi/__init__.py @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any): super().__init__(api_key, **kwargs) def symbols(self) -> List[str]: - """Supported Huobi supported symbols + """Huobi supported symbols `GET /v1/raw/huobi/symbols` @@ -35,7 +35,7 @@ def symbols(self) -> List[str]: return self.query(url_path) def intervals(self) -> List[str]: - """Supported Huobi supported intervals + """Huobi supported intervals `GET /v1/raw/huobi/intervals` diff --git a/datamaxi/okx/__init__.py b/datamaxi/okx/__init__.py index 66eec24..c155adb 100644 --- a/datamaxi/okx/__init__.py +++ b/datamaxi/okx/__init__.py @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any): super().__init__(api_key, **kwargs) def symbols(self) -> List[str]: - """Supported Okx supported symbols + """Okx supported symbols `GET /v1/raw/okx/symbols` @@ -35,7 +35,7 @@ def symbols(self) -> List[str]: return self.query(url_path) def intervals(self) -> List[str]: - """Supported Okx supported intervals + """Okx supported intervals `GET /v1/raw/okx/intervals` diff --git a/datamaxi/upbit/__init__.py b/datamaxi/upbit/__init__.py index 2605234..6329f6b 100644 --- a/datamaxi/upbit/__init__.py +++ b/datamaxi/upbit/__init__.py @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any): super().__init__(api_key, **kwargs) def symbols(self) -> List[str]: - """Supported Upbit supported symbols + """Upbit supported symbols `GET /v1/raw/upbit/symbols` @@ -35,7 +35,7 @@ def symbols(self) -> List[str]: return self.query(url_path) def intervals(self) -> List[str]: - """Supported Upbit supported intervals + """Upbit supported intervals `GET /v1/raw/upbit/intervals` From e22636eea279514928eaf715cf238bb1ffd9fb87 Mon Sep 17 00:00:00 2001 From: Martin Kersner Date: Sun, 2 Jun 2024 20:20:29 +0900 Subject: [PATCH 2/5] feat: unified candle data api --- datamaxi/datamaxi/__init__.py | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 datamaxi/datamaxi/__init__.py diff --git a/datamaxi/datamaxi/__init__.py b/datamaxi/datamaxi/__init__.py new file mode 100644 index 0000000..c2a915b --- /dev/null +++ b/datamaxi/datamaxi/__init__.py @@ -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` + + + + 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` + + + + 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` + + + + 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 = {"symbol": symbol, "interval": interval} + return self.query("/v1/candle", params) From 48dfdc6be7f5561d7da69800639f6af9860a06ae Mon Sep 17 00:00:00 2001 From: Martin Kersner Date: Sun, 2 Jun 2024 21:12:40 +0900 Subject: [PATCH 3/5] fix: pass missing exchange parameter --- datamaxi/datamaxi/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datamaxi/datamaxi/__init__.py b/datamaxi/datamaxi/__init__.py index c2a915b..996aba9 100644 --- a/datamaxi/datamaxi/__init__.py +++ b/datamaxi/datamaxi/__init__.py @@ -80,5 +80,5 @@ def candle( check_required_parameters( [[exchange, "exchange"], [symbol, "symbol"], [interval, "interval"]] ) - params = {"symbol": symbol, "interval": interval} + params = {"exchange": exchange, "symbol": symbol, "interval": interval} return self.query("/v1/candle", params) From 269cd23652f3c571537a2365e4dead0a53c28e1e Mon Sep 17 00:00:00 2001 From: Martin Kersner Date: Sun, 2 Jun 2024 21:19:38 +0900 Subject: [PATCH 4/5] feat: simplify Datamaxi import --- datamaxi/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/datamaxi/__init__.py b/datamaxi/__init__.py index e69de29..9b46fb9 100644 --- a/datamaxi/__init__.py +++ b/datamaxi/__init__.py @@ -0,0 +1 @@ +from datamaxi.datamaxi import Datamaxi From 2b96a42d02fdd508fb29998cb153c45199b672fe Mon Sep 17 00:00:00 2001 From: Martin Kersner Date: Sun, 2 Jun 2024 21:26:34 +0900 Subject: [PATCH 5/5] fix: noqa: F401 for auxiliary class import --- datamaxi/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datamaxi/__init__.py b/datamaxi/__init__.py index 9b46fb9..4548bca 100644 --- a/datamaxi/__init__.py +++ b/datamaxi/__init__.py @@ -1 +1 @@ -from datamaxi.datamaxi import Datamaxi +from datamaxi.datamaxi import Datamaxi # noqa: F401