ibapi 5.2.0

An unofficial Rust client for the Interactive Brokers TWS API. Async (Tokio) and blocking clients for TWS and IB Gateway.
Documentation
//! Sync Account Updates example
//!
//! # Usage
//!
//! ```bash
//! cargo run --no-default-features --features sync --example account_updates
//! ```

use ibapi::accounts::{types::AccountId, AccountUpdate};
use ibapi::client::blocking::Client;

fn main() {
    env_logger::init();

    let client = Client::connect("127.0.0.1:4002", 100).expect("connection failed");

    let account = AccountId("DU1234567".to_string());

    let subscription = client.account_updates(&account).expect("error requesting account updates");
    for update in subscription.iter_data() {
        let update = match update {
            Ok(update) => update,
            Err(e) => {
                eprintln!("error: {e}");
                break;
            }
        };
        println!("{update:?}");

        // stop after full initial update
        if let AccountUpdate::End = update {
            subscription.cancel();
        }
    }
}