Agent skill

Perpetual Funding and Basis Trading

by HKUDS in HKUDS/Vibe-Trading

Analyzes perpetual futures funding rates and spot-futures basis to find carry trades, crowded positioning and sentiment signals, including funding arbitrage between exchanges.

MITAuto-check passedBusiness, Finance & HR

Install Perpetual Funding and Basis Trading

skills CLI
$ npx skills add HKUDS/Vibe-Trading --skill perp-funding-basis -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install HKUDS/Vibe-Trading perp-funding-basis --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/HKUDS/Vibe-Trading.git skills-src && mkdir -p .claude/skills && cp -r skills-src/agent/src/skills/perp-funding-basis .claude/skills/perp-funding-basis && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
perp-funding-basis
GitHub stars
35k
Token cost
~2.7k tokens
SKILL.md length
675 words
Files
1
Skills in repo
89
Repo updated
First seen
Licence
MIT

At a glance

Analyzes perpetual futures funding rates and spot-futures basis to find carry trades, crowded positioning and sentiment signals, including funding arbitrage between exchanges.

  • Works in 7 steps: Funding Rate Mechanics → Funding Rate Signal Framework → Spot-Futures Basis Analysis → …
  • Reading funding rates as a signal of long or short crowding
  • SKILL.md covers Overview, Core Concepts, Data Access and Output Format, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Funding rates are treated here as a key microstructure indicator of crowded positioning and crowd sentiment in crypto derivatives. The skill explains the 8-hour funding exchange between longs and shorts on perpetual contracts, the OKX payment times of 00:00, 08:00 and 16:00 UTC, and annualization by multiplying a per-8h rate by three windows a day and 365 days.

A units convention keeps the code consistent by treating funding as a per-8h decimal, with the tables in percentages for readability. A signal table maps funding bands to market states, from extreme long crowding with a contrarian short signal to short-squeeze territory with a contrarian long signal, and a regime function classifies a 7-day history. The skill then covers spot-futures basis for dated futures, carry trade construction and funding arbitrage across exchanges.

When your agent uses it

  • Reading funding rates as a signal of long or short crowding
  • Annualizing a funding rate to compare carry opportunities
  • Analyzing the basis between spot and quarterly futures
  • Comparing funding rates across exchanges for arbitrage

Example prompts

  • “Annualize an 8-hour funding rate of 0.01% and tell me whether the carry is worth it.”
  • “Classify the funding regime from the last 7 days of OKX rates.”
  • “Is a funding rate above +0.05% a sign of extreme long crowding?”
  • “Compute the annualized basis for the quarterly BTC future against spot.”

Workflow steps

7 steps, taken from the step headings in SKILL.md.

  1. Funding Rate Mechanics
  2. Funding Rate Signal Framework
  3. Spot-Futures Basis Analysis
  4. Cash-Carry Arbitrage (Delta-Neutral)
  5. Cross-Exchange Funding Arbitrage
  6. Funding Rate as Directional Indicator
  7. Open Interest × Funding Rate Matrix

What it can do on your machine

Read from SKILL.md and the folder at commit 8e43007. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Perpetual Funding and Basis Trading loads about 2.7k tokens when it runs. Until then it costs about 52 tokens; SKILL.md has 675 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~52
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from HKUDS/Vibe-Trading at commit 8e43007, republished under its MIT licence (© HKUDS). 675 words, ~2,674 tokens.

