SearchFunction#

API documentation for tradeexecutor.backtest.optimiser.SearchFunction Python class in Trading Strategy framework.

class SearchFunction[source]#

Bases: Protocol

The function definition for the optimiser search function.

  • The search function extracts the result variable we want to optimise for from the GridSearchResult

Example:

# Search for the best CAGR value.
def optimise_profit(result: GridSearchResult) -> OptimiserSearchResult:
    return OptimiserSearchResult(-result.get_cagr(), negative=True)
__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

__call__(result)[source]#

The search function extracts the parm

Parameters:

result (GridSearchResult) – The latest backtest result as grid search result object.

Returns:

Value of the function to optimise.

Smaller is better. E.g. if you want to optimise profit, return negative profit.

Return type:

OptimiserSearchResult

__init__(*args, **kwargs)#