View as Markdown

Build a prop risk tool

Watch equity on many accounts, enforce daily and maximum drawdown, and flatten on breach.

A prop risk tool has one job: never miss a breach. That means knowing when you can’t see an account, not just when it’s losing.

The shape

  1. Connect each trader’s account, ideally with the investor password if you only monitor, or the master password if you must flatten.
  2. Subscribe to each account’s stream for equity and positions.
  3. Treat any health other than healthy as “not watching” and alert on it.
  4. On breach, flatten with an idempotent close, then verify.

1. Stream equity

const ws = new WebSocket(`wss://api.tickwire.io/users/current/accounts/${id}/ws?auth-token=${token}`);
ws.onopen = () => ws.send(JSON.stringify({ type: "subscribe" }));
ws.onmessage = (m) => {
  const f = JSON.parse(m.data);
  if (f.type === "accountInformation" || f.type === "accountInformationUpdated") {
    check(id, f.accountInformation.equity, f.accountInformation.balance);
  }
  if (f.type === "health" && f.health.status !== "healthy") notWatching(id, f);
};

Keep the sessionId from synchronizationStarted and the last seq you processed. If the socket drops, reconnect with {"type":"subscribe","sync":{"sessionId":"<id>","lastSeq":<seq>}} and you’ll get what you missed. See Streaming.

2. Day boundaries in broker time

Daily loss limits usually reset at the broker’s midnight. Take the start-of-day balance at the broker’s day change, not at UTC midnight. See Time zones.

3. Know when you’re blind

Register a webhook for account.health_changed. If an account goes disconnected or down, your tool isn’t protecting that trader. Say so in your UI rather than showing the last equity as current.

4. Flatten on breach

curl -s -X POST "$TW/users/current/accounts/$ID/trade" \
  -H "auth-token: $TW_KEY" \
  -H "Idempotency-Key: breach-$ID-2026-09-23" \
  -H "X-Actor: risk-engine" -H "X-Reason: daily loss 5% breached" \
  -H "content-type: application/json" \
  -d '{"actionType": "POSITIONS_CLOSE_SYMBOL", "symbol": "EURUSD"}'

Across many accounts at once, the batch endpoint POST /v1/orders/close takes selectors (all positions, by symbol, by magic) for up to 20 accounts in one idempotent call.

Then verify: read positions until it’s empty. If any close came back unknown, read positions, orders and deals, then decide. A retry with the same key never closes twice, but it won’t tell you the outcome. See Idempotency.

5. Or let Tickwire enforce it

Our risk engine can run the rule for you: drawdown and profit trackers per day, week, month and lifetime, with absolute or relative thresholds and broker-time day boundaries. A tracker that flattens is enforced by a guard that runs next to the terminal, so it keeps enforcing even if our central services or yours are unreachable.

Live now: the guard. We checked it on MT4 and MT5 accounts: it takes the day from the broker’s clock, flattens on breach, closes positions opened while the rule is locked, and records each close in the audit log.

Not available yet: setting up trackers with your own API key has not been checked end to end, and the tracker endpoints are not in the API reference yet. A breach is meant to arrive as a risk.tracker_exceeded webhook, but that delivery has not been checked live either. Until then, steps 1 to 4 are the way to enforce a rule from your own code.