Add a new algo strategy
When to use
Section titled “When to use”You are adding a new execution algorithm (e.g., OPPORTUNISTIC, LIQUIDITY-SEEKING) that consumes the parent-order stream and emits child orders.
Inputs needed
Section titled “Inputs needed”- A docker-compose stack running locally so the bus exists (
docker compose up -d redpanda) - Familiarity with the Algo strategies page
- Create the strategy file at
backend/src/algo/<lowercase-name>-strategy.ts. Pattern to follow:backend/src/algo/twap-strategy.tsis the most digestible reference. Required behaviour:- Subscribe to
orders.routedfor parents that name your strategy - Subscribe to
orders.filledso you can mark active orders complete - Publish to
orders.childfor each child slice you generate - Emit
algo.heartbeatevery 5s so the frontend's AlgoHeartbeat panel stays green
- Subscribe to
- Add a port + env var to
compose.yml. Use the next free port in the 5000-range. Add<UPPER>_ALGO_PORTand<UPPER>_ALGO_HOSTto thegatewayservice env block so SVC_PROXY can route to it. - Update the params type in
frontend/src/types.ts. Add a<Name>Paramsinterface and union member inAlgoParams. - Wire the order-ticket UI by adding a strategy option in
StrategyParams.tsx. Add a builder branch inOrderTicket/buildAlgoParams.ts. - Document in the strategy file's leading JSDoc. The first line becomes the title and the body becomes the description on Algo strategies — picked up automatically by
docs/site/scripts/generate-algos.mjson the next docs build.
Verification
Section titled “Verification”# Unit tests for the new strategydeno test --allow-all backend/src/tests/algo.unit.test.ts
# Integration smoke (start the algo + submit a parent order)deno task test:smoke -- --grep "<your-algo>"
# Frontend tests covering the new strategy in OrderTicketcd frontend && ./node_modules/.bin/vitest run src/components/OrderTicket/
# Docs site rebuild picks up the new algocd docs/site && npm run generateCommon pitfalls
Section titled “Common pitfalls”- Forgetting the heartbeat — frontend's algo health turns amber after 30s. The base
commonHttp.tshelper providessubscribeNewsSignals()and a heartbeat publisher; use them. - Hardcoding venue selection — child orders should let the EMS choose the venue (see Smart Order Router). Only set
venueexplicitly if your algo is doing best-price routing like SNIPER. - Missing tests in
deno.json— new test files are not auto-picked-up. Add the path to all threetest*task definitions indeno.json. - Docs auto-gen swallows your description — the algo generator reads the first sentence (split on
. <Capital>). Keep the first sentence punchy.