freqtradebot,main,hyperopt: fstrings in use

This commit is contained in:
Samuel Husso 2018-06-14 08:52:13 +03:00
parent 03c112a601
commit 7dca3c6d03
3 changed files with 18 additions and 25 deletions

View File

@ -626,12 +626,8 @@ with limit `{buy_limit:.8f} ({stake_amount:.6f} \
# Because telegram._forcesell does not have the configuration # Because telegram._forcesell does not have the configuration
# Ignore the FIAT value and does not show the stake_currency as well # Ignore the FIAT value and does not show the stake_currency as well
else: else:
message += '` ({gain}: {profit_percent:.2f}%, {profit_coin:.8f})`'.format( gain = "profit" if fmt_exp_profit > 0 else "loss"
gain="profit" if fmt_exp_profit > 0 else "loss", message += f'` ({gain}: {fmt_exp_profit:.2f}%, {profit_trade:.8f})`'
profit_percent=fmt_exp_profit,
profit_coin=profit_trade
)
# Send the message # Send the message
self.rpc.send_msg(message) self.rpc.send_msg(message)
Trade.session.flush() Trade.session.flush()

View File

@ -74,10 +74,7 @@ def reconfigure(freqtrade: FreqtradeBot, args: Namespace) -> FreqtradeBot:
# Create new instance # Create new instance
freqtrade = FreqtradeBot(Configuration(args).get_config()) freqtrade = FreqtradeBot(Configuration(args).get_config())
freqtrade.rpc.send_msg( freqtrade.rpc.send_msg(
'*Status:* `Config reloaded ...`'.format( '*Status:* `Config reloaded {freqtrade.state.name.lower()}...`')
freqtrade.state.name.lower()
)
)
return freqtrade return freqtrade

View File

@ -128,13 +128,12 @@ class Hyperopt(Backtesting):
Log results if it is better than any previous evaluation Log results if it is better than any previous evaluation
""" """
if results['loss'] < self.current_best_loss: if results['loss'] < self.current_best_loss:
current = results['current_tries']
total = results['total_tries']
res = results['result']
loss = results['loss']
self.current_best_loss = results['loss'] self.current_best_loss = results['loss']
log_msg = '\n{:5d}/{}: {}. Loss {:.5f}'.format( log_msg = f'\n{current:5d}/{total}: {res}. Loss {loss:.5f}'
results['current_tries'],
results['total_tries'],
results['result'],
results['loss']
)
print(log_msg) print(log_msg)
else: else:
print('.', end='') print('.', end='')
@ -309,15 +308,16 @@ class Hyperopt(Backtesting):
""" """
Return the format result in a string Return the format result in a string
""" """
return ('{:6d} trades. Avg profit {: 5.2f}%. ' trades = len(results.index)
'Total profit {: 11.8f} {} ({:.4f}Σ%). Avg duration {:5.1f} mins.').format( avg_profit = results.profit_percent.mean() * 100.0
len(results.index), total_profit = results.profit_abs.sum()
results.profit_percent.mean() * 100.0, stake_cur = self.config['stake_currency']
results.profit_abs.sum(), profit = results.profit_percent.sum()
self.config['stake_currency'], duration = results.trade_duration.mean()
results.profit_percent.sum(),
results.trade_duration.mean(), return (f'{trades:6d} trades. Avg profit {avg_profit: 5.2f}%. '
) f'Total profit {total_profit: 11.8f} {stake_cur} '
f'({profit:.4f}Σ%). Avg duration {duration:5.1f} mins.')
def get_optimizer(self, cpu_count) -> Optimizer: def get_optimizer(self, cpu_count) -> Optimizer:
return Optimizer( return Optimizer(