Portfolio Risk
workflow.run_portfolio_riskAggregates risk across multiple open positions in one call: total notional, total P&L, total margin in use, margin usage as a % of account balance (if given), and which single position sits closest to liquidation. Each position is computed through the same canonical PnL/liquidation math as the single-position tools, then rolled up. Linear (USDT-margined) positions sum into one USD total; inverse (coin-margined) positions are grouped by settlement coin instead, since a BTC-margined P&L cannot be summed with an ETH-margined one without a live conversion rate. Returns a verdict label, healthy / watch / reduce / critical, which places the closest liquidation distance and margin usage in fixed bands and is not a recommendation. Edge cases: 1 to 50 positions; each needs entry_price, mark_price, size and leverage above zero, mmr 0 to 0.2 and fees 0 to 0.05 as fractions; an inverse position must name its settlement coin; account_balance above zero is optional and without it margin usage is not computed. Positions are not netted against each other. Not covered: correlation between positions, collateral shared across positions, exchange tiered margin, funding, and price moves after the mark price you give. Use when user asks "how exposed am I across all my positions?" or "which of my positions is closest to liquidation?". Position size follows the product-wide convention: base-asset quantity for linear, USD notional (contracts) for inverse. liquidation_price and liq_distance_pct of a position are null when it cannot be liquidated (an inverse short at 1x or less); the closest liquidation skips it.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"positions": "<positions>"
},
"name": "workflow.run_portfolio_risk"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| positions | Yes | Open positions to aggregate (1 to 50). Each: { side, entry_price, mark_price, size, leverage }, plus optional fees, mmr, mmBase, liqFeeRate, contractType, coin, label. | |
| account_balance | No | Optional account balance in USD, used to compute margin_usage_pct: linear margin plus every inverse position's own margin marked to market at its mark_price, all as one USD total |