Skip to content

This repository provides an AI-powered trading bot leveraging AlloraNetwork for automatic trading on HyperLiquid decentralized exchange. The bot integrates predictive insights and customizable strategies for seamless trading. 🌟

Notifications You must be signed in to change notification settings

HarbhagwanDhaliwal/Allora_HyperLiquid_AutoTradeBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

34 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ AlloraNetwork, HyperLiquid & DeepSeek AI Auto Trade Bot

Welcome to the AlloraNetwork HyperLiquid Auto Trading Bot! This project leverages AlloraNetwork inference to enable automatic trading on the decentralized exchange HyperLiquid. The bot utilizes AI-driven predictions from AlloraNetwork, combined with DeepSeek AI trade validation, to make informed trading decisions based on customizable strategies. πŸ“ˆπŸ€–

By default, the bot uses a volatility-based strategy, but you can define your own custom strategy to suit your trading preferences.


πŸ› οΈ Prerequisites

Before you get started, make sure you have the following:

  1. HyperLiquid Account:
    • Create an account on HyperLiquid.
    • Set up your Vault for trading.
  2. API and Wallet Setup:
    • Go to More Options > API in HyperLiquid.
    • Generate your Private Key and Wallet Address.
    • πŸ”’ Securely store this information.
  3. Allora API Key:
  4. DeepSeek API Key:
    • Get your DeepSeek API key for AI-powered trade validation.

HyperLiquid API Setup


πŸš€ Installation

  1. Clone the Repository:
    git clone https://github.com/HarbhagwanDhaliwal/Allora_HyperLiquid_AutoTradeBot.git
  2. Create a Virtual Environment and Activate It:
    python3 -m venv venv && source venv/bin/activate
  3. Install Required Packages:
    pip install -r requirements.txt
  4. Configure the Bot:
    • Rename the .env.example file to .env:
      mv .env.example .env
    • Open the .env file and update the fields with your details:
      # HyperLiquid Credentials
      HL_SECRET_KEY=        # Enter your HyperLiquid secret key  
      HL_ACCOUNT_ADDRESS=   # Enter your HyperLiquid account address  
      
      # Vault Configuration  
      HL_VAULT=             # Enter your HyperLiquid vault identifier  
      
      # Master Address Configuration  
      HL_MASTER_ADDRESS=    # Enter your MetaMask wallet address  
      
      # Network Selection  
      MAINNET=False  # Set to True for mainnet, False for testnet  
      
      # API Keys  
      DEEPSEEK_API_KEY=     # Enter your DeepSeek API key  
      ALLORA_UPSHOT_KEY=    # Enter your Allora API key  
      
      # Trading Parameters  
      PRICE_GAP=0.25                        # Minimum price gap for trades  
      ALLOWED_AMOUNT_PER_TRADE=10            # Maximum amount per trade  
      MAX_LEVERAGE=1                         # Maximum leverage allowed  
      CHECK_FOR_TRADES=300                    # Interval (seconds) to check for trades  
      VOLATILITY_THRESHOLD=0.02               # Volatility threshold for trade execution  
      
      # Database Configuration  
      DB_PATH=trading_logs.db                # Path to the trading database  
      
      # Topic IDs (Asset Identifiers)  
      BTC_TOPIC_ID=14                         # Bitcoin topic ID  
      ETH_TOPIC_ID=13                         # Ethereum topic ID  
    • Save the file (CTRL+X, then Y, and Enter). πŸ’Ύ
  5. Run the Bot:
    python3 main.py

βš™οΈ Configuration Details

  • PRICE_GAP: Percentage difference between Allora's prediction and the current price required to trigger a trade.
  • ALLOWED_AMOUNT_PER_TRADE: πŸ’΅ Maximum amount (in USD) for each trade, excluding leverage.
  • MAX_LEVERAGE: Maximum leverage multiplier (e.g., 1 for 1x leverage).
  • CHECK_FOR_TRADES: Time interval (in seconds) for the bot to check for trading opportunities.
  • VOLATILITY_THRESHOLD: Minimum volatility level required before a trade executes.
  • BTC_TOPIC_ID and ETH_TOPIC_ID: Mapping of tradable tokens to their Allora prediction topic IDs.

🧠 Default Volatility Strategy

By default, the bot employs a volatility-based strategy to analyze market conditions and Allora's predictions to execute trades. The strategy is implemented in the volatility_strategy module.


πŸ› οΈ Custom Strategy

Modify custom_strategy.py to create a personalized trading strategy.

Example Custom Strategy

def custom_strategy(token, price=None, allora_signal=None, allora_prediction=None):
    """
    Custom strategy that trades against Allora’s predictions in high-volatility conditions.
    """
    if price is None or allora_signal is None or allora_prediction is None:
        return None
    
    return volatility_strategy.execute(token, price, allora_signal, allora_prediction)

How to Use

  1. Open strategy/custom_strategy.py.
  2. Modify custom_strategy to implement your own logic.

πŸ€– DeepSeek AI Trade Reviewer

The bot integrates DeepSeek AI for trade validation. It assesses trade risk, confidence, and reasoning before execution.

How It Works

  1. Trade Analysis:

    • Current price vs. Allora prediction
    • Market volatility
    • Trade direction (BUY/SELL)
    • Historical performance
  2. Decision Metrics:

    • approval (true/false): Trade approval status
    • confidence (0-100): Confidence level in the trade
    • reasoning: Explanation of the trade decision
    • risk_score (1-10): Trade risk assessment
  3. Trade Execution Criteria:

    • Confidence score β‰₯ 70%
    • DeepSeek AI approval βœ…
    • Risk score logged for tracking

Example Output

Trade Review by DeepSeek AI:
  Confidence: 85%
  Reasoning: "Allora prediction aligns with market trends.
              Volatility stable. Historical success rate: 70%."
  Risk Score: 3/10

πŸ”„ Example Workflow

  1. Allora Prediction: "BUY" signal detected for BTC.
  2. Custom Strategy: Evaluates trade feasibility.
  3. DeepSeek AI Review: Validates trade based on risk, confidence, and reasoning.
  4. Bot Action:
    • βœ… If Allora, Custom Strategy, and DeepSeek AI agree β†’ Trade executed.
    • ❌ If any disagree β†’ Trade rejected.

πŸ’¬ Support

For questions, reach out via GitHub. If this project helps you, consider giving it a ⭐!


🀝 Contribute

This project is open source! Feel free to fork the repo, improve the bot, and submit a pull request. 🌟


Happy Trading! πŸš€πŸ“ˆ

About

This repository provides an AI-powered trading bot leveraging AlloraNetwork for automatic trading on HyperLiquid decentralized exchange. The bot integrates predictive insights and customizable strategies for seamless trading. 🌟

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages