#![allow(clippy::uninlined_format_args)]
use ibapi::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
let client = Client::connect("127.0.0.1:4002", 100).await?;
println!("=== Requesting News Article ===");
let provider_code = "BRFG"; let article_id = "BRFG$12345";
println!("Requesting article: {article_id} from provider: {provider_code}");
match client.news_article(provider_code, article_id).await {
Ok(article_body) => {
println!("\n--- Article Content ---");
match article_body.article_type {
ibapi::news::ArticleType::Text => {
println!("Type: Text/HTML");
println!("Content:\n{}", article_body.article_text);
}
ibapi::news::ArticleType::Binary => {
println!("Type: Binary (Base64 encoded)");
println!("Content length: {} bytes", article_body.article_text.len());
}
}
}
Err(e) => {
eprintln!("Error fetching article: {e:?}");
eprintln!("Note: You need a valid article ID from historical_news or contract_news");
}
}
Ok(())
}