I am in the process of backtesting some trading systems, and i want the backtesting to give as realistic fills as possible.
Tthe backtesting engine is doing the following now:
- When entering an order i check the queue depth at the level using level 2 data.
- When the level trades my orders are filled based on the position in queue.
Downside to this is I need to have level 2 data to backtest, so another "almost realistic" fill method would be better, but i haven't come up with any.
In most cased this is good, but there are edge cases which I would be grateful to get inputs as to how others have solved it.
I would like to fill them as close to as how they might have been filled in a live market:
- If my orders are the last in the queue for a level.
- If my orders are the only ones in the queue. (which is a special case of the above)