Skip to main content
Glama
maven81g

TradeStation MCP Server

by maven81g

barChart

Retrieve historical price bars and candlestick data for trading symbols to analyze market trends and patterns.

Instructions

Get historical price bars/candles

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesTrading symbol
intervalYesBar interval value (e.g., 1, 5, 15)
unitYesBar interval unit
beginTimeNoBegin time in ISO format (optional)
endTimeNoEnd time in ISO format (optional)
barsBackNoNumber of bars to return (optional)

Implementation Reference

  • Handler function that parses input parameters, constructs the TradeStation API endpoint for bar chart data, authenticates and fetches the historical price bars, and returns the JSON response or error.
    async ({ arguments: args }) => { try { const { symbol, interval, unit, beginTime, endTime, barsBack } = args; const userId = args.userId; // You might need to pass this differently let endpoint = `/marketdata/barcharts/${encodeURIComponent(symbol)}?interval=${interval}&unit=${unit}`; if (beginTime) { endpoint += `&begin=${encodeURIComponent(beginTime)}`; } if (endTime) { endpoint += `&end=${encodeURIComponent(endTime)}`; } if (barsBack) { endpoint += `&barsback=${barsBack}`; } const bars = await makeAuthenticatedRequest(userId, endpoint); return { content: [ { type: "text", text: JSON.stringify(bars, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Failed to fetch bar chart data: ${error.message}` } ], isError: true }; } }
  • Zod schema defining the input parameters for the barChart tool: symbol (required), interval (number), unit (enum), and optional beginTime, endTime, barsBack.
    const barChartSchema = z.object({ symbol: z.string().describe('Trading symbol'), interval: z.number().describe('Bar interval value (e.g., 1, 5, 15)'), unit: z.enum(['Minute', 'Daily', 'Weekly', 'Monthly']).describe('Bar interval unit'), beginTime: z.string().optional().describe('Begin time in ISO format (optional)'), endTime: z.string().optional().describe('End time in ISO format (optional)'), barsBack: z.number().optional().describe('Number of bars to return (optional)') });
  • index.js:458-502 (registration)
    Registers the barChart tool with the MCP server using server.tool(), providing name, description, input schema, and handler function.
    server.tool( "barChart", "Get historical price bars/candles", barChartSchema, async ({ arguments: args }) => { try { const { symbol, interval, unit, beginTime, endTime, barsBack } = args; const userId = args.userId; // You might need to pass this differently let endpoint = `/marketdata/barcharts/${encodeURIComponent(symbol)}?interval=${interval}&unit=${unit}`; if (beginTime) { endpoint += `&begin=${encodeURIComponent(beginTime)}`; } if (endTime) { endpoint += `&end=${encodeURIComponent(endTime)}`; } if (barsBack) { endpoint += `&barsback=${barsBack}`; } const bars = await makeAuthenticatedRequest(userId, endpoint); return { content: [ { type: "text", text: JSON.stringify(bars, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Failed to fetch bar chart data: ${error.message}` } ], isError: true }; } } );
  • TypeScript handler function for barChart tool, similar to JS version, constructs endpoint and fetches data using makeAuthenticatedRequest.
    async (args) => { try { const { symbol, interval, unit, beginTime, endTime, barsBack } = args; let endpoint = `/marketdata/barcharts/${encodeURIComponent(symbol)}?interval=${interval}&unit=${unit}`; if (beginTime) { endpoint += `&begin=${encodeURIComponent(beginTime)}`; } if (endTime) { endpoint += `&end=${encodeURIComponent(endTime)}`; } if (barsBack) { endpoint += `&barsback=${barsBack}`; } const bars = await makeAuthenticatedRequest(endpoint); return { content: [ { type: "text", text: JSON.stringify(bars, null, 2) } ] }; } catch (error: unknown) { return { content: [ { type: "text", text: `Failed to fetch bar chart data: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
  • Input schema object for barChart tool parameters in TypeScript version.
    const barChartSchema = { symbol: z.string().describe('Trading symbol'), interval: z.number().describe('Bar interval value (e.g., 1, 5, 15)'), unit: z.enum(['Minute', 'Daily', 'Weekly', 'Monthly']).describe('Bar interval unit'), beginTime: z.string().optional().describe('Begin time in ISO format (optional)'), endTime: z.string().optional().describe('End time in ISO format (optional)'), barsBack: z.number().optional().describe('Number of bars to return (optional)') };

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