1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//! Public facade crate for `bat-markets`.
//!
//! `bat-markets` is a futures-first, headless exchange engine for Binance
//! USD-M and Bybit USDT linear futures. The facade keeps application code on a
//! small, typed surface while preserving venue-specific escape hatches when the
//! exchanges do not share identical semantics.
//!
//! # API map
//!
//! | Surface | Owner | Use it for |
//! | --- | --- | --- |
//! | [`BatMarkets`] / [`BatMarketsBuilder`] | engine construction | choose venue, product, config, and live/static mode |
//! | [`MarketClient`] | market read side | cached snapshots, public REST fetches, metadata refresh |
//! | [`StreamClient`] / [`PublicLaneClient`] | public data lane | fixture ingest, local event subscriptions, shared public WS watchers |
//! | [`StreamClient`] / [`PrivateLaneClient`] | private state lane | private feed ingest, account-stream watchers, manual reconcile |
//! | [`CommandLaneClient`] | command event lane | command lifecycle observation and low-level command classification |
//! | [`EntryClient`] | write side | order-entry and account-setting commands with [`PendingCommandHandle`] |
//! | [`TradeClient`] | order/execution read side | cached orders, open orders, executions, and REST refreshes |
//! | [`PositionClient`] | position read side | cached positions and REST refresh |
//! | [`AccountClient`] | account read side | balances, account summary, and account refresh |
//! | [`HealthClient`] | runtime health | cheap health snapshots and health-change subscriptions |
//! | [`DiagnosticsClient`] | local diagnostics | lock and runtime latency snapshots |
//! | [`NativeClient`] | venue-specific access | adapter details that should not be forced into a fake unified API |
//!
//! # Method families
//!
//! - [`BatMarketsBuilder::build`] creates an offline/static client and never
//! performs network I/O.
//! - [`BatMarketsBuilder::build_live`] bootstraps live transport with server
//! time, metadata, HTTP, and optional environment-backed auth.
//! - Snapshot getters such as [`MarketClient::ticker`],
//! [`TradeClient::orders`], and [`AccountClient::summary`] are synchronous
//! cached-state reads.
//! - `fetch_*` methods perform public REST reads.
//! - `refresh_*` methods perform REST reads and merge the result back into
//! engine state.
//! - `subscribe_*` methods read events already flowing through the local bus.
//! - `watch_*` methods acquire a shared live websocket lease and return typed
//! updates.
//! - [`EntryClient`] owns write commands and exposes acknowledgement,
//! lifecycle, and recovery through [`PendingCommandHandle`].
//!
//! # Safety model
//!
//! Public market reads do not require secrets. Live authenticated flows read
//! credentials from explicit config or venue-specific environment variables in
//! live mode. Command outcomes that cannot be proven are surfaced as
//! `UnknownExecution` and are resolved through reconciliation evidence instead
//! of being silently treated as success or failure.
//!
//! # Examples
//!
//! Static/offline client:
//!
//! ```
//! use bat_markets::{BatMarkets, errors::Result, types::{Product, Venue}};
//!
//! fn main() -> Result<()> {
//! let client = BatMarkets::builder()
//! .venue(Venue::Binance)
//! .product(Product::LinearUsdt)
//! .build()?;
//!
//! let capabilities = client.capabilities();
//! assert!(capabilities.market.ticker);
//! Ok(())
//! }
//! ```
//!
//! Live client:
//!
//! ```no_run
//! use bat_markets::{BatMarkets, errors::Result, types::{Product, Venue}};
//!
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! let client = BatMarkets::builder()
//! .venue(Venue::Bybit)
//! .product(Product::LinearUsdt)
//! .build_live()
//! .await?;
//!
//! println!("{} instruments", client.market().instrument_specs().len());
//! # Ok(())
//! # }
//! ```
/// Account balances and account summary facade.
/// Re-exported capability contracts from `bat-markets-core`.
/// Engine facade and builder.
/// Re-exported runtime config contracts from `bat-markets-core`.
/// Runtime and shared-state diagnostics facade.
/// Order-entry and account-setting command facade.
/// Re-exported error contracts from `bat-markets-core`.
/// Runtime health facade.
/// Market-data snapshot and REST facade.
/// Venue-specific native adapter access.
/// Position snapshot and compatibility settings facade.
/// Public, private, and command stream-lane facade.
/// Read-side order and execution facade.
/// Re-exported domain and request/response types from `bat-markets-core`.
pub use AccountClient;
pub use ;
pub use ;
pub use ;
pub use HealthClient;
pub use MarketClient;
pub use NativeClient;
pub use PositionClient;
pub use ;
pub use TradeClient;