Short answer
Load hourly candles and hourly funding rates into pandas, shift your signal one bar so it only uses closed candles, and subtract two costs from the bar returns: the taker fee on every position change (0.045% per side at Hyperliquid's base perp tier) and the funding each hour you hold a position. Hyperliquid's API gives you funding history for free but only the last 5,000 candles, so the candles below come from TikTape.
Runnable backtest: SMA trend with fees and funding
import os, time
import pandas as pd
import requests
KEY = os.environ["TIKTAPE_API_KEY"]
COIN, START, END = "ETH", "2025-06-01", "2025-12-01"
TAKER_FEE = 0.00045 # Hyperliquid base-tier perp taker fee, 0.045%
def ms(day):
return int(pd.Timestamp(day, tz="UTC").timestamp() * 1000)
# 1. Hourly candles from TikTape (one request holds 10,000 candles, about 416 days of 1h).
r = requests.get("https://tiktape.xyz/api/v1/ohlcv", headers={"X-API-Key": KEY}, timeout=60,
params={"coin": COIN, "interval": "1h", "startTime": ms(START), "endTime": ms(END), "limit": 10_000})
r.raise_for_status()
px = pd.DataFrame(r.json()["data"], columns=["ts", "open", "high", "low", "close", "volume"])
px.index = pd.to_datetime(px.pop("ts"), unit="ms", utc=True)
px = px.astype(float)
# 2. Hourly funding from Hyperliquid's free fundingHistory (500 rows per call).
rows, cursor = [], ms(START)
while True:
page = requests.post("https://api.hyperliquid.xyz/info", timeout=30, json={
"type": "fundingHistory", "coin": COIN, "startTime": cursor, "endTime": ms(END) - 1}).json()
rows += page
if len(page) < 500:
break
cursor = page[-1]["time"] + 1
time.sleep(0.2)
funding = pd.Series([float(x["fundingRate"]) for x in rows],
index=pd.to_datetime([x["time"] for x in rows], unit="ms", utc=True).floor("h"))
funding = funding[~funding.index.duplicated()]
# 3. Signal on closed bars, position held over the next bar.
fast, slow = px["close"].rolling(24).mean(), px["close"].rolling(168).mean()
pos = (fast > slow).astype(int) - (fast < slow).astype(int) # +1 long, -1 short
pos = pos.shift(1).fillna(0) # no lookahead
ret = px["close"].pct_change().fillna(0)
fees = pos.diff().abs().fillna(0) * TAKER_FEE # a flip pays two sides
# Funding settles at the end of each hour: longs pay a positive rate, shorts receive it.
fund = pos * funding.reindex(px.index).shift(-1).fillna(0)
pnl = pos * ret - fees - fund
print(f"bars {len(px)}, trades {int((pos.diff().abs() > 0).sum())}")
print(f"gross {(pos * ret).sum():+.2%} fees {-fees.sum():+.2%} funding {-fund.sum():+.2%} net {pnl.sum():+.2%}")
We ran it on 2026-12-03: 4,392 hourly bars, with fees and funding each printed as a separate line so you can see what costs eat. It is a sketch, not a strategy: returns are summed, not compounded, and funding is charged on the position, not on its notional at the mark price.
The costs that matter on Hyperliquid
- Fees: base-tier perps pay 0.045% taker and 0.015% maker; tiers drop with 14-day volume, and HIP-3 dexes add their own deployer share (Hyperliquid fees).
- Funding: paid every hour, so a position held for a month crosses about 720 funding payments. The rate history is free from
fundingHistory; see Hyperliquid funding rate history. - Timestamps: TikTape candles are stamped with their open time; funding
timelands just after the hour it settles, which is why the script floors it and shifts it one bar.
More history, other tools
For intraday bars, page through GET /api/v1/ohlcv 10,000 candles at a time with the Python download loop. To run the same idea in Freqtrade, write the candles and funding to its data folder: Freqtrade backtests on Hyperliquid history.