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
//! 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 root API is grouped by responsibility:
//!
//! - `fetch_*` methods read REST snapshots.
//! - `watch_*` methods return typed websocket watchers.
//! - `create_*`, `edit_*`, `cancel_*`, `close_*`, and `set_*` methods send commands.
//! - [`BatMarkets::advanced`] exposes raw ingestion, diagnostics, reconcile, and native adapters.
//!
//! # API map
//!
//! | Family | Primary methods | Responsibility |
//! | --- | --- | --- |
//! | Metadata/cache | [`BatMarkets::markets`], [`BatMarkets::load_markets`] | local bundled metadata and live venue metadata refresh |
//! | Public REST | `fetch_ticker`, `fetch_tickers`, `fetch_order_book`, `fetch_ohlcv`, `fetch_trades`, `fetch_mark_price`, `fetch_funding_rate`, `fetch_open_interest`, `fetch_liquidations` | unauthenticated market snapshots |
//! | Private REST | `fetch_balance`, `fetch_positions`, `fetch_open_orders`, `fetch_order`, `fetch_my_trades` | authenticated account, position, order, and execution snapshots |
//! | Public WS | `watch_ticker`, `watch_tickers`, `watch_trades`, `watch_trades_for_symbols`, `watch_order_book`, `watch_ohlcv`, `watch_ohlcv_for_symbols`, `watch_mark_price`, `watch_funding_rate`, `watch_open_interest`, `watch_liquidations`, `watch_status` | typed live updates over shared websocket hubs |
//! | Private WS | `watch_balance`, `watch_orders`, `watch_my_trades`, `watch_positions` | authenticated account-stream updates over one shared private hub |
//! | Commands | `create_order`, `create_orders`, `edit_order`, `edit_orders`, `cancel_order`, `cancel_orders`, `cancel_all_orders`, `close_position`, `validate_order`, `set_leverage`, `set_margin_mode`, `set_position_mode` | write operations with lifecycle-aware [`PendingCommandHandle`] results |
//! | Advanced | [`BatMarkets::advanced`] | raw lane ingest, subscriptions, command classification, reconcile, diagnostics, and native access |
//!
//! # 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()?;
//!
//! assert!(!client.markets().is_empty());
//! 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.markets().len());
//! # Ok(())
//! # }
//! ```
compile_error!;
/// Low-level advanced facade for custom transports and diagnostics.
/// Re-exported capability contracts from `bat-markets-core`.
/// Engine facade and builder.
/// Re-exported runtime config contracts from `bat-markets-core`.
/// Re-exported error contracts from `bat-markets-core`.
/// Re-exported domain and request/response types from `bat-markets-core`.
pub use AdvancedClient;
pub use ;
pub use ;
pub use PendingCommandHandle;
pub use StatusWatch;
pub use NativeClient;
pub use ;