Optimisation with seek

Optimisation with seek

The seek command finds optimal strategy input parameters by running multiple backtests and maximising a chosen fitness metric.

Basic usage

algo seek --strategy macrossover --symbols @ES --fitness-metric sharpe

This runs every combination of LenFast and LenSlow values defined in the strategy’s algolang: struct tags and reports the combination that maximises the Sharpe ratio.

Fitness metrics

MetricDescription
npddNet Profit divided by Max Drawdown (default)
sharpeSharpe ratio
sortinoSortino ratio
rinaRINA index
calmarCalmar ratio
profitNet profit
profitfactorProfit factor
pct-profitableWin percentage

Custom expressions are also supported using mathematical operators:

algo seek --strategy kbt --symbols @ES --fitness-metric "profit/maxdd"

Controlling inputs

Include specific inputs

# Only optimise LenFast
algo seek --strategy macrossover --symbols @ES --inputs-include LenFast

Exclude specific inputs

# Optimise everything except LenSlow
algo seek --strategy macrossover --symbols @ES --inputs-exclude LenSlow

Optimisation modes

ModeDescription
exhaustiveTests every combination (default). Guaranteed to find the global optimum.
geneticUses a genetic algorithm to search the parameter space. Faster for large spaces.

Multi-threaded optimisation

# Use 16 threads
algo seek --strategy kbt --symbols @ES --nbr-threads 16

The default is 24 threads. Algolang uses test deduplication to avoid running identical parameter combinations.

Avoiding overfitting

Use --use-first and --use-last to split data for in-sample optimisation and out-of-sample validation:

# Optimise on first 60% of data
algo seek --strategy kbt --symbols @ES --use-first 60 --fitness-metric sharpe

# Then validate the best parameters on the last 40%
algo run --strategy kbt --symbols @ES --use-last 40 \
    --inputs LenFast=10,LenSlow=50 --output-mode summary