Open ZENALC opened 3 years ago
Figured it out. You can directly do it from a private function like so:
self.binanceClient._request_margin_api('get', 'margin/isolated/account', True, data=params)
Hi~ I have tried your way to change function myself but got error msg:
KeyError Traceback (most recent call last)
<ipython-input-5-fb6f58ee1624> in <module>
----> 1 client._handle_response()
~/miniconda3/envs/jp/lib/python3.7/site-packages/binance/client.py in _handle_response(self)
228 """
229 if not str(self.response.status_code).startswith('2'):
--> 230 raise BinanceAPIException(self.response)
231 try:
232 return self.response.json()
~/miniconda3/envs/jp/lib/python3.7/site-packages/binance/exceptions.py in __init__(self, response)
11 self.message = 'Invalid JSON error message from Binance: {}'.format(response.text)
12 else:
---> 13 self.code = json_res['code']
14 self.message = json_res['msg']
15 self.status_code = response.status_code
KeyError: 'code'
Can you tell me how to solve this problem please~ Thank you!!!
ideally we would have an interface for the call. interested in creating a PR?
Hi~ I have tried your way to change function myself but got error msg:
KeyError Traceback (most recent call last) <ipython-input-5-fb6f58ee1624> in <module> ----> 1 client._handle_response() ~/miniconda3/envs/jp/lib/python3.7/site-packages/binance/client.py in _handle_response(self) 228 """ 229 if not str(self.response.status_code).startswith('2'): --> 230 raise BinanceAPIException(self.response) 231 try: 232 return self.response.json() ~/miniconda3/envs/jp/lib/python3.7/site-packages/binance/exceptions.py in __init__(self, response) 11 self.message = 'Invalid JSON error message from Binance: {}'.format(response.text) 12 else: ---> 13 self.code = json_res['code'] 14 self.message = json_res['msg'] 15 self.status_code = response.status_code KeyError: 'code'
Can you tell me how to solve this problem please~ Thank you!!!
Hey. Here is how I fixed it:
def get_isolated_margin_account(self, params) -> dict: """ Retrieves margin isolated account information. :param params: kwargs that normally go to binanceClient's request_margin_api function. :return: Margin isolated account information """ return self.binanceClient._request_margin_api('get', 'margin/isolated/account', True, data=params)
@ZENALC if you open up a PR, i can merge it in
looks like @xulngx beat me to it. #616
Describe the bug If you try to get your account's values for coins that are in the isolated-margin caps, you will receive an error. For example, if you try to get LUNA values, you will receive an error.
To Reproduce client.get_margin_asset(asset='LUNA')
Expected behavior You are supposed to get the amount of Luna owned and borrowed.
Environment (please complete the following information):
Logs or Additional context Binance announced new endpoints for this feature. These endpoints have not been added to the library.