MorphIQ Crucible
Strategy SDK
Current anvil-sdk strategy interface and the planned client-owned Crucible composition.
The SDK is the boundary between strategy logic and Crucible's trading runtime.
The public product name has changed; the Rust crate remains anvil-sdk.
Current interface
A strategy implements Strategy: Send. Its on_event method receives a
StrategyContext and an SDK event and returns zero or more OrderIntent
values. The trait also exposes a name and optional market-data type interests.
Use the matching release's API reference for signatures.
The SDK supplies state views and explicit inputs, not a broker execution handle. Strategies should derive decisions from those inputs and explicit strategy memory. Dependency checks and tests enforce the intended architecture; an in-process Rust trait is not a security sandbox or an automatic purity proof.
A strategy callback
Crucible is a Rust trading runtime. Strategy implementations use the
anvil-sdk interface; the platform owns risk admission, order lifecycle,
accounting and recovery. The intended client composition registers strategy
logic with the runtime through Rust calls.
This excerpt belongs inside an implementation of Strategy. It uses the real
on_event signature and Event::Market / Event::Fill variants. The
StrategyContext, Event and OrderIntent types are imported from anvil_sdk.
fn on_event(
&mut self,
ctx: &StrategyContext<'_>,
event: &Event,
) -> Vec<OrderIntent> {
match event {
Event::Market(market) => {
self.model.propose(ctx, market)
}
Event::Fill { fill, .. } => {
self.model.on_fill(fill);
vec![]
}
_ => vec![],
}
}model is strategy-owned code, not an SDK object. In this example,
model.propose consumes the context and market event and returns zero or more
OrderIntent values; model.on_fill updates the model's own state from the
reported fill. These two methods, the enclosing strategy type, and its required
name method are omitted. This is a callback excerpt, not a complete runnable
strategy or a supplied trading model.
The context exposes read-only portfolio state, strategy configuration, an explicit clock and derived features. Returning an intent proposes an action; it does not directly place an order. The abbreviated catch-all returns no proposals for other events. A full strategy must decide how to handle order updates, risk-state changes and fill correlation for its own lifecycle.
Intents and feedback
An intent proposes an action. Crucible applies configured admission and risk policy before execution. Recorded acceptance, rejection, broker reports and reconciliation distinguish a proposed trade from its actual lifecycle.
Existing strategy selection
The current runner uses Cargo features and runtime configuration together. A strategy must be compiled in and enabled in configuration. More than one strategy can be enabled; there is no one-strategy-per-binary invariant.
cargo build -p anvil-runner --features strat_mmPlanned client-owned executable
The accepted composition keeps strategy ownership with the client. A client-owned executable registers setups through Crucible's public SDK/runner API. Crucible owns the event loop, accepted inputs/cutoffs, risk, execution and recovery. Strategy research and development workflows remain separate.
This public composition API and the actual client strategy path remain implementation and
qualification work. Do not infer a delivered plug-in product from the existing
Strategy trait. The design uses ordinary Rust registration and direct calls,
not a dynamic plugin loader or a second trading scheduler.
Strategy discipline
- Use accepted inputs and explicit time/configuration.
- Keep decision evaluation free of blocking I/O.
- Return bounded proposals and preserve explicit strategy memory.
- Treat refusal, partial execution and restart as normal lifecycle cases.
- Measure real workload latency and failure behavior inside the composed runner.
Replay of portfolio events and replay of strategy decisions are distinct claims. The latter also needs retained decision inputs, memory policy and compatible code/configuration identities.