mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-04 03:34:26 +08:00
BUG: Calculate benchmark returns for first day
Before we were setting benchmark returns on the first day to 0. This commit changes this by calculating the benchmark return from open to close. According to @eherbert this is also what the answer key does.
This commit is contained in:
committed by
Thomas Wiecki
parent
9694dfbbfe
commit
eae5803910
@@ -120,7 +120,8 @@ def get_benchmark_returns(symbol, start_date=None, end_date=None):
|
||||
benchmark_returns = []
|
||||
for i, data_point in enumerate(data_points):
|
||||
if i == 0:
|
||||
returns = 0
|
||||
curr_open = data_points[i]['open']
|
||||
returns = (data_points[i]['close'] - curr_open) / curr_open
|
||||
else:
|
||||
prev_close = data_points[i-1]['close']
|
||||
returns = (data_point['close'] - prev_close) / prev_close
|
||||
|
||||
Reference in New Issue
Block a user