New function Spread(barsAgo) returns the closing spread

Dear All,

We launched a new function in TECHNICAL->PRICE & VOLUME

Spread(barsAgo) : Returns the closing spread (ask-bid) for the bar. Data is from ICE Data (formerly Interactive Data Corp).

It’s not very useful right now since it’s just another screening function. Perhaps there are uses for screening to avoid stocks with huge spreads. We’re evaluating how to best use this data. For example we plan to use it to calculate more accurate slippage in simulations, and in TRADE to help you enter limit/relative orders that won’t get rejected by IB.

Let us know your thoughts.


Great addition, Marco.

I think your use cases are spot on.

As far as screening uses, I found that following interesting:

Amihud and Mendelson. Asset pricing and the bid-ask spread . Journal of Financial Economics: Volume 17, Issue 2, December 1986, Pages 223-249

Jegadeesh and Titman. Short-Horizon Return Reversals and the Bid-Ask Spread. JOURNAL OF FINANCIAL INTERMEDIATION, Vol 4 No 2, April 1995

Question: It seems unlikely that information would be revised historically unless there is an error. Is this an accurate characterization?



Should DEFINITELY be helpful for this. I would guess that most people at P123 have found a way to get the bid, the ask (or better) on each individual trade by breaking up their trades (perhaps with one of the algos e.g., VWAP best-effort). Even most moderately sized (defined by the liquidity of the stock) market orders will have an average fill price at the bid or the ask—on average. Multiple trades through the day can complicate the calculation, I think.

I wonder if the bid/ask at the close reflects the bid/ask during the day. In fact, doesn’t the NASDAQ use a cross at the close (and the open)?

NASDAQ CROSS LINK: Here. The NYSE has a “Closing Auction:” Here. If there is a closing BID/ASK for these exchanges does it mean something different? Maybe it is the last BID/ASK before the close.

Anyway, without worrying about the details now (which I know P123 can work out): VERY NICE!


This is absolutely great. But with one caveat.

I’ve done some spot checking and most of the numbers seem absolutely correct. However, there are some stocks that show 0.00 spreads, and those are clearly wrong, and often very wrong. For example, ZYXI shows a 0.00 spread when its closing spread on 7/26 was actually 0.11, MIXT shows a 0.00 spread when its closing spread was actually 0.08, and so on. In other words, the 0.00 spreads seem to be for thinly traded stocks with large bid-ask spreads. If this isn’t fixed, there will be some weird results.

Please do keep us updated on this. This is, for me, one of the most significant improvements I’ve seen on P123 in the last few months. Kudos!

I wonder if the bid/ask at the close reflects the bid/ask during the day.

I have a similar question: what is the bar? The close?

I looked at Showvar(@spread,spread(0)) for the first 10 holdings of GARP $1M versus the closing (16:00:00 bar) BID/ASK as shown by Fidelity. They were exactly the same for all ten.

So the ICE data are 100% accurate (or it agrees 100% with the Fidelity data).

I am not sure if the closing cross is narrowing the BID/ASK at the end of the day or if this narrowing of the spread is not related to the closing cross (see below). It may be that higher volumes at the end of the day are narrowing the spreads (probably). But Spread(0) was less than or equal to the spread at 10:30 AM in every case.

Spot check of first 10 holdings of GARP $1M

Ticker, Last, Spread(0), Spread at 10:30 Friday (Fidelity data)
AEL 35.81 0.01 0.02
ANTM 249.48 0.01 0.2 (not a decimal error)
DSW 26.81 0.01 0.02
ENSG 37.11 0.01 0.06 (wider spread during the day NOT FLAGGED by Spread(0))
PFBC 62.94 0.06 0.15 (wider spread during the day flagged by Spread(0))
RYAM 17.28 0.01 0.01
SC 19.39 0.01 0.01
TSG 25.60 0.05 0.10 (wider spread during the day flagged by Spread(0))
WCG 255.73 0.01 0.24 (not an error)
XCRA 14.29 0.01 0.01

Conclusions: for ANTM and for WCG the spreads during the day and at the close are markedly different. But these stocks have high prices 249.46 and 255.73 respectively. By taking spread(0)/close(0) the data is still useful for trading during the day as this does accurately reflect the general trend of the spread amount in percent for these stocks.

Spread(0)/Close(0) would not have detected the relatively wide spread for ENSG during the day but it would have flagged TSG and PFBC.

This does seem to be sensitive enough in identifying large spreads (for this small sample) to be helpful (sensitivity = 66%). But it may not identify every stock with a wide spread.

My small sample did not have any false positives (it was specific). I.E., it did not flag any stocks as having wide spreads that did not, if fact, have wide spreads during the day.

My sample is small and it did not look at the more thinly trades stocks.

Penultimate conclusion: Doubling Spread(0) (or a factor close to 2) would give a pretty good estimate of the spread during the day. Using 2 as a factor then 100 * (2*Spread(0))/(2 * Close(0)) or or 100 * Spread(0)/Close(0) might give a good estimate of the slippage in percent. The factor could be (should be) refined.

