Backtesting a Grid Strategy with Latency, Fees, and Queue Modeling
Summary
This example sets up a historical simulation for a grid trading strategy on the linear 1000SHIBUSDT contract. It loads daily market data and latency files for a date range, initializes market depth from a start-of-day snapshot, and configures the backtest with a latency model, trading fees, an exchange fill rule, and a probabilistic queue model. The strategy is parameterized with a relative spread and grid interval, a number of levels, a minimum step, order quantity, skew, and maximum position. A recorder writes the results to CSV.
The setup demonstrates that grid results can depend on latency, fees, queue assumptions, and fill behavior, rather than price data alone. The document supplies no backtest output, comparison, or validation against live fills, so it cannot establish profitability or robustness. Its assumptions—including no partial fills and the selected queue and fee models—limit how closely the simulation may represent a particular venue. The referenced data files are required to reproduce the run.
Key ideas
- The backtest combines historical market data with separate latency data.
- A probabilistic queue model and an exchange fill rule shape simulated order execution.
- The fee model includes maker and taker rates as configured in the code.
- Initial market depth is populated from a start-of-day snapshot.
- Grid spacing, order size, skew, and maximum position are strategy inputs.
- No results are provided, and model assumptions limit conclusions about live performance.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.