Events & types
The value types your handlers receive and the scalars you build orders from. All come in through the prelude (use signalai_quant::prelude::*;).
Bar
One period of market data, delivered to on_bar.
| Field | Type | Meaning |
|---|---|---|
symbol | SymbolId | Which instrument |
ts | i64 | Bar time (nanoseconds, UTC) |
open / high / low / close | Price | OHLC — read with .as_f64() |
volume | f64 | Traded volume |
resolution | Resolution | Day1 or Min1 |
fn on_bar(&mut self, ctx: &mut Ctx, bar: &Bar) {
let close = bar.close.as_f64();
}
Price and Qty
Fixed-point newtypes (not raw floats), so prices and sizes are exact.
- Read:
.as_f64(). - Build:
Price::from_f64(184.22),Qty::shares(10.0). Qtyhelpers:.is_zero().
Side
Order direction: Side::Buy, Side::Sell.
OrderType
OrderType::Market, OrderType::Limit.
Resolution
Bar resolution: Resolution::Day1 (daily), Resolution::Min1 (minute).
Trade / Quote
Tick-level market data, delivered to on_trade / on_quote when you subscribe with ctx.subscribe_trades(sym) / ctx.subscribe_quotes(sym). Each carries the instrument, a timestamp, and the print/quote prices and sizes.
OrderEvent
Delivered to on_order as an order changes state. Keyed by the OrderId returned from ctx.order(...), carrying the OrderStatus and fill detail (filled quantity, fill price). Orders enqueue and fill as later events — see Fills.
OrderStatus
The order state on an OrderEvent: Submitted, PartiallyFilled, Filled, Cancelled, Rejected.
Timer
Delivered to on_timer for intervals you register with ctx.every("7d"). Carries the fire time.