get-price-change
Analyze cryptocurrency price fluctuations by fetching price change statistics over specific time periods. Input a trading pair symbol and select an exchange to retrieve data for market analysis and trend tracking.
Instructions
Get price change statistics over different time periods
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exchange | No | Exchange to use (supported: binance, coinbase, kraken, kucoin, hyperliquid, huobi, bitfinex, bybit, okx, mexc) | binance |
| symbol | Yes | Trading pair symbol (e.g., BTC/USDT, ETH/USDT) |
Implementation Reference
- src/server.py:307-336 (handler)Executes the get-price-change tool: fetches current price using fetch_ticker, then computes percentage price changes over 1h, 24h, 7d, and 30d periods using historical OHLCV data from ccxt exchange.elif name == "get-price-change": symbol = arguments.get("symbol", "").upper() # Get current price ticker = await exchange.fetch_ticker(symbol) current_price = ticker['last'] # Get historical prices timeframes = { "1h": (1, "1h"), "24h": (1, "1d"), "7d": (7, "1d"), "30d": (30, "1d") } changes = [] for label, (days, timeframe) in timeframes.items(): since = int((datetime.now() - timedelta(days=days)).timestamp() * 1000) ohlcv = await exchange.fetch_ohlcv(symbol, timeframe, since=since, limit=1) if ohlcv: start_price = ohlcv[0][1] # Open price change_pct = ((current_price - start_price) / start_price) * 100 changes.append(f"{label} change: {change_pct:+.2f}%") return [ types.TextContent( type="text", text=f"Price changes for {symbol} on {exchange_id.upper()}:\n\n" + "\n".join(changes) ) ]
- src/server.py:185-199 (registration)Registers the get-price-change tool in the MCP server with its input schema, including symbol (required) and optional exchange.types.Tool( name="get-price-change", description="Get price change statistics over different time periods", inputSchema={ "type": "object", "properties": { "symbol": { "type": "string", "description": "Trading pair symbol (e.g., BTC/USDT, ETH/USDT)", }, "exchange": get_exchange_schema() }, "required": ["symbol"], }, ),