pub struct SymbolCache { /* private fields */ }Expand description
Symbol → conid cache.
Resolving a ticker to IBKR’s numeric conid is a search call, and it’s
stable across days — most bots do it once per ticker per session. Wrap
your Client with a SymbolCache to memoise lookups.
The cache is deliberately simple: a Mutex<HashMap>. It’s built for the
low-volume rebalance-bot case (dozens of tickers, infrequent refreshes)
rather than high-volume quote streaming.
§Example
let client = bezant::Client::new("https://localhost:5000/v1/api")?;
let cache = bezant::SymbolCache::new(client);
let aapl = cache.conid_for("AAPL").await?;
let msft = cache.conid_for("MSFT").await?;
// further calls for AAPL/MSFT hit the in-memory cache.Implementations§
Source§impl SymbolCache
impl SymbolCache
Sourcepub async fn conid_for(&self, symbol: &str) -> Result<i64>
pub async fn conid_for(&self, symbol: &str) -> Result<i64>
Return the cached conid for symbol, looking it up on first miss.
Only STK-type matches are cached. If you need options / bonds /
futures, call Client::api directly. Both hits and misses are
memoised — if a symbol turns out to be invalid, subsequent calls
return Error::SymbolNotFound without touching the network.
§Errors
Error::SymbolNotFound if the symbol doesn’t resolve to any
contract, Error::BadConid if the upstream returned a contract
whose conid wasn’t a parseable integer, plus any transport /
decode errors.