From 24f30803bd9f1dcc8b66914092588d39debbfa53 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Fri, 27 May 2016 16:41:47 -0400 Subject: [PATCH] REL: 1.0.1. Update docs, whatsnew, and stub files for the release. --- docs/source/appendix.rst | 13 ++++++- docs/source/whatsnew/1.0.1.txt | 69 ++++++++++++++++------------------ zipline/api.pyi | 4 +- zipline/finance/commission.py | 27 +++++++++---- 4 files changed, 65 insertions(+), 48 deletions(-) diff --git a/docs/source/appendix.rst b/docs/source/appendix.rst index 6570b803..d26807e5 100644 --- a/docs/source/appendix.rst +++ b/docs/source/appendix.rst @@ -117,14 +117,25 @@ bugs that could cause undesirable behavior when trading with real money. Simulation Parameters ````````````````````` +.. autofunction:: zipline.api.set_benchmark + +Commission Models +''''''''''''''''' + .. autofunction:: zipline.api.set_commission +.. autoclass:: zipline.finance.commission.CommissionModel + :members: + .. autoclass:: zipline.finance.commission.PerShare .. autoclass:: zipline.finance.commission.PerTrade .. autoclass:: zipline.finance.commission.PerDollar +Slippage Models +''''''''''''''' + .. autofunction:: zipline.api.set_slippage .. autoclass:: zipline.finance.slippage.SlippageModel @@ -134,8 +145,6 @@ Simulation Parameters .. autoclass:: zipline.finance.slippage.VolumeShareSlippage -.. autofunction:: zipline.api.set_benchmark - Pipeline ```````` diff --git a/docs/source/whatsnew/1.0.1.txt b/docs/source/whatsnew/1.0.1.txt index ee12da55..37141662 100644 --- a/docs/source/whatsnew/1.0.1.txt +++ b/docs/source/whatsnew/1.0.1.txt @@ -1,59 +1,54 @@ -Development ------------ +Release 1.0.1 +------------- :Release: 1.0.1 -:Date: TBD +:Date: May 27, 2016 -.. warning:: - This release is still under active development. All changes listed are - subject to change at any time. - - -Highlights -~~~~~~~~~~ - -None +This is a minor bug-fix release from 1.0.0 and includes a small number of bug +fixes and documentation improvements. Enhancements ~~~~~~~~~~~~ -None +- Added support for user-defined commission models. See the + :class:`zipline.finance.commission.CommissionModel` class for more details on + implementing a commision model. (:issue:`1213`) -Experimental Features -~~~~~~~~~~~~~~~~~~~~~ - -.. warning:: - - Experimental features are subject to change. - -None +- Added support for non-float columns to Blaze-backed Pipeline + datasets (:issue:`1201`). Bug Fixes ~~~~~~~~~ -None +- Fixed a bug where Pipeline loaders were not properly initialized by + :func:`zipline.run_algorithm`. This also affected invocations of ``zipline + run`` from the CLI. -Performance -~~~~~~~~~~~ +- Fixed a bug that caused the ``%%zipline`` IPython cell magic to fail + (:commit:`533233fae43c7ff74abfb0044f046978817cb4e4`). -None +- Fixed a bug in the :class:`~zipline.finance.commission.PerTrade` commission + model where commissions were incorrectly applied to each partial-fill of an + order rather than on the order itself, resulting in algorithms being charged + too much in commissions when placing large orders. -Maintenance and Refactorings -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + :class:`~zipline.finance.commission.PerTrade` now correctly applies + commissions on a per-order basis (:issue:`1213`). -None +- Attribute accesses on :class:`CustomFactors ` + defining multiple outputs will now correctly return an output slice when the + output is also the name of a :class:`~zipline.pipeline.factors.Factor` method + (:issue:`1214`). -Build -~~~~~ +- Replaced deprecated usage of ``pandas.io.data`` with ``pandas_datareader`` + (:issue:`1218`). -None +- Fixed an issue where ``.pyi`` stub files for :mod:`zipline.api` were + accidentally excluded from the PyPI source distribution. Conda users should + be unaffected (:issue:`1230`). Documentation ~~~~~~~~~~~~~ -None - -Miscellaneous -~~~~~~~~~~~~~ - -None +- Added a new example, :mod:`zipline.examples.momentum_pipeline`, which + exercises the Pipeline API (:issue:`1230`). diff --git a/zipline/api.pyi b/zipline/api.pyi index 769306f6..0a16a719 100644 --- a/zipline/api.pyi +++ b/zipline/api.pyi @@ -557,11 +557,11 @@ def set_cancel_policy(cancel_policy): """ def set_commission(commission): - """Sets the commision model for the simulation. + """Sets the commission model for the simulation. Parameters ---------- - commission : PerShare, PerTrade, or PerDollar + commission : CommissionModel The commission model to use. See Also diff --git a/zipline/finance/commission.py b/zipline/finance/commission.py index 8f379aa8..0e2a3838 100644 --- a/zipline/finance/commission.py +++ b/zipline/finance/commission.py @@ -24,25 +24,38 @@ DEFAULT_MINIMUM_COST_PER_TRADE = 1.0 # $1 per trade class CommissionModel(with_metaclass(abc.ABCMeta)): """ Abstract commission model interface. + + Commission models are responsible for accepting order/transaction pairs and + calculating how much commission should be charged to an algorithm's account + on each transaction. """ @abstractmethod def calculate(self, order, transaction): """ + Calculate the amount of commission to charge on ``order`` as a result + of ``transaction``. + Parameters ---------- - order: the order whose transaction we are processing. Its `commission` - field is up to date with how much commission has been attributed - to this order so far. + order : zipline.finance.order.Order + The order being processed. - transaction: the transaction we are processing. + The ``commission`` field of ``order`` is a float indicating the + amount of commission already charged on this order. + + transaction : zipline.finance.transaction.Transaction + The transaction being processed. A single order may generate + multiple transactions if there isn't enough volume in a given bar + to fill the full amount requested in the order. Returns ------- - float: The additional commission, in dollars, that we should attribute - to this order. + amount_charged : float + The additional commission, in dollars, that we should attribute to + this order. """ - pass + raise NotImplementedError('calculate') class PerShare(CommissionModel):