Notebook
In [123]:
import pandas as pd
from quantopian.pipeline import Pipeline
from quantopian.pipeline.factors import Latest
from quantopian.research import run_pipeline
start = '2015-1-2'
end = '2015-3-2'
i = pd.to_datetime('2015-1-7', utc=True)
# yahoo finance value is 107.75
In [131]:
pipe= Pipeline()
prices = Latest(inputs=[USEquityPricing.close])
pipe.add(prices, 'prices')
myPipe=run_pipeline(pipe, start_date=start, end_date=end)
In [164]:
#pipeline prices
aapl_pp = myPipe.unstack().iloc[:,2]
In [165]:
#pipeline prices shifted
aapl_pp_sf = aapl_pp.shift(-1)
In [166]:
#get_pricing prices and prices resampled
aapl_gp = get_pricing('AAPL', start, end, fields='price')
aapl_gp_rs= aapl_gp.resample('3B')
aapl_gp_af= aapl_gp.asfreq('3B')

pipeline shifted vs get_pricing

In [161]:
ax = aapl_pp_sf.plot() #pipeline_prices shifted
aapl_gp.plot(ax=ax) #get_pricing prices
Out[161]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fdabf997e10>

same data resampled vs asfreq

In [160]:
ax = aapl_gp_rs.plot() #resampled data
aapl_gp_af.plot(ax=ax) #asfreq data
Out[160]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fdabfb9a7d0>
In [112]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [163]:
print 'yahoo finance: ', '107.75'
print 'get_pricing: ', aapl_gp.loc[i] #OK
print '--> ?? get_pricing resampled: ', aapl_gp_rs.loc[i] , '? <--'# ??
print 'get_pricing asfreq: ', aapl_gp_af.loc[i] #OK
print 'pipeline: ', aapl_pp.loc[i]
print 'pipeline shifted: ', aapl_pp_sf.loc[i]
yahoo finance:  107.75
get_pricing:  107.75
--> ?? get_pricing resampled:  110.54 ? <--
get_pricing asfreq:  107.75
pipeline:  106.23
pipeline shifted:  107.75
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]: