$BTC
import requests
import matplotlib.pyplot as plt
import numpy as np
# 1. CoinGlass API から清算データを取得
def get_liquidation_data(symbol="BTC"):
url = "https://open-api.coinglass.com/api/futures/liquidation/chart"
headers = {"coinglass-api-key": "YOUR_API_KEY"} # APIキーをここに入力
params = {
"symbol": symbol,
"exchange": "all",
"timeType": "7d" # スクリーンショットと同様に直近7日データ
}
response = requests.get(url, headers=headers, params=params)
data = response.json()
return data['data']
# 2. 清算ヒートマップを描画
def plot_liquidation_map(data):
prices = data['priceList'] # 価格レベル
long_liq = data['longList'] # ロング清算額
short_liq = data['shortList'] # ショート清算額
current_price = data['currentPrice']
plt.figure(figsize=(14,7))
# ショート清算をプロット - 左側の赤い領域
plt.bar(prices, short_liq, color='red', alpha=0.5, label='Short Liquidations')
# ロング清算をプロット - 右側の緑の領域
plt.bar(prices, long_liq, color='green', alpha=0.5, label='Long Liquidations')
# 現在価格のライン
plt.axvline(x=current_price, color='red', linestyle='--', linewidth=2, label=f'Current Price: ${current_price}')
plt.title("BTC 取引所 清算ヒートマップ", fontsize=16, fontweight='bold')
plt.xlabel("BTC 価格 (USD)")
plt.ylabel("清算額 (USD)")
plt.legend()
plt.grid(axis='y', alpha=0.3)
plt.show()
# 3. 実行方法
if __name__ == "__main__":
print("BTC の清算データを取得しています...")
data = get_liquidation_data("BTC")
plot_liquidation_map(data)
import requests
import matplotlib.pyplot as plt
import numpy as np
# 1. CoinGlass API から清算データを取得
def get_liquidation_data(symbol="BTC"):
url = "https://open-api.coinglass.com/api/futures/liquidation/chart"
headers = {"coinglass-api-key": "YOUR_API_KEY"} # APIキーをここに入力
params = {
"symbol": symbol,
"exchange": "all",
"timeType": "7d" # スクリーンショットと同様に直近7日データ
}
response = requests.get(url, headers=headers, params=params)
data = response.json()
return data['data']
# 2. 清算ヒートマップを描画
def plot_liquidation_map(data):
prices = data['priceList'] # 価格レベル
long_liq = data['longList'] # ロング清算額
short_liq = data['shortList'] # ショート清算額
current_price = data['currentPrice']
plt.figure(figsize=(14,7))
# ショート清算をプロット - 左側の赤い領域
plt.bar(prices, short_liq, color='red', alpha=0.5, label='Short Liquidations')
# ロング清算をプロット - 右側の緑の領域
plt.bar(prices, long_liq, color='green', alpha=0.5, label='Long Liquidations')
# 現在価格のライン
plt.axvline(x=current_price, color='red', linestyle='--', linewidth=2, label=f'Current Price: ${current_price}')
plt.title("BTC 取引所 清算ヒートマップ", fontsize=16, fontweight='bold')
plt.xlabel("BTC 価格 (USD)")
plt.ylabel("清算額 (USD)")
plt.legend()
plt.grid(axis='y', alpha=0.3)
plt.show()
# 3. 実行方法
if __name__ == "__main__":
print("BTC の清算データを取得しています...")
data = get_liquidation_data("BTC")
plot_liquidation_map(data)
