diff --git a/tests/test_finance.py b/tests/test_finance.py index fe4f2a4a..c3605fe7 100644 --- a/tests/test_finance.py +++ b/tests/test_finance.py @@ -151,7 +151,7 @@ class FinanceTestCase(TestCase): # tell the simulator to fill the orders in individual transactions # matching the order volume exactly. self.zipline_test_config['simulation_style'] = \ - SIMULATION_STYLE.FIXED_SLIPPAGE + SIMULATION_STYLE.FIXED_SLIPPAGE self.zipline_test_config['environment'] = factory.create_trading_environment() sid_list = [self.zipline_test_config['sid']] diff --git a/tests/test_ndict.py b/tests/test_ndict.py index 071f01b2..63f1f4df 100644 --- a/tests/test_ndict.py +++ b/tests/test_ndict.py @@ -32,6 +32,7 @@ def test_ndict(): assert '__iter__' not in nd assert not nd.__dict__.has_key('x') assert nd.get('__init__') is None + assert 'x' not in set(dir(nd)) # Comparison nd2 = nd.copy() diff --git a/zipline/finance/performance.py b/zipline/finance/performance.py index bab37e7c..6bf70058 100644 --- a/zipline/finance/performance.py +++ b/zipline/finance/performance.py @@ -550,7 +550,7 @@ class PerformancePeriod(): for sid, pos in self.positions.iteritems(): cur = pos.to_dict() if ndicted: - positions[sid] = zp.ndicted(cur) + positions[sid] = zp.ndict(cur) else: positions[sid] = cur diff --git a/zipline/utils/factory.py b/zipline/utils/factory.py index b26f8a6b..a8f1e4d7 100644 --- a/zipline/utils/factory.py +++ b/zipline/utils/factory.py @@ -206,9 +206,11 @@ def create_minutely_trade_source(sids, trade_count, trading_environment): def create_trade_source(sids, trade_count, trade_time_increment, trading_environment): trade_history = [] + + price = [10.1] * trade_count + volume = [100] * trade_count + for sid in sids: - price = [10.1] * trade_count - volume = [100] * trade_count start_date = trading_environment.first_open generated_trades = create_trade_history( diff --git a/zipline/utils/protocol_utils.py b/zipline/utils/protocol_utils.py index 7f79dd4f..86ea1d2f 100644 --- a/zipline/utils/protocol_utils.py +++ b/zipline/utils/protocol_utils.py @@ -50,6 +50,13 @@ class ndict(MutableMapping): # Abstact Overloads # ----------------- + def __setattr__(self, key, value): + if 'ndict' in key or key == 'cls': + MutableMapping.__setattr__(self, key, value) + else: + self.__internal[key] = value + return value + def __setitem__(self, key, value): """ Required for use by pymongo as_class parameter to find. @@ -59,7 +66,6 @@ class ndict(MutableMapping): else: self.__internal[key] = value - def __getattr__(self, key): if key in self.cls: return self.__dict__[key]