Sfoglia il codice sorgente

Update README.md - Remove outdated references, highlight single-command launcher, CCXT compatibility, and current project structure

Carles Sentis 2 settimane fa
parent
commit
ccf0f9cced
1 ha cambiato i file con 241 aggiunte e 206 eliminazioni
  1. 241 206
      README.md

+ 241 - 206
README.md

@@ -1,270 +1,305 @@
-# ๐Ÿ“ฑ Manual Hyperliquid Trading Bot
+# ๐Ÿš€ Hyperliquid Manual Trading Bot
 
-**Control your Hyperliquid account from your phone with comprehensive trading statistics**
+**Professional-grade manual trading with comprehensive statistics and mobile control**
 
-This bot provides complete manual control of your Hyperliquid account via Telegram, with professional-grade statistics tracking including P&L, win rates, Sharpe ratio, Sortino ratio, and all the metrics you'd expect from a trading platform.
+Complete phone control of your Hyperliquid account via Telegram with institutional-level analytics, auto-restart capabilities, and bulletproof data persistence.
 
-## ๐ŸŽฏ What This Bot Does
+[![CCXT Compatible](https://img.shields.io/badge/CCXT-Compatible-green.svg)](https://github.com/ccxt/ccxt)
+[![Testnet Safe](https://img.shields.io/badge/Testnet-Default-blue.svg)](#)
+[![Mobile First](https://img.shields.io/badge/Mobile-Optimized-purple.svg)](#)
 
-- ๐Ÿ“ฑ **Phone Control**: Trade from anywhere using Telegram commands
-- ๐Ÿ“Š **Comprehensive Stats**: Track all your performance metrics from day one
-- ๐Ÿ’ฐ **Balance Tracking**: Monitor starting vs current balance with real-time P&L
-- ๐Ÿ† **Performance Metrics**: Win rate, profit factor, expectancy, consecutive wins/losses
-- ๐Ÿ“ˆ **Risk Analysis**: Sharpe ratio, Sortino ratio, max drawdown, VaR (95%)
-- ๐Ÿ”„ **Trade History**: Complete trade logging with automatic P&L calculation
-- ๐Ÿ›ก๏ธ **Safety First**: Order confirmations, testnet mode, comprehensive logging
+## ๐ŸŽฏ What This Bot Delivers
 
-## ๐Ÿš€ Quick Start
+### ๐Ÿ“ฑ **Phone Trading**
+- **Complete control** from anywhere via Telegram
+- **One-tap actions** with inline keyboards
+- **Instant notifications** for trades and errors
+- **Mobile-optimized** interface design
 
-### 1. Install Dependencies
-```bash
-# Clone or download this repository
-cd trader_hyperliquid
-
-# Create virtual environment
-python3 -m venv venv
-source venv/bin/activate  # On Windows: venv\Scripts\activate
+### ๐Ÿ“Š **Professional Analytics**
+- **Real-time P&L** tracking with percentage returns
+- **Advanced metrics**: Sharpe ratio, Sortino ratio, VaR (95%)
+- **Trade analytics**: Win rate, profit factor, expectancy
+- **Risk monitoring**: Max drawdown, volatility analysis
+- **Complete audit trail** with order IDs and timestamps
 
-# Install dependencies
-pip install -r requirements.txt
-```
+### ๐Ÿ›ก๏ธ **Bulletproof Reliability**
+- **Auto-restart** on errors (up to 10 attempts)
+- **Persistent statistics** that survive forever
+- **Error notifications** sent to your phone
+- **Comprehensive logging** with daily files
+- **Graceful shutdown** handling
 
-### 2. Set Up Telegram Bot
-1. **Create a bot**: Message [@BotFather](https://t.me/BotFather) on Telegram
-   - Send `/newbot`
-   - Choose a name and username for your bot
-   - Save the bot token
+### โš™๏ธ **CCXT Compatibility**
+- **Standard authentication** following [CCXT patterns](https://github.com/ccxt/ccxt)
+- **Enhanced parameters** support for advanced trading
+- **Future-proof** architecture
+- **Professional configuration** management
 
-2. **Get your Chat ID**: Run the helper script
-   ```bash
-   python get_telegram_chat_id.py
-   ```
-   - Start the script and message your bot
-   - Copy the displayed Chat ID
+## ๐Ÿš€ **Single Command Launch**
 
-### 3. Configure Environment
 ```bash
-# Copy example configuration
-cp env.example .env
-
-# Edit .env with your details
-nano .env  # or use any text editor
+python trading_bot.py
 ```
 
-**Required settings in `.env`:**
-```env
-# Hyperliquid API
-HYPERLIQUID_PRIVATE_KEY=your_private_key_here
-HYPERLIQUID_TESTNET=true
+**That's it!** This one command:
+- โœ… Starts Telegram bot automatically
+- โœ… Handles all errors and restarts
+- โœ… Sends notifications to your phone  
+- โœ… Manages logging and data persistence
+- โœ… Validates configuration before starting
 
-# Telegram Bot
-TELEGRAM_ENABLED=true
-TELEGRAM_BOT_TOKEN=your_bot_token_here
-TELEGRAM_CHAT_ID=your_chat_id_here
+## โšก **Quick Setup (5 Minutes)**
 
-# Trading Settings
-DEFAULT_TRADING_SYMBOL=BTC/USDC:USDC
-DEFAULT_TRADE_AMOUNT=0.001
+### **1. Install & Configure**
+```bash
+# Clone repository
+git clone git@repo.codeskraps.com:codeskraps/ManualTrader.git
+cd ManualTrader
+
+# Setup environment
+python3 -m venv venv
+source venv/bin/activate
+pip install -r requirements.txt
+
+# Configure bot
+cp config/env.example .env
+nano .env  # Add your keys
 ```
 
-### 4. Start Manual Trading
+### **2. Get Telegram Chat ID**
 ```bash
-python manual_trading_bot.py
+# Use the robust script
+python utils/get_telegram_chat_id.py
 ```
 
-## ๐Ÿ“ฑ Using Your Trading Bot
-
-### Quick Actions (Buttons)
-Open Telegram โ†’ Find your bot โ†’ Send `/start`
+### **3. Start Trading!**
+```bash
+python trading_bot.py
+```
 
-You'll see quick action buttons for:
-- ๐Ÿ’ฐ **Balance** - Check account balance with P&L
-- ๐Ÿ“Š **Stats** - Complete trading statistics  
-- ๐Ÿ“ˆ **Positions** - Open positions with unrealized P&L
-- ๐Ÿ“‹ **Orders** - Pending orders
-- ๐Ÿ’ต **Price** - Current market price
-- ๐Ÿ”„ **Recent Trades** - Your trade history
+**๐Ÿ“ฑ Open Telegram โ†’ Send `/start` to your bot**
 
-### Manual Trading Commands
+## ๐Ÿ“ **Clean Project Structure**
 
-**Place Orders:**
 ```
-/buy 0.001 50000    # Buy 0.001 BTC at $50,000
-/sell 0.001 55000   # Sell 0.001 BTC at $55,000
+ManualTrader/
+โ”œโ”€โ”€ ๐Ÿš€ trading_bot.py              # MAIN LAUNCHER (run this!)
+โ”œโ”€โ”€ ๐Ÿ“Š trading_stats.json          # Your persistent statistics  
+โ”œโ”€โ”€ ๐Ÿ“ .env                        # Your configuration
+โ”‚
+โ”œโ”€โ”€ ๐Ÿ”ง src/                        # Core modules
+โ”‚   โ”œโ”€โ”€ config.py                  # CCXT-style configuration
+โ”‚   โ”œโ”€โ”€ hyperliquid_client.py      # Enhanced API wrapper
+โ”‚   โ”œโ”€โ”€ telegram_bot.py            # Mobile-optimized interface
+โ”‚   โ””โ”€โ”€ trading_stats.py           # Professional analytics
+โ”‚
+โ”œโ”€โ”€ ๐Ÿ› ๏ธ utils/                      # Setup & maintenance tools
+โ”‚   โ”œโ”€โ”€ get_telegram_chat_id.py   # Robust Chat ID finder
+โ”‚   โ”œโ”€โ”€ simple_chat_id.py         # Alternative for servers
+โ”‚   โ”œโ”€โ”€ demo_stats.py             # See sample statistics
+โ”‚   โ””โ”€โ”€ [other utilities]
+โ”‚
+โ”œโ”€โ”€ โš™๏ธ config/                     # Configuration templates
+โ”œโ”€โ”€ ๐Ÿ“‹ logs/                       # Auto-created logs & errors
+โ””โ”€โ”€ ๐Ÿ“– Documentation/
 ```
 
-**Monitor Account:**
+## ๐Ÿ“ฑ **Mobile Trading Interface**
+
+### **Quick Commands**
 ```
-/balance     # Account balance + P&L summary
-/positions   # Open positions
-/orders      # Pending orders
-/trades      # Recent trade history
+/start      # Main menu with instant buttons
+/balance    # Real-time balance + P&L
+/stats      # Complete trading statistics
+/positions  # Open positions with P&L
+/orders     # Pending orders
 ```
 
-**View Statistics:**
+### **Trading Commands**
 ```
-/stats       # Complete trading statistics
+/buy 0.001 50000    # Buy 0.001 BTC at $50,000
+/sell 0.001 55000   # Sell 0.001 BTC at $55,000
 ```
 
-## ๐Ÿ“Š Trading Statistics Tracked
-
-### Balance & P&L
-- ๐Ÿ’ฐ **Starting Balance**: Recorded when bot first launches
-- ๐Ÿ’ต **Current Balance**: Real-time balance updates
-- ๐Ÿ“ˆ **Total P&L**: Profit/Loss in USD and percentage
-- ๐Ÿ“… **Days Active**: Time since first launch
-
-### Performance Metrics  
-- ๐Ÿ† **Win Rate**: Percentage of profitable trades
-- ๐Ÿ’Ž **Profit Factor**: Total gains รท Total losses
-- ๏ฟฝ๏ฟฝ **Average Win/Loss**: Mean profit/loss per trade
-- ๐ŸŽฏ **Expectancy**: Expected value per trade
-- ๐Ÿ”ฅ **Consecutive Wins/Losses**: Streak tracking
-
-### Risk Metrics
-- ๐Ÿ“Š **Sharpe Ratio**: Risk-adjusted returns
-- ๐Ÿ“‰ **Sortino Ratio**: Downside risk-adjusted returns  
-- ๐Ÿ“ˆ **Max Drawdown**: Largest peak-to-trough decline
-- ๐ŸŒช๏ธ **Volatility**: Annualized price volatility
-- โš ๏ธ **VaR (95%)**: Value at Risk (95% confidence)
-
-### Trade Analytics
-- ๐Ÿ“ **Total Trades**: Complete trade count
-- ๐Ÿ”„ **Buy/Sell Breakdown**: Order type distribution
-- ๐ŸŽฏ **Best/Worst Trades**: Largest wins and losses
-- ๐Ÿ“Š **Trade History**: Complete audit trail with order IDs
-
-## ๐Ÿ›ก๏ธ Safety Features
-
-### Testnet First
-- Starts in testnet mode by default
-- Test all features before using real money
-- Clear warnings when switching to mainnet
-
-### Order Confirmations
-- All trades require explicit confirmation
-- Clear order details before execution
-- Easy cancellation option
-
-### Comprehensive Logging
-- All actions logged with timestamps
-- Trade history automatically saved
-- Statistics persist between bot restarts
-
-### Risk Management
-- Balance tracking for drawdown monitoring
-- Real-time P&L calculations
-- Risk metrics to assess performance
-
-## ๐Ÿ“ˆ Sample Statistics Output
+### **Instant Action Buttons**
+Send `/start` for one-tap access to:
+- ๐Ÿ’ฐ Balance, ๐Ÿ“Š Stats, ๐Ÿ“ˆ Positions, ๐Ÿ“‹ Orders, ๐Ÿ’ต Price
+
+## ๐Ÿ“Š **Professional Statistics**
 
 ```
 ๐Ÿ“Š Trading Statistics
 
 ๐Ÿ’ฐ Balance Overview
-โ€ข Initial: $1,000.00
-โ€ข Current: $1,150.00  
-โ€ข Total P&L: $150.00
-โ€ข Total Return: 15.00%
-
-๐Ÿ“ˆ Trading Activity
-โ€ข Total Trades: 25
-โ€ข Buy Orders: 13
+โ€ข Initial: $1,000.00        โ† Starting balance (never lost)
+โ€ข Current: $1,150.00        โ† Real-time balance
+โ€ข Total P&L: $150.00        โ† Profit/Loss
+โ€ข Total Return: 15.00%      โ† Percentage return
+
+๐Ÿ“ˆ Trading Activity  
+โ€ข Total Trades: 25          โ† Complete trade count
+โ€ข Buy Orders: 13            โ† Order breakdown
 โ€ข Sell Orders: 12
-โ€ข Days Active: 30
+โ€ข Days Active: 30           โ† Since first launch
 
 ๐Ÿ† Performance Metrics
-โ€ข Win Rate: 68.0%
-โ€ข Profit Factor: 2.15
-โ€ข Avg Win: $45.50
-โ€ข Avg Loss: $28.75
-โ€ข Expectancy: $6.25
+โ€ข Win Rate: 68.0%           โ† Profitable trades %
+โ€ข Profit Factor: 2.15       โ† Gains รท Losses
+โ€ข Avg Win: $45.50           โ† Average winning trade
+โ€ข Avg Loss: $28.75          โ† Average losing trade
+โ€ข Expectancy: $6.25         โ† Expected $ per trade
 
 ๐Ÿ“Š Risk Metrics
-โ€ข Sharpe Ratio: 1.85
-โ€ข Sortino Ratio: 2.41
-โ€ข Max Drawdown: 8.5%
-โ€ข Volatility: 12.3%
-โ€ข VaR (95%): 3.2%
-
-๐ŸŽฏ Best/Worst
-โ€ข Largest Win: $125.00
-โ€ข Largest Loss: $75.00
-โ€ข Max Consecutive Wins: 5
-โ€ข Max Consecutive Losses: 2
-
-๐Ÿ“… Since: 2024-01-15
+โ€ข Sharpe Ratio: 1.85        โ† Risk-adjusted returns
+โ€ข Sortino Ratio: 2.41       โ† Downside risk metric
+โ€ข Max Drawdown: 8.5%        โ† Worst decline from peak
+โ€ข Volatility: 12.3%         โ† Price volatility
+โ€ข VaR (95%): 3.2%          โ† Value at Risk
+
+๐ŸŽฏ Best/Worst Performance
+โ€ข Largest Win: $125.00      โ† Best single trade
+โ€ข Largest Loss: $75.00      โ† Worst single trade
+โ€ข Max Consecutive Wins: 5   โ† Winning streaks
+โ€ข Max Consecutive Losses: 2 โ† Losing streaks
+
+๐Ÿ“… Tracking Since: 2024-01-15
 ```
 
-## ๐Ÿ”ง Files Overview
+## โš™๏ธ **CCXT-Style Configuration**
 
-| File | Purpose |
-|------|---------|
-| `manual_trading_bot.py` | **Main launcher** - Start this for manual trading |
-| `telegram_bot.py` | Telegram interface with trading commands |
-| `trading_stats.py` | Comprehensive statistics tracking |
-| `hyperliquid_client.py` | Hyperliquid API wrapper |
-| `config.py` | Configuration management |
-| `get_telegram_chat_id.py` | Helper to find your Chat ID |
-| `trading_stats.json` | Your trading statistics (auto-created) |
+Following [CCXT standards](https://github.com/ccxt/ccxt) for exchange compatibility:
 
-## โš™๏ธ Advanced Configuration
-
-### Custom Trading Symbol
 ```env
-DEFAULT_TRADING_SYMBOL=ETH/USDC:USDC
-```
+# Hyperliquid API (CCXT Style)
+HYPERLIQUID_PRIVATE_KEY=your_private_key_here
+HYPERLIQUID_SECRET_KEY=your_secret_key_here
+HYPERLIQUID_TESTNET=true
 
-### Adjust Default Trade Size
-```env
-DEFAULT_TRADE_AMOUNT=0.01
-```
+# Telegram Bot
+TELEGRAM_BOT_TOKEN=your_token_from_botfather
+TELEGRAM_CHAT_ID=your_chat_id_here
+TELEGRAM_ENABLED=true
 
-### Logging Level
-```env
-LOG_LEVEL=INFO  # DEBUG, INFO, WARNING, ERROR
+# Trading Settings
+DEFAULT_TRADING_SYMBOL=BTC/USDC:USDC
+DEFAULT_TRADE_AMOUNT=0.001
 ```
 
-## ๐Ÿ” Troubleshooting
+## ๐Ÿ›ก๏ธ **Built-in Safety Features**
 
-### Bot Won't Start
+### **๐Ÿ“Š Data Protection**
+- **Statistics never lost** - saved to `trading_stats.json`
+- **Automatic backups** via comprehensive logging
+- **Persistent between restarts** - your data survives forever
+
+### **๐Ÿ”„ Error Recovery**
+- **Auto-restart** up to 10 attempts with exponential backoff
+- **Telegram error notifications** sent to your phone
+- **Comprehensive logging** to daily files
+- **Graceful shutdown** on Ctrl+C
+
+### **โš ๏ธ Trading Safety**
+- **Testnet default** - safe testing environment
+- **Order confirmations** - all trades require approval
+- **Balance monitoring** - real-time P&L tracking
+- **Clear error messages** with troubleshooting tips
+
+## ๐ŸŽฎ **Demo & Testing**
+
+### **See Sample Statistics**
 ```bash
-# Check configuration
-python -c "from config import Config; Config.validate()"
+python utils/demo_stats.py
+```
+Shows you exactly what metrics the bot will track.
 
-# Check Telegram setup
-python get_telegram_chat_id.py
+### **Test Configuration**
+```bash
+python -c "import sys; sys.path.insert(0, 'src'); from config import Config; Config.validate()"
 ```
 
-### Telegram Not Responding
-1. Verify bot token with BotFather
-2. Ensure Chat ID is correct
-3. Check that bot is started in Telegram
+### **Alternative Chat ID Finder**
+```bash
+# If the main script has issues
+python utils/simple_chat_id.py
+```
 
-### Trading Issues
-1. Confirm sufficient balance
-2. Check order parameters
-3. Verify network connectivity
+## ๐Ÿ”ง **Key Features**
+
+### **Mobile-First Design**
+- ๐Ÿ“ฑ **Complete phone control** via Telegram
+- ๐Ÿ”˜ **One-tap buttons** for quick actions
+- ๐Ÿ“Š **HTML-formatted** messages with emojis
+- ๐Ÿ“ฑ **Instant notifications** for errors and updates
+
+### **Professional Analytics**
+- ๐Ÿ“ˆ **Institutional-grade metrics** (Sharpe, Sortino, VaR)
+- ๐Ÿ’ฐ **FIFO P&L calculation** for accurate tracking
+- ๐Ÿ“Š **Real-time balance** monitoring
+- ๐ŸŽฏ **Complete trade history** with audit trails
+
+### **Robust Architecture**
+- ๐Ÿ”„ **Auto-restart capability** with error notifications
+- ๐Ÿ’พ **Persistent data storage** that survives restarts
+- ๐Ÿ›ก๏ธ **Comprehensive error handling** and logging
+- โš™๏ธ **CCXT-compatible** configuration and parameters
+
+## ๐Ÿ“– **Documentation**
+
+| Guide | Purpose |
+|-------|---------|
+| [SETUP_GUIDE.md](SETUP_GUIDE.md) | **5-minute setup** with step-by-step instructions |
+| [QUICK_START.md](QUICK_START.md) | **Your questions answered** - persistence, structure, safety |
+| [PROJECT_STRUCTURE.md](PROJECT_STRUCTURE.md) | **Folder organization** and file purposes |
+| [DEPLOYMENT_GUIDE.md](DEPLOYMENT_GUIDE.md) | **Production deployment** options and best practices |
+
+## ๐Ÿšจ **Important Notes**
 
-## ๐ŸŒ Network Modes
+### **Start with Testnet**
+- Bot defaults to **testnet mode** (safe testing)
+- Get testnet keys from [Hyperliquid Testnet](https://app.hyperliquid-testnet.xyz/)
+- Switch to mainnet only when fully tested
 
-### Testnet (Default)
-- Safe testing environment
-- No real money at risk
-- Perfect for learning
+### **Your Keys**
+- **Private Key**: From Hyperliquid account settings
+- **Secret Key**: May be optional depending on implementation
+- **Keep secure** - never share your private keys
 
-### Mainnet (Production)
-- Real money trading
-- Requires explicit confirmation
-- Use with caution
+### **Statistics Persistence**
+- โœ… **YES** - All statistics are permanently saved
+- โœ… **Survives restarts** - data loads automatically
+- โœ… **Never lost** - comprehensive backup via logging
 
-## ๐Ÿ“ž Support
+## ๐Ÿ” **Troubleshooting**
+
+### **Bot Won't Start**
+```bash
+# Check configuration
+python -c "import sys; sys.path.insert(0, 'src'); from config import Config; Config.validate()"
+
+# Try alternative Chat ID finder
+python utils/simple_chat_id.py
+```
+
+### **Telegram Issues**
+1. Verify bot token from @BotFather
+2. Ensure you messaged your bot first
+3. Check Chat ID with utility scripts
+
+### **Trading Problems**
+1. Confirm sufficient balance
+2. Verify network connectivity
+3. Check logs in `logs/` directory
 
-This bot is designed for manual trading control via phone. All features are focused on giving you complete control over your Hyperliquid account with professional-grade statistics tracking.
+## ๐ŸŽฏ **What Makes This Special**
 
-For technical issues:
-1. Check configuration with validation commands
-2. Review log files for error details
-3. Ensure all dependencies are installed
+- **๐Ÿš€ One command** - `python trading_bot.py` runs everything
+- **๐Ÿ“ฑ Professional mobile interface** - institutional-grade phone trading
+- **๐Ÿ“Š Complete analytics** - every metric you need from day one
+- **๐Ÿ›ก๏ธ Bulletproof reliability** - auto-restart with error notifications
+- **๐Ÿ’พ Never lose data** - statistics persist forever
+- **โš™๏ธ CCXT compatible** - follows industry standards
+- **๐Ÿงน Clean organization** - logical folder structure
+- **๐Ÿ“– Complete documentation** - guides for every use case
 
-**Happy trading! ๐Ÿš€๐Ÿ“ฑ** 
+**Get institutional-grade trading infrastructure with simple phone control! ๐Ÿš€๐Ÿ“ฑ**