Merge pull request #3007 from yazeed/hyperopt_interface_sort
hyperopt_interface.py code styling
This commit is contained in:
commit
db1227f279
@ -97,10 +97,10 @@ def start_hyperopt_show(args: Dict[str, Any]) -> None:
|
||||
|
||||
if n > trials_epochs:
|
||||
raise OperationalException(
|
||||
f"The index of the epoch to show should be less than {trials_epochs + 1}.")
|
||||
f"The index of the epoch to show should be less than {trials_epochs + 1}.")
|
||||
if n < -trials_epochs:
|
||||
raise OperationalException(
|
||||
f"The index of the epoch to show should be greater than {-trials_epochs - 1}.")
|
||||
f"The index of the epoch to show should be greater than {-trials_epochs - 1}.")
|
||||
|
||||
# Translate epoch index from human-readable format to pythonic
|
||||
if n > 0:
|
||||
@ -122,52 +122,52 @@ def _hyperopt_filter_trials(trials: List, filteroptions: dict) -> List:
|
||||
trials = [x for x in trials if x['results_metrics']['profit'] > 0]
|
||||
if filteroptions['filter_min_trades'] > 0:
|
||||
trials = [
|
||||
x for x in trials
|
||||
if x['results_metrics']['trade_count'] > filteroptions['filter_min_trades']
|
||||
]
|
||||
x for x in trials
|
||||
if x['results_metrics']['trade_count'] > filteroptions['filter_min_trades']
|
||||
]
|
||||
if filteroptions['filter_max_trades'] > 0:
|
||||
trials = [
|
||||
x for x in trials
|
||||
if x['results_metrics']['trade_count'] < filteroptions['filter_max_trades']
|
||||
]
|
||||
x for x in trials
|
||||
if x['results_metrics']['trade_count'] < filteroptions['filter_max_trades']
|
||||
]
|
||||
if filteroptions['filter_min_avg_time'] is not None:
|
||||
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
|
||||
trials = [
|
||||
x for x in trials
|
||||
if x['results_metrics']['duration'] > filteroptions['filter_min_avg_time']
|
||||
]
|
||||
x for x in trials
|
||||
if x['results_metrics']['duration'] > filteroptions['filter_min_avg_time']
|
||||
]
|
||||
if filteroptions['filter_max_avg_time'] is not None:
|
||||
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
|
||||
trials = [
|
||||
x for x in trials
|
||||
if x['results_metrics']['duration'] < filteroptions['filter_max_avg_time']
|
||||
]
|
||||
x for x in trials
|
||||
if x['results_metrics']['duration'] < filteroptions['filter_max_avg_time']
|
||||
]
|
||||
if filteroptions['filter_min_avg_profit'] is not None:
|
||||
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
|
||||
trials = [
|
||||
x for x in trials
|
||||
if x['results_metrics']['avg_profit']
|
||||
> filteroptions['filter_min_avg_profit']
|
||||
]
|
||||
x for x in trials
|
||||
if x['results_metrics']['avg_profit']
|
||||
> filteroptions['filter_min_avg_profit']
|
||||
]
|
||||
if filteroptions['filter_max_avg_profit'] is not None:
|
||||
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
|
||||
trials = [
|
||||
x for x in trials
|
||||
if x['results_metrics']['avg_profit']
|
||||
< filteroptions['filter_max_avg_profit']
|
||||
]
|
||||
x for x in trials
|
||||
if x['results_metrics']['avg_profit']
|
||||
< filteroptions['filter_max_avg_profit']
|
||||
]
|
||||
if filteroptions['filter_min_total_profit'] is not None:
|
||||
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
|
||||
trials = [
|
||||
x for x in trials
|
||||
if x['results_metrics']['profit'] > filteroptions['filter_min_total_profit']
|
||||
]
|
||||
x for x in trials
|
||||
if x['results_metrics']['profit'] > filteroptions['filter_min_total_profit']
|
||||
]
|
||||
if filteroptions['filter_max_total_profit'] is not None:
|
||||
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
|
||||
trials = [
|
||||
x for x in trials
|
||||
if x['results_metrics']['profit'] < filteroptions['filter_max_total_profit']
|
||||
]
|
||||
x for x in trials
|
||||
if x['results_metrics']['profit'] < filteroptions['filter_max_total_profit']
|
||||
]
|
||||
|
||||
logger.info(f"{len(trials)} " +
|
||||
("best " if filteroptions['only_best'] else "") +
|
||||
|
Loading…
Reference in New Issue
Block a user