I am currently developing a daytrading application which based on rules and algorithms buys or sells stocks, which right now might buy/sell a stock in the magnitude of 100 per day.
I am trying to backtest my strategy but i do not know how to handle the spread between bid and ask. If i for example in my backtesting assume that i can buy for the current price, i might get a biased result since buying at the latest price assumes that someone is still willing to sell at that price, which might not be the case.
Are there any best practises here? One of my big problems is that i do not have access to historical order depth for each data-point, so i do not know the ask and bid. Here are a couple of options i have considered (for buying a stock):
- Use the latest price (In the real world, i might not be able to buy at this price)
- Calculate the average movement between to trades in the stock, and add this to the latest price and use that.
And if i would have access to the order depth:
- Use the current bid (What if the volume of that bid is much smaller than my volume?)
- Use the average of ask and bid (Should give a good value, assuming that half of the time the next price will be the current ask, and half the time it will be the bid?)