use std::time::Duration;
use ibapi::client::blocking::Client;
use ibapi::contracts::Contract;
fn main() {
env_logger::init();
let connection_string = "127.0.0.1:4002";
println!("connecting to server @ {connection_string}");
let client = Client::connect(connection_string, 100).expect("connection failed");
let contract = Contract::stock("NVDA").build();
let ticks = client.tick_by_tick_last(&contract, 0, false).expect("failed to get ticks");
println!(
"streaming last price for security_type: {:?}, symbol: {}",
contract.security_type, contract.symbol
);
for (i, trade) in ticks.timeout_iter(Duration::from_secs(10)).enumerate() {
println!("{}: {i:?} {trade:?}", contract.symbol);
}
if let Some(error) = ticks.error() {
println!("error: {error:?}");
}
}