1

I have a problem running ccxt.load_markets() function in EC2 server but I check running is OK in local PC enviroment. Please me help for solution

Code and Error msg is as below.

python version : 3.7.15 CCXT version : 2.2.95

import ccxt
import time

b= ccxt.binance()

print(b.milliseconds())
print(b.nonce())
print(b.load_markets())

1671012133696 1671012133696 Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/ccxt/base/exchange.py", line 621, in fetch response.raise_for_status() File "/home/ec2-user/.local/lib/python3.7/site-packages/requests/models.py", line 953, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 451 Client Error: for url: https://api.binance.com/api/v3/exchangeInfo

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "test.py", line 15, in print(b.load_markets()) File "/usr/local/lib/python3.7/site-packages/ccxt/base/exchange.py", line 1448, in load_markets markets = self.fetch_markets(params) File "/usr/local/lib/python3.7/site-packages/ccxt/binance.py", line 1613, in fetch_markets response = getattr(self, method)(query) File "/usr/local/lib/python3.7/site-packages/ccxt/base/exchange.py", line 501, in inner return entry(_self, **inner_kwargs) File "/usr/local/lib/python3.7/site-packages/ccxt/binance.py", line 5854, in request response = self.fetch2(path, api, method, params, headers, body, config, context) File "/usr/local/lib/python3.7/site-packages/ccxt/base/exchange.py", line 2782, in fetch2 return self.fetch(request['url'], request['method'], request['headers'], request['body']) File "/usr/local/lib/python3.7/site-packages/ccxt/base/exchange.py", line 639, in fetch self.handle_http_status_code(http_status_code, http_status_text, url, method, http_response) File "/usr/local/lib/python3.7/site-packages/ccxt/base/exchange.py", line 1741, in handle_http_status_code raise ErrorClass(self.id + ' ' + method + ' ' + url + ' ' + codeAsString + ' ' + reason + ' ' + body) ccxt.base.errors.ExchangeNotAvailable: binance GET https://api.binance.com/api/v3/exchangeInfo 451 { "code": 0, "msg": "Service unavailable from a restricted location according to 'b. Eligibility' in https://www.binance.com/en/terms. Please contact customer service if you believe you received this message in error." }

zawoon
  • 11
  • 3

1 Answers1

3

You are getting this error because the request to binance server is being sent from a restricted location. Binance blacklists some locations due to policies and regulation. Since you are running on aws EC2 instance, it is most likely that your virtual server is located in a restricted location. Using VPN is also risky since binance server are able to identify most of them. The solution would be to rent a virtual server that exists from binance legible locations.

abeniOG
  • 51
  • 4