> ## 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.

# Strategy Forge: AI-assisted strategy development

> The Strategy Forge is QuanuX's end-to-end pipeline for creating, testing, and promoting trading strategies from Python prototype to compiled C++ execution.

The Strategy Forge is the intelligence layer of QuanuX. It gives you a structured path from a rough trading idea to a production-grade, compiled strategy running inside the C++ execution engine. Rather than treating research and deployment as separate workflows, the Forge unifies them into a single pipeline: you write your logic in Python, the AI Foundry generates and verifies equivalent code, the Crucible backtesting engine stress-tests it against historical L3 data, and the final compiled artifact is promoted into the live spreader.

## The Forge pipeline

Every strategy in QuanuX travels through four stages before it reaches live execution.

```mermaid theme={null}
flowchart LR
    A[Python prototype] --> B[AI Foundry generation]
    B --> C[Crucible backtest]
    C --> D[C++ deployment]
```

**Python prototype** — You write and iterate on your strategy using the `StrategyComponent` base classes in `server/strategies/`. Python gives you access to the full data science ecosystem and makes it fast to explore ideas.

**AI Foundry generation** — Once your logic is solid, you submit a forge request to `POST /api/foundry/forge`. The Foundry dispatches the job over NATS to an AI generation worker that produces Cython or C++ code matching your strategy's behavior.

**Crucible backtest** — You run the generated strategy through Crucible, QuanuX's C++ backtesting engine backed by DuckDB. Crucible executes your strategy at speeds up to 100x faster than pandas-based engines and captures L3-grade execution metrics.

**C++ deployment** — After the strategy passes backtesting and equivalence verification, it is compiled and promoted into the live spreader. SHA-256 verification and a signed Git commit are required before any strategy can be deployed.

## Foundry API endpoints

The Forge exposes two HTTP endpoints on the QuanuX server.

| Endpoint                   | Purpose                                                       |
| -------------------------- | ------------------------------------------------------------- |
| `POST /api/foundry/forge`  | Submit an AI generation job for a strategy component          |
| `POST /api/foundry/verify` | Trigger equivalence testing between Python and generated code |

Both endpoints accept a JSON body and return immediately with a job ID. The actual work runs asynchronously over the NATS mesh. You can monitor progress by subscribing to `sys.foundry.request.forge` and `sys.foundry.request.verify` on your NATS node.

<Note>
  The legacy `POST /api/strategy/generate` endpoint is deprecated. All strategy generation must go through the Foundry endpoints described above.
</Note>

## What the Forge produces

Depending on the `target_lang` you specify in your forge request, the Foundry outputs one of three artifact types:

* **Python** — A clean, validated Python module conforming to the `StrategyComponent` base classes.
* **Cython** — A `.pyx` file with typed declarations and C++ bindings, compiled into a shared object for use by the Crucible engine.
* **C++** — A native C++20 header and implementation targeting the spreader's `InjectionStub` interface.

<Warning>
  C++ generation is in active development. Python and Cython targets are stable and recommended for current use.
</Warning>

## Explore the Forge

<CardGroup cols={2}>
  <Card title="Write and generate strategies" icon="pen-line" href="/forge/writing-strategies">
    Learn how to write strategies in Python and use the Foundry API to generate verified code.
  </Card>

  <Card title="Backtest with Crucible" icon="flask-conical" href="/forge/backtesting">
    Run your strategy against historical L3 data using the Crucible engine and quanuxctl.
  </Card>

  <Card title="Promote to C++" icon="rocket" href="/forge/python-to-cpp">
    Understand the Python → Cython → C++ promotion pipeline and Git-as-Governance requirements.
  </Card>

  <Card title="quanuxctl reference" icon="terminal" href="/cli/overview">
    Full CLI reference for orchestrating Crucible, Foundry, and node management.
  </Card>
</CardGroup>
