Skip to content

AlgoHL - Automated trading bot for HyperLiquid exchange. Buy and sell crypto automatically using EMA signals with built-in risk protection.

License

Notifications You must be signed in to change notification settings

alfredalpino/AlgoHL

Repository files navigation

AlgoHL Trading Platform

Python 3.8+ License: MIT HyperLiquid Version

A streamlined algorithmic trading platform for HyperLiquid DEX, focusing on spot trading with technical indicator integration.

πŸš€ Features

  • Direct Exchange Connection: Connect to HyperLiquid mainnet/testnet
  • Spot Trading: Execute market and limit orders with ease
  • Balance Management: Real-time balance tracking
  • Order Management: View, place, and cancel orders
  • Technical Indicators:
    • Customizable EMA (Exponential Moving Average)
  • Automated Trading: Set up automated trading based on indicator signals
  • Clean CLI: Simple and intuitive command-line interface

πŸ“‹ Prerequisites

  • Python 3.8 or higher
  • HyperLiquid account with API credentials
  • Basic understanding of spot trading

πŸ› οΈ Installation

  1. Clone the repository:

    git clone https://github.com/AlwaysUbaid/AlgoHL.git
    cd algohl
  2. Install dependencies:

    pip install -r requirements.txt
  3. Run the setup script:

    python setup.py

    This will:

    • Create your .env file from the template
    • Check all dependencies are installed
    • Validate your Python version
  4. Configure your credentials:

    Edit the .env file with your API credentials:

    # Open .env in your favorite editor
    nano .env  # or vim, code, etc.

    Replace the placeholder values:

    # Mainnet credentials
    MAINNET_WALLET_ADDRESS=0xYOUR_ACTUAL_WALLET_ADDRESS
    MAINNET_PRIVATE_KEY=0xYOUR_ACTUAL_PRIVATE_KEY
    
    # Testnet credentials (optional)
    TESTNET_WALLET_ADDRESS=0xYOUR_TESTNET_WALLET_ADDRESS
    TESTNET_PRIVATE_KEY=0xYOUR_TESTNET_PRIVATE_KEY

    ⚠️ Security Best Practices:

    • Never commit your .env file (it's automatically gitignored)
    • Never share your private keys with anyone
    • Consider using a dedicated trading wallet with limited funds
    • Enable 2FA on your HyperLiquid account

🎯 Quick Start

  1. Run setup (first time only):

    python setup.py
  2. Start the platform:

    python main.py
  3. Connect to exchange:

    >>> connect mainnet
    
  4. Check your balance:

    >>> balance
    
  5. Place a trade:

    >>> buy ETH 0.1
    

πŸ“– Command Reference

Connection Commands

Command Description Example
connect [network] Connect to HyperLiquid connect mainnet
balance Show spot balances balance

Trading Commands

Command Description Example
buy <symbol> <size> [slippage] Market buy order buy ETH 0.1 0.05
sell <symbol> <size> [slippage] Market sell order sell BTC 0.01
limit_buy <symbol> <size> <price> Limit buy order limit_buy ETH 0.1 3000
limit_sell <symbol> <size> <price> Limit sell order limit_sell BTC 0.01 65000

Order Management

Command Description Example
orders [symbol] List open orders orders ETH
cancel <symbol> <order_id> Cancel specific order cancel ETH 123456
cancel_all [symbol] Cancel all orders cancel_all
history [limit] Show trade history history 20

Indicator Trading

Command Description Example
indicators List available indicators indicators
ema <symbol> Set up EMA trading with custom period ema BTC

Utility Commands

Command Description
help Show all commands
clear Clear the screen
exit Exit the application

πŸ”§ Advanced Usage

Command Line Arguments

# Use testnet
python main.py --testnet

# Enable verbose logging
python main.py --verbose

# Log to file
python main.py --log-file trading.log

Trading Examples

Market Buy with Custom Slippage:

>>> buy ETH 0.5 0.03

This buys 0.5 ETH with maximum 3% slippage.

Place Multiple Limit Orders:

>>> limit_buy ETH 0.1 3000
>>> limit_buy ETH 0.2 2950
>>> limit_buy ETH 0.3 2900

Cancel All ETH Orders:

>>> cancel_all ETH

πŸ“Š Technical Indicators

EMA (Exponential Moving Average)

  • Trend-following indicator with customizable period
  • User can set any EMA period (default: 20)
  • Bullish when price is above EMA
  • Bearish when price is below EMA
  • Crossover signals for entry/exit

🎯 Trading Examples

Setting up Custom EMA:

>>> ema BTC
Enter EMA period (default 20): 50
EMA period set to: 50

Current Price: $65,432.10
EMA(50): $64,890.25
Trend: BULLISH

πŸ—οΈ Project Structure

algohl-trading/
β”œβ”€β”€ main.py              # Entry point
β”œβ”€β”€ terminal_ui.py       # CLI interface
β”œβ”€β”€ api_connector.py     # HyperLiquid API connection
β”œβ”€β”€ order_handler.py     # Order execution logic
β”œβ”€β”€ config.py            # Configuration management
β”œβ”€β”€ ema_indicator.py     # EMA indicator
β”œβ”€β”€ setup.py             # Initial setup helper
β”œβ”€β”€ .env.example         # Environment variables template
β”œβ”€β”€ .env                 # Your credentials (create from setup.py)
β”œβ”€β”€ requirements.txt     # Python dependencies
β”œβ”€β”€ .gitignore          # Git ignore file
└── README.md           # This file

πŸ” Security Best Practices

  1. Never share your private keys
  2. Use environment variables for production
  3. Enable 2FA on your HyperLiquid account
  4. Start with small amounts on testnet
  5. Regularly monitor your positions

πŸ› Troubleshooting

Connection Issues:

  • Verify your wallet address and private key
  • Check internet connection
  • Ensure you're using the correct network (mainnet/testnet)

Order Failures:

  • Check available balance
  • Verify symbol format (e.g., ETH, BTC)
  • Ensure price/size parameters are valid

Import Errors:

  • Run pip install -r requirements.txt
  • Check Python version (3.8+)

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

This software is for educational purposes only. Trading cryptocurrencies carries significant risk. Always do your own research and never trade more than you can afford to lose.

πŸ™ Acknowledgments

  • HyperLiquid team for the excellent DEX and API
  • Python community for the amazing libraries
  • All contributors and users of AlgoHL

Made with ❀️ for the HyperLiquid community

About

AlgoHL - Automated trading bot for HyperLiquid exchange. Buy and sell crypto automatically using EMA signals with built-in risk protection.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages