ccxt / ccxt

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
https://docs.ccxt.com
MIT License
31.91k stars 7.37k forks source link

error in ECS(VPS):ccxt.base.errors.ExchangeNotAvailable: binance GET https://api.binance.com/api/v3/exchangeInfo #22784

Closed DPZZxlz closed 3 weeks ago

DPZZxlz commented 3 weeks ago

Operating System

windows and ububtu

Programming Languages

Python

CCXT Version

4.3.38

Description

problem In ECS, I chose to install freqtrade directly (including installing C++ dependencies first) due to docker installation failures, set up the proxy(VPN,global-japan), and then tried to download the data: ccxt.base.errors.ExchangeNotAvailable: binance GET https://api.binance.com/api/v3/exchangeInfo 2024-06-11 17:17:12,810 - freqtrade - ERROR - Markets were not loaded.

C:\Users\Administrator\freqtrade\ft_userdata>freqtrade download-data --config user_data/config.json --exchange binance --timerange 20200101- -t  5m 15m 30m 1h
2024-06-11 17:14:47,713 - freqtrade - INFO - freqtrade 2024.6-dev-0d6109211
2024-06-11 17:14:47,713 - freqtrade.configuration.load_config - INFO - Using config: user_data/config.json ...
2024-06-11 17:14:47,713 - freqtrade.loggers - INFO - Verbosity set to 0
2024-06-11 17:14:47,713 - freqtrade.configuration.configuration - INFO - Parameter --timerange detected: 20200101- ...
2024-06-11 17:14:47,713 - freqtrade.configuration.configuration - INFO - Using exchange binance
2024-06-11 17:14:47,713 - freqtrade.configuration.configuration - INFO - Using user-data directory: C:\Users\Administrator\freqtrade\ft_userdata\user_data ...
2024-06-11 17:14:47,713 - freqtrade.configuration.configuration - INFO - Using data directory: C:\Users\Administrator\freqtrade\ft_userdata\user_data\data\binance ...
2024-06-11 17:14:47,713 - freqtrade.configuration.configuration - INFO - timeframes --timeframes: ['5m', '15m', '30m', '1h']
2024-06-11 17:14:47,713 - freqtrade.configuration.configuration - INFO - Filter trades by timerange: 20200101-
2024-06-11 17:14:47,728 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2024-06-11 17:14:47,745 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2024-06-11 17:14:47,745 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2024-06-11 17:14:47,745 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2024-06-11 17:14:47,745 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2024-06-11 17:14:47,745 - freqtrade.exchange.exchange - INFO - Using CCXT 4.3.38
2024-06-11 17:14:47,745 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'options': {'defaultType': 'swap'}, 'timeout': 30000}
2024-06-11 17:14:47,760 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'options': {'defaultType': 'swap'}, 'timeout': 30000}
2024-06-11 17:14:47,776 - freqtrade.exchange.exchange - INFO - Using Exchange "Binance"
2024-06-11 17:14:47,776 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Binance'...
2024-06-11 17:14:47,776 - freqtrade.exchange.exchange - INFO - Markets were not loaded. Loading them now..
2024-06-11 17:15:09,153 - freqtrade.exchange.exchange - ERROR - Could not load markets.
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiohttp\connector.py", line 1025, in _wrap_create_connection
  return await self._loop.create_connection(*args, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 1122, in create_connection
  raise exceptions[0]
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 1104, in create_connection
  sock = await self._connect_sock(
         ^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 1007, in _connect_sock
  await self.sock_connect(sock, address)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\proactor_events.py", line 729, in sock_connect
  return await self._proactor.connect(sock, address)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\windows_events.py", line 803, in _poll
  value = callback(transferred, key, ov)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\windows_events.py", line 599, in finish_connect
  ov.getresult()
OSError: [WinError 121] 信号灯超时时间已到

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\ccxt\async_support\base\exchange.py", line 199, in fetch
  async with session_method(yarl.URL(url, encoded=True),
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiohttp\client.py", line 1197, in __aenter__
  self._resp = await self._coro
               ^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiohttp\client.py", line 581, in _request
  conn = await self._connector.connect(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiohttp\connector.py", line 544, in connect
  proto = await self._create_connection(req, traces, timeout)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiohttp\connector.py", line 944, in _create_connection
  _, proto = await self._create_direct_connection(req, traces, timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiohttp\connector.py", line 1257, in _create_direct_connection
  raise last_exc
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiohttp\connector.py", line 1226, in _create_direct_connection
  transp, proto = await self._wrap_create_connection(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiohttp\connector.py", line 1033, in _wrap_create_connection
  raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.binance.com:443 ssl:default [信号灯超时时间已到]

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\Administrator\freqtrade\freqtrade\exchange\exchange.py", line 562, in reload_markets
  self._markets = self._load_async_markets(reload=True)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\freqtrade\freqtrade\exchange\exchange.py", line 535, in _load_async_markets
  markets = self.loop.run_until_complete(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
  return future.result()
         ^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\ccxt\async_support\base\exchange.py", line 276, in load_markets
  raise e
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\ccxt\async_support\base\exchange.py", line 272, in load_markets
  result = await self.markets_loading
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\ccxt\async_support\base\exchange.py", line 262, in load_markets_helper
  markets = await self.fetch_markets(params)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\ccxt\async_support\binance.py", line 2832, in fetch_markets
  promises = await asyncio.gather(*promisesRaw)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\ccxt\async_support\binance.py", line 10334, in request
  response = await self.fetch2(path, api, method, params, headers, body, config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\ccxt\async_support\base\exchange.py", line 829, in fetch2
  return await self.fetch(request['url'], request['method'], request['headers'], request['body'])
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\ccxt\async_support\base\exchange.py", line 237, in fetch
  raise ExchangeNotAvailable(details) from e
ccxt.base.errors.ExchangeNotAvailable: binance GET https://api.binance.com/api/v3/exchangeInfo
2024-06-11 17:17:12,810 - freqtrade - ERROR - Markets were not loaded.

when i try curl:

C:\Users\Administrator\freqtrade\ft_userdata>curl https://api.binance.com/api/v3/exchangeInfo
curl: (28) Failed to connect to api.binance.com port 443 after 21055 ms: Couldn't connect to server

then i try :

curl --proxy http://127.0.0.1:7890/ https://api.binance.com/api/v3/exchangeInfo

and i get the transaction data.

and i see #18799 but it didn`t help.So I guess the problem may be with the proxy, but I looked through the issues of ccxt and freqtrade and tried to set up the proxy, but it still failed.

ubuntu(in docker)

freqtrade    |     raise NetworkError(details) from e
freqtrade    | ccxt.base.errors.NetworkError: binance GET https://api.binance.com/api/v3/exchangeInfo
freqtrade    | 2024-06-09 13:49:55,045 - freqtrade - ERROR - Could not load markets, therefore cannot start. Please investigate the above error for more details.

Code

config.json

{
"max_open_trades": 6,
"stake_currency": "USDT",
"stake_amount": "unlimited",
"tradable_balance_ratio": 0.99,
"fiat_display_currency": "USD",
"dry_run": true,
"dry_run_wallet": 10000,
"cancel_open_orders_on_exit": false,
"trading_mode": "futures",
"margin_mode": "isolated",
"unfilledtimeout": {
"entry": 10,
"exit": 10,
"exit_timeout_count": 0,
"unit": "minutes"
},
"entry_pricing": {
"price_side": "same",
"use_order_book": true,
"order_book_top": 1,
"price_last_balance": 0.0,
"check_depth_of_market": {
"enabled": false,
"bids_to_ask_delta": 1
}
},
"exit_pricing":{
"price_side": "same",
"use_order_book": true,
"order_book_top": 1
},
"exchange": {
"name": "binance",
"key": "",
"secret": "",
"ccxt_config": {
        "httpsProxy": "http://127.0.0.1:7890"
        },
"ccxt_async_config": {},
"pair_whitelist": ["BTC/USDT:USDT", "ETH/USDT:USDT", "BNB/USDT:USDT","LINK/USDT:USDT","WLD/USDT:USDT","XRP/USDT:USDT","SOL/USDT:USDT","DOGE/USDT:USDT","AVAX/USDT:USDT","LTC/USDT:USDT","DOT/USDT:USDT","TRX/USDT:USDT","UNI/USDT:USDT"
],
"pair_blacklist": [
"BNB/.*"
]
},
DPZZxlz commented 3 weeks ago

open VPN TUN mode will help.