use lazy-evaluating form of logger (pylint W1202)
This commit is contained in:
parent
06d92042fd
commit
98f9d7cc21
@ -89,7 +89,7 @@ def get_buy_signal(pair):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
signal = latest['underpriced'] == 1
|
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
|
return signal
|
||||||
|
|
||||||
|
|
||||||
|
12
main.py
12
main.py
@ -109,7 +109,7 @@ class TradeThread(threading.Thread):
|
|||||||
trade.open_order_id = None
|
trade.open_order_id = None
|
||||||
# Check if this trade can be marked as closed
|
# Check if this trade can be marked as closed
|
||||||
if close_trade_if_fulfilled(trade):
|
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
|
continue
|
||||||
|
|
||||||
# Check if we can sell our current pair
|
# Check if we can sell our current pair
|
||||||
@ -144,7 +144,7 @@ def handle_trade(trade):
|
|||||||
if not trade.is_open:
|
if not trade.is_open:
|
||||||
raise ValueError('attempt to handle closed trade: {}'.format(trade))
|
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
|
# Get current rate
|
||||||
current_rate = api_wrapper.get_ticker(trade.pair)['bid']
|
current_rate = api_wrapper.get_ticker(trade.pair)['bid']
|
||||||
current_profit = 100 * ((current_rate - trade.open_rate) / trade.open_rate)
|
current_profit = 100 * ((current_rate - trade.open_rate) / trade.open_rate)
|
||||||
@ -171,7 +171,7 @@ def handle_trade(trade):
|
|||||||
TelegramHandler.send_msg(message)
|
TelegramHandler.send_msg(message)
|
||||||
return
|
return
|
||||||
else:
|
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:
|
except ValueError:
|
||||||
logger.exception('Unable to handle open order')
|
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 stake_amount: amount of btc to spend
|
||||||
:param exchange: exchange to use
|
: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']
|
whitelist = CONFIG[exchange.name.lower()]['pair_whitelist']
|
||||||
# Check if btc_amount is fulfilled
|
# Check if btc_amount is fulfilled
|
||||||
if api_wrapper.get_balance(CONFIG['stake_currency']) < stake_amount:
|
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:
|
for trade in trades:
|
||||||
if trade.pair in whitelist:
|
if trade.pair in whitelist:
|
||||||
whitelist.remove(trade.pair)
|
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:
|
if not whitelist:
|
||||||
raise ValueError('No pair in whitelist')
|
raise ValueError('No pair in whitelist')
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ def create_trade(stake_amount: float, exchange):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logger.info('Starting freqtrade {}'.format(__version__))
|
logger.info('Starting freqtrade %s', __version__)
|
||||||
TelegramHandler.listen()
|
TelegramHandler.listen()
|
||||||
while True:
|
while True:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
@ -36,10 +36,10 @@ def authorized_only(command_handler):
|
|||||||
|
|
||||||
chat_id = int(conf['telegram']['chat_id'])
|
chat_id = int(conf['telegram']['chat_id'])
|
||||||
if int(update.message.chat_id) == 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)
|
return command_handler(*args, **kwargs)
|
||||||
else:
|
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
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ class TelegramHandler(object):
|
|||||||
except NetworkError as error:
|
except NetworkError as error:
|
||||||
# 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('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)
|
bot.send_message(conf['telegram']['chat_id'], msg, parse_mode=parse_mode)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception('Exception occurred within Telegram API')
|
logger.exception('Exception occurred within Telegram API')
|
||||||
|
Loading…
Reference in New Issue
Block a user