get_top_shareholders_by_sector
Identify key investors in a specific sector of the Spanish stock exchange by retrieving top shareholders for sector analysis and investment research.
Instructions
Get top shareholders in a specific sector
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sector | Yes | Sector name | |
| limit | No | Maximum number of results |
Implementation Reference
- src/database.ts:153-166 (handler)Core handler function that implements the tool logic: fetches companies in the sector, retrieves all shareholder positions, filters to sector companies, sorts by ownership percentage descending, and limits results.async getTopShareholdersBySector(sector: string, limit: number = 10): Promise<any[]> { const companies = await this.getCompaniesBySector(sector); const data = await this.fetchAPI('/api/shareholder-positions'); const shareholders = data.shareholderPositions || data.positions || []; const sectorSymbols = companies.map(c => c.symbol); const sectorShareholders = shareholders.filter(position => sectorSymbols.includes(position.company_symbol || position.ticker) ); return sectorShareholders .sort((a, b) => (b.percentage || 0) - (a.percentage || 0)) .slice(0, limit); }
- src/index.ts:166-184 (registration)Tool registration in the listTools response, including name, description, and input schema.{ name: 'get_top_shareholders_by_sector', description: 'Get top shareholders in a specific sector', inputSchema: { type: 'object', properties: { sector: { type: 'string', description: 'Sector name', }, limit: { type: 'number', description: 'Maximum number of results', default: 10, }, }, required: ['sector'], }, },
- src/index.ts:613-615 (handler)Dispatch handler in the CallToolRequestSchema switch statement that invokes the database method with parsed arguments.case 'get_top_shareholders_by_sector': result = await this.db.getTopShareholdersBySector((args as any)?.sector, (args as any)?.limit || 10); break;
- src/index.ts:169-182 (schema)Input schema defining parameters: sector (required string), limit (optional number, default 10).inputSchema: { type: 'object', properties: { sector: { type: 'string', description: 'Sector name', }, limit: { type: 'number', description: 'Maximum number of results', default: 10, }, }, required: ['sector'],