Building a Custom Event Handler for HftBacktest
Summary
This Rust example shows how to wrap HftBacktest’s local processor to add custom handling around market events and order responses. The wrapper implements the local processor interface by forwarding order submission, modification, cancellation, state, depth, and latency calls to the underlying Local object. It also implements the broader processor interface, delegating timestamp and event processing while leaving marked locations for user-defined behavior when market feed events or order responses arrive.
The example constructs a backtest using event data, a hash-map market depth, a linear asset, fee models, constant order latency, and a probabilistic queue model, then advances the simulation to the end of the data. It illustrates integration structure and configurable simulation components rather than a trading strategy. The two custom event-handling sections are unfinished, and no strategy logic, test results, or performance evidence is provided. Users must supply those behaviors and confirm that the chosen data and exchange assumptions fit their intended simulation.
Key ideas
- A custom local processor can wrap HftBacktest’s Local processor and delegate its standard operations.
- The Processor implementation provides locations for custom logic on market events and order responses.
- The example configures event data, market depth, fees, latency, and a probabilistic queue model.
- The event-handling callbacks are unfinished, and the document reports no strategy results.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.