Skip to content

NautilusTrader

Use HyperOptimizer to run NautilusTrader backtests as managed optimization trials. Your container owns the strategy and engine setup; HyperOptimizer chooses parameter sets and collects metrics.

NautilusTrader strategies are often sensitive to windows, thresholds, bar sizes, sizing rules, and risk parameters. HyperOptimizer lets you expose those values as CLI flags and evaluate them across many containerized backtests.

Repeatable backtests

Run the same Nautilus script repeatedly with different parameter values.

Managed search

Let HyperOptimizer choose candidates while you focus on strategy logic.

Risk-aware metrics

Emit PnL, drawdown, order count, runtime, or custom objective scores.

  1. Package: Build an image with your NautilusTrader environment and data access.
  2. Publish: Push the image to your org Images registry.
  3. Inject: Receive --hpo-* parameters in your backtest entrypoint.
  4. Run: Configure your strategy and run one backtest.
  5. Collect: Print metrics for HyperOptimizer to collect.
import argparse
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--hpo-bar-size", type=str, default="5-MINUTE")
parser.add_argument("--hpo-lookback-window", type=int, default=50)
parser.add_argument("--hpo-risk-multiplier", type=float, default=1.0)
return parser.parse_args()
args = parse_args()

Map CLI values into your strategy or config objects before running the engine.

strategy_config = StrategyConfig(
bar_size=args.hpo_bar_size,
lookback_window=args.hpo_lookback_window,
risk_multiplier=args.hpo_risk_multiplier,
)
engine.add_strategy(MyStrategy(strategy_config))
engine.run()
backtest_result = engine.get_result()
import json
metrics = {
"total_pnl": float(backtest_result.stats_pnls.get("PnL", 0)),
"total_orders": backtest_result.total_orders,
"elapsed_time": backtest_result.elapsed_time,
}
for key, value in metrics.items():
print(f"hpo.metrics.{key}={json.dumps(value, default=str)}")
Metric Role Notes
total_pnl objective Useful for raw profitability, but pair it with risk guardrails.
max_drawdown guardrail Helps avoid unstable configurations.
total_orders context Helps spot overfit runs with too few or too many orders.
elapsed_time runtime Useful when you care about trial cost or operational latency.

After the wrapper works locally, publish the image to your org Images registry and create an experiment. For the full contract, read the Quickstart.