From c45efa931c9f2e30c5fcb45f8ec346144026d058 Mon Sep 17 00:00:00 2001 From: avolution Date: Sun, 21 Oct 2018 22:43:16 +0100 Subject: [PATCH] ENH: Solution for #503 - pass parameters HTTP_PROXY and HTTPS_PROXY parameter for the ccxt connections --- catalyst/exchange/ccxt/ccxt_exchange.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/catalyst/exchange/ccxt/ccxt_exchange.py b/catalyst/exchange/ccxt/ccxt_exchange.py index 11aad4789..047dc0bad 100644 --- a/catalyst/exchange/ccxt/ccxt_exchange.py +++ b/catalyst/exchange/ccxt/ccxt_exchange.py @@ -64,11 +64,22 @@ def __init__(self, exchange_name, key, else: exchange_attr = getattr(ccxt, exchange_name) - self.api = exchange_attr({ + exchange_config = { 'apiKey': key, 'secret': secret, - 'password': password, - }) + 'password': password + } + + if('HTTP_PROXY' in os.environ or 'HTTPS_PROXY' in os.environ): + exchange_config['proxies'] = {} + + if('HTTP_PROXY' in os.environ): + exchange_config['proxies']['HTTP_PROXY'] = os.environ['HTTP_PROXY'] + + if ('HTTPS_PROXY' in os.environ): + exchange_config['proxies']['HTTPS_PROXY'] = os.environ['HTTPS_PROXY'] + + self.api = exchange_attr(exchange_config) self.api.enableRateLimit = True except Exception: