BUG: in relation to issue #77, catching the remaining warnings

This commit is contained in:
fredfortier
2017-11-21 20:42:44 -05:00
parent c1d140a831
commit 3ec9853b75
3 changed files with 18 additions and 9 deletions
+5 -5
View File
@@ -41,11 +41,11 @@ class AssetFinderExchange(object):
SidsNotFound
When a requested sid is not found and default_none=False.
"""
for sid in sids:
if sid in self._asset_cache:
log.debug('got asset from cache: {}'.format(sid))
else:
log.debug('fetching asset: {}'.format(sid))
# for sid in sids:
# if sid in self._asset_cache:
# log.debug('got asset from cache: {}'.format(sid))
# else:
# log.debug('fetching asset: {}'.format(sid))
return list()
def lookup_symbol(self, symbol, exchange, as_of_date=None, fuzzy=False):
+2 -2
View File
@@ -196,8 +196,8 @@ class RiskMetricsCumulative(object):
self.benchmark_cumulative_returns[dt_loc] = cum_returns(
self.benchmark_returns
)[-1]
except Exception as e:
log.debug('cumulative returns error: {}'.format(e))
except Exception:
self.benchmark_cumulative_returns[dt_loc] = 0
benchmark_cumulative_returns_to_date = \
self.benchmark_cumulative_returns[:dt_loc + 1]
+11 -2
View File
@@ -14,6 +14,7 @@
# limitations under the License.
import functools
import warnings
import logbook
@@ -78,8 +79,14 @@ class RiskMetricsPeriod(object):
self.calculate_metrics()
def calculate_metrics(self):
self.benchmark_period_returns = \
cum_returns(self.benchmark_returns).iloc[-1]
warnings.filterwarnings('error')
try:
self.benchmark_period_returns = \
cum_returns(self.benchmark_returns).iloc[-1]
except Exception:
# TODO: why is there an error
self.benchmark_period_returns = 0
self.algorithm_period_returns = \
cum_returns(self.algorithm_returns).iloc[-1]
@@ -152,6 +159,8 @@ class RiskMetricsPeriod(object):
self.max_drawdown = max_drawdown(self.algorithm_returns.values)
self.max_leverage = self.calculate_max_leverage()
warnings.resetwarnings()
def to_dict(self):
"""
Creates a dictionary representing the state of the risk report.