Skip to main content

brokapi/
lib.rs

1//! One interface to the APIs of Russian brokers: BCS, T-Bank, Finam and ALOR.
2//!
3//! This is the crate you depend on. It re-exports the library and switches brokers on with
4//! features, the way `tokio` does:
5//!
6//! ```toml
7//! [dependencies]
8#![doc = concat!(" brokapi = { version = \"", env!("CARGO_PKG_VERSION"), "\", features = [\"bcs\"] }   # or \"tbank\", \"finam\", \"alor\", \"bybit\"")]
9//! ```
10//!
11//! | Path | What is there | Feature |
12//! |---|---|---|
13//! | [`core`] | domain types, capability traits, events, errors | always |
14//! | [`runtime`] | rate limits, subscription buffers, reconcile, shutdown | always |
15//! | [`sansio`] | the network-free core of a connector and the recorded-frame test harness | always |
16//! | `bcs` | BCS connectors (`MarketDataConnector`, `UserDataConnector`); `bcs::protocol` is the wire client | `bcs` |
17//! | `tbank` | T-Bank connectors; `tbank::protocol` is the gRPC client | `tbank` |
18//! | `finam` | Finam connectors; `finam::protocol` is the gRPC client | `finam` |
19//! | `alor` | ALOR connectors; `alor::protocol` is the HTTP and WebSocket client | `alor` |
20//! | `bybit` | Bybit connectors; `bybit::protocol` is the HTTP and WebSocket client | `bybit` |
21//!
22//! The guide and the rules for orders are in the book:
23//! <https://brokapi.ru/docs/>. The stage is open alpha: the interface can change before the beta. Before you trade with real
24//! money, read <https://brokapi.ru/docs/before-live.html>.
25//!
26//! # Example
27//!
28//! A command with no answer is never repeated: the error says so by its class.
29//!
30//! ```
31//! use brokapi::core::{Error, ErrorClass};
32//!
33//! assert_eq!(Error::Unknown.class(), ErrorClass::Unknown);
34//! ```
35
36#![warn(missing_docs)]
37
38pub use brokapi_core as core;
39pub use brokapi_runtime as runtime;
40pub use brokapi_sansio as sansio;
41
42/// BCS connectors and the BCS wire client.
43#[cfg(feature = "bcs")]
44pub mod bcs {
45    pub use brokapi_bcs::*;
46    /// The BCS REST and WebSocket client (lower layer).
47    pub use brokapi_bcs_protocol as protocol;
48}
49
50/// T-Bank connectors and the T-Bank gRPC client.
51#[cfg(feature = "tbank")]
52pub mod tbank {
53    pub use brokapi_tbank::*;
54    /// The T-Bank Invest API gRPC client (lower layer).
55    pub use brokapi_tbank_protocol as protocol;
56}
57
58/// Finam connectors and the Finam gRPC client.
59#[cfg(feature = "finam")]
60pub mod finam {
61    pub use brokapi_finam::*;
62    /// The Finam Trade API gRPC client (lower layer).
63    pub use brokapi_finam_protocol as protocol;
64}
65
66/// ALOR connectors and the ALOR wire client.
67#[cfg(feature = "alor")]
68pub mod alor {
69    pub use brokapi_alor::*;
70    /// The ALOR HTTP and WebSocket client (lower layer).
71    pub use brokapi_alor_protocol as protocol;
72}
73
74/// Bybit connectors and the Bybit wire client.
75#[cfg(feature = "bybit")]
76pub mod bybit {
77    pub use brokapi_bybit::*;
78    /// The Bybit HTTP and WebSocket client (lower layer).
79    pub use brokapi_bybit_protocol as protocol;
80}