ibapi 5.0.0

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

use ibapi::client::blocking::Client;
use ibapi::contracts::SecurityType;

// This example demonstrates requesting option chain data from the TWS.

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

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

    // One OptionChain per exchange listing AAPL options. The contract id is the
    // underlying's and is required; `.exchange(..)` exists for futures options only.
    let subscription = client
        .option_chain("AAPL", SecurityType::Stock, 265598)
        .subscribe()
        .expect("request option chain failed!");

    for option_chain in &subscription {
        println!("{option_chain:?}")
    }
}