Skip to main content

Crate bot_engine

Crate bot_engine 

Source
Expand description

Bot Engine: order manager, inventory ledger, event routing, and polling.

This crate contains the runtime that:

  • Manages order state (in-memory source of truth)
  • Tracks inventory/balances with reservations
  • Routes events to strategies
  • Handles rate limiting and backoff
  • Manages exchange health state machine
  • Polling loop for fills and quotes (native only)
  • Trade syncing to upstream API for PnL tracking (native only)

Re-exports§

pub use account_syncer::AccountSyncer;
pub use account_syncer::AccountSyncerConfig;
pub use account_syncer::ClearingHouseStateRequest;
pub use account_syncer::PositionInfo as AccountPositionInfo;
pub use account_syncer::SyncError;
pub use account_syncer::SyncResponse as AccountSyncerResponse;
pub use account_syncer::SyncResult as AccountSyncerResult;
pub use sync_traits::AccountSync;
pub use sync_traits::AccountSyncResult;
pub use sync_traits::TradeSync;
pub use sync_traits::TradeSyncResult;
pub use trade_syncer::SyncRequest as TradeSyncRequest;
pub use trade_syncer::SyncResponse as TradeSyncerResponse;
pub use trade_syncer::SyncResult as TradeSyncerResult;
pub use trade_syncer::SyncedInfo;
pub use trade_syncer::TradeSyncer;
pub use trade_syncer::TradeSyncerConfig;
pub use trade_syncer::UpstreamTrade;
pub use runner::spawn_runner;
pub use runner::spawn_runner_with_syncer;
pub use runner::BacktestResult;
pub use runner::EngineRunner;
pub use runner::PollResult;
pub use runner::RunnerConfig;
pub use runner::TradingStats;
pub use testing::FillSimulator;
pub use testing::MockQuoteSource;
pub use testing::PendingOrder;
pub use testing::QuoteSource;
pub use testing::SimulatedFill;
pub use testing::MockAccountSyncer;
pub use testing::MockTradeSyncer;
pub use testing::MockExchange;
pub use testing::MockKnobs;
pub use testing::OrderFailMode;
pub use testing::PaperExchange;
pub use config::*;
pub use context::*;
pub use engine::*;
pub use inventory::*;
pub use order_manager::*;
pub use performance_metrics::*;
pub use poll_guard::*;

Modules§

account_syncer
Account syncer: syncs account state snapshots to upstream API.
compat
Platform compatibility layer for WASM and native targets.
config
Bot configuration types and strategy builder.
context
Strategy context implementation.
engine
Main engine implementation.
inventory
Inventory ledger: tracks balances and reservations.
order_manager
Order manager: tracks order state and transitions.
performance_metrics
Shared performance metrics for backtests and upstream sync payloads.
poll_guard
Generic poll handler with backoff and error classification.
runner
Engine runner - polling loop and event dispatch.
simulation
Simulation Layer: Shared margin-aware accounting for paper trading and backtesting.
sync_traits
Syncer traits for testing abstraction.
testing
Testing infrastructure: Mock exchanges, paper trading, and simulation utilities.
trade_syncer
Trade syncer: syncs fills to upstream API for PnL tracking.