From ec7cba2e314e47124b9f799ac6e6008137442dcc Mon Sep 17 00:00:00 2001 From: dmichalowicz Date: Tue, 25 Apr 2017 18:42:43 -0400 Subject: [PATCH] API: Don't require custom models to define allowed types --- zipline/finance/commission.py | 10 +++------- zipline/finance/slippage.py | 11 ++++------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/zipline/finance/commission.py b/zipline/finance/commission.py index 61a17711..19cda98c 100644 --- a/zipline/finance/commission.py +++ b/zipline/finance/commission.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import abc -from abc import abstractmethod, abstractproperty +from abc import abstractmethod from collections import defaultdict from six import with_metaclass @@ -39,12 +39,8 @@ class CommissionModel(with_metaclass(abc.ABCMeta)): on each transaction. """ - @abstractproperty - def allowed_asset_types(self): - """ - Return a tuple of asset types that are compatible with the given model. - """ - raise NotImplementedError('allowed_asset_types') + # Asset types that are compatible with the given model. + allowed_asset_types = (Equity, Future) @abstractmethod def calculate(self, order, transaction): diff --git a/zipline/finance/slippage.py b/zipline/finance/slippage.py index 09e72666..c1900414 100644 --- a/zipline/finance/slippage.py +++ b/zipline/finance/slippage.py @@ -80,6 +80,10 @@ def fill_price_worse_than_limit_price(fill_price, order): class SlippageModel(with_metaclass(ABCMeta)): """Abstract interface for defining a slippage model. """ + + # Asset types that are compatible with the given model. + allowed_asset_types = (Equity, Future) + def __init__(self): self._volume_for_bar = 0 @@ -87,13 +91,6 @@ class SlippageModel(with_metaclass(ABCMeta)): def volume_for_bar(self): return self._volume_for_bar - @abstractproperty - def allowed_asset_types(self): - """ - Return a tuple of asset types that are compatible with the given model. - """ - raise NotImplementedError('allowed_asset_types') - @abstractproperty def process_order(self, data, order): """Process how orders get filled.