# Automated Crypto Trading Bot This project is a sophisticated, multi-process automated trading bot designed to interact with the Hyperliquid decentralized exchange. It features a robust data pipeline, a flexible strategy engine, multi-agent trade execution, and a live terminal dashboard for real-time monitoring. ## Features * **Multi-Process Architecture**: Core components (data fetching, trading, strategies) run in parallel processes for maximum performance and stability. * **Comprehensive Data Pipeline**: * Live price feeds for all assets. * Historical candle data collection for any coin and timeframe. * Historical market cap data fetching from the CoinGecko API. * **High-Performance Database**: Uses SQLite with pandas for fast, indexed storage and retrieval of all market data. * **Configuration-Driven Strategies**: Trading strategies are defined and managed in a simple JSON file (`_data/strategies.json`), allowing for easy configuration without code changes. * **Multi-Agent Trading**: Supports multiple, independent trading agents for advanced risk segregation and PNL tracking. * **Live Terminal Dashboard**: A real-time, flicker-free dashboard to monitor live prices, market caps, strategy signals, and the status of all background processes. * **Secure Key Management**: Uses a `.env` file to securely manage all private keys and API keys, keeping them separate from the codebase. ## Project Structure The project is composed of several key scripts that work together: * **`main_app.py`**: The central orchestrator. It launches all background processes and displays the main monitoring dashboard. * **`trade_executor.py`**: The trading "brain." It reads signals from all active strategies and executes trades using the appropriate agent. * **`data_fetcher.py`**: A background service that collects 1-minute historical candle data and saves it to the SQLite database. * **`resampler.py`**: A background service that reads the 1-minute data and generates all other required timeframes (e.g., 5m, 1h, 1d). * **`market_cap_fetcher.py`**: A scheduled service to download daily market cap data. * **`strategy_*.py`**: Individual files containing the logic for different types of trading strategies (e.g., SMA Crossover). * **`_data/strategies.json`**: The configuration file for defining and enabling/disabling your trading strategies. * **`.env`**: The secure file for storing all your private keys and API keys. ## Installation 1. **Clone the Repository** ```bash git clone [https://github.com/your-username/your-repo-name.git](https://github.com/your-username/your-repo-name.git) cd your-repo-name ``` 2. **Create and Activate a Virtual Environment** ```bash # For Windows python -m venv .venv .\.venv\Scripts\activate # For macOS/Linux python3 -m venv .venv source .venv/bin/activate ``` 3. **Install Dependencies** ```bash pip install -r requirements.txt ``` ## Getting Started: Configuration Before running the application, you must configure your wallets, agents, and API keys. 1. Create the .env File In the root of the project, create a file named .env. Copy the following content into it and replace the placeholder values with your actual keys. 2. **Activate Your Main Wallet on Hyperliquid** The `trade_executor.py` script will fail if your main wallet is not registered. * Go to the Hyperliquid website, connect your main wallet, and make a small deposit. This is a one-time setup step. 3. **Create and Authorize Trading Agents** The `trade_executor.py` uses secure "agent" keys that can trade but cannot withdraw. You need to generate these and authorize them with your main wallet. * Run the `create_agent.py` script ```bash python create_agent.py ``` The script will output a new Agent Private Key. Copy this key and add it to your .env file (e.g., as SCALPER_AGENT_PK). Repeat this for each agent you want to create. 4. **Configure** Your Strategies Open the `_data/strategies.json` file to define which strategies you want to run. * Set "enabled": true to activate a strategy. * Assign an "agent" (e.g., "scalper", "swing") to each strategy. The agent name must correspond to a key in your .env file (e.g., SCALPER_AGENT_PK -> "scalper"). * Configure the parameters for each strategy, such as the coin, timeframe, and any indicator settings. ##Usage## Once everything is configured, you can run the main application from your terminal: ```bash python main_app.py ``` ## Documentation Detailed project documentation is available in the `WIKI/` directory. Start with the summary page: `WIKI/SUMMARY.md` This contains links and explanations for `OVERVIEW.md`, `SETUP.md`, `SCRIPTS.md`, and other helpful pages that describe usage, data layout, agent management, development notes, and troubleshooting.