SignalAI SDK
Write a trading strategy in Rust, backtest it honestly, and ship it.
You author a strategy against the signalai-quant crate and backtest it in the cloud — the SignalAI Rust engine runs it and returns the equity curve, trade ledger, and stats, viewable at your backtests. The engine never ships to you; you code against the same types it runs on the server.
Why "honest"
Backtests lie when they peek at the future or assume perfect fills. The engine is built to avoid that: orders never fill on data they couldn't have seen (see Fills), and intraday strategies are evaluated the way real intraday trading works — each day from the same capital, flat overnight (see Intraday vs long).
Write a strategy
You implement the Strategy trait and a build_strategy() entry point:
use signalai_quant::prelude::*;
struct Momentum { sma: indicators::Sma, sym: SymbolId }
impl Strategy for Momentum {
fn init(&mut self, ctx: &mut Ctx) {
self.sym = ctx.universe()[0]; // the run's symbols — never hard-code tickers
ctx.subscribe_bars(self.sym, Resolution::Day1);
}
fn on_bar(&mut self, ctx: &mut Ctx, bar: &Bar) {
let close = bar.close.as_f64();
let Some(avg) = self.sma.update(close) else { return }; // None until warm
let holding = !ctx.position(self.sym).is_zero();
if close > avg && !holding {
ctx.order(self.sym, Side::Buy, Qty::shares((ctx.cash() / close).floor()));
} else if close < avg && holding {
ctx.liquidate(self.sym);
}
}
}
pub fn build_strategy() -> Box<dyn Strategy> {
Box::new(Momentum { sma: indicators::Sma::new(20), sym: SymbolId(0) })
}
Three ways in
- Web Studio — describe an idea in chat; the agent writes the Rust, you tune run params and backtest inline. Nothing to install.
- Claude (MCP connector) — author and run strategies from any Claude conversation.
- Local (cargo) —
cargo add signalai-quantand write strategies in your own editor with full type-checking; see Setup.
Start with the tutorial, or browse the SDK reference. New here? Ways to use it.