Fix ndict woes.

This commit is contained in:
Stephen Diehl
2012-05-14 13:49:45 -04:00
parent d0d48ab7df
commit d399edd419
5 changed files with 14 additions and 5 deletions
+1 -1
View File
@@ -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']]
+1
View File
@@ -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()
+1 -1
View File
@@ -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
+4 -2
View File
@@ -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(
+7 -1
View File
@@ -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]