Skip to main content
Glama

TradeStation MCP Server

by maven81g

getBalances

Retrieve account balances and available buying power to monitor your trading capital and make informed investment decisions.

Instructions

Get account balances and buying power

Input Schema

NameRequiredDescriptionDefault
accountIdNoAccount ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided)

Input Schema (JSON Schema)

{ "properties": { "accountId": { "description": "Account ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided)", "type": "string" } }, "type": "object" }

Implementation Reference

  • The handler function that executes the getBalances tool logic, fetching account balances from the TradeStation API endpoint `/brokerage/accounts/{accountId}/balances` using the shared makeAuthenticatedRequest helper.
    async (args) => { try { const accountId = args.accountId || TS_ACCOUNT_ID; if (!accountId) { throw new Error('Account ID is required. Either provide accountId parameter or set TRADESTATION_ACCOUNT_ID in .env file.'); } const balances = await makeAuthenticatedRequest( `/brokerage/accounts/${encodeURIComponent(accountId)}/balances` ); return { content: [ { type: "text", text: JSON.stringify(balances, null, 2) } ] }; } catch (error: unknown) { return { content: [ { type: "text", text: `Failed to fetch balances: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
  • The Zod schema defining the input parameters for the getBalances tool, including optional accountId.
    const balancesSchema = { accountId: z.string().optional().describe('Account ID (optional, uses TRADESTATION_ACCOUNT_ID from env if not provided)') };
  • src/index.ts:471-507 (registration)
    The registration of the getBalances tool using server.tool(), including name, description, schema, and handler function.
    server.tool( "getBalances", "Get account balances and buying power", balancesSchema, async (args) => { try { const accountId = args.accountId || TS_ACCOUNT_ID; if (!accountId) { throw new Error('Account ID is required. Either provide accountId parameter or set TRADESTATION_ACCOUNT_ID in .env file.'); } const balances = await makeAuthenticatedRequest( `/brokerage/accounts/${encodeURIComponent(accountId)}/balances` ); return { content: [ { type: "text", text: JSON.stringify(balances, null, 2) } ] }; } catch (error: unknown) { return { content: [ { type: "text", text: `Failed to fetch balances: ${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