Back to Community
Analyzing Pipeline Data from Research notebook - How to get data using Equity object?

Hi there,

Say if I have a data that I got from running a pipeline i.e.

my_pipe = make_pipeline()  
data = run_pipeline(my_pipe, '2014-05-05', '2015-05-05')  

How do I get, for example, data for only AAPL equity? In Pipeline result, looks like equities are zipline.assets._assets.Equity objects and we are not allowed to run from zipline.assets._assets import Equity. How else do I create Equity object?

Loading notebook preview...
Notebook previews are currently unavailable.
4 responses

you have 2 levels that are not columns. Convert at least one of them.
Then access as normal. Here is how I did it.

result.reset_index(inplace =True)  
result.rename(columns ={ 'level_0': 'Current Day',  
                        'level_1': 'sid'  
                     },  
                     inplace=True)  

Where 'Ps' is price to sales ratio

for i in xrange(0,len(result)):  
    if result.sid[i].symbol == u'AAPL':  
        print 'AAPL',result['Ps'][i]  

Thank you for replying to this thread.

Unfortunately, I cannot use for iteration nor == operator here. I need to be able to get directly from pandas. See following code:

eq1 = # How do I create Equity object here?  
df = pd.DataFrame(data.ix[:, 'close_price'].xs(eq1, level=1))  

Any idea?

Thanks

this will give you Equity object for SPY

p = get_pricing(['SPY','TLT'])  
SPY = p.axes[2][0]