How to use NautilusTrader with Hyperliquid (Python)

Updated Nov 19, 2026 · 5 min read

NautilusTrader 1.231.0 has a Hyperliquid adapter for data and trading on spot, perps and HIP-3. Load markets and candles with no key, backtest on them, then trade on testnet. Tested Nov 19, 2026.

Does NautilusTrader work with Hyperliquid? Yes. NautilusTrader ships a Hyperliquid adapter, written in Rust with Python bindings, that streams data and places orders on spot, perps and HIP-3 perps, on mainnet or testnet; its README marks it stable. The script below, run on Nov 19, 2026 with nautilus_trader 1.231.0 and Python 3.12, loads Hyperliquid’s BTC perp and candles with no key and backtests on them.

Key takeaways

  • pip install nautilus_trader installs 1.231.0 (Aug 2, 2026); version 2.0 is in release candidates (2.0.0rc9, Nov 10).
  • Public data needs no key. Trading needs a private key; with an API wallet, also set the main account address.

What the Hyperliquid adapter supports

Areanautilus_trader 1.231.0
MarketsSpot, perps, HIP-3 perps and HIP-4 outcome markets: data and trading
DataTrades, quotes, L2 book, bars (1 minute to 1 month), mark and index prices, funding, open interest
OrdersMarket (an IOC limit with a 50 bps slippage buffer by default), limit, stop, take-profit; post-only, reduce-only; GTC and IOC only
StatusREADME: stable; the 1.231.0 example scripts still say beta
NautilusTrader’s Hyperliquid guide and README at tag v1.231.0, checked Nov 19, 2026. Needs Python 3.12 to 3.14; LGPL-3.0 license.

Load Hyperliquid data and backtest on it

The adapter’s HyperliquidHttpClient reads Hyperliquid’s public info endpoint. The script loads the main perps, requests BTC 4h bars (Hyperliquid serves only the latest 5,000 candles) and runs NautilusTrader’s EMACross example (EMA 20/50, always long or short 0.1 BTC) in a BacktestEngine, with Hyperliquid’s base-tier fees added because the adapter’s definition carries none. The live part starts only with RUN_LIVE=1 and a testnet key.

python
# Load Hyperliquid's BTC perp and 4h candles through NautilusTrader's Hyperliquid adapter (public data, no key),
# then backtest the built-in EMA crossover with the 0.045% base-tier taker fee. Live trading is guarded below.
import asyncio, os
from datetime import datetime, timedelta, timezone
from decimal import Decimal

import nautilus_trader
from nautilus_trader.adapters.hyperliquid import HYPERLIQUID, HyperliquidDataClientConfig, HyperliquidExecClientConfig
from nautilus_trader.backtest.engine import BacktestEngine, BacktestEngineConfig
from nautilus_trader.config import InstrumentProviderConfig, LoggingConfig, TradingNodeConfig
from nautilus_trader.core import nautilus_pyo3 as pyo3
from nautilus_trader.examples.strategies.ema_cross import EMACross, EMACrossConfig
from nautilus_trader.model.currencies import USD
from nautilus_trader.model.data import Bar, BarType
from nautilus_trader.model.enums import AccountType, OmsType
from nautilus_trader.model.identifiers import Venue
from nautilus_trader.model.instruments import CryptoPerpetual, instruments_from_pyo3
from nautilus_trader.model.objects import Money

BAR = "BTC-USD-PERP.HYPERLIQUID-4-HOUR-LAST-EXTERNAL"

async def load_from_hyperliquid():
    client = pyo3.HyperliquidHttpClient()  # mainnet, no private key: public info endpoint only
    perps = await client.load_instrument_definitions(
        include_spot=False, include_perps=True, include_perps_hip3=False, include_outcomes=False)
    btc = next(i for i in perps if i.id.value == "BTC-USD-PERP.HYPERLIQUID")
    client.cache_instrument(btc)
    now = datetime.now(timezone.utc)
    bars = await client.request_bars(pyo3.BarType.from_str(BAR), now - timedelta(days=900), now, None)
    return len(perps), btc, bars

n_perps, btc_pyo3, bars_pyo3 = asyncio.run(load_from_hyperliquid())
btc = instruments_from_pyo3([btc_pyo3])[0]
bars = Bar.from_pyo3_list(bars_pyo3)
first, last = (datetime.fromtimestamp(b.ts_event / 1e9, timezone.utc) for b in (bars[0], bars[-1]))
print(f"nautilus_trader {nautilus_trader.__version__} | pulled {datetime.now(timezone.utc):%Y-%m-%d %H:%M} UTC")
print(f"{n_perps} main-dex perps loaded | {btc.id}: tick {btc.price_increment}, size step {btc.size_increment}, "
      f"fees in definition maker {btc.maker_fee} / taker {btc.taker_fee}")
print(f"{len(bars)} closed 4h bars, {first:%Y-%m-%d %H:%M} to {last:%Y-%m-%d %H:%M} UTC | "
      f"buy and hold {float(bars[-1].close) / float(bars[0].close) - 1:+.1%}")

# The adapter's definition carries no fees, so set Hyperliquid's base-tier crypto-perp fees for the backtest.
d = CryptoPerpetual.to_dict(btc)
d.update(maker_fee="0.00015", taker_fee="0.00045")
btc = CryptoPerpetual.from_dict(d)

