Back to Community
zipline: Issue while creating custom bundle to bring Yahoo data

Hi, I'm using zipline in offline backtesting mode. I want to download some tickers (SPDR industry ETFs), which quantopian-quandl bundle doesn't have, but I having trouble doing that as per guide here:
zipline custom bundles The instruction is:

To create a bundle from a set of equities, add the following to your file:
~/.zipline/extensions.py

from zipline.data.bundles import register, yahoo_equities

# these are the tickers you would like data for  
equities = {  
    'AAPL',  
    'MSFT',  
    'GOOG',  
}
register(  
    'my-yahoo-equities-bundle',  # name this whatever you like  
    yahoo_equities(equities),  
)

The problem is that I don't have file extensions.py in my zipline folder and I installed zipline through conda and everything else seems to be working correctly. Can someone enlighten me please how can I create a custom bundle to get only certain tickers?

3 responses

Hi Pepo,

To be clear, the folder that extensions.py should be in is the hidden folder ".zipline" (note the period at the beginning), which should be in your home folder. If you're on a Mac, you can open the hidden folder in Finder by executing the following in Terminal:

open ~/.zipline  

If you do that can you see the extensions.py file?

Disclaimer

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 Nathan. I see both file and folder. Thanks for that. I'll keep experimenting.

File "/usr/local/bin/zipline", line 11, in
load_entry_point('zipline-live==1.1.0.1', 'console_scripts', 'zipline')()
File "/usr/lib/python2.7/dist-packages/click/core.py", line 716, in call
return self.main(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
return process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, *ctx.params)
File "/usr/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
return callback(
args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/zipline/
main.py", line 360, in ingest
show_progress,
File "/usr/local/lib/python2.7/dist-packages/zipline/data/bundles/core.py", line 451, in ingest
pth.data_path([name, timestr], environ=environ),
File "/usr/local/lib/python2.7/dist-packages/zipline/data/bundles/yahoo.py", line 152, in ingest
session=session,
File "/usr/local/lib/python2.7/dist-packages/pandas_datareader/data.py", line 126, in DataReader
session=session).read()
File "/usr/local/lib/python2.7/dist-packages/pandas_datareader/yahoo/actions.py", line 35, in read
splits['value'] = splits.apply(lambda x: 1/eval(x['value']), axis=1) # noqa
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 2357, in _
setitem__
self.set_item(key, value)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 2422, in _set_item
self._ensure_valid_index(value)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 2404, in _ensure
valid_index
raise ValueError('Cannot set a frame with no defined index '
ValueError: Cannot set a frame with no defined index and a value that cannot be converted to a Series

I get this error