getExecutions
Retrieve order execution details and fill information for specific trades placed through the TradeStation trading platform.
Instructions
Get fills/executions for a specific order
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | No | Account ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided) | |
| orderId | Yes | Order ID |
Input Schema (JSON Schema)
{
"properties": {
"accountId": {
"description": "Account ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided)",
"type": "string"
},
"orderId": {
"description": "Order ID",
"type": "string"
}
},
"required": [
"orderId"
],
"type": "object"
}
Implementation Reference
- src/index.ts:629-666 (handler)Full implementation of the getExecutions tool handler, registered via server.tool. Fetches order executions from the TradeStation brokerage API endpoint `/brokerage/accounts/{accountId}/orders/{orderId}/executions` using the shared makeAuthenticatedRequest helper.server.tool( "getExecutions", "Get fills/executions for a specific order", executionsSchema, async (args) => { try { const accountId = args.accountId || TS_ACCOUNT_ID; const { orderId } = args; if (!accountId) { throw new Error('Account ID is required. Either provide accountId parameter or set TRADESTATION_ACCOUNT_ID in .env file.'); } const executions = await makeAuthenticatedRequest( `/brokerage/accounts/${encodeURIComponent(accountId)}/orders/${encodeURIComponent(orderId)}/executions` ); return { content: [ { type: "text", text: JSON.stringify(executions, null, 2) } ] }; } catch (error: unknown) { return { content: [ { type: "text", text: `Failed to fetch executions: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } );
- src/index.ts:124-127 (schema)Zod schema defining input parameters for the getExecutions tool: optional accountId and required orderId.const executionsSchema = { accountId: z.string().optional().describe('Account ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided)'), orderId: z.string().describe('Order ID') };
- src/index.ts:629-666 (registration)Registration of the getExecutions tool on the MCP server using server.tool method, specifying name, description, input schema, and handler function.server.tool( "getExecutions", "Get fills/executions for a specific order", executionsSchema, async (args) => { try { const accountId = args.accountId || TS_ACCOUNT_ID; const { orderId } = args; if (!accountId) { throw new Error('Account ID is required. Either provide accountId parameter or set TRADESTATION_ACCOUNT_ID in .env file.'); } const executions = await makeAuthenticatedRequest( `/brokerage/accounts/${encodeURIComponent(accountId)}/orders/${encodeURIComponent(orderId)}/executions` ); return { content: [ { type: "text", text: JSON.stringify(executions, null, 2) } ] }; } catch (error: unknown) { return { content: [ { type: "text", text: `Failed to fetch executions: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } );