use lazy-evaluating form of logger (pylint W1202)

This commit is contained in:
Janne Sinivirta 2017-08-27 16:50:59 +03:00
parent 06d92042fd
commit 98f9d7cc21
3 changed files with 10 additions and 10 deletions

View File

@ -89,7 +89,7 @@ def get_buy_signal(pair):
return False
signal = latest['underpriced'] == 1
logger.debug('buy_trigger: {} (pair={}, signal={})'.format(latest['date'], pair, signal))
logger.debug('buy_trigger: %s (pair=%s, signal=%s)', latest['date'], pair, signal)
return signal

12
main.py
View File

@ -109,7 +109,7 @@ class TradeThread(threading.Thread):
trade.open_order_id = None
# Check if this trade can be marked as closed
if close_trade_if_fulfilled(trade):
logger.info('No open orders found and trade is fulfilled. Marking {} as closed ...'.format(trade))
logger.info('No open orders found and trade is fulfilled. Marking %s as closed ...', trade)
continue
# Check if we can sell our current pair
@ -144,7 +144,7 @@ def handle_trade(trade):
if not trade.is_open:
raise ValueError('attempt to handle closed trade: {}'.format(trade))
logger.debug('Handling open trade {} ...'.format(trade))
logger.debug('Handling open trade %s ...', trade)
# Get current rate
current_rate = api_wrapper.get_ticker(trade.pair)['bid']
current_profit = 100 * ((current_rate - trade.open_rate) / trade.open_rate)
@ -171,7 +171,7 @@ def handle_trade(trade):
TelegramHandler.send_msg(message)
return
else:
logger.debug('Threshold not reached. (cur_profit: {}%)'.format(round(current_profit, 2)))
logger.debug('Threshold not reached. (cur_profit: %1.2f%%)', current_profit)
except ValueError:
logger.exception('Unable to handle open order')
@ -182,7 +182,7 @@ def create_trade(stake_amount: float, exchange):
:param stake_amount: amount of btc to spend
:param exchange: exchange to use
"""
logger.info('Creating new trade with stake_amount: {} ...'.format(stake_amount))
logger.info('Creating new trade with stake_amount: %f ...', stake_amount)
whitelist = CONFIG[exchange.name.lower()]['pair_whitelist']
# Check if btc_amount is fulfilled
if api_wrapper.get_balance(CONFIG['stake_currency']) < stake_amount:
@ -196,7 +196,7 @@ def create_trade(stake_amount: float, exchange):
for trade in trades:
if trade.pair in whitelist:
whitelist.remove(trade.pair)
logger.debug('Ignoring {} in pair whitelist'.format(trade.pair))
logger.debug('Ignoring %s in pair whitelist', trade.pair)
if not whitelist:
raise ValueError('No pair in whitelist')
@ -231,7 +231,7 @@ def create_trade(stake_amount: float, exchange):
if __name__ == '__main__':
logger.info('Starting freqtrade {}'.format(__version__))
logger.info('Starting freqtrade %s', __version__)
TelegramHandler.listen()
while True:
time.sleep(0.5)

View File

@ -36,10 +36,10 @@ def authorized_only(command_handler):
chat_id = int(conf['telegram']['chat_id'])
if int(update.message.chat_id) == chat_id:
logger.info('Executing handler: {} for chat_id: {}'.format(command_handler.__name__, chat_id))
logger.info('Executing handler: %s for chat_id: %s', command_handler.__name__, chat_id)
return command_handler(*args, **kwargs)
else:
logger.info('Rejected unauthorized message from: {}'.format(update.message.chat_id))
logger.info('Rejected unauthorized message from: %s', update.message.chat_id)
return wrapper
@ -307,7 +307,7 @@ class TelegramHandler(object):
except NetworkError as error:
# Sometimes the telegram server resets the current connection,
# if this is the case we send the message again.
logger.warning('Got Telegram NetworkError: {}! trying one more time'.format(error.message))
logger.warning('Got Telegram NetworkError: %s! Trying one more time.', error.message)
bot.send_message(conf['telegram']['chat_id'], msg, parse_mode=parse_mode)
except Exception:
logger.exception('Exception occurred within Telegram API')