I am writing the backend of a back tester these days. Tick by tick etc. blablabla Anyhow, my problem is: How would you deal with non fillable orders? Basically, when an order is triggered I an generate fills according to the book (bids, asks). My problem comes along when the book is not available and / or too small to accommodate the values. This can be because I do not have order book (only best bid/ask) in a tight market, or in general because the market IS tight (overnight, crazy market situation). Actually - it is a lot more relevant during night trading etc. I do not want to keep those orders all around, and for a market order that would not be valid. Those are particularly very fancy times anyway (flash crash) and I want to actually make this somehow visible in a possibly run. What would be your suggest way of handling those orders? Cancel them after filling what can be filled (and sending a cancel to the strategy, obviously), plus a logging message that can go into the backtest results? I also consider a log message / info attachment to an execution to state how much of the order book was used to create the data. This normally should not be more than single digit percetnage, but a number higher than 100 would indicate the order was larger than the book, prompting an error in the backtest? Asking for opinions here Also, how would you handle limit order queueing? My idea is that I track the queue location for every order, and decrease that * On every trade at the price, by trade volume. * When the book moves away in my favour, I assume I got all fills there. The main problem is tracking queue position when out of the book - so I assume I just end up at the end always ?