Using zipline and ta-lib to create input data for alphalens

Quantopian's open source python stock trading simulator zipline is very powerful and now comes with a mechanism to run daily bar simulations against over 3000 symbols from the quandl library.  It also provides flexible support to many libraries including classic technical analysis indicators.   Now a new tool can be used to more formally evaluate your trading signal.


Create custom zipline data bundle from local csv files

Quantopian's open source zipline - a Pythonic Algorithmic Trading Library - now uses an internal format to store open-high-low-close-volume (OHLCV) equity data called a data bundle.  Some examples of how to create bundles are provided in the data/bundles folder but they contain a lot of extra functionality for pulling data from web sources like yahoo.

Here is a basic example of creating a custom data bundle from local csv files.

Use minute bar machi.na challenge csv data in zipline with a custom data bundle

Quantopian’s zipline - a Pythonic Algorithmic Trading Library - is capable of running trading algorithm simulations with 1 minute open-high-low-close-volume (OHLCV). 

Here is an example of how to create a zipline custom data bundle from a local csv file that contains one minute bar data.  It builds on an earlier blog post for how to create custom zipline data bundles.  Then, we will write a simple zipline algo to test it.

Stock Universe and “IB reports a holding … adding to Quantopian Blotter”

IB Adding

When running against an Interactive Brokers (IB) paper (or real money) account, Quantopian has a cool feature where it scans the current holdings and populates context.portfolio with current holdings.  You see a log message like “IB reports a holding … adding to Quantopian Blotter”.


A side effect of this is also expansion of your stock universe that is passed to handle_data or your scheduled functions.  If your IB account has existing stocks that are outside of the universe you specified in your initialize segment (eg, using context.secs = [symbol(‘IBM’),symbol(‘HPQ’)] or via Quantopian Pipeline , and you have automated sell logic based on examining context.portfolio.positions, you could sell holdings by mistake.


Read more for how to plan for this


Subscribe to RSS - Quantopian