Merge pull request #411 from jblestang/fixing_crappy_ticker_data_handling
fixing handling of data fetched from Bittrex server with bad content in the ticker
This commit is contained in:
commit
52d881e3f9
@ -122,9 +122,10 @@ class Bittrex(Exchange):
|
||||
raise OperationalException('{message} params=({pair})'.format(
|
||||
message=data['message'],
|
||||
pair=pair))
|
||||
|
||||
keys = ['Bid', 'Ask', 'Last']
|
||||
if not data.get('result') or\
|
||||
not all(key in data.get('result', {}) for key in ['Bid', 'Ask', 'Last']):
|
||||
not all(key in data.get('result', {}) for key in keys) or\
|
||||
not all(data.get('result', {})[key] is not None for key in keys):
|
||||
raise ContentDecodingError('{message} params=({pair})'.format(
|
||||
message='Got invalid response from bittrex',
|
||||
pair=pair))
|
||||
|
@ -232,6 +232,11 @@ def test_exchange_bittrex_get_ticker_bad():
|
||||
with pytest.raises(btx.OperationalException, match=r'.*gone bad.*'):
|
||||
wb.get_ticker('BTC_ETH')
|
||||
|
||||
fb.result = {'success': True,
|
||||
'result': {'Bid': 1, 'Ask': 0, 'Last': None}} # incomplete result
|
||||
with pytest.raises(ContentDecodingError, match=r'.*Got invalid response from bittrex params.*'):
|
||||
wb.get_ticker('BTC_ETH')
|
||||
|
||||
|
||||
def test_exchange_bittrex_get_ticker_history_one():
|
||||
wb = make_wrap_bittrex()
|
||||
|
Loading…
Reference in New Issue
Block a user