Funding-Rate Backtesting

Backtest funding-rate strategies on Hyperliquid

Keel ships an end-to-end funding-rate backtest on Hyperliquid. The simulator decomposes P&L into three curves — price-only, funding, and combined — from 1-hour HL funding data. FundingLevelRegime and FundingDispersionRegime gate carry signals so you only deploy size when the carry edge is actually present.

By Keel Research Team · Updated May 18, 2026
Verified Keel backtest · Carry · Regime-gated · Vol-targeted

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.

Total return
+79.6%
Sharpe
2.17
Max drawdown
-9.7%
Win rate
48.7%

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:

CurvePlot colorWhat it represents
Price-onlyBlueP&L from price movement alone, funding zeroed out
FundingGreenCumulative funding cashflows scaled to position size
CombinedGoldTrue 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.

FAQ

Common questions

How often does Hyperliquid pay funding?

Hourly. HL accrues and settles funding every hour against the mark price, not every 8 hours like most centralized perp venues. That cadence matters for a backtest: an 8-hour discretization will lose the intra-day funding swings that a carry strategy is actually trading. Keel loads HL funding at native 1-hour resolution.

How is funding shown in the equity curve?

As a separate component. When you run a backtest with decomposed P&L, Keel returns three series: price-only equity (what you would have made from price changes alone), funding equity (cumulative funding cashflows scaled to your position size), and combined equity (the true strategy result). The plot command renders all three on one chart.

Can I see funding separately from price P&L?

Yes. Open the backtest report in the Keel app to see all three curves overlaid (blue for price-only, green for funding, gold for combined) and toggle each one independently. If you drive Keel from a terminal or an AI agent with the keel-trade CLI, the same decomposition comes back in the JSON response — price-only series, funding series, and combined series.

Does Keel backtest cross-venue funding spreads?

No. Keel is single-venue on Hyperliquid only. Cross-venue carry — long HL, short Binance against the funding differential — is not supported. If you need cross-venue spread backtesting, you need a different stack. Keel covers the case where HL is both legs (long basket, short basket, both on HL).

How do FundingLevelRegime and FundingDispersionRegime work?

FundingLevelRegime computes the mean absolute funding rate across the universe and smooths it with a rolling window — high values flag periods where carry is rich. FundingDispersionRegime computes the cross-sectional standard deviation of funding rates — high values flag periods where long/short carry pairs differentiate cleanly. Both emit a scalar GlobalSeries you feed into RegimeGate (binary on/off) or RegimeScale (continuous modulation) of a downstream carry signal.

Which assets are covered?

All Hyperliquid perpetual markets that have at least the lookback window of funding history. That is roughly 220 markets at varying maturities. Newer listings have short funding history — be careful using them in regime detectors with a 20-bar lookback. Keel does not impute missing funding data.