Dump parameters from hyperopt-show
This commit is contained in:
parent
750c780293
commit
2bf17f71e7
@ -129,9 +129,15 @@ def start_hyperopt_show(args: Dict[str, Any]) -> None:
|
|||||||
|
|
||||||
metrics = val['results_metrics']
|
metrics = val['results_metrics']
|
||||||
if 'strategy_name' in metrics:
|
if 'strategy_name' in metrics:
|
||||||
show_backtest_result(metrics['strategy_name'], metrics,
|
strategy_name = metrics['strategy_name']
|
||||||
|
show_backtest_result(strategy_name, metrics,
|
||||||
metrics['stake_currency'])
|
metrics['stake_currency'])
|
||||||
|
|
||||||
|
# Export parameters ...
|
||||||
|
# TODO: make this optional? otherwise it'll overwrite previous parameters ...
|
||||||
|
fn = HyperoptTools.get_strategy_filename(config, strategy_name)
|
||||||
|
HyperoptTools.export_params(val, strategy_name, fn.with_suffix('.json'))
|
||||||
|
|
||||||
HyperoptTools.show_epoch_details(val, total_epochs, print_json, no_header,
|
HyperoptTools.show_epoch_details(val, total_epochs, print_json, no_header,
|
||||||
header_str="Epoch details")
|
header_str="Epoch details")
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
|
from copy import deepcopy
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
@ -9,8 +10,9 @@ import tabulate
|
|||||||
from colorama import Fore, Style
|
from colorama import Fore, Style
|
||||||
from pandas import isna, json_normalize
|
from pandas import isna, json_normalize
|
||||||
|
|
||||||
|
from freqtrade.constants import USERPATH_STRATEGIES
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.misc import round_coin_value, round_dict
|
from freqtrade.misc import deep_merge_dicts, round_coin_value, round_dict
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -18,6 +20,34 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class HyperoptTools():
|
class HyperoptTools():
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_strategy_filename(config: Dict, strategy_name: str) -> Path:
|
||||||
|
"""
|
||||||
|
Get Strategy-location (filename) from strategy_name
|
||||||
|
"""
|
||||||
|
from freqtrade.resolvers.strategy_resolver import StrategyResolver
|
||||||
|
directory = Path(config.get('strategy_path', config['user_data_dir'] / USERPATH_STRATEGIES))
|
||||||
|
strategy_objs = StrategyResolver.search_all_objects(directory, False)
|
||||||
|
strategy = [s for s in strategy_objs if s['name'] == strategy_name]
|
||||||
|
if strategy:
|
||||||
|
strategy = strategy[0]
|
||||||
|
|
||||||
|
return Path(strategy['location'])
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def export_params(params, strategy_name: str, filename: Path):
|
||||||
|
"""
|
||||||
|
Generate files
|
||||||
|
"""
|
||||||
|
final_params = deepcopy(params['params_not_optimized'])
|
||||||
|
final_params = deep_merge_dicts(params['params_details'], final_params)
|
||||||
|
final_params = {
|
||||||
|
'strategy_name': strategy_name,
|
||||||
|
'params': final_params
|
||||||
|
}
|
||||||
|
logger.info(f"Dumping parameters to {filename}")
|
||||||
|
rapidjson.dump(final_params, filename.open('w'), indent=2)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def has_space(config: Dict[str, Any], space: str) -> bool:
|
def has_space(config: Dict[str, Any], space: str) -> bool:
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user