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 sharpeThis 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
| Metric | Description |
|---|---|
npdd | Net Profit divided by Max Drawdown (default) |
sharpe | Sharpe ratio |
sortino | Sortino ratio |
rina | RINA index |
calmar | Calmar ratio |
profit | Net profit |
profitfactor | Profit factor |
pct-profitable | Win 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 LenFastExclude specific inputs
# Optimise everything except LenSlow
algo seek --strategy macrossover --symbols @ES --inputs-exclude LenSlowOptimisation modes
| Mode | Description |
|---|---|
exhaustive | Tests every combination (default). Guaranteed to find the global optimum. |
genetic | Uses 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 16The 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