From 06e7f379b39087134ed8c756eb28a700668b23a0 Mon Sep 17 00:00:00 2001 From: raphael Date: Fri, 23 Jul 2021 16:32:30 -0400 Subject: [PATCH 1/2] Fix code to get Bittrex US-restricted markets Old code was no longer working --- docs/exchanges.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/exchanges.md b/docs/exchanges.md index e54f97714..72f5e4ba4 100644 --- a/docs/exchanges.md +++ b/docs/exchanges.md @@ -77,8 +77,8 @@ You can get a list of restricted markets by using the following snippet: ``` python import ccxt ct = ccxt.bittrex() -_ = ct.load_markets() -res = [ f"{x['MarketCurrency']}/{x['BaseCurrency']}" for x in ct.publicGetMarkets()['result'] if x['IsRestricted']] +ct.load_markets() +res = [f"{x['quoteCurrencySymbol']}/{x['baseCurrencySymbol']}" for x in ct.publicGetMarkets() if 'US' in x['prohibitedIn']] print(res) ``` From cf4d1875dd2f34c74f64fa416b23aa4804cc1a6c Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 29 Jul 2021 06:56:37 +0200 Subject: [PATCH 2/2] Use prohibitedIn instead of isRestricted --- docs/exchanges.md | 5 +++-- freqtrade/exchange/exchange.py | 2 +- tests/exchange/test_exchange.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/exchanges.md b/docs/exchanges.md index 72f5e4ba4..29b9bb533 100644 --- a/docs/exchanges.md +++ b/docs/exchanges.md @@ -77,8 +77,9 @@ You can get a list of restricted markets by using the following snippet: ``` python import ccxt ct = ccxt.bittrex() -ct.load_markets() -res = [f"{x['quoteCurrencySymbol']}/{x['baseCurrencySymbol']}" for x in ct.publicGetMarkets() if 'US' in x['prohibitedIn']] +lm = ct.load_markets() + +res = [p for p, x in lm.items() if 'US' in x['info']['prohibitedIn']] print(res) ``` diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 91b278077..47ce8b4ba 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -387,7 +387,7 @@ class Exchange: # its contents depend on the exchange. # It can also be a string or similar ... so we need to verify that first. elif (isinstance(self.markets[pair].get('info', None), dict) - and self.markets[pair].get('info', {}).get('IsRestricted', False)): + and self.markets[pair].get('info', {}).get('prohibitedIn', False)): # Warn users about restricted pairs in whitelist. # We cannot determine reliably if Users are affected. logger.warning(f"Pair {pair} is restricted for some users on this exchange." diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 02adf01c4..bf77a9460 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -673,7 +673,7 @@ def test_validate_pairs_restricted(default_conf, mocker, caplog): api_mock = MagicMock() type(api_mock).load_markets = MagicMock(return_value={ 'ETH/BTC': {'quote': 'BTC'}, 'LTC/BTC': {'quote': 'BTC'}, - 'XRP/BTC': {'quote': 'BTC', 'info': {'IsRestricted': True}}, + 'XRP/BTC': {'quote': 'BTC', 'info': {'prohibitedIn': ['US']}}, 'NEO/BTC': {'quote': 'BTC', 'info': 'TestString'}, # info can also be a string ... }) mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock))