get_historical_chart
Retrieve historical stock price data with customizable time intervals to analyze market trends and performance over specific periods.
Instructions
Get historical price data with flexible time intervals
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Stock ticker symbol | |
| interval | Yes | Time interval | |
| from | No | Start date in YYYY-MM-DD format (optional) | |
| to | No | End date in YYYY-MM-DD format (optional) |
Implementation Reference
- src/tools/technical.ts:91-108 (handler)The 'get_historical_chart' tool is registered and implemented here, using the HistoricalChartSchema for input validation and calling fetchFMP to retrieve data.
server.registerTool( 'get_historical_chart', { description: 'Get historical price data with flexible time intervals', inputSchema: HistoricalChartSchema, }, async (args: z.infer<typeof HistoricalChartSchema>) => { try { let endpoint = `/historical-chart/${args.interval}?symbol=${args.symbol.toUpperCase()}`; if (args.from) endpoint += `&from=${args.from}`; if (args.to) endpoint += `&to=${args.to}`; const data = await fetchFMP<HistoricalPrice[]>(endpoint); return jsonResponse(data); } catch (error) { return errorResponse(error); } } ); - src/tools/technical.ts:19-24 (schema)Validation schema for the input arguments of the get_historical_chart tool.
const HistoricalChartSchema = z.object({ symbol: z.string().describe('Stock ticker symbol'), interval: IntervalSchema.describe('Time interval'), from: z.string().optional().describe('Start date in YYYY-MM-DD format (optional)'), to: z.string().optional().describe('End date in YYYY-MM-DD format (optional)'), }); - src/tools/technical.ts:29-109 (registration)Tool registration function that includes the get_historical_chart tool definition.
export function registerTechnicalTools(server: any) { // RSI server.registerTool( 'get_technical_indicator_rsi', { description: 'Get Relative Strength Index (RSI) technical indicator', inputSchema: TechnicalIndicatorSchema, }, async (args: z.infer<typeof TechnicalIndicatorSchema>) => { try { const period = args.period || 14; const data = await fetchFMP<TechnicalIndicator[]>( `/technical-indicators/rsi?symbol=${args.symbol.toUpperCase()}&timeframe=${args.timeframe}&periodLength=${period}` ); return jsonResponse(data); } catch (error) { return errorResponse(error); } } ); // SMA server.registerTool( 'get_technical_indicator_sma', { description: 'Get Simple Moving Average (SMA) technical indicator', inputSchema: TechnicalIndicatorSchema, }, async (args: z.infer<typeof TechnicalIndicatorSchema>) => { try { const period = args.period || 10; const data = await fetchFMP<TechnicalIndicator[]>( `/technical-indicators/sma?symbol=${args.symbol.toUpperCase()}&timeframe=${args.timeframe}&periodLength=${period}` ); return jsonResponse(data); } catch (error) { return errorResponse(error); } } ); // EMA server.registerTool( 'get_technical_indicator_ema', { description: 'Get Exponential Moving Average (EMA) technical indicator', inputSchema: TechnicalIndicatorSchema, }, async (args: z.infer<typeof TechnicalIndicatorSchema>) => { try { const period = args.period || 10; const data = await fetchFMP<TechnicalIndicator[]>( `/technical-indicators/ema?symbol=${args.symbol.toUpperCase()}&timeframe=${args.timeframe}&periodLength=${period}` ); return jsonResponse(data); } catch (error) { return errorResponse(error); } } ); // Historical Chart server.registerTool( 'get_historical_chart', { description: 'Get historical price data with flexible time intervals', inputSchema: HistoricalChartSchema, }, async (args: z.infer<typeof HistoricalChartSchema>) => { try { let endpoint = `/historical-chart/${args.interval}?symbol=${args.symbol.toUpperCase()}`; if (args.from) endpoint += `&from=${args.from}`; if (args.to) endpoint += `&to=${args.to}`; const data = await fetchFMP<HistoricalPrice[]>(endpoint); return jsonResponse(data); } catch (error) { return errorResponse(error); } } ); }