Daily Volume Data different from other sources

Hello everyone,

I'm pretty new to Quantopian.
I recently started creating a pipeline filter for volume, but came to realize the volume data was different from sources like Yahoo or Nasdaq.
I've read a post in the forums (link) but it doesn't explain as to why Quantopia's volume numbers are very different from other sources.

I've tried :
1.) quantopian.research.volumes import volumes
2.) USEquityPricing.volume.latest

and both have quite different numbers compared to Yahoo or Nasdaq.

Does anyone know I can get information that is closer to that of Yahoo or Nasdaq?

3 responses

First off welcome to Quantopian!

What you may be seeing is how various platforms adjusts for splits and dividends? Quantopian pipeline prices and volumes are adjusted daily as of the pipeline date (ie the date in the level 0 index). Yahoo prices are adjusted as of the current date. Being adjusted as of different dates makes the prices and volumes appear different. There are several post which go into more detail. Take a look at the following:

If that doesn't seem to be the issue you are seeing please attach a notebook showing the problem. Maybe it's something else.

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.

Hi Dan,

Thanks for the prompt response. I believe this most likely is the answer to my question.
You mentioned Quantopian's pipeline prices & volumes are adjusted daily & Yahoo Prices are adjusted as of the current date.
Could you kindly explain how this is different? Is adjusted as of the current date != adjusted daily?

For example:

If the pipeline was looking for the daily volume of 'AAPL' for 2017-01-04', how would the adjusting be different in both cases?

Thank you!

Maybe a little bit of perspective on why prices and volumes are presented as 'adjusted'. Let's take a real life example of AAPL which had a 7-for-1 stock split on June 9, 2014. The real, you would have paid this much, 'un-adjusted' close prices for AAPL around the time of the split were

Date                  Equity    price

2014-06-05  Equity(24 [AAPL])   644.82
2014-06-06  Equity(24 [AAPL])   647.35
2014-06-09  Equity(24 [AAPL])   92.22
2014-06-10  Equity(24 [AAPL])   93.70


On Friday 2014-06-06 one would have paid $647.35 for a share of AAPL. On Monday 2014-06-09 one would have paid$92.22 for a share. The reality is that on Monday there were 7 times as many shares in circulation so each share was worth proportionately less. Conversely, if one had purchased a share of AAPL on Friday then they would hold 7 shares on Monday. Nonetheless, those are what a share would have cost on those days.

In a 'simple' world that would be the end of the story. That was the price. Period.

However, a huge part of trading revolves around returns and gains. 'How much did I make ' and 'how much is it worth now' are fundamental questions. Looking simply at the prices above it would appear AAPL lost a lot on Monday 2014-06-09. That clearly wasn't the case. To get around this, the concept of 'adjusted prices' was invented. First one needs to specify the 'adjusted as of date'. Price and volumes are typically adjusted backwards from that date. Next one needs to know when any stock splits occurred. Finally, divide the price by the split value if the split (or splits) occurred before a particular date in question. Below are the prices adjusted as of 2014-06-09.

Date                  Equity    price

2014-06-05  Equity(24 [AAPL])   92.12
2014-06-06  Equity(24 [AAPL])   92.48
2014-06-09  Equity(24 [AAPL])   92.22



Now one can see there was actually a relative increase from 2014-06-05 to 2014-06-09. Additionally, the volumes would have also been proportionally adjusted.

Now the case if prices are adjusted as of 2014-06-06.

Date                  Equity    price

2014-06-05  Equity(24 [AAPL])   644.82
2014-06-06  Equity(24 [AAPL])   647.35


Since the split hasn't occurred yet the prices appear the same.

A similar calculation is done whenever adjusting for dividends. It looks much like a small stock split. It adjusts share values before the dividend down by the amount of the dividend. It's as if the dividend was a rebate the company paid on it's stock so the net price was a little lower.

OK, back to the original question... "If the pipeline was looking for the daily volume of 'AAPL' for 2017-01-04', how would the adjusting be different in both cases?". Pipeline would use 2017-01-04 as the adjustment date while Yahoo uses the current date (ie 2019-8-22). Pipeline wouldn't include any corporate actions after 2017-01-04 while Yahoo would.

Using the example above, in the research (notebook) environment a pipeline returns a multi-indexed dataframe. All pipeline data based upon price or volume are adjusted daily as of the pipeline date (ie the date in the level 0 index). Using the example above, for index 2014-06-06 the latest price would be adjusted as of that date and be 647.35. For index 2014-06-09 the latest price would be adjusted as of that date and be 92.22. The 2014-06-06 price would be similarly adjusted and be 92.48. Think of it as a 'rolling' adjustment as-of date. To prevent lookahead bias, the entire framework is based around having pipeline return only data that would have been known on that date. It never looks into the future to assume any events.

To get an 'apples to apples' comparison (please excuse the pun) use the Quantopian get_pricing method with and end date equal to the current date. This should closely match Yahoo or other 3rd party data since they will all be adjusted to the same current date.

Now, there may be other reasons why volumes vary so these need to be looked at case by case. As mentioned, if that doesn't seem to be the issue you are seeing please attach a notebook showing the problem.

A final word of caution on Yahoo data. Since it's constantly being re-adjusted as of the current date, historical data downloaded six months ago may be different than what is downloaded today. It all depends upon if any relevant corporate actions occurred in the past 6 months. This is one aspect of Quantopian data which is important in research. It can be replicated by specifying the as-of date.