Closed ruidazeng closed 2 weeks ago
It seems like this program does not work in the United States since Binance dot com is restricted in the US.
Yes, it only works when the exchange is reachable
@Herklos Do we have alternative exchange available we can use?
@Herklos Do we have alternative exchange available we can use?
You can use Kucoin, Binance US and many others. You should check this page https://www.octobot.cloud/tools/triangular-arbitrage-crypto. It contains multiple signals on different exchanges
@Herklos Do we have alternative exchange available we can use?
You can use Kucoin, Binance US and many others. You should check this page https://www.octobot.cloud/tools/triangular-arbitrage-crypto. It contains multiple signals on different exchanges
Thanks for the advice. I will try to see if I can get the code to work on alternative exchanges that work in the USA as well.
me@My-Laptop Triangular-Arbitrage % python3 main.py
best_opportunities, best_profit = asyncio.run(detector.run_detection(exchange_name))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/me/Documents/Triangular-Arbitrage/triangular_arbitrage/detector.py", line 105, in run_detection
last_prices = await get_exchange_last_prices(exchange_name, ignored_symbols or [], whitelisted_symbols)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/me/Documents/Triangular-Arbitrage/triangular_arbitrage/detector.py", line 99, in get_exchange_last_prices
tickers, exchange_time = await get_exchange_data(exchange_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/me/Documents/Triangular-Arbitrage/triangular_arbitrage/detector.py", line 92, in get_exchange_data
tickers = await fetch_tickers(exchange)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/me/Documents/Triangular-Arbitrage/triangular_arbitrage/detector.py", line 20, in fetch_tickers
return await exchange.fetch_tickers() if exchange.has['fetchTickers'] else []
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/ccxt/async_support/binance.py", line 4068, in fetch_tickers
await self.load_markets()
File "/opt/homebrew/lib/python3.12/site-packages/ccxt/async_support/base/exchange.py", line 287, in load_markets
raise e
File "/opt/homebrew/lib/python3.12/site-packages/ccxt/async_support/base/exchange.py", line 283, in load_markets
result = await self.markets_loading
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/ccxt/async_support/base/exchange.py", line 273, in load_markets_helper
markets = await self.fetch_markets(params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/ccxt/async_support/binance.py", line 2877, in fetch_markets
results = await asyncio.gather(*promisesRaw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/ccxt/async_support/binance.py", line 10764, in request
response = await self.fetch2(path, api, method, params, headers, body, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/ccxt/async_support/base/exchange.py", line 855, in fetch2
raise e
File "/opt/homebrew/lib/python3.12/site-packages/ccxt/async_support/base/exchange.py", line 846, in fetch2
return await self.fetch(request['url'], request['method'], request['headers'], request['body'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/ccxt/async_support/base/exchange.py", line 255, in fetch
self.handle_http_status_code(http_status_code, http_status_text, url, method, http_response)
File "/opt/homebrew/lib/python3.12/site-packages/ccxt/base/exchange.py", line 1679, 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."
}
binance requires to release all resources with an explicit call to the .close() coroutine. If you are using the exchange instance with async coroutines, add
Scanning... Traceback (most recent call last): File "/Users/me/Documents/Triangular-Arbitrage/main.py", line 18, in
await exchange.close()
to your code into a place when you're done with the exchange and don't need the exchange instance anymore (at the end of your async coroutine). Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x107236c90>, 342710.190403125)]'] connector: <aiohttp.connector.TCPConnector object at 0x1061724b0>