Skip to main content
Glama

get_sectors_overview

Retrieve aggregated performance metrics by sector for specific stock exchanges on chosen dates to analyze market trends and sector performance.

Instructions

Get aggregated performance metrics by sector for an exchange on a specific date.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stockExchangeYesStock exchange: amex, nasdaq, nyse, us-all, lse, moex, bist, hkex
yearNo
monthNo
dayNo
sectorNoGet data for specific sector only

Implementation Reference

  • The asynchronous handler function that implements the core logic of the 'get_sectors_overview' tool. It fetches market data for the specified exchange and date, filters for sector entries, optionally filters by a specific sector, maps the data to a structured format, and returns a response with charts and metrics.
    async ({ stockExchange, year, month, day, sector, }: { stockExchange: StockExchange; year?: number; month?: number; day?: number; sector?: string; }) => { try { const formattedDate = getDate(year, month, day); const marketDataResponse = await fetchMarketData( stockExchange, formattedDate, ); const sectors = marketDataResponse.securities.data .filter( (item: any) => item[INDICES.TYPE] === "sector" && item[INDICES.SECTOR] !== "", ) .filter((item: any) => !sector || item[INDICES.TICKER] === sector) .map((item: any) => ({ name: item[INDICES.TICKER], marketCap: item[INDICES.MARKET_CAP], marketCapChangePct: item[INDICES.PRICE_CHANGE_PCT], volume: item[INDICES.VOLUME], value: item[INDICES.VALUE], numTrades: item[INDICES.NUM_TRADES], itemsPerSector: item[INDICES.ITEMS_PER_SECTOR], })); return createResponse({ info: INFO, charts: createCharts(stockExchange, formattedDate), date: formattedDate, exchange: stockExchange.toUpperCase(), currency: EXCHANGE_INFO[stockExchange as StockExchange].currency, sectors, }); } catch (error) { return createErrorResponse(error); } },
  • The tool metadata including title, description, and inputSchema using Zod for validation of parameters: stockExchange (enum), optional date components (year, month, day), and optional sector string.
    { title: "Sector performance", description: "Get aggregated performance metrics by sector for an exchange on a specific date.", inputSchema: { stockExchange: exchangeSchema, ...dateSchema, sector: z .string() .optional() .describe("Get data for specific sector only"), }, },
  • src/core.ts:548-611 (registration)
    The MCP server registration call for the 'get_sectors_overview' tool, including the tool name, schema/metadata, and handler function reference.
    server.registerTool( "get_sectors_overview", { title: "Sector performance", description: "Get aggregated performance metrics by sector for an exchange on a specific date.", inputSchema: { stockExchange: exchangeSchema, ...dateSchema, sector: z .string() .optional() .describe("Get data for specific sector only"), }, }, async ({ stockExchange, year, month, day, sector, }: { stockExchange: StockExchange; year?: number; month?: number; day?: number; sector?: string; }) => { try { const formattedDate = getDate(year, month, day); const marketDataResponse = await fetchMarketData( stockExchange, formattedDate, ); const sectors = marketDataResponse.securities.data .filter( (item: any) => item[INDICES.TYPE] === "sector" && item[INDICES.SECTOR] !== "", ) .filter((item: any) => !sector || item[INDICES.TICKER] === sector) .map((item: any) => ({ name: item[INDICES.TICKER], marketCap: item[INDICES.MARKET_CAP], marketCapChangePct: item[INDICES.PRICE_CHANGE_PCT], volume: item[INDICES.VOLUME], value: item[INDICES.VALUE], numTrades: item[INDICES.NUM_TRADES], itemsPerSector: item[INDICES.ITEMS_PER_SECTOR], })); return createResponse({ info: INFO, charts: createCharts(stockExchange, formattedDate), date: formattedDate, exchange: stockExchange.toUpperCase(), currency: EXCHANGE_INFO[stockExchange as StockExchange].currency, sectors, }); } catch (error) { return createErrorResponse(error); } }, );

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/BACH-AI-Tools/bach-finmap-mcp'

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