sammchardy / python-binance

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

APIError(code=0): Invalid JSON error message from Binance: #963

Open countblackjack opened 3 years ago

countblackjack commented 3 years ago

Note that this is my first python program and my first post on github. The code used to work fine, all of the sudden it doesnt work anymore. It could be due to the things that are going on with binance and options, just want to make sure that it is not something I overlooked.

Code used to run fine, now suddenly returns " APIError(code=0): Invalid JSON error message from Binance:"

To Reproduce

from binance.client import Client
from binance.exceptions import BinanceAPIException

import bin_config

client = Client(bin_config.apikey, bin_config.apiSecurity)

OptionsInfo = client.options_info()
for s in OptionsInfo['data']:
                instrument_name = client.options_order_book(symbol=s['symbol'])
                #print(s['symbol'])

Expected behavior Should return order book

Environment (please complete the following information):

Logs or Additional context binance.exceptions.BinanceAPIException: APIError(code=0): Invalid JSON error message from Binance: <!DOCTYPE html>

Binance
We’re sorry, but something went wrong. Go to Homepage
Binance desktop
A secure, fast and smooth trading experience.
Karlheinzniebuhr commented 2 years ago

I'm getting this error when sending

params={
        'symbol': SYMBOL_TO_TRADE,
        'side': tp_sl_side,
        'quantity': str(quantity),
        'price': str(tp_price),
        'stopPrice': str(tp_stop_price),
        'stopLimitPrice': str(sl_price),
        'stopLimitTimeInForce':'GTC',
        'isIsolated': isIsolated,
        'sideEffectType': 'MARGIN_BUY'
        }

oco_order = cls.client._post('margin/order/oco', True, data=params)

Did you find a solution?

harsh-sangwan commented 11 months ago

Traceback (most recent call last): File "/Users/harshdeep.sangwan/PycharmProjects/pythonProject1/binance futures.py", line 264, in y = client.futures_position_information(symbol=symbol) File "/opt/anaconda3/lib/python3.9/site-packages/binance/client.py", line 5417, in futures_position_information return self._request_futures_api('get', 'positionRisk', True, data=params) File "/opt/anaconda3/lib/python3.9/site-packages/binance/client.py", line 339, in _request_futures_api return self._request(method, uri, signed, True, **kwargs) File "/opt/anaconda3/lib/python3.9/site-packages/binance/client.py", line 315, in _request return self._handle_response(self.response) File "/opt/anaconda3/lib/python3.9/site-packages/binance/client.py", line 324, 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>

Binance

出错啦!您访问的网页不存在。

Sorry! The page you’re looking for cannot be found.

I'm getting this error

Acutapugione commented 8 months ago

.venv/lib/python3.10/site-packages/binance/client.py", line 368, in _handle_response raise BinanceAPIException(response, response.status_code, response.text) binance.exceptions.BinanceAPIException: APIError(code=0): Invalid JSON error message from Binance:

502 Bad Gateway

502 Bad Gateway


nginx