Aligning Spot Prices with Futures Data in a Backtest
Summary
This example shows how to combine a spot BTCUSDT mid-price series with US dollar margined futures order book data in an hftbacktest simulation. It parses spot book ticker messages into local timestamps and mid prices, then, at each backtest timestamp, selects the latest spot observation available at or before that time. Comparing this value with the futures mid-price yields a basis series that can be inspected over time.
The accompanying example reports that the basis appears mean-reverting over the short sample and suggests that it could merit statistical arbitrage research, particularly where fees are low or rebates apply. This is an observation from a limited period, not evidence of a robust or profitable strategy. The article demonstrates data alignment and visualization, but does not specify a trading rule or provide broader out-of-sample results.
Key ideas
- Spot observations should be matched to futures timestamps using only data already available at each point in the simulation.
- The example computes spot and futures mid-prices and tracks their price difference as a basis.
- The displayed short sample appears mean-reverting, which motivates further statistical arbitrage investigation.
- A brief sample does not establish persistent mean reversion or account for a complete trading strategy's risks.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.