Skip to content

Commit

Permalink
add missing methods
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmiei committed Oct 21, 2024
1 parent dd3a1d3 commit 2b2873f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
22 changes: 18 additions & 4 deletions binance/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
14 changes: 14 additions & 0 deletions tests/test_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit 2b2873f

Please sign in to comment.