WASM Runtime
Use the WASM runtime when you want Quantago to execute a compiled module directly.
This is a good fit for Rust, Go, Zig, C++, or any other language that can target WebAssembly.
Why WASM Exists Here
- no separate strategy server to operate
- a portable artifact that can be versioned and stored
- fast execution with a stable JSON-over-memory boundary
Required Exports
By default, Quantago expects these WASM exports:
memoryalloc(size: i32) -> i32signal(ptr: i32, len: i32) -> i32signal_len() -> i32
Optional:
dealloc(ptr: i32, len: i32)
Execution Model
- Quantago serializes the strategy input as UTF-8 JSON.
- It allocates memory in the module.
- It writes the input bytes into module memory.
- It invokes
signal(ptr, len). - It reads the output pointer and output length.
- It parses the returned JSON as a strategy signal.
Output Shape
Your WASM module must return JSON matching the normal strategy contract:
{
"action": "BUY",
"size": 0.25,
"reason": "Momentum threshold crossed",
"metadata": {
"score": 0.81
}
}
Registering a WASM Strategy
The strategies API accepts either:
- a
moduleUrlpointing to a hosted.wasmfile - an uploaded base64 artifact stored by Quantago
Example runtime config:
{
"type": "wasm",
"language": "rust",
"lookbackCandles": 120,
"moduleUrl": "https://example.com/strategy.wasm"
}
When WASM Is the Right Choice
Choose WASM when:
- you want a portable compiled runtime
- you do not want to operate a separate HTTP strategy service
- your strategy language has a strong WASM toolchain
Use the Strategies API to publish and version these modules.