This analysis examines whether the Hyperliquid trading bot codebase uses Python SDK from Hyperliquid or direct API commands.
The codebase uses both the official Hyperliquid Python SDK and direct API calls strategically.
- Dependencies:
requirements.txtincludeshyperliquid-python-sdk>=1.0.0 - SDK Imports: Multiple imports from the official SDK:
from hyperliquid.exchange import Exchange from hyperliquid.utils.constants import MAINNET_API_URL from hyperliquid.utils.signing import OrderType, LimitOrderType
- SDK Usage: The
HyperliquidClientclass createsExchangeinstances and uses SDK methods:exchange_client = Exchange( wallet=account, base_url=MAINNET_API_URL, account_address=self.api_key )
- Trading operations (
place_order,place_market_order,update_leverage) - Order management (limit orders, market orders)
- Leverage updates
- Position management
- Direct HTTP calls: Uses
requests.get()andrequests.post()in_make_request()method - Info endpoints: All information gathering uses direct API calls:
def get_user_state(self) -> Dict[str, Any]: data = {"type": "clearinghouseState", "user": self.api_key} return self._make_request("/info", data)
- Account information (
get_user_state,get_account_value) - Market data (
get_l2_book,get_candles,get_trades) - Position queries (
get_position) - Order book data
- Historical data
The project follows a two-tier architecture:
- Read-only operations
- Market data retrieval
- Account state queries
- No authentication complexity
- All trading operations
- Order placement
- Position management
- Leverage updates
- Proper signature handling
This is actually a smart architectural choice because:
- SDK for Trading: The official SDK handles complex signature generation and trading operations reliably
- Direct API for Data: Simple HTTP requests are more efficient for read-only data operations
- Reduced Dependencies: Avoids unnecessary SDK overhead for simple data queries
- Better Performance: Direct API calls are faster for market data retrieval
The codebase uses both approaches strategically:
- ✅ Official Hyperliquid Python SDK for all trading operations
- ✅ Direct API calls for information and market data
- ✅ Hybrid architecture that leverages the strengths of both approaches
This is a well-designed implementation that uses the SDK where it's most beneficial (trading) and direct API calls where they're more efficient (data retrieval).
hyperliquid_client.py- Main client with hybrid approachtrading_bot.py- Trading logic using the clienttrade_usdc.py- Interactive trading interfacerequirements.txt- Dependencies includinghyperliquid-python-sdk
- SDK Usage: Trading operations use
Exchangeclass from SDK - Direct API: Information queries use
requestslibrary - Hybrid Client:
HyperliquidClientwraps both approaches - Clean Separation: Trading vs information operations are clearly separated