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 }; } } );

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