use ibtwsapi::core::errors::*;
use ibtwsapi::examples::example_wrapper::ExampleWrapper;
use log::*;
use std::thread;
use std::time::Duration;
pub fn main() -> Result<(), IBKRApiLibError> {
match log4rs::init_file("./log_config.yml", Default::default()) {
Ok(_) => (),
Err(e) => {
println!("Error: {}", e.to_string());
return Err(IBKRApiLibError::ApiError(TwsApiReportableError::new(
-1,
"-1".to_string(),
"Failed to create logger!!".to_string(),
)));
}
};
let mut app = ExampleWrapper::new();
info!("getting connection...");
app.client.connect("127.0.0.1", 4002, 0)?;
loop {
match app.process_event() {
Ok(_) => continue,
Err(e) => {
error!("{}", e.to_string());
break ();
}
};
}
thread::sleep(Duration::new(2, 0));
Ok(())
}