All posts
Trading Automation·July 28, 2026·9 min

How Does a Funding Rate Arbitrage Bot Work? The Honest Mechanics

How a funding rate arbitrage bot works: hold spot long and perpetual short, collect funding every 8 hours, and why fees, basis and liquidation decide it.

A funding rate arbitrage bot works by holding two opposite positions of equal size on the same coin: long on the spot market (or a long perpetual on one venue) and short on the perpetual futures contract. Price moves cancel out, so the position is roughly delta-neutral, and the bot collects the funding payment that perpetual longs pay to shorts every eight hours whenever the funding rate is positive. When funding flips negative or the net rate after fees drops below a threshold, the bot closes both legs or rotates into a coin where funding is richer.

That is the whole idea, and it is one of the few crypto strategies that survived proper out-of-sample testing in my own research system. But "survived" is not "free money". The result after fees depends on how often you rotate, how you handle basis moves between the two legs, and whether you can keep the short leg from being liquidated during a spike. I will go through each mechanic, then describe how my research lab tests this kind of strategy before any capital is allowed near it. This is engineering, not financial advice; anyone running a bot like this trades their own account at their own risk.

What is the funding rate and why does it exist?

Perpetual swaps have no expiry, so there is no settlement date to pull their price back to spot. Exchanges solve this with funding: every eight hours (on most venues) one side pays the other a small percentage of position value. When the perpetual trades above spot, longs pay shorts, which pushes traders to short the perpetual and buy spot until the gap narrows. When it trades below, shorts pay longs.

Funding is quoted per interval, so a rate of 0.01 percent is 0.03 percent a day and roughly 11 percent a year if it held constant, which it never does. In bull markets, funding on popular coins can sit several times higher for weeks; in quiet markets it hovers near the baseline and dips negative. The bot's job is to be short the perpetual when that payment is worth collecting and flat when it is not.

How does the bot stay delta neutral?

Delta neutral means the combined position's value does not change when price moves. In practice it is approximate, and the approximations are where money leaks:

  • Quantity matching. The spot leg and the perpetual leg must be the same coin quantity, not the same dollar value at different prices. Exchanges enforce different lot sizes and precision on spot and futures, so the bot rounds both to a common quantity.
  • Fee drag at entry and exit. Two legs open and two legs close is four taker fees unless you post maker orders. On a thin funding rate, taker fees on both legs can wipe out a week of funding, which is why rotation frequency matters so much.
  • Basis drift. The perpetual-to-spot gap itself moves. If you enter when the perpetual is rich and exit when it is richer, the short leg loses on the basis even though funding was collected. A patient bot exits when the basis is tight, not on a schedule.
  • Collateral and margin. The short leg sits on margin. Spot holdings on the same exchange may or may not count as collateral depending on account mode. Cross-margin with the spot asset as collateral is the natural setup, but it means a sharp rally raises the short's unrealised loss while raising the collateral's value, roughly in step, with the margin engine's haircuts deciding whether "roughly" is enough.

Can the short leg get liquidated?

Yes, and this is the risk that turns a "neutral" strategy into a loss. During a fast rally, the perpetual can spike well above spot for minutes (the basis blows out), and the short leg's mark price loss can exceed what the margin engine credits for the spot collateral after haircuts. If leverage on the short leg is high, liquidation triggers, the hedge disappears, and you are left long spot into whatever happens next.

The controls a serious bot applies:

  1. Low leverage on the short leg, typically 1x to 2x, so the liquidation price is far above any plausible spike.
  2. A margin-ratio monitor that adds collateral or trims both legs before the exchange's own liquidation engine gets involved.
  3. A maximum per-coin allocation so one illiquid coin's blow-up cannot take the whole book.
  4. A preference for coins with deep order books on both spot and perpetual, because the spike risk is worst where liquidity is thin.

How do you pick which coins to hold?

Rank by net expected funding after costs, not by the headline rate. The highest funding is almost always on the newest, thinnest coins, where the exit spread and the liquidation risk are worst. A ranking that works in testing uses a smoothed trailing funding rate (so a single spiky interval does not trigger entry), minimum spot and perpetual volume filters, and a required margin above a threshold that covers the round-trip fees over the expected holding period.

