get_market_momentum
Retrieve NYSE and NASDAQ market breadth data including advancing/declining issues, new highs/lows, and percent advancing for a given date or range. Assess whether market breadth is strong.
Instructions
Return NYSE and NASDAQ market breadth data — advancing/declining issues, new highs/lows, percent advancing. Use when the user asks 'how's the market today' or 'is breadth strong'. Default (no params): last 7 trading days. Returns { dates, count, data: [{exchange, advancing_issues, declining_issues, new_highs, new_lows, percent_advancing_issues, data_date}] }. Two rows per date (NYSE + NASDAQ). Tier: Basic+.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | Single day (YYYY-MM-DD) | |
| date_from | No | Range start | |
| date_to | No | Range end |
Implementation Reference
- src/tools/marketMomentum.ts:24-37 (handler)The handler function that executes the get_market_momentum tool logic. Parses input with Zod schema, creates a cache key, and delegates to ctx.apiClient.get('/market-momentum') with optional date params.
export async function handleGetMarketMomentum( ctx: McpContext, rawArgs: unknown ): Promise<unknown> { const args = GetMarketMomentumInputSchema.parse(rawArgs); const key = `market-momentum:${args.date || ""}:${args.date_from || ""}:${args.date_to || ""}`; return ctx.cache.wrap(key, 300_000, () => ctx.apiClient.get("/market-momentum", { date: args.date, date_from: args.date_from, date_to: args.date_to, }) ); } - src/tools/marketMomentum.ts:8-12 (schema)Zod input schema for get_market_momentum tool: optional date, date_from, date_to fields all validated as YYYY-MM-DD format strings.
export const GetMarketMomentumInputSchema = z.object({ date: z.string().regex(dateRegex).optional().describe("Single day (YYYY-MM-DD)"), date_from: z.string().regex(dateRegex).optional().describe("Range start"), date_to: z.string().regex(dateRegex).optional().describe("Range end"), }); - src/tools/marketMomentum.ts:14-21 (registration)Tool definition object with name='get_market_momentum', description, inputSchema, and annotations. Exported as part of marketMomentumTools array.
export const marketMomentumTools: Tool[] = [ { name: "get_market_momentum", description: "Return NYSE and NASDAQ market breadth data — advancing/declining issues, new highs/lows, percent advancing. Use when the user asks 'how's the market today' or 'is breadth strong'. Default (no params): last 7 trading days. Returns { dates, count, data: [{exchange, advancing_issues, declining_issues, new_highs, new_lows, percent_advancing_issues, data_date}] }. Two rows per date (NYSE + NASDAQ). Tier: Basic+.", inputSchema: z.toJSONSchema(GetMarketMomentumInputSchema) as Tool["inputSchema"], annotations: READ_ONLY_ANNOTATIONS, }, - src/tools/index.ts:51-61 (registration)The tool is registered in the ALL_TOOLS array (line 58) and its handler is mapped in the HANDLERS record (line 85). registerAllTools() registers all tools with the MCP server via ListToolsRequestSchema and CallToolRequestSchema.
const ALL_TOOLS: Tool[] = [ PING_TOOL, ...screenersTools, ...patternsTools, ...optionsFlowTools, ...stockTools, ...compositeTools, ...marketMomentumTools, ...trendsTools, ...educationTools, ]; - src/context.ts:8-11 (helper)McpContext interface providing apiClient (used to make the HTTP request) and cache (used to wrap/responses with a 300s TTL).
export interface McpContext { apiClient: ApiClient; cache: TtlCache; }