Skip to main content
Glama

ig_create_working_order

Place a working order on IG Trading by specifying epic, direction, size, currency, expiry, type, level, and time in force. Manage stop loss, take profit, and use guaranteed stops for forex, indices, and commodities trading.

Instructions

Create a working order

Input Schema

NameRequiredDescriptionDefault
currencyCodeYesCurrency code
directionYesTrade direction
epicYesMarket epic code
expiryYesContract expiry
forceOpenNoForce open a new position
goodTillDateNoExpiry date for GOOD_TILL_DATE orders
guaranteedStopNoUse guaranteed stop
levelYesEntry level
limitLevelNoTake profit level
sizeYesOrder size
stopLevelNoStop loss level
timeInForceYesTime in force
typeYesOrder type

Input Schema (JSON Schema)

{ "properties": { "currencyCode": { "description": "Currency code", "type": "string" }, "direction": { "description": "Trade direction", "enum": [ "BUY", "SELL" ], "type": "string" }, "epic": { "description": "Market epic code", "type": "string" }, "expiry": { "description": "Contract expiry", "type": "string" }, "forceOpen": { "default": true, "description": "Force open a new position", "type": "boolean" }, "goodTillDate": { "description": "Expiry date for GOOD_TILL_DATE orders", "type": "string" }, "guaranteedStop": { "default": false, "description": "Use guaranteed stop", "type": "boolean" }, "level": { "description": "Entry level", "type": "number" }, "limitLevel": { "description": "Take profit level", "type": "number" }, "size": { "description": "Order size", "type": "number" }, "stopLevel": { "description": "Stop loss level", "type": "number" }, "timeInForce": { "description": "Time in force", "enum": [ "GOOD_TILL_CANCELLED", "GOOD_TILL_DATE" ], "type": "string" }, "type": { "description": "Order type", "enum": [ "LIMIT", "STOP" ], "type": "string" } }, "required": [ "epic", "direction", "size", "currencyCode", "expiry", "type", "level", "timeInForce" ], "type": "object" }

Implementation Reference

  • Core handler that validates input, posts working order to IG API endpoint /workingorders/otc, and retrieves confirmation if available.
    async createWorkingOrder(ticket) { this.validateWorkingOrderTicket(ticket); try { const response = await this.apiClient.post('/workingorders/otc', ticket, 2); if (response.data.dealReference) { const confirmation = await this.getConfirmation(response.data.dealReference); return { order: response.data, confirmation }; } return response.data; } catch (error) { logger.error('Failed to create working order:', error.message); throw error; } }
  • Input schema and tool metadata definition used for tool listing and validation.
    { name: 'ig_create_working_order', description: 'Create a working order', inputSchema: { type: 'object', properties: { epic: { type: 'string', description: 'Market epic code', }, direction: { type: 'string', enum: ['BUY', 'SELL'], description: 'Trade direction', }, size: { type: 'number', description: 'Order size', }, currencyCode: { type: 'string', description: 'Currency code', }, expiry: { type: 'string', description: 'Contract expiry', }, type: { type: 'string', enum: ['LIMIT', 'STOP'], description: 'Order type', }, level: { type: 'number', description: 'Entry level', }, stopLevel: { type: 'number', description: 'Stop loss level', }, limitLevel: { type: 'number', description: 'Take profit level', }, guaranteedStop: { type: 'boolean', description: 'Use guaranteed stop', default: false, }, forceOpen: { type: 'boolean', description: 'Force open a new position', default: true, }, timeInForce: { type: 'string', enum: ['GOOD_TILL_CANCELLED', 'GOOD_TILL_DATE'], description: 'Time in force', }, goodTillDate: { type: 'string', description: 'Expiry date for GOOD_TILL_DATE orders', }, }, required: ['epic', 'direction', 'size', 'currencyCode', 'expiry', 'type', 'level', 'timeInForce'], }, },
  • MCP server tool dispatch case that calls the IGService handler and formats the response.
    case 'ig_create_working_order': const orderResult = await igService.createWorkingOrder(args); return { content: [ { type: 'text', text: JSON.stringify(orderResult, null, 2), }, ], };
  • Helper function that validates the working order ticket parameters before API submission.
    validateWorkingOrderTicket(ticket) { const required = ['currencyCode', 'direction', 'epic', 'expiry', 'size', 'forceOpen', 'type', 'guaranteedStop', 'timeInForce', 'level']; const missing = required.filter(field => ticket[field] === undefined); if (missing.length > 0) { throw new Error(`Missing required fields: ${missing.join(', ')}`); } if (!['LIMIT', 'STOP'].includes(ticket.type)) { throw new Error('Order type must be LIMIT or STOP'); } if (!['GOOD_TILL_CANCELLED', 'GOOD_TILL_DATE'].includes(ticket.timeInForce)) { throw new Error('TimeInForce must be GOOD_TILL_CANCELLED or GOOD_TILL_DATE'); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kea0811/ig-trading-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server