get_companies_with_pe_ratio
Filter companies in the Spanish stock exchange by P/E ratio range to identify investment opportunities based on valuation metrics.
Instructions
Get companies filtered by P/E ratio range
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxPE | No | Maximum P/E ratio | |
| minPE | No | Minimum P/E ratio |
Implementation Reference
- src/database.ts:69-79 (handler)Core handler function that implements the tool logic: fetches all companies and filters those within the specified P/E ratio range using client-side filtering.async getCompaniesWithPERatio(minPE?: number, maxPE?: number): Promise<any[]> { const companies = await this.getAllCompanies(); return companies.filter(company => { const pe = company.price_to_earnings || company.pe_ratio; if (pe === null || pe === undefined) return false; if (minPE !== undefined && pe < minPE) return false; if (maxPE !== undefined && pe > maxPE) return false; return true; }); }
- src/index.ts:88-103 (registration)Tool registration including name, description, and input schema definition in the ListToolsRequestSchema handler.name: 'get_companies_with_pe_ratio', description: 'Get companies filtered by P/E ratio range', inputSchema: { type: 'object', properties: { minPE: { type: 'number', description: 'Minimum P/E ratio', }, maxPE: { type: 'number', description: 'Maximum P/E ratio', }, }, }, },
- src/index.ts:589-591 (handler)Dispatch handler in the CallToolRequestSchema switch statement that invokes the database method with parsed arguments.case 'get_companies_with_pe_ratio': result = await this.db.getCompaniesWithPERatio((args as any)?.minPE, (args as any)?.maxPE); break;