Crucible is QuanuX’s backtesting engine, written in C++20. It executes your Python and Cython strategies at native speeds by bypassing standard memory copies, SQL overhead, and Python object serialization entirely. Under the hood, Crucible uses the nativeDocumentation Index
Fetch the complete documentation index at: https://docs.quanux.org/llms.txt
Use this file to discover all available pages before exploring further.
duckdb::Appender API to inject vectorized blocks of trade data directly into DuckDB’s in-memory columnar engine, with the Python boundary bridged exclusively via Cython. The result is throughput approaching 100x that of traditional pandas-based backtesters.
You control Crucible entirely through quanuxctl. The engine runs as an isolated background process so it does not block your terminal or compete with other research workloads.
Before you start
Crucible expects a Foundry-generated test harness to exist atserver/backtests/<strategy>_v<version>/ before you run start. If that directory is missing, generate your strategy with the Foundry first, or create the harness manually following the expected layout.
Crucible writes its state to
server/backtests/<strategy>_v<version>/crucible.duckdb. Do not delete or modify this file while the engine is running — doing so will produce a fatal segmentation fault in the C++ appender.Backtesting workflow
Start the engine
Launch a Crucible simulation for your strategy. Replace Crucible forks from the terminal via
my_strategy with your strategy name and supply the version string that matches the Foundry-generated harness.os.setsid() and writes the OS process ID to /tmp/quanux_crucible.pid. The simulation runs entirely in the background.Monitor resource usage
Check CPU and memory consumption while the simulation is running.
status reads the PID from /tmp/quanux_crucible.pid and uses psutil to return real-time CPU load and RAM consumption inside the C++ 128-byte aligned memory pools.For live streaming telemetry, subscribe to the NATS topic directly:Pull the metrics report
Extract the instantaneous metrics payload from the running engine.
report bypasses the Python pandas pipeline entirely. It loads the compiled Cython extension from QuanuX-Backtesting-Engine/python and calls the native DuckDBFeeder::get_metrics_json() method directly through the C++ DuckDB API, reading from the live .duckdb state file.You can also target a specific version:L3 execution metrics
Unlike basic backtesters that only track P&L, Crucible enforces institutional-grade L3 (Market By Order) metric collection natively. Every trade record is stored as aCrucibleTrade struct aligned to 128 bytes for optimal CPU cache line saturation.
| Metric | Description |
|---|---|
| Latency Slippage (bps) | Slippage measured in basis points, calculated automatically from execution delay relative to the signal timestamp. |
| Queue Position at Entry | Estimated position in the order queue, determined by simulated volume-ahead tracking in the FifoMatcher. |
| MAE | Maximum Adverse Excursion — the worst intra-trade drawdown from entry price, tracked per tick. |
| MFE | Maximum Favorable Excursion — the best intra-trade unrealized gain from entry price, tracked per tick. |
Backtest state files
Crucible stores all persistent state in the following locations:| Path | Contents |
|---|---|
server/backtests/<strategy>_v<version>/crucible.duckdb | Live DuckDB state file written natively by the C++ engine. Contains all CrucibleTrade records for the current run. |
/tmp/quanux_crucible.pid | OS process ID of the currently running simulation. Cleared automatically on stop. |
.duckdb file directly with the DuckDB CLI after stopping the engine for ad-hoc analysis:
Architecture note
Crucible’sCrucibleTrade struct is explicitly aligned to 128 bytes to maintain memory locality inside CPU L1 and L2 data caches. If you are extending Crucible and modify this struct, you must propagate the changes down to the Cython header at QuanuX-Backtesting-Engine/python/quanux_crucible.pxd. Mismatches between the C++ struct and the Cython header produce fatal segmentation faults at runtime.