Skip to main content

bot_core/
lib.rs

1//! Canonical types, events, commands, and traits for the trading bot.
2//!
3//! `bot-core` is the shared contract between strategies, the engine, and
4//! exchange adapters. It owns identifiers, money/quantity wrappers, instrument
5//! metadata, order state, command/event DTOs, and the strategy/exchange traits.
6//!
7//! # Example
8//!
9//! ```
10//! use bot_core::{
11//!     Environment, ExchangeId, ExchangeInstance, InstrumentId, OrderSide, PlaceOrder, Price, Qty,
12//! };
13//! use rust_decimal::Decimal;
14//!
15//! let exchange = ExchangeInstance::new(ExchangeId::new("hyperliquid"), Environment::Testnet);
16//! let order = PlaceOrder::limit(
17//!     exchange,
18//!     InstrumentId::new("BTC-PERP"),
19//!     OrderSide::Buy,
20//!     Price::new(Decimal::new(65_000, 0)),
21//!     Qty::new(Decimal::new(1, 3)),
22//! );
23//!
24//! assert_eq!(order.instrument.as_str(), "BTC-PERP");
25//! ```
26//!
27//! # Error and panic policy
28//!
29//! Constructors are intentionally lightweight and do not validate exchange
30//! semantics. String parsing helpers return `rust_decimal::Error` on invalid
31//! decimals. Non-WASM [`now_ms`] panics only if the host clock is before the
32//! Unix epoch.
33
34pub mod commands;
35pub mod events;
36pub mod exchange;
37pub mod market;
38pub mod strategy;
39pub mod types;
40
41pub use commands::*;
42pub use events::*;
43pub use exchange::*;
44pub use market::*;
45pub use strategy::*;
46pub use types::*;