check if result exists in get_ticker (fixes #106)
This commit is contained in:
parent
0bc96241d5
commit
d86dcc4752
@ -2,6 +2,7 @@ import logging
|
||||
from typing import List, Dict
|
||||
|
||||
from bittrex.bittrex import Bittrex as _Bittrex, API_V2_0, API_V1_1
|
||||
from requests.exceptions import ContentDecodingError
|
||||
|
||||
from freqtrade.exchange.interface import Exchange
|
||||
|
||||
@ -82,9 +83,13 @@ class Bittrex(Exchange):
|
||||
raise RuntimeError('{message} params=({pair})'.format(
|
||||
message=data['message'],
|
||||
pair=pair))
|
||||
if not data['result']['Bid'] or not data['result']['Ask'] or not data['result']['Last']:
|
||||
raise RuntimeError('{message} params=({pair})'.format(
|
||||
message=data['message'],
|
||||
|
||||
if not data.get('result') \
|
||||
or not data['result'].get('Bid') \
|
||||
or not data['result'].get('Ask') \
|
||||
or not data['result'].get('Last'):
|
||||
raise ContentDecodingError('{message} params=({pair})'.format(
|
||||
message='Got invalid response from bittrex',
|
||||
pair=pair))
|
||||
return {
|
||||
'bid': float(data['result']['Bid']),
|
||||
@ -104,13 +109,16 @@ class Bittrex(Exchange):
|
||||
|
||||
# These sanity check are necessary because bittrex cannot keep their API stable.
|
||||
if not data.get('result'):
|
||||
return []
|
||||
raise ContentDecodingError('{message} params=({pair})'.format(
|
||||
message='Got invalid response from bittrex',
|
||||
pair=pair))
|
||||
|
||||
for prop in ['C', 'V', 'O', 'H', 'L', 'T']:
|
||||
for tick in data['result']:
|
||||
if prop not in tick.keys():
|
||||
logger.warning('Required property %s not present in response', prop)
|
||||
return []
|
||||
raise ContentDecodingError('{message} params=({pair})'.format(
|
||||
message='Required property {} not present in response'.format(prop),
|
||||
pair=pair))
|
||||
|
||||
if not data['success']:
|
||||
raise RuntimeError('{message} params=({pair})'.format(
|
||||
|
@ -93,8 +93,10 @@ def _process(dynamic_whitelist: Optional[bool] = False) -> bool:
|
||||
|
||||
Trade.session.flush()
|
||||
except (requests.exceptions.RequestException, json.JSONDecodeError) as error:
|
||||
msg = 'Got {} in _process(), retrying in 30 seconds...'.format(error.__class__.__name__)
|
||||
logger.warning(msg)
|
||||
logger.warning(
|
||||
'Got %s in _process(), retrying in 30 seconds...',
|
||||
error
|
||||
)
|
||||
time.sleep(30)
|
||||
except RuntimeError:
|
||||
telegram.send_msg('*Status:* Got RuntimeError:\n```\n{traceback}```{hint}'.format(
|
||||
|
@ -1,9 +1,9 @@
|
||||
import argparse
|
||||
import enum
|
||||
import logging
|
||||
import time
|
||||
from typing import Any, Callable
|
||||
|
||||
import time
|
||||
from wrapt import synchronized
|
||||
|
||||
from freqtrade import __version__
|
||||
|
Loading…
Reference in New Issue
Block a user