Closed jaonewguy closed 6 years ago
There is an instance of a get_full_orderbook which is not catching ccxt.NetworkError, causing to bot to sometimes crash due to a cloudflare exception.
get_full_orderbook
ccxt.NetworkError
Stack trace:
2018-05-07 16:06:28.902 INFO [fcf_autotrageur.py:_execute_trade:149] **Dry run - end fake execution 2018-05-07 16:06:35.602 INFO [arbseeker.py:get_arb_opportunities_by_orderbook:79] gemini buy of 20000, ETH price: 748.9579564395475 2018-05-07 16:06:35.603 INFO [arbseeker.py:get_arb_opportunities_by_orderbook:82] bithumb buy of 20000, ETH price: 778.543900000078 2018-05-07 16:06:35.604 INFO [arbseeker.py:get_arb_opportunities_by_orderbook:85] gemini sell of 20000, ETH price: 747.3357488512611 2018-05-07 16:06:35.605 INFO [arbseeker.py:get_arb_opportunities_by_orderbook:88] bithumb sell of 20000, ETH price: 777.6148499999974 2018-05-07 16:06:35.606 INFO [arbseeker.py:get_arb_opportunities_by_orderbook:101] Ex2 (bithumb) sell Ex1 (gemini) buy spread: (3.82623527983883) 2018-05-07 16:06:35.607 INFO [arbseeker.py:get_arb_opportunities_by_orderbook:105] Ex2 (bithumb) buy Ex1 (gemini) sell spread: (4.175921089923418) 2018-05-07 16:06:35.608 INFO [fcf_autotrageur.py:_execute_trade:143] Subject: Arb Forward-Spread Alert! The spread of ETH is 3.82623527983883 2018-05-07 16:06:35.609 INFO [fcf_autotrageur.py:_is_within_tolerance:61] Previous spread of: 3.820407 Current spread of: 3.826235 spread tolerance of: 0.500000 2018-05-07 16:06:35.610 INFO [fcf_autotrageur.py:_execute_trade:147] **Dry run - begin fake execution Traceback (most recent call last): File "/home/pi/dev_rnd/Autotrageur/venv/lib/python3.6/site-packages/ccxt/base/exchange.py", line 356, in fetch response.raise_for_status() File "/home/pi/dev_rnd/Autotrageur/venv/lib/python3.6/site-packages/requests/models.py", line 935, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 525 Server Error: Origin SSL Handshake Error for url: https://api.bithumb.com/public/orderbook/ETH During handling of the above exception, another exception occurred: Traceback (most recent call last): File "run_autotrageur.py", line 24, in <module> autotrageur.run_autotrageur(arguments) File "/home/pi/dev_rnd/Autotrageur/bot/arbitrage/autotrageur.py", line 178, in run_autotrageur self._execute_trade() File "/home/pi/dev_rnd/Autotrageur/bot/arbitrage/fcf_autotrageur.py", line 148, in _execute_trade arbseeker.execute_arbitrage(self.spread_opp) File "/home/pi/dev_rnd/Autotrageur/bot/arbitrage/arbseeker.py", line 154, in execute_arbitrage bids = sell_trading_client.get_full_orderbook()[BIDS] File "/home/pi/dev_rnd/Autotrageur/bot/trader/ccxt_trader.py", line 272, in get_full_orderbook return self.fetcher.get_full_orderbook(self.base, self.quote) File "/home/pi/dev_rnd/Autotrageur/libs/trade/fetcher/ccxt_fetcher.py", line 113, in get_full_orderbook return self.exchange.fetch_order_book(base + "/" + quote) File "/home/pi/dev_rnd/Autotrageur/venv/lib/python3.6/site-packages/ccxt/bithumb.py", line 138, in fetch_order_book response = self.publicGetOrderbookCurrency(self.extend(request, params)) File "/home/pi/dev_rnd/Autotrageur/venv/lib/python3.6/site-packages/ccxt/bithumb.py", line 323, in request response = self.fetch2(path, api, method, params, headers, body) File "/home/pi/dev_rnd/Autotrageur/venv/lib/python3.6/site-packages/ccxt/base/exchange.py", line 295, in fetch2 return self.fetch(request['url'], request['method'], request['headers'], request['body']) File "/home/pi/dev_rnd/Autotrageur/venv/lib/python3.6/site-packages/ccxt/base/exchange.py", line 369, in fetch self.handle_rest_errors(e, response.status_code, self.last_http_response, url, method) File "/home/pi/dev_rnd/Autotrageur/venv/lib/python3.6/site-packages/ccxt/base/exchange.py", line 398, in handle_rest_errors self.raise_error(error, url, method, exception if exception else http_status_code, response) File "/home/pi/dev_rnd/Autotrageur/venv/lib/python3.6/site-packages/ccxt/base/exchange.py", line 280, in raise_error raise exception_type(output) ccxt.base.errors.ExchangeNotAvailable: bithumb https://api.bithumb.com/public/orderbook/ETH GET 525 Server Error: Origin SSL Handshake Error for url: https://api.bithumb.com/public/orderbook/ETH <!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]--> <!--[if IE 7]> <html class="no-js ie7 oldie" lang="en-US"> <![endif]--> <!--[if IE 8]> <html class="no-js ie8 oldie" lang="en-US"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]--> <head> <meta http-equiv="refresh" content="0"> <title>api.bithumb.com | 525: SSL handshake failed</title> <meta charset="UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /> <meta name="robots" content="noindex, nofollow" /> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" /> <link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" type="text/css" media="screen,projection" /> <!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" type="text/css" media="screen,projection" /><![endif]--> <style type="text/css">body{margin:0;padding:0}</style> </head> <body> <div id="cf-wrapper"> <div id="cf-error-details" class="cf-error-details-wrapper"> <div class="cf-wrapper cf-error-overview"> <h1> <span class="cf-error-type">Error</span> <span class="cf-error-code">525</span> <small class="heading-ray-id">Ray ID: 417078b589d879ff • 2018-05-07 03:06:36 UTC</small> </h1> <h2 class="cf-subheadline">SSL handshake failed</h2> </div><!-- /.error-overview --> <div class="cf-section cf-highlight cf-status-display"> <div class="cf-wrapper"> <div class="cf-columns cols-3"> <div id="cf-browser-status" class="cf-column cf-status-item cf-browser-status "> <div class="cf-icon-error-container"> <i class="cf-icon cf-icon-browser"></i> <i class="cf-icon-status cf-icon-ok"></i> </div> <span class="cf-status-desc">You</span> <h3 class="cf-status-name">Browser</h3> <span class="cf-status-label">Working</span> </div> <div id="cf-cloudflare-status" class="cf-column cf-status-item cf-cloudflare-status "> <div class="cf-icon-error-container"> <i class="cf-icon cf-icon-cloud"></i> <i class="cf-icon-status cf-icon-ok"></i> </div> <span class="cf-status-desc">Seattle</span> <h3 class="cf-status-name">Cloudflare</h3> <span class="cf-status-label">Working</span> </div> <div id="cf-host-status" class="cf-column cf-status-item cf-host-status cf-error-source"> <div class="cf-icon-error-container"> <i class="cf-icon cf-icon-server"></i> <i class="cf-icon-status cf-icon-error"></i> </div> <span class="cf-status-desc">api.bithumb.com</span> <h3 class="cf-status-name">Host</h3> <span class="cf-status-label">Error</span> </div> </div> </div> </div><!-- /.status-display --> <div class="cf-section cf-wrapper"> <div class="cf-columns two"> <div class="cf-column"> <h2>What happened?</h2> <p>Cloudflare is unable to establish an SSL connection to the origin server.</p> </div> <div class="cf-column"> <h2>What can I do?</h2> <h5>If you're a visitor of this website:</h5> <p>Please try again in a few minutes.</p> <h5>If you're the owner of this website:</h5> <p><span>It appears that the SSL configuration used is not compatible with Cloudflare. This could happen for a several reasons, including no shared cipher suites.</span> <a href="https://support.cloudflare.com/hc/en-us/articles/200278659">Additional troubleshooting information here.</a></p> </div> </div> </div><!-- /.section --> <div class="cf-error-footer cf-wrapper"> <p> <span class="cf-footer-item">Cloudflare Ray ID: <strong>417078b589d879ff</strong></span> <span class="cf-footer-separator">•</span> <span class="cf-footer-item"><span>Your IP</span>: 75.157.140.200</span> <span class="cf-footer-separator">•</span> <span class="cf-footer-item"><span>Performance & security by</span> <a href="https://www.cloudflare.com/5xx-error-landing?utm_source=error_footer" id="brand_link" target="_blank">Cloudflare</a></span> </p> </div><!-- /.error-footer --> </div><!-- /#cf-error-details --> </div><!-- /#cf-wrapper --> </body> </html>
This will be addressed in fcf_autotrageur testing as we just need to change _execute_trade to catch NetworkError instead of RequestTimeout like _poll_opportunity does
_execute_trade
_poll_opportunity
Part of #46 review
There is an instance of a
get_full_orderbook
which is not catchingccxt.NetworkError
, causing to bot to sometimes crash due to a cloudflare exception.Stack trace: