Skip to content

The equity cap

The equity cap tells the risk engine: “size from at most this much, whatever the account holds.” It is RiskLimits::max_trading_equity_usd in crates/zunder-risk/src/limits.rs, true today. It is off unless set.

Zunder built it for its own rule: only EUR 2,000 is ever traded. The cap is in USDC, the venue’s currency, so EUR 2,000 becomes a dollar number. Zunder’s code accepts at most 2,500 USDC (EUR 2,000 at up to 1.25 USD per EUR).

Every entry is sized from the smallest of: the equity the caller reports, the last equity the engine observed, and the cap.

Example. The account holds 5,000 USDC. The cap is 2,000. A 2% trade risks 40 USDC, not 100. A deposit on top never raises a size, the per-trade budget, the open-risk budget or the leverage room.

The daily loss stop and the drawdown halt measure the real loss, in USDC, against the smaller of their base and the cap:

daily loss = (day start − equity) / min(day start, cap)
drawdown = (peak − equity) / min(peak, cap)

Example (from docs/decisions.md, 6 Oct 2026, “The EUR 2,000 sleeve in code”). The account holds 3,000, the cap is 2,000, the daily stop is 6%.

  • Measured this way, the stop fires after a loss of 120 (6% of 2,000).
  • The naive way, capping equity itself at 2,000, would keep “equity” at 2,000 until 1,000 were lost. The stop would fire only after a loss of 1,120.

So the cap makes the stops fire earlier, never later. A grid test checks that the capped fraction is never below the uncapped one.

The cap limits what the engine sizes from. It does not take money off the account.

Example. 5,000 USDC sit on the account by mistake, the cap is 2,000. Positions are sized as for 2,000, so at 5x they are worth at most 10,000. A 30% gap through every stop still loses 3,000, and part of that is paid from the money above the cap.

Only keeping no more than you are willing to lose on the account (or on a sub-account) bounds the loss. The cap is a second line, not the first.

Withdrawals. Taking money off the account counts as a loss, and with a cap it trips the stops sooner. With 2,300 on the account and a cap of 2,000, a withdrawal of 130 is a 6.5% daily loss. Stop the bot first.

The cap is part of the limits a journal is written under. Changing or removing it means a new journal.