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! ๐๐ฑ