Quant

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

Quantopian zipline trading algorithm parameter optimization with Spearmint Bayesian Optimizer - Part 5 Conclusions and Next Steps

In this series, we used the open source spearmint optimizer to select optimal tuning parameters for a quantopian zipline trading algorithm.
Read more for conclusions and next steps.

Pages

Subscribe to RSS - Quant