From 65138fbcebace69dab92bc53910564a9521b529b Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Wed, 16 Jan 2013 11:38:37 -0500 Subject: [PATCH] Uses numpy.dot instead numpy.vdot to calculate positions value. Since the position amount and price ndarrays are one dimensional and use real numbers, we do not need the overhead of the extra case handling provided by numpy.vdot, which comes at a cost of performance. With thanks to @jlowin, for pointing out the better fit of numpy.dot. --- zipline/finance/performance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zipline/finance/performance.py b/zipline/finance/performance.py index ed1e2822..63949e7c 100644 --- a/zipline/finance/performance.py +++ b/zipline/finance/performance.py @@ -508,7 +508,7 @@ class PerformancePeriod(object): return int(base * round(float(x) / base)) def calculate_positions_value(self): - return np.vdot(self._position_amounts, self._position_last_sale_prices) + return np.dot(self._position_amounts, self._position_last_sale_prices) def update_last_sale(self, event): is_trade = event.type == zp.DATASOURCE_TYPE.TRADE