get_margin
Calculate margin requirements for hypothetical portfolios by simulating positions and collaterals with Derive market data.
Instructions
Simulate margin requirements for a hypothetical portfolio
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| margin_type | Yes | Margin type: PM (Portfolio), PM2, or SM (Standard) | |
| simulated_collaterals | Yes | List of simulated collaterals | |
| simulated_positions | Yes | List of simulated positions | |
| market | No | Market (required for Portfolio Margin) |
Implementation Reference
- src/client.ts:153-155 (handler)Method in the DeriveClient class that performs the actual API call for 'get_margin'.
getMargin(params: GetMarginParams): Promise<unknown> { return this.post('public/get_margin', params); } - src/tools.ts:177-212 (registration)Registration of the 'get_margin' tool with its input schema definition.
name: 'get_margin', description: 'Simulate margin requirements for a hypothetical portfolio', inputSchema: { type: 'object', properties: { margin_type: { type: 'string', enum: MARGIN_TYPE_ENUM, description: 'Margin type: PM (Portfolio), PM2, or SM (Standard)' }, simulated_collaterals: { type: 'array', items: { type: 'object', properties: { amount: { type: 'string', description: 'Collateral amount' }, asset_name: { type: 'string', description: 'Asset name, e.g. USDC' }, }, required: ['amount', 'asset_name'], }, description: 'List of simulated collaterals', }, simulated_positions: { type: 'array', items: { type: 'object', properties: { amount: { type: 'string', description: 'Position size' }, instrument_name: { type: 'string', description: 'Instrument name' }, entry_price: { type: 'string', description: 'Entry price' }, }, required: ['amount', 'instrument_name'], }, description: 'List of simulated positions', }, market: { type: 'string', description: 'Market (required for Portfolio Margin)' }, }, required: ['margin_type', 'simulated_collaterals', 'simulated_positions'], }, },