# ๐Ÿ“ฑ Manual Hyperliquid Trading Bot **Control your Hyperliquid account from your phone with comprehensive trading statistics** 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. ## ๐ŸŽฏ What This Bot Does - ๐Ÿ“ฑ **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 ## ๐Ÿš€ Quick Start ### 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 # Install dependencies pip install -r requirements.txt ``` ### 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 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 ### 3. Configure Environment ```bash # Copy example configuration cp env.example .env # Edit .env with your details nano .env # or use any text editor ``` **Required settings in `.env`:** ```env # Hyperliquid API HYPERLIQUID_PRIVATE_KEY=your_private_key_here HYPERLIQUID_TESTNET=true # Telegram Bot TELEGRAM_ENABLED=true TELEGRAM_BOT_TOKEN=your_bot_token_here TELEGRAM_CHAT_ID=your_chat_id_here # Trading Settings DEFAULT_TRADING_SYMBOL=BTC/USDC:USDC DEFAULT_TRADE_AMOUNT=0.001 ``` ### 4. Start Manual Trading ```bash python manual_trading_bot.py ``` ## ๐Ÿ“ฑ Using Your Trading Bot ### Quick Actions (Buttons) Open Telegram โ†’ Find your bot โ†’ Send `/start` 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 ### Manual Trading Commands **Place Orders:** ``` /buy 0.001 50000 # Buy 0.001 BTC at $50,000 /sell 0.001 55000 # Sell 0.001 BTC at $55,000 ``` **Monitor Account:** ``` /balance # Account balance + P&L summary /positions # Open positions /orders # Pending orders /trades # Recent trade history ``` **View Statistics:** ``` /stats # Complete trading statistics ``` ## ๐Ÿ“Š 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 ``` ๐Ÿ“Š 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 โ€ข Sell Orders: 12 โ€ข Days Active: 30 ๐Ÿ† Performance Metrics โ€ข Win Rate: 68.0% โ€ข Profit Factor: 2.15 โ€ข Avg Win: $45.50 โ€ข Avg Loss: $28.75 โ€ข Expectancy: $6.25 ๐Ÿ“Š 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 ``` ## ๐Ÿ”ง Files Overview | 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) | ## โš™๏ธ Advanced Configuration ### Custom Trading Symbol ```env DEFAULT_TRADING_SYMBOL=ETH/USDC:USDC ``` ### Adjust Default Trade Size ```env DEFAULT_TRADE_AMOUNT=0.01 ``` ### Logging Level ```env LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR ``` ## ๐Ÿ” Troubleshooting ### Bot Won't Start ```bash # Check configuration python -c "from config import Config; Config.validate()" # Check Telegram setup python get_telegram_chat_id.py ``` ### Telegram Not Responding 1. Verify bot token with BotFather 2. Ensure Chat ID is correct 3. Check that bot is started in Telegram ### Trading Issues 1. Confirm sufficient balance 2. Check order parameters 3. Verify network connectivity ## ๐ŸŒ Network Modes ### Testnet (Default) - Safe testing environment - No real money at risk - Perfect for learning ### Mainnet (Production) - Real money trading - Requires explicit confirmation - Use with caution ## ๐Ÿ“ž Support 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. For technical issues: 1. Check configuration with validation commands 2. Review log files for error details 3. Ensure all dependencies are installed **Happy trading! ๐Ÿš€๐Ÿ“ฑ**