From d6e997e96c6c4a00cbc9dde889fa974114012798 Mon Sep 17 00:00:00 2001 From: Joe Jevnik Date: Tue, 7 Oct 2014 12:30:28 -0400 Subject: [PATCH] BUG: Stops the TradingEnvironment from being created at import time when zipline.utils.events is imported. Changes the class level attribute `env` on EventRule to a property so that the environment is only looked up at when needed. --- zipline/utils/events.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zipline/utils/events.py b/zipline/utils/events.py index 562301f0..0247e4b8 100644 --- a/zipline/utils/events.py +++ b/zipline/utils/events.py @@ -175,7 +175,9 @@ class EventRule(six.with_metaclass(ABCMeta)): """ An event rule checks a datetime and sees if it should trigger. """ - env = TradingEnvironment.instance() + @property + def env(self): + return TradingEnvironment.instance() @abstractmethod def should_trigger(self, dt):