From 25659f96728fce2fcd3d321c7c62604608b32474 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin Date: Sun, 23 Mar 2014 15:51:06 -0400 Subject: [PATCH] MAINT: Use current_data instead of last_sale_price It seems more clear to get price values from `self.trading_client.current_data[sid].price` than from `self.portfolio.positions[sid].last_sale_price`. The two values are the same, so this is just a readability change, but it is also the same behavior as in `self.order_value()` and it's good to have them all be the same. --- zipline/algorithm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zipline/algorithm.py b/zipline/algorithm.py index 56cde705..1a419b44 100644 --- a/zipline/algorithm.py +++ b/zipline/algorithm.py @@ -593,7 +593,7 @@ class TradingAlgorithm(object): """ if sid in self.portfolio.positions: current_position = self.portfolio.positions[sid].amount - current_price = self.portfolio.positions[sid].last_sale_price + current_price = self.trading_client.current_data[sid].price current_value = current_position * current_price req_value = target - current_value return self.order_value(sid, req_value, limit_price, stop_price) @@ -614,7 +614,7 @@ class TradingAlgorithm(object): """ if sid in self.portfolio.positions: current_position = self.portfolio.positions[sid].amount - current_price = self.portfolio.positions[sid].last_sale_price + current_price = self.trading_client.current_data[sid].price current_value = current_position * current_price else: current_value = 0