From aa872afdf4bde19aff288aba84d92e0d1d5350cf Mon Sep 17 00:00:00 2001 From: warren-oneill Date: Mon, 23 Mar 2015 12:19:10 +0100 Subject: [PATCH] adding updates from master --- zipline/data/loader.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/zipline/data/loader.py b/zipline/data/loader.py index 009a73d0..7ff6b5ae 100644 --- a/zipline/data/loader.py +++ b/zipline/data/loader.py @@ -176,21 +176,18 @@ Fetching data from Yahoo Finance. # If more than 1 trading days has elapsed since the last day where # we have data,then we need to update - if len(days_up_to_now) - last_bm_date_offset > 1: + # We're doing "> 2" rather than "> 1" because we're subtracting an array + # _length_ from an array _index_, and therefore even if we had data up to + # and including the current day, the difference would still be 1. + if len(days_up_to_now) - last_bm_date_offset > 2: benchmark_returns = update_benchmarks(bm_symbol, last_bm_date) - if ( - benchmark_returns.index.tz is None - or - benchmark_returns.index.tz.zone != 'UTC' - ): + if benchmark_returns.index.tz is None or \ + benchmark_returns.index.tz.zone != 'UTC': benchmark_returns = benchmark_returns.tz_localize('UTC') else: benchmark_returns = saved_benchmarks - if ( - benchmark_returns.index.tz is None - or - benchmark_returns.index.tz.zone != 'UTC' - ): + if benchmark_returns.index.tz is None or\ + benchmark_returns.index.tz.zone != 'UTC': benchmark_returns = benchmark_returns.tz_localize('UTC') # Get treasury curve module, filename & source from mapping. @@ -217,7 +214,8 @@ Fetching data from {0} # If more than 1 trading days has elapsed since the last day where # we have data,then we need to update - if len(days_up_to_now) - last_tr_date_offset > 1: + # Comment above explains why this is "> 2". + if len(days_up_to_now) - last_tr_date_offset > 2: treasury_curves = dump_treasury_curves(module, filename) else: treasury_curves = saved_curves.tz_localize('UTC')