mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-07 13:35:43 +08:00
BUG: Fixed bug with returning non-primitive dicts.
This commit is contained in:
@@ -48,7 +48,7 @@ p20
|
||||
I6
|
||||
sS'id'
|
||||
p21
|
||||
S'66ba5ccdddf84fb886427412c5803fd7'
|
||||
S'd34900be98354821b96936b1b6a5cac3'
|
||||
p22
|
||||
sS'filled'
|
||||
p23
|
||||
|
||||
+10
-24
@@ -171,38 +171,24 @@ F0.0
|
||||
sg55
|
||||
F0.0
|
||||
sg33
|
||||
g4
|
||||
(czipline.protocol
|
||||
Positions
|
||||
p70
|
||||
c__builtin__
|
||||
dict
|
||||
p71
|
||||
(dp72
|
||||
tp73
|
||||
Rp74
|
||||
(dp70
|
||||
sS'positions_value'
|
||||
p75
|
||||
p71
|
||||
F0.0
|
||||
sS'start_date'
|
||||
p76
|
||||
p72
|
||||
NsbsS'starting_value'
|
||||
p77
|
||||
p73
|
||||
F0.0
|
||||
sS'period_open'
|
||||
p78
|
||||
p74
|
||||
NsS'period_close'
|
||||
p79
|
||||
p75
|
||||
NsS'orders_by_id'
|
||||
p80
|
||||
ccyordereddict._cyordereddict
|
||||
OrderedDict
|
||||
p81
|
||||
((lp82
|
||||
tp83
|
||||
Rp84
|
||||
p76
|
||||
(dp77
|
||||
ssS'initargs'
|
||||
p85
|
||||
p78
|
||||
NsS'newargs'
|
||||
p86
|
||||
p79
|
||||
Ns.
|
||||
+669
-699
File diff suppressed because one or more lines are too long
@@ -25,25 +25,14 @@ p9
|
||||
F0.0
|
||||
sS'positions'
|
||||
p10
|
||||
ccopy_reg
|
||||
_reconstructor
|
||||
p11
|
||||
(czipline.protocol
|
||||
Positions
|
||||
p12
|
||||
c__builtin__
|
||||
dict
|
||||
p13
|
||||
(dp14
|
||||
tp15
|
||||
Rp16
|
||||
(dp11
|
||||
sS'positions_value'
|
||||
p17
|
||||
p12
|
||||
F0.0
|
||||
sS'start_date'
|
||||
p18
|
||||
p13
|
||||
NssS'initargs'
|
||||
p19
|
||||
p14
|
||||
NsS'newargs'
|
||||
p20
|
||||
p15
|
||||
Ns.
|
||||
@@ -592,6 +592,8 @@ class PerformancePeriod(object):
|
||||
# nastiness.
|
||||
state_dict['processed_transactions'] = \
|
||||
dict(self.processed_transactions)
|
||||
state_dict['orders_by_id'] = \
|
||||
dict(self.orders_by_id)
|
||||
state_dict['orders_by_modified'] = \
|
||||
dict(self.orders_by_modified)
|
||||
state_dict['positions'] = \
|
||||
@@ -615,6 +617,9 @@ class PerformancePeriod(object):
|
||||
processed_transactions = defaultdict(list)
|
||||
processed_transactions.update(state.pop('processed_transactions'))
|
||||
|
||||
orders_by_id = OrderedDict()
|
||||
orders_by_id.update(state.pop('orders_by_id'))
|
||||
|
||||
orders_by_modified = defaultdict(OrderedDict)
|
||||
orders_by_modified.update(state.pop('orders_by_modified'))
|
||||
|
||||
@@ -625,6 +630,7 @@ class PerformancePeriod(object):
|
||||
_positions_store.update(state.pop('_positions_store'))
|
||||
|
||||
self.processed_transactions = processed_transactions
|
||||
self.orders_by_id = orders_by_id
|
||||
self.orders_by_modified = orders_by_modified
|
||||
self.positions = positions
|
||||
self._positions_store = _positions_store
|
||||
|
||||
@@ -147,6 +147,9 @@ class Portfolio(object):
|
||||
|
||||
state_dict = copy(self.__dict__)
|
||||
|
||||
# Have to convert to primitive dict
|
||||
state_dict['positions'] = dict(self.positions)
|
||||
|
||||
STATE_VERSION = 1
|
||||
state_dict[VERSION_LABEL] = STATE_VERSION
|
||||
|
||||
@@ -160,6 +163,9 @@ class Portfolio(object):
|
||||
if version < OLDEST_SUPPORTED_STATE:
|
||||
raise BaseException("Portfolio saved state is too old.")
|
||||
|
||||
self.positions = Positions()
|
||||
self.positions.update(state.pop('positions'))
|
||||
|
||||
self.__dict__.update(state)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user