TRIGGER - perpetual swap, perp funding, funding interval, funding history, mark versus index versus last price, liquidation threshold, maintenance margin, inverse contract, cash-and-carry, basis to dated futures, open interest versus volume, why a perp backtest disagrees with cash P&L. SKIP for token swaps and delistings (crypto-token-events), AMM impact and LP fees (defi-and-amm-mechanics), calendars, outages and stablecoin depegs (crypto-market-structure), exchange clients and data fetching (crypto-data-and-execution), and rolling dated contracts (futures-continuous-contracts).
Ships in fin-crypto. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Keep three ledgers distinct: trade P&L, funding cash flows, and margin/liquidation state. A last-trade candle supplies none of the other two automatically.
✅ Source-verified 2026-09-14, web text: Bybit funding-fee documentation uses position value times funding rate; positive funding transfers from longs to shorts and negative funding reverses the direction. For a linear contract, position value uses quantity and mark price. Inverse contracts require the venue's coin-denominated valuation convention.
For a fixed linear quantity q, accumulate q * mark_at_settlement * rate in the cash account.
For shorts the funding sign reverses. If exposure changes, align the quantity held at the actual
settlement time; do not charge a rate simply because a bar exists. Separately record settlement
currency and any USD conversion.
✅ Measured 2026-09-14 by scripts/perpetuals.py, seed 20260910:
| Example | Result |
|---|---|
| Synthetic fixed $100,000 notional, 1,095 eight-hour settlements | $9,587 paid |
| Funding as a share of notional / initial margin at 10x | 9.59% / 95.9% |
| Fixed-quantity long, seeded moving settlement mark: price-only return | +47.67% |
| Same quantity and marks, accumulated funding cash debited | +36.82% |
| Funding cash divided by initial capital | 10.84% |
🚨 The two rows use different exposure policies. Fixed-notional funding sums to the rate
sum; fixed-quantity funding changes with the mark. The latter now uses a cash ledger rather
than compounding (1 + price_return - funding_rate) and calling it a buy-and-hold position.
These examples do not simulate survival of a leveraged margin account, collateral interest,
fees or position resizing.
The seeded generator combines a historical clamp-shaped formula with a configurable cap. Its default clamp and cap were drawn from different venues; it is not a current exchange replica. The resulting funding rate is a scenario assumption, not an empirical expected return.
✅ Source-verified 2026-09-14, web text: Bybit instruments-info
defines fundingInterval in minutes per instrument. Archive interval changes together with
realized funding. rate * 24 / interval_hours * 365 is a simple annualized quotation, not a
compounded or predictable return.
✅ Measured 2026-09-14: on the same uncapped premium path the illustrative four-hour rate is half the eight-hour rate. Multiplying a four-hour rate by three settlements per day therefore understates the annual quotation by a factor of two; a one-hour rate by a factor of eight. The demo's differing-length histories produce annual rates of 9.59%, 9.40% and 9.06%, respectively; they are not the same sampled history. Historical OKX instrument counts in the script remain 2026-09-08 snapshots, not current counts.
✅ Source-verified 2026-09-14, web text: Bybit mark-price rules use mark price for liquidation and describe a median construction, a moving basis and fallback criteria. The page permits selection-rule changes in volatile markets. Fetch the actual mark series when replaying a venue; do not claim a synthetic reconstruction is exchange truth.
✅ Measured 2026-09-14: 6,000 seeded paths, each six hours with ten-second observations. The script uses its historical median-mark model with a thirty-second basis average, not the current Bybit implementation. With assumed maintenance margin 0.4% and 50x leverage:
| Trigger model | Trigger hits | Last-trade hits | Trigger only | Last only |
|---|---|---|---|---|
| Median mark | 2,717 | 3,033 | 3 | 319 |
| Hypothetical index-only trigger | 2,699 | 3,033 | 37 | 371 |
“Trigger only” means the trigger crossed while last never crossed anywhere in the simulated path. Those counts prove the disagreement can occur; they do not estimate its live frequency. Sampling misses intrabar breaches, and actual liquidation fills depend on venue rules and depth.
For an isolated linear position, constant maintenance fraction m, leverage L and no fees:
long_liq/entry = (1 - 1/L)/(1 - m) and
short_liq/entry = (1 + 1/L)/(1 + m).
✅ Measured 2026-09-14: at the assumed 10x and 0.4% maintenance fraction, the long level is −9.64% from entry. Paying 0.01% every eight hours for thirty days consumes 0.90% of notional and moves that level to −8.73% even with a flat mark. Tiered margin, collateral haircuts, liquidation fees and cross-margin positions require more than this isolated-position formula.
annualised_basis() computes simple or compounded annual quotations from F/S and time to
expiry. deribit_curve() preserves the 2026-09-08 13:25 UTC historical constants recorded in
the original project. Its 3.10%–4.83% simple annualized curve is historical arithmetic; the
synthetic perp path is not a contemporaneous market comparison. A dated spot/futures hedge
requires financing, custody, fees and sufficient margin to survive until expiry; future perp
funding is unknown. Contract chains and roll yield belong to
../../../fin-futures-fx/skills/futures-continuous-contracts/SKILL.md.
🚨 Volume cannot uniquely identify position creation: opening on both sides increases OI, closing on both sides decreases it, and an opening/closing transfer leaves it unchanged. Aggregate price and OI do not identify traders' motives or prove “new money” versus covering.
✅ Measured 2026-09-14: the seeded tape has volume 366,697, net OI change +17,753 and signed volume/OI-change correlation −0.0005. Initial OI is a separate balance so simulated closes cannot create negative outstanding interest. These correlation values belong to this random tape.
Run python plugins/fin-crypto/skills/perpetuals-and-funding/scripts/perpetuals.py.
Pure functions cover funding histories/cash costs, fixed-quantity accounting, annualized rates,
liquidation thresholds, mark/last path comparisons, dated basis and OI accounting. The script
never connects to a venue, touches credentials or places orders.
../crypto-data-and-execution/SKILL.md — venue clients and funding-history collection.../crypto-token-events/SKILL.md — underlying migrations and contract delistings.../defi-and-amm-mechanics/SKILL.md — AMM-based liquidity; some on-chain perp venues instead
use order books, so inspect the actual design.../crypto-market-structure/SKILL.md — annualization, stablecoin collateral and ADL.../../../fin-core/skills/execution-cost-analysis/SKILL.md — liquidation impact.../../../fin-libraries/skills/lib-ccxt/SKILL.md — per-exchange funding capabilities.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
5 skills in this plugin
/crypto-data-and-executionTRIGGER - choose a crypto data or exchange client, Bitcoin or Ethereum OHLCV, crypto order book feeds, ccxt, cryptofeed, python-binance, freqtrade, jesse, hummingbot, OctoBot; exchange API pagination, testnet, sandbox, precision, retries, or order safety. SKIP for token migrations, rebases and delisted universes (crypto-token-events), perpetual funding and mark-price liquidation (perpetuals-and-funding), AMM pools and impermanent loss (defi-and-amm-mechanics), 365-day annualisation, venue outages and stablecoin depegs (crypto-market-structure), equity brokers (broker-execution-apis), RL agents (rl-and-ml-trading), and named-library implementation details (lib-ccxt, lib-freqtrade)./crypto-market-structureTRIGGER - crypto annualisation, 365 versus 252, weekend returns, 24/7 market, calendar-day rolling windows, exchange daily close timezone, cross-venue price dispersion, no consolidated tape, venue outage, auto-deleveraging, ADL, socialised losses, stablecoin depeg or quote-currency conversion. SKIP for token events and delisting universes (crypto-token-events), perpetual funding and mark-price liquidation (perpetuals-and-funding), AMM pools and LP fees (defi-and-amm-mechanics), and choosing exchange clients or fetching data (crypto-data-and-execution)./crypto-token-eventsTRIGGER - token swap, redenomination, migration, same ticker changed units, hard fork, airdropped fork coin, rebase, elastic supply, balance changed but price did not, wrapped or bridged token, delisted pair, reconstruct a historical top-N crypto universe, survivorship bias, a -90% day caused by a token conversion. SKIP for funding and liquidation (perpetuals-and-funding), AMM pools and LP losses (defi-and-amm-mechanics), 24/7 calendars, outages and stablecoin depegs (crypto-market-structure), and exchange clients and OHLCV fetching (crypto-data-and-execution)./defi-and-amm-mechanicsTRIGGER - AMM, constant-product pool, x*y=k, Uniswap v2 or v3, concentrated liquidity, LP position, impermanent loss, divergence loss, fee income versus IL, pool price impact, out-of-range liquidity, DEX quote versus fill, sandwich, MEV or gas. SKIP for funding, mark price and liquidation (perpetuals-and-funding), rebases and token swaps (crypto-token-events), calendars, venue outages and stablecoin depegs (crypto-market-structure), centralised exchange clients (crypto-data-and-execution), and quoting on an order book (market-making-models)./fin-crypto:perpetuals-and-fundingfrom fin-crypto
npx claudepluginhub howard-lynn-ye/fin-rsi --plugin fin-crypto