validate if bittrex pairs are valid
This commit is contained in:
parent
8c3f20ce52
commit
9200ebb48a
14
utils.py
14
utils.py
@ -2,6 +2,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from wrapt import synchronized
|
from wrapt import synchronized
|
||||||
|
from bittrex.bittrex import Bittrex
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -61,8 +62,9 @@ def validate_conf(conf):
|
|||||||
if not isinstance(poloniex.get('pair_whitelist'), list):
|
if not isinstance(poloniex.get('pair_whitelist'), list):
|
||||||
raise ValueError('poloniex.pair_whitelist must be a list')
|
raise ValueError('poloniex.pair_whitelist must be a list')
|
||||||
if poloniex.get('enabled', False):
|
if poloniex.get('enabled', False):
|
||||||
if not poloniex.get('pair_whitelist'):
|
raise ValueError('poloniex is currently not implemented')
|
||||||
raise ValueError('poloniex.pair_whitelist must contain some pairs')
|
#if not poloniex.get('pair_whitelist'):
|
||||||
|
# raise ValueError('poloniex.pair_whitelist must contain some pairs')
|
||||||
|
|
||||||
if conf.get('bittrex'):
|
if conf.get('bittrex'):
|
||||||
bittrex = conf.get('bittrex')
|
bittrex = conf.get('bittrex')
|
||||||
@ -75,9 +77,17 @@ def validate_conf(conf):
|
|||||||
if bittrex.get('enabled', False):
|
if bittrex.get('enabled', False):
|
||||||
if not bittrex.get('pair_whitelist'):
|
if not bittrex.get('pair_whitelist'):
|
||||||
raise ValueError('bittrex.pair_whitelist must contain some pairs')
|
raise ValueError('bittrex.pair_whitelist must contain some pairs')
|
||||||
|
validate_bittrex_pairs(bittrex.get('pair_whitelist'))
|
||||||
|
|
||||||
if conf.get('poloniex', {}).get('enabled', False) \
|
if conf.get('poloniex', {}).get('enabled', False) \
|
||||||
and conf.get('bittrex', {}).get('enabled', False):
|
and conf.get('bittrex', {}).get('enabled', False):
|
||||||
raise ValueError('Cannot use poloniex and bittrex at the same time')
|
raise ValueError('Cannot use poloniex and bittrex at the same time')
|
||||||
|
|
||||||
logger.info('Config is valid ...')
|
logger.info('Config is valid ...')
|
||||||
|
|
||||||
|
|
||||||
|
def validate_bittrex_pairs(pairs):
|
||||||
|
available_markets = [m['MarketName'].replace('-', '_')for m in Bittrex(None, None).get_markets()['result']]
|
||||||
|
for p in pairs:
|
||||||
|
if p not in available_markets:
|
||||||
|
raise ValueError('Invalid pair: {}'.format(m))
|
||||||
|
Loading…
Reference in New Issue
Block a user