nautilus_binance/config.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3// https://nautechsystems.io
4//
5// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6// You may not use this file except in compliance with the License.
7// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Binance adapter configuration structures.
17
18use std::any::Any;
19
20use nautilus_model::identifiers::{AccountId, TraderId};
21use nautilus_system::factories::ClientConfig;
22
23use crate::common::enums::{BinanceEnvironment, BinanceProductType};
24
25/// Configuration for Binance data client.
26#[derive(Clone, Debug)]
27pub struct BinanceDataClientConfig {
28 /// Product types to subscribe to.
29 pub product_types: Vec<BinanceProductType>,
30 /// Environment (mainnet or testnet).
31 pub environment: BinanceEnvironment,
32 /// Optional base URL override for HTTP API.
33 pub base_url_http: Option<String>,
34 /// Optional base URL override for WebSocket.
35 pub base_url_ws: Option<String>,
36 /// API key for HTTP authenticated endpoints (HMAC).
37 pub api_key: Option<String>,
38 /// API secret for HTTP request signing (HMAC).
39 pub api_secret: Option<String>,
40 /// Ed25519 API key for SBE WebSocket streams (required for SBE).
41 pub ed25519_api_key: Option<String>,
42 /// Ed25519 private key (base64) for SBE WebSocket streams (required for SBE).
43 pub ed25519_api_secret: Option<String>,
44}
45
46impl Default for BinanceDataClientConfig {
47 fn default() -> Self {
48 Self {
49 product_types: vec![BinanceProductType::Spot],
50 environment: BinanceEnvironment::Mainnet,
51 base_url_http: None,
52 base_url_ws: None,
53 api_key: None,
54 api_secret: None,
55 ed25519_api_key: None,
56 ed25519_api_secret: None,
57 }
58 }
59}
60
61impl ClientConfig for BinanceDataClientConfig {
62 fn as_any(&self) -> &dyn Any {
63 self
64 }
65}
66
67/// Configuration for Binance execution client.
68#[derive(Clone, Debug)]
69pub struct BinanceExecClientConfig {
70 /// Trader ID for the client.
71 pub trader_id: TraderId,
72 /// Account ID for the client.
73 pub account_id: AccountId,
74 /// Product types to trade.
75 pub product_types: Vec<BinanceProductType>,
76 /// Environment (mainnet or testnet).
77 pub environment: BinanceEnvironment,
78 /// Optional base URL override for HTTP API.
79 pub base_url_http: Option<String>,
80 /// Optional base URL override for WebSocket.
81 pub base_url_ws: Option<String>,
82 /// API key for authenticated endpoints (optional, uses env var if not provided).
83 pub api_key: Option<String>,
84 /// API secret for request signing (optional, uses env var if not provided).
85 pub api_secret: Option<String>,
86}
87
88impl ClientConfig for BinanceExecClientConfig {
89 fn as_any(&self) -> &dyn Any {
90 self
91 }
92}