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
│ ├── 🔔 alarm_manager.py # Price alarm management
│ └── 📝 logging_config.py # Logging configuration
├── 📂 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
│ └── 🔧 SYSTEM_INTEGRATION.md # System integration
├── 📂 config/ # Configuration files
│ └── 📄 .env.example # Environment template
├── 📂 logs/ # Log files (auto-created)
├── 📂 utils/ # Utility scripts
│ ├── 🔍 get_telegram_chat_id.py # Chat ID finder
│ ├── 🔍 simple_chat_id.py # Alternative chat ID finder
│ └── 📊 demo_stats.py # Demo statistics
├── 📂 __pycache__/ # Python cache (auto-created)
├── 📂 venv/ # Virtual environment
├── 📄 README.md # Main project README
├── 📄 requirements.txt # Python dependencies
├── 📄 .gitignore # Git ignore rules
├── 📄 .env # Environment configuration
├── 📊 trading_stats.json # Persistent statistics data
└── 🚀 trading_bot.py # Main entry point
Main Telegram bot implementation
Key Classes:
TelegramTradingBot
- Main bot classKey Methods:
start_command()
- Bot startuplong_command()
- Long position with stop loss supportshort_command()
- Short position with stop loss supportexit_command()
- Close positionsorders_command()
- Order managementcoo_command()
- Cancel orderssl_command()
- Manual stop losstp_command()
- Take profit ordersalarm_command()
- Price alertsmonitoring_command()
- System statusperformance_command()
- Token performancerisk_command()
- Risk metricsversion_command()
- System infologs_command()
- Log managementbalance_adjustments_command()
- Deposit/withdrawal historyHyperliquid 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 formattingPrice alarm management system
Key Classes:
AlarmManager
- Alarm managementKey Methods:
create_alarm()
- Create price alertcheck_alarms()
- Monitor pricesremove_alarm()
- Delete alarmget_statistics()
- Alarm statsCentralized logging configuration
Key Functions:
setup_logging()
- Initialize loggingcleanup_logs()
- Remove old logsformat_log_stats()
- Log statisticsTest 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
# 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! 🚀📱