Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
History data does not match real time data

Hi All
I tried to compare the 1m volume data with the yahoo finance data . but it does not match with quantopian . am i missing some thing ?

my code to print

def handle_data(context, data):
"""
Called every minute.
"""
sids=[sid(24)]

prices_15m_2bar = data.history(sids, 'volume', 1, '1m')  
print prices_15m_2bar

For ex the data printed above for 9/20 for AAPL

2019-09-20 13:31:00+00:00 6148172.0
2019-09-20 13:32:00+00:00 151885.0
2019-09-20 13:33:00+00:00 117187.0
2019-09-20 13:34:00+00:00 91811.0
2019-09-20 13:35:00+00:00 93632.0
2019-09-20 13:36:00+00:00 65137.0
2019-09-20 13:37:00+00:00 97718.0
2019-09-20 13:38:00+00:00 69243.0
2019-09-20 13:39:00+00:00 50268.0

The data from yahoo finance
9/20 9:31AM 174.32K
9/20 9:32AM 132.21k so on

is this expected ? thanks for any help

2 responses

Quantopian price and volume data is compiled from trades executed on the major US exchanges during market hours. However, for many stocks, a considerable number of shares are not traded on an exchange at all but rather through private channels. ETFs, large funds, and brokers often trade 'off-exchange'. Estimates have put the number of 'off-exchange' trades to be about 30% and potentially much higher for large liquid stocks like AAPL. These trades will not show up in the Quantopian data.

These 'off-exchange' trades are often lumped together under the ominous umbrella 'dark pools'. It's not as nefarious as it sounds and ALL trading is very tightly regulated by the SEC and FINRA rules. Also, all trade volume, regardless of the channel, must be reported and does find its way back to the exchange where the stock is listed. There is a pretty good description in Wikipedia https://en.wikipedia.org/wiki/Dark_pool . The nitty-gritty of who and how and when security transfers must be reported is detailed in the FINRA guidelines https://www.finra.org/filing-reporting/market-transparency-reporting/trade-reporting-faq#102.

So, other providers such as Yahoo may get their data from other sources and cover other hours (eg after hours trading) and include trade volume which didn't occur on a major exchange or potentially only occurred on a specific exchange. Price data will generally be very close regardless of how the data is captured (because of market forces). However, volume data can vary widely.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Dan
Thanks for the quick and detailed explanation . Obviously the variation is applicable to other parameters(close , price , open , high ,low etc ) too ?