BUG: Only localize benchmark index if it is naive.

Check for whether or not the index's timezone is UTC or not before
attempting to localize, since an already localized index throws an
error when tz_localize is called.
This commit is contained in:
Eddie Hebert
2013-10-29 13:17:58 -04:00
parent 0a7539b6de
commit c45c1a22e1
+4 -2
View File
@@ -162,10 +162,12 @@ Fetching data from Yahoo Finance.
# we have data,then we need to update
if len(trading_days) - last_bm_date_offset > 1:
benchmark_returns = update_benchmarks(bm_symbol, last_bm_date)
benchmark_returns = benchmark_returns.tz_localize('UTC')
if benchmark_returns.index.tz.zone != 'UTC':
benchmark_returns = benchmark_returns.tz_localize('UTC')
else:
benchmark_returns = saved_benchmarks
benchmark_returns = benchmark_returns.tz_localize('UTC')
if benchmark_returns.index.tz.zone != 'UTC':
benchmark_returns = benchmark_returns.tz_localize('UTC')
try:
fp_tr = get_datafile('treasury_curves.csv', "rb")