Expand description
Direct access to any Finam Trade API method (“back door”): same secret and token manager, same
endpoint, same [BrokerLimiter] as the connector it came from.
The connectors wrap what the shared traits can express. Everything else (reports, corporate
actions, options chains, constituents, PlaceSLTPOrder, usage metrics, …) is reachable here:
use brokapi_finam::limits::default_limits;
use brokapi_finam::{MarketDataConfig, MarketDataConnector};
use brokapi_runtime::BrokerLimiter;
use brokapi_finam_protocol::pb::grpc::tradeapi::v1::marketdata::QuoteRequest;
use tokio::sync::mpsc;
let (events, _rx) = mpsc::channel(16);
let md = MarketDataConnector::start(
MarketDataConfig::new(api, "finam-md"),
BrokerLimiter::new(&default_limits()),
events,
)
.await?;
// The name is the proto method name: the quota is looked up by it.
let raw = md.raw();
let quote = raw
.call("LastQuote", |api| async move {
api.market_data().last_quote(QuoteRequest { symbol: "SBER@MISX".into() }).await
})
.await?;
assert_eq!(quote.symbol, "SBER@MISX");Rules of a call:
- The quota is taken first, by the proto method name (
"GetFutureSplits"), from the route inlimits.toml. A name without a route spends the"*"default route, so a call is never free. A refusal isError::RateLimitedand the request is not sent. - The closure gets a [
FinamApi] that attaches the CURRENT JWT to every request (the connector’s token manager renews it ahead of expiry). One closure is one API method. - The answer is cut by the connector’s request timeout.
callis for reads: onUNAUTHENTICATEDthe JWT is renewed and the call is made once more.call_commandis for anything that changes the account: no retry, and a timeout or break is [Error::Unknown].
A stream opened through call keeps the JWT it was opened with. Reopen it after the token
changes (the connector does that for its own streams).
The raw layer does not know about the connector’s order index: orders placed through it are not
tracked (no events, no reconcile). Use the shared traits for orders.
Structs§
- Finam
Raw - Handle for calling any Finam method with the connector’s token, endpoint and rate limiter.