assess_investment_risk
Analyze market, governance, and operational risks for companies or sectors in the Spanish stock exchange to inform investment decisions.
Instructions
Comprehensive risk assessment for companies or sectors including market, governance, and operational risks
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| risk_types | No | Types of risk to assess | |
| target | Yes | Company symbol, sector name, or portfolio of companies |
Implementation Reference
- src/analytics.ts:428-490 (handler)Core handler function that performs comprehensive investment risk assessment by evaluating multiple risk categories (market, governance, sector, liquidity, concentration) and computing an overall risk score.async assessInvestmentRisk(target: string, riskTypes: string[] = ['all']): Promise<any> { try { const riskAssessment = { target: target, assessment_date: new Date().toISOString(), risk_types_analyzed: riskTypes, overall_risk_score: 0, risk_breakdown: {}, recommendations: [] }; // Try to determine if target is a company, sector, or portfolio let targetType = 'unknown'; let targetData = null; try { targetData = await this.db.getCompanyBySymbol(target); targetType = 'company'; } catch { try { targetData = await this.db.getCompaniesBySector(target); targetType = 'sector'; } catch { // Assume it's a portfolio or custom target targetType = 'portfolio'; } } // Initialize risk_breakdown as any to allow dynamic property assignment const riskBreakdown: any = {}; // Assess different risk types if (riskTypes.includes('all') || riskTypes.includes('market_risk')) { riskBreakdown.market_risk = await this.assessMarketRisk(targetData, targetType); } if (riskTypes.includes('all') || riskTypes.includes('governance_risk')) { riskBreakdown.governance_risk = await this.assessGovernanceRisk(targetData, targetType); } if (riskTypes.includes('all') || riskTypes.includes('sector_risk')) { riskBreakdown.sector_risk = await this.assessSectorRisk(targetData, targetType); } if (riskTypes.includes('all') || riskTypes.includes('liquidity_risk')) { riskBreakdown.liquidity_risk = await this.assessLiquidityRisk(targetData, targetType); } if (riskTypes.includes('all') || riskTypes.includes('concentration_risk')) { riskBreakdown.concentration_risk = await this.assessConcentrationRisk(targetData, targetType); } riskAssessment.risk_breakdown = riskBreakdown; // Calculate overall risk score riskAssessment.overall_risk_score = this.calculateOverallRiskScore(riskAssessment.risk_breakdown); riskAssessment.recommendations = this.generateRiskRecommendations(riskAssessment.risk_breakdown); return riskAssessment; } catch (error) { throw new Error(`Risk assessment failed: ${error}`); } }
- src/index.ts:435-456 (schema)MCP tool schema definition including input validation for target and optional risk_types array.name: 'assess_investment_risk', description: 'Comprehensive risk assessment for companies or sectors including market, governance, and operational risks', inputSchema: { type: 'object', properties: { target: { type: 'string', description: 'Company symbol, sector name, or portfolio of companies', }, risk_types: { type: 'array', items: { type: 'string', enum: ['market_risk', 'governance_risk', 'sector_risk', 'liquidity_risk', 'concentration_risk', 'all'], }, description: 'Types of risk to assess', default: ['all'], }, }, required: ['target'], }, },
- src/index.ts:674-676 (registration)Tool registration and dispatch handler in the MCP CallToolRequest switch statement, delegating to AnalyticsManager.assessInvestmentRisk.case 'assess_investment_risk': result = await this.analytics.assessInvestmentRisk((args as any)?.target, (args as any)?.risk_types || ['all']); break;
- src/analytics.ts:877-884 (helper)Helper method providing stubbed market risk assessment data used by the main handler.private async assessMarketRisk(targetData: any, targetType: string): Promise<any> { return { risk_level: 'medium', factors: ['Market volatility', 'Sector concentration'], score: 6.5, recommendations: ['Diversify across sectors', 'Monitor market trends'] }; }
- src/analytics.ts:913-920 (helper)Helper method for concentration risk assessment.private async assessConcentrationRisk(targetData: any, targetType: string): Promise<any> { return { risk_level: 'medium', factors: ['Position size', 'Sector exposure'], score: 6.1, recommendations: ['Diversify holdings', 'Limit single position exposure'] }; }