Expand description
§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/tickleso the 5-minute CPAPI session never expires.Client::health— one call that returnsError::NotAuthenticatedorError::NoSessioninstead 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
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?;Re-exports§
pub use ws::MarketDataFields;pub use ws::Subscription;pub use ws::WsClient;pub use ws::WsMessage;pub use ws::WsRecv;pub use ws::WsSink;pub use bezant_api as api;
Modules§
- prelude
- Glob-importable prelude for the typical bot use case:
Client,ClientBuilder,Result,Error,SymbolCache,KeepaliveHandle. Optimised foruse bezant::prelude::*;. - ws
- WebSocket streaming client for the IBKR Client Portal Web API.
Structs§
- Auth
Status - Simplified view of the Gateway’s brokerage session status, projected from
the generated
bezant_api::BrokerageSessionStatustype. - Client
- A configured client for the IBKR Client Portal Web API.
- Client
Builder - Builder for
Client. - Keepalive
Handle - Drop-to-stop handle for a background keepalive task.
- Name
Keyed Jar - Thread-safe, name-keyed cookie store.
set_cookiesparses eachSet-Cookievalue and stores(name → value)ignoring everything after the first;(attributes likePath,HttpOnly,Secure). - Status
Code - Re-export of
reqwest::StatusCode— callers usingClient::httpfrequently need it and otherwise have to addreqwestto their ownCargo.tomljust to spell the type. An HTTP status code (status-codein RFC 9110 et al.). - Symbol
Cache - Symbol → conid cache.
- Tickle
Response - Response from a tickle call, projected from the generated type.
- Url
- Re-export of
url::Urlso callers can name the return type ofClient::base_urlwithout addingurlto their ownCargo.toml. A parsed URL record.
Enums§
- Error
- Errors that can arise when talking to the Client Portal Gateway.
Constants§
- DEFAULT_
BASE_ URL - Default base URL of the Client Portal Gateway when run locally via the bundled Docker image.
- MAX_
POSITION_ PAGES - Safety limit on the number of pages
Client::all_positionswill walk. - POSITIONS_
PAGE_ SIZE - Page size the Gateway returns for paginated position calls.
Type Aliases§
- Contract
Summary - Contract-search result, alias over the generated type.
- Position
- Positions returned for an account. Alias over the generated type so callers
can use
bezant::Positionwithout digging intobezant_api. - Result
- Result alias using
Error.