sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
6.01k stars 2.2k forks source link

client.futures_account_balance() problem (Solved) #1345

Open mahdial opened 1 year ago

mahdial commented 1 year ago

Describe the bug This is my code and before yesterday, it was ok, but now it give me this error : Error : packages binance client py line 6279 in futures_account_balance return self _request_futures_api get balance True

My code : for bal in client.futures_account_balance(): if bal['asset'] == 'USDT': usdtBalance = bal['balance']

Environment (please complete the following information):

Logs or Additional context Traceback most recent call last File marimacd py line 1394 in main for bal in client futures_account_balance File usr local lib python3 8 site packages binance client py line 6279 in futures_account_balance return self _request_futures_api get balance True data params File usr local lib python3 8 site packages binance client py line 382 in _request_futures_api return self _request method uri signed True kwargs File usr local lib python3 8 site packages binance client py line 358 in _request return self _handle_response self response File usr local lib python3 8 site packages binance client py line 367 in _handle_response raise BinanceAPIException response response status_code response text binance exceptions BinanceAPIException APIError code 0 Invalid JSON error message from Binance DOCTYPE html saved from url 0032 https www binance com en error html head meta http equiv Content Type content text html charset UTF 8 meta name format detection content telephone no email no address no title Binance title link rel Shortcut Icon href https www binance com en favicon ico style body margin 0 img width 611px margin 68px auto 0 info width 370px margin 0 auto text align center font family Arial info h3 margin 0 font size 25px color 333 font weight normal info p font size 14px font family Arial color 333 line height 18px margin 0 info button margin top 20px width 231px height 34px background FFFFFF border 1px solid F0B90B box sizing border box border radius 3px font size 14px line height 16px color F0B90B style head body div class img img alt src errorPages 404 jpg div div class info h3 å ºé å ï¼ æ è é ç ç½ é µä å å ã h3 p Sorry The page youâ re looking for cannot be found p a href https www binance com button Return to Binance home page button a div body html

TA2018b commented 1 year ago

Some v1 futures private endpoints are being deprecated. image

Looks like new pull request is already made to upgrade the endpoint to v2. Let's wait a bit for update. https://github.com/sammchardy/python-binance/pull/1342

mahdial commented 1 year ago

Thank you.

TA2018b commented 1 year ago

You can quickly access V2 API by using bare _request function with v2 url pointed. See below asynchronous positionRisk & account endpoint examples.

positionRisk endpoint

client = await AsyncClient.create(api_key="yourapikey", api_secret="yourapisecret")
response = await client._request(method='get', uri='https://fapi.binance.com/fapi/v2/positionRisk', signed=True, force_params=True, data={'symbol':'XRPUSDT'})
await client.close_connection()

account endpoint

client = await AsyncClient.create(api_key="yourapikey", api_secret="yourapisecret")
response = await client._request(method='get', uri='https://fapi.binance.com/fapi/v2/account', signed=True, force_params=True, data={})
await client.close_connection()
mahdial commented 1 year ago

Fortunately, a few hours ago, I updated the client.py file and everything got fixed. I have uploaded the new and updated file for you at the following address: https://livici.com/client.py.zip

tugrandemirel commented 1 year ago

The code I wrote was working until a few days ago. But it's not working right now. My mistake was in October. I haven't figured out how to solve this. Can you help me? Thanks in advance.

["<class 'Exception'>","brsBot.py","878","APIError(code=0): Invalid JSON error message from Binance: \n\n\n\n\n \n\n \n Binance\n \n \n\n\n\n

\n
\n

\u00e5\u0087\u00ba\u00e9\u0094\u0099\u00e5\u0095\u00a6\u00ef\u00bc\u0081\u00e6\u0082\u00a8\u00e8\u00ae\u00bf\u00e9\u0097\u00ae\u00e7\u009a\u0084\u00e7\u00bd\u0091\u00e9\u00a1\u00b5\u00e4\u00b8\u008d\u00e5\u00ad\u0098\u00e5\u009c\u00a8\u00e3\u0080\u0082\n Sorry! The page you\u00e2\u0080\u0099re looking for cannot be found.

\n \n Return to Binance home page\n \n
\n\n\n\n"]

mahdial commented 1 year ago

Merhaba Tugran. (Hi) Please write the code you have on lines 877 and 878 here, so we can assist you. You haven't provided any specific information for us to help with.