> ## Documentation Index
> Fetch the complete documentation index at: https://docs.0xarchive.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Backtest Hyperliquid and Lighter in Python with Manifold-BT

> Backtest Hyperliquid and Lighter in Python with Manifold-BT. Load candles, funding, trades and order books from 0xArchive, with Hyperliquid perps history back to April 2023.

[Manifold-BT](https://www.manifoldbt.com/integrations/0xarchive) is a Python backtesting library with a Rust engine. Its 0xArchive connector loads our history with one call, so you can backtest Hyperliquid perps on trades and order books recorded since April 2023. Hyperliquid's own API only returns its last 5,000 candles.

You use your own 0xArchive key. Requests go from your machine to our API and never pass through Manifold-BT.

**How far back each market goes**

## What the connector loads

| Data | What you get | Notes |
| - | - | - |
| Candles | 1m, 5m, 15m, 30m, 1h, 4h, 1d and 1w | From March 2025 on Hyperliquid perps and Spot, later on Lighter and HIP-3 |
| Funding | Funding rates on every perpetual | Spot pairs have none |
| Trades | Every recorded fill, timestamped to the millisecond, with the aggressor's side | Loaded in whole UTC days |
| Order book | Snapshots of both sides: 20 levels on Hyperliquid, deeper on Lighter | A day with no recorded book stops with an error that names it |

If a day has no recorded book, loading stops and the error names that day, so a gap never slips into your results. The exact start of every dataset is on [Venue coverage](https://docs.0xarchive.io/venue-coverage.md).

## Run your first backtest

**1. Install Manifold-BT**

```bash theme={"theme":"github-dark"}
pip install manifoldbt
```

The 0xArchive connector needs a Manifold-BT Pro license. Loading trades and order books needs Researcher.

**2. Create a 0xArchive key**

[Sign up](https://0xarchive.io/dashboard?utm_source=docs\&utm_medium=referral\&utm_campaign=docs_referral\&utm_content=manifold_bt_create_key), open **API keys** in the dashboard and create one. Then export it in the shell you run Python from:

```bash theme={"theme":"github-dark"}
export OXARCHIVE_API_KEY="your-key"
```

**3. Load a market**

The symbol picks the venue and market type. These examples use older dates, which need Build or Pro. On Free, set the start and end inside the most recent 30 days.

> [tab] Hyperliquid perps
>
> ```python theme={"theme":"github-dark"}
> import manifoldbt as mbt
>
> store = mbt.ingest(
>     provider="0xarchive",
>     symbol="BTC",
>     symbol_id=1,
>     interval="1h",
>     start="2025-06-01T00:00:00Z",
>     end="2025-12-01T00:00:00Z",
> )
> ```

> [tab] Spot
>
> ```python theme={"theme":"github-dark"}
> import manifoldbt as mbt
>
> store = mbt.ingest(
>     provider="0xarchive",
>     symbol="HYPE-USDC",
>     symbol_id=1,
>     interval="1h",
>     start="2025-06-01T00:00:00Z",
>     end="2025-12-01T00:00:00Z",
> )
> ```

> [tab] HIP-3
>
> ```python theme={"theme":"github-dark"}
> import manifoldbt as mbt
>
> store = mbt.ingest(
>     provider="0xarchive",
>     symbol="xyz/XYZ100",
>     symbol_id=1,
>     interval="1h",
>     start="2026-01-01T00:00:00Z",
>     end="2026-06-01T00:00:00Z",
> )
> ```
>
> Manifold-BT writes a HIP-3 market as deployer, then ticker. Our REST API calls the same market `xyz:XYZ100`.

> [tab] Lighter
>
> ```python theme={"theme":"github-dark"}
> import manifoldbt as mbt
>
> store = mbt.ingest(
>     provider="0xarchive",
>     symbol="lighter/BTC",
>     symbol_id=1,
>     interval="1h",
>     start="2025-09-01T00:00:00Z",
>     end="2026-03-01T00:00:00Z",
> )
> ```

**4. Run a strategy**

Any Manifold-BT strategy runs on the loaded store. This one is a simple EMA crossover on the BTC hours from the first tab:

```python theme={"theme":"github-dark"}
from manifoldbt.indicators import close, ema
from manifoldbt.helpers import (
    Interval, Slippage, time_range,
)

fast, slow = ema(close, 12), ema(close, 26)
strategy = (
    mbt.Strategy.create("ema_cross")
    .signal("fast", fast)
    .signal("slow", slow)
    .size(mbt.when(fast > slow, 0.5, -0.5))
)

start, end = time_range("2025-06-01", "2025-12-01")
config = mbt.BacktestConfig(
    universe=[1],
    time_range_start=start,
    time_range_end=end,
    bar_interval=Interval.hours(1),
    initial_capital=10_000,
    warmup_bars=26,
    execution=mbt.ExecutionConfig(allow_short=True),
    fees=mbt.FeeConfig(
        maker_fee_bps=1.5, taker_fee_bps=4.5,
    ),
    slippage=Slippage.fixed_bps(2),
)

result = mbt.run(strategy, config, store)
print(result.summary())
```

For tick-level work, load trades and book snapshots for whole UTC days:

```python theme={"theme":"github-dark"}
mbt.ingest_trades(
    "0xarchive", "BTC", 1, "2025-11-03", "2025-11-07"
)
mbt.ingest_book(
    "0xarchive", "BTC", 1, "2025-11-03", "2025-11-07"
)
```

## Checked against the venue

Before release, the Manifold-BT team ran the connector against our API and against Hyperliquid's own.

> [card] Bars match Hyperliquid
>
> BTC 1h candles from 0xArchive are identical to Hyperliquid's: open, high, low, close, volume and timestamps.

> [card] Trades add up to the candle
>
> One day of BTC, 327,914 trades, matches that day's candle in count and in volume.

> [card] Trades sit inside the book
>
> Over ten minutes of BTC, every trade printed between the book snapshots just before and after it.

> [card] All four market types run
>
> A perp, a Spot pair, a HIP-3 market and a Lighter market each go from loading to a strategy run.

## Plans on each side

You subscribe to each service directly.

| Service | Plan | What it gives you |
| - | - | - |
| 0xArchive | Free | The most recent 30 days, enough to test the connector |
| 0xArchive | Build, \$49 a month | The full archive at 50 requests a second |
| 0xArchive | Pro, \$199 a month | The full archive at 150 requests a second |
| Manifold-BT | Pro | Candles and funding through the connector |
| Manifold-BT | Researcher | Trades and order books, with tick-level simulation |

Trades and books use [credits](https://docs.0xarchive.io/core-concepts/credits.md) much faster than candles. Monthly allowances for every plan are on [Rate limits](https://docs.0xarchive.io/rate-limits.md).

**Run the quickstart on real data**

A free key covers the most recent 30 days on every market, enough to try the connector before you pick a plan.

[Create a free key](https://0xarchive.io/dashboard?utm_source=docs\&utm_medium=referral\&utm_campaign=docs_referral\&utm_content=manifold_bt_create_key)
[Manifold-BT's 0xArchive page](https://www.manifoldbt.com/integrations/0xarchive)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.