Expand description
Finam Trade API gRPC protocol layer.
pb: messages and clients generated from the official.proto(vendored inproto/, seeproto/README.md), compiled withoutprotocbybuild.rs.auth: secret -> JWT, refreshed ahead of expiry; shareable between connectors.client: channel setup and service clients that attach the current JWT to every call.error:FinamError, the error type of this layer.
This is the protocol layer. The connectors that implement the shared traits (brokapi-finam) sit
on top of it. Use this crate directly only when you need a Finam call the connector does not wrap
(the connector’s raw() is usually easier, it also keeps the rate limit).
The book with the full guide: https://brokapi.ru/docs/
§Examples
Log in and ask for the last quote of an instrument. The example runs against an in-process imitation of the broker, so it needs no account and no network:
use brokapi_finam_protocol::pb::grpc::tradeapi::v1::marketdata::QuoteRequest;
use brokapi_finam_protocol::{ApiEndpoint, FinamApi, start_token_manager};
// For the real broker: `ApiEndpoint::default()` and your API secret.
let tokens = start_token_manager(&endpoint, secret, "my-app").await?;
let api = FinamApi::connect(&endpoint, tokens, false)?;
let reply = api
.market_data()
.last_quote(QuoteRequest { symbol: "SBER@MISX".into() })
.await?
.into_inner();
assert_eq!(reply.symbol, "SBER@MISX");Re-exports§
pub use auth::GrpcTokenApi;pub use auth::TokenApi;pub use auth::TokenInfo;pub use auth::TokenManager;pub use client::ApiEndpoint;pub use client::Authorized;pub use client::DEFAULT_ENDPOINT;pub use client::FinamApi;pub use client::start_token_manager;pub use error::FinamError;
Modules§
- auth
- JWT lifecycle: secret ->
AuthService.Auth-> JWT, refreshed ahead of expiry. - client
- Channel setup and authorized service clients.
- error
- Protocol-layer errors.
- pb
- Generated messages and gRPC clients/servers.
Constants§
- FILE_
DESCRIPTOR_ SET - The descriptors of every service and message of the API, as a serialized
FileDescriptorSet(the.protofiles this crate is built from, with their imports). Load it into a descriptor pool to call a method by its name, seeFinamApi::grpc.