Skip to main content
Glama

get_top_performers

Identify top-performing stocks in the Spanish stock exchange over a specified period to inform investment decisions.

Instructions

Get top performing stocks over a specified period

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNoPeriod in days
limitNoMaximum number of results

Implementation Reference

  • The core handler function that implements get_top_performers by fetching all companies, retrieving historical prices for the top 20, calculating percentage change over the specified days, sorting by performance, and returning the top limit performers.
    async getTopPerformers(days: number = 7, limit: number = 10): Promise<any[]> {
      const companies = await this.getAllCompanies();
      
      // Get recent performance data for each company
      const performances = [];
      for (const company of companies.slice(0, 20)) { // Limit to avoid too many requests
        try {
          const historical = await this.getHistoricalPrices(company.id, days);
          if (historical.length >= 2) {
            const recent = historical[0];
            const old = historical[historical.length - 1];
            const changePercent = ((recent.close - old.close) / old.close) * 100;
            
            performances.push({
              symbol: company.symbol,
              name: company.name,
              sector: company.sector,
              current_price: recent.close,
              period_change: changePercent
            });
          }
        } catch (error) {
          // Skip companies with no data
          continue;
        }
      }
    
      return performances
        .sort((a, b) => b.period_change - a.period_change)
        .slice(0, limit);
    }
  • The tool schema definition including name, description, and input schema for parameters 'days' (default 7) and 'limit' (default 10), registered in the ListTools handler.
    {
      name: 'get_top_performers',
      description: 'Get top performing stocks over a specified period',
      inputSchema: {
        type: 'object',
        properties: {
          days: {
            type: 'number',
            description: 'Period in days',
            default: 7,
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results',
            default: 10,
          },
        },
      },
    },
  • src/index.ts:621-623 (registration)
    The registration/dispatcher in the CallToolRequest handler that routes calls to get_top_performers to the DatabaseManager's getTopPerformers method.
    case 'get_top_performers':
      result = await this.db.getTopPerformers((args as any)?.days || 7, (args as any)?.limit || 10);
      break;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/anbrme/ibex35-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server