Skip to main content

rustrade_core/
lib.rs

1#![warn(missing_docs)]
2
3//! # rustrade-core
4//!
5//! Core types and traits for the rustrade trading bot framework.
6//!
7//! This crate is the type-layer foundation used by every other crate in the
8//! `rustrade` ecosystem. It is deliberately dependency-light and contains
9//! **no I/O, no async runtime state, and no exchange-specific logic**.
10//!
11//! # What lives here
12//!
13//! - Domain types: [`Price`], [`Volume`], [`Candle`], [`Tick`], [`Order`], [`Fill`], [`Position`]
14//! - Trading intents: [`Signal`], [`Decision`], [`SizeHint`]
15//! - Trait contracts: [`Brain`], [`ExchangeClient`], [`MarketSource`]
16//! - Broadcast buses: [`MarketDataBus`], [`SignalBus`]
17//! - State persistence: [`StateStore`], [`InMemoryStore`]
18//! - Error types: [`Error`], [`Result`]
19//!
20//! # What does NOT live here
21//!
22//! - Service lifecycle / supervision → `rustrade-supervisor`
23//! - Risk calculations → `rustrade-risk`
24//! - Backtest replay → `rustrade-backtest`
25//! - Exchange clients → separate crates (e.g. `exchange-apiws`)
26//! - Indicator implementations → separate crates (e.g. `indicators-ta`)
27//!
28//! # Design principles
29//!
30//! 1. **Zero runtime deps beyond tokio primitives.** No HTTP, no Redis, no
31//!    tracing-subscriber, no prometheus. Downstream crates add those.
32//! 2. **Newtype wrappers for numeric quantities** to prevent unit confusion.
33//! 3. **Traits are narrow.** Implementors should not need to stub dozens
34//!    of methods they don't care about.
35//! 4. **Traits are object-safe where possible** so `Box<dyn Brain>` works.
36
37pub mod brain;
38pub mod bus;
39pub mod error;
40pub mod exchange;
41pub mod instrument;
42pub mod market;
43pub mod metrics;
44pub mod signal;
45pub mod store;
46pub mod types;
47
48pub use brain::{Brain, BrainHealth, Decision, SizeHint};
49pub use bus::{MarketDataBus, SignalBus};
50pub use error::{Error, Result};
51pub use exchange::{
52    CandleSource, Capability, EventSource, ExchangeClient, FillSource, MarketSource, OpenOrder,
53    OrderStatus,
54};
55pub use instrument::{AssetClass, InstrumentSpec};
56pub use market::{Exchange, MarketDataEvent, Side, Symbol};
57pub use metrics::{MetricsSink, NoopSink};
58pub use signal::{Signal, SignalType};
59pub use store::{InMemoryStore, StateStore};
60pub use types::{
61    Candle, Fill, Order, OrderKind, Position, Price, StopAttachment, StopKind, Tick, Volume,
62};