mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-12 11:50:11 +08:00
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:
committed by
twiecki
parent
9feed61748
commit
45844bac31
@@ -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'})
|
||||
|
||||
Reference in New Issue
Block a user