The other night I was wondering why the daily trading volumes I receive from brokers and see on market data websites is different than the volumes I see on Quantopian.
Here are two examples from the past few days.
SPY
Date......Broker Volume.......Quantopian......% Difference
12-Jun........86,108,102.......57,082,069......-34%
9-Jun........132,256,362.....103,552,885.....-22%
8-Jun..........65,950,691.......48,049,822.....-27%
7-Jun..........54,144,311.......38,597,399.....-29%
TSLA
Date......Broker Volume......Quantopian......% Difference
12-Jun.......10,517,660........8,528,736......-19%
9-Jun.........17,261,435......14,322,826......-17%
8-Jun...........9,061,496........7,489,685......-17%
7-Jun...........9,397,959........7,850,442......-16%
The Quantopian code I'm using is:
context.spy = sid(8554)
data.history(context.spy, ['volume'], 14, '1d')
Looking at some minute bars for these days, it quickly became apparent that the Quantopian data doesn't include after-hours volumes, which is documented on the API Reference page. The first few minutes after the close appear to be the most significant source of the difference, which I'm assuming is the closing auction. I simply never realized how large of a percentage of the total daily trading volume occurred at the close and after-hours. Thought others might find this interesting.
I personally think excluding after-hours volumes makes sense for many intents and purposes, but wonder if there is also a way in Quantopian to get the full daily volume should it be useful. Thoughts?