mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-04 09:34:49 +08:00
BUG: Updated some bugs in serialization.
The state dictionaries weren't being copied, so the state version label was being injected into the original object.
This commit is contained in:
@@ -251,10 +251,6 @@ class Blotter(SerializeableZiplineObject):
|
||||
|
||||
yield txn, order
|
||||
|
||||
def __getinitargs__(self):
|
||||
# Ensure that init is called on deserialization
|
||||
return ()
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
state_to_save = ['new_orders', 'orders', '_status']
|
||||
@@ -272,6 +268,8 @@ class Blotter(SerializeableZiplineObject):
|
||||
|
||||
def __setstate__(self, state):
|
||||
|
||||
self.__init__()
|
||||
|
||||
OLDEST_SUPPORTED_STATE = 1
|
||||
version = state.pop(VERSION_LABEL)
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ from math import (
|
||||
floor,
|
||||
)
|
||||
|
||||
from copy import copy
|
||||
|
||||
import logbook
|
||||
import zipline.protocol as zp
|
||||
|
||||
@@ -214,7 +216,7 @@ last_sale_price: {last_sale_price}"
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
state_dict = self.__dict__
|
||||
state_dict = copy(self.__dict__)
|
||||
|
||||
STATE_VERSION = 1
|
||||
state_dict[VERSION_LABEL] = STATE_VERSION
|
||||
|
||||
@@ -134,7 +134,7 @@ class Transaction(SerializeableZiplineObject):
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
state_dict = self.__dict__
|
||||
state_dict = copy(self.__dict__)
|
||||
|
||||
STATE_VERSION = 1
|
||||
state_dict[VERSION_LABEL] = STATE_VERSION
|
||||
@@ -271,7 +271,7 @@ class VolumeShareSlippage(SlippageModel, SerializeableZiplineObject):
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
state_dict = self.__dict__
|
||||
state_dict = copy(self.__dict__)
|
||||
|
||||
STATE_VERSION = 1
|
||||
state_dict[VERSION_LABEL] = STATE_VERSION
|
||||
@@ -309,7 +309,7 @@ class FixedSlippage(SlippageModel, SerializeableZiplineObject):
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
state_dict = self.__dict__
|
||||
state_dict = copy(self.__dict__)
|
||||
|
||||
STATE_VERSION = 1
|
||||
state_dict[VERSION_LABEL] = STATE_VERSION
|
||||
|
||||
+5
-3
@@ -13,6 +13,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from copy import copy
|
||||
|
||||
from six import iteritems, iterkeys
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
@@ -144,7 +146,7 @@ class Portfolio(SerializeableZiplineObject):
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
state_dict = self.__dict__
|
||||
state_dict = copy(self.__dict__)
|
||||
|
||||
STATE_VERSION = 1
|
||||
state_dict[VERSION_LABEL] = STATE_VERSION
|
||||
@@ -196,7 +198,7 @@ class Account(SerializeableZiplineObject):
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
state_dict = self.__dict__
|
||||
state_dict = copy(self.__dict__)
|
||||
|
||||
STATE_VERSION = 1
|
||||
state_dict[VERSION_LABEL] = STATE_VERSION
|
||||
@@ -230,7 +232,7 @@ class Position(SerializeableZiplineObject):
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
state_dict = self.__dict__
|
||||
state_dict = copy(self.__dict__)
|
||||
|
||||
STATE_VERSION = 1
|
||||
state_dict[VERSION_LABEL] = STATE_VERSION
|
||||
|
||||
Reference in New Issue
Block a user