engine = BacktestEngine(BacktestEngineConfig(logging=LoggingConfig(log_level="ERROR")))
engine.add_venue(Venue("HYPERLIQUID"), oms_type=OmsType.NETTING, account_type=AccountType.MARGIN,
                 base_currency=USD, starting_balances=[Money(10_000, USD)])
engine.add_instrument(btc)
engine.add_data(bars)
engine.add_strategy(EMACross(EMACrossConfig(
    instrument_id=btc.id, bar_type=BarType.from_str(BAR), trade_size=Decimal("0.1"),
    fast_ema_period=20, slow_ema_period=50)))
engine.run()

fills = engine.trader.generate_order_fills_report()
positions = engine.trader.generate_positions_report()
account = engine.trader.generate_account_report(Venue("HYPERLIQUID"))
end = float(account["total"].iloc[-1])
fees = sum(float(m.split()[0]) for row in fills["commissions"] for m in row)  # e.g. ["2.63 USD"]
print(f"EMA 20/50, 0.1 BTC long or short: {len(fills)} fills, {len(positions)} positions, "
      f"fees ${fees:,.0f}, end balance ${end:,.0f} ({end / 10_000 - 1:+.1%})")

# Live trading needs a private key. Dry-run unless you set RUN_LIVE=1 and HYPERLIQUID_TESTNET_PK.
live = TradingNodeConfig(
    data_clients={HYPERLIQUID: HyperliquidDataClientConfig(
        environment=pyo3.HyperliquidEnvironment.TESTNET, instrument_provider=InstrumentProviderConfig(load_all=True))},
    exec_clients={HYPERLIQUID: HyperliquidExecClientConfig(
        environment=pyo3.HyperliquidEnvironment.TESTNET, instrument_provider=InstrumentProviderConfig(load_all=True))},
)
if os.getenv("RUN_LIVE") == "1" and os.getenv("HYPERLIQUID_TESTNET_PK"):
    from nautilus_trader.adapters.hyperliquid import HyperliquidLiveDataClientFactory, HyperliquidLiveExecClientFactory
    from nautilus_trader.live.node import TradingNode
    node = TradingNode(config=live)
    node.trader.add_strategy(EMACross(EMACrossConfig(
        instrument_id=btc.id, bar_type=BarType.from_str(BAR), trade_size=Decimal("0.001"))))
    node.add_data_client_factory(HYPERLIQUID, HyperliquidLiveDataClientFactory)
    node.add_exec_client_factory(HYPERLIQUID, HyperliquidLiveExecClientFactory)
    node.build()
    node.run()
else:
    print("DRY_RUN: testnet TradingNode configured, not started (set RUN_LIVE=1 and HYPERLIQUID_TESTNET_PK)")
StepResult
Instruments235 main-dex perps; BTC-USD-PERP tick 0.1, size step 0.00001
Bars5,000 closed 4h candles opening Aug 8, 2024 04:00 to Nov 19, 2026 08:00 UTC
EMACross demo182 fills, 91 positions, $710 in fees; account $10,000 to $14,857
Demo run, nautilus_trader 1.231.0, 12:35 UTC on Nov 19, 2026 (same output at 14:19 UTC): Hyperliquid BTC perp, 0.045% taker fee per fill, no slippage or funding. Market data only; not a forecast or a trade signal.

This only shows the pipeline works. NautilusTrader labels EMACross a test strategy with no alpha, and one market and one parameter pair without slippage or funding say nothing about returns (how to backtest a crypto strategy).

Trading live: start on testnet

A live TradingNode takes a HyperliquidDataClientConfig and a HyperliquidExecClientConfig and reads the key from HYPERLIQUID_TESTNET_PK (HYPERLIQUID_PK on mainnet). If it is an API wallet key, set HYPERLIQUID_ACCOUNT_ADDRESS to the main account, or orders won’t reconcile. Set leverage on Hyperliquid; the adapter doesn’t manage it. Mainnet orders carry NautilusTrader’s builder code with no builder fee: run builder_fee_approve() once or set include_builder_attribution=False. Testnet orders skip it.

Not executed for this guide

NautilusTrader or another Python framework?

backtrader and vectorbt backtest Hyperliquid data; Freqtrade and NautilusTrader also trade it live, and NautilusTrader runs the same strategy code in both.

Or run the rule on Senpi

On Senpi, a strategy you confirm runs as code on Senpi’s runtime, and by default no AI model makes live trading decisions. Senpi doesn’t run backtests; Simulations, paper trading with simulated money, are coming. Hyperliquid charges 0.015% maker and 0.045% taker at the base tier on crypto perps. Senpi adds 0% on paid plans (from $50 a month) and 0.03% on the free trial.

Does NautilusTrader support Hyperliquid?

Yes. Version 1.231.0 includes a Hyperliquid adapter for data and trading on spot, perps, HIP-3 and HIP-4 markets.

Do I need an API key to get Hyperliquid data in NautilusTrader?

No. The script above loaded instruments and bars with no key; only the execution client needs a private key.

Can NautilusTrader trade HIP-3 perps such as xyz:TSLA?

Yes. They load with the standard perps in a live node, as IDs like xyz:TSLA-USD-PERP.HYPERLIQUID, and default to isolated margin.

Sources: NautilusTrader README, Hyperliquid guide and examples at v1.231.0 (GitHub) and PyPI; Hyperliquid docs (info endpoint, fees). Checked and run Nov 19, 2026.

This is educational material, not financial advice. Leveraged perps can lose money quickly.

Run a rule without a server

Describe the rule; Senpi runs it on its runtime with a stop from the first fill.

Try Senpi free
Share

Related articles