1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! # bezant
//!
//! Ergonomic async client for the IBKR Client Portal Web API.
//!
//! Bezant wraps the auto-generated [`bezant-api`] crate with the sugar you
//! actually need to build an automated trading bot:
//!
//! - [`Client`] — a thin wrapper around the Gateway with saner TLS defaults
//! (self-signed certs, timeout, user-agent, session cookies).
//! - [`Client::spawn_keepalive`] — a drop-to-stop background task that
//! tickles `/tickle` so the 5-minute CPAPI session never expires.
//! - [`Client::health`] — one call that returns [`Error::NotAuthenticated`]
//! or [`Error::NoSession`] instead of an opaque HTTP status.
//!
//! For raw access to every one of the ~154 CPAPI endpoints, use the
//! underlying [`bezant-api`] crate directly. The two are fully interoperable
//! — [`Client::api`] hands you the generated client.
//!
//! ## Quickstart
//!
//! ```no_run
//! # async fn run() -> bezant::Result<()> {
//! use std::time::Duration;
//!
//! let client = bezant::Client::new("https://localhost:5000/v1/api")?;
//! let _keepalive = client.spawn_keepalive(Duration::from_secs(60));
//! client.health().await?; // errors early if the user hasn't logged in
//!
//! // drop into the generated client for real work:
//! let _ = client
//! .api()
//! .get_all_accounts(bezant::api::GetAllAccountsRequest::default())
//! .await?;
//! # Ok(())
//! # }
//! ```
//!
//! [`bezant-api`]: https://docs.rs/bezant-api
pub use ;
pub use ;
pub use ;
pub use ;
pub use NameKeyedJar;
pub use ;
/// Re-export of the auto-generated API crate for callers that want raw access.
pub use bezant_api as api;
/// Re-export of [`url::Url`] so callers can name the return type of
/// [`Client::base_url`] without adding `url` to their own `Cargo.toml`.
pub use Url;
/// Re-export of [`reqwest::StatusCode`] — callers using
/// [`Client::http`] frequently need it and otherwise have to add
/// `reqwest` to their own `Cargo.toml` just to spell the type.
pub use StatusCode;
/// Glob-importable prelude for the typical bot use case:
/// `Client`, `ClientBuilder`, `Result`, `Error`, `SymbolCache`,
/// `KeepaliveHandle`. Optimised for `use bezant::prelude::*;`.
///
/// ```no_run
/// use bezant::prelude::*;
///
/// # async fn run() -> Result<()> {
/// let client = Client::new("https://localhost:5000/v1/api")?;
/// let cache = SymbolCache::new(client);
/// let aapl = cache.conid_for("AAPL").await?;
/// println!("AAPL = {aapl}");
/// # Ok(())
/// # }
/// ```