get_historical_prices
Retrieve historical stock price data for companies on the Spanish stock exchange to analyze market trends and performance over time.
Instructions
Get historical price data for a company
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| companyId | Yes | Company ID | |
| days | No | Number of days of historical data |
Implementation Reference
- src/database.ts:203-215 (handler)Core implementation of getHistoricalPrices: resolves companyId to symbol, fetches historical price data from API endpoint '/api/historical-prices/company', returns historicalData array.async getHistoricalPrices(companyId: string, days: number = 30): Promise<any[]> { // Find company symbol from ID const companies = await this.getAllCompanies(); const company = companies.find(c => c.id === companyId); if (!company) return []; const data = await this.fetchAPI('/api/historical-prices/company', { symbol: company.symbol, days: days }); return data.historicalData || []; }
- src/index.ts:187-205 (registration)Tool registration in the ListToolsRequestSchema handler: defines name, description, and input schema.{ name: 'get_historical_prices', description: 'Get historical price data for a company', inputSchema: { type: 'object', properties: { companyId: { type: 'string', description: 'Company ID', }, days: { type: 'number', description: 'Number of days of historical data', default: 30, }, }, required: ['companyId'], }, },
- src/index.ts:617-619 (handler)Dispatch in CallToolRequestSchema handler: calls the database getHistoricalPrices method with parsed arguments.case 'get_historical_prices': result = await this.db.getHistoricalPrices((args as any)?.companyId, (args as any)?.days || 30); break;
- src/index.ts:190-204 (schema)Input schema definition for the tool: specifies companyId (required string) and optional days (number, default 30).inputSchema: { type: 'object', properties: { companyId: { type: 'string', description: 'Company ID', }, days: { type: 'number', description: 'Number of days of historical data', default: 30, }, }, required: ['companyId'], },