Skip to main content
Glama
kea0811
by kea0811

ig_create_position

Create a new trading position on IG Trading by specifying market epic, direction, size, currency, expiry, order type, and time in force. Set stop loss, take profit, and guaranteed stop options for risk management.

Instructions

Create a new trading position

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
currencyCodeYesCurrency code (e.g., GBP, USD)
directionYesTrade direction
epicYesMarket epic code
expiryYesContract expiry (e.g., DFB for daily funded bet)
forceOpenNoForce open a new position
guaranteedStopNoUse guaranteed stop
levelNoPrice level (required for LIMIT orders)
limitLevelNoTake profit level
orderTypeYesOrder type
sizeYesPosition size
stopLevelNoStop loss level
timeInForceYesTime in force

Implementation Reference

  • Core implementation of position creation: validates input, POSTs to IG API /positions/otc endpoint, fetches deal confirmation if available.
    async createPosition(ticket) {
      this.validatePositionTicket(ticket);
      
      try {
        const response = await this.apiClient.post('/positions/otc', ticket, 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 create position:', error.message);
        throw error;
      }
    }
  • JSON schema defining input parameters, types, enums, defaults, and required fields for the ig_create_position tool.
    {
      name: 'ig_create_position',
      description: 'Create a new trading position',
      inputSchema: {
        type: 'object',
        properties: {
          epic: {
            type: 'string',
            description: 'Market epic code',
          },
          direction: {
            type: 'string',
            enum: ['BUY', 'SELL'],
            description: 'Trade direction',
          },
          size: {
            type: 'number',
            description: 'Position size',
          },
          currencyCode: {
            type: 'string',
            description: 'Currency code (e.g., GBP, USD)',
          },
          expiry: {
            type: 'string',
            description: 'Contract expiry (e.g., DFB for daily funded bet)',
          },
          orderType: {
            type: 'string',
            enum: ['MARKET', 'LIMIT'],
            description: 'Order type',
          },
          level: {
            type: 'number',
            description: 'Price level (required for LIMIT orders)',
          },
          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: ['FILL_OR_KILL', 'EXECUTE_AND_ELIMINATE'],
            description: 'Time in force',
          },
        },
        required: ['epic', 'direction', 'size', 'currencyCode', 'expiry', 'orderType', 'timeInForce'],
      },
    },
  • MCP server tool call handler registration: switch case that invokes the igService.createPosition method and formats the response.
    case 'ig_create_position':
      const positionResult = await igService.createPosition(args);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(positionResult, null, 2),
          },
        ],
      };
  • Input validation helper for position creation ticket, enforcing required fields, valid enums, and order-type specific rules.
    validatePositionTicket(ticket) {
      const required = ['currencyCode', 'direction', 'epic', 'expiry', 'size', 'forceOpen', 'orderType', 'guaranteedStop', 'timeInForce'];
      const missing = required.filter(field => ticket[field] === undefined);
      
      if (missing.length > 0) {
        throw new Error(`Missing required fields: ${missing.join(', ')}`);
      }
    
      const validCurrencies = ['AUD', 'USD', 'EUR', 'GBP', 'CHF', 'NZD', 'JPY', 'CAD'];
      if (!validCurrencies.includes(ticket.currencyCode)) {
        throw new Error(`Invalid currency code: ${ticket.currencyCode}`);
      }
    
      if (!['BUY', 'SELL'].includes(ticket.direction)) {
        throw new Error('Direction must be BUY or SELL');
      }
    
      if (!['LIMIT', 'MARKET'].includes(ticket.orderType)) {
        throw new Error('Order type must be LIMIT or MARKET');
      }
    
      if (ticket.orderType === 'LIMIT' && !ticket.level) {
        throw new Error('Level is required for LIMIT orders');
      }
    
      if (ticket.orderType === 'MARKET' && ticket.level) {
        throw new Error('Level should not be set for MARKET orders');
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Create' implies a write/mutation operation, the description doesn't address critical aspects like authentication requirements, rate limits, whether this is a live trading action with financial consequences, error conditions, or what happens on success/failure. This is inadequate for a financial trading tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is maximally concise - a single clear sentence with zero wasted words. It's front-loaded with the essential information and doesn't include any unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex financial trading tool with 12 parameters (7 required) and no annotations or output schema, the description is insufficient. It doesn't address the tool's behavioral characteristics, error handling, financial implications, or relationship to sibling tools. The agent would struggle to use this tool correctly without additional context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the input schema already documents all 12 parameters thoroughly. The description adds no additional parameter information beyond what's in the schema, so it meets the baseline expectation but doesn't provide extra value like explaining parameter relationships or trade-offs.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create') and resource ('new trading position'), making the purpose immediately understandable. However, it doesn't differentiate this from sibling tools like 'ig_create_working_order' or 'ig_update_position', which might create similar trading-related entities.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'ig_create_working_order' and 'ig_update_position' available, there's no indication of when a position should be created versus a working order, or whether this is for opening new positions versus modifying existing ones.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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