Skip to main content

Crate bezant

Crate bezant 

Source
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:

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 for use bezant::prelude::*;.
ws
WebSocket streaming client for the IBKR Client Portal Web API.

Structs§

AuthStatus
Simplified view of the Gateway’s brokerage session status, projected from the generated bezant_api::BrokerageSessionStatus type.
Client
A configured client for the IBKR Client Portal Web API.
ClientBuilder
Builder for Client.
KeepaliveHandle
Drop-to-stop handle for a background keepalive task.
NameKeyedJar
Thread-safe, name-keyed cookie store. set_cookies parses each Set-Cookie value and stores (name → value) ignoring everything after the first ; (attributes like Path, HttpOnly, Secure).
StatusCode
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. An HTTP status code (status-code in RFC 9110 et al.).
SymbolCache
Symbol → conid cache.
TickleResponse
Response from a tickle call, projected from the generated type.
Url
Re-export of url::Url so callers can name the return type of Client::base_url without adding url to their own Cargo.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_positions will walk.
POSITIONS_PAGE_SIZE
Page size the Gateway returns for paginated position calls.

Type Aliases§

ContractSummary
Contract-search result, alias over the generated type.
Position
Positions returned for an account. Alias over the generated type so callers can use bezant::Position without digging into bezant_api.
Result
Result alias using Error.