Coinglass

From Starchild-ai-agent/official-skills · View interactive version

Coinglass is an AI agent skill from the GitHub repository Starchild-ai-agent/official-skills. Crypto derivatives data: funding rates, open interest, liquidations, long/short ratios. Use when researching perp markets or comparing ETF flows (e.g. BTC funding, ETH OI). NOTE: platform API key is Startup tier — liquidation heatmap, coins-markets detail, liquidation order book and Hyperliquid posi

How to use this skill

Skill file

Plan Tiers (platform key = Startup, verified 2026-09)

The platform-injected COINGLASS_API_KEY is on the Startup plan. Actual endpoint access at the tool layer:

✅ Available on Startup (normal data):

❌ Not available on Startup (401 "Upgrade plan" — skip these, don't call):

Alternatives (in priority order):

  1. User supplies their own key (Basic+ plan): set COINGLASS_API_KEY and call

https://open-api-v4.coinglass.com directly, bypassing sc-proxy (sc-proxy overwrites that header, so a user key has no effect on the proxied path).

  1. Apify scraper: use the apify skill to scrape the liquidation heatmap / Hyperliquid position pages on coinglass.com.

On a 401 "Upgrade plan" response, cg_request raises CoinglassPlanError, and the error message already includes this guidance.

Full-market / multi-coin OI routing (coins-markets unavailable)

| Need | Use | Notes |

|---|---|---|

| Current OI and 4h/24h change for one coin | cg_open_interest(symbol) (take the exchangeName=="All" row) | Works on Startup |

| Funding for one coin | funding_rate(symbol) | Returns a string with % |

| OI history across coins | Per-coin OI history, summed by timestamp | Label it "Top-N aggregate" with the bar interval; never present it as full-market |

| Full-market current OI total / current OI per coin | coingecko skill cg_derivatives(include_tickers='unexpired'): keep contract_type=="perpetual", sum open_interest (USD) by index_id | Exchange-reported, includes small exchanges, runs higher than CoinGlass; current values only, no history; always cite the source in charts and text |

Do not plot numbers from different sources (CoinGlass Top-N, CoinGecko full-market, Bloomberg or other third parties) on one chart as comparison or reference lines.

Liquidation Heatmap (❌ not available on Startup — archived usage)

cg_liquidation_analysis returns all zeros and is unusable. Both heatmap endpoints (heatmap/model1 and

aggregated-heatmap/model1) return 401 Upgrade plan on the Startup plan.

If heatmap data is needed: have the user bring a Basic+ key and call directly (see Alternatives above), or scrape the page with Apify.

# Only works with a user-owned higher-tier key (direct, not via sc-proxy)
from tools._api import cg_request

# Full-market aggregated heatmap (recommended, no exchange needed)
# range supports: 12h, 24h, 3d, 7d, 30d, 90d, 180d, 1y
data = cg_request("api/futures/liquidation/aggregated-heatmap/model1",
                  params={"symbol": "BTC", "range": "24h"})

# Response structure:
# data["y_axis"]                   → price levels (low to high)
# data["liquidation_leverage_data"] → [[y_idx, leverage, usd_value], ...]
# data["price_candlesticks"]        → OHLCV candles; last close = current price
# data["update_time"]               → update timestamp

# How to parse:
from collections import defaultdict
y_axis = data["y_axis"]
current_price = float(data["price_candlesticks"][-1][4])
price_liq = defaultdict(float)
for y_idx, leverage, usd_val in data["liquidation_leverage_data"]:
    if 0 <= y_idx < len(y_axis):
        price_liq[y_axis[y_idx]] += usd_val

longs  = {p: v for p, v in price_liq.items() if p < current_price}  # long liquidations (triggered on the way down)
shorts = {p: v for p, v in price_liq.items() if p > current_price}  # short liquidations (triggered on the way up)

Script Usage

Script-mode skill — read this file, then invoke from a bash block:

python3 - <<'EOF'
import sys, json
sys.path.insert(0, "/data/workspace/skills/coinglass")
from exports import funding_rate, cg_open_interest, cg_liquidations

print(funding_rate(symbol="BTC"))
print(cg_open_interest(symbol="BTC"))
EOF

Read exports.py for the full list of available functions and exact

signatures. Common ones: funding_rate, long_short_ratio,

cg_open_interest, cg_liquidations, cg_liquidation_analysis,

cg_global_account_ratio, cg_top_account_ratio, cg_top_position_ratio,

cg_taker_exchanges, cg_net_position, cg_supported_coins,

cg_supported_exchanges, cg_coins_market_data, cg_pair_market_data,

cg_ohlc_history, cg_hyperliquid_whale_alerts,

cg_hyperliquid_whale_positions, cg_taker_volume_history,

cg_aggregated_taker_volume, cg_cumulative_volume_delta,

cg_coin_netflow, cg_whale_transfers, cg_btc_etf_flows,

cg_eth_etf_flows, cg_sol_etf_flows.

Coinglass

Coinglass provides the most comprehensive crypto derivatives and institutional data available. 37 tools covering futures positioning, whale tracking, volume analysis, liquidations, and ETF flows.

API Plan: Startup (platform key downgraded; see "Plan Tiers" at the top)

Rate Limit: request limits are lower on this plan; keep batch calls modest

API Version: V4 (with V2 backward compatibility)

Total Tools: 37 across 8 categories

Function Reference (full signatures + return shapes)

All functions live in exports.py. Most return Optional[List[Dict]] or

Optional[Dict]. None means the upstream call failed or returned empty —

always check before indexing.

⚠️ Field naming convention (READ THIS FIRST)

CoinGlass v4 API uses camelCase for almost all data fields, with a few

legacy snake_case exceptions in liquidation endpoints. Don't assume

snake_case — inspect the dict before scripting.

exchangeName, nextFundingTime, fundingIntervalHours,

oichangePercent, h4OIChangePercent, avgFundingRateBySymbol,

tokenAmount, liquidationUsd (in some endpoints)

longLiquidation_usd, shortLiquidation_usd

float(r.rstrip('%').lstrip('+')) to compare numerically

already in percent — 0.005313 means 0.0053%/8h. Do NOT multiply by

100. Sanity bound: BTC funding is normally around ±0.01%/8h; anything above

~0.1%/8h is almost certainly a unit bug.

Funding & Open Interest

| Function | Signature |

|---|---|

| funding_rate(symbol, exchange=None) | dict — keys: symbol, exchange, rate (str), num_exchanges, exchanges_data (list of {exchangeName, rate, nextFundingTime, fundingIntervalHours, status}) |

| cg_open_interest(symbol='BTC', interval='0') | LIST of dicts (one per exchange) — keys: symbol, openInterest, volUsd, oichangePercent, h4OIChangePercent, h24VolChangePercent, volChangePercent7d, avgFundingRateBySymbol, exchangeName, exchangeLogo |

Long/Short Ratios

| Function | Signature |

|---|---|

| long_short_ratio(symbol='BTC', interval='h4') | LIST — top item is aggregated; list field inside has per-exchange breakdown. Keys: longRate, shortRate, longVolUsd, shortVolUsd, totalVolUsd, list |

| cg_global_account_ratio(symbol='BTC', exchange='Binance', interval='1h') | list of historical bars |

| cg_top_account_ratio(symbol='BTC', exchange='Binance', interval='1h') | list — top trader account-count ratio |

| cg_top_position_ratio(symbol='BTC', exchange='Binance', interval='1h') | list — top trader position-size ratio |

| cg_taker_exchanges(symbol='BTC', range_type='4h') | list — taker buy/sell across exchanges |

| cg_net_position(symbol='BTC', exchange='Binance', interval='1h') | list — net long-short USD over time |

Liquidations

| Function | Signature |

|---|---|

| cg_liquidations(symbol='BTC', time_type='h24') | LIST of dicts (one per exchange + an 'All' row first). Keys: exchange, liquidation_usd, longLiquidation_usd, shortLiquidation_usd (NOTE: snake_case legacy fields) |

| cg_liquidation_analysis(symbol='BTC', time_type='h24') | dict — aggregated network-wide stats |

| cg_coin_liquidation_history(symbol='BTC', interval='h4') | list — historical liq bars |

| cg_pair_liquidation_history(symbol='BTC', exchange='Binance', interval='h4') | list — historical liq for one pair on one exchange |

| cg_liquidation_coin_list(symbol=None) | list of all coins with liq summary |

| cg_liquidation_orders(symbol='BTC', exchange=None) | list — recent individual liq orders |

Futures Market Data

| Function | Signature |

|---|---|

| cg_supported_coins() | List[str] — symbols supported by CoinGlass |

| cg_supported_exchanges() | list of exchange info dicts |

| cg_coins_market_data(symbol=None) | ❌ Not available on Startup (401) — see "Full-market / multi-coin OI routing" |

| cg_pair_market_data(symbol='BTC', exchange=None) | list — pair-level snapshot |

| cg_ohlc_history(symbol='BTC', interval='h4', exchange=None) | list of OHLCV bars |

Hyperliquid Whale Tracking

| Function | Signature |

|---|---|

| cg_hyperliquid_whale_alerts() | list — recent large-position alerts |

| cg_hyperliquid_whale_positions() | list — current open whale positions |

| cg_hyperliquid_positions_by_coin(symbol='BTC') | list — whales holding a specific coin |

| cg_hyperliquid_position_distribution(symbol='BTC') | dict — long/short position-size distribution |

Volume / Flow

| Function | Signature |

|---|---|

| cg_taker_volume_history(symbol='BTC', exchange='Binance', interval='1h', limit=1000, start_time=None, end_time=None) | list — taker buy/sell volume bars |

| cg_aggregated_taker_volume(symbol='BTC', interval='h4') | list — aggregated across all exchanges |

| cg_cumulative_volume_delta(symbol='BTC', exchange='Binance', interval='1h', limit=1000, start_time=None, end_time=None) | list — CVD bars |

| cg_coin_netflow(symbol=None) | list — net inflow/outflow per coin |

| cg_whale_transfers() | dict — recent on-chain large transfers |

ETF Flows

| Function | Signature |

|---|---|

| cg_btc_etf_flows() | list — daily flows per US BTC ETF |

| cg_btc_etf_history(etf_ticker=None) | list — historical AUM/flows |

| cg_btc_etf_list() | list of BTC ETF tickers + AUM |

| cg_btc_etf_premium_discount() | list — premium/discount % vs NAV |

| cg_hk_btc_etf_flows() | list — Hong Kong BTC ETF flows |

| cg_eth_etf_flows() / cg_eth_etf_list() / cg_eth_etf_premium_discount() / cg_hk_eth_etf_flows() | ETH ETF equivalents |

| cg_sol_etf_flows() / cg_sol_etf_list() | SOL ETF data |

| cg_xrp_etf_flows() / cg_xrp_etf_list() | XRP ETF data |

Sample responses (most-used functions)

funding_rate(symbol="BTC"):

{
  "symbol": "BTC",
  "exchange": "average",
  "rate": "-0.0016%",
  "num_exchanges": 21,
  "exchanges_data": [
    {"exchangeName": "Binance", "rate": "+0.0050%",
     "nextFundingTime": 1777881600000, "fundingIntervalHours": 8, "status": 1}
  ]
}

cg_liquidations(symbol="BTC", time_type="h24"):

[
  {"exchange": "All", "liquidation_usd": 170497688.16,
   "longLiquidation_usd": 8179073.80, "shortLiquidation_usd": 162318614.36},
  {"exchange": "Bybit", "liquidation_usd": 40454694.98, ...}
]

cg_open_interest(symbol="BTC"):

[
  {"symbol": "BTC", "openInterest": 61395303653.62, "volUsd": 56349328748.42,
   "oichangePercent": 7.17, "h4OIChangePercent": 5.33,
   "avgFundingRateBySymbol": -0.001874, "exchangeName": "Binance"}
]

long_short_ratio(symbol="BTC", interval="h4"):

[{
  "symbol": "BTC", "longRate": 53.65, "shortRate": 46.35,
  "longVolUsd": 12558668895.91, "shortVolUsd": 10848776476.99,
  "totalVolUsd": 23407445372.91,
  "list": [
    {"exchangeName": "Binance", "longRate": 55.75, "shortRate": 44.25, ...}
  ]
}]

Tool Selection Guide

Decision Tree

Step 1: Is this about LIQUIDATIONS?

Liquidation query?
├─ YES → How many coins?
│   ├─ ALL coins / ranking / summary
│   │   └─ → cg_liquidation_coin_list  ✅ (most liquidation queries land here)
│   ├─ ONE coin, need history over time
│   │   └─ → cg_coin_liquidation_history
│   ├─ ONE coin, specific orders (price/side/USD)
│   │   └─ → cg_liquidation_orders
│   └─ ONE coin, just a quick total + sentiment label
│       └─ → cg_liquidation_analysis  (rarely needed; only if explicitly "simple summary")

Step 2: Is this about LONG/SHORT RATIO?

Long/short query?
├─ Historical time-series, trend over time, L/S ratio change
│   └─ → cg_global_account_ratio  (ALL accounts)
│      or cg_top_account_ratio    (top traders only)
│      or cg_top_position_ratio   (by position size)
└─ Current snapshot only (no history needed)
    └─ → long_short_ratio

Step 3: Is this about OPEN INTEREST?

OI query?
└─ → cg_open_interest  (always — do NOT use cg_coins_market_data for OI)

Step 4: Is this a MARKET OVERVIEW / SENTIMENT query?

Sentiment / pre-trade check?
└─ Use: funding_rate + long_short_ratio + cg_open_interest
   DO NOT use cg_coins_market_data as a substitute for any of the above

Keyword → Tool Lookup

| Keyword / Pattern | Correct Tool | ❌ Do NOT use |

|---|---|---|

| liquidation ranking / today's liquidations / all coins liquidation | cg_liquidation_coin_list | cg_liquidations |

| 24h liquidation summary | cg_liquidation_coin_list | cg_liquidation_analysis |

| global account L/S ratio | cg_global_account_ratio | long_short_ratio |

| top trader L/S ratio | cg_top_account_ratio | long_short_ratio |

| open interest | cg_open_interest | cg_coins_market_data |

| market sentiment / positioning analysis | funding_rate + long_short_ratio + cg_open_interest | cg_coins_market_data |

| BTC long pre-trade checklist | funding_rate + cg_global_account_ratio + cg_liquidation_coin_list | — |


Common Mistakes

Mistake 1 (most common — 8x failure): Using cg_liquidations when you need cg_liquidation_coin_list

Mistake 2 (5x failure): Using cg_liquidation_analysis for liquidation rankings

Mistake 3 (3x failure): Using long_short_ratio for historical L/S analysis

Mistake 4 (2x failure): Using cg_coins_market_data for open interest

Rules

Tool Call Guidance

❌ FORBIDDEN TOOLS — NEVER USE:

✅ CORRECT PATTERN:

Match tool count to question scope:

Learning Log Usage (CRITICAL)

learning_log is FORBIDDEN for:

learning_log is ONLY for:

ETF Tool Selection

| Query | Primary Tool | Secondary Tool |

|-------|--------------|----------------|

| BTC ETF inflows/outflows | cg_btc_etf_flows() | cg_btc_etf_history() for detailed history |

| ETH ETF inflows/outflows | cg_eth_etf_flows() | — |

| SOL/XRP ETF flows | cg_sol_etf_flows() / cg_xrp_etf_flows() | — |

| HK ETF flows | cg_hk_btc_etf_flows() / cg_hk_eth_etf_flows() | — |

| ETF list / tickers | cg_btc_etf_list() / cg_eth_etf_list() | — |

| ETF premium / discount | cg_btc_etf_premium_discount() | — |

ETF comparison workflow:

# BTC vs ETH ETF comparison
btc = cg_btc_etf_flows()
eth = cg_eth_etf_flows()
# Compare the latest day's net flows, summarize in 2-3 sentences

Quick Routing (use this first)

| Query type | Tool |

|---|---|

| liquidation summary (24h, by coin) | cg_liquidation_coin_list |

| Individual liquidation orders | cg_liquidation_orders |

| Liquidation history for a coin | cg_coin_liquidation_history |

| Funding rate | funding_rate |

| Long/short ratio (global) | cg_global_account_ratio |

| Open interest | cg_open_interest |

| Whale activity on Hyperliquid | cg_hyperliquid_whale_alerts |

| ETF flows (BTC) | cg_btc_etf_flows |

When to Use Coinglass

Use Coinglass for:

Tool Categories

1. Basic Derivatives Analytics (7 tools)

Core derivatives data for market analysis:

2. Advanced Long/Short Ratios (6 tools)

Deep positioning analysis with multiple metrics:

Use cases:

3. Advanced Liquidations (4 tools)

Granular liquidation tracking for cascade prediction:

Use cases:

4. Hyperliquid Whale Tracking (4 tools)

Track large traders on Hyperliquid DEX (~200 recent alerts):

Use cases:

5. Futures Market Data (5 tools)

Market overview and price data:

Use cases:

6. Volume & Flow Analysis (4 tools)

Order flow and capital movement tracking:

Use cases:

7. Bitcoin ETF Data (5 tools)

Track institutional Bitcoin adoption:

Use cases:

8. Other ETF Data (8 tools)

Ethereum, Solana, XRP, and Hong Kong ETFs:

Use cases:

Common Workflows

Quick Market Scan

# Get everything in 3 calls
btc_oi = cg_open_interest("BTC")  # coins-markets is plan-gated on Startup
btc_liquidations = cg_liquidations("BTC")
whale_alerts = cg_hyperliquid_whale_alerts()

Deep Position Analysis

# BTC positioning across metrics
cg_global_account_ratio("BTC")  # Retail sentiment
cg_top_account_ratio("BTC", "Binance")  # Smart money
cg_net_position_v2("BTC")  # Net positioning
# Note: liquidation heatmap is unavailable on Startup; see "Plan Tiers" at the top

ETF Flow Monitoring

# Institutional demand
btc_flows = cg_btc_etf_flows()
eth_flows = cg_eth_etf_flows()
sol_flows = cg_sol_etf_flows()

Whale Tracking

# Follow the whales
hyperliquid_whales = cg_hyperliquid_whale_alerts()
whale_positions = cg_hyperliquid_whale_positions()
onchain_whales = cg_whale_transfers()  # >$10M on-chain

Volume Analysis

# Order flow
cvd = cg_cumulative_volume_delta("BTC", "Binance", "1h", 100)
netflow = cg_coin_netflow()  # All coins
taker_vol = cg_aggregated_taker_volume("BTC", "1h", 100)

Interpretation Guides

Funding Rates

| Rate (8h) | Read |

|------------|------|

| > +0.05% | Extreme greed — crowded long, squeeze risk |

| +0.01% to +0.05% | Bullish bias, normal |

| -0.005% to +0.01% | Neutral |

| -0.05% to -0.005% | Bearish bias, normal |

| < -0.05% | Extreme fear — crowded short, bounce risk |

Extreme funding often precedes reversals. The crowd is usually wrong at extremes.

Open Interest + Price Matrix

| OI | Price | Read |

|----|-------|------|

| Up | Up | New longs entering — bullish conviction |

| Up | Down | New shorts entering — bearish conviction |

| Down | Up | Short covering — weaker rally, less conviction |

| Down | Down | Long liquidation — weaker selloff, capitulation |

Long/Short Ratio

| Ratio | Read |

|-------|------|

| > 1.5 | Crowded long — contrarian bearish |

| 1.1–1.5 | Moderately bullish |

| 0.9–1.1 | Balanced |

| 0.7–0.9 | Moderately bearish |

| < 0.7 | Crowded short — contrarian bullish |

CVD (Cumulative Volume Delta)

| Pattern | Read |

|---------|------|

| CVD rising, price rising | Strong buy pressure, healthy uptrend |

| CVD falling, price rising | Weak rally, distribution |

| CVD rising, price falling | Accumulation, potential bottom |

| CVD falling, price falling | Strong sell pressure, healthy downtrend |

ETF Flows

| Flow | Read |

|------|------|

| Large inflows | Institutional buying, bullish |

| Consistent inflows | Sustained demand |

| Large outflows | Institutional selling, bearish |

| Premium to NAV | High demand, bullish sentiment |

| Discount to NAV | Weak demand, bearish sentiment |

Analysis Patterns

Multi-metric confirmation: Combine tools across categories for high-confidence signals:

Smart money vs retail: Compare metrics to identify divergence:

Cascade prediction: Use liquidation tools to predict volatility:

Flow divergence: Track capital movements:

Performance Optimization

Batch vs Individual Calls

✅ OPTIMAL: Use batch endpoints

# Whole-market current OI: coingecko cg_derivatives (coins-markets is plan-gated)

# One call gets all whale alerts
whales = cg_hyperliquid_whale_alerts()

# One call gets all ETF flows
btc_etf = cg_btc_etf_flows()

❌ INEFFICIENT: Multiple individual calls

# Don't do this - wastes API quota
btc = cg_pair_market_data("BTC", "Binance")
eth = cg_pair_market_data("ETH", "Binance")
sol = cg_pair_market_data("SOL", "Binance")

Query Parameters

Most history endpoints support:

Example:

cg_coin_liquidation_history(
    symbol="BTC",
    interval="1h",
    limit=100,
    start_time=1704067200000,  # 2024-01-01
    end_time=1704153600000     # 2024-01-02
)

Supported Exchanges

Major exchanges with futures data:

Use cg_supported_exchanges() for complete list with pair details.

Important Notes

Hyperliquid position return 401 Upgrade plan (raises CoinglassPlanError).

If the user needs this data → have them provide their own key (COINGLASS_DIRECT=1 + own

COINGLASS_API_KEY, direct call), or scrape coinglass.com pages with the Apify skill.

Data Quality Notes

Version History

aggregated taker volume (exchange_list), price history (pair symbol)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.