IB's market data stream contains ask, bid and last price plus volume info so there should enough data to make backtesting a good approximations of real trading but there are some pitfalls. Rather than go over my mistakes I'll jump right to my proposed new system. I've lost count of the rewrites!
Market buy orders watch the price of the last trade and trigger when a trade occurs at the ask price, then uses that price for the simulated buy price. The idea here is that trades that occur at the ask are market buys which is what I want to mimic. Any lower price might be the result of a market sell which would result in over optimistic backtesting results. I would rather error on the side of "pessimistic" during system development.
Market sell orders do the same as above but watch for a trade that occurs at the bid and uses that price.
Limit buys orders are like market orders except they trigger when a trade occurs at the ask price AND that price is at the limit price or greater.
Limit sell orders are the same but use the bid instead of ask and watch for a trade that is equal or lower than the limit price.
The final thing (and the hardest) is to come up with a slippage factor that depends on the strategy, liquidity, position sizes and more. A trend-following strategy that jumps in with entries during a bullish frenzy with market orders would have a very different slippage factor than a strategy that waits for a pull-back using limit orders, for example.
I think I'll wrap it here and see if anyone has any interest in this or if I am blabbering to no one. In a nutshell, I believe that improvements could include "smart" slippage factor that takes into account trades on either side of market orders to determine the likelihood of a fill, and for limit orders estimate where my order would be in the queue and let that number of trades pass by. And most important (for days like today) to notice when things are screwy and just step aside!
Mike
Market buy orders watch the price of the last trade and trigger when a trade occurs at the ask price, then uses that price for the simulated buy price. The idea here is that trades that occur at the ask are market buys which is what I want to mimic. Any lower price might be the result of a market sell which would result in over optimistic backtesting results. I would rather error on the side of "pessimistic" during system development.
Market sell orders do the same as above but watch for a trade that occurs at the bid and uses that price.
Limit buys orders are like market orders except they trigger when a trade occurs at the ask price AND that price is at the limit price or greater.
Limit sell orders are the same but use the bid instead of ask and watch for a trade that is equal or lower than the limit price.
The final thing (and the hardest) is to come up with a slippage factor that depends on the strategy, liquidity, position sizes and more. A trend-following strategy that jumps in with entries during a bullish frenzy with market orders would have a very different slippage factor than a strategy that waits for a pull-back using limit orders, for example.
I think I'll wrap it here and see if anyone has any interest in this or if I am blabbering to no one. In a nutshell, I believe that improvements could include "smart" slippage factor that takes into account trades on either side of market orders to determine the likelihood of a fill, and for limit orders estimate where my order would be in the queue and let that number of trades pass by. And most important (for days like today) to notice when things are screwy and just step aside!
Mike
