pick_best_grid_search_result#
API documentation for tradeexecutor.backtest.grid_search.pick_best_grid_search_result Python function.
- pick_best_grid_search_result(results, key=<function <lambda>>, highest=True)[source]#
Pick the best combination in the results based on one metric.
Use trading metrics or performance metrics for the selection.
Example:
sample = pick_best_grid_search_result( results, key=lambda r: r.metrics.loc["Max Drawdown"][0]) assert sample is not None
- Parameters:
result – Output from
perform_grid_search()
key (Callable) –
Lambda function to extract the value to compare from the data.
If not given use cumulative return.
highest – If true pick the highest value, otherwise lowest.
results (List[GridSearchResult]) –
- Returns:
The grid search result with the matching parameters or None if not found
- Returns:
The grid search result with the matching parameters or None if not found
- Return type: