Strategy Testing

Backtesting API

Test your trading strategies on historical data before risking real capital. Uses real Hyperliquid OHLCV data for 100% accuracy.

Why Use Our Backtesting?

Real Data

Uses actual Hyperliquid historical candles, not simulated data.

Realistic Execution

Includes slippage, maker/taker fees, and proper position sizing.

Comprehensive Metrics

Sharpe ratio, max drawdown, win rate, profit factor, and more.

Backtesting Workflow

1

Sync Historical Data

First, sync the OHLCV data for the coins and timeframes you want to test.

POST /v1/exchanges/hyperliquid/backtest/ohlcv/sync
{
  "coin": "BTC",
  "interval": "1h",
  "start_date": "2024-01-01T00:00:00Z",
  "end_date": "2024-12-01T00:00:00Z"
}
2

Check Data Availability

Verify that data is complete for your backtest range.

POST /v1/exchanges/hyperliquid/backtest/ohlcv/check-availability
{
  "coin": "BTC",
  "interval": "1h",
  "start_time": "2024-01-01T00:00:00Z",
  "end_time": "2024-12-01T00:00:00Z"
}

// Response
{
  "available": true,
  "candle_count": 8016,
  "coverage": 0.99,
  "last_sync": "2024-12-14T10:30:00Z"
}
3

Run Backtest

Submit your strategy and parameters. The backtest runs in the background.

POST /v1/exchanges/hyperliquid/backtest/backtests
{
  "name": "BTC Moving Average Crossover",
  "coins": ["BTC"],
  "interval": "1h",
  "start_time": "2024-01-01T00:00:00Z",
  "end_time": "2024-12-01T00:00:00Z",
  "initial_balance": 10000,
  "leverage": 1,
  "strategy_type": "preset",
  "strategy_code": "ma_crossover_20_50"
}
4

Get Results

Poll for status or retrieve results when complete.

GET /v1/exchanges/hyperliquid/backtest/backtests/{id}

// Response
{
  "id": "abc123",
  "status": "completed",
  "total_trades": 156,
  "winning_trades": 89,
  "losing_trades": 67,
  "total_pnl": 2450.50,
  "total_pnl_percent": 24.5,
  "win_rate": 57.05,
  "max_drawdown": 850.00,
  "max_drawdown_percent": 8.5,
  "sharpe_ratio": 1.85,
  "profit_factor": 1.65
}

API Endpoints

EndpointMethodDescription
/backtest/ohlcv/syncPOSTStart syncing historical OHLCV data
/backtest/ohlcv/statusGETGet sync status for coin/interval pairs
/backtest/ohlcv/check-availabilityPOSTCheck if data is complete for a range
/backtest/backtestsPOSTCreate and run a new backtest
/backtest/backtestsGETList your backtests
/backtest/backtests/{id}GETGet backtest details and results
/backtest/backtests/{id}/tradesGETGet all trades from a backtest
/backtest/backtests/{id}/equity-curveGETGet equity curve for charting
/backtest/backtests/{id}DELETEDelete a backtest

Performance Metrics

Total PnLNet profit/loss in USD
Total PnL %Return on initial balance
Win RatePercentage of winning trades
Profit FactorGross profit / gross loss
Sharpe RatioRisk-adjusted return (annualized)
Max DrawdownLargest peak-to-trough decline
Avg Trade PnLAverage profit per trade
Largest Win/LossBest and worst individual trades

Supported Intervals

1m5m15m1h4h1d1w