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:
Ben McCann
2013-07-16 19:23:59 -07:00
committed by Thomas Wiecki
parent 9694dfbbfe
commit eae5803910
+2 -1
View File
@@ -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