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.
tools/bitcoin_etf.py
1#!/usr/bin/env python32"""3Coinglass Bitcoin ETF Module45Provides Bitcoin ETF data including flows, net assets,6premium/discount, history, and Hong Kong ETF data.7"""89import sys10import json11import argparse12from typing import Dict, Any, Optional, List1314from ._api import cg_request151617def get_btc_etf_flows() -> Optional[List[Dict[str, Any]]]:18"""Get Bitcoin ETF flow history (inflows/outflows by fund)."""19return cg_request("api/etf/bitcoin/flow-history")202122def get_btc_etf_net_assets() -> Optional[List[Dict[str, Any]]]:23"""Get Bitcoin ETF net assets history."""24return cg_request("api/reference/bitcoin-etf-netassets-history")252627def get_btc_etf_premium_discount() -> Optional[List[Dict[str, Any]]]:28"""Get Bitcoin ETF premium/discount rate history."""29return cg_request("api/etf/bitcoin/premium-discount/history")303132def get_btc_etf_history(33etf_ticker: Optional[str] = None34) -> Optional[List[Dict[str, Any]]]:35"""36Get comprehensive Bitcoin ETF history.3738Args:39etf_ticker: Filter by specific ETF ticker (e.g. "GBTC", "IBIT").40"""41params = {}42if etf_ticker:43params["ticker"] = etf_ticker44return cg_request("api/etf/bitcoin/history", params=params or None)454647def get_btc_etf_list() -> Optional[List[Dict[str, Any]]]:48"""Get list of all Bitcoin ETFs with details."""49return cg_request("api/etf/bitcoin/list")505152def get_hk_btc_etf_flows() -> Optional[List[Dict[str, Any]]]:53"""Get Hong Kong Bitcoin ETF flow history."""54return cg_request("api/hk-etf/bitcoin/flow-history")555657def main():58"""CLI entry point."""59parser = argparse.ArgumentParser(description="Coinglass BTC ETF Tools")60parser.add_argument("action", choices=[61"flows", "assets", "premium", "history", "list", "hk-flows"62])63parser.add_argument("--ticker", help="ETF ticker filter")64parser.add_argument("--json", "-j", action="store_true")65args = parser.parse_args()6667actions = {68"flows": get_btc_etf_flows,69"assets": get_btc_etf_net_assets,70"premium": get_btc_etf_premium_discount,71"history": lambda: get_btc_etf_history(args.ticker),72"list": get_btc_etf_list,73"hk-flows": get_hk_btc_etf_flows,74}7576try:77result = actions[args.action]()78print(json.dumps(result, indent=2))79except Exception as e:80print(f"Error: {e}", file=sys.stderr)81sys.exit(1)828384if __name__ == "__main__":85main()86