1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! Trader Bot - A configurable trading bot with multi-strategy support.
//!
//! This crate provides a comprehensive trading bot framework with:
//! - Multi-exchange support through a unified abstraction layer
//! - Multiple trading strategies (balancing, scalping, holding)
//! - Recursive strategy composition (balancer can balance between sub-strategies)
//! - Multi-user, multi-account support
//! - Market simulator for backtesting and testing
//!
//! # Architecture
//!
//! The crate follows Clean Architecture principles with clear separation:
//!
//! - **domain**: Core business types (Position, Wallet, Order, Money, Trade)
//! - **exchange**: Exchange API abstraction layer (ExchangeProvider trait)
//! - **strategy**: Trading strategies (balancing, scalping, holding)
//! - **adapters**: Exchange-specific implementations (T-Bank, Binance, etc.)
//! - **simulator**: Market simulation for testing
//! - **config**: Configuration management for multi-user/multi-account setups
//!
//! # Features
//!
//! - **Portfolio Balancing**: Rebalance portfolio to target allocations
//! - **Scalping Strategy**: High-frequency buy-low sell-high trading
//! - **Holding Strategy**: Configurable asset holding with position limits
//! - **Strategy Composition**: Balance between multiple sub-strategies
//! - **Multi-Exchange**: T-Bank, Binance, Interactive Brokers support
//! - **Multi-Account**: Manage multiple accounts per user
//! - **Multi-User**: Support multiple users with isolated configurations
//! - **Market Simulator**: Full-featured simulator for backtesting
//!
//! # Example
//!
//! ```rust,no_run
//! use trader_bot::{
//! strategy::{BalancerEngine, BalancerConfig},
//! domain::DesiredAllocation,
//! simulator::SimulatedExchange,
//! };
//! use rust_decimal_macros::dec;
//! use std::sync::Arc;
//!
//! #[tokio::main]
//! async fn main() {
//! // Create a simulated exchange
//! let exchange = SimulatedExchange::new("USD");
//! exchange.add_instrument("AAPL", "Apple Inc.", dec!(150), 1);
//! exchange.add_instrument("GOOGL", "Alphabet Inc.", dec!(2800), 1);
//! exchange.create_account("my_account", dec!(100000));
//!
//! // Define target allocation
//! let mut target = DesiredAllocation::new();
//! target.set("AAPL", dec!(50));
//! target.set("GOOGL", dec!(50));
//!
//! // Create and run balancer
//! let exchange = Arc::new(exchange);
//! let config = BalancerConfig::default();
//! let mut engine = BalancerEngine::new(exchange, config);
//!
//! let result = engine.rebalance("my_account", &target).await;
//! println!("Rebalance result: {:?}", result);
//! }
//! ```
// Include lino_args from lib/rust directory
// Re-export balancer module at the old path for backwards compatibility
pub use balancer;
/// Package version (matches Cargo.toml version).
pub const VERSION: &str = env!;
/// Re-export commonly used types at the crate root.