Specifically for this study the slippage would have been 0.0337% or 3 basis points for the end of the day spread and 0.0637% or 6 basis points for trades at 10:30 AM based on the BID/ASK at that time on Friday. This assumes that the average buys were at the ASK or sells at the BID. I think this is an excellent conservative estimate. Most people at P123 can do this well (or better) with each individual trade. Price impact with multiple trades is a whole different thing.

Final Conclusion: LIKELY TO BE VERY ACCURATE FOR PREDICTING SLIPPAGE (in aggregate for a port/sim). Especially after a little more work (more trials, bigger samples and different universes) than I have done here. I do not think it would be necessary to calculate the slippage for every transaction in a sim. Going back a month, a few months or whatever is possible with the computing power at P123 should be very accurate. The data seems to go back many years.

Slippage before penny pricing of stocks is useless information. Also, inflation makes your universe today a little different (in practice) than the distant past. So the use of extensive historical data is probably not necessary (or even helpful) on this. Going back a couple of years could be better than a couple of months for predicting slippage but I will take a couple of months if that is the best bang for the buck.


Testing this data item out, I fail to find any significant linear relationship between forward returns and raw/relative spreads. However, there are interesting non-linear relationships. E.g., interesting cross sections of stylistic (value, growth, momentum, etc.) returns in universes sorted by relative b/a spread. More evidence that opportunity/inefficiency is directly related to market friction (but not specifying the kind of relationship between friction and returns).


I can think of several possible uses for this function.

  1. As you suggest, using it to calculate much more accurate slippage in simulations. I look forward to being able to use a variable slippage option based on the spread.

  2. Defining a universe. Right now I use liquidity, float, and price to exclude stocks that are going to be expensive to trade. Using the median closing bid-ask spread over the last 25 days, for instance, in addition to or instead of one of these may save myself headaches when buying and selling low-liquidity stocks.

  3. Lowering the amount invested in a simulation depending on bid-ask spread. I tend to invest less in stocks with large bid-ask spreads, and being able to simulate that is a real boon.

Do let us know what the plan is for all the stocks that show bid-ask spreads of 0.00. There are over 800 of them, most of them ADRs or OTC stocks as far as I can tell.


This is a great addition and users will certainly find useful applications. Not sure it offers a much better guarantee in trading low-liquidity stocks. The spreads don’t tell how many shares were available at these prices. Bait orders with insignificant volumes are not rare.

There’s not much we can do for spreads that are 0.0 or NA . It seem to affect around 28% of the universe that has fundamentals (1700 out of 6000)

We can introduce a SpreadAvg that looks at the past 10 bars and averages the spreads if they are a number > 0. But this solution “fixes” (ie. has spread > 0) only 80 of the 1700 companies that have at least one NA or a 0 in the past 10 spreads.

In other words I think it’s best to keep it simple: any spreads that are 0 are converted to NA. And whatever algorithm we will use for slippage (like the one Jim proposes) will only use Spread(0); and fallback to some other algorithm if Spread(0) is NA.


Longterm it would be nice to have this slippage calculation (variable slippage calculated with Spread(0)) along with VWAP price data as options in sims.

Advantage: many people who are truly approaching their maximum liquidity use VWAP orders, percent of volume orders or other orders/algos that split the trading into many small orders throughout the day. Average fill price during the day vs VWAP is possibly the best measure of slippage for these people. Many institutional investors seem to use VWAP orders (e.g Miro). But also many savvy traders with IB as their broker use VWAP orders: many P123 members including SuPirate1081. And, as I mentioned, VWAP may be the best metric for many algos other than VWAP orders (e.g., percent of volume orders and many more).

If you look at each of the multiple 100 stock lot trades for a VWAP order throughout the day you will find that every one (almost no exceptions) is filled at the ASK for buys, or BID for sells, or better. This makes the combination of VWAP for price and Spread(0) for slippage an almost perfect conservative estimate for sims. If fact, the only imperfection is the lack of an estimate for price impact: perhaps a consideration for the far-distant future.

Disadvantage: Historical VWAP appears to be expensive. If you cannot get it cheaper than what I can find it for on the web I wouldn’t do it now.

It may belong on a wish list should you run into an inexpensive provider of historical VWAP data.



This should be a great addition for calculating slippage as everyone has noted.

For large orders market impact is an additional consideration and is very difficult to calculate from your own trades.

But here is a table for VWAP and Percent of Volume orders from the book “The Science of Algoithmic Trading and Portfolio Management” by Robert Kissell, Ph.D.

So, if you want to buy 5% of the ADV and you are willing to space the trades out over the entire trading day (with VWAP or 5% POV) your total trading cost would be 11.7 bp using his results.

This can be refined by looking at the volatility of the stock you are trading (formulas in the book). Or maybe it isn’t correct at all but as I said it is hard to measure and I have nothing better at this point. This is the simplest (with the table) that I have seen. But I cannot say how accurate it is.

Ideas and improvements very welcome.


Marco et al,

Does ICE also provide daily VWAP prices?


The biggest linear correlation I saw is that high priced stocks tend to have the smallest relative spread (Spread(0)/price) while the lowest priced stocks tend to have the largest relative spread. There are outliers, of course.

Good stuff!

We might all want to confirm our test/studies after the Nickel spreads are gone.


I’m very thankful for this new (as of last year anyway) Spread function. Thanks!