TCPDashboard/tasks/tasks-prd-crypto-bot-dashboard.md
2025-05-29 23:04:08 +08:00

4.4 KiB

Relevant Files

  • app.py - Main Dash application entry point and layout definition
  • bot_manager.py - Core bot lifecycle management and orchestration
  • database/models.py - SQLAlchemy models for bots, trades, and market data
  • database/connection.py - Database connection and session management
  • data/okx_integration.py - OKX API connection and real-time data feed
  • strategies/ - Directory containing strategy modules (existing, may need refactoring)
  • trader/ - Directory containing virtual trading logic (existing, may need refactoring)
  • components/dashboard.py - Dash dashboard components and layout
  • components/charts.py - Plotly chart components for price and performance visualization
  • backtesting/engine.py - Backtesting execution engine
  • config/bot_configs/ - Directory for JSON bot configuration files
  • utils/logging.py - Logging configuration and utilities
  • requirements.txt - Python dependencies using UV package manager

Notes

  • Use docker for development and database
  • Use UV for package management as specified in project requirements
  • PostgreSQL with SQLAlchemy for database persistence
  • Plotly Dash for rapid UI development
  • Bot configurations stored as JSON files in config directory
  • System should support hot-reloading of bot states

Tasks

  • 0.0 Dev environment and Docker setup

    • 0.1 Create Docker Compose file with PostgreSQL service
    • 0.2 Set up UV package management with pyproject.toml dependencies
    • 0.3 Create .env file template for database and API configuration
    • 0.4 Add development scripts for starting/stopping services
    • 0.5 Test database connection and basic container orchestration
  • 1.0 Database Infrastructure Setup

    • 1.1 Design PostgreSQL schema for bots, trades, market_data, and bot_states tables
    • 1.2 Create SQLAlchemy models in database/models.py for all entities
    • 1.3 Implement database connection management in database/connection.py
    • 1.4 Create Alembic migration scripts for initial schema
    • 1.5 Add database utility functions for common queries
    • 1.6 Implement bot state persistence for hot-reloading capability
  • 2.0 Bot Management System Development

    • 2.1 Create bot_manager.py with BotManager class for lifecycle control
    • 2.2 Implement bot configuration loading from JSON files in config/bot_configs/
    • 2.3 Add start/stop functionality for individual bots using threading/multiprocessing
    • 2.4 Create bot status tracking and monitoring system
    • 2.5 Implement error handling and automatic bot restart on crash
    • 2.6 Add bot state persistence to database for system restart recovery
    • 2.7 Create unified signal processing interface for strategy integration
  • 3.0 OKX Integration and Data Pipeline

    • 3.1 Create data/okx_integration.py with OKX API client
    • 3.2 Implement real-time WebSocket connection for market data
    • 3.3 Add market data normalization and validation
    • 3.4 Create data storage pipeline to PostgreSQL with proper indexing
    • 3.5 Implement data feed monitoring and reconnection logic
    • 3.6 Add historical data retrieval for backtesting
    • 3.7 Test data pipeline with multiple cryptocurrency pairs
  • 4.0 Dashboard UI and Visualization

    • 4.1 Set up basic Dash application structure in app.py
    • 4.2 Create dashboard layout with bot controls and chart areas
    • 4.3 Implement bot control panel in components/dashboard.py
    • 4.4 Build candlestick charts with buy/sell markers in components/charts.py
    • 4.5 Add performance metrics display for each bot (balance, P&L, trade count, trade time)
    • 4.6 Implement bot switching functionality for chart views
    • 4.7 Add real-time data updates with 2-second refresh cycle
    • 4.8 Create responsive layout that works on different screen sizes
  • 5.0 Backtesting System Implementation

    • 5.1 Create backtesting/engine.py with backtesting framework
    • 5.2 Implement historical data loading and time range selection
    • 5.3 Add accelerated testing capability (faster than real-time)
    • 5.4 Create backtesting results storage and comparison system
    • 5.5 Integrate backtesting with dashboard for result visualization
    • 5.6 Add date range picker component for backtest periods
    • 5.7 Test backtesting with sample strategies on 1+ week datasets