Hide navigation sidebar
Hide table of contents sidebar
Toggle table of contents sidebar

# self.get_position

lumibot.strategies.strategy.Strategy.get_position(self, asset)

  Get a tracked position given an asset for the current strategy.

  Seeks out and returns the position object for the given asset in the current strategy.

  Parameters

    asset (Asset) – Asset object who’s traded positions is sought.

  Returns

    A position object for the assset if there is a tracked position or returns None to indicate no tracked position.

  Return type

    Position or None

  Example

      >>> # Get the position for the TLT asset
      >>> position = self.get_position("TLT")
      >>> # Show the quantity of the TLT position
      >>> self.log_message(position.quantity)