Polytraders Dev Guide
internal
v3 spine Phase 1 · Shared contracts 9 demo-wired · 0 shadow-ready · 0 production-live · 100 pending · 109 total 15/33 infra tasks the plan status board

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

Promotion checklist

  1. Implement decide().
  2. Run npm test — all four test classes must pass.
  3. Open a PR with the bot's spec page linked in the description.
  4. Promote through the modes ladder: stub → shadow → advisory → enforced.