Funding-carry on Hyperliquid perps
A real run of the strategy described below. Period: 2024-08-15 → 2026-04-30 (20 mo). View the full tearsheet — equity curve, per-trade detail, decomposed price-vs-funding P&L — in the Keel app.
Verified Keel backtest run. Past performance is not indicative of future returns.
Why funding matters on Hyperliquid
Funding is a real cashflow, not a price effect. When you hold a perp long and funding is positive, the venue debits your margin account every hour and pays the shorts. The price doesn't move — your cash does. On most centralized venues the cadence is every eight hours; on Hyperliquid it is every hour. That changes both the magnitude of the carry trade and how a backtest has to model it.
The practical consequence: the carry view and the price view diverge. A position can lose money on price and still make money on net, or vice versa. A backtest that bakes funding into a synthetic adjusted price is hiding which side of the trade is earning. A backtest that ignores funding entirely is missing the entire alpha source for carry strategies. Neither is acceptable if you want to deploy capital against the result.
What “funding backtest” actually means
A funding-rate backtest, done right, has four properties:
- Funding is a separate cashflow in the simulator, applied to cash at the native hourly cadence — not folded into a fake adjusted price.
- The equity curve is decomposable into price-only and funding components so you can attribute P&L to its actual source.
- Funding direction is correct: long positions pay positive funding, short positions receive it. (The bug that flips this sign is the most common one in DIY funding backtests.)
- Funding data is at native resolution — 1-hour bars on HL, not 8-hour resampled. Otherwise short-horizon carry signals get smeared.
Keel's portfolio simulator implements all four. Per-instrument funding is applied to cash after orders fire and before the end-of-bar mark, cumulative funding is tracked separately, and every backtest result exposes the decomposed series — price-only, funding, and combined.
The decomposed equity curve
Every Keel backtest run with the decompose flag returns three equity curves:
| Curve | Plot color | What it represents |
|---|---|---|
| Price-only | Blue | P&L from price movement alone, funding zeroed out |
| Funding | Green | Cumulative funding cashflows scaled to position size |
| Combined | Gold | True strategy result — what your account would actually do |
View them in the Keel app's backtest report — all three curves render overlaid by default and each one can be toggled independently. The same data is available via the API and the keel-trade CLI for users who want to compute funding attribution, funding Sharpe in isolation, or funding-only drawdowns in their own notebook.
Regime-gated carry
Carry strategies fail when funding compresses across the universe. There is nothing to harvest — the cross-sectional spread shrinks toward zero and you take fees for no reason. The fix is a regime gate: a top-level signal that says “is the carry environment rich enough to be worth trading right now?” Keel ships two regime detectors for this:
- FundingLevelRegime — averages absolute funding across the universe per bar, smoothed with a rolling window. High values mean the universe is in an extreme funding regime where carry is structurally rich. Lookback default is 20 bars; set shorter (5-10) to react faster, longer (20-40) for a more stable gate.
- FundingDispersionRegime — cross-sectional standard deviation of funding rates per bar, smoothed. High values mean longs and shorts have very different funding, making it possible to differentiate. Low dispersion means every asset is paying roughly the same funding — no edge for a long/short carry book.
Both emit a scalar GlobalSeries. Feed one into RegimeGate to flip the carry leg on/off binary, or into RegimeScale to continuously modulate forecast intensity between a floor and ceiling. RegimeScale is usually the better choice — binary gates create whipsaw at the regime boundary.
End-to-end Keel example
The fastest path: open the verified funding-carry tearsheet and fork it into your account. The strategy lands in the visual builder ready to edit — change the universe, swap the regime detector, raise gross leverage — then click Run Backtest to see the decomposed equity curves on your own parameters.
Here's the pipeline shape the builder produces — the same structured definition whether you compose it visually or author it in Python:
# my_strategy.py — funding carry with regime scaling
Globals(target_timeframe="1d")
Universe(mode="top_volume", top_n=30, market="perp", resolved=[], resolved_at="")
Pipeline([
# Load HL 15-minute price bars + 1-hour funding for the universe
PriceDataLoader(timeframe="15min"),
FundingDataLoader(),
Store("funding_level_funding_data"),
# Detect funding regime — mean absolute funding across the universe
FundingLevelRegime(lookback=20),
Store("funding_regime"),
# Carry signal: long high-funding payers, short low-funding payers
CarrySignal(),
# Scale carry intensity by the regime — bigger in extreme funding periods
RegimeScale(regime_key="funding_regime", min_scale=0.25, max_scale=1.5),
# Aggregate to portfolio weights at target gross leverage
ForecastWeightNormalizer(gross_leverage=1.5, max_weight=0.20),
], name="hl_funding_carry")
Driving Keel from a terminal or an AI agent? pipx install keel-trade puts the keel CLI on your PATH; the CLI reference covers strategy create and backtest run. Same engine and data either way.
Honest scope: single-venue HL only
Keel's funding backtest covers one venue: Hyperliquid. Both legs of a long/short carry book have to be HL perps. If you want to short a perp on Binance against a long on HL to capture a cross-venue funding spread, that is a different problem and Keel does not solve it today. We are explicit about this because the cross-venue carry trade is a real strategy class and conflating “funding backtest” with “cross-venue funding arb” is a common marketing sleight-of-hand in the space.
Within HL: ~220 perp markets, 15-minute bars for price, 1-hour bars for funding, the same production-grade portfolio simulator that drives every other backtest on the platform.
Common failure modes
- Treating funding as a fixed cost. Funding is a variable cashflow that flips sign across regimes. A backtest that subtracts a constant “funding fee” will massively misprice carry — both directions. The simulator must use the actual time-series of realized funding rates.
- Ignoring regime. A funding-carry signal that trades the same size during compressed-funding regimes and extreme-funding regimes will give back its edge to fees during the compressed periods. Gate or scale by FundingLevelRegime or FundingDispersionRegime.
- Flipping funding direction. Long positions pay positive funding (cash leaves the account); short positions receive it. Trivial to invert in DIY code, catastrophic in a live backtest. Keel's simulator hardcodes the sign convention so you cannot get this wrong.
- Resampling funding to 8-hour. Convenient if you came from BitMEX or Binance. Wrong on HL. HL pays hourly; averaging away the intra-day variance hides the alpha for any signal with a horizon under a day.
- Forgetting position-size scaling. Funding P&L is
position * mark_price * funding_rate. A backtest that applies funding to notional but not to the actual realized position size will overstate funding in periods where the strategy is small or in cash.
Try it
Sign up and run a funding-decomposed backtest against ~220 HL perps with hourly funding data. Same pipeline runs live when you deploy it.