diff --git a/build/generate_private_tests.js b/build/generate_private_tests.js new file mode 100644 index 0000000..e8974e4 --- /dev/null +++ b/build/generate_private_tests.js @@ -0,0 +1,195 @@ +const { match } = require('assert'); +const fs = require('fs'); + +const SOURSE_FILE_NAME = './kucoin/client.py' +const TARGET_FILE_NAME = './tests/test_private_requests_generated.py' +const METHOD_DEFINITION_MATCH = /def\s(\w+)/ +const METHOD_CALL_MATCH = /self\.(\w+)\(/ +const REQUEST_METHODS = ['_get', '_post', '_put', '_delete'] +const METHOD_NAME_MATCH = /(\w+)\(/ +const ARGUMENTS_MATCH = /\((.*)\)/ +const REST_API_URL = 'https://api.kucoin.com' +const REST_FUTURES_API_URL = 'https://api-futures.kucoin.com' +const API_VERSIONS = { + 'API_VERSION': 'v1', + 'API_VERSION2': 'v2', + 'API_VERSION3': 'v3' +} + +const MANDATORY_ARGS = [ + 'sub_user_id', + 'include_base_ammount', + 'sub_name', + 'passphrase', + 'remark', + 'api_key', + 'account_id', + 'account_type', + 'currency', + 'type', + 'client_oid', + 'amount', + 'from_account_type', + 'to_account_type', + 'pay_account_type', + 'withdrawal_id', + 'symbols', + 'symbol', + 'side', + 'order_list', + 'order_id', + 'cancel_size', + 'timeout', + 'stop_price', + 'size', + 'price', + 'limit_price', + 'orders_data', + 'trade_type', + 'interest_rate', + 'purchase_order_no' +] + +function getPrivateMethodsArgumentsAndRequests (data) { + const lines = data.split ('\n') + lines.push('\n') + const methods = {} + let metodName = '' + let methodArgs = [] + let lastMethodDefinition = '' + for (let i = 0; i < lines.length; i++) { + let line = lines[i] + const methodDefinition = line.match (METHOD_DEFINITION_MATCH) + const methodCall = line.match (METHOD_CALL_MATCH) + if (methodDefinition) { // if line is method definition + while (!line.includes (':')) { + i++ + line += lines[i].trim() + } + lastMethodDefinition = line.replace ('def ', '') + .replaceAll (' ', '') + .replaceAll (',)', ')') + .replace (':', '') + continue // we need to check if this is private method + } else if (methodCall) { + let name = methodCall[1] + if (!REQUEST_METHODS.includes (name)) { // if this is not request method just skip + continue + } + if (line.endsWith ('(')) { // if request method is called not in one line + i++ + let nextLine = lines[i].trim() + while (nextLine !== ')') { + line += nextLine + i++ + nextLine = lines[i].trim() + } + line += nextLine + } + if (line.match (/[^,]+, True/)) { // if request method is called with second argument True + if (line.indexOf ('path') !== -1) { + continue // skip methods with path argument + } + [ metodName, methodArgs ] = getNameAndArgs (lastMethodDefinition) + methods[metodName] = { + args: methodArgs, + request: getParamsFromRequestCall (line.trim ().replace ('return self._', '').replaceAll ("'", '"')) + } + } + } + } + return methods +} + +function getNameAndArgs (line) { + let name = line.match (METHOD_NAME_MATCH)[1] + let args = line.match (ARGUMENTS_MATCH)[1].trim().split (',').filter (arg => (arg !== 'self' && arg !== '**params')) + return [ name, args ] +} + +function getParamsFromRequestCall (line) { + const matchMethodAndEndpointPattern = /(\w+)\("([^"]*)"/ + const matchFuturePattern = /is_futures=(\w+)/ + const matchVersionPattern = /version=self.(\w+)/ + const matchFormatPattern = /.format\((\w+)\)/ + const matchMethodAndEndpoint = line.match (matchMethodAndEndpointPattern) + const matchFuture = line.match (matchFuturePattern) + const matchVersion = line.match (matchVersionPattern) + const isFutures = (matchFuture && matchFuture[1] === 'True') ? true : false + const baseUrl = isFutures ? REST_FUTURES_API_URL : REST_API_URL + const version = matchVersion ? API_VERSIONS[matchVersion[1]] : API_VERSIONS.API_VERSION + let endpoint = matchMethodAndEndpoint[2] + const matchFormat = line.match (matchFormatPattern) + if (matchFormat) { + endpoint = endpoint.replace (matchFormat[0], '').replace ('{}', '{' + matchFormat[1] + '}') + } + const url = baseUrl + '/api/' + version + '/' + endpoint + return { + full: line, + url: url, + method: matchMethodAndEndpoint[1], + endpoint: endpoint, + isFutures: isFutures, + } +} + +function generateTests (methods) { + const tests = [ + 'import requests_mock', + 'import pytest', + 'from aioresponses import aioresponses' + ] + const methodNames = Object.keys (methods) + for (let methodName of methodNames) { + const method = methods[methodName] + const mandatoryArgs = generateMandatoryArgs (method) + let functionArgs = '' + for (let arg of mandatoryArgs) { + functionArgs += '"' + arg + '", ' + } + functionArgs = functionArgs.slice (0, -2) + const request = method.request + let url = request.url + const paramInParth = url.match (/{(\w+)}/) + if (paramInParth) { + url = url.replace (paramInParth[0], paramInParth[1]) + } + + const test = [ + '\n', + 'def test_' + methodName + '(client):', + ' with requests_mock.mock() as m:', + ' m.' + request.method + '("' + url + '")', + ' client.' + methodName + '('+ functionArgs + ')', + ' assert m.last_request.url == "' + url + '"' + + ] + tests.push (...test) + } + return tests.join ('\n') +} + +function generateMandatoryArgs (method) { + const args = method.args + return args.filter (arg => arg.indexOf ('=') === -1) +} + +function main () { + fs.readFile (SOURSE_FILE_NAME, 'utf8', (err, data) => { + if (err) { + console.error (err) + return + } + const privateMethodsArgumentsAndRequests = getPrivateMethodsArgumentsAndRequests (data) + const tests = generateTests (privateMethodsArgumentsAndRequests) + fs.writeFile (TARGET_FILE_NAME, tests, (err) => { + if (err) { + console.error (err) + return + } + console.log (TARGET_FILE_NAME + ' file is generated') + }) + }) +} + +main () diff --git a/kucoin/async_client.py b/kucoin/async_client.py index e53f862..6edf593 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): @@ -763,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 @@ -773,7 +769,7 @@ async def get_kline_data(self, symbol, kline_type="5min", start=None, end=None, :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 @@ -783,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 @@ -1277,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 @@ -1287,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 @@ -1297,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 @@ -8919,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. @@ -9232,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. @@ -9287,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): @@ -9324,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 @@ -9378,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 @@ -10295,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), ) @@ -10341,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 2357b9a..200f66c 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): @@ -763,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 @@ -773,7 +769,7 @@ def get_kline_data(self, symbol, kline_type="5min", start=None, end=None, **para :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 @@ -783,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 @@ -1277,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 @@ -1287,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 @@ -1297,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 @@ -8923,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. @@ -9236,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. @@ -9291,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): @@ -9328,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 @@ -9382,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 @@ -10299,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), ) @@ -10345,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), ) diff --git a/tests/test_public_endpoints.py b/tests/test_public_endpoints.py new file mode 100644 index 0000000..68ac9c9 --- /dev/null +++ b/tests/test_public_endpoints.py @@ -0,0 +1,291 @@ +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_klines(client): + response = client.get_klines("ETH-USDT") + assert response is not None + +@pytest.mark.asyncio() +async def test_klines_async(asyncClient): + response = await asyncClient.get_klines("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 + +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 + +@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 + +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" + +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