# PolyHermes [![GitHub](https://img.shields.io/badge/GitHub-WrBug%2FPolyHermes-blue?logo=github)](https://github.com/WrBug/PolyHermes) [![Twitter](https://img.shields.io/badge/Twitter-@polyhermes-blue?logo=twitter)](https://x.com/polyhermes) [![Docker](https://img.shields.io/docker/v/wrbug/polyhermes?label=Docker&logo=docker)](https://hub.docker.com/r/wrbug/polyhermes) > 🌐 **Language**: English | [δΈ­ζ–‡](README.md) A powerful copy trading system for Polymarket prediction markets, supporting automated copy trading, multi-account management, real-time order push, and statistical analysis. --- ## πŸ“‹ Table of Contents - [Part 1: Product Features](#part-1-product-features) - [Part 2: How to Deploy](#part-2-how-to-deploy) - [Part 3: Development Documentation](#part-3-development-documentation) --- ## Part 1: Product Features ### πŸ“Έ Interface Preview #### πŸ–₯️ Desktop
#### πŸ“± Mobile
### ✨ Core Features #### πŸ” Account Management - **Multi-Account Support**: Import multiple wallet accounts via private keys for unified management - **Secure Storage**: Private keys and API credentials are encrypted and stored securely - **Account Information**: View detailed account information including balance, positions, and transaction history - **Account Editing**: Support for modifying account names, setting default accounts, etc. #### πŸ‘₯ Leader Management - **Add Leaders**: Add wallet addresses of traders to copy (Leaders) - **Category Filtering**: Support filtering by category (sports/crypto) - **Leader Information**: View trading history and statistics of Leaders - **Note Management**: Add notes to Leaders for easy identification and management #### πŸ“Š Copy Trading Templates - **Flexible Configuration**: Create copy trading templates and configure copy trading parameters - **Copy Trading Modes**: Support proportional copy trading and fixed amount copy trading - **Risk Control**: Configure daily loss limits, order count limits, price tolerance, etc. - **Template Reuse**: One template can be used for multiple copy trading relationships #### πŸ”„ Copy Trading Configuration - **Relationship Management**: Associate accounts, templates, and Leaders to create copy trading relationships - **Enable/Disable**: Flexibly control the enabled state of copy trading relationships - **Automatic Copy Trading**: Real-time monitoring of Leader trades, automatically copying orders (supports buy and sell) - **Order Tracking**: Complete order lifecycle tracking, including buy, sell, and match records #### πŸ“ˆ Order Management - **Buy Orders**: View detailed information of all buy orders - **Sell Orders**: View detailed information of all sell orders - **Matched Orders**: View matched order records - **Order Filtering**: Support filtering by account, Leader, time range, and other conditions #### πŸ’Ό Position Management - **Real-Time Positions**: View and manage positions of all accounts in real-time - **Position Push**: Real-time position changes via WebSocket - **Sell Positions**: Support market and limit price selling of positions - **Redeem Positions**: Support batch redemption of settled positions #### πŸ“Š Statistical Analysis - **Global Statistics**: View aggregated statistics of all copy trading relationships - **Leader Statistics**: View statistics of specific Leaders - **Category Statistics**: View statistics by category (sports/crypto) - **Copy Trading Relationship Statistics**: View detailed statistics of individual copy trading relationships - **Time Filtering**: Support filtering statistics by time range #### βš™οΈ System Management - **Proxy Configuration**: Configure HTTP proxy through Web UI without modifying environment variables - **API Health Check**: Real-time monitoring of Polymarket API health status - **User Management**: Manage system users, support adding, editing, and deleting users - **Announcement Management**: View system announcements and update information ### πŸš€ Technical Features - **WebSocket Real-Time Push**: Real-time push of order and position data without manual refresh - **Secure Storage**: Private keys and API credentials stored using AES encryption - **Responsive Design**: Perfect support for mobile and desktop, providing a consistent user experience - **High Performance**: Asynchronous processing, concurrency optimization, support for large-scale order processing - **Risk Control**: Multiple risk control mechanisms including daily loss limits, order count limits, price tolerance, etc. - **Multi-Language Support**: Support for Chinese (Simplified/Traditional) and English - **Version Management**: Automatic version number display and management, support for GitHub Releases auto-build ### πŸ—οΈ Tech Stack #### Backend - **Framework**: Spring Boot 3.2.0 - **Language**: Kotlin 1.9.20 - **Database**: MySQL 8.2.0 - **ORM**: Spring Data JPA - **Database Migration**: Flyway - **HTTP Client**: Retrofit 2.9.0 + OkHttp 4.12.0 - **WebSocket**: Spring WebSocket #### Frontend - **Framework**: React 18 + TypeScript - **Build Tool**: Vite - **UI Library**: Ant Design 5.12.0 - **HTTP Client**: axios - **State Management**: Zustand - **Routing**: React Router 6 - **Ethereum Library**: ethers.js 6.9.0 - **Internationalization**: react-i18next --- ## Part 2: How to Deploy ### πŸš€ Quick Deployment #### All-in-One Deployment (Recommended) Deploy both frontend and backend together in a single Docker container, using Nginx to serve frontend static files and proxy backend API. **Prerequisites**: - Docker 20.10+ - Docker Compose 2.0+ **Deployment Steps**: #### ⚑ One-Liner Installation (Fastest, Recommended for New Users) **Using curl (Recommended):** ```bash mkdir -p ~/polyhermes && cd ~/polyhermes && curl -fsSL https://raw.githubusercontent.com/WrBug/PolyHermes/main/deploy-interactive.sh -o deploy.sh && chmod +x deploy.sh && ./deploy.sh ``` **Using wget:** ```bash mkdir -p ~/polyhermes && cd ~/polyhermes && wget -O deploy.sh https://raw.githubusercontent.com/WrBug/PolyHermes/main/deploy-interactive.sh && chmod +x deploy.sh && ./deploy.sh ``` This command will automatically: - πŸ“ Create dedicated working directory `~/polyhermes` - βœ… Automatically check Docker environment - βš™οΈ Interactive configuration for all parameters (supports pressing Enter for defaults) - πŸ” Automatically generate secure random keys - πŸš€ Automatically download latest images and deploy --- #### πŸ“‹ Alternative Deployment Methods 1. **Using Docker Hub Images (Recommended, Production First Choice)** **Method 1: Standalone Deployment (No code clone required, Recommended)** Suitable for production environments, no need to download project code, only two files needed for deployment: ```bash # 1. Create deployment directory mkdir polyhermes && cd polyhermes # 2. Download production environment configuration files # Download docker-compose.prod.yml and docker-compose.prod.env.example from GitHub curl -O https://raw.githubusercontent.com/WrBug/PolyHermes/main/docker-compose.prod.yml curl -O https://raw.githubusercontent.com/WrBug/PolyHermes/main/docker-compose.prod.env.example # 3. Create configuration file cp docker-compose.prod.env.example .env # 4. Edit .env file, modify the following required configurations: # - DB_PASSWORD: Database password # - JWT_SECRET: Generate using openssl rand -hex 64 # - ADMIN_RESET_PASSWORD_KEY: Generate using openssl rand -hex 32 # 5. Start services docker-compose -f docker-compose.prod.yml up -d # 6. View logs docker-compose -f docker-compose.prod.yml logs -f # 7. Stop services docker-compose -f docker-compose.prod.yml down ``` **Method 2: Using Deployment Script (Requires code clone)** ```bash # If you have already cloned the code ./deploy.sh --use-docker-hub ``` **Method 3: Modify Existing docker-compose.yml** ```bash # 1. Modify docker-compose.yml, uncomment: # image: wrbug/polyhermes:latest # and comment out the build section # 2. Create .env file (see below) # 3. Start services docker-compose up -d ``` **Advantages**: - βœ… No local build required, fast deployment - βœ… No code clone required, only configuration files needed for deployment - βœ… Uses officially built images with correct version numbers - βœ… Supports multiple architectures (amd64, arm64), automatically selects matching architecture - βœ… Recommended for production environments **Pull Specific Version**: ```bash # Modify the image tag in docker-compose.prod.yml # image: wrbug/polyhermes:v1.0.0 ``` **Update Docker Version**: ```bash # 1. Stop current containers docker-compose -f docker-compose.prod.yml down # 2. Pull latest image docker pull wrbug/polyhermes:latest # 3. Restart services docker-compose -f docker-compose.prod.yml up -d # Or update to specific version (e.g., v1.0.1) # Modify image tag in docker-compose.prod.yml to: image: wrbug/polyhermes:v1.0.1 # Then run: docker-compose -f docker-compose.prod.yml up -d ``` For detailed update instructions, please refer to: [Deployment Guide - Update Docker Version](docs/en/DEPLOYMENT.md#update-docker-version) 2. **Local Build Deployment (Development Environment)** ```bash # Use deployment script ./deploy.sh ``` The script will automatically: - Check Docker environment - Create `.env` configuration file (if it doesn't exist) - Build Docker image (including frontend and backend) - Start services (application + MySQL) 3. **Manual Deployment** ```bash # Create .env file cat > .env <