mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-30 03:11:14 +08:00
Merge pull request #1689 from quantopian/slippage_needs_asdict
Rename _attrs_to_check to asdict
This commit is contained in:
@@ -95,6 +95,9 @@ class SlippageTestCase(WithCreateBarData,
|
||||
self.assertEqual(vol1, vol2)
|
||||
self.assertEqual(hash(vol1), hash(vol2))
|
||||
|
||||
self.assertEqual(vol1.__dict__, vol1.asdict())
|
||||
self.assertEqual(vol2.__dict__, vol2.asdict())
|
||||
|
||||
def test_fill_price_worse_than_limit_price(self):
|
||||
non_limit_order = TestOrder(limit=None, direction=1)
|
||||
limit_buy = TestOrder(limit=1.5, direction=1)
|
||||
|
||||
@@ -153,15 +153,15 @@ class SlippageModel(with_metaclass(abc.ABCMeta)):
|
||||
return self.simulate(bar_data, asset, current_orders)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self._attrs_to_check() == other._attrs_to_check()
|
||||
return self.asdict() == other.asdict()
|
||||
|
||||
def __hash__(self):
|
||||
return hash((
|
||||
type(self),
|
||||
tuple(sorted(iteritems(self._attrs_to_check())))
|
||||
tuple(sorted(iteritems(self.asdict())))
|
||||
))
|
||||
|
||||
def _attrs_to_check(self):
|
||||
def asdict(self):
|
||||
return self.__dict__
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user