Strategy architecture
Every strategy inserver/strategies/ is assembled from four component types, each inheriting from StrategyComponent defined in server/strategies/base.py.
A
CompositeStrategy wires these components together and drives the on_bar loop.
Writing a strategy in Python
The example below is drawn from theSmaCrossover strategy in server/strategies/full/SmaCrossover/.
Using the Foundry to generate code
Once your Python prototype is working, submit it to the AI Foundry to generate a faster equivalent. The Foundry dispatches your request as a NATS payload and returns a job ID immediately.POST /api/foundry/forge
Submit a generation job for a strategy component. Request bodystring
required
The type of component to generate. Accepted values:
indicator, entry, exit, strategy.string
required
The name for the generated component, used as the file and class identifier.
string
required
The output language. Accepted values:
python, cython, cpp.string
Semantic version string for the generated artifact, e.g.
1.0.0. Optional; defaults to null.string
Natural-language description of the strategy logic. The Foundry uses this alongside the component type and name to guide code generation.
string
required
Always
"accepted" on success. The job runs asynchronously.string
required
Unique job identifier in the format
job_xxxxxxxx. Use this to correlate NATS telemetry events back to your request.Response
POST /api/foundry/verify
After the Foundry generates code, run equivalence testing to confirm the generated version produces mathematically identical output to your Python prototype. Request bodystring
required
The name of the strategy to verify. Must match the
name used in the forge request.string
required
Always
"accepted". Verification runs asynchronously in a deterministic sandbox.string
required
Unique job identifier for this verification run.
cURL
Response