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 authored and Thomas Wiecki committed 2013-08-08 12:20:04 -04:00
1 parent 9694dfbbfe
commit eae5803910
1 file changed
+2 -1
+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