get-price-change
Retrieve cryptocurrency price change statistics over various time periods from major exchanges to analyze market trends and performance.
Instructions
Get price change statistics over different time periods
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Trading pair symbol (e.g., BTC/USDT, ETH/USDT) | |
| exchange | No | Exchange to use (supported: binance, coinbase, kraken, kucoin, hyperliquid, huobi, bitfinex, bybit, okx, mexc) | binance |
Implementation Reference
- src/server.py:307-336 (handler)Handler function implementing the logic for the 'get-price-change' tool. Fetches current price and compares it against historical open prices from 1h, 24h, 7d, and 30d periods to calculate percentage changes.
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 (schema)Input schema definition for the 'get-price-change' tool, specifying required 'symbol' and optional 'exchange' parameters.
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"], }, ), - src/server.py:103-221 (registration)The tool is registered within the @server.list_tools() handler by including it in the returned list of available tools.
return [ # Market Data Tools types.Tool( name="get-price", description="Get current price of a cryptocurrency pair from a specific exchange", inputSchema={ "type": "object", "properties": { "symbol": { "type": "string", "description": "Trading pair symbol (e.g., BTC/USDT, ETH/USDT)", }, "exchange": get_exchange_schema() }, "required": ["symbol"], }, ), types.Tool( name="get-market-summary", description="Get detailed market summary for a cryptocurrency pair from a specific exchange", inputSchema={ "type": "object", "properties": { "symbol": { "type": "string", "description": "Trading pair symbol (e.g., BTC/USDT, ETH/USDT)", }, "exchange": get_exchange_schema() }, "required": ["symbol"], }, ), types.Tool( name="get-top-volumes", description="Get top cryptocurrencies by trading volume from a specific exchange", inputSchema={ "type": "object", "properties": { "limit": { "type": "number", "description": "Number of pairs to return (default: 5)", }, "exchange": get_exchange_schema() } }, ), types.Tool( name="list-exchanges", description="List all supported cryptocurrency exchanges", inputSchema={ "type": "object", "properties": {} }, ), # Historical Data Tools types.Tool( name="get-historical-ohlcv", description="Get historical OHLCV (candlestick) data for a trading pair", inputSchema={ "type": "object", "properties": { "symbol": { "type": "string", "description": "Trading pair symbol (e.g., BTC/USDT, ETH/USDT)", }, "timeframe": { "type": "string", "description": "Timeframe for candlesticks (e.g., 1m, 5m, 15m, 1h, 4h, 1d)", "enum": ["1m", "5m", "15m", "1h", "4h", "1d"], "default": "1h" }, "days_back": { "type": "number", "description": "Number of days of historical data to fetch (default: 7, max: 30)", "default": 7, "maximum": 30 }, "exchange": get_exchange_schema() }, "required": ["symbol"], }, ), 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"], }, ), types.Tool( name="get-volume-history", description="Get trading volume history over time", inputSchema={ "type": "object", "properties": { "symbol": { "type": "string", "description": "Trading pair symbol (e.g., BTC/USDT, ETH/USDT)", }, "days": { "type": "number", "description": "Number of days of volume history (default: 7, max: 30)", "default": 7, "maximum": 30 }, "exchange": get_exchange_schema() }, "required": ["symbol"], }, ), ]