Skip to main content
Glama

TradeStation MCP Server

by maven81g

confirmOrder

Preview order costs and requirements before executing trades. Check commission fees, margin requirements, and order validation for stocks and options without placing actual trades.

Instructions

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

Input 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

Input Schema (JSON Schema)

{ "properties": { "accountId": { "description": "Account ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided)", "type": "string" }, "duration": { "default": "DAY", "description": "Time in force duration", "enum": [ "DAY", "GTC", "GTD", "DYP", "GCP" ], "type": "string" }, "limitPrice": { "description": "Limit price (required for Limit and StopLimit orders)", "type": "number" }, "orderType": { "description": "Order type", "enum": [ "Market", "Limit", "Stop", "StopLimit" ], "type": "string" }, "quantity": { "description": "Order quantity", "type": "number" }, "stopPrice": { "description": "Stop price (required for Stop and StopLimit orders)", "type": "number" }, "symbol": { "description": "Symbol to trade (e.g., SPY, SPY 251121C580)", "type": "string" }, "tradeAction": { "description": "Trade action", "enum": [ "BUY", "SELL", "BUYTOOPEN", "BUYTOCLOSE", "SELLTOOPEN", "SELLTOCLOSE" ], "type": "string" } }, "required": [ "symbol", "quantity", "orderType", "tradeAction" ], "type": "object" }

Implementation Reference

  • Handler function for the confirmOrder tool. Builds the order data payload and makes a POST request to TradeStation's /orderexecution/orderconfirm endpoint to preview order costs and requirements without executing the trade.
    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 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-769 (registration)
    Registration of the confirmOrder tool using McpServer.tool() method, specifying 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