Skip to main content
Glama
Ademscodeisnotsobad

Quant Companion MCP

getHistoricalPrices.ts1.94 kB
/** * MCP Tool: get_historical_prices * * Get historical daily OHLCV data for a symbol. */ import { z } from "zod"; import { getDefaultProvider, OHLCV } from "../marketData"; export const getHistoricalPricesSchema = z.object({ symbol: z.string().describe("Stock/ETF ticker symbol"), start: z.string().describe("Start date in YYYY-MM-DD format"), end: z.string().describe("End date in YYYY-MM-DD format"), }); export type GetHistoricalPricesInput = z.infer<typeof getHistoricalPricesSchema>; export interface GetHistoricalPricesOutput { symbol: string; candles: OHLCV[]; count: number; } export async function getHistoricalPrices( input: GetHistoricalPricesInput ): Promise<GetHistoricalPricesOutput> { const provider = getDefaultProvider(); const start = new Date(input.start); const end = new Date(input.end); if (isNaN(start.getTime())) { throw new Error(`Invalid start date: ${input.start}`); } if (isNaN(end.getTime())) { throw new Error(`Invalid end date: ${input.end}`); } const candles = await provider.getHistoricalOHLCV({ symbol: input.symbol, start, end, interval: "1d", }); return { symbol: input.symbol, candles, count: candles.length, }; } export const getHistoricalPricesDefinition = { name: "get_historical_prices", description: "Get historical daily OHLCV (Open, High, Low, Close, Volume) data for a symbol. Use this for historical volatility calculations, backtesting, and analysis.", inputSchema: { type: "object", properties: { symbol: { type: "string", description: "Stock/ETF ticker symbol (e.g., AAPL, SPY)", }, start: { type: "string", description: "Start date in YYYY-MM-DD format", }, end: { type: "string", description: "End date in YYYY-MM-DD format", }, }, required: ["symbol", "start", "end"], }, };

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/Ademscodeisnotsobad/Quant-Companion-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server