Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
bad price and volume data in minute getting from history()
API

I implement a strategy based on k lines in minute, and get corresponding history data with:
h = data.history(sid(24), fields=['open', 'high', 'low', 'close', 'volume'], bar_count=390, frequency="1m")
But I find 'volume' is incorrect within in every minute, and the accumulated volume is less than actual daily volume. I tested both AAPL and IRTC. Another problem is that other prices in minute without changing are all nan.
Any advise?

2 responses

@scout dai Could you give an example of why you feel the "'volume' is incorrect within every minute". Are you comparing the numbers to a third party data source? Note that the data.history values will be adjusted for splits and dividends as of the simulation date. Third party sources are generally adjusted (and often only split adjusted) as of the current date. Also, Quantopian data does not include the opening and closing auctions in the data. There is a post with some more information on that here.

Any minute open, high, low, and close prices where a trade did not occur will be nan. The volume in those minutes will be zero. The 'price' however, is forward filled from the previous minute close price and will not generally be nan (unless there were no previous trades).

Attached is a notebook showing how the aggregated minute volume equals the daily volume. The data from get_pricing in a notebook will be the same as that from data.history in an algo if the get_pricing end date is the same as the simulation date.

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.

The answer help me solve the puzzles, thank you.