7.6 KiB
Product Requirements Document: Crypto Trading Bot Dashboard
Introduction/Overview
Create a simple control dashboard for managing and monitoring multiple cryptocurrency trading bots simultaneously. The system will allow testing different strategies in parallel using real OKX market data and virtual trading simulation. The focus is on rapid implementation to enable strategy testing within days rather than weeks.
Core Problem: Currently, testing multiple trading strategies requires manual coordination and lacks real-time monitoring capabilities. There's no unified way to compare strategy performance or manage multiple bots running simultaneously.
Goals
- Enable Parallel Strategy Testing: Run up to 5 different trading bots simultaneously with different strategies
- Real-time Monitoring: Visualize bot performance, trading decisions, and market data in real-time
- Quick Strategy Validation: Reduce the time from strategy implementation to performance assessment
- Historical Analysis: Enable backtesting with previously collected market data
- Operational Control: Simple start/stop functionality for individual bots
User Stories
-
As a strategy developer, I want to start multiple bots with different strategies so that I can compare their performance over the same time period.
-
As a trader, I want to see real-time price charts and bot decisions so that I can understand how my strategies are performing.
-
As an analyst, I want to view historical performance metrics so that I can evaluate strategy effectiveness over different market conditions.
-
As a system operator, I want to stop underperforming bots so that I can prevent further virtual losses.
-
As a researcher, I want to run backtests on historical data so that I can validate strategies before live testing.
Functional Requirements
Core Bot Management
- Bot Lifecycle Control: System must allow starting and stopping individual bots via web interface
- Multi-Bot Support: System must support running up to 5 bots simultaneously
- Bot Configuration: System must read bot configurations from JSON/YAML files in a configs directory
- Status Monitoring: System must display current status (running/stopped) for each configured bot
Data Management
- Market Data Integration: System must connect to existing OKX data feed and display real-time price information
- Trading Decision Storage: System must record all bot trading decisions (buy/sell signals, amounts, timestamps) to database
- Performance Tracking: System must calculate and store key metrics (balance, profit/loss, number of trades) for each bot
- Data Persistence: System must use SQLite for simplicity with separate tables for market data and bot decisions
User Interface
- Dashboard Layout: System must provide a single-page dashboard showing all bot information
- Price Visualization: System must display candlestick charts with bot buy/sell markers overlaid
- Bot Switching: System must allow switching chart view between different active bots
- Performance Metrics: System must show current balance, total profit/loss, and trade count for each bot and trade time
- Real-time Updates: System must refresh data every 2 seconds minimum
Backtesting
- Historical Mode: System must allow running bots against historical market data
- Time Range Selection: System must provide date range picker for backtest periods
- Accelerated Testing: System must support running backtests faster than real-time
Non-Goals (Out of Scope)
- Multi-exchange Support: Only OKX integration for MVP
- Real Money Trading: Virtual trading simulation only
- Advanced UI/UX: Basic functional interface, not polished design
- User Authentication: Single-user system for MVP
- Strategy Editor: Strategy creation/editing via code only, not UI
- Advanced Analytics: Complex statistical analysis beyond basic P&L
- Mobile Interface: Desktop web interface only
- High-frequency Trading: Strategies with sub-second requirements not supported
Technical Considerations
Technology Stack
- Backend: Python with existing OKX, strategy, and trader modules
- Frontend: Plotly Dash for rapid development and Python integration
- Database: PostgreSQL, SQLAlchemy
- Communication: Direct database polling (no WebSockets for MVP)
Architecture Simplicity
- Monolithic Design: Single Python application with all components
- File-based Configuration: JSON files for bot settings
- Polling Updates: 2-second refresh cycle acceptable for MVP
- Process Management: Simple threading or multiprocessing for bot execution
Integration Requirements
- Existing Module Refactoring: May need to modify current strategy and trader modules for unified signal processing
- Database Schema: Design simple schema for bot decisions and performance metrics
- Error Handling: Basic error logging and bot restart capabilities
Success Metrics
- Functionality: Successfully run 3+ bots simultaneously for 24+ hours without crashes
- Data Completeness: Capture 100% of trading decisions and market data during bot operation
- Performance Visibility: Display real-time bot performance with <5 second update latency
- Backtesting Capability: Run historical tests covering 1+ weeks of data in <10 minutes
- Operational Control: Start/stop bots with <10 second response time
Design Considerations
Dashboard Layout
+------------------+-------------------+
| Bot Controls | Active Charts |
| [Bot1] [Start] | |
| [Bot2] [Stop] | Price/Strategy |
| [Bot3] [Start] | Chart |
+------------------+-------------------+
| Performance Metrics |
| Bot1: +$50 Bot2: -$20 Bot3: +$35 |
+--------------------------------------+
Configuration Example
{
"bot_id": "ema_crossover_01",
"strategy": "EMA_Crossover",
"parameters": {
"fast_period": 12,
"slow_period": 26,
"symbol": "BTC-USDT"
},
"virtual_balance": 10000
}
Implementation Phases
Phase 1 (Week 1-2): Core Infrastructure
- Set up basic Dash application
- Integrate existing OKX data feed
- Create bot manager for start/stop functionality
- Basic database schema for trading decisions
Phase 2 (Week 3): Visualization
- Implement price charts with Plotly
- Add bot decision overlays
- Create performance metrics dashboard
- Bot switching functionality
Phase 3 (Week 4): Testing & Refinement
- Add backtesting capability
- Implement error handling and logging
- Performance optimization
- User acceptance testing
Open Questions
- Strategy Module Integration: What modifications are needed to current strategy modules for unified signal processing?
- Database Migration: Start with PostgreSQL
- Bot Resource Management: How should we handle memory/CPU limits for individual bots?
- Configuration Management: Bot can have hot reloading (we can save current active, paused bots so on start it restore last state.)
- Error Recovery: On bot crash system should restart it if it is active.
Acceptance Criteria
- Start 5 different bots simultaneously via web interface
- View real-time price charts with buy/sell decision markers
- Switch between different bot views in the dashboard
- See current virtual balance and P&L for each bot
- Stop/start individual bots without affecting others
- Run backtest on 1 week of historical data
- System operates continuously for 48+ hours without manual intervention
- All trading decisions logged to database with timestamps