self.get_positions¶
- lumibot.strategies.strategy.Strategy.get_positions(self, include_cash_positions: bool = False)¶
Get all positions for the account.
- Parameters:
include_cash_positions (bool) – If True, include cash positions in the returned list. If False, exclude cash positions.
- Returns:
A list of Position objects for the strategy if there are tracked positions or returns and empty list to indicate no tracked position.
- Return type:
list
Example
>>> # Get all tracked positions >>> positions = self.get_positions() >>> for position in positions: >>> # Show the quantity of each position >>> self.log_message(position.quantity) >>> # Show the asset of each position >>> self.log_message(position.asset)