From eae580391009d8eca1137f01aa8d2a8e30cb9e4e Mon Sep 17 00:00:00 2001 From: Ben McCann Date: Tue, 16 Jul 2013 19:23:59 -0700 Subject: [PATCH] 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. --- zipline/data/benchmarks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zipline/data/benchmarks.py b/zipline/data/benchmarks.py index bca2a54c..86663937 100644 --- a/zipline/data/benchmarks.py +++ b/zipline/data/benchmarks.py @@ -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