Back to Community
USEquityPricing and get_pricing data difference

I'm trying to see why USEquityPricing.close in a Factor and get_pricing return data that might be different.

For example, in the factor below, on 2014-01-02, I get AAPL's (sid: 24) price as 567.72. Whereas using get_pricing, I get a price of 77.405.

Any help is appreciated. Thanks!

universe = Q500US()

class MyReturns(CustomFactor):  
    inputs = [USEquityPricing.close]

    def compute(self, today, assets, out, close):  
        if str( in ['2014-01-02']:  
            print pd.DataFrame(close, columns=assets)[24]  
        out[:] = (close[-1] - close[0]) / close[0]

def make_pipeline():  
    past_returns = MyReturns(window_length=5, mask=universe)  
    pipe = Pipeline(  
        columns = {  
            'past_returns': past_returns,  
    return pipe

results = run_pipeline(make_pipeline(), '2014-01-01', '2015-01-01')  


0 | 567.72
1 | 563.83
2 | 560.09
3 | 554.50
4 | 561.16

[5 rows x 500 columns]

Here is using get_pricing:
prices = get_pricing(asset_list, start_date='2014-01-01', end_date='2015-01-01', fields='close_price') prices[24].head()


2014-01-02 | 77.405
2014-01-03 | 75.700
2014-01-06 | 76.107
2014-01-07 | 75.559
2014-01-08 | 76.043
Freq: C, Name: Equity(24 [AAPL]), dtype: float64

4 responses

inconsistent stock split adjustement?

Yup, that is probably it. Looks like USEquityPricing is not adjusted for splits. This could be a problem.

Loading notebook preview...

Your issue is with the end date used in 'get_pricing' . When using 'get_pricing' the prices are all split AND dividend adjusted AS OF THE END DATE in the 'get_pricing' call. When using pipeline the prices are continuously split adjusted each day AS OF THE CURRENT day (ie the day returned in 'today').

Note your numbers are off by a factor of about 7. Running 'get_pricing' with an end date of 2015-01-01 takes into account the big 7:1 AAPL split on June 9th 2014 and the dividends throughout the year. Running the pipeline, as of 2014-01-02, that split and those dividends haven't occurred yet. Pipeline never looks into the future and therefor always returns the actual non-adjusted prices for the current day.

Take a look at this post

If you run get pricing ending the same day as 'today' (ie 2014-01-02 in your example) they should be the same. Note however, the pipeline close retrieved on 2014-01-03 is actually the close price from the previous day 2014-01-02. You will need to change your 'if' statement in the customfactor.

prices = get_pricing(asset_list, start_date='2014-01-01', end_date='2014-01-02', fields='close_price') prices[24].head()

ah that makes sense. Thanks Dan!