mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-21 12:30:16 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user