From 2b2873f29aa11a7149a9b06ad1e2d2aca86d84ac Mon Sep 17 00:00:00 2001 From: carlosmiei <43336371+carlosmiei@users.noreply.github.com> Date: Mon, 21 Oct 2024 12:15:57 +0100 Subject: [PATCH] add missing methods --- binance/client.py | 22 ++++++++++++++++++---- tests/test_futures.py | 14 ++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/binance/client.py b/binance/client.py index 0681df8f..3d133b8d 100755 --- a/binance/client.py +++ b/binance/client.py @@ -7448,10 +7448,10 @@ def futures_countdown_cancel_all(self, **params): def futures_account_balance(self, **params): """Get futures account balance - https://binance-docs.github.io/apidocs/futures/en/#future-account-balance-user_data + https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Futures-Account-Balance-V3 """ - return self._request_futures_api('get', 'balance', True, 2, data=params) + return self._request_futures_api('get', 'balance', True, 3, data=params) def futures_account(self, **params): """Get current account information. @@ -7568,6 +7568,13 @@ def futures_stream_close(self, listenKey): } return self._request_futures_api('delete', 'listenKey', signed=False, data=params) + # new methods + def futures_account_config(self, **params): + return self._request_futures_api('get', 'accountConfig', signed=True, version=1, data=params) + + def futures_symbol_config(self, **params): + return self._request_futures_api('get', 'symbolConfig', signed=True, version=1, data=params) + # COIN Futures API def futures_coin_ping(self): """Test connectivity to the Rest API @@ -9947,9 +9954,9 @@ async def futures_cancel_orders(self, **params): async def futures_countdown_cancel_all(self, **params): return await self._request_futures_api('post', 'countdownCancelAll', True, data=params) - + async def futures_account_balance(self, **params): - return await self._request_futures_api('get', 'balance', True, version=2, data=params) + return await self._request_futures_api('get', 'balance', True, version=3, data=params) async def futures_account(self, **params): return await self._request_futures_api('get', 'account', True, version=2, data=params) @@ -10006,6 +10013,13 @@ async def futures_stream_close(self, listenKey): } return await self._request_futures_api('delete', 'listenKey', signed=False, data=params) + # new methods + async def futures_account_config(self, **params): + return await self._request_futures_api('get', 'accountConfig', signed=True, version=1, data=params) + + async def futures_symbol_config(self, **params): + return await self._request_futures_api('get', 'symbolConfig', signed=True, version=1, data=params) + # COIN Futures API async def futures_coin_ping(self): diff --git a/tests/test_futures.py b/tests/test_futures.py index 3ce52650..fc512bc1 100644 --- a/tests/test_futures.py +++ b/tests/test_futures.py @@ -24,3 +24,17 @@ def test_futures_position_information_version_override(): pos = client.futures_position_information(symbol="LTCUSDT", version=2) assert m.last_request.qs['symbol'][0] == 'LTCUSDT'.lower() assert m.last_request.path == '/fapi/v2/positionrisk' + +def test_futures_account_balance(): + with requests_mock.mock() as m: + url_matcher = re.compile(r"https:\/\/fapi.binance.com\/fapi\/v3\/balance\?.+") + m.register_uri("GET", url_matcher, json={}, status_code=200) + client.futures_account_balance() + assert m.last_request.path == '/fapi/v3/balance' + +def test_futures_account_config(): + with requests_mock.mock() as m: + url_matcher = re.compile(r"https:\/\/fapi.binance.com\/fapi\/v1\/accountConfig\?.+") + m.register_uri("GET", url_matcher, json={}, status_code=200) + client.futures_account_config() + assert m.last_request.path == '/fapi/v1/accountconfig' \ No newline at end of file