ig_update_position
Modify stop loss, take profit, and trailing stop levels for an open position using deal ID on IG Trading MCP. Adjust risk management parameters dynamically while trading forex, indices, or commodities.
Instructions
Update stop/limit levels for an open position
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dealId | Yes | Deal ID of the position to update | |
| limitLevel | No | New take profit level | |
| stopLevel | No | New stop loss level | |
| trailingStop | No | Enable trailing stop | |
| trailingStopDistance | No | Trailing stop distance |
Input Schema (JSON Schema)
{
"properties": {
"dealId": {
"description": "Deal ID of the position to update",
"type": "string"
},
"limitLevel": {
"description": "New take profit level",
"type": "number"
},
"stopLevel": {
"description": "New stop loss level",
"type": "number"
},
"trailingStop": {
"description": "Enable trailing stop",
"type": "boolean"
},
"trailingStopDistance": {
"description": "Trailing stop distance",
"type": "number"
}
},
"required": [
"dealId"
],
"type": "object"
}
Implementation Reference
- src/services/ig-service.js:181-198 (handler)Core handler function that performs the IG API PUT request to update position levels (stop, limit, trailing stop).async updatePosition(dealId, updates) { try { const response = await this.apiClient.put(`/positions/otc/${dealId}`, updates, 2); if (response.data.dealReference) { const confirmation = await this.getConfirmation(response.data.dealReference); return { position: response.data, confirmation }; } return response.data; } catch (error) { logger.error('Failed to update position:', error.message); throw error; } }
- src/services/mcp-service.js:237-265 (schema)Input schema definition for the ig_update_position tool, defining parameters like dealId, stopLevel, limitLevel, etc.name: 'ig_update_position', description: 'Update stop/limit levels for an open position', inputSchema: { type: 'object', properties: { dealId: { type: 'string', description: 'Deal ID of the position to update', }, stopLevel: { type: 'number', description: 'New stop loss level', }, limitLevel: { type: 'number', description: 'New take profit level', }, trailingStop: { type: 'boolean', description: 'Enable trailing stop', }, trailingStopDistance: { type: 'number', description: 'Trailing stop distance', }, }, required: ['dealId'], }, },
- src/services/mcp-service.js:634-643 (handler)MCP server handler that dispatches the tool call to igService.updatePosition and formats the response.case 'ig_update_position': const updateResult = await igService.updatePosition(args.dealId, args); return { content: [ { type: 'text', text: JSON.stringify(updateResult, null, 2), }, ], };
- src/services/mcp-service.js:506-510 (registration)Registers the list of tools (including ig_update_position schema from TOOLS array) with the MCP server.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TOOLS, }; });