mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-04 01:39:33 +08:00
API: Don't require custom models to define allowed types
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user