Back to Community
Getting adjusted price in pipeline

I'm using pipeline in my research, and suspect that price data (eg. from EquityPricing.Close) isn't adjusted to split or dividend. Take for instance close price for AAPL:

2005-02-18 00:00:00+00:00 87.810
2005-02-22 00:00:00+00:00 86.740
2005-02-23 00:00:00+00:00 85.380
2005-02-24 00:00:00+00:00 88.220
2005-02-25 00:00:00+00:00 88.900
2005-02-28 00:00:00+00:00 44.485*
2005-03-01 00:00:00+00:00 44.780
2005-03-02 00:00:00+00:00 44.430
2005-03-03 00:00:00+00:00 44.130
2005-03-04 00:00:00+00:00 41.800

*From Feb 25 to Feb 28, the price of AAPL suddenly dropped by half.

Is there any way to get adjusted close price in pipeline?

3 responses

Pipeline data is split and dividend adjusted. It's just adjusted as of each pipeline date. The goal of pipeline is to provide point-in-time data which is what a trader (or algorithm) would have seen on a specific pipeline date. Providing forward adjusted prices would introduce forward lookahead bias. If one wants adjusted prices as of a specific day then one can use the get_pricing or similar method. Check out the documentation

There are a couple of posts which go into more detail on this (and interestingly use AAPL as an example too).


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.

Thanks Dan.

I would have thought that pipeline would adjusted for split based on the end_date parameter.

For instance:

pipe = Pipeline(  
        'close': USEquityPricing.close.latest,  

# filter  
symbol = StaticAssets(symbols(['AAPL']))  
df = run_pipeline(pipe, '2005-02-20', '2005-03-05')  

The result shows no adjustment:
2005-02-22 00:00:00+00:00 Equity(24 [AAPL]) 86.740
2005-02-23 00:00:00+00:00 Equity(24 [AAPL]) 85.380
2005-02-24 00:00:00+00:00 Equity(24 [AAPL]) 88.220
2005-02-25 00:00:00+00:00 Equity(24 [AAPL]) 88.900
2005-02-28 00:00:00+00:00 Equity(24 [AAPL]) 44.485
2005-03-01 00:00:00+00:00 Equity(24 [AAPL]) 44.780
2005-03-02 00:00:00+00:00 Equity(24 [AAPL]) 44.430
2005-03-03 00:00:00+00:00 Equity(24 [AAPL]) 44.130
2005-03-04 00:00:00+00:00 Equity(24 [AAPL]) 41.800
2005-03-07 00:00:00+00:00 Equity(24 [AAPL]) 42.800

Does that mean my CustomFactor is using a non-adjusted price all this time?

I can switch to get_pricing in my research. But I need the universe selection capability of the pipeline. Is this possible?

Ok correction, after some experiments I got it. The price is adjusted during CustomFactor: on 2005-2-25, when we look at value[-1] it is at 88.9. But on the next tick on 2005-2-28, if we look back to 2005-2-25 at value[-2], it is adjusted accordingly to 44.45.

Following is the custom factor code that I used for the experiment in case someone is interested.

class get_adj(CustomFactor):  
    window_length = 2  
    def compute(self, today, assets, out, value):  
        out[:] = value[-2]  

So, if we use the price in CustomFactor, it is safe. My problem arises when I try to create new columns from pipeline result (pandas dataframe). If I stick to just CustomFactor this should be fine.

Although, having the universe functionality in get_pricing does come in handy.