compare_companies
Analyze and compare multiple companies across financial, governance, and market performance metrics to evaluate relationships in the Spanish stock exchange.
Instructions
Compare multiple companies across various metrics (financial, governance, market performance)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| companies | Yes | List of company symbols or names to compare | |
| metrics | No | Metrics to compare (defaults to all if not specified) |
Implementation Reference
- src/analytics.ts:314-358 (handler)Core handler implementing company comparison by fetching comprehensive data (financials, governance, market performance, news) for each company and generating analytical summary and investment recommendations.async compareCompanies(companies: string[], metrics: string[] = ['all']): Promise<any> { try { const companyData = []; for (const companyInput of companies) { try { const company = await this.db.getCompanyBySymbol(companyInput); if (company) { const directors = await this.db.getCompanyDirectors(company.id); const shareholders = await this.db.getCompanyShareholders(company.id); const historical = await this.db.getHistoricalPrices(company.id, 30); const news = await this.db.getRecentNews(company.id, 5); companyData.push({ basic_info: company, directors: directors.length, shareholders: shareholders.length, recent_performance: historical.length > 1 ? this.calculatePerformance(historical) : null, news_coverage: news.length, risk_profile: this.assessCompanyRisk(company, directors) }); } } catch (error) { companyData.push({ symbol: companyInput, error: `Could not find or analyze company: ${error}` }); } } // Generate comparison analysis const comparison = { companies_compared: companyData.length, comparison_date: new Date().toISOString(), metrics_analyzed: metrics, detailed_comparison: companyData, summary: this.generateComparisonSummary(companyData), recommendations: this.generateComparisonRecommendations(companyData) }; return comparison; } catch (error) { throw new Error(`Company comparison failed: ${error}`); } }
- src/index.ts:379-404 (schema)Input schema definition for the compare_companies tool, specifying required companies array and optional metrics enum.{ name: 'compare_companies', description: 'Compare multiple companies across various metrics (financial, governance, market performance)', inputSchema: { type: 'object', properties: { companies: { type: 'array', items: { type: 'string', }, description: 'List of company symbols or names to compare', }, metrics: { type: 'array', items: { type: 'string', enum: ['financial', 'governance', 'market_performance', 'sector_position', 'risk_profile', 'all'], }, description: 'Metrics to compare (defaults to all if not specified)', default: ['all'], }, }, required: ['companies'], }, },
- src/index.ts:661-663 (registration)Tool registration in the CallToolRequestSchema handler switch statement, dispatching calls to the analytics manager's compareCompanies method.case 'compare_companies': result = await this.analytics.compareCompanies((args as any)?.companies, (args as any)?.metrics || ['all']); break;