From ffa93377b4e66f7182fcfcee305c8635299b106b Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 1 Jun 2020 09:34:03 +0200 Subject: [PATCH 1/6] Test colorama init again (after the fixes done to progressbar) --- freqtrade/optimize/hyperopt.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 3a28de785..bd80f7069 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -4,26 +4,26 @@ This module contains the hyperopt logic """ +import io import locale import logging import random import warnings -from math import ceil from collections import OrderedDict +from math import ceil from operator import itemgetter from pathlib import Path from pprint import pprint from typing import Any, Dict, List, Optional +import progressbar import rapidjson +import tabulate from colorama import Fore, Style +from colorama import init as colorama_init from joblib import (Parallel, cpu_count, delayed, dump, load, wrap_non_picklable_objects) -from pandas import DataFrame, json_normalize, isna -import progressbar -import tabulate -from os import path -import io +from pandas import DataFrame, isna, json_normalize from freqtrade.data.converter import trim_dataframe from freqtrade.data.history import get_timerange @@ -32,7 +32,8 @@ from freqtrade.misc import plural, round_dict from freqtrade.optimize.backtesting import Backtesting # Import IHyperOpt and IHyperOptLoss to allow unpickling classes from these modules from freqtrade.optimize.hyperopt_interface import IHyperOpt # noqa: F401 -from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss # noqa: F401 +from freqtrade.optimize.hyperopt_loss_interface import \ + IHyperOptLoss # noqa: F401 from freqtrade.resolvers.hyperopt_resolver import (HyperOptLossResolver, HyperOptResolver) @@ -374,7 +375,7 @@ class Hyperopt: return # Verification for overwrite - if path.isfile(csv_file): + if Path(csv_file).is_file(): logger.error(f"CSV file already exists: {csv_file}") return @@ -603,7 +604,7 @@ class Hyperopt: data, timerange = self.backtesting.load_bt_data() preprocessed = self.backtesting.strategy.ohlcvdata_to_dataframe(data) - + colorama_init(autoreset=True) # Trim startup period from analyzed dataframe for pair, df in preprocessed.items(): preprocessed[pair] = trim_dataframe(df, timerange) From d9afef8fe19d1fee53cd3c0421cdd3ffcdb27a91 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 1 Jun 2020 09:37:10 +0200 Subject: [PATCH 2/6] Move colorama_init to where it was --- freqtrade/optimize/hyperopt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index bd80f7069..566ba5de8 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -604,7 +604,7 @@ class Hyperopt: data, timerange = self.backtesting.load_bt_data() preprocessed = self.backtesting.strategy.ohlcvdata_to_dataframe(data) - colorama_init(autoreset=True) + # Trim startup period from analyzed dataframe for pair, df in preprocessed.items(): preprocessed[pair] = trim_dataframe(df, timerange) @@ -629,6 +629,10 @@ class Hyperopt: self.dimensions: List[Dimension] = self.hyperopt_space() self.opt = self.get_optimizer(self.dimensions, config_jobs) + + if self.print_colorized: + colorama_init(autoreset=True) + try: with Parallel(n_jobs=config_jobs) as parallel: jobs = parallel._effective_n_jobs() From f6edb32a33c5ddc6a48c7bd9e3abeb01871a6054 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 1 Jun 2020 09:55:52 +0200 Subject: [PATCH 3/6] Run hyperopt with --print-all --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 239576c61..2c6141344 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,7 +88,7 @@ jobs: run: | cp config.json.example config.json freqtrade create-userdir --userdir user_data - freqtrade hyperopt --datadir tests/testdata -e 5 --strategy SampleStrategy --hyperopt SampleHyperOpt + freqtrade hyperopt --datadir tests/testdata -e 5 --strategy SampleStrategy --hyperopt SampleHyperOpt --print-all - name: Flake8 run: | @@ -150,7 +150,7 @@ jobs: run: | cp config.json.example config.json freqtrade create-userdir --userdir user_data - freqtrade hyperopt --datadir tests/testdata -e 5 --strategy SampleStrategy --hyperopt SampleHyperOpt + freqtrade hyperopt --datadir tests/testdata -e 5 --strategy SampleStrategy --hyperopt SampleHyperOpt --print-all - name: Flake8 run: | From 9dba2a34f9edc91a9e0e3ab0f970fb3286aa9b75 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 16 Jun 2020 10:16:23 +0200 Subject: [PATCH 4/6] Add note for hyperopt color support on windows --- docs/hyperopt.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/hyperopt.md b/docs/hyperopt.md index 8efc51a39..9f7f97476 100644 --- a/docs/hyperopt.md +++ b/docs/hyperopt.md @@ -370,6 +370,9 @@ By default, hyperopt prints colorized results -- epochs with positive profit are You can use the `--print-all` command line option if you would like to see all results in the hyperopt output, not only the best ones. When `--print-all` is used, current best results are also colorized by default -- they are printed in bold (bright) style. This can also be switched off with the `--no-color` command line option. +!!! Note "Windows and color output" + Windows does not support color-output nativly, therefore it is automatically disabled. To have color-output for hyperopt running under windows, please consider using WSL. + ### Understand Hyperopt ROI results If you are optimizing ROI (i.e. if optimization search-space contains 'all', 'default' or 'roi'), your result will look as follows and include a ROI table: From c2573c998b98fb295c2c29f6bc092a89c829b7c2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 15 Aug 2020 16:26:47 +0200 Subject: [PATCH 5/6] Remove Hyperopt note about windows --- docs/hyperopt.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/hyperopt.md b/docs/hyperopt.md index 6330a1a5e..9acb606c3 100644 --- a/docs/hyperopt.md +++ b/docs/hyperopt.md @@ -370,9 +370,6 @@ By default, hyperopt prints colorized results -- epochs with positive profit are You can use the `--print-all` command line option if you would like to see all results in the hyperopt output, not only the best ones. When `--print-all` is used, current best results are also colorized by default -- they are printed in bold (bright) style. This can also be switched off with the `--no-color` command line option. -!!! Note "Windows and color output" - Windows does not support color-output nativly, therefore it is automatically disabled. To have color-output for hyperopt running under windows, please consider using WSL. - ### Understand Hyperopt ROI results If you are optimizing ROI (i.e. if optimization search-space contains 'all', 'default' or 'roi'), your result will look as follows and include a ROI table: From fa0c8fa0b332e144556851cde5de218bca77f56d Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 21 Aug 2020 14:26:23 +0200 Subject: [PATCH 6/6] Readd note about windows hyperopt color output --- docs/hyperopt.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/hyperopt.md b/docs/hyperopt.md index 9acb606c3..6330a1a5e 100644 --- a/docs/hyperopt.md +++ b/docs/hyperopt.md @@ -370,6 +370,9 @@ By default, hyperopt prints colorized results -- epochs with positive profit are You can use the `--print-all` command line option if you would like to see all results in the hyperopt output, not only the best ones. When `--print-all` is used, current best results are also colorized by default -- they are printed in bold (bright) style. This can also be switched off with the `--no-color` command line option. +!!! Note "Windows and color output" + Windows does not support color-output nativly, therefore it is automatically disabled. To have color-output for hyperopt running under windows, please consider using WSL. + ### Understand Hyperopt ROI results If you are optimizing ROI (i.e. if optimization search-space contains 'all', 'default' or 'roi'), your result will look as follows and include a ROI table: