mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-06 05:14:38 +08:00
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:
committed by
Eddie Hebert
parent
64b2a7377c
commit
25659f9672
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user