1
0
mirror of https://github.com/Rikj000/MoniGoMani.git synced 2022-03-06 00:08:05 +03:00

mgm-config-hyperopt - Only store optimized spaces

This commit is contained in:
Rik Helsen
2022-01-16 16:42:56 +01:00
parent 28c5d7b3e7
commit 04103fbe6f
2 changed files with 19 additions and 5 deletions

View File

@@ -681,12 +681,15 @@ class MGMHurry:
epochs = self.monigomani_config.config['hyperopt']['epochs']
initial_run = True
previously_hyperopted_spaces = []
if clean_start is True:
self.cleanup(strategy)
elif os.path.isfile(f'{self.basedir}/user_data/strategies/{strategy}.json') or (
(strategy == 'MoniGoManiHyperStrategy') and (
os.path.isfile(self.monigomani_config.get_config_filepath('mgm-config-hyperopt')) is True)):
initial_run = False
if strategy == 'MoniGoManiHyperStrategy':
previously_hyperopted_spaces = self.monigomani_config.get_hyperopted_spaces()
self.logger.info(Color.title('👉 Starting HyperOpt run. Keep calm while your computer burns 🔥'))
@@ -725,8 +728,9 @@ class MGMHurry:
sys.exit(1)
if (apply_best_results is True) and (strategy == 'MoniGoManiHyperStrategy'):
self.monigomani_cli.apply_mgm_results(strategy)
self.monigomani_config.save_weak_strong_signal_overrides()
self.monigomani_cli.apply_mgm_results(strategy=strategy)
self.monigomani_config.save_weak_strong_signal_overrides(
previously_hyperopted_spaces=previously_hyperopted_spaces)
# Read 'mgm-config-hyperopt' or <StrategyName>.json and pretty print it
if strategy == 'MoniGoManiHyperStrategy':

View File

@@ -433,10 +433,11 @@ class MoniGoManiConfig(object):
return True
def save_weak_strong_signal_overrides(self) -> bool:
def save_weak_strong_signal_overrides(self, previously_hyperopted_spaces: list[str]) -> bool:
"""
Overrides weak and strong signals to their actual values used by MoniGoMani in 'mgm-config-hyperopt'
:param previously_hyperopted_spaces: (list[str]) List containing previously HyperOpted spaces
:return bool: True if json data is overwritten correctly, False otherwise.
"""
# Check if 'mgm-config-hyperopt' exists
@@ -497,9 +498,18 @@ class MoniGoManiConfig(object):
elif signal_weight_value >= (number_of_weighted_signals - signal_triggers_needed_threshold):
mgm_config_hyperopt['params'][space][signal] = number_of_weighted_signals
# Sort the spaces to Freqtrades default order
# Fetch all used spaces, for the previous + current hyperopt
all_used_spaces = previously_hyperopted_spaces
command_object = self.load_config_file(filename=f'{self.basedir}/user_data/.last_command.json')
currently_used_spaces = list(command_object['properties']['spaces'].split(' '))
for currently_used_space in currently_used_spaces:
if currently_used_space not in previously_hyperopted_spaces:
all_used_spaces.append(currently_used_space)
# Sort the spaces to the order used during hyperopting
sorted_spaces = {}
for space_name in ['buy', 'sell', 'roi', 'stoploss', 'trailing']:
for space_name in all_used_spaces:
if space_name in mgm_config_hyperopt['params']:
sorted_spaces[space_name] = mgm_config_hyperopt['params'][space_name]
mgm_config_hyperopt['params'] = sorted_spaces