#![cfg_attr(
feature = "async",
doc = r#"```no_run
use ibapi::prelude::*;
#[tokio::main]
async fn main() {
let client = Client::connect("127.0.0.1:4002", 100)
.await
.expect("connection failed");
let contract = Contract::stock("AAPL").build();
let order_id = client
.order(&contract)
.buy(100)
.market()
.submit()
.await
.expect("order submission failed");
println!("submitted order id: {order_id}");
}
```"#
)]
#![cfg_attr(
not(feature = "async"),
doc = r#"```no_run
use ibapi::prelude::*;
fn main() {
let client = Client::connect("127.0.0.1:4002", 100).expect("connection failed");
let contract = Contract::stock("AAPL").build();
let order_id = client
.order(&contract)
.buy(100)
.market()
.submit()
.expect("order submission failed");
println!("submitted order id: {order_id}");
}
```"#
)]
#![warn(missing_docs)]
#![allow(clippy::octal_escapes)]
#![allow(clippy::bool_assert_comparison)]
#![allow(clippy::useless_format)]
#![allow(clippy::uninlined_format_args)]
#![allow(clippy::assertions_on_constants)]
#[cfg(not(any(feature = "sync", feature = "async")))]
compile_error!(
"You must enable at least one of the 'sync' or 'async' features to use this crate.\n\
The 'async' feature is enabled by default; if you disabled default features, be sure to\n\
opt back into either API:\n\
ibapi = { version = \"4.0\", default-features = false, features = [\"sync\"] }\n\
ibapi = { version = \"4.0\", default-features = false, features = [\"async\"] }\n\
You may also enable both to access the synchronous API under `client::blocking`."
);
#[cfg(all(feature = "utoipa", not(feature = "utoipa-6")))]
compile_error!("the `utoipa` feature is internal; enable a `utoipa-<major>` feature such as `utoipa-6`");
#[cfg(feature = "utoipa-6")]
extern crate utoipa6 as utoipa;
#[macro_use]
mod macros;
pub mod accounts;
pub mod client;
pub(crate) mod transport;
pub(crate) mod connection;
#[cfg_attr(
feature = "async",
doc = r#"```no_run
use ibapi::{Client, StartupMessage};
use std::sync::{Arc, Mutex};
#[tokio::main]
async fn main() {
let order_ids = Arc::new(Mutex::new(Vec::new()));
let order_ids_clone = order_ids.clone();
let client = Client::builder()
.address("127.0.0.1:4002")
.client_id(100)
.startup_callback(move |msg| if let StartupMessage::OpenOrder(o) = msg {
order_ids_clone.lock().unwrap().push(o.order_id);
})
.connect()
.await
.expect("connection failed");
println!("Received {} startup open-orders", order_ids.lock().unwrap().len());
drop(client);
}
```"#
)]
#[cfg_attr(
not(feature = "async"),
doc = r#"```no_run
use ibapi::{Client, StartupMessage};
use std::sync::{Arc, Mutex};
fn main() {
let order_ids = Arc::new(Mutex::new(Vec::new()));
let order_ids_clone = order_ids.clone();
let client = Client::builder()
.address("127.0.0.1:4002")
.client_id(100)
.startup_callback(move |msg| if let StartupMessage::OpenOrder(o) = msg {
order_ids_clone.lock().unwrap().push(o.order_id);
})
.connect()
.expect("connection failed");
println!("Received {} startup open-orders", order_ids.lock().unwrap().len());
drop(client);
}
```"#
)]
pub use connection::StartupMessage;
pub(crate) mod common;
pub use common::timezone::register_timezone_alias;
pub mod display_groups;
pub mod subscriptions;
pub mod config;
pub mod contracts;
pub mod errors;
pub mod market_data;
pub(crate) mod messages;
pub mod news;
pub mod orders;
pub mod scanner;
pub mod wsh;
pub mod prelude;
pub mod protocol;
pub(crate) mod proto;
mod server_versions;
#[doc(inline)]
pub use errors::Error;
#[doc(inline)]
pub use client::Client;
#[doc(inline)]
pub use client::ClientBuilder;
#[doc(inline)]
pub use transport::rate_limiter::RateLimiter;
pub(crate) use messages::{encode_option_field, ToField};
#[doc(inline)]
pub use messages::{ConnectivityStatus, IncomingMessages, Notice, NoticeCategory, OutgoingMessages};
#[doc(inline)]
pub use messages::{
DATA_ADVISORY_CODES, HANDSHAKE_DECODE_FAILURE_CODE, HANDSHAKE_UNKNOWN_FRAME_CODE, NOTICE_STREAM_LAG_CODE, ORDER_CANCELLED_CODE,
ORDER_MESSAGE_CODE, ORDER_REJECTION_CODE_RANGE, REQUEST_ERROR_CODES, SUBSCRIPTION_LAG_CODE, SYSTEM_MESSAGE_CODES, TRANSPORT_RECONNECT_CODE,
UNKNOWN_MESSAGE_TYPE_CODE, WARNING_CODE_RANGE,
};
#[cfg(test)]
pub(crate) mod stubs;
#[cfg(test)]
pub(crate) mod tests;
#[cfg(test)]
#[path = "lib_tests.rs"]
mod lib_tests;
#[cfg(test)]
pub(crate) mod testdata;