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(today.date()) 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')
Output:
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()
Output:
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