avg profit and total profit corrected (to be %, not ratio); comments cleaned up a bit; typo in the log msg fixed

This commit is contained in:
hroff-1902 2019-05-12 21:14:00 +03:00
parent 75306b7a6e
commit 00b4501c59

View File

@ -63,9 +63,11 @@ class Hyperopt(Backtesting):
# if eval ends with higher value, we consider it a failed eval # if eval ends with higher value, we consider it a failed eval
self.max_accepted_trade_duration = 300 self.max_accepted_trade_duration = 300
# this is expexted avg profit * expected trade count # This is assumed to be expected avg profit * expected trade count.
# for example 3.5%, 1100 trades, self.expected_max_profit = 3.85 # For example, for 0.35% avg per trade (or 0.0035 as ratio) and 1100 trades,
# check that the reported Σ% values do not exceed this! # self.expected_max_profit = 3.85
# Check that the reported Σ% values do not exceed this!
# Note, this is ratio. 3.85 stated above means 385Σ%.
self.expected_max_profit = 3.0 self.expected_max_profit = 3.0
# Previous evaluations # Previous evaluations
@ -211,8 +213,8 @@ class Hyperopt(Backtesting):
trade_count = len(results.index) trade_count = len(results.index)
trade_duration = results.trade_duration.mean() trade_duration = results.trade_duration.mean()
# If this evaluation contains too short small amount of trades # If this evaluation contains too short amount of trades to be
# to be interesting -- consider it as 'bad' (assign max. loss value) # interesting -- consider it as 'bad' (assigned max. loss value)
# in order to cast this hyperspace point away from optimization # in order to cast this hyperspace point away from optimization
# path. We do not want to optimize 'hodl' strategies. # path. We do not want to optimize 'hodl' strategies.
if trade_count < self.config['hyperopt_min_trades']: if trade_count < self.config['hyperopt_min_trades']:
@ -235,15 +237,15 @@ class Hyperopt(Backtesting):
Return the format result in a string Return the format result in a string
""" """
trades = len(results.index) trades = len(results.index)
avg_profit = results.profit_percent.mean() avg_profit = results.profit_percent.mean() * 100.0
total_profit = results.profit_abs.sum() total_profit = results.profit_abs.sum()
stake_cur = self.config['stake_currency'] stake_cur = self.config['stake_currency']
profit = results.profit_percent.sum() profit = results.profit_percent.sum() * 100.0
duration = results.trade_duration.mean() duration = results.trade_duration.mean()
return (f'{trades:6d} trades. Avg profit {avg_profit: 9.6f}%. ' return (f'{trades:6d} trades. Avg profit {avg_profit: 5.2f}%. '
f'Total profit {total_profit: 11.8f} {stake_cur} ' f'Total profit {total_profit: 11.8f} {stake_cur} '
f'({profit:.4f}Σ%). Avg duration {duration:5.1f} mins.') f'({profit: 7.2f}Σ%). Avg duration {duration:5.1f} mins.')
def get_optimizer(self, cpu_count) -> Optimizer: def get_optimizer(self, cpu_count) -> Optimizer:
return Optimizer( return Optimizer(
@ -318,7 +320,7 @@ class Hyperopt(Backtesting):
}) })
logger.debug(f"Optimizer params: {f_val[j]['params']}") logger.debug(f"Optimizer params: {f_val[j]['params']}")
for j in range(jobs): for j in range(jobs):
logger.debug(f"Opimizer state: Xi: {opt.Xi[-j-1]}, yi: {opt.yi[-j-1]}") logger.debug(f"Optimizer state: Xi: {opt.Xi[-j-1]}, yi: {opt.yi[-j-1]}")
except KeyboardInterrupt: except KeyboardInterrupt:
print('User interrupted..') print('User interrupted..')