Skip to content
All library documents

Converting Hyperliquid Trades and Order Books for Backtesting

Code Stratmill research code

Summary

This document describes a data-conversion workflow for preparing Hyperliquid market feeds for HftBacktest. It reads timestamped stream records, handles trade and level-two book messages, and converts them into typed depth and trade events using configurable tick size, lot size, book depth, and timestamp scaling. For book updates, it compares each snapshot with the prior state and emits events for inserted or changed levels, plus deletions according to the configured policy.

The converter adjusts local timestamps for a supplied base latency, orders events by exchange and local timestamps, validates the resulting sequence, and can save the output in compressed form. The examples illustrate the raw feed structure and show how book levels are represented. This is a data-engineering method rather than a trading strategy, and the document reports no performance evidence. Correct output depends on appropriate instrument parameters and feed interpretation; the documentation notes that a buffer that is too small can cause an index error, and deletion behavior is configurable.

Key ideas

  • The converter transforms Hyperliquid stream records into events that HftBacktest can consume.
  • Order book snapshots are diffed so inserted, changed, and deleted price levels become depth events.
  • Tick size, lot size, timestamp scaling, base latency, and book depth are configurable inputs.
  • After conversion, local timestamps are adjusted and event ordering is corrected and validated.
  • Buffer capacity and the policy for deleting levels outside the book affect conversion behavior.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.