mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-13 12:51:33 +08:00
BUG: don't fail if you cannot make a webrequest
This commit is contained in:
committed by
Richard Frank
parent
69cc5e6564
commit
5eb453675d
+16
-5
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2013 Quantopian, Inc.
|
||||
# Copyright 2016 Quantopian, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ from pandas.io.data import DataReader
|
||||
import pytz
|
||||
|
||||
from six import iteritems
|
||||
from six.moves.urllib_error import HTTPError
|
||||
|
||||
from . benchmarks import get_benchmark_returns
|
||||
from . import treasuries, treasuries_can
|
||||
@@ -239,8 +240,15 @@ def ensure_benchmark_data(symbol, first_date, last_date, now, trading_day):
|
||||
path=path,
|
||||
)
|
||||
|
||||
data = get_benchmark_returns(symbol, first_date - trading_day, last_date)
|
||||
data.to_csv(path)
|
||||
try:
|
||||
data = get_benchmark_returns(
|
||||
symbol,
|
||||
first_date - trading_day,
|
||||
last_date,
|
||||
)
|
||||
data.to_csv(path)
|
||||
except (OSError, IOError, HTTPError):
|
||||
logger.exception('failed to cache the new benchmark returns')
|
||||
if not has_data_for_dates(data, first_date, last_date):
|
||||
logger.warn("Still don't have expected data after redownload!")
|
||||
return data
|
||||
@@ -306,8 +314,11 @@ def ensure_treasury_data(bm_symbol, first_date, last_date, now):
|
||||
)
|
||||
)
|
||||
|
||||
data = loader_module.get_treasury_data(first_date, last_date)
|
||||
data.to_csv(path)
|
||||
try:
|
||||
data = loader_module.get_treasury_data(first_date, last_date)
|
||||
data.to_csv(path)
|
||||
except (OSError, IOError, HTTPError):
|
||||
logger.exception('failed to cache treasury data')
|
||||
if not has_data_for_dates(data, first_date, last_date):
|
||||
logger.warn("Still don't have expected data after redownload!")
|
||||
return data
|
||||
|
||||
Reference in New Issue
Block a user