Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
37-tool crypto derivatives data suite: funding rates, open interest, liquidations, Hyperliquid whale tracking, and ETF flows.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
coinglass.py.backup2
1"""2Coinglass Tool Wrappers34Wraps tools from /tools/coinglass/ for use in Agent framework.5Provides derivatives data: funding rates, open interest, liquidations, long/short ratios.6"""7import asyncio8import logging9from typing import Any, Dict, Optional1011from core.tool import BaseTool, ToolContext, ToolResult1213logger = logging.getLogger(__name__)1415# Import original tools from local tools directory16try:17from .tools.funding_rate import get_funding_rates, get_symbol_funding_rate18from .tools.long_short_ratio import get_long_short_ratio19from .tools.long_short_advanced import (20get_global_account_ratio,21get_top_account_ratio,22get_top_position_ratio,23get_taker_buysell_exchanges,24get_net_position25)26from .tools.open_interest import get_open_interest, get_open_interest_history27from .tools.liquidations import get_liquidations, get_liquidation_aggregated28from .tools.liquidations_advanced import (29get_coin_liquidation_history,30get_pair_liquidation_history,31get_liquidation_coin_list,32get_liquidation_orders,33get_liquidation_heatmap34)35from .tools.hyperliquid import (36get_whale_alerts,37get_whale_positions,38get_positions_by_coin,39get_user_positions,40get_position_distribution41)42from .tools.futures_market import (43get_supported_coins,44get_supported_exchanges,45get_coins_data,46get_pair_data,47get_ohlc_history48)49from .tools.volume_flow import (50get_taker_volume_history,51get_aggregated_taker_volume,52get_cumulative_volume_delta,53get_coin_netflow,54get_volume_ohlc_history55)56from .tools.whale_transfer import get_whale_transfers57from .tools.bitcoin_etf import (58get_btc_etf_flows,59get_btc_etf_net_assets,60get_btc_etf_premium_discount,61get_btc_etf_history,62get_btc_etf_list,63get_hk_btc_etf_flows64)65from .tools.other_etfs import (66get_eth_etf_flows,67get_eth_etf_list,68get_sol_etf_flows,69get_xrp_etf_flows70)71COINGLASS_AVAILABLE = True72except ImportError as e:73logger.warning(f"Coinglass tools not available: {e}")74COINGLASS_AVAILABLE = False757677class FundingRateTool(BaseTool):78"""79Get perpetual futures funding rates across exchanges.8081Funding rates indicate market sentiment:82- Positive rates: Longs pay shorts (bullish bias)83- Negative rates: Shorts pay longs (bearish bias)84- Extreme rates often precede reversals85"""8687@property88def name(self) -> str:89return "funding_rate"9091@property92def description(self) -> str:93return """Get perpetual futures funding rates across exchanges.9495Positive rates = longs pay shorts (bullish sentiment)96Negative rates = shorts pay longs (bearish sentiment)97Extreme funding often signals reversal risk.9899Examples:100- Get BTC funding rates: funding_rate(symbol="BTC")101- Get ETH funding on Binance: funding_rate(symbol="ETH", exchange="Binance")"""102103@property104def parameters(self) -> dict:105return {106"type": "object",107"properties": {108"symbol": {109"type": "string",110"description": "Symbol (BTC, ETH, SOL, etc.)"111},112"exchange": {113"type": "string",114"description": "Optional: specific exchange (Binance, OKX, Bybit, etc.)"115}116},117"required": ["symbol"]118}119120async def execute(121self,122ctx: ToolContext,123symbol: str,124exchange: Optional[str] = None125) -> ToolResult:126if not COINGLASS_AVAILABLE:127return ToolResult(128success=False,129output=None,130error="Coinglass tools not available. Check if /tools/coinglass exists."131)132133try:134if exchange:135result = await asyncio.to_thread(get_symbol_funding_rate, symbol=symbol, exchange=exchange)136else:137result = await asyncio.to_thread(get_funding_rates, symbol=symbol)138139if result is None:140return ToolResult(141success=False,142output=None,143error="Failed to fetch funding rates. Check COINGLASS_API_KEY."144)145146return ToolResult(success=True, output=result)147except Exception as e:148return ToolResult(success=False, output=None, error=str(e))149150151class LongShortRatioTool(BaseTool):152"""153Get long/short ratio for a cryptocurrency.154155Shows the ratio of long vs short positions across exchanges.156Useful for sentiment analysis.157"""158159@property160def name(self) -> str:161return "long_short_ratio"162163@property164def description(self) -> str:165return """Get long/short position ratio across exchanges.166167Ratio > 1: More longs than shorts168Ratio < 1: More shorts than longs169Extreme ratios often signal crowded trades.170171Examples:172- Get BTC L/S ratio: long_short_ratio(symbol="BTC")173- Get ETH L/S ratio with timeframe: long_short_ratio(symbol="ETH", interval="h4")"""174175@property176def parameters(self) -> dict:177return {178"type": "object",179"properties": {180"symbol": {181"type": "string",182"description": "Symbol (BTC, ETH, SOL, etc.)"183},184"interval": {185"type": "string",186"description": "Time interval: h1, h4, h12, h24",187"default": "h4"188}189},190"required": ["symbol"]191}192193async def execute(194self,195ctx: ToolContext,196symbol: str,197interval: str = "h4"198) -> ToolResult:199if not COINGLASS_AVAILABLE:200return ToolResult(201success=False,202output=None,203error="Coinglass tools not available."204)205206try:207result = await asyncio.to_thread(get_long_short_ratio, symbol=symbol, time_type=interval)208209if result is None:210return ToolResult(211success=False,212output=None,213error="Failed to fetch long/short ratio. Check COINGLASS_API_KEY."214)215216return ToolResult(success=True, output=result)217except Exception as e:218return ToolResult(success=False, output=None, error=str(e))219220221# ==================== Advanced Long/Short Ratio Tools ====================222223class GlobalAccountRatioTool(BaseTool):224"""Get global long/short account ratio history."""225226@property227def name(self) -> str:228return "cg_global_account_ratio"229230@property231def description(self) -> str:232return """Get global long/short account ratio history for a trading pair.233234Shows the percentage of accounts holding long vs short positions over time.235236Examples:237- Get BTC global ratio: cg_global_account_ratio(symbol="BTC", exchange="Binance")238- Get ETH with 4h interval: cg_global_account_ratio(symbol="ETH", exchange="OKX", interval="4h")"""239240@property241def parameters(self) -> dict:242return {243"type": "object",244"properties": {245"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"},246"exchange": {"type": "string", "description": "Exchange name (Binance, OKX, Bybit, etc.)"},247"interval": {"type": "string", "description": "Time interval: 1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w", "default": "1h"},248"limit": {"type": "integer", "description": "Number of results (default: 100)", "default": 100}249},250"required": ["symbol", "exchange"]251}252253async def execute(self, ctx: ToolContext, symbol: str, exchange: str, interval: str = "1h", limit: int = 100) -> ToolResult:254if not COINGLASS_AVAILABLE:255return ToolResult(success=False, output=None, error="Coinglass tools not available.")256257try:258result = await asyncio.to_thread(get_global_account_ratio, symbol, exchange, interval, limit)259if result is None:260return ToolResult(success=False, output=None, error="Failed to fetch global account ratio. Check COINGLASS_API_KEY.")261return ToolResult(success=True, output=result)262except Exception as e:263return ToolResult(success=False, output=None, error=str(e))264265266class TopAccountRatioTool(BaseTool):267"""Get top traders long/short account ratio."""268269@property270def name(self) -> str:271return "cg_top_account_ratio"272273@property274def description(self) -> str:275return """Get long/short account ratio for top traders only.276277Shows what the most successful traders are doing. More reliable than global ratios.278279Examples:280- Get BTC top trader ratio: cg_top_account_ratio(symbol="BTC", exchange="Binance")281- Get ETH 4h: cg_top_account_ratio(symbol="ETH", exchange="OKX", interval="4h")"""282283@property284def parameters(self) -> dict:285return {286"type": "object",287"properties": {288"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"},289"exchange": {"type": "string", "description": "Exchange name (Binance, OKX, Bybit, etc.)"},290"interval": {"type": "string", "description": "Time interval: 1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w", "default": "1h"},291"limit": {"type": "integer", "description": "Number of results (default: 100)", "default": 100}292},293"required": ["symbol", "exchange"]294}295296async def execute(self, ctx: ToolContext, symbol: str, exchange: str, interval: str = "1h", limit: int = 100) -> ToolResult:297if not COINGLASS_AVAILABLE:298return ToolResult(success=False, output=None, error="Coinglass tools not available.")299300try:301result = await asyncio.to_thread(get_top_account_ratio, symbol, exchange, interval, limit)302if result is None:303return ToolResult(success=False, output=None, error="Failed to fetch top account ratio. Check COINGLASS_API_KEY.")304return ToolResult(success=True, output=result)305except Exception as e:306return ToolResult(success=False, output=None, error=str(e))307308309class TopPositionRatioTool(BaseTool):310"""Get top traders long/short position ratio."""311312@property313def name(self) -> str:314return "cg_top_position_ratio"315316@property317def description(self) -> str:318return """Get long/short position ratio for top traders (by position size, not account count).319320Shows the actual $ amount split between longs and shorts for top traders.321322Examples:323- Get BTC top position ratio: cg_top_position_ratio(symbol="BTC", exchange="Binance")324- Get ETH 4h: cg_top_position_ratio(symbol="ETH", exchange="OKX", interval="4h")"""325326@property327def parameters(self) -> dict:328return {329"type": "object",330"properties": {331"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"},332"exchange": {"type": "string", "description": "Exchange name (Binance, OKX, Bybit, etc.)"},333"interval": {"type": "string", "description": "Time interval: 1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w", "default": "1h"},334"limit": {"type": "integer", "description": "Number of results (default: 100)", "default": 100}335},336"required": ["symbol", "exchange"]337}338339async def execute(self, ctx: ToolContext, symbol: str, exchange: str, interval: str = "1h", limit: int = 100) -> ToolResult:340if not COINGLASS_AVAILABLE:341return ToolResult(success=False, output=None, error="Coinglass tools not available.")342343try:344result = await asyncio.to_thread(get_top_position_ratio, symbol, exchange, interval, limit)345if result is None:346return ToolResult(success=False, output=None, error="Failed to fetch top position ratio. Check COINGLASS_API_KEY.")347return ToolResult(success=True, output=result)348except Exception as e:349return ToolResult(success=False, output=None, error=str(e))350351352class TakerBuySellExchangesTool(BaseTool):353"""Get exchanges with taker buy/sell volume data."""354355@property356def name(self) -> str:357return "cg_taker_exchanges"358359@property360def description(self) -> str:361return """Get list of exchanges with taker buy/sell volume data available.362363Shows which exchanges provide taker volume metrics and their current ratios.364365Examples:366- Get BTC exchanges (1h): cg_taker_exchanges(symbol="BTC")367- Get ETH exchanges (24h): cg_taker_exchanges(symbol="ETH", range="24h")"""368369@property370def parameters(self) -> dict:371return {372"type": "object",373"properties": {374"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"},375"range": {"type": "string", "description": "Time range: 1h, 4h, 12h, 24h (default: 1h)", "default": "1h"}376},377"required": ["symbol"]378}379380async def execute(self, ctx: ToolContext, symbol: str, range: str = "1h") -> ToolResult:381if not COINGLASS_AVAILABLE:382return ToolResult(success=False, output=None, error="Coinglass tools not available.")383384try:385result = await asyncio.to_thread(get_taker_buysell_exchanges, symbol, range)386if result is None:387return ToolResult(success=False, output=None, error="Failed to fetch taker exchanges. Check COINGLASS_API_KEY.")388return ToolResult(success=True, output=result)389except Exception as e:390return ToolResult(success=False, output=None, error=str(e))391392393class NetPositionTool(BaseTool):394"""Get net position changes (net long/short delta)."""395396@property397def name(self) -> str:398return "cg_net_position"399400@property401def description(self) -> str:402return """Get historical net position data showing net long/short changes.403404Net position = difference between long and short positions opened.405Useful for tracking institutional positioning.406407Examples:408- Get BTC net position: cg_net_position(symbol="BTC", exchange="Binance")409- Get ETH 4h: cg_net_position(symbol="ETH", exchange="OKX", interval="4h")"""410411@property412def parameters(self) -> dict:413return {414"type": "object",415"properties": {416"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"},417"exchange": {"type": "string", "description": "Exchange name (Binance, OKX, Bybit, etc.)"},418"interval": {"type": "string", "description": "Time interval: 1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w", "default": "1h"},419"limit": {"type": "integer", "description": "Number of results (default: 100)", "default": 100}420},421"required": ["symbol", "exchange"]422}423424async def execute(self, ctx: ToolContext, symbol: str, exchange: str, interval: str = "1h", limit: int = 100) -> ToolResult:425if not COINGLASS_AVAILABLE:426return ToolResult(success=False, output=None, error="Coinglass tools not available.")427428try:429result = await asyncio.to_thread(get_net_position, symbol, exchange, interval, limit)430if result is None:431return ToolResult(success=False, output=None, error="Failed to fetch net position. Check COINGLASS_API_KEY.")432return ToolResult(success=True, output=result)433except Exception as e:434return ToolResult(success=False, output=None, error=str(e))435436437# ==================== Open Interest Tools ====================438439class OpenInterestTool(BaseTool):440"""441Get aggregate open interest across exchanges.442"""443444@property445def name(self) -> str:446return "cg_open_interest"447448@property449def description(self) -> str:450return """Get aggregate open interest across exchanges for a symbol.451452Open interest = total outstanding derivative contracts.453Rising OI + rising price = new money entering (bullish)454Rising OI + falling price = new shorts opening (bearish)455Falling OI = positions closing (trend weakening)456457Examples:458- Get BTC open interest: cg_open_interest(symbol="BTC")459- Get ETH open interest: cg_open_interest(symbol="ETH")"""460461@property462def parameters(self) -> dict:463return {464"type": "object",465"properties": {466"symbol": {467"type": "string",468"description": "Symbol (BTC, ETH, SOL, etc.)"469}470},471"required": ["symbol"]472}473474async def execute(475self,476ctx: ToolContext,477symbol: str478) -> ToolResult:479if not COINGLASS_AVAILABLE:480return ToolResult(481success=False,482output=None,483error="Coinglass tools not available."484)485486try:487result = await asyncio.to_thread(get_open_interest, symbol)488489if result is None:490return ToolResult(491success=False,492output=None,493error="Failed to fetch open interest. Check COINGLASS_API_KEY."494)495496return ToolResult(success=True, output=result)497except Exception as e:498return ToolResult(success=False, output=None, error=str(e))499500501# ==================== Liquidation Tools ====================502503class LiquidationsTool(BaseTool):504"""505Get recent liquidation data.506"""507508@property509def name(self) -> str:510return "cg_liquidations"511512@property513def description(self) -> str:514return """Get recent liquidation data across exchanges.515516Liquidations = forced position closures due to insufficient margin.517More long liquidations = bearish pressure (longs being squeezed)518More short liquidations = bullish pressure (shorts being squeezed)519520Examples:521- Get BTC liquidations (24h): cg_liquidations(symbol="BTC")522- Get ETH liquidations (4h): cg_liquidations(symbol="ETH", time_type="h4")"""523524@property525def parameters(self) -> dict:526return {527"type": "object",528"properties": {529"symbol": {530"type": "string",531"description": "Symbol (BTC, ETH, SOL, etc.)"532},533"time_type": {534"type": "string",535"description": "Time window: h1, h4, h12, h24",536"default": "h24"537}538},539"required": ["symbol"]540}541542async def execute(543self,544ctx: ToolContext,545symbol: str,546time_type: str = "h24"547) -> ToolResult:548if not COINGLASS_AVAILABLE:549return ToolResult(550success=False,551output=None,552error="Coinglass tools not available."553)554555try:556result = await asyncio.to_thread(get_liquidations, symbol, time_type)557558if result is None:559return ToolResult(560success=False,561output=None,562error="Failed to fetch liquidations. Check COINGLASS_API_KEY."563)564565return ToolResult(success=True, output=result)566except Exception as e:567return ToolResult(success=False, output=None, error=str(e))568569570class LiquidationAnalysisTool(BaseTool):571"""572Get liquidation data with sentiment analysis.573"""574575@property576def name(self) -> str:577return "cg_liquidation_analysis"578579@property580def description(self) -> str:581return """Get liquidation data with market sentiment analysis.582583Includes interpretation of liquidation imbalances.584585Examples:586- Analyze BTC liquidations: cg_liquidation_analysis(symbol="BTC")587- Analyze ETH (4h): cg_liquidation_analysis(symbol="ETH", time_type="h4")"""588589@property590def parameters(self) -> dict:591return {592"type": "object",593"properties": {594"symbol": {595"type": "string",596"description": "Symbol (BTC, ETH, SOL, etc.)"597},598"time_type": {599"type": "string",600"description": "Time window: h1, h4, h12, h24",601"default": "h24"602}603},604"required": ["symbol"]605}606607async def execute(608self,609ctx: ToolContext,610symbol: str,611time_type: str = "h24"612) -> ToolResult:613if not COINGLASS_AVAILABLE:614return ToolResult(615success=False,616output=None,617error="Coinglass tools not available."618)619620try:621result = await asyncio.to_thread(get_liquidation_aggregated, symbol, time_type)622623if result is None:624return ToolResult(625success=False,626output=None,627error="Failed to fetch liquidation analysis. Check COINGLASS_API_KEY."628)629630return ToolResult(success=True, output=result)631except Exception as e:632return ToolResult(success=False, output=None, error=str(e))633634635# ==================== Advanced Liquidation Tools ====================636637class CoinLiquidationHistoryTool(BaseTool):638"""Get aggregated liquidation history for a coin across all exchanges."""639640@property641def name(self) -> str:642return "cg_coin_liquidation_history"643644@property645def description(self) -> str:646return """Get aggregated liquidation history across all exchanges for a coin.647648Shows total long/short liquidations over time, aggregated across all exchanges.649650Examples:651- Get BTC liquidation history: cg_coin_liquidation_history(symbol="BTC", interval="1h", limit=100)652- Get ETH 4h intervals: cg_coin_liquidation_history(symbol="ETH", interval="4h", limit=50)"""653654@property655def parameters(self) -> dict:656return {657"type": "object",658"properties": {659"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"},660"exchange_list": {"type": "string", "description": "Comma-separated exchange list (e.g. 'Binance,OKX,Bybit')"},661"interval": {"type": "string", "description": "Time interval: 1m, 3m, 5m, 15m, 30m, 1h, 4h, 6h, 8h, 12h, 1d, 1w", "default": "1h"},662"limit": {"type": "integer", "description": "Number of results (default: 1000, max: 4500)", "default": 1000},663"start_time": {"type": "integer", "description": "Start timestamp in milliseconds"},664"end_time": {"type": "integer", "description": "End timestamp in milliseconds"}665},666"required": ["symbol", "exchange_list"]667}668669async def execute(self, ctx: ToolContext, symbol: str, exchange_list: str, interval: str = "1h", limit: int = 1000,670start_time: Optional[int] = None, end_time: Optional[int] = None) -> ToolResult:671if not COINGLASS_AVAILABLE:672return ToolResult(success=False, output=None, error="Coinglass tools not available.")673674try:675result = await asyncio.to_thread(get_coin_liquidation_history, symbol, exchange_list, interval, limit, start_time, end_time)676if result is None:677return ToolResult(success=False, output=None, error="Failed to fetch coin liquidation history. Check COINGLASS_API_KEY.")678return ToolResult(success=True, output=result)679except Exception as e:680return ToolResult(success=False, output=None, error=str(e))681682683class PairLiquidationHistoryTool(BaseTool):684"""Get liquidation history for a specific trading pair on an exchange."""685686@property687def name(self) -> str:688return "cg_pair_liquidation_history"689690@property691def description(self) -> str:692return """Get liquidation history for a specific pair on a specific exchange.693694Shows long/short liquidations over time for exchange-specific pairs.695696Examples:697- Get BTC/USDT on Binance: cg_pair_liquidation_history(symbol="BTC", exchange="Binance", interval="1h")698- Get ETH/USDT on OKX: cg_pair_liquidation_history(symbol="ETH", exchange="OKX", interval="4h")"""699700@property701def parameters(self) -> dict:702return {703"type": "object",704"properties": {705"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"},706"exchange": {"type": "string", "description": "Exchange name (Binance, OKX, Bybit, etc.)"},707"interval": {"type": "string", "description": "Time interval: 1h, 4h, 12h, 24h", "default": "1h"},708"limit": {"type": "integer", "description": "Number of results (default: 1000, max: 4500)", "default": 1000},709"start_time": {"type": "integer", "description": "Start timestamp in seconds"},710"end_time": {"type": "integer", "description": "End timestamp in seconds"}711},712"required": ["symbol", "exchange"]713}714715async def execute(self, ctx: ToolContext, symbol: str, exchange: str, interval: str = "1h", limit: int = 1000,716start_time: Optional[int] = None, end_time: Optional[int] = None) -> ToolResult:717if not COINGLASS_AVAILABLE:718return ToolResult(success=False, output=None, error="Coinglass tools not available.")719720try:721result = await asyncio.to_thread(get_pair_liquidation_history, symbol, exchange, interval, limit, start_time, end_time)722if result is None:723return ToolResult(success=False, output=None, error="Failed to fetch pair liquidation history. Check COINGLASS_API_KEY.")724return ToolResult(success=True, output=result)725except Exception as e:726return ToolResult(success=False, output=None, error=str(e))727728729class LiquidationCoinListTool(BaseTool):730"""Get liquidation data for all coins on a specific exchange."""731732@property733def name(self) -> str:734return "cg_liquidation_coin_list"735736@property737def description(self) -> str:738return """Get liquidation data for all coins on a specific exchange.739740Shows liquidation amounts across multiple timeframes (1h, 4h, 12h, 24h) for all coins on an exchange.741742Examples:743- Get all Binance liquidations: cg_liquidation_coin_list(exchange="Binance")744- Get all OKX liquidations: cg_liquidation_coin_list(exchange="OKX")"""745746@property747def parameters(self) -> dict:748return {749"type": "object",750"properties": {751"exchange": {"type": "string", "description": "Exchange name (Binance, OKX, Bybit, etc.)"}752},753"required": ["exchange"]754}755756async def execute(self, ctx: ToolContext, exchange: str) -> ToolResult:757if not COINGLASS_AVAILABLE:758return ToolResult(success=False, output=None, error="Coinglass tools not available.")759760try:761result = await asyncio.to_thread(get_liquidation_coin_list, exchange)762if result is None:763return ToolResult(success=False, output=None, error="Failed to fetch liquidation coin list. Check COINGLASS_API_KEY.")764return ToolResult(success=True, output=result)765except Exception as e:766return ToolResult(success=False, output=None, error=str(e))767768769class LiquidationOrdersTool(BaseTool):770"""Get individual liquidation orders (past 7 days)."""771772@property773def name(self) -> str:774return "cg_liquidation_orders"775776@property777def description(self) -> str:778return """Get individual liquidation orders with price, side, and USD value (past 7 days only).779780Shows actual liquidation events. Max 200 records per request.781782Examples:783- Get BTC liquidations on Binance (min $10K): cg_liquidation_orders(symbol="BTC", exchange="Binance", min_liquidation_amount="10000")784- Get ETH liquidations on OKX (min $5K): cg_liquidation_orders(symbol="ETH", exchange="OKX", min_liquidation_amount="5000")"""785786@property787def parameters(self) -> dict:788return {789"type": "object",790"properties": {791"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"},792"exchange": {"type": "string", "description": "Exchange name (Binance, OKX, Bybit, etc.)"},793"min_liquidation_amount": {"type": "string", "description": "Minimum threshold for liquidation events (USD)"},794"start_time": {"type": "integer", "description": "Start timestamp in milliseconds"},795"end_time": {"type": "integer", "description": "End timestamp in milliseconds"}796},797"required": ["symbol", "exchange", "min_liquidation_amount"]798}799800async def execute(self, ctx: ToolContext, symbol: str, exchange: str, min_liquidation_amount: str,801start_time: Optional[int] = None, end_time: Optional[int] = None) -> ToolResult:802if not COINGLASS_AVAILABLE:803return ToolResult(success=False, output=None, error="Coinglass tools not available.")804805try:806result = await asyncio.to_thread(get_liquidation_orders, symbol, exchange, min_liquidation_amount, start_time, end_time)807if result is None:808return ToolResult(success=False, output=None, error="Failed to fetch liquidation orders. Check COINGLASS_API_KEY.")809return ToolResult(success=True, output=result)810except Exception as e:811return ToolResult(success=False, output=None, error=str(e))812813814# ==================== Futures Market Data Tools (V4 API) ====================815816class SupportedCoinsTool(BaseTool):817"""Get list of all supported coins for futures trading."""818819@property820def name(self) -> str:821return "cg_supported_coins"822823@property824def description(self) -> str:825return """Get list of all supported coins for futures trading on Coinglass.826827Returns array of coin symbols (BTC, ETH, SOL, XRP, HYPE, DOGE, etc.)828829Use this for:830- Market discovery831- Checking if a coin has futures markets832- Finding new trading opportunities833834Examples:835- Get all supported coins: cg_supported_coins()"""836837@property838def parameters(self) -> dict:839return {"type": "object", "properties": {}, "required": []}840841async def execute(self, ctx: ToolContext) -> ToolResult:842if not COINGLASS_AVAILABLE:843return ToolResult(success=False, output=None, error="Coinglass tools not available.")844845try:846result = await asyncio.to_thread(get_supported_coins)847if result is None:848return ToolResult(success=False, output=None, error="Failed to fetch supported coins. Check COINGLASS_API_KEY.")849return ToolResult(success=True, output=result)850except Exception as e:851return ToolResult(success=False, output=None, error=str(e))852853854class SupportedExchangesTool(BaseTool):855"""Get all supported exchanges with their trading pairs."""856857@property858def name(self) -> str:859return "cg_supported_exchanges"860861@property862def description(self) -> str:863return """Get all supported exchanges with trading pairs and specs.864865Returns dictionary with exchange pairs including leverage limits, funding intervals, tick sizes.866867Examples:868- Get all exchanges: cg_supported_exchanges()"""869870@property871def parameters(self) -> dict:872return {"type": "object", "properties": {}, "required": []}873874async def execute(self, ctx: ToolContext) -> ToolResult:875if not COINGLASS_AVAILABLE:876return ToolResult(success=False, output=None, error="Coinglass tools not available.")877878try:879result = await asyncio.to_thread(get_supported_exchanges)880if result is None:881return ToolResult(success=False, output=None, error="Failed to fetch supported exchanges. Check COINGLASS_API_KEY.")882return ToolResult(success=True, output=result)883except Exception as e:884return ToolResult(success=False, output=None, error=str(e))885886887class CoinsMarketDataTool(BaseTool):888"""Get comprehensive market data for ALL coins in one request."""889890@property891def name(self) -> str:892return "cg_coins_market_data"893894@property895def description(self) -> str:896return """Get market data for ALL coins in ONE request.897898Returns: price, funding rates, OI, volume, long/short ratios, liquidations for 100+ coins.899900Use this for market screening and bulk analysis. MUCH more efficient than individual calls.901902Examples:903- Get all coins data: cg_coins_market_data()"""904905@property906def parameters(self) -> dict:907return {"type": "object", "properties": {}, "required": []}908909async def execute(self, ctx: ToolContext) -> ToolResult:910if not COINGLASS_AVAILABLE:911return ToolResult(success=False, output=None, error="Coinglass tools not available.")912913try:914result = await asyncio.to_thread(get_coins_data)915if result is None:916return ToolResult(success=False, output=None, error="Failed to fetch coins market data. Check COINGLASS_API_KEY.")917return ToolResult(success=True, output=result)918except Exception as e:919return ToolResult(success=False, output=None, error=str(e))920921922class PairMarketDataTool(BaseTool):923"""Get detailed market data for a specific trading pair."""924925@property926def name(self) -> str:927return "cg_pair_market_data"928929@property930def description(self) -> str:931return """Get detailed market data for a specific pair on an exchange.932933Returns: price, volume, OI, funding rate, liquidations, long/short volumes.934935Examples:936- Get BTC/USDT on Binance: cg_pair_market_data(symbol="BTC", exchange="Binance")937- Get ETH/USDT on OKX: cg_pair_market_data(symbol="ETH", exchange="OKX")"""938939@property940def parameters(self) -> dict:941return {942"type": "object",943"properties": {944"symbol": {"type": "string", "description": "Coin symbol (BTC, ETH, SOL, etc.)"},945"exchange": {"type": "string", "description": "Exchange name (Binance, OKX, Bybit, Gate, etc.)"}946},947"required": ["symbol", "exchange"]948}949950async def execute(self, ctx: ToolContext, symbol: str, exchange: str) -> ToolResult:951if not COINGLASS_AVAILABLE:952return ToolResult(success=False, output=None, error="Coinglass tools not available.")953954try:955result = await asyncio.to_thread(get_pair_data, symbol, exchange)956if result is None:957return ToolResult(success=False, output=None, error="Failed to fetch pair market data. Check COINGLASS_API_KEY.")958return ToolResult(success=True, output=result)959except Exception as e:960return ToolResult(success=False, output=None, error=str(e))961962963class OHLCHistoryTool(BaseTool):964"""Get OHLC price history for a trading pair."""965966@property967def name(self) -> str:968return "cg_ohlc_history"969970@property971def description(self) -> str:972return """Get OHLC candlestick data for price analysis.973974Returns array of candles with: timestamp, open, high, low, close.975976Examples:977- Get BTC 1h candles: cg_ohlc_history(symbol="BTC", exchange="Binance", interval="h1", limit=100)978- Get ETH daily: cg_ohlc_history(symbol="ETH", exchange="OKX", interval="d1", limit=30)"""979980@property981def parameters(self) -> dict:982return {983"type": "object",984"properties": {985"symbol": {"type": "string", "description": "Coin symbol (BTC, ETH, SOL, etc.)"},986"exchange": {"type": "string", "description": "Exchange name (Binance, OKX, Bybit, etc.)"},987"interval": {"type": "string", "description": "Time interval: m1, m5, m15, m30, h1, h4, h12, d1", "default": "h1"},988"limit": {"type": "integer", "description": "Number of candles (default: 100)", "default": 100}989},990"required": ["symbol", "exchange"]991}992993async def execute(self, ctx: ToolContext, symbol: str, exchange: str, interval: str = "h1", limit: int = 100) -> ToolResult:994if not COINGLASS_AVAILABLE:995return ToolResult(success=False, output=None, error="Coinglass tools not available.")996997try:998result = await asyncio.to_thread(get_ohlc_history, symbol, exchange, interval, limit)999if result is None:1000return ToolResult(success=False, output=None, error="Failed to fetch OHLC history. Check COINGLASS_API_KEY.")1001return ToolResult(success=True, output=result)1002except Exception as e:1003return ToolResult(success=False, output=None, error=str(e))100410051006# ==================== Hyperliquid Tools ====================10071008class HyperliquidWhaleAlertsTool(BaseTool):1009"""Get recent whale alerts on Hyperliquid (positions > $1M)."""10101011@property1012def name(self) -> str:1013return "cg_hyperliquid_whale_alerts"10141015@property1016def description(self) -> str:1017return """Get recent whale alerts on Hyperliquid (positions > $1M).10181019Returns approximately 200 most recent large position opens/closes.10201021Examples:1022- Get whale alerts: cg_hyperliquid_whale_alerts()"""10231024@property1025def parameters(self) -> dict:1026return {"type": "object", "properties": {}, "required": []}10271028async def execute(self, ctx: ToolContext) -> ToolResult:1029if not COINGLASS_AVAILABLE:1030return ToolResult(success=False, output=None, error="Coinglass tools not available.")10311032try:1033result = await asyncio.to_thread(get_whale_alerts)1034if result is None:1035return ToolResult(success=False, output=None, error="Failed to fetch whale alerts. Check COINGLASS_API_KEY.")1036return ToolResult(success=True, output=result)1037except Exception as e:1038return ToolResult(success=False, output=None, error=str(e))103910401041class HyperliquidWhalePositionsTool(BaseTool):1042"""Get current whale positions on Hyperliquid."""10431044@property1045def name(self) -> str:1046return "cg_hyperliquid_whale_positions"10471048@property1049def description(self) -> str:1050return """Get current whale positions on Hyperliquid.10511052Shows large active positions with entry price, PnL, leverage, and margin data.10531054Examples:1055- Get whale positions: cg_hyperliquid_whale_positions()"""10561057@property1058def parameters(self) -> dict:1059return {"type": "object", "properties": {}, "required": []}10601061async def execute(self, ctx: ToolContext) -> ToolResult:1062if not COINGLASS_AVAILABLE:1063return ToolResult(success=False, output=None, error="Coinglass tools not available.")10641065try:1066result = await asyncio.to_thread(get_whale_positions)1067if result is None:1068return ToolResult(success=False, output=None, error="Failed to fetch whale positions. Check COINGLASS_API_KEY.")1069return ToolResult(success=True, output=result)1070except Exception as e:1071return ToolResult(success=False, output=None, error=str(e))107210731074class HyperliquidPositionsByCoinTool(BaseTool):1075"""Get wallet positions organized by coin on Hyperliquid."""10761077@property1078def name(self) -> str:1079return "cg_hyperliquid_positions_by_coin"10801081@property1082def description(self) -> str:1083return """Get real-time wallet positions for a specific coin on Hyperliquid.10841085Shows all open positions for the specified cryptocurrency.10861087Examples:1088- Get BTC positions: cg_hyperliquid_positions_by_coin(symbol="BTC")1089- Get ETH positions: cg_hyperliquid_positions_by_coin(symbol="ETH")"""10901091@property1092def parameters(self) -> dict:1093return {1094"type": "object",1095"properties": {1096"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"}1097},1098"required": ["symbol"]1099}11001101async def execute(self, ctx: ToolContext, symbol: str) -> ToolResult:1102if not COINGLASS_AVAILABLE:1103return ToolResult(success=False, output=None, error="Coinglass tools not available.")11041105try:1106result = await asyncio.to_thread(get_positions_by_coin, symbol)1107if result is None:1108return ToolResult(success=False, output=None, error="Failed to fetch positions by coin. Check COINGLASS_API_KEY.")1109return ToolResult(success=True, output=result)1110except Exception as e:1111return ToolResult(success=False, output=None, error=str(e))111211131114class HyperliquidUserPositionsTool(BaseTool):1115"""Get positions for a specific user address on Hyperliquid."""11161117@property1118def name(self) -> str:1119return "cg_hyperliquid_user_positions"11201121@property1122def description(self) -> str:1123return """Get positions for a specific user address on Hyperliquid.11241125Shows margin summaries, withdrawable balance, and open positions for the specified wallet.11261127Examples:1128- Get user positions: cg_hyperliquid_user_positions(user_address="0x...")"""11291130@property1131def parameters(self) -> dict:1132return {1133"type": "object",1134"properties": {1135"user_address": {"type": "string", "description": "Wallet address to query"}1136},1137"required": ["user_address"]1138}11391140async def execute(self, ctx: ToolContext, user_address: str) -> ToolResult:1141if not COINGLASS_AVAILABLE:1142return ToolResult(success=False, output=None, error="Coinglass tools not available.")11431144try:1145result = await asyncio.to_thread(get_user_positions, user_address)1146if result is None:1147return ToolResult(success=False, output=None, error="Failed to fetch user positions. Check COINGLASS_API_KEY.")1148return ToolResult(success=True, output=result)1149except Exception as e:1150return ToolResult(success=False, output=None, error=str(e))115111521153class HyperliquidPositionDistributionTool(BaseTool):1154"""Get wallet position distribution on Hyperliquid."""11551156@property1157def name(self) -> str:1158return "cg_hyperliquid_position_distribution"11591160@property1161def description(self) -> str:1162return """Get wallet position distribution on Hyperliquid.11631164Shows distribution by size tiers including address counts, long/short values, sentiment, and P/L distribution.11651166Examples:1167- Get position distribution: cg_hyperliquid_position_distribution()"""11681169@property1170def parameters(self) -> dict:1171return {"type": "object", "properties": {}, "required": []}11721173async def execute(self, ctx: ToolContext) -> ToolResult:1174if not COINGLASS_AVAILABLE:1175return ToolResult(success=False, output=None, error="Coinglass tools not available.")11761177try:1178result = await asyncio.to_thread(get_position_distribution)1179if result is None:1180return ToolResult(success=False, output=None, error="Failed to fetch position distribution. Check COINGLASS_API_KEY.")1181return ToolResult(success=True, output=result)1182except Exception as e:1183return ToolResult(success=False, output=None, error=str(e))11841185# ==================== Volume & Flow Tools ====================11861187class TakerVolumeHistoryTool(BaseTool):1188"""Get taker buy/sell volume history for a specific trading pair."""11891190@property1191def name(self) -> str:1192return "cg_taker_volume_history"11931194@property1195def description(self) -> str:1196return """Get historical taker buy/sell volume data for a specific trading pair.11971198Taker volume = aggressive market orders (vs passive limit orders).1199Higher taker buy volume = bullish pressure.1200Higher taker sell volume = bearish pressure.12011202Examples:1203- Get BTC taker volume on Binance: cg_taker_volume_history(symbol="BTC", exchange="Binance", interval="1h")1204- Get ETH 4h intervals: cg_taker_volume_history(symbol="ETH", exchange="OKX", interval="4h", limit=50)"""12051206@property1207def parameters(self) -> dict:1208return {1209"type": "object",1210"properties": {1211"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"},1212"exchange": {"type": "string", "description": "Exchange name (Binance, OKX, Bybit, etc.)"},1213"interval": {"type": "string", "description": "Time interval: 1m, 3m, 5m, 15m, 30m, 1h, 4h, 6h, 8h, 12h, 1d, 1w", "default": "1h"},1214"limit": {"type": "integer", "description": "Number of results (default: 1000, max: 4500)", "default": 1000},1215"start_time": {"type": "integer", "description": "Start timestamp in seconds"},1216"end_time": {"type": "integer", "description": "End timestamp in seconds"}1217},1218"required": ["symbol", "exchange"]1219}12201221async def execute(self, ctx: ToolContext, symbol: str, exchange: str, interval: str = "1h", limit: int = 1000,1222start_time: Optional[int] = None, end_time: Optional[int] = None) -> ToolResult:1223if not COINGLASS_AVAILABLE:1224return ToolResult(success=False, output=None, error="Coinglass tools not available.")12251226try:1227result = await asyncio.to_thread(get_taker_volume_history, symbol, exchange, interval, limit, start_time, end_time)1228if result is None:1229return ToolResult(success=False, output=None, error="Failed to fetch taker volume history. Check COINGLASS_API_KEY.")1230return ToolResult(success=True, output=result)1231except Exception as e:1232return ToolResult(success=False, output=None, error=str(e))123312341235class AggregatedTakerVolumeTool(BaseTool):1236"""Get aggregated taker buy/sell volume across all exchanges."""12371238@property1239def name(self) -> str:1240return "cg_aggregated_taker_volume"12411242@property1243def description(self) -> str:1244return """Get aggregated taker buy/sell volume across all exchanges for a coin.12451246Shows total market pressure across all major exchanges.1247More comprehensive than single-exchange data.12481249Examples:1250- Get BTC aggregated volume: cg_aggregated_taker_volume(symbol="BTC", interval="1h")1251- Get ETH 4h: cg_aggregated_taker_volume(symbol="ETH", interval="4h", limit=100)"""12521253@property1254def parameters(self) -> dict:1255return {1256"type": "object",1257"properties": {1258"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"},1259"exchange_list": {"type": "string", "description": "Comma-separated exchange list (e.g. 'Binance,OKX,Bybit')"},1260"interval": {"type": "string", "description": "Time interval: 1m, 3m, 5m, 15m, 30m, 1h, 4h, 6h, 8h, 12h, 1d, 1w", "default": "1h"},1261"limit": {"type": "integer", "description": "Number of results (default: 1000, max: 4500)", "default": 1000},1262"start_time": {"type": "integer", "description": "Start timestamp in seconds"},1263"end_time": {"type": "integer", "description": "End timestamp in seconds"}1264},1265"required": ["symbol", "exchange_list"]1266}12671268async def execute(self, ctx: ToolContext, symbol: str, exchange_list: str, interval: str = "1h", limit: int = 1000,1269start_time: Optional[int] = None, end_time: Optional[int] = None) -> ToolResult:1270if not COINGLASS_AVAILABLE:1271return ToolResult(success=False, output=None, error="Coinglass tools not available.")12721273try:1274result = await asyncio.to_thread(get_aggregated_taker_volume, symbol, exchange_list, interval, limit, start_time, end_time)1275if result is None:1276return ToolResult(success=False, output=None, error="Failed to fetch aggregated taker volume. Check COINGLASS_API_KEY.")1277return ToolResult(success=True, output=result)1278except Exception as e:1279return ToolResult(success=False, output=None, error=str(e))128012811282class CumulativeVolumeDeltaTool(BaseTool):1283"""Get Cumulative Volume Delta (CVD) for trend analysis."""12841285@property1286def name(self) -> str:1287return "cg_cumulative_volume_delta"12881289@property1290def description(self) -> str:1291return """Get Cumulative Volume Delta (CVD) history for a trading pair.12921293CVD = Running total of (taker buy volume - taker sell volume).1294Rising CVD = accumulation (bullish).1295Falling CVD = distribution (bearish).1296Divergences between price and CVD signal trend weakness.12971298Examples:1299- Get BTC CVD on Binance: cg_cumulative_volume_delta(symbol="BTC", exchange="Binance", interval="1h")1300- Get ETH CVD: cg_cumulative_volume_delta(symbol="ETH", exchange="OKX", interval="4h", limit=100)"""13011302@property1303def parameters(self) -> dict:1304return {1305"type": "object",1306"properties": {1307"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"},1308"exchange": {"type": "string", "description": "Exchange name (Binance, OKX, Bybit, etc.)"},1309"interval": {"type": "string", "description": "Time interval: 1m, 3m, 5m, 15m, 30m, 1h, 4h, 6h, 8h, 12h, 1d, 1w", "default": "1h"},1310"limit": {"type": "integer", "description": "Number of results (default: 1000, max: 4500)", "default": 1000},1311"start_time": {"type": "integer", "description": "Start timestamp in seconds"},1312"end_time": {"type": "integer", "description": "End timestamp in seconds"}1313},1314"required": ["symbol", "exchange"]1315}13161317async def execute(self, ctx: ToolContext, symbol: str, exchange: str, interval: str = "1h", limit: int = 1000,1318start_time: Optional[int] = None, end_time: Optional[int] = None) -> ToolResult:1319if not COINGLASS_AVAILABLE:1320return ToolResult(success=False, output=None, error="Coinglass tools not available.")13211322try:1323result = await asyncio.to_thread(get_cumulative_volume_delta, symbol, exchange, interval, limit, start_time, end_time)1324if result is None:1325return ToolResult(success=False, output=None, error="Failed to fetch CVD. Check COINGLASS_API_KEY.")1326return ToolResult(success=True, output=result)1327except Exception as e:1328return ToolResult(success=False, output=None, error=str(e))132913301331class CoinNetflowTool(BaseTool):1332"""Get netflow data for all futures coins."""13331334@property1335def name(self) -> str:1336return "cg_coin_netflow"13371338@property1339def description(self) -> str:1340return """Get coin netflow data for all futures coins.13411342Netflow = Capital flowing into/out of a coin across exchanges.1343Positive netflow = accumulation (bullish signal).1344Negative netflow = distribution (bearish signal).13451346Use for identifying which coins are seeing the strongest capital inflows.13471348Examples:1349- Get all coin netflows: cg_coin_netflow()"""13501351@property1352def parameters(self) -> dict:1353return {"type": "object", "properties": {}, "required": []}13541355async def execute(self, ctx: ToolContext) -> ToolResult:1356if not COINGLASS_AVAILABLE:1357return ToolResult(success=False, output=None, error="Coinglass tools not available.")13581359try:1360result = await asyncio.to_thread(get_coin_netflow)1361if result is None:1362return ToolResult(success=False, output=None, error="Failed to fetch coin netflow. Check COINGLASS_API_KEY.")1363return ToolResult(success=True, output=result)1364except Exception as e:1365return ToolResult(success=False, output=None, error=str(e))136613671368class VolumeOHLCTool(BaseTool):1369"""Get volume OHLC history for a trading pair."""13701371@property1372def name(self) -> str:1373return "cg_volume_ohlc"13741375@property1376def description(self) -> str:1377return """Get trading volume OHLC (Open, High, Low, Close) history.13781379Shows volume patterns over time in candlestick format.1380Useful for identifying volume spikes and trends.13811382Examples:1383- Get BTC volume OHLC: cg_volume_ohlc(symbol="BTC", exchange="Binance", interval="1h")1384- Get ETH daily volume: cg_volume_ohlc(symbol="ETH", exchange="OKX", interval="1d", limit=30)"""13851386@property1387def parameters(self) -> dict:1388return {1389"type": "object",1390"properties": {1391"symbol": {"type": "string", "description": "Trading coin (BTC, ETH, SOL, etc.)"},1392"exchange": {"type": "string", "description": "Exchange name (Binance, OKX, Bybit, etc.)"},1393"interval": {"type": "string", "description": "Time interval: 1h, 4h, 12h, 1d", "default": "1h"},1394"limit": {"type": "integer", "description": "Number of results (default: 100)", "default": 100}1395},1396"required": ["symbol", "exchange"]1397}13981399async def execute(self, ctx: ToolContext, symbol: str, exchange: str, interval: str = "1h", limit: int = 100) -> ToolResult:1400if not COINGLASS_AVAILABLE:1401return ToolResult(success=False, output=None, error="Coinglass tools not available.")14021403try:1404result = await asyncio.to_thread(get_volume_ohlc_history, symbol, exchange, interval, limit)1405if result is None:1406return ToolResult(success=False, output=None, error="Failed to fetch volume OHLC. Check COINGLASS_API_KEY.")1407return ToolResult(success=True, output=result)1408except Exception as e:1409return ToolResult(success=False, output=None, error=str(e))141014111412# ==================== Whale Transfer Tools ====================14131414class WhaleTransferTool(BaseTool):1415"""Get large on-chain transfers (minimum $10M) across major blockchains."""14161417@property1418def name(self) -> str:1419return "cg_whale_transfers"14201421@property1422def description(self) -> str:1423return """Get large on-chain whale transfers (minimum $10M) within the past 6 months.14241425Covers major blockchains: Bitcoin, Ethereum, Tron, Ripple, Dogecoin, Litecoin, Polygon, Algorand, Bitcoin Cash, Solana.14261427Shows transaction hash, asset, amount, exchanges involved, and transfer direction.1428Useful for tracking institutional movements and market impact events.14291430Transfer types:1431- 1 = Inflow (to exchange)1432- 2 = Outflow (from exchange)1433- 3 = Internal (between exchange wallets)14341435Examples:1436- Get recent whale transfers: cg_whale_transfers()"""14371438@property1439def parameters(self) -> dict:1440return {"type": "object", "properties": {}, "required": []}14411442async def execute(self, ctx: ToolContext) -> ToolResult:1443if not COINGLASS_AVAILABLE:1444return ToolResult(success=False, output=None, error="Coinglass tools not available.")14451446try:1447result = await asyncio.to_thread(get_whale_transfers)1448if result is None:1449return ToolResult(success=False, output=None, error="Failed to fetch whale transfers. Check COINGLASS_API_KEY.")1450return ToolResult(success=True, output=result)1451except Exception as e:1452return ToolResult(success=False, output=None, error=str(e))145314541455# ==================== Bitcoin ETF Tools ====================14561457class BTCETFFlowsTool(BaseTool):1458"""Get Bitcoin ETF flow history (inflows/outflows)."""14591460@property1461def name(self) -> str:1462return "cg_btc_etf_flows"14631464@property1465def description(self) -> str:1466return """Get Bitcoin ETF flow history including daily net inflows and outflows.14671468Shows institutional money movement into/out of Bitcoin through ETFs.1469Large inflows = institutional accumulation (bullish).1470Large outflows = institutional distribution (bearish).14711472Examples:1473- Get BTC ETF flows: cg_btc_etf_flows()"""14741475@property1476def parameters(self) -> dict:1477return {"type": "object", "properties": {}, "required": []}14781479async def execute(self, ctx: ToolContext) -> ToolResult:1480if not COINGLASS_AVAILABLE:1481return ToolResult(success=False, output=None, error="Coinglass tools not available.")14821483try:1484result = await asyncio.to_thread(get_btc_etf_flows)1485if result is None:1486return ToolResult(success=False, output=None, error="Failed to fetch BTC ETF flows. Check COINGLASS_API_KEY.")1487return ToolResult(success=True, output=result)1488except Exception as e:1489return ToolResult(success=False, output=None, error=str(e))149014911492class BTCETFNetAssetsTool(BaseTool):1493"""Get Bitcoin ETF net assets history."""14941495@property1496def name(self) -> str:1497return "cg_btc_etf_net_assets"14981499@property1500def description(self) -> str:1501return """Get Bitcoin ETF net assets history.15021503Shows total value held in Bitcoin ETFs over time and daily changes.1504Rising net assets = growing institutional adoption.15051506Examples:1507- Get BTC ETF net assets: cg_btc_etf_net_assets()"""15081509@property1510def parameters(self) -> dict:1511return {"type": "object", "properties": {}, "required": []}15121513async def execute(self, ctx: ToolContext) -> ToolResult:1514if not COINGLASS_AVAILABLE:1515return ToolResult(success=False, output=None, error="Coinglass tools not available.")15161517try:1518result = await asyncio.to_thread(get_btc_etf_net_assets)1519if result is None:1520return ToolResult(success=False, output=None, error="Failed to fetch BTC ETF net assets. Check COINGLASS_API_KEY.")1521return ToolResult(success=True, output=result)1522except Exception as e:1523return ToolResult(success=False, output=None, error=str(e))152415251526class BTCETFPremiumDiscountTool(BaseTool):1527"""Get Bitcoin ETF premium/discount rates."""15281529@property1530def name(self) -> str:1531return "cg_btc_etf_premium_discount"15321533@property1534def description(self) -> str:1535return """Get Bitcoin ETF premium/discount rates.15361537Shows how ETF market prices compare to their net asset value (NAV).1538Premium (positive) = trading above NAV (high demand).1539Discount (negative) = trading below NAV (low demand).15401541Examples:1542- Get BTC ETF premium/discount: cg_btc_etf_premium_discount()"""15431544@property1545def parameters(self) -> dict:1546return {"type": "object", "properties": {}, "required": []}15471548async def execute(self, ctx: ToolContext) -> ToolResult:1549if not COINGLASS_AVAILABLE:1550return ToolResult(success=False, output=None, error="Coinglass tools not available.")15511552try:1553result = await asyncio.to_thread(get_btc_etf_premium_discount)1554if result is None:1555return ToolResult(success=False, output=None, error="Failed to fetch BTC ETF premium/discount. Check COINGLASS_API_KEY.")1556return ToolResult(success=True, output=result)1557except Exception as e:1558return ToolResult(success=False, output=None, error=str(e))155915601561class BTCETFHistoryTool(BaseTool):1562"""Get comprehensive Bitcoin ETF history."""15631564@property1565def name(self) -> str:1566return "cg_btc_etf_history"15671568@property1569def description(self) -> str:1570return """Get comprehensive Bitcoin ETF history.15711572Includes market price, NAV, premium/discount %, shares outstanding, and net assets.15731574Examples:1575- Get IBIT history: cg_btc_etf_history(ticker="IBIT")1576- Get FBTC history: cg_btc_etf_history(ticker="FBTC")"""15771578@property1579def parameters(self) -> dict:1580return {1581"type": "object",1582"properties": {1583"ticker": {"type": "string", "description": "ETF ticker symbol (e.g. IBIT, FBTC, GBTC)"}1584},1585"required": ["ticker"]1586}15871588async def execute(self, ctx: ToolContext, ticker: str) -> ToolResult:1589if not COINGLASS_AVAILABLE:1590return ToolResult(success=False, output=None, error="Coinglass tools not available.")15911592try:1593result = await asyncio.to_thread(get_btc_etf_history, ticker)1594if result is None:1595return ToolResult(success=False, output=None, error="Failed to fetch BTC ETF history. Check COINGLASS_API_KEY.")1596return ToolResult(success=True, output=result)1597except Exception as e:1598return ToolResult(success=False, output=None, error=str(e))159916001601class BTCETFListTool(BaseTool):1602"""Get list of Bitcoin ETFs."""16031604@property1605def name(self) -> str:1606return "cg_btc_etf_list"16071608@property1609def description(self) -> str:1610return """Get list of Bitcoin ETFs with key status information.16111612Returns ticker symbols, names, inception dates, and other ETF metadata.16131614Examples:1615- Get BTC ETF list: cg_btc_etf_list()"""16161617@property1618def parameters(self) -> dict:1619return {"type": "object", "properties": {}, "required": []}16201621async def execute(self, ctx: ToolContext) -> ToolResult:1622if not COINGLASS_AVAILABLE:1623return ToolResult(success=False, output=None, error="Coinglass tools not available.")16241625try:1626result = await asyncio.to_thread(get_btc_etf_list)1627if result is None:1628return ToolResult(success=False, output=None, error="Failed to fetch BTC ETF list. Check COINGLASS_API_KEY.")1629return ToolResult(success=True, output=result)1630except Exception as e:1631return ToolResult(success=False, output=None, error=str(e))163216331634class HKBTCETFFlowsTool(BaseTool):1635"""Get Hong Kong Bitcoin ETF flow history."""16361637@property1638def name(self) -> str:1639return "cg_hk_btc_etf_flows"16401641@property1642def description(self) -> str:1643return """Get Hong Kong Bitcoin ETF flow history.16441645Shows ETF flow activity for Bitcoin ETFs in the Hong Kong market.1646Useful for tracking Asian institutional demand.16471648Examples:1649- Get HK BTC ETF flows: cg_hk_btc_etf_flows()"""16501651@property1652def parameters(self) -> dict:1653return {"type": "object", "properties": {}, "required": []}16541655async def execute(self, ctx: ToolContext) -> ToolResult:1656if not COINGLASS_AVAILABLE:1657return ToolResult(success=False, output=None, error="Coinglass tools not available.")16581659try:1660result = await asyncio.to_thread(get_hk_btc_etf_flows)1661if result is None:1662return ToolResult(success=False, output=None, error="Failed to fetch HK BTC ETF flows. Check COINGLASS_API_KEY.")1663return ToolResult(success=True, output=result)1664except Exception as e:1665return ToolResult(success=False, output=None, error=str(e))166616671668# ==================== Ethereum & Other ETF Tools ====================16691670class ETHETFFlowsTool(BaseTool):1671"""Get Ethereum ETF flow history."""16721673@property1674def name(self) -> str:1675return "cg_eth_etf_flows"16761677@property1678def description(self) -> str:1679return """Get Ethereum ETF flow history including daily net inflows and outflows.16801681Shows institutional money movement into/out of Ethereum through ETFs.16821683Examples:1684- Get ETH ETF flows: cg_eth_etf_flows()"""16851686@property1687def parameters(self) -> dict:1688return {"type": "object", "properties": {}, "required": []}16891690async def execute(self, ctx: ToolContext) -> ToolResult:1691if not COINGLASS_AVAILABLE:1692return ToolResult(success=False, output=None, error="Coinglass tools not available.")16931694try:1695result = await asyncio.to_thread(get_eth_etf_flows)1696if result is None:1697return ToolResult(success=False, output=None, error="Failed to fetch ETH ETF flows. Check COINGLASS_API_KEY.")1698return ToolResult(success=True, output=result)1699except Exception as e:1700return ToolResult(success=False, output=None, error=str(e))170117021703class ETHETFListTool(BaseTool):1704"""Get list of Ethereum ETFs."""17051706@property1707def name(self) -> str:1708return "cg_eth_etf_list"17091710@property1711def description(self) -> str:1712return """Get list of Ethereum ETFs with key status information.17131714Examples:1715- Get ETH ETF list: cg_eth_etf_list()"""17161717@property1718def parameters(self) -> dict:1719return {"type": "object", "properties": {}, "required": []}17201721async def execute(self, ctx: ToolContext) -> ToolResult:1722if not COINGLASS_AVAILABLE:1723return ToolResult(success=False, output=None, error="Coinglass tools not available.")17241725try:1726result = await asyncio.to_thread(get_eth_etf_list)1727if result is None:1728return ToolResult(success=False, output=None, error="Failed to fetch ETH ETF list. Check COINGLASS_API_KEY.")1729return ToolResult(success=True, output=result)1730except Exception as e:1731return ToolResult(success=False, output=None, error=str(e))173217331734class SOLETFFlowsTool(BaseTool):1735"""Get Solana ETF flow history."""17361737@property1738def name(self) -> str:1739return "cg_sol_etf_flows"17401741@property1742def description(self) -> str:1743return """Get Solana ETF flow history including daily net inflows and outflows.17441745Examples:1746- Get SOL ETF flows: cg_sol_etf_flows()"""17471748@property1749def parameters(self) -> dict:1750return {"type": "object", "properties": {}, "required": []}17511752async def execute(self, ctx: ToolContext) -> ToolResult:1753if not COINGLASS_AVAILABLE:1754return ToolResult(success=False, output=None, error="Coinglass tools not available.")17551756try:1757result = await asyncio.to_thread(get_sol_etf_flows)1758if result is None:1759return ToolResult(success=False, output=None, error="Failed to fetch SOL ETF flows. Check COINGLASS_API_KEY.")1760return ToolResult(success=True, output=result)1761except Exception as e:1762return ToolResult(success=False, output=None, error=str(e))176317641765class XRPETFFlowsTool(BaseTool):1766"""Get XRP ETF flow history."""17671768@property1769def name(self) -> str:1770return "cg_xrp_etf_flows"17711772@property1773def description(self) -> str:1774return """Get XRP ETF flow history including daily net inflows and outflows.17751776Examples:1777- Get XRP ETF flows: cg_xrp_etf_flows()"""17781779@property1780def parameters(self) -> dict:1781return {"type": "object", "properties": {}, "required": []}17821783async def execute(self, ctx: ToolContext) -> ToolResult:1784if not COINGLASS_AVAILABLE:1785return ToolResult(success=False, output=None, error="Coinglass tools not available.")17861787try:1788result = await asyncio.to_thread(get_xrp_etf_flows)1789if result is None:1790return ToolResult(success=False, output=None, error="Failed to fetch XRP ETF flows. Check COINGLASS_API_KEY.")1791return ToolResult(success=True, output=result)1792except Exception as e:1793return ToolResult(success=False, output=None, error=str(e))179417951796