Download SKILL.mdSave it as .claude/skills/perp-funding-basis/SKILL.md (or your agent's skills folder).
name
perp-funding-basis
description
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.
category
crypto

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:

python
# 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)AnnualizedMarket StateSignal
> +0.05%> +54.75%Extreme long crowdingContrarian short / reduce longs
+0.02% to +0.05%+21.9% to +54.75%Elevated long biasCautious, carry trade viable
+0.005% to +0.02%+5.5% to +21.9%Mild long biasNeutral to mild bullish
-0.005% to +0.005%-5.5% to +5.5%BalancedNeutral
-0.02% to -0.005%-21.9% to -5.5%Mild short biasNeutral to mild bearish
< -0.02%< -21.9%Short squeeze territoryContrarian long / reduce shorts

Funding rate regime detection:

python
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:

python
# 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 BasisMarket StateSignal
> 30%Extreme contango, euphoric leverageSell basis (cash-carry), top warning
15-30%Elevated contango, bullish leverageCarry trade attractive
5-15%Normal contangoNeutral, mild bullish
0-5%Flat basisLow conviction, wait for direction
< 0% (backwardation)Bearish, forced sellingContrarian long, extreme pessimism
4. Cash-Carry Arbitrage (Delta-Neutral)

Strategy: buy spot + sell perpetual futures → collect funding rate

python
# 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 * position_size
        else:  # Shorts pay longs → we pay as short
            total_funding_collected += rate * position_size  # This is negative

    return total_funding_collected

# Example: $100,000 position, avg funding +0.015% (0.00015 decimal) per 8h, 30 days
# Revenue: 0.00015 × 3 × 30 × $100,000 = $1,350 (16.4% annualized)

Carry trade execution on OKX:

  1. Buy spot BTC-USDT on OKX spot market
  2. Open equal-sized short BTC-USDT-SWAP on OKX perpetual
  3. Net delta = 0 (spot long cancels perp short)
  4. Collect positive funding rate every 8 hours
  5. Close both legs when funding rate turns negative or basis compresses

Risk factors:

  • Funding rate can flip negative → carry becomes a cost
  • Liquidation risk on short perp if insufficient margin (use 3-5x max leverage)
  • Exchange counterparty risk (keep position across 2-3 exchanges)
  • Basis can widen further before mean-reverting → mark-to-market loss on short leg
5. Cross-Exchange Funding Arbitrage

Different exchanges have different funding rates for the same asset. Arbitrage the spread:

python
# Example: BTC-USDT perpetual funding rates
exchange_rates = {          # per-8h decimals (API-native)
    "OKX": 0.00015,     # +0.015% per 8h
    "Binance": 0.00020, # +0.020% per 8h
    "Bybit": 0.00025,   # +0.025% per 8h
}

# Strategy: short on highest funding (Bybit) + long on lowest funding (OKX)
# Net carry = 0.00025 - 0.00015 = 0.00010 per 8h  (0.010%)
# Annualized: 0.00010 × 3 × 365 = 0.1095 → 10.95%
# Risk: execution cost + potential for rates to converge/flip
Show full SKILL.md (264 more words)Show less
6. Funding Rate as Directional Indicator

Divergence signals (most powerful):

Price ActionFunding RateInterpretationSignal
Price making new highsFunding decliningLongs not chasing → distributionBearish divergence
Price making new lowsFunding rising (less negative)Shorts not pressing → accumulationBullish divergence
Price consolidatingFunding spiking positiveLeverage building without breakoutSqueeze risk
Price consolidatingFunding deeply negativeShorts paying heavy cost to maintainShort squeeze imminent

Historical pattern statistics (BTC):

  • Funding > +0.05% for 3+ consecutive periods → 70% probability of a 5-10% correction within 7 days
  • Funding < -0.03% for 3+ consecutive periods → 65% probability of a 5-15% bounce within 7 days
  • These are contrarian signals; funding rate extremes indicate crowded positioning
7. Open Interest × Funding Rate Matrix
python
# Combined OI + Funding signal
def oi_funding_matrix(oi_change_24h_pct, funding_rate):
    if oi_change_24h_pct > 5 and funding_rate > 0.0003:       # funding > +0.03%
        return "leveraged_long_buildup"    # High risk, squeeze potential
    elif oi_change_24h_pct > 5 and funding_rate < -0.0001:    # funding < -0.01%
        return "leveraged_short_buildup"   # Short squeeze potential
    elif oi_change_24h_pct < -5 and funding_rate > 0:
        return "long_liquidation"          # Forced long closing
    elif oi_change_24h_pct < -5 and funding_rate < 0:
        return "short_liquidation"         # Forced short closing
    elif abs(oi_change_24h_pct) < 2 and abs(funding_rate) < 0.00005:  # |funding| < 0.005%
        return "quiet_market"              # Low conviction, wait
    else:
        return "mixed"

Data Access

Via OKX API
python
# Funding rate history
# GET /api/v5/public/funding-rate-history?instId=BTC-USDT-SWAP

# Current funding rate
# GET /api/v5/public/funding-rate?instId=BTC-USDT-SWAP

# Open interest
# GET /api/v5/public/open-interest?instType=SWAP&instId=BTC-USDT-SWAP

Use load_skill("okx-market") for OKX data retrieval patterns.

Key Metrics to Track
MetricSourceFrequencyAlert Threshold
BTC funding rate (8h)OKX / BinanceEvery 8h> +0.05% or < -0.03%
ETH funding rate (8h)OKX / BinanceEvery 8h> +0.05% or < -0.03%
Annualized basis (quarterly)OKXContinuous> 30% or < 0%
BTC open interest changeOKXHourly> ±5% in 24h
Cross-exchange funding spreadMulti-exchangeEvery 8hSpread > 0.02%

Output Format

## Funding Rate & Basis Analysis — [Asset]

### Current Funding Rates
| Exchange | 8h Rate | Annualized | Regime |
|----------|---------|------------|--------|
| OKX | +0.015% | +16.4% | bullish_carry |
| Binance | +0.020% | +21.9% | bullish_carry |

### Basis Structure
- **Spot price**: $XX,XXX
- **Perp price**: $XX,XXX (premium: X.XX%)
- **Quarterly futures**: $XX,XXX (annualized basis: X.X%)
- **Basis regime**: [contango / flat / backwardation]

### Funding History (7-day)
- **Average**: +X.XXX%
- **Trend**: [rising / stable / declining]
- **Consecutive direction**: [X periods positive/negative]

### Open Interest
- **Current OI**: $X.XB
- **24h change**: [+/-X%]
- **OI × Funding signal**: [leveraged_long_buildup / quiet / etc.]

### Carry Trade Opportunity
- **Best carry**: [short on Exchange X, long spot]
- **Expected annualized yield**: X.X%
- **Risk**: [funding flip probability, liquidation distance]

### Directional Signal
- **Funding regime**: [overheated / bullish / neutral / bearish / oversold]
- **Divergence**: [none / bullish / bearish]
- **Confidence**: [high / medium / low]

Notes

  • Funding rates are exchange-specific; always compare across OKX, Binance, and Bybit for the full picture
  • Extremely high funding rates are a cost for longs, not a bullish signal — they indicate overcrowded positioning
  • Cash-carry trades have execution risk: slippage on entry/exit, funding rate flipping, and exchange downtime during volatility
  • Basis and funding rate signals work best when combined with on-chain data (MVRV, exchange flows)
  • This framework is for research purposes only and does not constitute investment advice

© HKUDS, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in agent/src/skills/perp-funding-basis of HKUDS/Vibe-Trading.

Open the folder on GitHubat commit 8e43007

Compare with similar skills

Perpetual Funding and Basis Trading next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Perpetual Funding and Basis Trading compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Perpetual Funding and Basis Trading this skillHKUDS/Vibe-Trading35k—~2.7kAutomated safety check: PassMIT
ArbiscanLeoYeAI/openclaw-master-skills2.2k—~4.7kAutomated safety check: PassMIT
Okx Cex Marketdex-original/okx-agent-trade-kit1101 repos~2.7kAutomated safety check: PassMIT
Fintoolsecond-state/fintool316—~5.9kAutomated safety check: PassNone
Okx Cex Smartmoneydex-original/okx-agent-trade-kit1101 repos~1.4kAutomated safety check: PassMIT
Okx Sentiment Trackerdex-original/okx-agent-trade-kit1101 repos~3.8kAutomated safety check: PassMIT

Similar skills

  • Arbiscan

    LeoYeAI/openclaw-master-skills

    Comprehensive crypto market scanner across Binance, OKX, Bybit, and Bitget.

    2.2k GitHub stars~4.7k tokensUpdated 2 mo ago
    Business, Finance & HRAuto-check passed
  • Okx Cex Market

    dex-original/okx-agent-trade-kit

    A skill your agent uses when the user asks for: price of any asset, ticker, order book, candles, OHLCV, funding rate, open interest, OI change scanner, market screener (top movers, high-volume…

    110 GitHub starsUsed in 1 repo~2.7k tokens
    Business, Finance & HRAuto-check passed
  • Fintool

    second-state/fintool

    Financial trading CLIs — spot and perp trading on Hyperliquid, Binance, Coinbase, OKX.

    316 GitHub stars~5.9k tokensUpdated 4 mo ago
    Business, Finance & HRAuto-check passed
  • Okx Cex Smartmoney

    dex-original/okx-agent-trade-kit

    Smart Money analytics on OKX: leaderboard traders, position tracking, trade records, aggregated consensus signals, and signal history.

    110 GitHub starsUsed in 1 repo~1.4k tokens
    Business, Finance & HRAuto-check passed
  • Okx Sentiment Tracker

    dex-original/okx-agent-trade-kit

    A skill your agent uses when the user asks about: 'any crypto news', 'latest news', 'market update', 'daily briefing', 'BTC news', 'ETH news', 'news on SOL', 'search SEC ETF', 'regulation news'…

    110 GitHub starsUsed in 1 repo~3.8k tokens
    Business, Finance & HRAuto-check passed
  • Academy Skill

    binance/binance-skills-hub

    Retrieve Binance Academy's official educational content (Glossary, Courses, Learn & Earn, Articles) for AI chat.

    1.1k GitHub stars~3.5k tokensUpdated 1 mo ago
    Business, Finance & HRAuto-check: notes

More from HKUDS/Vibe-Trading

All 89 skills in this repo
  • Eastmoney Market Data

    HKUDS/Vibe-Trading

    Index of Eastmoney's free, no-token market data interfaces for China A-shares and Hong Kong stocks: fund flows, dragon-tiger lists, margin trading, reports and news.

    35k GitHub stars~1k tokensUpdated today
    Auto-check passed
  • OKX Market Data

    HKUDS/Vibe-Trading

    Retrieves public OKX cryptocurrency market data such as spot prices, candlesticks, funding rates and open interest through the OKX V5 REST API, with no authentication.

    35k GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • SEC EDGAR Filings Fetcher

    HKUDS/Vibe-Trading

    Fetches U.S. SEC EDGAR data: resolves tickers to CIK numbers, lists recent 10-K, 10-Q and 8-K filings with document URLs, and pulls XBRL financial series.

    35k GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • A-Share ST Risk Screener

    HKUDS/Vibe-Trading

    Predicts whether a mainland China A-share company risks an ST or *ST warning after its next annual report, using financial thresholds and Sina penalty records.

    35k GitHub stars~4.9k tokensUpdated today
    Auto-check passed
  • Breaks a structural trend such as AI infrastructure into its physical supply chain and ranks lesser-known listed companies sitting on each bottleneck.

    35k GitHub stars~2.7k tokensUpdated today
    Auto-check passed
  • Plans and drafts an eight-part, roughly 120k-word investigative series on one company, built around a strict fact-check pass rather than fast drafting.

    35k GitHub stars~2.4k tokensUpdated today
    Auto-check passed

Works with

Questions about Perpetual Funding and Basis Trading

What does Perpetual Funding and Basis Trading do?

Analyzes perpetual futures funding rates and spot-futures basis to find carry trades, crowded positioning and sentiment signals, including funding arbitrage between exchanges. Funding rates are treated here as a key microstructure indicator of crowded positioning and crowd sentiment in crypto derivatives. The skill explains the 8-hour funding exchange between longs and shorts on perpetual contracts, the OKX payment times of 00:00, 08:00 and 16:00 UTC, and annualization by multiplying a per-8h rate by three windows a day and 365 days.

When should I use Perpetual Funding and Basis Trading?

Perpetual Funding and Basis Trading fits situations like: reading funding rates as a signal of long or short crowding; annualizing a funding rate to compare carry opportunities; analyzing the basis between spot and quarterly futures; comparing funding rates across exchanges for arbitrage.

How do I install Perpetual Funding and Basis Trading in Claude Code?

Run `npx skills add HKUDS/Vibe-Trading --skill perp-funding-basis -a claude-code`. Or copy the skill folder (agent/src/skills/perp-funding-basis in HKUDS/Vibe-Trading) into .claude/skills/perp-funding-basis in your project. Claude Code loads it when a task matches its description.

How do I install Perpetual Funding and Basis Trading in Codex?

Run `npx skills add HKUDS/Vibe-Trading --skill perp-funding-basis -a codex`. Or copy the skill folder (agent/src/skills/perp-funding-basis in HKUDS/Vibe-Trading) into .agents/skills/perp-funding-basis in your project. Codex loads it when a task matches its description.

Can I use Perpetual Funding and Basis Trading in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add HKUDS/Vibe-Trading --skill perp-funding-basis -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/perp-funding-basis, .gemini/skills/perp-funding-basis, .github/skills/perp-funding-basis and .opencode/skills/perp-funding-basis in your project.

What does Perpetual Funding and Basis Trading need to run?

SKILL.md names no scripts, command-line tools or credentials: Perpetual Funding and Basis Trading is instructions for the agent only.

Does Perpetual Funding and Basis Trading access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Perpetual Funding and Basis Trading safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Perpetual Funding and Basis Trading use?

Perpetual Funding and Basis Trading is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Perpetual Funding and Basis Trading use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Perpetual Funding and Basis Trading?

Skills that share tags, products or a category with Perpetual Funding and Basis Trading: Arbiscan (LeoYeAI/openclaw-master-skills, 2.2k stars), Okx Cex Market (dex-original/okx-agent-trade-kit, 110 stars), Fintool (second-state/fintool, 316 stars) and Okx Cex Smartmoney (dex-original/okx-agent-trade-kit, 110 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Perpetual Funding and Basis Trading?

HKUDS (a GitHub organization) maintains it in HKUDS/Vibe-Trading, which has 35,163 GitHub stars. The repository holds 89 skills in this directory. The repository was last updated on October 10, 2026.

Source: HKUDS/Vibe-Trading on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.