improving log messages
This commit is contained in:
parent
5e73f3431c
commit
160af91f9a
@ -52,7 +52,7 @@ class Bittrex(Exchange):
|
|||||||
'MIN_TRADE_REQUIREMENT_NOT_MET',
|
'MIN_TRADE_REQUIREMENT_NOT_MET',
|
||||||
]
|
]
|
||||||
if response['message'] in temp_error_messages:
|
if response['message'] in temp_error_messages:
|
||||||
raise ContentDecodingError('Got {}'.format(response['message']))
|
raise ContentDecodingError(response['message'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fee(self) -> float:
|
def fee(self) -> float:
|
||||||
@ -110,7 +110,7 @@ class Bittrex(Exchange):
|
|||||||
not all(key in data.get('result', {}) for key in keys) or\
|
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):
|
not all(data.get('result', {})[key] is not None for key in keys):
|
||||||
raise ContentDecodingError('{message} params=({pair})'.format(
|
raise ContentDecodingError('{message} params=({pair})'.format(
|
||||||
message='Got invalid response from bittrex',
|
message='Invalid response from Bittrex',
|
||||||
pair=pair))
|
pair=pair))
|
||||||
# Update the pair
|
# Update the pair
|
||||||
self.cached_ticker[pair] = {
|
self.cached_ticker[pair] = {
|
||||||
@ -132,14 +132,14 @@ class Bittrex(Exchange):
|
|||||||
elif tick_interval == 1440:
|
elif tick_interval == 1440:
|
||||||
interval = 'Day'
|
interval = 'Day'
|
||||||
else:
|
else:
|
||||||
raise ValueError('Cannot parse tick_interval: {}'.format(tick_interval))
|
raise ValueError('Unknown tick_interval: {}'.format(tick_interval))
|
||||||
|
|
||||||
data = _API_V2.get_candles(pair.replace('_', '-'), interval)
|
data = _API_V2.get_candles(pair.replace('_', '-'), interval)
|
||||||
|
|
||||||
# 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'):
|
||||||
raise ContentDecodingError('{message} params=({pair})'.format(
|
raise ContentDecodingError('{message} params=({pair})'.format(
|
||||||
message='Got invalid response from bittrex',
|
message='Invalid response from Bittrex',
|
||||||
pair=pair))
|
pair=pair))
|
||||||
|
|
||||||
for prop in ['C', 'V', 'O', 'H', 'L', 'T']:
|
for prop in ['C', 'V', 'O', 'H', 'L', 'T']:
|
||||||
|
@ -65,10 +65,7 @@ def process_maybe_execute_buy(interval: int) -> bool:
|
|||||||
if create_trade(float(_CONF['stake_amount']), interval):
|
if create_trade(float(_CONF['stake_amount']), interval):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
logger.info(
|
logger.info('Found no buy signals for whitelisted currencies. Trying again..')
|
||||||
'Checked all whitelisted currencies. '
|
|
||||||
'Found no suitable entry positions for buying. Will keep looking ...'
|
|
||||||
)
|
|
||||||
return False
|
return False
|
||||||
except DependencyException as exception:
|
except DependencyException as exception:
|
||||||
logger.warning('Unable to create trade: %s', exception)
|
logger.warning('Unable to create trade: %s', exception)
|
||||||
@ -83,7 +80,7 @@ def process_maybe_execute_sell(trade: Trade, interval: int) -> bool:
|
|||||||
# Get order details for actual price per unit
|
# Get order details for actual price per unit
|
||||||
if trade.open_order_id:
|
if trade.open_order_id:
|
||||||
# Update trade with order values
|
# Update trade with order values
|
||||||
logger.info('Got open order for %s', trade)
|
logger.info('Found open order for %s', trade)
|
||||||
trade.update(exchange.get_order(trade.open_order_id))
|
trade.update(exchange.get_order(trade.open_order_id))
|
||||||
|
|
||||||
if trade.is_open and trade.open_order_id is None:
|
if trade.is_open and trade.open_order_id is None:
|
||||||
@ -130,16 +127,16 @@ def _process(interval: int, nb_assets: Optional[int] = 0) -> bool:
|
|||||||
|
|
||||||
except (requests.exceptions.RequestException, json.JSONDecodeError) as error:
|
except (requests.exceptions.RequestException, json.JSONDecodeError) as error:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
'Got %s in _process(), retrying in 30 seconds...',
|
'%s in _process(), retrying in 30 seconds...',
|
||||||
error
|
error
|
||||||
)
|
)
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
except OperationalException:
|
except OperationalException:
|
||||||
rpc.send_msg('*Status:* Got OperationalException:\n```\n{traceback}```{hint}'.format(
|
rpc.send_msg('*Status:* OperationalException:\n```\n{traceback}```{hint}'.format(
|
||||||
traceback=traceback.format_exc(),
|
traceback=traceback.format_exc(),
|
||||||
hint='Issue `/start` if you think it is safe to restart.'
|
hint='Issue `/start` if you think it is safe to restart.'
|
||||||
))
|
))
|
||||||
logger.exception('Got OperationalException. Stopping trader ...')
|
logger.exception('OperationalException. Stopping trader ...')
|
||||||
update_state(State.STOPPED)
|
update_state(State.STOPPED)
|
||||||
return state_changed
|
return state_changed
|
||||||
|
|
||||||
@ -558,9 +555,9 @@ def main(sysargv=sys.argv[1:]) -> int:
|
|||||||
)
|
)
|
||||||
old_state = new_state
|
old_state = new_state
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logger.info('Got SIGINT, aborting ...')
|
logger.info('SIGINT received, aborting ...')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
logger.exception('Got fatal exception!')
|
logger.exception('Fatal exception!')
|
||||||
finally:
|
finally:
|
||||||
cleanup()
|
cleanup()
|
||||||
return 0
|
return 0
|
||||||
|
@ -425,7 +425,7 @@ def send_msg(msg: str, bot: Bot = None, parse_mode: ParseMode = ParseMode.MARKDO
|
|||||||
# Sometimes the telegram server resets the current connection,
|
# Sometimes the telegram server resets the current connection,
|
||||||
# if this is the case we send the message again.
|
# if this is the case we send the message again.
|
||||||
logger.warning(
|
logger.warning(
|
||||||
'Got Telegram NetworkError: %s! Trying one more time.',
|
'Telegram NetworkError: %s! Trying one more time.',
|
||||||
network_err.message
|
network_err.message
|
||||||
)
|
)
|
||||||
bot.send_message(
|
bot.send_message(
|
||||||
@ -433,4 +433,4 @@ def send_msg(msg: str, bot: Bot = None, parse_mode: ParseMode = ParseMode.MARKDO
|
|||||||
parse_mode=parse_mode, reply_markup=reply_markup
|
parse_mode=parse_mode, reply_markup=reply_markup
|
||||||
)
|
)
|
||||||
except TelegramError as telegram_err:
|
except TelegramError as telegram_err:
|
||||||
logger.warning('Got TelegramError: %s! Giving up on that message.', telegram_err.message)
|
logger.warning('TelegramError: %s! Giving up on that message.', telegram_err.message)
|
||||||
|
@ -211,14 +211,14 @@ def test_exchange_bittrex_get_ticker_bad():
|
|||||||
fb = FakeBittrex()
|
fb = FakeBittrex()
|
||||||
fb.result = {'success': True, 'result': {'Bid': 1, 'Ask': 0}} # incomplete result
|
fb.result = {'success': True, 'result': {'Bid': 1, 'Ask': 0}} # incomplete result
|
||||||
|
|
||||||
with pytest.raises(ContentDecodingError, match=r'.*Got invalid response from bittrex params.*'):
|
with pytest.raises(ContentDecodingError, match=r'.*Invalid response from Bittrex params.*'):
|
||||||
wb.get_ticker('BTC_ETH')
|
wb.get_ticker('BTC_ETH')
|
||||||
fb.result = {'success': False, 'message': 'gone bad'}
|
fb.result = {'success': False, 'message': 'gone bad'}
|
||||||
with pytest.raises(btx.OperationalException, match=r'.*gone bad.*'):
|
with pytest.raises(btx.OperationalException, match=r'.*gone bad.*'):
|
||||||
wb.get_ticker('BTC_ETH')
|
wb.get_ticker('BTC_ETH')
|
||||||
|
|
||||||
fb.result = {'success': True, 'result': {}} # incomplete result
|
fb.result = {'success': True, 'result': {}} # incomplete result
|
||||||
with pytest.raises(ContentDecodingError, match=r'.*Got invalid response from bittrex params.*'):
|
with pytest.raises(ContentDecodingError, match=r'.*Invalid response from Bittrex params.*'):
|
||||||
wb.get_ticker('BTC_ETH')
|
wb.get_ticker('BTC_ETH')
|
||||||
fb.result = {'success': False, 'message': 'gone bad'}
|
fb.result = {'success': False, 'message': 'gone bad'}
|
||||||
with pytest.raises(btx.OperationalException, match=r'.*gone bad.*'):
|
with pytest.raises(btx.OperationalException, match=r'.*gone bad.*'):
|
||||||
@ -226,7 +226,7 @@ def test_exchange_bittrex_get_ticker_bad():
|
|||||||
|
|
||||||
fb.result = {'success': True,
|
fb.result = {'success': True,
|
||||||
'result': {'Bid': 1, 'Ask': 0, 'Last': None}} # incomplete result
|
'result': {'Bid': 1, 'Ask': 0, 'Last': None}} # incomplete result
|
||||||
with pytest.raises(ContentDecodingError, match=r'.*Got invalid response from bittrex params.*'):
|
with pytest.raises(ContentDecodingError, match=r'.*Invalid response from Bittrex params.*'):
|
||||||
wb.get_ticker('BTC_ETH')
|
wb.get_ticker('BTC_ETH')
|
||||||
|
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ def test_exchange_bittrex_get_ticker_history():
|
|||||||
wb = make_wrap_bittrex()
|
wb = make_wrap_bittrex()
|
||||||
fb = FakeBittrex()
|
fb = FakeBittrex()
|
||||||
assert wb.get_ticker_history('BTC_ETH', 5)
|
assert wb.get_ticker_history('BTC_ETH', 5)
|
||||||
with pytest.raises(ValueError, match=r'.*Cannot parse tick_interval.*'):
|
with pytest.raises(ValueError, match=r'.*Unknown tick_interval.*'):
|
||||||
wb.get_ticker_history('BTC_ETH', 2)
|
wb.get_ticker_history('BTC_ETH', 2)
|
||||||
|
|
||||||
fb.success = False
|
fb.success = False
|
||||||
@ -250,7 +250,7 @@ def test_exchange_bittrex_get_ticker_history():
|
|||||||
wb.get_ticker_history('BTC_ETH', 5)
|
wb.get_ticker_history('BTC_ETH', 5)
|
||||||
|
|
||||||
fb.success = True
|
fb.success = True
|
||||||
with pytest.raises(ContentDecodingError, match=r'.*Got invalid response from bittrex.*'):
|
with pytest.raises(ContentDecodingError, match=r'.*Invalid response from Bittrex.*'):
|
||||||
fb.result = {'bad': 0}
|
fb.result = {'bad': 0}
|
||||||
wb.get_ticker_history('BTC_ETH', 5)
|
wb.get_ticker_history('BTC_ETH', 5)
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ def test_get_signal_old_dataframe(default_conf, mocker, caplog):
|
|||||||
ticks = DataFrame([{'buy': 1, 'date': oldtime}])
|
ticks = DataFrame([{'buy': 1, 'date': oldtime}])
|
||||||
mocker.patch('freqtrade.analyze.analyze_ticker', return_value=DataFrame(ticks))
|
mocker.patch('freqtrade.analyze.analyze_ticker', return_value=DataFrame(ticks))
|
||||||
assert (False, False) == get_signal('xyz', int(default_conf['ticker_interval']))
|
assert (False, False) == get_signal('xyz', int(default_conf['ticker_interval']))
|
||||||
assert tt.log_has('Too old dataframe for pair xyz',
|
assert tt.log_has('Too old dataframe for pair xyz. Last ticker is 11 minutes old',
|
||||||
caplog.record_tuples)
|
caplog.record_tuples)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user