Complete directory structure and file organization for the Hyperliquid Trading Bot
trader_hyperliquid/
├── 📂 src/ # Source code
│ ├── 🐍 telegram_bot.py # Main Telegram bot
│ ├── 🔗 hyperliquid_client.py # Hyperliquid API client
│ ├── ⚙️ config.py # Configuration management
│ └── 📊 trading_stats.py # Statistics tracking
├── 📂 tests/ # Test suite
│ ├── 📋 README.md # Test documentation
│ ├── 🏃 run_all_tests.py # Test runner
│ ├── 🧪 test_config.py # Configuration tests
│ ├── 💰 test_balance.py # Balance tests
│ ├── 📈 test_perps_commands.py # Trading tests
│ ├── 🚪 test_exit_command.py # Exit command tests
│ └── 📋 test_order_management.py # Order management tests
├── 📂 docs/ # Documentation
│ ├── 📚 README.md # Documentation index
│ ├── 📝 commands.md # Command reference
│ ├── 🚀 setup.md # Setup guide
│ ├── 🏗️ project-structure.md # This file
│ └── 🚀 deployment.md # Deployment guide
├── 📂 config/ # Configuration files
│ └── 📄 .env.example # Environment template
├── 📂 logs/ # Log files
├── 📂 utils/ # Utility scripts
├── 📂 __pycache__/ # Python cache
├── 📂 venv/ # Virtual environment
├── 📄 README.md # Main project README
├── 📄 requirements.txt # Python dependencies
├── 📄 .gitignore # Git ignore rules
├── 🐍 telegram_bot.py # Bot entry point (legacy)
├── 🐍 trading_bot.py # Trading bot (legacy)
└── 📊 demo_stats.py # Demo statistics
Main Telegram bot implementation
Key Classes:
TelegramTradingBot
- Main bot classKey Methods:
start_command()
- Bot startuplong_command()
- Long positionshort_command()
- Short positionexit_command()
- Close positionsorders_command()
- Order managementcoo_command()
- Cancel ordersHyperliquid API client using CCXT
Key Classes:
HyperliquidClient
- API wrapperKey Methods:
get_balance()
- Fetch account balanceget_positions()
- Get open positionsget_open_orders()
- Fetch ordersplace_market_order()
- Market ordersplace_limit_order()
- Limit orderscancel_order()
- Cancel ordersConfiguration management
Key Classes:
Config
- Configuration managerKey Methods:
validate()
- Validate settingsget_hyperliquid_config()
- CCXT configTrading statistics and performance tracking
Key Classes:
TradingStats
- Statistics managerKey Methods:
record_trade()
- Log tradesget_basic_stats()
- Basic metricsformat_stats_message()
- Telegram formattingTest runner for all test modules
Documentation index and navigation
Complete command reference
Quick setup guide
This file - complete project organization
Production deployment guide
Environment variable template
# Hyperliquid API
HYPERLIQUID_PRIVATE_KEY=0x...
HYPERLIQUID_TESTNET=true
# Telegram Bot
TELEGRAM_BOT_TOKEN=...
TELEGRAM_CHAT_ID=...
TELEGRAM_ENABLED=true
# Trading Settings
DEFAULT_TRADING_SYMBOL=BTC/USDC:USDC
DEFAULT_TRADE_AMOUNT=100
LOG_LEVEL=INFO
Demo statistics generator for testing
Sample statistics data
Application log files (created at runtime)
Legacy bot entry point - use src/telegram_bot.py
instead
Legacy trading bot - functionality moved to src/
# Main bot
python src/telegram_bot.py
# Tests
python tests/run_all_tests.py
# Main bot
python -m src.telegram_bot
# Individual tests
python tests/test_config.py
ccxt>=4.2.0
python-telegram-bot>=20.0
python-dotenv>=1.0.0
requests>=2.31.0
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
pip install -r requirements.txt
.env
docs/setup.md
tests/run_all_tests.py
src/
docs/
docs/deployment.md
Happy coding! 🚀📱