Take the 2-minute tour ×

I'm backtesting an algorithm for trading nasdaq stocks, and would like to take into account the spread. I am using historical data from yahoo, which contains:

open, high, low, close, volume, adj. close

All of my trading signals are based off of those prices as they are (without regard to whether they are bid, ask, best bid, best ask, etc.)

To attempt to take into account the bid/ask spread when executing a trade, I have treated all the prices above as the bid prices. To estimate the ask price, I decided to set the spread always equal to 1% of the previous day's high. So the ask price is just estimated by adding that spread to the bid price (and again, the bid price is equal to the yahoo prices given).

Under what conditions is this a reasonable estimate for the spread? For example, very low priced stocks have larger spread percentages so I exclude those stocks completely from my backtesting.

Any better way to do this?


share|improve this question
If all you have is end-of-day data from Yahoo, then deriving the bid-ask spread is the least of your worries. What price you do you think you're trading at anyway? The close? VWAP? –  chrisaycock Oct 4 '12 at 3:49
My strategy is based on limit orders. After market close on day N, I have all the information I need to create buy-limit-orders good for day N+1 only. My backteser then only executes a trade for day N+1 if Yahoo's low price for day N+1 is lower than my limit price that was set on day N. My trade will be executed at whichever is lower: my limit buy price, or the open price for day N+1 (plus my estimated spread, plus a flat trading fee). –  Lee Schmidt Oct 4 '12 at 4:27
Selling works the same way. Sell orders only execute for day N+1 if the high on day N+1 exceeds my sell-limit-order price (which was formulated only with data available through day N). –  Lee Schmidt Oct 4 '12 at 4:28
Why would the bid ask spread matter if you use limit orders (which basically get executed at your limit outside of the open or temporary suspensions)? –  assylias Oct 4 '12 at 20:02
Because it will affect profit. –  Lee Schmidt Oct 4 '12 at 22:15

2 Answers 2

This recent Statalgo blog post outlines a simple theoretical model of bid/ask prices: the Roll model, and also shows how the bid/ask spread can be derived from prices using this model. Included in the post are links to papers that show how this model might be improved.

share|improve this answer
You could provide summary of what's in the blog.... –  SRKX Oct 8 '12 at 14:19


The Roll model makes many simplifying assumptions and is an empirical failure (although still theoretically important), so I would not advise using it as a real proxy for costs. There have been many advancements since that original paper. Two better options:

[I may blog further on this topic in the future, but it doesn't seem as important as other topics given the ready availability of actual bid/ask spread data.]

share|improve this answer
Welcome back, Shane! –  chrisaycock Oct 10 '12 at 1:37
Thanks, Chris! Might try to poke my head in a little more. –  Shane Oct 10 '12 at 1:58

Your Answer


