Skip to main content
Glama
maven81g

TradeStation MCP Server

by maven81g

confirmOrder

Preview order costs and requirements before execution to verify trade details and avoid errors in the TradeStation MCP Server.

Instructions

Preview order costs and requirements (READ-ONLY - does not execute trades)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdNoAccount ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided)
symbolYesSymbol to trade (e.g., SPY, SPY 251121C580)
quantityYesOrder quantity
orderTypeYesOrder type
tradeActionYesTrade action
limitPriceNoLimit price (required for Limit and StopLimit orders)
stopPriceNoStop price (required for Stop and StopLimit orders)
durationNoTime in force durationDAY

Implementation Reference

  • Executes the confirmOrder tool logic: constructs order preview data based on parameters, calls TradeStation API endpoint '/orderexecution/orderconfirm' via POST, returns confirmation details or error.
    async (args) => {
      try {
        const accountId = args.accountId || TS_ACCOUNT_ID;
        const { symbol, quantity, orderType, tradeAction, limitPrice, stopPrice, duration } = args;
    
        if (!accountId) {
          throw new Error('Account ID is required. Either provide accountId parameter or set TRADESTATION_ACCOUNT_ID in .env file.');
        }
    
        // Build order confirmation request body
        const orderData: any = {
          AccountID: accountId,
          Symbol: symbol,
          Quantity: quantity,
          OrderType: orderType,
          TradeAction: tradeAction,
          TimeInForce: {
            Duration: duration
          }
        };
    
        // Add price fields based on order type
        if (orderType === 'Limit' || orderType === 'StopLimit') {
          if (!limitPrice) {
            throw new Error('limitPrice is required for Limit and StopLimit orders');
          }
          orderData.LimitPrice = limitPrice;
        }
    
        if (orderType === 'Stop' || orderType === 'StopLimit') {
          if (!stopPrice) {
            throw new Error('stopPrice is required for Stop and StopLimit orders');
          }
          orderData.StopPrice = stopPrice;
        }
    
        const confirmation = await makeAuthenticatedRequest(
          '/orderexecution/orderconfirm',
          'POST',
          orderData
        );
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(confirmation, null, 2)
            }
          ]
        };
      } catch (error: unknown) {
        return {
          content: [
            {
              type: "text",
              text: `Failed to confirm order: ${error instanceof Error ? error.message : 'Unknown error'}`
            }
          ],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters and validation for the confirmOrder tool.
    const confirmOrderSchema = {
      accountId: z.string().optional().describe('Account ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided)'),
      symbol: z.string().describe('Symbol to trade (e.g., SPY, SPY 251121C580)'),
      quantity: z.number().describe('Order quantity'),
      orderType: z.enum(['Market', 'Limit', 'Stop', 'StopLimit']).describe('Order type'),
      tradeAction: z.enum(['BUY', 'SELL', 'BUYTOOPEN', 'BUYTOCLOSE', 'SELLTOOPEN', 'SELLTOCLOSE']).describe('Trade action'),
      limitPrice: z.number().optional().describe('Limit price (required for Limit and StopLimit orders)'),
      stopPrice: z.number().optional().describe('Stop price (required for Stop and StopLimit orders)'),
      duration: z.enum(['DAY', 'GTC', 'GTD', 'DYP', 'GCP']).default('DAY').describe('Time in force duration')
    };
  • src/index.ts:702-768 (registration)
    Registers the confirmOrder tool with the MCP server using server.tool(), providing name, description, input schema, and handler function.
    server.tool(
      "confirmOrder",
      "Preview order costs and requirements (READ-ONLY - does not execute trades)",
      confirmOrderSchema,
      async (args) => {
        try {
          const accountId = args.accountId || TS_ACCOUNT_ID;
          const { symbol, quantity, orderType, tradeAction, limitPrice, stopPrice, duration } = args;
    
          if (!accountId) {
            throw new Error('Account ID is required. Either provide accountId parameter or set TRADESTATION_ACCOUNT_ID in .env file.');
          }
    
          // Build order confirmation request body
          const orderData: any = {
            AccountID: accountId,
            Symbol: symbol,
            Quantity: quantity,
            OrderType: orderType,
            TradeAction: tradeAction,
            TimeInForce: {
              Duration: duration
            }
          };
    
          // Add price fields based on order type
          if (orderType === 'Limit' || orderType === 'StopLimit') {
            if (!limitPrice) {
              throw new Error('limitPrice is required for Limit and StopLimit orders');
            }
            orderData.LimitPrice = limitPrice;
          }
    
          if (orderType === 'Stop' || orderType === 'StopLimit') {
            if (!stopPrice) {
              throw new Error('stopPrice is required for Stop and StopLimit orders');
            }
            orderData.StopPrice = stopPrice;
          }
    
          const confirmation = await makeAuthenticatedRequest(
            '/orderexecution/orderconfirm',
            'POST',
            orderData
          );
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(confirmation, null, 2)
              }
            ]
          };
        } catch (error: unknown) {
          return {
            content: [
              {
                type: "text",
                text: `Failed to confirm order: ${error instanceof Error ? error.message : 'Unknown error'}`
              }
            ],
            isError: true
          };
        }
      }
    );
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It clearly states the tool is 'READ-ONLY - does not execute trades,' which is crucial safety information. However, it doesn't mention rate limits, authentication requirements, or what specific 'costs and requirements' are returned in the preview.

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 extremely concise (one sentence plus a parenthetical clarification) and front-loaded with the core purpose. Every word earns its place, with no wasted text or redundancy.

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

Completeness4/5

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

For a tool with 8 parameters, 100% schema coverage, and no output schema, the description provides adequate context about its read-only nature and purpose. However, it could be more complete by hinting at the return format (e.g., 'returns estimated costs and validation results') since there's no output schema.

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?

Schema description coverage is 100%, so the schema already documents all 8 parameters thoroughly with descriptions and enums. The description doesn't add any parameter-specific information beyond what's in the schema, maintaining the baseline score of 3.

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

Purpose5/5

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

The description clearly states the specific action ('Preview order costs and requirements') and resource ('order'), with explicit distinction from actual execution ('READ-ONLY - does not execute trades'). This differentiates it from potential sibling tools that might execute trades.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('Preview order costs and requirements'), implying it's for pre-trade analysis. However, it doesn't explicitly mention when not to use it or name specific alternatives among the sibling tools (like which tools would actually execute trades).

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

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/maven81g/tradestation_mcp'

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