How zhiwei-3/trading-butler works
Trading Butler is a Telegram-operated MetaTrader 5 trading bot. Its user workflow runs from Telegram commands and callbacks through strategy selection or trading controls, market analysis, signal evaluation, and—when enabled—trade execution; scheduled jobs monitor markets and trade outcomes. Configuration, SQLite persistence, and chart/message helpers support that runtime. The excerpts establish application startup, handler registration, settings, and key package boundaries; several command, evaluator, and execution internals were not sampled, so those workflow links are marked unverified rather than asserted.
Main entry points: app.py Bot application · commands Bot commands · strategies Trading strategies · jobs Scheduled jobs
Components 20
Telegram interface
- Bot application
app.py - Handler registry
bot/registry.py - Bot commands
bot/commands - Telegram messaging
bot/messaging.py
Strategy and analysis
- Strategy registry
strategies/__init__.py - Trading strategies
strategies - Indicators and features
analysis/indicators.py - Market structure analysis
analysis/smc.py
Trading runtime
- Backtesting
core/backtester.py - Signal evaluation
core/evaluator.py - Order execution
core/execution/orders.py - Trade guards
core/guards - MT5 access
core/mt5/gateway.py
Monitoring and reporting
- Scheduled jobs
bot/jobs - News engine
core/news_engine.py - Charts and reports
charts
Configuration and state
- Settings and runtime state
config.py - Signal persistence API
core/db/signals.py - SQLite persistence
core/db/connection.py
Other components
- Telegram user
Connections 27
- Telegram user → Bot application: sends updates
app.py - Bot application → Settings and runtime state: reads credentials
app.py - Bot application → SQLite persistence: initializes database
app.py - Bot application → MT5 access: initializes MT5
app.py - Bot application → Handler registry: installs handlers
app.py - Bot application → Bot commands: loads registrations
app.py - Handler registry → Bot commands: dispatches commands
bot/registry.py - Bot commands → Telegram messaging: sends replies
bot/commands/journal.py - Bot commands → Strategy registry: selects strategies
bot/commands/optimize.py - Strategy registry → Trading strategies: discovers strategies
strategies/__init__.py - Trading strategies → Indicators and features: uses indicators
- Trading strategies → Market structure analysis: uses structure analysis
- Backtesting → Strategy registry: loads strategies
core/backtester.py - Backtesting → Indicators and features: uses analysis
core/backtester.py - Trading strategies → Signal evaluation: packages signals
- Signal evaluation → Signal persistence API: records signals
- Signal evaluation → Order execution: submits intents
- Order execution → Trade guards: checks trade gates
- Order execution → MT5 access: routes orders
core/execution/orders.py - Signal persistence API → SQLite persistence: persists signals
core/db/signals.py - Bot application → Scheduled jobs: starts scheduled jobs
app.py - Scheduled jobs → News engine: monitors news
- Scheduled jobs → Order execution: tracks trades
- Scheduled jobs → Charts and reports: generates reports
bot/jobs/tracker.py - Bot commands → Backtesting: runs optimization
bot/commands/optimize.py - Bot commands → Signal persistence API: reads journal data
bot/commands/journal.py - Bot commands → MT5 access: reads account history
bot/commands/journal.py