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