MAINT: Use Series throughout for daily returns.

Remove the lists of DailyReturn objects in favor of using pd.Series
to store the return values.

Should make it easier to inspect the values when stepping through,
make the windowing of data to a certain range more facile by using,
and have some performance increases due to removing object creation
and member access.
This commit is contained in:
Eddie Hebert
2013-10-19 23:06:18 -04:00
parent 76887e2855
commit 37c56b9aa4
13 changed files with 44 additions and 98 deletions
+5 -5
View File
@@ -174,13 +174,13 @@ class TradingAlgorithm(object):
"""
if self.benchmark_return_source is None:
benchmark_return_source = [
Event({'dt': ret.date,
'returns': ret.returns,
Event({'dt': dt,
'returns': ret,
'type': zipline.protocol.DATASOURCE_TYPE.BENCHMARK,
'source_id': 'benchmarks'})
for ret in trading.environment.benchmark_returns
if ret.date.date() >= sim_params.period_start.date()
and ret.date.date() <= sim_params.period_end.date()
for dt, ret in trading.environment.benchmark_returns.iterkv()
if dt.date() >= sim_params.period_start.date()
and dt.date() <= sim_params.period_end.date()
]
else:
benchmark_return_source = self.benchmark_return_source