Release 0.7.0 ------------- :Release: 0.7.0 :Date: July 25, 2014 Highlights ~~~~~~~~~~ * Command line interface to run algorithms directly. * IPython Magic ``%%zipline`` that runs algorithm defined in an IPython notebook cell. * API methods for building safeguards against runaway ordering and undesired short positions. * New history() function to get a moving DataFrame of past market data (replaces BatchTransform). * A new `beginner tutorial `__. Enhancements ~~~~~~~~~~~~ * CLI: Adds a CLI and IPython magic for zipline. Example: :: python run_algo.py -f dual_moving_avg.py --symbols AAPL --start 2011-1-1 --end 2012-1-1 -o dma.pickle Grabs the data from yahoo finance, runs the file dual\_moving\_avg.py (and looks for ``dual_moving_avg_analyze.py`` which, if found, will be executed after the algorithm has been run), and outputs the perf ``DataFrame`` to ``dma.pickle`` (:issue:`325`). - IPython magic command (at the top of an IPython notebook cell). Example: :: %%zipline --symbols AAPL --start 2011-1-1 --end 2012-1-1 -o perf Does the same as above except instead of executing the file looks for the algorithm in the cell and instead of outputting the perf df to a file, creates a variable in the namespace called perf (:issue:`325`). * Adds Trading Controls to the algorithm API. The following functions are now available on ``TradingAlgorithm`` and for algo scripts: ``set_max_order_size(self, sid=None, max_shares=None, max_notional=None)`` Set a limit on the absolute magnitude, in shares and/or total dollar value, of any single order placed by this algorithm for a given sid. If ``sid`` is None, then the rule is applied to any order placed by the algorithm. Example: .. code-block:: python def initialize(context): # Algorithm will raise an exception if we attempt to place an # order which would cause us to hold more than 10 shares # or 1000 dollars worth of sid(24). set_max_order_size(sid(24), max_shares=10, max_notional=1000.0) ``set_max_position_size(self, sid=None, max_shares=None, max_notional=None)`` -Set a limit on the absolute magnitude, in either shares or dollar value, of any position held by the algorithm for a given sid. If ``sid`` is None, then the rule is applied to any position held by the algorithm. Example: .. code-block:: python def initialize(context): # Algorithm will raise an exception if we attempt to order more than # 10 shares or 1000 dollars worth of sid(24) in a single order. set_max_order_size(sid(24), max_shares=10, max_notional=1000.0) ``set_max_order_count(self, max_count)`` Set a limit on the number of orders that can be placed by the algorithm in a single trading day. Example: .. code-block:: python def initialize(context): # Algorithm will raise an exception if more than 50 orders are placed in a day. set_max_order_count(50) ``set_long_only(self)`` Set a rule specifying that the algorithm may not hold short positions. Example: .. code-block:: python def initialize(context): # Algorithm will raise an exception if it attempts to place # an order that would cause it to hold a short position. set_long_only() (:issue:`329`). * Adds an ``all_api_methods`` classmethod on ``TradingAlgorithm`` that returns a list of all ``TradingAlgorithm`` API methods (:issue:`333`). * Expanded record() functionality for dynamic naming. The record() function can now take positional args before the kwargs. All original usage and functionality is the same, but now these extra usages will work: .. code-block:: python name = 'Dynamically_Generated_String' record( name, value, ... ) record( name, value1, 'name2', value2, name3=value3, name4=value4 ) The requirements are simply that the poritional args occur only before the kwargs (:issue:`355`). * history() has been ported from Quantopian to Zipline and provides moving window of market data. history() replaces BatchTransform. It is faster, works for minute level data and has a superior interface. To use it, call ``add_history()`` inside of ``initialize()`` and then receive a pandas ``DataFrame`` by calling history() from inside ``handle_data()``. Check out the `tutorial `__ and an `example `__. (:issue:`345` and :issue:`357`). * history() now supports ``1m`` window lengths (:issue:`345`). Bug Fixes ~~~~~~~~~ * Fix alignment of trading days and open and closes in trading environment (:issue:`331`). * RollingPanel fix when adding/dropping new fields (:issue:`349`). Performance ~~~~~~~~~~~ None Maintenance and Refactorings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Removed undocumented and untested HDF5 and CSV data sources (:issue:`267`). * Refactor sim\_params (:issue:`352`). * Refactoring of history (:issue:`340`). Build ~~~~~ * The following dependencies have been updated (zipline might work with other versions too): .. code-block:: diff -pytz==2013.9 +pytz==2014.4 +numpy==1.8.1 -numpy==1.8.0 +scipy==0.12.0 +patsy==0.2.1 +statsmodels==0.5.0 -six==1.5.2 +six==1.6.1 -Cython==0.20 +Cython==0.20.1 -TA-Lib==0.4.8 +--allow-external TA-Lib --allow-unverified TA-Lib TA-Lib==0.4.8 -requests==2.2.0 +requests==2.3.0 -nose==1.3.0 +nose==1.3.3 -xlrd==0.9.2 +xlrd==0.9.3 -pep8==1.4.6 +pep8==1.5.7 -pyflakes==0.7.3 -pip-tools==0.3.4 +pyflakes==0.8.1` -scipy==0.13.2 -tornado==3.2 -pyparsing==2.0.1 -patsy==0.2.1 -statsmodels==0.4.3 +tornado==3.2.1 +pyparsing==2.0.2 -Markdown==2.3.1 +Markdown==2.4.1 Contributors ~~~~~~~~~~~~ The following people have contributed to this release, ordered by numbers of commit: :: 38 Scott Sanderson 29 Thomas Wiecki 26 Eddie Hebert 6 Delaney Granizo-Mackenzie 3 David Edwards 3 Richard Frank 2 Jonathan Kamens 1 Pankaj Garg 1 Tony Lambiris 1 fawce