desk-risk-limits
How the Risk Manager writes the desk's risk limits with the user, sizes every proposed trade from live account state and Hyperliquid's real constraints, checks the book, and issues a PASS or REJECT with exact ticket fields. Use for setting up or changing limits, sizing any trade, and answering "how's the book".
Galleon Labs · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add galleonlabs/hypergrok-trading-desk --skill desk-risk-limits技能说明
name: desk-risk-limits description: How the Risk Manager writes the desk's risk limits with the user, sizes every proposed trade from live account state and Hyperliquid's real constraints, checks the book, and issues a PASS or REJECT with exact ticket fields. Use for setting up or changing limits, sizing any trade, and answering "how's the book". license: MIT metadata: version: "1.2.0" author: Galleon Labs category: desk
Risk limits and sizing
The user sets the desk's limits, in writing, once; the Risk Manager enforces them on every ticket using live data. Hyperliquid's own constraints (max leverage per market, margin tiers, size decimals, minimum order value) always apply on top.
0. Desk ceilings
These ceilings reject limits files that exceed the desk's bounds. They are maximum permitted settings, not recommended risk levels; the user chooses stricter limits below. They are also the defaults for every desk without a standing mandate.
| Ceiling | Value |
|---|---|
| max risk per trade | 2% of equity |
| max total open risk | 6% of equity |
| max leverage on any market | 20x, and never above the exchange or tier max |
| daily loss stop | -10% of start-of-day equity |
| exchange-resting stop on every entry | mandatory |
| standing approval for a mainnet send that can open or increase exposure | never; only a valid standing mandate (section 5) replaces approval by id |
The one send a standing approval may cover on any network is reduce-only protection: placing or resizing a stop for a position that has none. It can only ever reduce exposure, and the alternative is an unprotected position waiting on a human. Without a valid standing mandate, entries, adds, leverage increases and anything that can open or grow a position need approval by id, on every network.
The user's limits file may only be stricter than these. A file that sets a value looser than a ceiling is not applied: the Risk Manager REJECTs with gate failed: limits file exceeds desk ceiling <name>, keeps enforcing the ceiling, and asks the user to edit the file. The desk never edits the file itself, and no Bot may raise a ceiling.
1. Write the limits file (setup, or on change)
Interview the user, one question at a time, then write /workspace/trading-desk/risk-limits.md. Version it (v1, v2...) and date every change. Only the user changes it, in chat; the Risk Manager records who, when and why.
# Risk limits v1 - 2026-08-16 - set by user
- network: testnet # testnet | mainnet
- account: 0xabc...def # the account the API wallet acts for
- equity basis: accountValue from clearinghouseState (cross margin summary), read live
- max risk per trade: 0.5% of equity # loss if the stop is hit
- max total open risk: 2% of equity # positions plus reserved risk for pending entries
- max leverage per market: 3x # never above the exchange max, and never above this
- max positions: 3
- allowed markets: BTC, ETH, SOL, HYPE # perps; spot needs an explicit entry
- stops: mandatory on every entry, on the exchange, not "mental"
- daily loss stop: -2% of start-of-day equity -> no new risk until the user resets in writing
- max slippage tolerance at send: 10 bps # Execution Trader stops if mid moved further
- correlated cluster limit: majors (BTC, ETH, SOL) count as one cluster; max 2 positions per cluster
- standing approvals: none # recommended: protective stops (reduce-only), any network
- unprotected position deadline: 15m # then tell the user to fix it in the Hyperliquid app
- notes:
Sensible starting points for someone new to perps: 0.25-0.5% per trade, 3x or lower, testnet first. Do not argue the user up or down; record what they choose and enforce it, within the ceilings in section 0.
2. Size a trade
Inputs you need before you start: entry price, stop price, side, market, the current limits file, and live state. If any input is missing or stale, REJECT with "missing input", do not guess.
2.1 Read live state (never from memory)
- Account:
clearinghouseStatefor equity (marginSummary.accountValue), free margin (accountValue - totalMarginUsed), positions (assetPositions[].position:coin,szi,entryPx,leverage,liquidationPx,marginUsed,unrealizedPnl) and open orders viaopenOrders/frontendOpenOrders; andactiveAssetDatafor the market, whoseavailableToTrade(buy, sell) andmaxTradeSzsare the exchange's own figures for what can be opened at the account's current leverage setting. Skill:hyperliquid-account. - Market:
metafor the asset'sszDecimals,maxLeverageand its margin table;metaAndAssetCtxsfor mark and mid;l2Bookdepth from the Market Analyst's evidence. Skill:hyperliquid-market-data. - Day PnL: start-of-day equity from the journal or
portfolio, current equity now.
Read userAbstraction before choosing the equity and margin basis. Use the account-mode rules in hyperliquid-account; adding spot USDC to a perp summary can count the same collateral twice. An unsupported or unclear basis is missing input, not permission to use whichever balance is larger.
Record each request's account, network, exchange time where supplied, and local request/receipt times. These reads are separate responses, not an atomic account snapshot. If fills or order changes arrive between them, refresh the affected reads before a PASS; stale, future-dated or conflicting state cannot establish capacity.
2.2 Arithmetic (show every line in the PASS)
risk_usd = equity x max_risk_pct
stop_distance = |entry - stop| (must be > 0)
slip_stop = assumed slippage on a triggered stop, in price units
(at least the market's current spread; widen it on thin l2Book depth for this size)
stop_fill = stop - slip_stop (long) | stop + slip_stop (short)
taker_fee = the account's taker rate from `userFees` (a
阅读完整来源 ↗