Skip to main content

subscribe_positions

Function subscribe_positions 

Source
pub async fn subscribe_positions(
    client: &Arc<Client>,
    account_id: AccountId,
    position_tracker: PositionTracker,
    instrument_provider: Arc<InteractiveBrokersInstrumentProvider>,
) -> Result<()>
Expand description

Subscribe to real-time position updates for detecting external position changes (e.g., option exercises).

This spawns a background task to track position changes and generate position status reports for external changes.

§Arguments

  • client - The IB API client
  • account_id - The account ID
  • position_tracker - Shared position tracker for detecting external changes
  • instrument_provider - Instrument provider for resolving contracts to instruments

§Errors

Returns an error if subscription fails.