mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-05 06:12:09 +08:00
Fix ndict woes.
This commit is contained in:
@@ -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']]
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user