Skip to main content
Glama
maven81g

TradeStation MCP Server

by maven81g

getOrders

Retrieve order history from TradeStation accounts with status filtering options to track trading activity.

Instructions

Get order history with optional status filter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdNoAccount ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided)
statusNoFilter orders by statusAll

Implementation Reference

  • Handler function that fetches account orders from TradeStation API, optionally filtering by status (Open, Filled, etc.). Uses makeAuthenticatedRequest helper.
    async (args) => { try { const accountId = args.accountId || TS_ACCOUNT_ID; const { status } = args; if (!accountId) { throw new Error('Account ID is required. Either provide accountId parameter or set TRADESTATION_ACCOUNT_ID in .env file.'); } let endpoint = `/brokerage/accounts/${encodeURIComponent(accountId)}/orders`; if (status && status !== 'All') { endpoint += `?status=${status}`; } const orders = await makeAuthenticatedRequest(endpoint); return { content: [ { type: "text", text: JSON.stringify(orders, null, 2) } ] }; } catch (error: unknown) { return { content: [ { type: "text", text: `Failed to fetch orders: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
  • Input schema for getOrders tool using Zod validation: optional accountId and status filter (defaults to 'All').
    const ordersSchema = { accountId: z.string().optional().describe('Account ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided)'), status: z.enum(['Open', 'Filled', 'Canceled', 'Rejected', 'All']) .default('All') .describe('Filter orders by status') };
  • src/index.ts:547-588 (registration)
    MCP server registration of the 'getOrders' tool with description, schema reference, and inline handler function.
    server.tool( "getOrders", "Get order history with optional status filter", ordersSchema, async (args) => { try { const accountId = args.accountId || TS_ACCOUNT_ID; const { status } = args; if (!accountId) { throw new Error('Account ID is required. Either provide accountId parameter or set TRADESTATION_ACCOUNT_ID in .env file.'); } let endpoint = `/brokerage/accounts/${encodeURIComponent(accountId)}/orders`; if (status && status !== 'All') { endpoint += `?status=${status}`; } const orders = await makeAuthenticatedRequest(endpoint); return { content: [ { type: "text", text: JSON.stringify(orders, null, 2) } ] }; } catch (error: unknown) { return { content: [ { type: "text", text: `Failed to fetch orders: ${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