Rotation is then a hysteresis problem: enter when net funding exceeds an upper bound, exit when it falls below a lower bound, and never churn between two coins whose rates are within noise of each other. Every rotation costs four fees; the bot has to be convinced before it pays them.

Why do most crypto bot backtests lie about this?

Because they ignore one or more of the costs above. The three omissions I see most are funding modelled as a constant rather than the actual interval history, fills assumed at mid price with no maker-or-taker distinction, and parameters tuned on the same period they are reported on. Funding carry looks spectacular under those assumptions and merely decent under honest ones. The difference between the two is the difference between a strategy and a story.

For how I validate strategies in general without fooling myself, including the walk-forward split and sealed holdout, see how I take Pine strategies from backtest to production; the same discipline applies to Python crypto research.

How I built this: CryptoLab: Walk-Forward Crypto Research and Gated Paper Trading

CryptoLab is my Binance USDT-M futures research system, and funding carry is the strategy that survived it. The point of the lab is not to run a bot; it is to answer "what actually works in crypto futures" with evidence before any capital moves. The workflow:

  1. Data. An hourly scheduled task pulls perpetual prices and the full funding-rate history for the tradeable universe, so funding is a real time series in every test rather than an assumed constant.
  2. Walk-forward evaluation. Every strategy is trained on twelve months and tested on the next three, rolling forward, with maker and taker fees applied per fill and funding paid or received at each interval. A full holdout year is sealed and never used to select anything.
  3. Candidate strategies. Funding carry, cross-sectional momentum, trend following, mean reversion and a gradient-boosted model were all put through the same harness. Funding carry was the only one with a healthy out-of-sample Sharpe; the others died to costs or turnover.
  4. Debunking round. Popular ideas were tested properly and retired: a descending-trendline meme-coin breakout gave expectancy indistinguishable from random entries across 46 variants, a 2.15-million-run SuperTrend sweep showed the default setting as good as any with near-zero rank correlation between train and holdout, and a study of 8,889 copy-trading leaders found top-decile 90-day returns predicted a median of zero for the following 90 days.
  5. Calibration. Academic Donchian, moving-average filter and time-series momentum papers were replicated; results were lower but directionally consistent, which is what you want from a harness that is not flattering anyone.
  6. Paper book and gate. Portfolio weights update from the stitched out-of-sample results, a paper executor journals fills hourly, and a daily report summarises. The live executor refuses to trade unless a gate file records four weeks of positive paper results under a drawdown cap, and only I can flip that gate.

The key design decision is the gate: code that can trade live exists, but it is structurally blocked until the paper record earns it. The outcome so far is a funding-carry paper book with realistic costs, a shelf of debunked popular strategies with the numbers attached, and no live capital deployed on a hunch.

FAQ

How much can funding rate arbitrage earn?

It depends entirely on the funding regime, which you do not control. In exuberant markets annualised rates on major coins run into double digits; in quiet markets they sit near the baseline or go negative and the bot should be mostly flat. Anyone quoting a fixed return is ignoring the regime dependence.

Do I need two exchanges?

No. The simplest version is spot long and perpetual short on the same exchange, which also lets the spot asset serve as collateral. Cross-exchange versions capture funding differentials between venues but add transfer risk, withdrawal delays and two sets of margin rules.

Does the bot need to be fast?

Not at all. Funding settles every eight hours and the decision to rotate is made on smoothed rates. A bot that checks every hour is plenty. The engineering effort belongs in cost modelling and margin monitoring, not latency.

What about tax and accounting?

Every funding payment is a separate cash flow and every rotation is a realised trade on two legs. Journal everything from day one; reconstructing a year of eight-hourly payments from exchange exports later is painful.

If you want a research harness or a gated carry bot like this built for your own exchange accounts, tell me about it on the contact page.

Building something in this space? I ship trading automation, Pine Script, MQL5 EAs, and full-stack tools with source and docs.

Start a project →