One thing to remember is that pipelines use values up to the previous day when carrying out calculations. For example, running a pipeline on 11/29/2017 that calculates the YTD returns of a stock will calculate the returns between 01/01/2017 and 11/28/2017.
On the other hand, the prices function returns the pricing data for the date requested. Using the example from your notebook, calculating the YTD returns on 11/29/2017 will result on calculating returns between 01/01/2017 and 11/29/2017.
To make the outputs match, you will need to adjust the start/end dates you input to prices to be 1 day previous to the date on which you run the pipeline. Attached you will find a copy of your notebook where I have made this change, you will notice the outputs from both methods match.
Regarding AAME's missing values, it appears to be missing pricing data on some days but not for the entire year. The problem is that the sum function does not handle NaN values properly, a single NaN value will cause the result to be NaN as well. You should use numpy.nansum instead.
I hope this helps.
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.