getCOTAnalysis
Analyze Commitment of Traders (COT) reports for a commodity and date range to evaluate market sentiment, dynamics, and potential reversals.
Instructions
Gain in-depth insights into market sentiment with the FMP COT Report Analysis API. Analyze the Commitment of Traders (COT) reports for a specific date range to evaluate market dynamics, sentiment, and potential reversals across various sectors.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Commodity symbol | |
| from_date | No | Optional start date (YYYY-MM-DD) | |
| to | No | Optional end date (YYYY-MM-DD) |
Implementation Reference
- src/tools/cot.ts:49-82 (handler)The tool handler for 'getCOTAnalysis'. Registers the tool with schema (symbol, from_date, to) and implements the async handler that calls cotClient.getAnalysis().
server.tool( "getCOTAnalysis", "Gain in-depth insights into market sentiment with the FMP COT Report Analysis API. Analyze the Commitment of Traders (COT) reports for a specific date range to evaluate market dynamics, sentiment, and potential reversals across various sectors.", { symbol: z.string().describe("Commodity symbol"), from_date: z .string() .optional() .describe("Optional start date (YYYY-MM-DD)"), to: z .string() .optional() .describe("Optional end date (YYYY-MM-DD)"), }, async ({ symbol, from_date: from, to }) => { try { const results = await cotClient.getAnalysis(symbol, from, to); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } } - src/api/cot/COTClient.ts:35-49 (helper)The COTClient.getAnalysis() method that calls the FMP API endpoint '/commitment-of-traders-analysis' with symbol, from, to parameters.
async getAnalysis( symbol: string, from?: string, to?: string, options?: { signal?: AbortSignal; context?: FMPContext; } ): Promise<COTAnalysis[]> { return super.get<COTAnalysis[]>( "/commitment-of-traders-analysis", { symbol, from, to }, options ); } - src/api/cot/types.ts:132-149 (schema)The COTAnalysis interface defining the return type from getAnalysis(). Contains fields: symbol, date, name, sector, exchange, long/short market situation, net position, market sentiment, and reversal trend.
export interface COTAnalysis { symbol: string; date: string; name: string; sector: string; exchange: string; currentLongMarketSituation: number; currentShortMarketSituation: number; marketSituation: string; previousLongMarketSituation: number; previousShortMarketSituation: number; previousMarketSituation: string; netPostion: number; previousNetPosition: number; changeInNetPosition: number; marketSentiment: string; reversalTrend: boolean; } - src/toolception-adapters/coreModuleAdapters.ts:22-33 (registration)Registration of the cot module (which includes getCOTAnalysis) via createModuleAdapter('cot', registerCOTTools) in the CORE_MODULE_ADAPTERS registry.
export const CORE_MODULE_ADAPTERS: Record<string, ModuleLoader> = { search: createModuleAdapter('search', registerSearchTools), directory: createModuleAdapter('directory', registerDirectoryTools), analyst: createModuleAdapter('analyst', registerAnalystTools), calendar: createModuleAdapter('calendar', registerCalendarTools), chart: createModuleAdapter('chart', registerChartTools), company: createModuleAdapter('company', registerCompanyTools), cot: createModuleAdapter('cot', registerCOTTools), esg: createModuleAdapter('esg', registerESGTools), economics: createModuleAdapter('economics', registerEconomicsTools), dcf: createModuleAdapter('dcf', registerDCFTools), }; - src/tools/cot.ts:10-108 (registration)The registerCOTTools function that registers all COT-related tools on the MCP server, including getCOTAnalysis (line 50).
export function registerCOTTools(server: McpServer, accessToken?: string): void { const cotClient = new COTClient(accessToken); server.tool( "getCOTReports", "Access comprehensive Commitment of Traders (COT) reports with the FMP COT Report API. This API provides detailed information about long and short positions across various sectors, helping you assess market sentiment and track positions in commodities, indices, and financial instruments.", { symbol: z.string().describe("Commodity symbol"), from_date: z .string() .optional() .describe("Optional start date (YYYY-MM-DD)"), to: z .string() .optional() .describe("Optional end date (YYYY-MM-DD)"), }, async ({ symbol, from_date: from, to }) => { try { const results = await cotClient.getReports(symbol, from, to); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } } ); server.tool( "getCOTAnalysis", "Gain in-depth insights into market sentiment with the FMP COT Report Analysis API. Analyze the Commitment of Traders (COT) reports for a specific date range to evaluate market dynamics, sentiment, and potential reversals across various sectors.", { symbol: z.string().describe("Commodity symbol"), from_date: z .string() .optional() .describe("Optional start date (YYYY-MM-DD)"), to: z .string() .optional() .describe("Optional end date (YYYY-MM-DD)"), }, async ({ symbol, from_date: from, to }) => { try { const results = await cotClient.getAnalysis(symbol, from, to); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } } ); server.tool("getCOTList", "Access a comprehensive list of available Commitment of Traders (COT) reports by commodity or futures contract using the FMP COT Report List API. This API provides an overview of different market segments, allowing users to retrieve and explore COT reports for a wide variety of commodities and financial instruments.", {}, async () => { try { const results = await cotClient.getList(); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } }); }