Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.quanux.org/llms.txt

Use this file to discover all available pages before exploring further.

quanuxctl crucible is the primary interface for managing the QuanuX Crucible backtesting engine — a C++20 simulation engine that executes strategies at speeds up to 100x faster than pandas-based backends. Crucible enforces process isolation by moving execution off the terminal shell via os.setsid(), meaning your backtest runs in the background and survives terminal disconnection. All metrics are stored natively in a DuckDB state file and are accessible instantly via the C++ API without going through Python.

Synopsis

quanuxctl crucible <command> [options]

Commands

start

Starts a backtesting simulation for the named strategy. Crucible looks for a test harness generated by the Foundry at server/backtests/<strategy>_v<version>/. If found, it forks the process and writes the OS process ID to /tmp/quanux_crucible.pid.
quanuxctl crucible start <strategy> [--version VERSION]
strategy
string
required
The strategy name. Must match a directory under server/backtests/.
--version
string
The version of the strategy to run (e.g., 1.0.0). Defaults to the latest available version.
Example:
quanuxctl crucible start my_strategy --version 1.0.0

stop

Sends a SIGTERM to the running engine PID. If the process has not exited after 5 seconds, Crucible escalates to SIGKILL.
quanuxctl crucible stop
Crucible reads the PID from /tmp/quanux_crucible.pid. If no PID file exists, the command exits cleanly.

status

Reads the tracked PID and returns real-time CPU and memory usage for the running simulation.
quanuxctl crucible status
The output shows:
  • CPU usage (%) against the C++ execution loop
  • RAM consumption inside the 128-byte aligned memory pools

report

Extracts the complete metrics payload from the DuckDB state file at C++ speed. This command bypasses the Python pandas pipeline entirely — it loads the compiled Cython extension and calls DuckDBFeeder::get_metrics_json() directly via the C++ DuckDB API.
quanuxctl crucible report <strategy> [--version VERSION]
strategy
string
required
The strategy name to pull metrics for.
--version
string
The version to report on. Defaults to the latest available version.
Example:
quanuxctl crucible report my_strategy --version 1.0.0

L3 execution metrics

Unlike conventional backtesters, Crucible enforces institutional-grade L3 (Market By Order) metric collection. The report command returns the following metrics in its JSON payload:
MetricDescription
Latency Slippage (bps)Slippage measured in basis points based on execution delay relative to signal time
Queue Position at EntrySimulated position in the order queue, tracked via volume-ahead in the FifoMatcher
MAEMaximum Adverse Excursion — the worst unrealized loss reached during the trade
MFEMaximum Favorable Excursion — the best unrealized gain reached during the trade
The CrucibleTrade struct is explicitly aligned to 128 bytes to maintain CPU L1/L2 cache locality. If you modify this struct in C++, you must propagate the change to quanux_crucible.pxd Cython headers. Failing to do so will produce a segmentation fault at runtime.

Files

PathDescription
/tmp/quanux_crucible.pidOS process ID of the currently running simulation
server/backtests/<strategy>_v<version>/crucible.duckdbDuckDB state file written natively by the C++ engine

Example workflow

1

Start the backtest

Launch the simulation in the background:
quanuxctl crucible start my_strategy --version 1.0.0
The terminal returns immediately. The simulation runs as an isolated OS process.
2

Monitor resource usage

Check CPU and memory consumption while the simulation runs:
quanuxctl crucible status
3

Watch live telemetry (optional)

Subscribe to the NATS telemetry subject for real-time trade events:
nats sub "sys.crucible.report.my_strategy"
4

Pull the metrics report

When the simulation completes (or at any point during execution), extract the L3 metrics:
quanuxctl crucible report my_strategy --version 1.0.0
The command returns a JSON payload with slippage, queue position, MAE, and MFE data.
5

Stop if needed

If you need to halt the simulation early:
quanuxctl crucible stop
Crucible sends SIGTERM first, then SIGKILL after 5 seconds if the process has not exited.

Architecture note

Crucible uses the native duckdb::Appender API to inject vectorized blocks of CrucibleTrade structures directly into DuckDB’s in-memory columnar engine. No SQL parsing occurs during execution. The Cython bridge (QuanuX-Backtesting-Engine/python) provides Python developers with transparent C++ throughput by statically linking libbacktest_engine.a into quanux_crucible.so.