set_limit
Creates or tightens risk barriers for rate limits, order-size caps, P&L kill switches, and Spot Funds enforcement, then returns the stored barrier; requests that loosen risk are refused.
Instructions
Create a risk barrier, or make the one stored at the same address stricter, and return it as stored. policy names the kind - rate_limit, order_size_limit, one of the P&L-bound kill switches spot_funds_pnl_bounds_kill_switch (realized P&L), spot_funds_unrealized_pnl_bounds_kill_switch (unrealized P&L) and spot_funds_total_pnl_bounds_kill_switch (total P&L), or spot_funds_limit_mode - and the other arguments are that kind's fields; a field of another kind is refused with validation. Anything that loosens risk is refused with loosening_refused and changes nothing. A barrier that replaces the one at its address must be no looser: for rate_limit no more orders and, on the broker and asset scopes, the same window, on the account and account_asset scopes a window no shorter; for order_size_limit every current cap kept and none raised; for a P&L-bound kill switch the same currency, every current bound kept, the lower bound no lower and the upper bound no higher. A new account_underlying_asset or account_settlement_asset cap must be no higher than the underlying_asset or settlement_asset cap on the same asset that it overrides, and a new account_group or account bound must be in the currency of, and no looser than, the bound it takes over from: for a group the global bound, for an account the bound that applies to it now. The first order-size barrier is refused while any rate-limit barrier is configured. spot_funds_limit_mode is the Officer policy that decides whether Spot Funds checks funds, on the global scope only, with the one field mode: enforce (Check funds) refuses an order that lacks funds or holdings; track_only (Accounting without blocking) does not refuse on funds but records every hold, so balances and positions may go negative. Until first set the mode is enforce; the switch to track_only is refused with loosening_refused, and the switch to enforce resets no balance. P&L bounds, rate and order-size barriers apply in both modes. No barrier can be removed; to switch Spot Funds back to Check funds, set spot_funds_limit_mode with mode enforce. Mutates Officer control-plane config; protected and disabled by default.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | spot_funds_limit_mode: enforce (Check funds) or track_only (Accounting without blocking); the switch from enforce to track_only is refused with loosening_refused | |
| asset | No | rate_limit and order_size_limit: asset code, for a scope with an asset axis - the underlying asset for a quantity cap, the settlement asset for a notional cap; omitted otherwise | |
| scope | Yes | Barrier scope: broker, asset, account or account_asset for rate_limit; broker, underlying_asset, settlement_asset, account_underlying_asset or account_settlement_asset for order_size_limit; global, account_group or account for the P&L-bound kill switches; global for spot_funds_limit_mode | |
| policy | Yes | Barrier kind: rate_limit, order_size_limit, spot_funds_pnl_bounds_kill_switch, spot_funds_unrealized_pnl_bounds_kill_switch, spot_funds_total_pnl_bounds_kill_switch or spot_funds_limit_mode | |
| account | No | Account code, for a scope with an account axis; omitted otherwise | |
| currency | No | P&L-bound kill switches: code of an existing asset that denominates both bounds | |
| windowMs | No | rate_limit: window in milliseconds, fixed on the broker and asset scopes and rolling on the account and account_asset scopes | |
| maxOrders | No | rate_limit: most orders admitted within the window | |
| lowerBound | No | P&L-bound kill switches: lower P&L bound as an exact decimal string in plain notation, without an exponent | |
| upperBound | No | P&L-bound kill switches: upper P&L bound, written as lowerBound is; at least one bound is set | |
| maxNotional | No | order_size_limit: per-order notional cap as an exact decimal string; the settlement-asset scopes carry this one only | |
| maxQuantity | No | order_size_limit: per-order quantity cap as an exact decimal string; a broker barrier carries either cap or both, the underlying-asset scopes this one only | |
| accountGroup | No | P&L-bound kill switches: account group code, for the account_group scope | |
| missingAccount | No | Needed when account is named: create or reject; for an account that does not exist yet, create is refused for an agent with loosening_refused, and reject fails the call instead; ignored otherwise |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rateLimit | No | ||
| orderSizeLimit | No | ||
| spotFundsLimitMode | No | ||
| spotFundsPnlBoundsLimit | No | ||
| spotFundsTotalPnlBoundsLimit | No | ||
| spotFundsUnrealizedPnlBoundsLimit | No |