Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
Wil Boayue committed Nov 8, 2024
1 parent c453d0b commit 45f543a
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1570,40 +1570,38 @@ impl Debug for Client {
}

/// Subscriptions facilitate handling responses from TWS that may be delayed or delivered periodically.
///
///
/// They offer both blocking and non-blocking methods for retrieving data.
///
///
/// In the simplest case a subscription can be implicitly converted to blocking iterator
/// that cancels the subscription when it goes out of scope.
///
/// ```no_run
/// use ibapi::contracts::Contract;
/// use ibapi::market_data::realtime::{BarSize, WhatToShow};
/// use ibapi::Client;
///
/// fn main() {
/// let connection_url = "127.0.0.1:4002";
/// let client = Client::connect(connection_url, 100).expect("connection to TWS failed!");
///
/// // Request real-time bars data for AAPL with 5-second intervals
/// let contract = Contract::stock("AAPL");
/// let subscription = client
/// .realtime_bars(&contract, BarSize::Sec5, WhatToShow::Trades, false)
/// .expect("realtime bars request failed!");
///
/// // Use the subscription as a blocking iterator
/// for bar in subscription {
/// // Process each bar here (e.g., print or use in calculations)
/// println!("Received bar: {bar:?}");
/// }
/// // The subscription is automatically cancelled when it goes out of scope
///
/// let connection_url = "127.0.0.1:4002";
/// let client = Client::connect(connection_url, 100).expect("connection to TWS failed!");
///
/// // Request real-time bars data for AAPL with 5-second intervals
/// let contract = Contract::stock("AAPL");
/// let subscription = client
/// .realtime_bars(&contract, BarSize::Sec5, WhatToShow::Trades, false)
/// .expect("realtime bars request failed!");
///
/// // Use the subscription as a blocking iterator
/// for bar in subscription {
/// // Process each bar here (e.g., print or use in calculations)
/// println!("Received bar: {bar:?}");
/// }
/// // The subscription is automatically cancelled when it goes out of scope
/// ```
///
///
/// Subscriptions can be explicitly canceled using the [cancel](Subscription::cancel) method.
///
///
/// You can convert subscriptions into blocking or non-blocking iterators using the [iter](Subscription::iter), [try_iter](Subscription::try_iter) or [timeout_iter](Subscription::timeout_iter) methods.
///
///
/// Alternatively, you may poll subscriptions in a blocking or non-blocking manner using the [next](Subscription::next), [try_next](Subscription::try_next) or [next_timeout](Subscription::next_timeout) methods.
#[allow(private_bounds)]
#[derive(Debug)]
Expand Down

0 comments on commit 45f543a

Please sign in to comment.