8
$\begingroup$

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?

Thanks

$\endgroup$
6
  • $\begingroup$ 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? $\endgroup$ Commented Oct 4, 2012 at 3:49
  • $\begingroup$ 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). $\endgroup$ Commented Oct 4, 2012 at 4:27
  • $\begingroup$ 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). $\endgroup$ Commented Oct 4, 2012 at 4:28
  • $\begingroup$ 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)? $\endgroup$
    – assylias
    Commented Oct 4, 2012 at 20:02
  • $\begingroup$ Because it will affect profit. $\endgroup$ Commented Oct 4, 2012 at 22:15

2 Answers 2

4
$\begingroup$

As @babelproofreader mentioned, I recently blogged about the Roll model (see the original paper), which provides a very simple method for inferring the bid/ask spread based on trade prices. In short, you can estimate the cost using using the covariance: $c = \sqrt{\gamma_1}$. Where $\gamma_1$ is the $Cov(r_t, r_{t-1})$. (The R code is provided in my post).

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.]

$\endgroup$
2
  • $\begingroup$ Welcome back, Shane! $\endgroup$ Commented Oct 10, 2012 at 1:37
  • $\begingroup$ Thanks, Chris! Might try to poke my head in a little more. $\endgroup$
    – Shane
    Commented Oct 10, 2012 at 1:58
0
$\begingroup$

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.

$\endgroup$
1
  • 2
    $\begingroup$ You could provide summary of what's in the blog.... $\endgroup$
    – SRKX
    Commented Oct 8, 2012 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.