#![allow(clippy::uninlined_format_args)]
use ibapi::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
let client = Client::connect("127.0.0.1:4002", 105).await?;
println!("Connected to IB Gateway");
let contract = Contract::stock("AAPL").build();
for i in 1..=3 {
println!("Making call {i:?}");
match client
.head_timestamp(&contract, HistoricalWhatToShow::Trades, TradingHours::Regular)
.await
{
Ok(timestamp) => {
println!("Call {i} - Success: {timestamp}");
}
Err(e) => {
println!("Call {i} - Error: {e}");
}
}
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
}
println!("All calls completed!");
Ok(())
}