Filters

[filters] defines conditions used to discard unsatisfactory backtest results or to prematurely stop a backtest run if its performance drops below certain thresholds.

Some filters, like min_required_positions, are evaluated only after the backtest ends, because they depend on the final result. Others, such as max_allowed_drawdown, can trigger an immediate stop if the threshold is breached during the run. This early exit capability can significantly reduce the overall computation time. For example, setting a maximum drawdown of 40% will terminate many underperforming backtests before completion.

A strategy can declare only one [filters] block.

Example

[filters]
# Filters out results with fewer than 10 completed positions.
min_required_positions = 10

# Filters out results with ROI below 20%.
min_roi_pct = 20

# Filters out results with a win rate below 50%.
min_win_rate = 50

# Filters out results with a Sharpe ratio below 1.0.
min_sharpe_ratio = 1.0

# Filters out results with a Sortino ratio below 1.0.
min_sortino_ratio = 1.0

# Filters out results with a Calmar ratio below 1.0.
# This filter is evaluated only after the backtest ends.
min_calmar_ratio = 1.0

# Stops and filters out results if the drawdown exceeds 40%.
max_allowed_drawdown = 40

# Stops and filters out results if the current capital falls 30% below the initial capital.
max_initial_capital_loss = 30

# Stops and filters out results if too many Margin Calls happen.
#  - Absent or < 0: disabled
#  - 0: forbid any Margin Call
#  - > 0: cap total Margin Calls (All = Long + Short)
max_margin_calls = 0

Block parameters

ParameterDescription
min_required_positions
 Integer
Minimum number of completed positions (trades) required before results are considered statistically meaningful.
Default value: 1
min_roi_pct
 Decimal
Minimum required return on initial capital, expressed in percent. Results are kept only if final capital is at least (1 + value/100) times the initial capital. For example, 20 requires final ≥ 1.2 × initial.
Default value: 0 (disabled)
min_win_rate
 Decimal
Minimum allowed percentage of winning positions out of the total number of positions. Strategies with a win rate lower than this value are rejected.
Default value: 0
min_sharpe_ratio
 Decimal
Minimum required annualized Sharpe ratio. If set to a value greater than 0, backtests with a Sharpe ratio below this threshold, or with a non‑computable (NaN) ratio, are rejected.
Default value: 0 (disabled)
min_sortino_ratio
 Decimal
Minimum required annualized Sortino ratio. If set to a value greater than 0, backtests with a Sortino ratio below this threshold, or with a non‑computable (NaN) ratio, are rejected.
Default value: 0 (disabled)
min_calmar_ratio
 Decimal
Minimum required Calmar ratio. If set to a value greater than 0, backtests with a Calmar ratio below this threshold, or with a non‑computable (NaN) ratio, are rejected. This is a final-only filter and cannot stop a backtest early.
Default value: 0 (disabled)
max_allowed_drawdown
 Decimal
Maximum tolerated drawdown, expressed as a percentage. The drawdown refers to the largest drop in capital from a peak to a trough during the entire backtest. If this limit is set and the running drawdown exceeds it, the backtest stops immediately and its results are discarded.
Default value: No limit
max_initial_capital_loss
 Decimal
Maximum allowed loss relative to the initial capital, expressed as a percentage. The backtest stops if the capital falls more than this percentage below the starting value. With the default value of 80, the test stops only after 80% of the capital is gone.
Default value: 80
max_margin_calls
 Integer
Maximum number of Margin Calls allowed for the whole backtest (All = Long + Short). If set to 0, the backtest is rejected on the first Margin Call (forbid). If set to a positive value N, the backtest stops and is filtered out as soon as the total number of Margin Calls exceeds N. If absent or negative, the filter is disabled.