MAINT: Removes the ability to reference a global TradingEnvironment

This commit removes the ability to reference a shared TradingEnvironment through the zipline.finance.trading module. In place, the classes that require a TradingEnvironment, or its child AssetFinder, contain their own references to those objects.

This commit also adds serialization utilities that allow for the pickling/unpickling of objects without unintentionally their TradingEnvironments or AssetFinders.
This commit is contained in:
jfkirk
2015-09-10 11:53:28 -04:00
parent 661314ce49
commit dc964a7e7d
45 changed files with 1484 additions and 1173 deletions
+7 -4
View File
@@ -13,14 +13,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import pickle
from zipline.utils.serialization_utils import (
load_with_persistent_ids, dump_with_persistent_ids
)
from nose_parameterized import parameterized
from unittest import TestCase
from .serialization_cases import (
object_serialization_cases,
assert_dict_equal
assert_dict_equal,
cases_env,
)
@@ -37,9 +40,9 @@ class PickleSerializationTestCase(TestCase):
obj = cls(*initargs)
for k, v in di_vars.items():
setattr(obj, k, v)
state = pickle.dumps(obj)
state = dump_with_persistent_ids(obj)
obj2 = pickle.loads(state)
obj2 = load_with_persistent_ids(state, env=cases_env)
for k, v in di_vars.items():
setattr(obj2, k, v)