How cardosojoel/trade works
Trade is a spot-Bitcoin trading system whose presently supported user workflow is collecting public Bybit candles and evaluating a strategy in a backtest. The engine turns strategy signals into orders through a mandatory risk guard, with simulated execution and required audit recording. The tree also contains session, paper-execution, and reporting/server components, but the README explicitly says paper and live trading are not available. Wiring for unsampled modules is omitted where the excerpts and index do not establish a caller relationship.
Main entry points: guard.rs Risk guard · engine.rs Backtest engine · app.rs Reporting application · main.rs Trade CLI
Components 24
User entry
- Trade CLI
crates/trade-cli/src/main.rs - Collection command
crates/trade-cli/src/cmd_collect.rs - Backtest command
crates/trade-cli/src/cmd_backtest.rs
Market data
- Public Bybit client
crates/trade-bybit/src/client.rs - Candle collector
crates/trade-bybit/src/collector.rs - Candle source
crates/trade-storage/src/market_source.rs - Candle repository
crates/trade-storage/src/candle_repo.rs
Trading runtime
- Trading domain
crates/trade-domain/src/types.rs - SMA strategy
crates/trade-strategy/src/sma_cross.rs - Backtest engine
crates/trade-backtest/src/engine.rs - Simulated executor
crates/trade-backtest/src/executor.rs - Backtest outcome
crates/trade-backtest/src/run.rs - Risk guard
crates/trade-risk/src/guard.rs - Risk rules
crates/trade-risk/src/rules.rs - Kill switch
crates/trade-risk/src/kill_switch.rs
Storage and audit
- Audit events
crates/trade-domain/src/audit.rs - Run repository
crates/trade-storage/src/runs_repo.rs - SQLite access
crates/trade-storage/src/db.rs
Session and reporting
- Session loop
crates/trade-session/src/laco.rs - Paper executor
crates/trade-paper/src/executor.rs - Reporting application
crates/trade-serve/src/app.rs - Run queries
crates/trade-serve/src/consultas.rs - Report responses
crates/trade-serve/src/respostas.rs
Other components
- Operator
Connections 19
- Operator → Trade CLI: runs commands
README.md - Trade CLI → Collection command: dispatches collection
- Trade CLI → Backtest command: dispatches backtest
- Collection command → Public Bybit client: fetches candles
README.md - Collection command → Candle repository: stores history
README.md - Backtest command → Backtest engine: starts backtest
README.md - Backtest engine → SMA strategy: requests signals
README.md - Backtest engine → Risk guard: submits orders
crates/trade-backtest/src/engine.rs - Backtest engine → Simulated executor: constructs executor
crates/trade-backtest/src/engine.rs - Risk guard → Simulated executor: owns executor
README.md - Risk guard → Risk rules: evaluates limits
crates/trade-risk/src/guard.rs - Risk guard → Kill switch: checks switch
crates/trade-risk/src/guard.rs - Backtest engine → Backtest outcome: returns outcome
crates/trade-backtest/src/engine.rs - Reporting application → Run queries: calls queries
crates/trade-serve/src/app.rs - Reporting application → Report responses: builds responses
crates/trade-serve/src/app.rs - Reporting application → Run repository: reads run data
crates/trade-serve/src/app.rs - Run repository → SQLite access: uses SQLite
crates/trade-storage/src/runs_repo.rs - Session loop → Risk guard: dispatches orders
- Risk guard → Paper executor: may wrap executor