pub struct BotConfig {
pub name: String,
pub symbols: Vec<Symbol>,
pub shutdown_timeout: Duration,
pub install_signal_handler: bool,
pub market_bus_capacity: usize,
pub signal_bus_capacity: usize,
pub close_positions_on_shutdown: bool,
pub risk: RiskConfig,
}Expand description
Configuration for a Bot.
Construct via BotConfig::builder. The builder validates every
field on BotConfigBuilder::build and returns Error::Config on
any violation — the framework never panics on bad config. Bot::new
does a final brain-count check on top.
§Example
use std::time::Duration;
use rustrade::BotConfig;
let config = BotConfig::builder()
.name("market-maker")
.symbols(["BTCUSDT", "ETHUSDT"])
.shutdown_timeout(Duration::from_secs(5))
.without_signal_handler() // tests + embedded use
.build()
.unwrap();
assert_eq!(config.name, "market-maker");
assert_eq!(config.symbols.len(), 2);Fields§
§name: StringHuman-readable name used in logs, tracing spans, and supervisor service identification.
symbols: Vec<Symbol>Symbols this bot trades. Every symbol gets a pre-seeded entry in the risk-state map and the position cache. Must be non-empty — the position cache and risk-state map would otherwise be empty, which is a silent footgun.
shutdown_timeout: DurationMaximum time to wait for services to drain on shutdown. Must be
> 0; the supervisor’s drain logic needs a non-zero deadline.
install_signal_handler: boolWhether the supervisor installs its own Ctrl-C / SIGTERM handler.
Disable when the host service drives shutdown via BotHandle::shutdown.
market_bus_capacity: usizeCapacity of the in-process market-data broadcast bus. Backed by
tokio::sync::broadcast, which has drop-oldest semantics: a
slow subscriber that falls behind by more than capacity events
sees RecvError::Lagged(n) and the oldest dropped events are
gone. Size this to absorb the worst-case latency between
publish and slowest subscriber’s recv.
signal_bus_capacity: usizeCapacity of the in-process signal broadcast bus. Same drop-oldest
semantics as market_bus_capacity. Typically smaller — signals
are emitted ~once per non-Hold decision, far less frequent than
market events.
close_positions_on_shutdown: boolOn shutdown, attempt to close any open position for each symbol
before exit, using ExchangeClient::close_position. Best-effort:
failures are logged but do not propagate.
risk: RiskConfigRisk-layer defaults applied to every configured symbol.