API: Don't require custom models to define allowed types

This commit is contained in:
dmichalowicz
2017-04-25 18:42:43 -04:00
parent 0782e402d3
commit ec7cba2e31
2 changed files with 7 additions and 14 deletions
+3 -7
View File
@@ -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):
+4 -7
View File
@@ -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.