From 61f03d2a8b7bbc439463ef796807ee74acb7637a Mon Sep 17 00:00:00 2001 From: Hayot Date: Mon, 8 Jul 2024 14:07:37 +0900 Subject: [PATCH] feat: gateio futures --- datamaxi/__version__.py | 2 +- datamaxi/gateio/__init__.py | 19 +++++++++++++++---- pyproject.toml | 2 +- tests/gateio/test_gateio_candle.py | 4 ++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/datamaxi/__version__.py b/datamaxi/__version__.py index 777f190..3e2f46a 100644 --- a/datamaxi/__version__.py +++ b/datamaxi/__version__.py @@ -1 +1 @@ -__version__ = "0.8.0" +__version__ = "0.9.0" diff --git a/datamaxi/gateio/__init__.py b/datamaxi/gateio/__init__.py index ab646d7..2465af8 100644 --- a/datamaxi/gateio/__init__.py +++ b/datamaxi/gateio/__init__.py @@ -49,7 +49,11 @@ def intervals(self) -> List[str]: @postprocess() def candle( - self, symbol: str, interval: str = "1d", pandas: bool = True + self, + symbol: str, + interval: str = "1d", + market: str = "spot", + pandas: bool = True, ) -> Union[List, pd.DataFrame]: """Get Gateio candle data @@ -60,11 +64,18 @@ def candle( Args: symbol (str): Gateio symbol interval (str): Candle interval + market (str): Market type (spot/futures) pandas (bool): Return data as pandas DataFrame Returns: - Gateio candle data for a given symbol and interval in pandas DataFrame + Gateio candle data for a given symbol, interval and market in pandas DataFrame """ - check_required_parameters([[symbol, "symbol"], [interval, "interval"]]) - params = {"symbol": symbol, "interval": interval} + check_required_parameters( + [[symbol, "symbol"], [interval, "interval"], [market, "market"]] + ) + + if market not in ["spot", "futures"]: + raise ValueError("market must be either spot or futures") + + params = {"symbol": symbol, "interval": interval, "market": market} return self.query("/v1/raw/gateio/candle", params) diff --git a/pyproject.toml b/pyproject.toml index d7b898a..fda66ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "datamaxi" -version = "0.8.0" +version = "0.9.0" authors = [ { name="Bisonai", email="business@bisonai.com" }, ] diff --git a/tests/gateio/test_gateio_candle.py b/tests/gateio/test_gateio_candle.py index aa7147f..9c4cf62 100644 --- a/tests/gateio/test_gateio_candle.py +++ b/tests/gateio/test_gateio_candle.py @@ -30,8 +30,8 @@ key = random_str() client = Client(key) -req_params = {"symbol": "BTC-USDT", "interval": "1d"} -params = {"symbol": "BTC-USDT", "interval": "1d", "pandas": False} +req_params = {"symbol": "BTC-USDT", "interval": "1d", "market": "spot"} +params = {"symbol": "BTC-USDT", "interval": "1d", "market": "spot", "pandas": False} @mock_http_response(