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.
This commit is contained in:
Jeremiah Lowin
2014-03-23 15:51:06 -04:00
committed by Eddie Hebert
parent 64b2a7377c
commit 25659f9672
+2 -2
View File
@@ -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