From 1054134bd9e8796861500e4d714980b0e2cf28bf Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Fri, 20 Feb 2015 16:22:06 -0500 Subject: [PATCH] BUG: Fix div by 0 error due to changed return type. When calculate_positions_value used np.dot, the return type was a np.float64. Which allows the use of 0.0 in division to not raise an exception. Fix by expliciting creating an np.float64 with 0 value. --- zipline/finance/performance/period.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zipline/finance/performance/period.py b/zipline/finance/performance/period.py index f027920f..83c0671a 100644 --- a/zipline/finance/performance/period.py +++ b/zipline/finance/performance/period.py @@ -351,7 +351,7 @@ class PerformancePeriod(object): def calculate_positions_value(self): if len(self.position_values) == 0: - return 0 + return np.float64(0) return sum(self.position_values)