Search code examples
pythonzipline

How do I load an index (Dow, Nasdaq) with Zipline?


Loading individual stocks is no problem but I was struggeling with loading stock indexes for a while so I thought I should share.


Solution

  • If you want to load an index with zipline just add it to the stock parameter like this:

        data = load_from_yahoo(stocks=['AAPL', '^gspc', '^ixic'], indexes={}, start=datetime(2014, 1, 1), end=datetime(2015,4,2))
    

    This will load both Apple's stock prices, NASDAQ Composite and s&p500.