market-basis
Skill3 starsChanged 4 months agoMITView on GitHub
Perpetual swap market structure: funding rate, spot-perp basis, and squeeze/RSI on both sides. Use to gauge positioning cost, directional bias in perp markets, and spot-perp divergence. Requires --source ccxt or ccxt:exchange.
In this repository47 other files it gives its agents.
- AGENTS.mdAGENTS.md
- beadsSkill
- backtest-engineSkill
- backtest-pipelineSkill
- backtest-trend-minerSkill
- bug-scanSkill
- daily-trade-pickSkill
- execution-kraken-perpsSkill
- execution-kraken-spotSkill
- l3-conviction-scanSkill
- market-accumulationSkill
- market-breadthSkill
- market-breakoutSkill
- market-emaSkill
- market-exhaustionSkill
- market-fibonacciSkill
- market-liquidity-sweepSkill
- market-macdSkill
- market-macroSkill
- market-moversSkill
- market-notesSkill
- market-overviewSkill
- market-rsiSkill
- market-snapshotSkill
- market-squeezeSkill
- market-s-rSkill
- market-stateSkill
- market-trend-qualitySkill
- market-trendSkill
- market-valuationSkill
- market-volatilitySkill
- market-volumeSkill
- market-watchlistSkill
- portfolio-mgmtSkill
- position-watchdogSkill
- risk-engineSkill
- run-all-l2Skill
- run-all-l3Skill
- run-watchlistSkill
- strategy-accumulation-swingSkill
- strategy-breakout-confirmSkill
- strategy-exhaustion-fadeSkill
- strategy-fitness-heatmapSkill
- strategy-funding-carrySkill
- strategy-liquidity-sweepSkill
- strategy-mean-reversionSkill
- strategy-trend-followSkill
The file
Files
market-basis
Analyzes perpetual swap market structure for any ticker on supported CCXT exchanges. Reports funding rate (current and historical average), spot-perp basis, and compares squeeze momentum and RSI between spot and perpetual markets.
When NOT to use
- For price-direction calls — this skill only reports perp/venue state (funding, basis, spot-vs-perp divergence), not which way to trade. Use the market-* trend indicators for direction.
- For spot execution or spot analysis — it requires
--source ccxtand a perp ticker (BTC/USDT); without a/it is treated as spot and yields no funding/basis. - As a standalone trade signal — pair the positioning read with
market-trend-quality/market-squeezefor directional context.
Quick Start
uv run skills/market-basis/scripts/run.py BTC/USDT --source ccxt:binance --jsonFlags
| Flag | Default | Notes |
TICKER (positional) | BTC/USDT | Perp ticker (BTC/USDT, ETH/USDT, etc.). Without a /, treated as spot. |
--source=PROVIDER | ccxt:binance | CCXT provider and exchange. Other CCXT exchanges: ccxt:bybit, ccxt:okx, ccxt:bitfinex, etc. |
--interval=INTERVAL | 1d | 1m/5m/15m/30m/1h/2h/4h/8h/12h/1d/3d/1wk/1M. |
--period=PERIOD | 6mo | 1d/5d/1mo/3mo/6mo/1y/2y/5y/10y/ytd/max. |
--json | human | Emit JSON to stdout. |
Both timeframe flags are validated — bad values exit 2 with a friendly error. Period defaults to 6mo (vs 1y elsewhere) because basis/funding analysis is most meaningful on the recent half-year.
What it returns
- Funding: current rate, 30-period average, annualized APR
- Basis: perp vs spot price difference in absolute and percentage terms
- Spot analysis: squeeze signal, RSI, trend (EMA21/50)
- Perp analysis: squeeze signal, RSI, trend (EMA21/50)
- Divergence: flags when spot and perp disagree on squeeze direction or RSI zone
Signal Interpretation
| Signal | Meaning |
| Funding > +0.01% / 8h | Longs paying shorts — bullish positioning, potential crowded trade |
| Funding < -0.01% / 8h | Shorts paying longs — bearish positioning, potential short squeeze |
| Positive basis (contango) | Perp above spot — bullish demand for leveraged exposure |
| Negative basis (backwardation) | Perp below spot — bearish or hedging pressure |
| Squeeze divergence | Spot and perp show different squeeze signals — structural disagreement |
Edge Cases
- Funding rates only available on perp-capable exchanges (binance, bybit, okx, etc.)
- Some exchanges update funding every 8h, others every 1h or 4h
- Lightly traded perps may have stale or erratic funding data
- Best paired with
market-trend-qualityandmarket-squeezefor directional context
Output envelope (AXI)
--json output follows the canonical AXI envelope — {data, count, errors, help[]}. Default schema is the per-skill minimal fields (3-6 essentials); pass --fields=<csv> to project or --full for the full payload. count is the item count, help[] is contextual next-step command templates. Lib.py return shapes (L1Result / L2Result / L3Result / L3Idea / RegimeSignal) are unchanged — the envelope wraps them at the scripts/run.py boundary.
Home view (no-arg mode)
No-arg mode prints the home view from $XDG_DATA_HOME/market-skills/<skill>_last.json (last successful run). Errors are not cached.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

