From b37149cf6fa311eb820d8921dabba48fb7d71177 Mon Sep 17 00:00:00 2001 From: gcarq Date: Mon, 22 May 2017 22:15:33 +0200 Subject: [PATCH] make conf validation more robust --- utils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index 7d00bff7a..304c55e1e 100644 --- a/utils.py +++ b/utils.py @@ -87,7 +87,15 @@ def validate_conf(conf): def validate_bittrex_pairs(pairs): - available_markets = [m['MarketName'].replace('-', '_')for m in Bittrex(None, None).get_markets()['result']] + """ + Validates if all given pairs exist on bittrex + :param pairs: list of str + :return: None + """ + data = Bittrex(None, None).get_markets() + if not data['success']: + raise RuntimeError('BITTREX: {}'.format(data['message'])) + available_markets = [m['MarketName'].replace('-', '_')for m in data['result']] for p in pairs: if p not in available_markets: - raise ValueError('Invalid pair: {}'.format(m)) + raise ValueError('Invalid pair: {}'.format(p))