BUG: adjust benchmark events to match market hours

Previously benchmark events were emitted at 0:00 on the day the
benchmark related to: in 'minute' emission mode this meant that
the benchmarks were emitted before any intra-day trades were
processed.

See: https://github.com/quantopian/zipline/issues/241
This commit is contained in:
Jamie Kirkpatrick
2014-01-30 16:01:58 -05:00
committed by twiecki
parent 9feed61748
commit 45844bac31
2 changed files with 20 additions and 1 deletions
+6 -1
View File
@@ -227,8 +227,13 @@ class TradingAlgorithm(object):
skipped.
"""
if self.benchmark_return_source is None:
env = trading.environment
if self.data_frequency == 'minute':
update_time = lambda date: env.get_open_and_close(date)[1]
else:
update_time = lambda date: date
benchmark_return_source = [
Event({'dt': dt,
Event({'dt': update_time(dt),
'returns': ret,
'type': zipline.protocol.DATASOURCE_TYPE.BENCHMARK,
'source_id': 'benchmarks'})