Welcome to the AlloraNetwork HyperLiquid Auto Trading Bot! This project leverages AlloraNetwork inference to enable automatic trading on the decentralized exchange HyperLiquid. The bot uses 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.
Before you get started, make sure you have the following:
- HyperLiquid Account:
- Create an account on HyperLiquid.
- Set up your Vault for trading.
- API and Wallet Setup:
- Go to More Options > API in HyperLiquid.
- Generate your Private Key and Wallet Address.
- π Record this information securely.
- Allora API Key:
- Create an API key from the Upshot Developer Portal.
- DeepSeek API Key:
- Obtain your DeepSeek API key for AI-powered trade validation.
- Clone the Repository:
git clone https://github.com/HarbhagwanDhaliwal/Allora_HyperLiquid_AutoTradeBot.git
- Create a Virtual Environment and Activate It:
python3 -m venv venv && source venv/bin/activate
- Install Required Packages:
pip install -r requirements.txt
- Configure the Bot:
- Rename the
.env.example
file to.env
:mv .env.example .env
- Open the
.env
file and update the following fields with your details:# HyperLiquid Credentials HL_SECRET_KEY= # Your HyperLiquid secret key HL_ACCOUNT_ADDRESS= # Your HyperLiquid account address HL_VAULT= # Your HyperLiquid vault identifier # Set to True to run the bot on the mainnet, False for testnet MAINNET=False # DeepSeek API DEEPSEEK_API_KEY= # Your DeepSeek API key # Allora API ALLORA_UPSHOT_KEY= # Your Allora Upshot API key # Trading Parameters PRICE_GAP=0.25 ALLOWED_AMOUNT_PER_TRADE=10 MAX_LEVERAGE=1 CHECK_FOR_TRADES=300 VOLATILITY_THRESHOLD=0.02 # Database DB_PATH=trading_logs.db # Topic IDs BTC_TOPIC_ID=14 ETH_TOPIC_ID=13
- Save the file by pressing
CTRL+X
, thenY
, andEnter
. πΎ
- Rename the
- Running the Bot:
python3 main.py
- PRICE_GAP: The percentage difference between the Allora prediction and the current price to trigger a trade. Example:
0.25
means a 0.25% gap is required to initiate a trade. - ALLOWED_AMOUNT_PER_TRADE: π΅ The maximum amount (in USD) to open a trade. Note: Total trade value will include leverage.
- MAX_LEVERAGE: Leverage multiplier for trades. Example:
1
means 1x leverage. - CHECK_FOR_TRADES: Interval (in seconds) for the bot to check open positions and trading opportunities.
- VOLATILITY_THRESHOLD: The volatility threshold to consider before executing a trade.
- BTC_TOPIC_ID and ETH_TOPIC_ID: Map tradable tokens (e.g., BTC, ETH) to their Allora prediction topic IDs. Ensure tokens match HyperLiquid symbols.
By default, the bot uses a volatility-based strategy to make trading decisions. This strategy evaluates market conditions and Allora's predictions to determine whether to enter or exit trades. The default strategy is implemented in the volatility_strategy
module.
You can define your own custom trading strategy by modifying the custom_strategy
function in strategy/custom_strategy.py
. This function allows you to incorporate your own logic and override the default volatility strategy.
def custom_strategy(token, price=None, allora_signal=None, allora_prediction=None):
"""
Modified custom strategy that trades counter to Allora's predictions
during high volatility periods.
"""
if price is None or allora_signal is None or allora_prediction is None:
return None
# Use the default volatility strategy or implement your own logic here
return volatility_strategy.execute(token, price, allora_signal, allora_prediction)
- Open
strategy/custom_strategy.py
. - Modify the
custom_strategy
function to implement your own logic.
The bot integrates DeepSeek AI as an additional layer of trade validation. This AI reviewer analyzes each potential trade before execution, considering multiple factors:
-
Trade Analysis: Before executing any trade, DeepSeek AI reviews:
- Current price vs Allora prediction
- Market volatility
- Trade direction (BUY/SELL)
- Historical performance in similar conditions
-
Decision Metrics:
approval
(true/false): Whether the trade should proceedconfidence
(0-100): Confidence level in the decisionreasoning
: Detailed explanation of the decisionrisk_score
(1-10): Risk assessment of the trade
-
Trade Requirements:
- Minimum 70% confidence score
- DeepSeek approval must be true
- Risk score is logged for analysis
Trade Review by DeepSeek AI:
Confidence: 85%
Reasoning: "Strong directional alignment between Allora prediction and current market momentum.
Volatility within acceptable range. Recent similar setups showed 70% success rate."
Risk Score: 3/10
- π― Reduced false positives
- π Enhanced risk management
- π§ AI-powered trade validation
- π Detailed trade reasoning
- Allora Prediction: Indicates a "BUY" signal for BTC. π
- Custom Strategy: Evaluates the trade based on your custom logic or the default volatility strategy.
- DeepSeek AI Review:
- Analyzes the trade for risk, confidence, and reasoning.
- Approves the trade if confidence is above 70% and risk is acceptable.
- Bot Action:
- If Allora, Custom Strategy, and DeepSeek AI all agree, the bot executes the trade. β
- If any of the three components disagree, the bot does not execute the trade. β
You can combine the bot with other strategies or modify it further. Just import your custom strategy:
from strategy.custom_strategy import custom_strategy
For any questions, feel free to contact me via GitHub. Donβt forget to give this repository a β if you find it helpful!
This project is open source, and contributions are welcome! If you have ideas for improvements, feel free to fork the repository and submit a pull request. Together, we can make this bot even better. π
Happy Trading! ππ