get_futures_open_interest
Retrieve current open interest data for Binance futures trading pairs to analyze market sentiment and liquidity.
Instructions
Get current open interest for a futures trading pair
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Trading pair symbol (e.g., BTCUSDT) |
Implementation Reference
- src/index.ts:209-221 (handler)The MCP server tool handler that processes calls to 'get_futures_open_interest', validates input using isFuturesDataParams, extracts the symbol, calls the rest connector's getFuturesOpenInterest method, and returns the data as formatted JSON.case "get_futures_open_interest": { if (!isFuturesDataParams(request.params.arguments)) { throw new Error('Invalid futures data parameters'); } const { symbol } = request.params.arguments; const data = await restConnector.getFuturesOpenInterest(symbol); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }
- src/index.ts:80-93 (registration)Tool registration in the ListToolsRequestSchema handler, defining the name, description, and input schema (object with required 'symbol' string).{ name: "get_futures_open_interest", description: "Get current open interest for a futures trading pair", inputSchema: { type: "object", properties: { symbol: { type: "string", description: "Trading pair symbol (e.g., BTCUSDT)" } }, required: ["symbol"] } },
- Core helper method in BinanceRestConnector class that performs the HTTP GET request to Binance futures '/openInterest' endpoint using axios with retry logic, logging, and error handling, returning the raw API response data.public async getFuturesOpenInterest(symbol: string): Promise<any> { try { logger.info(`Getting futures open interest for ${symbol}`); const response = await this.executeWithRetry(() => this.axiosInstance.get(`${config.FUTURES_REST_URL}/openInterest`, { params: { symbol: symbol.toUpperCase() } }) ); logger.info('Successfully fetched open interest data'); return response.data; } catch (error) { logger.error('Error fetching open interest:', error); throw new APIError('Failed to fetch open interest data', error as Error); } }