Hyperliquid Funding Rate Arbitrage Bot
An open-source funding rate arbitrage bot for Hyperliquid. Captures yield from extreme funding rate outliers by taking the opposite side of crowded positions on the fastest on-chain perpetuals exchange.
What Are Funding Rates?
Perpetual futures contracts have no expiry date, which means they need a mechanism to keep the contract price anchored to the underlying spot price. This mechanism is the funding rate — a periodic payment exchanged between long and short traders. When the funding rate is positive, longs pay shorts; when it is negative, shorts pay longs.
Funding rates reflect market sentiment. When most traders are long and bullish, the funding rate becomes highly positive, making it expensive to hold a long position. Conversely, when the market is overwhelmingly short, the funding rate becomes deeply negative, making shorts expensive. These extremes tend to be temporary because the funding cost itself creates an economic incentive for the market to rebalance.
On Hyperliquid, funding rates are calculated and settled every hour. The rates are transparent and available through the API, which makes them ideal for algorithmic strategies that can react faster than manual traders.
How the Arbitrage Works
The bot scans funding rates across all Hyperliquid perpetual markets on every funding interval. When it detects a rate that exceeds a configurable threshold — for example, an annualized rate above 100% — it opens a position on the side that receives the funding payment. If the funding rate is extremely positive, the bot goes short to collect the funding. If extremely negative, it goes long.
The core thesis is mean reversion: extreme funding rates are unsustainable and tend to normalize. While the bot holds its position, it collects funding payments every hour. When the rate normalizes back toward zero, the bot closes the position. The profit comes from the accumulated funding payments, ideally supplemented by a favorable price move as the market rebalances.
This is distinct from a traditional cross-exchange arbitrage because it operates entirely on Hyperliquid. There is no need to maintain balances on multiple venues or deal with transfer delays. The bot uses a single agent wallet and the Hyperliquid Python SDK for all executions.
The Economics of Funding Rate Yield
Funding rate yield is unique to perpetual futures and has no direct equivalent in spot or traditional futures markets. When a position earns funding, the yield accrues directly to the margin balance without requiring additional trades. This makes it one of the most capital-efficient forms of yield in DeFi.
However, the yield is not risk-free. The bot takes a directional position to collect funding, which means it is exposed to adverse price movement. A position that earns 0.05% per hour in funding can still lose money if the underlying asset moves 2% against it. The strategy's edge comes from the statistical tendency of extreme funding rates to revert, but individual trades can and will lose.
Effective position sizing is critical. The bot should allocate only a fraction of available capital to any single funding trade, and the funding threshold should be high enough that the expected cumulative funding payments meaningfully exceed the expected adverse price movement.
Configuration Options
The bot provides several knobs for tuning the strategy to your risk tolerance and capital. The funding threshold determines how extreme a rate must be before the bot acts. The position size caps exposure per trade. The hold duration sets a maximum time to keep a position open regardless of whether the rate has normalized.
For conservative deployment, set a high threshold (e.g., 200% annualized) and small position sizes. This generates fewer trades but each one has a higher expected return per unit of risk. For more aggressive deployment, lower the threshold and increase size — but be prepared for more frequent drawdowns.
Command-Line Arguments
| Flag | Description | Default |
|---|---|---|
| --threshold | Minimum annualized funding rate to trigger a trade | 100 |
| --size | Position size in USD per trade | 100 |
| --max-positions | Maximum number of simultaneous positions | 3 |
| --hold-hours | Maximum hours to hold a position | 24 |
| --poll-interval | Seconds between funding rate checks | 300 |
Risk Warnings
- ■Directional exposure — the bot takes a position to earn funding, which can lose money if the price moves adversely.
- ■Extreme funding rates can persist longer than expected, especially during strong trends or liquidation cascades.
- ■Liquidity risk on low-volume assets. Slippage on entry and exit can exceed the funding earned.
- ■Funding rates can change rapidly. A rate that was favorable at entry may flip before the next settlement.
Get Started
Deploy this strategy in under five minutes.
1. Clone the repo
$ git clone https://github.com/atlasdetitan/hyperliquid-trading-bots.git
2. Install dependencies
$ cd strategies/funding_arb
$ pip install -r requirements.txt
3. Configure your agent wallet
$ cp .env.example .env
Paste your agent wallet private key from app.hyperliquid.xyz/API
4. Run the bot
$ python main.py
DEPLOY ON HYPERLIQUID
Run this bot on the fastest on-chain perpetuals exchange