make conf validation more robust

This commit is contained in:
gcarq 2017-05-22 22:15:33 +02:00
parent 9200ebb48a
commit b37149cf6f
1 changed files with 10 additions and 2 deletions

View File

@ -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))