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:
Delaney Granizo-Mackenzie
2015-03-03 12:56:35 -05:00
parent b2ee0e179e
commit 0fd1efff5f
4 changed files with 13 additions and 11 deletions
+2 -4
View File
@@ -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)
+3 -1
View File
@@ -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
+3 -3
View File
@@ -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
View File
@@ -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