NautilusTrader backtests
Run one NautilusTrader backtest for each parameter set. Your wrapper applies strategy inputs before constructing the engine, then reads the result and prints numeric objectives.
If this is your first integration, run the quickstart first to verify Docker, publishing, and metric collection.
Prepare a repeatable local backtest
Section titled “Prepare a repeatable local backtest”Pin your dependencies to the release you have tested. Package your strategy, configuration, and reproducible data access in Docker. Keep the same dataset, date window, fees, seed, and warmup assumptions across trials. Run the exact container command locally before publishing.
Apply strategy inputs before execution
Section titled “Apply strategy inputs before execution”Parse your configured flags, such as --hpo-fast-period and --hpo-slow-period,
before constructing the strategy configuration. Enforce constraints such as
fast-period < slow-period through the search space or reject invalid trials
explicitly. Add the strategy, then call engine.run() once per trial.
Keep instruments, venues, account balances, bar types, timestamps, and precision consistent. A successful process exit must not conceal an engine run that stopped early. Use the official backtest documentation and result reports for your pinned release. The report fields below are version-specific; confirm them against the release you pin.
Extract actual results
Section titled “Extract actual results”Read engine.get_result() after the backtest. PnL reports are nested by currency;
select the intended currency before the named statistic.
| Metric | Source | Meaning |
|---|---|---|
| Currency-specific PnL | result.stats_pnls[currency]['PnL (total)'] |
Objective with currency explicit in its name |
| Order count | result.total_orders |
Check execution and compare activity |
| Other selected metrics | Documented result reports for your pinned release | Independent objectives or context |
Require the intended report and finite numeric objectives. Do not substitute zero
for missing keys. Emit hpo.metrics.<name>=<JSON number> using
json.dumps(value, allow_nan=False). Dispose the engine after collecting results,
including when a backtest fails.
Publish, validate, and launch
Section titled “Publish, validate, and launch”Use CLI builds or manual publishing to publish into your workspace registry. Create a project and configure matching parameter slugs and objective names/directions. Review trial count, concurrency, machine size, and timeout using measured local runtime. Validate before explicitly launching. The platform processes the image, packaged data, logs, and metrics needed to run the experiment. Review billing.
Inspect one successful trial before widening the search. Keep a separate holdout time window and realistic cost assumptions. Synthetic data verifies integration, not investment value. Historical results do not predict live returns. Multiple objectives retain their own directions; there is no implicit combined winner.
See debug trials, troubleshooting, and the general Docker workflow.