Skip to main content
Glama
Ademscodeisnotsobad

Quant Companion MCP

getOptionsChain.ts1.83 kB
/** * MCP Tool: get_options_chain * * Fetch options chain data for a given symbol. */ import { z } from "zod"; import type { OptionsChain } from "@quant-companion/core"; import { getDefaultProvider } from "../marketData"; export const getOptionsChainSchema = z.object({ symbol: z.string().describe("Stock/ETF ticker symbol (e.g., AAPL, SPY)"), expiration: z .string() .optional() .describe("Optional expiration date (ISO format: YYYY-MM-DD). If omitted, returns nearest expiration."), }); export type GetOptionsChainInput = z.infer<typeof getOptionsChainSchema>; export type GetOptionsChainOutput = OptionsChain; export async function getOptionsChain( input: GetOptionsChainInput ): Promise<GetOptionsChainOutput> { const provider = getDefaultProvider(); try { const chain = await provider.getOptionsChain({ symbol: input.symbol, expiration: input.expiration, }); return chain; } catch (error) { const message = error instanceof Error ? error.message : "Unknown error"; throw new Error(`Options chain not found for ${input.symbol}: ${message}`); } } export const getOptionsChainDefinition = { name: "get_options_chain", description: "Fetch options chain data for a given stock/ETF symbol. Returns available expirations, strikes, and option contract details including bid/ask, volume, open interest, and implied volatility where available.", inputSchema: { type: "object", properties: { symbol: { type: "string", description: "Stock/ETF ticker symbol (e.g., AAPL, SPY, NVDA)", }, expiration: { type: "string", description: "Optional expiration date in ISO format (YYYY-MM-DD). If omitted, returns nearest expiration.", }, }, required: ["symbol"], }, };

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/Ademscodeisnotsobad/Quant-Companion-MCP'

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