Strategy template
Copy templates/strategy-bot/ into the implementation repo. Fill in decide(). Run the fixtures.
Files
templates/strategy-bot/
README.md
bot.ts
config.schema.json
default.config.json
input.fixture.json
expected.output.json
tests.spec.ts
Bot interface bound
This template implements Bot<MarketSnapshot, OrderIntent | null>. The contract is the canonical bot interface.
The only function you write
async decide(input: MarketSnapshot, ctx: BotContext): Promise<OrderIntent | null> {
if (input.resolution.status !== "open") return null;
const edgeBps = this.model.edge(input);
if (edgeBps < this.config.parameters.min_edge_bps) {
this.emit({ ...envelope(ctx), reasonCode: "STRAT_NO_EDGE" });
return null;
}
return {
schemaVersion: "1.0.0",
intentId: ctx.correlationId,
emittedBy: this.botId,
marketId: input.marketId,
side: edgeBps > 0 ? "buy" : "sell",
outcome: "yes",
sizePusd: kellySize(edgeBps, this.config),
timeInForce: "IOC",
reason: "STRAT_EDGE_DETECTED",
modelEdgeBps: edgeBps,
emittedAt: ctx.now(),
expiresAt: ctx.now() + this.config.parameters.intent_ttl_ms,
builderCode: ctx.builderCode,
};
}
What's already wired for you
init(),validateInput(),explain(),emit(),health(),setMode().- ReportEnvelope construction with correlation IDs, builderCode, killSwitchState.
- The full test harness — unit, integration, property, failure-injection.
- Config schema validation; the bot crashes on init if its config violates a hard threshold.
Promotion checklist
- Implement
decide(). - Run
npm test— all four test classes must pass. - Open a PR with the bot's spec page linked in the description.
- Promote through the modes ladder:
stub → shadow → advisory → enforced.