perp-funding-basis
What it does
This skill explains funding rates and the basis gap on crypto perpetual futures. It is for traders who want to gauge market crowding or test carry trades.
When to use it
- βWhen you want to know whether traders in a crypto market are heavily long or short.
- βWhen funding rates on a perpetual contract have become unusually high or negative.
- βWhen you are comparing a spot price with a futures price to look for a carry trade.
Skill link
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/perp-funding-basis/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βAre funding rates on Bitcoin perpetuals unusually high right now, and what does that mean?β
5 new skills a week. 1 minute to read.
How it works
It converts the funding rate into an annual figure and compares futures prices with spot prices. High positive funding suggests crowded long positions, while negative funding suggests crowded shorts.
Technical content (original SKILL.md)
Original text by the author, straight from 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
FAQ
Who pays the funding rate?
When funding is positive, longs pay shorts. When it is negative, shorts pay longs.
How often is funding paid?
On most exchanges, including OKX, funding is paid every 8 hours.
What is a cash-and-carry trade?
It buys the spot asset and sells futures to capture the basis gap, and it still carries some risk.
Details
Original description by the author
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
Popularity
- GitHub stars
- 37k
- Ranking position
- #7542
- License
- MIT
- Updated
- 11/1/2026
Comments
- β¦
More skills from this repository
vibe-trading
37kGives your agent a full finance research toolkit, covering backtests, factor analysis, options pricing and market data across many markets.
adr-hshare
37kShows your agent how to compare the price of a Chinese company listed in several markets, such as a US ADR and a Hong Kong share.
akshare
37kLets your agent pull free market data for Chinese and global stocks, futures, forex and economic indicators, with no API key needed.
alpha-zoo
37kLets your agent browse a library of ready-made stock factors and test how well a whole set of them predicts returns on a chosen market.
Similar skills
gitcrawl
394kLets your agent search a saved archive of GitHub issues and pull requests, group duplicates, and check their current status on GitHub.
slacrawl
394kLets your agent search and count messages in a local Slack archive, check how fresh that archive is, and refresh it when needed.
goplaces
394kHelps your agent search for places, get their details and reviews, and resolve place names using Google Places, with JSON output for scripts.