Explorar el Código

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

Carles Sentis hace 6 días
padre
commit
ccf0f9cced
Se han modificado 1 ficheros con 241 adiciones y 206 borrados
  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! 🚀📱**