pub struct BotConfigBuilder { /* private fields */ }Expand description
Builder for BotConfig.
Implementations§
Source§impl BotConfigBuilder
impl BotConfigBuilder
Sourcepub fn name(self, name: impl Into<String>) -> Self
pub fn name(self, name: impl Into<String>) -> Self
Human-readable bot name (logs, supervisor identification). Required.
Sourcepub fn symbol(self, sym: impl Into<Symbol>) -> Self
pub fn symbol(self, sym: impl Into<Symbol>) -> Self
Add a single symbol. Repeated calls accumulate.
Sourcepub fn symbols<I, S>(self, syms: I) -> Self
pub fn symbols<I, S>(self, syms: I) -> Self
Add many symbols at once. Repeated calls accumulate.
Sourcepub fn shutdown_timeout(self, dur: Duration) -> Self
pub fn shutdown_timeout(self, dur: Duration) -> Self
Maximum time to wait for services to drain on shutdown.
Sourcepub fn without_signal_handler(self) -> Self
pub fn without_signal_handler(self) -> Self
Disable the supervisor’s signal handler — host drives shutdown.
Sourcepub fn market_bus_capacity(self, cap: usize) -> Self
pub fn market_bus_capacity(self, cap: usize) -> Self
Override the in-process market-data bus capacity (default 1024).
Sourcepub fn signal_bus_capacity(self, cap: usize) -> Self
pub fn signal_bus_capacity(self, cap: usize) -> Self
Override the in-process signal-bus capacity (default 256).
Sourcepub fn close_positions_on_shutdown(self, b: bool) -> Self
pub fn close_positions_on_shutdown(self, b: bool) -> Self
Enable best-effort exchange.close_position for non-flat positions
after the supervisor drains.
Sourcepub fn session_pnl_config(self, cfg: SessionPnlConfig) -> Self
pub fn session_pnl_config(self, cfg: SessionPnlConfig) -> Self
Override the session-PnL config used for every symbol.
Sourcepub fn circuit_breaker_config(self, cfg: CircuitBreakerConfig) -> Self
pub fn circuit_breaker_config(self, cfg: CircuitBreakerConfig) -> Self
Override the circuit-breaker config used for every symbol.
Sourcepub fn sizing_config(self, cfg: SizingConfig) -> Self
pub fn sizing_config(self, cfg: SizingConfig) -> Self
Override the position-sizing config used for every symbol.
Sourcepub fn portfolio_config(self, cfg: PortfolioRiskConfig) -> Self
pub fn portfolio_config(self, cfg: PortfolioRiskConfig) -> Self
Set the account-wide PortfolioRiskConfig — a daily-loss halt, a
max-concurrent-positions cap, and a gross-exposure cap applied across
all symbols. Unset, every limit is off (the per-symbol gates still apply).
use rustrade::{BotConfig, PortfolioRiskConfig};
let cfg = BotConfig::builder()
.name("bot")
.symbols(["BTCUSDT", "ETHUSDT"])
.without_signal_handler()
.portfolio_config(PortfolioRiskConfig {
max_daily_loss: -500.0,
max_concurrent_positions: 3,
max_gross_exposure: 50_000.0,
})
.build()
.unwrap();
assert_eq!(cfg.portfolio.max_concurrent_positions, 3);Sourcepub fn bracket_failure_policy(self, policy: BracketFailurePolicy) -> Self
pub fn bracket_failure_policy(self, policy: BracketFailurePolicy) -> Self
Set the BracketFailurePolicy — what happens when a bracket entry
fills but its protective stop-loss leg fails to place. Defaults to
BracketFailurePolicy::CloseEntry.
Sourcepub fn symbol_risk(self, symbol: impl Into<Symbol>, cfg: RiskConfig) -> Self
pub fn symbol_risk(self, symbol: impl Into<Symbol>, cfg: RiskConfig) -> Self
Set a per-symbol RiskConfig override. The given symbol then uses
this config (session-PnL cap, circuit breaker, sizing) instead of the
bot-wide default. Repeated calls for the same symbol replace the
previous override. Symbols without an override use the default.
use rustrade::{BotConfig, RiskConfig};
use rustrade::SessionPnlConfig;
let cfg = BotConfig::builder()
.name("bot")
.symbols(["BTCUSDT", "DOGEUSDT"])
.without_signal_handler()
// tighter daily loss cap on the volatile alt
.symbol_risk("DOGEUSDT", RiskConfig {
session_pnl: SessionPnlConfig { loss_limit: -20.0 },
..Default::default()
})
.build()
.unwrap();
assert_eq!(cfg.risk_for(&"DOGEUSDT".into()).session_pnl.loss_limit, -20.0);Sourcepub fn class_risk(self, class: AssetClass, cfg: RiskConfig) -> Self
pub fn class_risk(self, class: AssetClass, cfg: RiskConfig) -> Self
Set a per-AssetClass RiskConfig override. Symbols whose
instrument reports this class use cfg (unless a per-symbol override
also exists, which wins). See RiskConfig::preset_for for ready-made
presets to start from.
use rustrade::{AssetClass, BotConfig, RiskConfig};
let cfg = BotConfig::builder()
.name("multi-asset")
.symbols(["XBTUSDTM", "EURUSD"])
.without_signal_handler()
.class_risk(AssetClass::CryptoPerp, RiskConfig::crypto_perp())
.class_risk(AssetClass::Fx, RiskConfig::fx())
.build()
.unwrap();
// FX symbols resolve to the FX preset (20× leverage) absent a
// per-symbol override.
assert_eq!(
cfg.resolve_risk(&"EURUSD".into(), AssetClass::Fx).sizing.leverage,
20
);Trait Implementations§
Source§impl Clone for BotConfigBuilder
impl Clone for BotConfigBuilder
Source§fn clone(&self) -> BotConfigBuilder
fn clone(&self) -> BotConfigBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more