From 517834efd40b194074df142f33a543e38b4c04d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Wed, 4 Dec 2024 14:01:26 +0300 Subject: [PATCH 01/10] get_symbol fixed --- kucoin/async_client.py | 6 +----- kucoin/client.py | 10 +++------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/kucoin/async_client.py b/kucoin/async_client.py index e53f862..802d304 100644 --- a/kucoin/async_client.py +++ b/kucoin/async_client.py @@ -469,12 +469,8 @@ async def get_symbol(self, symbol=None, **params): """ - data = {} - if symbol: - data["symbol"] = symbol - return await self._get( - "symbol", False, api_version=self.API_VERSION2, data=dict(data, **params) + "symbols/{}".format(symbol), False, api_version=self.API_VERSION2, **params ) async def get_ticker(self, symbol, **params): diff --git a/kucoin/client.py b/kucoin/client.py index 2357b9a..d0d6fef 100644 --- a/kucoin/client.py +++ b/kucoin/client.py @@ -361,13 +361,13 @@ def get_symbols(self, market=None, **params): https://www.kucoin.com/docs/rest/spot-trading/market-data/get-symbols-list - :param market: (optional) Name of market e.g. BTC + :param market: (optional) Name of market e.g. ETH-USDT :type market: string .. code:: python symbols = client.get_symbols() - symbols = client.get_symbols('USDS') + symbols = client.get_symbols('ETH-USDT') :returns: ApiResponse @@ -469,12 +469,8 @@ def get_symbol(self, symbol=None, **params): """ - data = {} - if symbol: - data["symbol"] = symbol - return self._get( - "symbol", False, api_version=self.API_VERSION2, data=dict(data, **params) + "symbols/{}".format(symbol), False, api_version=self.API_VERSION2, data=params ) def get_ticker(self, symbol, **params): From 1e871937fcd19301a07de2df7a5f46cba3819086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Wed, 4 Dec 2024 14:04:24 +0300 Subject: [PATCH 02/10] test_public_endpoints.py started --- tests/test_public_endpoints.py | 145 +++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 tests/test_public_endpoints.py diff --git a/tests/test_public_endpoints.py b/tests/test_public_endpoints.py new file mode 100644 index 0000000..aef9ead --- /dev/null +++ b/tests/test_public_endpoints.py @@ -0,0 +1,145 @@ +import pytest + +def test_spot_status(client): + response = client.get_status() + assert response is not None + +@pytest.mark.asyncio() +async def test_spot_status_async(asyncClient): + response = await asyncClient.get_status() + assert response is not None + +def test_futures_status(client): + response = client.futures_get_status() + assert response is not None + +@pytest.mark.asyncio() +async def test_futures_status_async(asyncClient): + response = await asyncClient.futures_get_status() + assert response is not None + +def test_announcements(client): + response = client.get_announcements() + assert response is not None + +@pytest.mark.asyncio() +async def test_announcements_async(asyncClient): + response = await asyncClient.get_announcements() + assert response is not None + +def test_currencies(client): + response = client.get_currencies() + assert response is not None + +@pytest.mark.asyncio() +async def test_currencies_async(asyncClient): + response = await asyncClient.get_currencies() + assert response is not None + +def test_currency(client): + response = client.get_currency("BTC") + currency = response["currency"] + assert currency == "BTC" + +# todo: throws TypeError: Invalid variable type: value should be str, int or float, got None of type +# @pytest.mark.asyncio() +# async def test_currency_async(asyncClient): +# response = await asyncClient.get_currency("BTC") +# currency = response["currency"] +# assert currency == "BTC" + +def test_symbols(client): + response = client.get_symbols() + assert response is not None + +@pytest.mark.asyncio() +async def test_symbols_async(asyncClient): + response = await asyncClient.get_symbols() + assert response is not None + +def test_symbol(client): + response = client.get_symbol("ETH-USDT") + symbol = response["symbol"] + assert symbol == "ETH-USDT" + +@pytest.mark.asyncio() +async def test_symbol_async(asyncClient): + response = await asyncClient.get_symbol("ETH-USDT") + symbol = response["symbol"] + assert symbol == "ETH-USDT" + +def test_ticker(client): + response = client.get_ticker("ETH-USDT") + assert response is not None + +@pytest.mark.asyncio() +async def test_ticker_async(asyncClient): + response = await asyncClient.get_ticker("ETH-USDT") + assert response is not None + +def test_tickers(client): + response = client.get_tickers() + assert response is not None + +@pytest.mark.asyncio() +async def test_tickers_async(asyncClient): + response = await asyncClient.get_tickers() + assert response is not None + +def test_24hr_stats(client): + response = client.get_24hr_stats("ETH-USDT") + symbol = response["symbol"] + assert symbol == "ETH-USDT" + +@pytest.mark.asyncio() +async def test_24hr_stats_async(asyncClient): + response = await asyncClient.get_24hr_stats("ETH-USDT") + symbol = response["symbol"] + assert symbol == "ETH-USDT" + +def test_markets(client): + response = client.get_markets() + assert response is not None + +@pytest.mark.asyncio() +async def test_markets_async(asyncClient): + response = await asyncClient.get_markets() + assert response is not None + +def test_order_book(client): + response = client.get_order_book("ETH-USDT") + assert response is not None + +@pytest.mark.asyncio() +async def test_order_book_async(asyncClient): + response = await asyncClient.get_order_book("ETH-USDT") + assert response is not None + +def test_trade_histories(client): + response = client.get_trade_histories("ETH-USDT") + assert response is not None + +@pytest.mark.asyncio() +async def test_trade_histories_async(asyncClient): + response = await asyncClient.get_trade_histories("ETH-USDT") + assert response is not None + +def test_kline_data(client): + response = client.get_kline_data("ETH-USDT") + assert response is not None + +@pytest.mark.asyncio() +async def test_kline_data_async(asyncClient): + response = await asyncClient.get_kline_data("ETH-USDT") + assert response is not None + +def test_fiat_prices(client): + code = "BTC" + response = client.get_fiat_prices(None, code) + assert code in response + +@pytest.mark.asyncio() +async def test_fiat_prices_async(asyncClient): + code = "BTC" + response = await asyncClient.get_fiat_prices(None, code) + assert code in response \ No newline at end of file From b3cf0785b9e06126961b38582c8bb22bd2f963c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Wed, 4 Dec 2024 16:34:29 +0300 Subject: [PATCH 03/10] get_kline_data changed to get_klines --- kucoin/async_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kucoin/async_client.py b/kucoin/async_client.py index 802d304..d4bf687 100644 --- a/kucoin/async_client.py +++ b/kucoin/async_client.py @@ -759,7 +759,7 @@ async def get_trade_histories(self, symbol, **params): return await self._get("market/histories", False, data=dict(data, **params)) - async def get_kline_data(self, symbol, kline_type="5min", start=None, end=None, **params): + async def get_klines(self, symbol, kline_type="5min", start=None, end=None, **params): """Get kline data https://www.kucoin.com/docs/rest/spot-trading/market-data/get-klines @@ -779,7 +779,7 @@ async def get_kline_data(self, symbol, kline_type="5min", start=None, end=None, .. code:: python - klines = client.get_kline_data('KCS-BTC', '5min', 1507479171, 1510278278) + klines = client.get_klines('KCS-BTC', '5min', 1507479171, 1510278278) :returns: ApiResponse From b6a8443ad5be39b02d50a7c608164c864cea852d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Wed, 4 Dec 2024 16:34:56 +0300 Subject: [PATCH 04/10] get_kline_data changed to get_klines sync --- kucoin/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kucoin/client.py b/kucoin/client.py index d0d6fef..793c96d 100644 --- a/kucoin/client.py +++ b/kucoin/client.py @@ -759,7 +759,7 @@ def get_trade_histories(self, symbol, **params): return self._get("market/histories", False, data=dict(data, **params)) - def get_kline_data(self, symbol, kline_type="5min", start=None, end=None, **params): + def get_klines(self, symbol, kline_type="5min", start=None, end=None, **params): """Get kline data https://www.kucoin.com/docs/rest/spot-trading/market-data/get-klines @@ -779,7 +779,7 @@ def get_kline_data(self, symbol, kline_type="5min", start=None, end=None, **para .. code:: python - klines = client.get_kline_data('KCS-BTC', '5min', 1507479171, 1510278278) + klines = client.get_klines('KCS-BTC', '5min', 1507479171, 1510278278) :returns: ApiResponse From 4baac3ab6aec532361e16a08a2887fee84420fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Wed, 4 Dec 2024 16:45:24 +0300 Subject: [PATCH 05/10] futures_get_kline_data fixed --- kucoin/async_client.py | 9 ++++----- kucoin/client.py | 11 +++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/kucoin/async_client.py b/kucoin/async_client.py index d4bf687..9bfce88 100644 --- a/kucoin/async_client.py +++ b/kucoin/async_client.py @@ -769,7 +769,7 @@ async def get_klines(self, symbol, kline_type="5min", start=None, end=None, **pa :param symbol: Name of symbol e.g. KCS-BTC :type symbol: string - :param kline_type: type of symbol, type of candlestick patterns: 1min, 3min, 5min, 15min, 30min, 1hour, 2hour, + :param kline_type: type of candlestick patterns: 1min, 3min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 8hour, 12hour, 1day, 1week :type kline_type: string :param start: Start time as unix timestamp (optional) default start of day in UTC @@ -1283,9 +1283,8 @@ async def futures_get_klines( :param symbol: Name of symbol e.g. XBTUSDTM :type symbol: string - :param kline_type: type of symbol, type of candlestick patterns: 1min, 3min, 5min, 15min, 30min, 1hour, 2hour, - 4hour, 6hour, 8hour, 12hour, 1day, 1week - :type kline_type: string + :param kline_type: type of candlestick in minutes: 1, 5, 50 etc. + :type kline_type: int :param start: Start time as unix timestamp (optional) default start of day in UTC :type start: int :param end: End time as unix timestamp (optional) default now in UTC @@ -1293,7 +1292,7 @@ async def futures_get_klines( .. code:: python - klines = client.futures_get_klines('XBTUSDTM', '5min', 1507479171, 1510278278) + klines = client.futures_get_klines('XBTUSDTM', 5, 1507479171, 1510278278) :returns: ApiResponse diff --git a/kucoin/client.py b/kucoin/client.py index 793c96d..b709084 100644 --- a/kucoin/client.py +++ b/kucoin/client.py @@ -769,7 +769,7 @@ def get_klines(self, symbol, kline_type="5min", start=None, end=None, **params): :param symbol: Name of symbol e.g. KCS-BTC :type symbol: string - :param kline_type: type of symbol, type of candlestick patterns: 1min, 3min, 5min, 15min, 30min, 1hour, 2hour, + :param kline_type: type of candlestick patterns: 1min, 3min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 8hour, 12hour, 1day, 1week :type kline_type: string :param start: Start time as unix timestamp (optional) default start of day in UTC @@ -1273,7 +1273,7 @@ def futures_get_trade_histories(self, symbol, **params): ) def futures_get_klines( - self, symbol, kline_type="5min", start=None, end=None, **params + self, symbol, kline_type=5, start=None, end=None, **params ): """Get kline data @@ -1283,9 +1283,8 @@ def futures_get_klines( :param symbol: Name of symbol e.g. XBTUSDTM :type symbol: string - :param kline_type: type of symbol, type of candlestick patterns: 1min, 3min, 5min, 15min, 30min, 1hour, 2hour, - 4hour, 6hour, 8hour, 12hour, 1day, 1week - :type kline_type: string + :param kline_type: type of candlestick in minutes: 1, 5, 50 etc. + :type kline_type: int :param start: Start time as unix timestamp (optional) default start of day in UTC :type start: int :param end: End time as unix timestamp (optional) default now in UTC @@ -1293,7 +1292,7 @@ def futures_get_klines( .. code:: python - klines = client.futures_get_klines('XBTUSDTM', '5min', 1507479171, 1510278278) + klines = client.futures_get_klines('XBTUSDTM', 5, 1507479171, 1510278278) :returns: ApiResponse From efbdff81694ed86cdc45f3bf77a2c806a3c3c8ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Wed, 4 Dec 2024 16:46:33 +0300 Subject: [PATCH 06/10] more public tests added --- tests/test_public_endpoints.py | 79 +++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 5 deletions(-) diff --git a/tests/test_public_endpoints.py b/tests/test_public_endpoints.py index aef9ead..e7903df 100644 --- a/tests/test_public_endpoints.py +++ b/tests/test_public_endpoints.py @@ -124,13 +124,13 @@ async def test_trade_histories_async(asyncClient): response = await asyncClient.get_trade_histories("ETH-USDT") assert response is not None -def test_kline_data(client): - response = client.get_kline_data("ETH-USDT") +def test_klines(client): + response = client.get_klines("ETH-USDT") assert response is not None @pytest.mark.asyncio() -async def test_kline_data_async(asyncClient): - response = await asyncClient.get_kline_data("ETH-USDT") +async def test_klines(asyncClient): + response = await asyncClient.get_klines("ETH-USDT") assert response is not None def test_fiat_prices(client): @@ -142,4 +142,73 @@ def test_fiat_prices(client): async def test_fiat_prices_async(asyncClient): code = "BTC" response = await asyncClient.get_fiat_prices(None, code) - assert code in response \ No newline at end of file + assert code in response + +def test_futures_symbols(client): + response = client.futures_get_symbols() + assert response is not None + +@pytest.mark.asyncio() +async def test_futures_symbols_async(asyncClient): + response = await asyncClient.futures_get_symbols() + assert response is not None + +def test_futures_tickers(client): + response = client.futures_get_tickers() + assert response is not None + +@pytest.mark.asyncio() +async def test_futures_tickers_async(asyncClient): + response = await asyncClient.futures_get_tickers() + assert response is not None + +def test_futures_ticker(client): + response = client.futures_get_ticker("ETHUSDTM") + symbol = response["symbol"] + assert symbol == "ETHUSDTM" + +@pytest.mark.asyncio() +async def test_futures_ticker_async(asyncClient): + response = await asyncClient.futures_get_ticker("ETHUSDTM") + symbol = response["symbol"] + assert symbol == "ETHUSDTM" + +def test_futures_order_book(client): + response = client.futures_get_order_book("ETHUSDTM") + symbol = response["symbol"] + assert symbol == "ETHUSDTM" + +@pytest.mark.asyncio() +async def test_futures_order_book_async(asyncClient): + response = await asyncClient.futures_get_order_book("ETHUSDTM") + symbol = response["symbol"] + assert symbol == "ETHUSDTM" + +def test_futures_full_order_book(client): + response = client.futures_get_full_order_book("ETHUSDTM") + symbol = response["symbol"] + assert symbol == "ETHUSDTM" + +@pytest.mark.asyncio() +async def test_futures_full_order_book_async(asyncClient): + response = await asyncClient.futures_get_full_order_book("ETHUSDTM") + symbol = response["symbol"] + assert symbol == "ETHUSDTM" + +def test_futures_trade_histories(client): + response = client.futures_get_trade_histories("ETHUSDTM") + assert response is not None + +@pytest.mark.asyncio() +async def test_futures_trade_histories_async(asyncClient): + response = await asyncClient.futures_get_trade_histories("ETHUSDTM") + assert response is not None + +def test_futures_klines(client): + response = client.futures_get_klines("ETHUSDTM") + assert response is not None + +@pytest.mark.asyncio() +async def test_futures_klines_async(asyncClient): + response = await asyncClient.futures_get_klines("ETHUSDTM") + assert response is not None \ No newline at end of file From 6a74dab1584a1b4080fea044064defae9bc11278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Wed, 4 Dec 2024 17:45:23 +0300 Subject: [PATCH 07/10] async futures_get_klines signature changed --- kucoin/async_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kucoin/async_client.py b/kucoin/async_client.py index 9bfce88..7716118 100644 --- a/kucoin/async_client.py +++ b/kucoin/async_client.py @@ -1273,7 +1273,7 @@ async def futures_get_trade_histories(self, symbol, **params): ) async def futures_get_klines( - self, symbol, kline_type="5min", start=None, end=None, **params + self, symbol, kline_type=5, start=None, end=None, **params ): """Get kline data From f5bfec8e6f4a7085c4f8f9ba0fdeadeec0544b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Wed, 4 Dec 2024 18:28:49 +0300 Subject: [PATCH 08/10] test_public_endpoints.py updated --- tests/test_public_endpoints.py | 41 ++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/tests/test_public_endpoints.py b/tests/test_public_endpoints.py index e7903df..810552a 100644 --- a/tests/test_public_endpoints.py +++ b/tests/test_public_endpoints.py @@ -129,7 +129,7 @@ def test_klines(client): assert response is not None @pytest.mark.asyncio() -async def test_klines(asyncClient): +async def test_klines_async(asyncClient): response = await asyncClient.get_klines("ETH-USDT") assert response is not None @@ -211,4 +211,41 @@ def test_futures_klines(client): @pytest.mark.asyncio() async def test_futures_klines_async(asyncClient): response = await asyncClient.futures_get_klines("ETHUSDTM") - assert response is not None \ No newline at end of file + assert response is not None + +def test_futures_interest_rate(client): + response = client.futures_get_interest_rate(".KXBT") + assert response is not None + +# todo: +# File "/opt/homebrew/lib/python3.11/site-packages/yarl/_url.py", line 946, in _query_var +# raise TypeError( +# TypeError: Invalid variable type: value should be str, int or float, got True of type +# @pytest.mark.asyncio() +# async def test_futures_interest_rate_async(asyncClient): +# response = await asyncClient.futures_get_interest_rate(".KXBT") +# assert response is not None + +# def test_futures_index(client): +# response = client.futures_get_index(".KXBT") +# assert response is not None + +# todo: +# File "/opt/homebrew/lib/python3.11/site-packages/yarl/_url.py", line 946, in _query_var +# raise TypeError( +# TypeError: Invalid variable type: value should be str, int or float, got True of type +# @pytest.mark.asyncio() +# async def test_futures_index_async(asyncClient): +# response = await asyncClient.futures_get_index(".KXBT") +# assert response is not None + +def test_futures_mark_price(client): + response = client.futures_get_mark_price("ETHUSDTM") + symbol = response["symbol"] + assert symbol == "ETHUSDTM" + +@pytest.mark.asyncio() +async def test_futures_mark_price_async(asyncClient): + response = await asyncClient.futures_get_mark_price("ETHUSDTM") + symbol = response["symbol"] + assert symbol == "ETHUSDTM" \ No newline at end of file From c4ccd4331af8c1ee9b914732cecaa9ba3c0ce124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Thu, 5 Dec 2024 14:39:58 +0300 Subject: [PATCH 09/10] Some public endpoints changed to private --- kucoin/async_client.py | 14 +++++++------- kucoin/client.py | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/kucoin/async_client.py b/kucoin/async_client.py index 7716118..6edf593 100644 --- a/kucoin/async_client.py +++ b/kucoin/async_client.py @@ -8914,7 +8914,7 @@ async def get_fills( if limit: data["pageSize"] = limit - return await self._get("fills", False, data=dict(data, **params)) + return await self._get("fills", True, data=dict(data, **params)) async def get_recent_fills(self, **params): """Get a list of recent fills. @@ -9227,7 +9227,7 @@ async def futures_get_fills( if limit: data["pageSize"] = limit - return await self._get("fills", False, is_futures=True, data=dict(data, **params)) + return await self._get("fills", True, is_futures=True, data=dict(data, **params)) async def futures_get_recent_fills(self, symbol=None, **params): """Get a list of recent futures fills. @@ -9282,7 +9282,7 @@ async def futures_get_recent_fills(self, symbol=None, **params): data["symbol"] = symbol return await self._get( - "recentFills", False, is_futures=True, data=dict(data, **params) + "recentFills", True, is_futures=True, data=dict(data, **params) ) async def futures_get_active_order_value(self, symbol, **params): @@ -9319,7 +9319,7 @@ async def futures_get_active_order_value(self, symbol, **params): data = {"symbol": symbol} return await self._get( - "openOrderStatistics", False, is_futures=True, data=dict(data, **params) + "openOrderStatistics", True, is_futures=True, data=dict(data, **params) ) # Margin Info Endpoints @@ -9373,7 +9373,7 @@ async def margin_get_leverage_token_info(self, currency=None, **params): async def margin_get_all_trading_pairs_mark_prices(self, **params): """Get a list of trading pairs and their mark prices - https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-all-trading-pairs-mark-price + https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-all-margin-trading-pairs-mark-prices .. code:: python @@ -10290,7 +10290,7 @@ async def margin_lending_get_currency_info(self, currency=None, **params): return await self._get( "project/list", - False, + True, api_version=self.API_VERSION3, data=dict(data, **params), ) @@ -10336,7 +10336,7 @@ async def margin_lending_get_interest_rate(self, currency, **params): return await self._get( "project/marketInterestRatet", - False, + True, api_version=self.API_VERSION3, data=dict(data, **params), ) diff --git a/kucoin/client.py b/kucoin/client.py index b709084..200f66c 100644 --- a/kucoin/client.py +++ b/kucoin/client.py @@ -8918,7 +8918,7 @@ def get_fills( if limit: data["pageSize"] = limit - return self._get("fills", False, data=dict(data, **params)) + return self._get("fills", True, data=dict(data, **params)) def get_recent_fills(self, **params): """Get a list of recent fills. @@ -9231,7 +9231,7 @@ def futures_get_fills( if limit: data["pageSize"] = limit - return self._get("fills", False, is_futures=True, data=dict(data, **params)) + return self._get("fills", True, is_futures=True, data=dict(data, **params)) def futures_get_recent_fills(self, symbol=None, **params): """Get a list of recent futures fills. @@ -9286,7 +9286,7 @@ def futures_get_recent_fills(self, symbol=None, **params): data["symbol"] = symbol return self._get( - "recentFills", False, is_futures=True, data=dict(data, **params) + "recentFills", True, is_futures=True, data=dict(data, **params) ) def futures_get_active_order_value(self, symbol, **params): @@ -9323,7 +9323,7 @@ def futures_get_active_order_value(self, symbol, **params): data = {"symbol": symbol} return self._get( - "openOrderStatistics", False, is_futures=True, data=dict(data, **params) + "openOrderStatistics", True, is_futures=True, data=dict(data, **params) ) # Margin Info Endpoints @@ -9377,7 +9377,7 @@ def margin_get_leverage_token_info(self, currency=None, **params): def margin_get_all_trading_pairs_mark_prices(self, **params): """Get a list of trading pairs and their mark prices - https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-all-trading-pairs-mark-price + https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-all-margin-trading-pairs-mark-prices .. code:: python @@ -10294,7 +10294,7 @@ def margin_lending_get_currency_info(self, currency=None, **params): return self._get( "project/list", - False, + True, api_version=self.API_VERSION3, data=dict(data, **params), ) @@ -10340,7 +10340,7 @@ def margin_lending_get_interest_rate(self, currency, **params): return self._get( "project/marketInterestRatet", - False, + True, api_version=self.API_VERSION3, data=dict(data, **params), ) From 98223a78342b4b0dcfb5c84dae40e7403c8498e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Thu, 5 Dec 2024 14:41:04 +0300 Subject: [PATCH 10/10] All tests for public endpoints added --- tests/test_public_endpoints.py | 48 +++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/tests/test_public_endpoints.py b/tests/test_public_endpoints.py index 810552a..68ac9c9 100644 --- a/tests/test_public_endpoints.py +++ b/tests/test_public_endpoints.py @@ -144,6 +144,17 @@ async def test_fiat_prices_async(asyncClient): response = await asyncClient.get_fiat_prices(None, code) assert code in response +def test_futures_symbol(client): + response = client.futures_get_symbol("ETHUSDTM") + symbol = response["symbol"] + assert symbol == "ETHUSDTM" + +@pytest.mark.asyncio() +async def test_futures_symbol_async(asyncClient): + response = await asyncClient.futures_get_symbol("ETHUSDTM") + symbol = response["symbol"] + assert symbol == "ETHUSDTM" + def test_futures_symbols(client): response = client.futures_get_symbols() assert response is not None @@ -226,9 +237,9 @@ def test_futures_interest_rate(client): # response = await asyncClient.futures_get_interest_rate(".KXBT") # assert response is not None -# def test_futures_index(client): -# response = client.futures_get_index(".KXBT") -# assert response is not None +def test_futures_index(client): + response = client.futures_get_index(".KXBT") + assert response is not None # todo: # File "/opt/homebrew/lib/python3.11/site-packages/yarl/_url.py", line 946, in _query_var @@ -248,4 +259,33 @@ def test_futures_mark_price(client): async def test_futures_mark_price_async(asyncClient): response = await asyncClient.futures_get_mark_price("ETHUSDTM") symbol = response["symbol"] - assert symbol == "ETHUSDTM" \ No newline at end of file + assert symbol == "ETHUSDTM" + +def test_futures_premium_index(client): + response = client.futures_get_premium_index("ETHUSDTM") + assert response is not None + +# todo: +# TypeError: Invalid variable type: value should be str, int or float, got True of type +# @pytest.mark.asyncio() +# async def test_futures_premium_index_async(asyncClient): +# response = await asyncClient.futures_get_premium_index("ETHUSDTM") +# assert response is not None + +def test_margin_all_trading_pairs_mark_prices(client): + response = client.margin_get_all_trading_pairs_mark_prices() + assert response is not None + +@pytest.mark.asyncio() +def test_margin_all_trading_pairs_mark_prices_async(asyncClient): + response = asyncClient.margin_get_all_trading_pairs_mark_prices() + assert response is not None + +def test_futures_public_funding_history(client): + response = client.futures_get_public_funding_history('ETHUSDTM', start=1622505600000, end=1622592000000) + assert response is not None + +@pytest.mark.asyncio() +async def test_futures_public_funding_history_async(asyncClient): + response = await asyncClient.futures_get_public_funding_history('ETHUSDTM', start=1622505600000, end=1622592000000) + assert response is not None \ No newline at end of file