X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=ccxt_wrapper.py;h=d2c9b4ce26550b0074f6632ddc2bdc972eb17bd2;hb=18de421e455ab4b125a6684d703a296562097e6b;hp=260d49dccbe2a2221b79fe8c36be70d940a24ab3;hpb=b03f2a307dfdaafc1597035ef669b14da0d55f77;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git diff --git a/ccxt_wrapper.py b/ccxt_wrapper.py index 260d49d..d2c9b4c 100644 --- a/ccxt_wrapper.py +++ b/ccxt_wrapper.py @@ -3,6 +3,8 @@ import decimal import time from retry.api import retry_call import re +from requests.exceptions import RequestException +from ssl import SSLError def _cw_exchange_sum(self, *args): return sum([arg for arg in args if isinstance(arg, (float, int, decimal.Decimal))]) @@ -45,10 +47,18 @@ class poloniexE(poloniex): self.session._parent = self def request_wrap(self, *args, **kwargs): - r = self.origin_request(*args, **kwargs) - self._parent._market.report.log_http_request(args[0], - args[1], kwargs["data"], kwargs["headers"], r) - return r + kwargs["headers"]["X-market-id"] = str(self._parent._market.market_id) + kwargs["headers"]["X-user-id"] = str(self._parent._market.user_id) + try: + r = self.origin_request(*args, **kwargs) + self._parent._market.report.log_http_request(args[0], + args[1], kwargs["data"], kwargs["headers"], r) + return r + except (SSLError, RequestException) as e: + self._parent._market.report.log_http_request(args[0], + args[1], kwargs["data"], kwargs["headers"], e) + raise e + self.session.request = request_wrap.__get__(self.session, self.session.__class__) @@ -381,4 +391,14 @@ class poloniexE(poloniex): else: raise NotImplementedError + def common_currency_code(self, currency): + """ + Wrapped to avoid the currency translation + """ + return currency + def currency_id(self, currency): + """ + Wrapped to avoid the currency translation + """ + return currency