From 92241baadee5b41651d087d2d659c9e1e688ecd5 Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Sun, 14 Jan 2018 13:09:39 +0200 Subject: [PATCH 1/5] log the loss value --- freqtrade/optimize/hyperopt.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 71ddd33c6..19c48371c 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -133,10 +133,11 @@ def log_results(results): if results['loss'] < CURRENT_BEST_LOSS: CURRENT_BEST_LOSS = results['loss'] - logger.info('{:5d}/{}: {}'.format( + logger.info('{:5d}/{}: {}. Loss {:.5f}'.format( results['current_tries'], results['total_tries'], - results['result'])) + results['result'], + results['loss'])) else: print('.', end='') sys.stdout.flush() From f1e176d35c77d3772732532978007409d2d2adb3 Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Sun, 14 Jan 2018 13:10:25 +0200 Subject: [PATCH 2/5] log total profit in percentages also --- freqtrade/optimize/hyperopt.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 19c48371c..97c6a82f5 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -191,12 +191,13 @@ def optimizer(params): def format_results(results: DataFrame): return ('{:6d} trades. Avg profit {: 5.2f}%. ' - 'Total profit {: 11.8f} BTC. Avg duration {:5.1f} mins.').format( + 'Total profit {: 11.8f} BTC ({:.4f}Σ%). Avg duration {:5.1f} mins.').format( len(results.index), results.profit_percent.mean() * 100.0, results.profit_BTC.sum(), + results.profit_percent.sum(), results.duration.mean() * 5, - ) + ) def buy_strategy_generator(params): From ec7bfba8dfcc85fe47282b76d39dc994ddcf47f3 Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Sun, 14 Jan 2018 13:11:19 +0200 Subject: [PATCH 3/5] add comment about checking the new total profit logging --- freqtrade/optimize/hyperopt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 97c6a82f5..3235a10e6 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -41,6 +41,7 @@ MAX_ACCEPTED_TRADE_DURATION = 240 # this is expexted avg profit * expected trade count # for example 3.5%, 1100 trades, EXPECTED_MAX_PROFIT = 3.85 +# check that the reported Σ% values do not exceed this! EXPECTED_MAX_PROFIT = 3.85 # Configuration and data used by hyperopt From 38fe7ec7cdae4703cb96588067ea419e10f7acfa Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Tue, 16 Jan 2018 16:35:48 +0200 Subject: [PATCH 4/5] adjust default target values for hyperopt --- freqtrade/optimize/hyperopt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 3235a10e6..02a64fa74 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -30,19 +30,19 @@ logging.getLogger('hyperopt.tpe').setLevel(logging.WARNING) logger = logging.getLogger(__name__) # set TARGET_TRADES to suit your number concurrent trades so its realistic to 20days of data -TARGET_TRADES = 1100 +TARGET_TRADES = 600 TOTAL_TRIES = 0 _CURRENT_TRIES = 0 CURRENT_BEST_LOSS = 100 # max average trade duration in minutes # if eval ends with higher value, we consider it a failed eval -MAX_ACCEPTED_TRADE_DURATION = 240 +MAX_ACCEPTED_TRADE_DURATION = 300 # this is expexted avg profit * expected trade count # for example 3.5%, 1100 trades, EXPECTED_MAX_PROFIT = 3.85 # check that the reported Σ% values do not exceed this! -EXPECTED_MAX_PROFIT = 3.85 +EXPECTED_MAX_PROFIT = 3.0 # Configuration and data used by hyperopt PROCESSED = None # optimize.preprocess(optimize.load_data()) From 501be8a3bc2df259765bedf6ad6f3fd6f66cd4a8 Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Tue, 16 Jan 2018 16:36:50 +0200 Subject: [PATCH 5/5] adjust the hyperopt objective function to emphasize profit and allow more variation in trade counts --- freqtrade/optimize/hyperopt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 02a64fa74..f8a494a0a 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -146,9 +146,9 @@ def log_results(results): def calculate_loss(total_profit: float, trade_count: int, trade_duration: float): """ objective function, returns smaller number for more optimal results """ - trade_loss = 1 - 0.35 * exp(-(trade_count - TARGET_TRADES) ** 2 / 10 ** 5.2) + trade_loss = 1 - 0.25 * exp(-(trade_count - TARGET_TRADES) ** 2 / 10 ** 5.8) profit_loss = max(0, 1 - total_profit / EXPECTED_MAX_PROFIT) - duration_loss = min(trade_duration / MAX_ACCEPTED_TRADE_DURATION, 1) + duration_loss = 0.7 + 0.3 * min(trade_duration / MAX_ACCEPTED_TRADE_DURATION, 1) return trade_loss + profit_loss + duration_loss