hyperliquid-trading-agent  by sanketagarwal

LLM-powered perpetual futures trading agent

Created 3 weeks ago

New!

326 stars

Top 83.6% on SourcePulse

GitHubView on GitHub
Project Summary

Summary

This project provides an AI-powered trading agent designed for executing perpetual futures trades on the Hyperliquid exchange. It targets users interested in leveraging advanced AI models like Claude for market analysis and automated trading across a wide range of crypto and TradFi assets. The primary benefit is an automated trading system that combines sophisticated market analysis with robust, code-enforced risk management.

How It Works

The agent operates in iterative loops, fetching real-time account state and market candle data. It locally computes a suite of technical indicators (EMA, RSI, MACD, etc.) for selected assets. This comprehensive market context, along with defined risk parameters, is then sent to the Claude LLM, which generates trading decisions (buy/sell/hold) including allocation, take-profit, and stop-loss levels. A dedicated risk manager validates these decisions against hard-coded safety guards before executing trades via the Hyperliquid API.

Quick Start & Requirements

  • Primary Install: pip install hyperliquid-python-sdk anthropic python-dotenv aiohttp requests
  • Run Command: python3 src/main.py
  • Prerequisites: Python 3.12+, Anthropic API key, Hyperliquid wallet (main wallet with funds and a separate agent wallet authorized as a signer).
  • Configuration: Requires editing a .env file with API keys and wallet addresses. Key environment variables include ANTHROPIC_API_KEY, HYPERLIQUID_PRIVATE_KEY, HYPERLIQUID_VAULT_ADDRESS, ASSETS, and INTERVAL.
  • Agent Wallet Setup: Authorize the agent wallet address as a signer in Hyperliquid's API Wallets settings.
  • Links: Hyperliquid setup: app.hyperliquid.xyz. Dashboard source: dashboard/ directory.

Highlighted Details

  • Market Coverage: Supports over 229 Hyperliquid perpetual markets and HIP-3 TradFi assets, including cryptocurrencies, stocks (e.g., TSLA, NVDA), commodities (e.g., GOLD, BRENTOIL), indices (e.g., SP500), and forex.
  • Comprehensive Safety Guards: Enforces strict risk controls in code, including Max Position Size (10%), Force Close (-20% loss), Max Leverage (10x), Total Exposure (50%), Daily Circuit Breaker (-10% drawdown), Mandatory Stop-Loss (5%), Max Positions (10), and Balance Reserve (20%).
  • Local Dashboard: Includes a separate Next.js dashboard for real-time PnL and trade monitoring.
  • API Endpoints: Exposes /diary for trade logs and /logs for LLM request history when running.

Maintenance & Community

No specific details regarding maintainers, community channels (like Discord/Slack), or project roadmaps are provided in the README.

Licensing & Compatibility

The project operates under a "Use at your own risk" disclaimer with no explicit open-source license mentioned. Compatibility is primarily with the Hyperliquid exchange and its supported HIP-3 markets. Commercial use is implicitly discouraged due to the lack of guarantees and audits.

Limitations & Caveats

This code has not undergone formal auditing, and its use carries inherent financial risk, with no guarantee of returns. The project is presented as-is, and users assume full responsibility for any trading outcomes.

Health Check
Last Commit

3 weeks ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
3
Star History
327 stars in the last 22 days

Explore Similar Projects

Feedback? Help us improve.