# Crypto Trading Bot Dashboard

A simple control dashboard for managing and monitoring multiple cryptocurrency trading bots simultaneously. Test different trading strategies in parallel using real OKX market data and virtual trading simulation.

## Features

- **Multi-Bot Management**: Run up to 5 trading bots simultaneously with different strategies
- **Real-time Monitoring**: Live price charts with bot buy/sell decision markers
- **Performance Tracking**: Monitor virtual balance, P&L, trade count, and timing for each bot
- **Backtesting**: Test strategies on historical data with accelerated execution
- **Simple Configuration**: JSON-based bot configuration files
- **Hot Reloading**: System remembers active bots and restores state on restart

## Tech Stack

- **Backend**: Python with existing OKX, strategy, and trader modules
- **Frontend**: Plotly Dash for rapid development
- **Database**: PostgreSQL with SQLAlchemy ORM
- **Package Management**: UV
- **Development**: Docker for consistent environment

## Quick Start

### Prerequisites

- Python 3.10+
- Docker and Docker Compose
- UV package manager

### Development Setup

*Complete setup workflow*

```
python scripts/dev.py setup        # Setup environment and dependencies
python scripts/dev.py start        # Start Docker services
uv run python tests/test_setup.py  # Verify everything works
```

*Development workflow*
```
python scripts/dev.py dev-server   # Start with hot reload (recommended)
python scripts/dev.py run          # Start without hot reload
python scripts/dev.py status       # Check service status
python scripts/dev.py stop         # Stop services
```

*Dependency management*
```
uv add "new-package>=1.0.0"        # Add new dependency
uv sync --dev                      # Install all dependencies
```

## Project Structure

```
Dashboard/
├── app.py                    # Main Dash application
├── bot_manager.py           # Bot lifecycle management
├── database/
│   ├── models.py           # SQLAlchemy models
│   └── connection.py       # Database connection
├── data/
│   └── okx_integration.py  # OKX API integration
├── components/
│   ├── dashboard.py        # Dashboard components
│   └── charts.py          # Chart components
├── backtesting/
│   └── engine.py          # Backtesting framework
├── config/
│   └── bot_configs/       # Bot configuration files
├── strategies/            # Trading strategy modules
├── trader/               # Virtual trading logic
└── docs/                 # Project documentation
```

## Documentation

- **[Product Requirements](tasks/prd-crypto-bot-dashboard.md)** - Detailed project requirements and specifications
- **[Implementation Tasks](tasks/tasks-prd-crypto-bot-dashboard.md)** - Step-by-step development task list
- **[API Documentation](docs/)** - Module and API documentation

## Bot Configuration

Create bot configuration files in `config/bot_configs/`:

```json
{
  "bot_id": "ema_crossover_01",
  "strategy": "EMA_Crossover", 
  "parameters": {
    "fast_period": 12,
    "slow_period": 26,
    "symbol": "BTC-USDT"
  },
  "virtual_balance": 10000
}
```

## Development Status

This project is in active development. See the [task list](tasks/tasks-prd-crypto-bot-dashboard.md) for current implementation progress.

### Current Phase: Setup and Infrastructure
- [ ] Development environment setup
- [ ] Database schema design
- [ ] Basic bot management system
- [ ] OKX integration
- [ ] Dashboard UI implementation
- [ ] Backtesting framework

## Contributing

1. Check the [task list](tasks/tasks-prd-crypto-bot-dashboard.md) for available tasks
2. Follow the project's coding standards and architectural patterns
3. Use UV for package management
4. Write tests for new functionality
5. Update documentation when adding features
