GridSearchResult#

API documentation for tradeexecutor.backtest.grid_search.GridSearchResult Python class in Trading Strategy framework.

class GridSearchResult[source]#

Bases: object

Result for one grid combination.

  • Result for one grid search combination

  • Calculate various statistics and curves ready in a multiprocess worker

  • Results can be cached on a disk, as a pickle

  • Some of the data might not be available or discarded as per GridSearchDataRetention

__init__(combination, state, summary, metrics, equity_curve, returns, universe_options, cached=False, process_id=None)#
Parameters:
Return type:

None

Methods

__init__(combination, state, summary, ...[, ...])

get_label()

Get name for this result for charts.

get_metric(name)

Get a performance metric from quantstats.

has_result(combination)

load(combination)

Deserialised from the cached Python pickle.

save()

Serialise as Python pickle.

Attributes

combination

For which grid combination this result is

state

The full back test state

summary

Calculated trade summary

metrics

Performance metrics

equity_curve

Needed for visualisations

returns

Needed for visualisations

universe_options

What backtest data range we used

cached

Was this result read from the earlier run save

process_id

Child process that created this result.

combination: GridCombination#

For which grid combination this result is

state: tradeexecutor.state.state.State | None#

The full back test state

summary: TradeSummary#

Calculated trade summary

Internal stats calculated about trades

metrics: DataFrame#

Performance metrics

Use QuantStats lib to calculate these stats.

equity_curve: Series#

Needed for visualisations

returns: Series#

Needed for visualisations

universe_options: UniverseOptions#

What backtest data range we used

cached: bool#

Was this result read from the earlier run save

process_id: int#

Child process that created this result.

Only applicable to multiprocessing

get_label()[source]#

Get name for this result for charts.

Return type:

str

get_metric(name)[source]#

Get a performance metric from quantstats.

A shortcut method.

Example:

grid_search_results = perform_grid_search(
    decide_trades,
    strategy_universe,
    combinations,
    max_workers=8,
    trading_strategy_engine_version="0.4",
    multiprocess=True,
)

print("Sharpe of the first result", grid_search_results[0].get_metric("Sharpe")
Parameters:

name (str) – See quantstats for examples

Returns:

Performance metrics value

Return type:

float

static load(combination)[source]#

Deserialised from the cached Python pickle.

Parameters:

combination (GridCombination) –

save()[source]#

Serialise as Python pickle.

__init__(combination, state, summary, metrics, equity_curve, returns, universe_options, cached=False, process_id=None)#
Parameters:
Return type:

None