perp-funding-basis
它能做什么
这项技能解释加密货币永续合约上的资金费率和基差。适合希望衡量市场拥挤程度或测试套利交易的交易者。
适用场景
- ✓当你想知道某个加密货币市场中的交易者是否大量持有多头或空头的时候。
- ✓当某个永续合约的资金费率异常高或为负的时候。
- ✓当你比较现货价格与期货价格以寻找套利交易的时候。
技能链接
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/perp-funding-basis/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“比特币永续合约的资金费率现在是否异常高?这意味着什么?”
每周 5 个新技能,1 分钟读完。
工作原理
它会把资金费率换算为年化数字,并将期货价格与现货价格进行比较。资金费率为较大正值时,表示多头持仓拥挤;为负值时,表示空头持仓拥挤。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Perpetual Funding Rate & Basis Trading
Overview
Analyze perpetual futures funding rates and spot-futures basis to identify carry trade opportunities, market positioning extremes, and directional sentiment signals. Funding rates are the single most important microstructure indicator in crypto derivatives — they reveal real-time leverage positioning and crowd sentiment.
Core Concepts
1. Funding Rate Mechanics
Perpetual futures have no expiry date. Instead, a funding rate is exchanged between longs and shorts every 8 hours (on most exchanges) to keep the perpetual price anchored to the spot price.
If perp price > spot price → funding rate positive → longs pay shorts
If perp price < spot price → funding rate negative → shorts pay longs
OKX funding rate schedule: payments at 00:00, 08:00, 16:00 UTC
Annualized funding rate:
# Funding rate is a per-8h DECIMAL, exactly as OKX/Binance return it
# (the API sends "0.0001" for 0.01%). 3 funding windows/day → × 3 × 365.
funding_rate_8h = 0.0001 # 0.01% per 8h, as a decimal
annualized = funding_rate_8h * 3 * 365 # 0.1095 → 10.95% annualized
Units convention (whole skill): all code treats the funding rate as a per-8h decimal (
0.0001= 0.01%), matching the raw OKX/Binance API value. The tables below show the equivalent percentages for readability — divide a table's%by 100 to get the decimal a comparison expects (+0.05%→0.0005).
2. Funding Rate Signal Framework
| Funding Rate (8h) | Annualized | Market State | Signal |
|---|---|---|---|
| > +0.05% | > +54.75% | Extreme long crowding | Contrarian short / reduce longs |
| +0.02% to +0.05% | +21.9% to +54.75% | Elevated long bias | Cautious, carry trade viable |
| +0.005% to +0.02% | +5.5% to +21.9% | Mild long bias | Neutral to mild bullish |
| -0.005% to +0.005% | -5.5% to +5.5% | Balanced | Neutral |
| -0.02% to -0.005% | -21.9% to -5.5% | Mild short bias | Neutral to mild bearish |
| < -0.02% | < -21.9% | Short squeeze territory | Contrarian long / reduce shorts |
Funding rate regime detection:
def funding_regime(rates_7d):
"""Classify funding rate regime from 7-day history."""
avg = sum(rates_7d) / len(rates_7d)
consecutive_positive = all(r > 0 for r in rates_7d[-3:])
consecutive_negative = all(r < 0 for r in rates_7d[-3:])
if avg > 0.0003 and consecutive_positive: # > +0.03% per 8h
return "overheated_long" # High risk of long squeeze
elif avg > 0.0001 and consecutive_positive: # > +0.01% per 8h
return "bullish_carry" # Good carry trade environment
elif avg < -0.0002 and consecutive_negative: # < -0.02% per 8h
return "overheated_short" # High risk of short squeeze
elif avg < -0.00005 and consecutive_negative: # < -0.005% per 8h
return "bearish_carry" # Inverse carry trade
else:
return "neutral"
3. Spot-Futures Basis Analysis
Basis = Futures price - Spot price
For dated futures (quarterly), basis reflects cost-of-carry expectations:
# Annualized basis
def annualized_basis(futures_price, spot_price, days_to_expiry):
basis_pct = (futures_price - spot_price) / spot_price
annualized = basis_pct * (365 / days_to_expiry)
return annualized
# Example: BTC spot $65,000, quarterly future $66,500, 45 days to expiry
# Basis: 2.31%, Annualized: 18.7%
Basis signal interpretation:
| Annualized Basis | Market State | Signal |
|---|---|---|
| > 30% | Extreme contango, euphoric leverage | Sell basis (cash-carry), top warning |
| 15-30% | Elevated contango, bullish leverage | Carry trade attractive |
| 5-15% | Normal contango | Neutral, mild bullish |
| 0-5% | Flat basis | Low conviction, wait for direction |
| < 0% (backwardation) | Bearish, forced selling | Contrarian long, extreme pessimism |
4. Cash-Carry Arbitrage (Delta-Neutral)
Strategy: buy spot + sell perpetual futures → collect funding rate
# Cash-carry trade P&L
def carry_trade_pnl(spot_entry, funding_rates, position_size):
"""
Delta-neutral carry: long spot + short perp
P&L comes purely from funding rate collection.
"""
total_funding_collected = 0
for rate in funding_rates:
if rate > 0: # Longs pay shorts → we collect as short
total_funding_collected += rate
常见问题
谁来支付资金费率?
资金费率为正时,多头支付给空头;为负时,空头支付给多头。
资金费率多久支付一次?
在包括 OKX 在内的大多数交易所,每 8 小时支付一次。
什么是现货-期货套利?
它买入现货并卖出期货,以获取基差收益,但仍存在一定风险。
详情
作者的原始描述
Perpetual futures funding rate analysis and cash-carry basis trading — funding rate regimes, annualized basis signals, carry trade construction, and funding rate arbitrage between exchanges.
repo: HKUDS/Vibe-Trading
热度
- GitHub 星标
- 37k
- 排名
- #7542
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …