See Also
- Optimization - Performance optimization techniques
- Performance Issues - Troubleshooting: Performance optimization techniques
- Data Management - Guide: Data handling and management
- Exchanges - Data handling and management
- Strategy Development - Guide: Strategy development and implementation
- Optimization - Strategy development and implementation
High-Frequency Trading (HFT) Backtesting Documentation
The SimMode class, also known as the planar backtester, utilizes Open-High-Low-Close-Volume (OHLCV) data to simulate the execution of trades.
Reasons to Avoid Tick-by-Tick Backtesting
Tick-by-tick backtesting may not be ideal due to several factors:
- Data Availability: Bid/ask tick data is often difficult to obtain and can be extremely voluminous, leading to increased resource consumption.
- Data Reconstruction: Attempting to reconstruct order book data from trade history is speculative and can introduce significant bias.
- Overfitting Risks: High-detail backtesting can cause strategies to overfit to specific market maker behaviors, resulting in additional bias.
- Computational Costs: Intensive data and computational requirements may limit backtesting to a short time frame, insufficient for evaluating performance through different market conditions.
Implementing HFT Backtesting
Two approaches are available for HFT-style backtesting.
Built-in Tick-Based Backtesting
SimMode ships with a tick-based backtester that replays the market's trade stream trade by trade — no new execution mode is needed. See Running a Backtest → Tick-by-Tick Backtesting for the full details. In short:
- Each universe asset needs a tick
DataFramewith:timestamp,:price,:amountcolumns (the schema returned byPlanar.Fetch.fetch_trades), stored withPlanar.Instances.setticks!. - The strategy implements
ping!(s, ctx, tick)instead ofcall!. - The backtest runs with:
ctx = TickContext(Sim(), TradeTickRange(s))
start!(s, ctx)OHLCV-Based Approach
- A simpler method involves using the OHLCV model with extremely short-duration candles, such as
1scandles. The backtester processes time steps, typically using the strategy's base timeframe. By selecting a1stimeframe and supplying the corresponding candles, you can achieve the desired time resolution for your backtest.