Requirements
- Target platform
- OpenClaw
- Install method
- Manual import
- Extraction
- Extract archive
- Prerequisites
- OpenClaw
- Primary doc
- SKILL.md
Generate executable Hyperliquid trading strategy code from natural language prompts. Use when a user wants to create automated trading strategies for Hyperliquid exchange based on their trading ideas, technical indicators, or VibeTrading signals. The skill generates complete Python code with proper error handling, logging, and configuration using actual Hyperliquid API wrappers.
Generate executable Hyperliquid trading strategy code from natural language prompts. Use when a user wants to create automated trading strategies for Hyperliquid exchange based on their trading ideas, technical indicators, or VibeTrading signals. The skill generates complete Python code with proper error handling, logging, and configuration using actual Hyperliquid API wrappers.
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete.
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run.
Generate executable Hyperliquid trading strategy code from natural language prompts. This skill transforms trading ideas into ready-to-run Python code using actual Hyperliquid API implementations. Generated code includes complete API integration, error handling, logging, and configuration management.
# Generate a simple RSI strategy python scripts/strategy_generator.py "Generate a BTC RSI strategy, buy below 30, sell above 70" # Generate a grid trading strategy python scripts/strategy_generator.py "BTC grid trading 50000-60000 10 grids 0.01 BTC per grid" # Generate a signal-following strategy python scripts/strategy_generator.py "ETH trading strategy based on VibeTrading signals, buy on bullish signals, sell on bearish signals"
The generator creates: Strategy Python file - Complete trading strategy class Configuration file - Strategy parameters and settings Usage instructions - How to run and monitor the strategy Requirements file - Python dependencies
All generated code is automatically validated and fixed using the built-in validation system: # Validate generated code python scripts/code_validator.py generated_strategy.py # Validate and fix automatically python scripts/code_validator.py generated_strategy.py --fix # Validate entire directory python scripts/code_validator.py strategy_directory/
The validation system performs these checks: Syntax Validation - Python syntax checking Import Validation - Module import verification Compatibility Checks - Python 3.5+ compatibility Common Issue Detection - Missing imports, encoding issues, etc.
When validation fails, the system automatically fixes common issues: Add missing imports - Add typing imports if type annotations are used Fix encoding declaration - Add # -*- coding: utf-8 -*- if missing Remove incompatible syntax - Remove f-strings and type annotations for Python 3.5 compatibility Fix import paths - Add sys.path modifications for API wrappers Fix logger initialization order - Ensure logger is initialized before API client Remove pathlib usage - Replace with os.path for Python 3.4 compatibility Fix string formatting - Convert f-strings to .format() method
The validation system can be configured via command-line arguments: # Basic validation python scripts/code_validator.py strategy.py # Validate and fix automatically python scripts/code_validator.py strategy.py --fix # Use specific Python executable python scripts/code_validator.py strategy.py --python python3.6 # Validate directory with all files python scripts/code_validator.py strategies/ --fix # Maximum 5 fix iterations python scripts/code_validator.py strategy.py --fix --max-iterations 5
The system enforces these rules for generated code: Python 3.5+ Compatibility No f-strings (use .format() or % formatting) No type annotations (remove or use comments) No pathlib (use os.path instead) No typing module imports Code Quality Proper encoding declaration (# -*- coding: utf-8 -*-) Logger initialized before API client All imports are resolvable No syntax errors Security API keys loaded from environment variables No hardcoded credentials Proper error handling for API calls Performance Reasonable check intervals (not too frequent) Efficient data fetching Proper resource cleanup
User Prompt โ Code Generation โ Validation โ Fixes โ Final Code โ If validation fails โ Apply automatic fixes โ Re-validate until success โ Deliver validated code
When validation fails, the system automatically updates the code with these steps: Error Analysis - Identify the specific validation errors Fix Application - Apply appropriate fixes based on error type Re-validation - Validate again after fixes Iterative Repair - Repeat until code is valid (max 3 iterations) Fallback Strategy - If automatic fixes fail, provide detailed error report and manual fix instructions
Fix 1: Missing Imports # Before (error: NameError: name 'List' is not defined) def calculate_prices(prices: List[float]) -> List[float]: # After (automatic fix) from typing import List, Dict, Optional def calculate_prices(prices): Fix 2: Encoding Issues # Before (error: SyntaxError: Non-ASCII character) # Strategy description: Grid trading # After (automatic fix) # -*- coding: utf-8 -*- # Strategy description: Grid trading Fix 3: Python 3.5 Incompatibility # Before (error: SyntaxError in Python 3.5) price = f"Current price: {current_price}" # After (automatic fix) price = "Current price: {}".format(current_price) Fix 4: Import Path Issues # Before (error: ImportError: No module named 'hyperliquid_api') from hyperliquid_api import HyperliquidClient # After (automatic fix) import sys import os sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "api_wrappers")) from hyperliquid_api import HyperliquidClient
RSI-based: Oversold/overbought trading MACD-based: Trend following with MACD crossovers Moving Average: SMA/EMA cross strategies Bollinger Bands: Mean reversion strategies
Grid Trading: Price range trading with multiple orders Mean Reversion: Statistical arbitrage strategies Trend Following: Momentum-based strategies Arbitrage: Spot-perp or cross-exchange arbitrage
VibeTrading Integration: Follow AI-generated trading signals News-based: React to market news and sentiment Whale Activity: Track large wallet movements Funding Rate: Funding rate arbitrage strategies
The generator analyzes your natural language prompt to identify: Trading symbol (BTC, ETH, SOL, etc.) Strategy type (grid, RSI, signal-based, etc.) Key parameters (price ranges, grid counts, indicator values) Risk management preferences
Based on the analysis, the system selects the most appropriate template from: templates/grid_trading.py - Grid trading strategy template
The generator: Fills template parameters with your values Adds proper error handling and logging Includes configuration management Generates complete runnable code
The generated code is automatically validated and fixed: Syntax checking - Ensure valid Python syntax Import verification - Check all imports are resolvable Compatibility testing - Verify Python 3.5+ compatibility Automatic fixes - Apply fixes for common issues Re-validation - Validate again after fixes Error reporting - If fixes fail, provide detailed error report
If validation fails after automatic fixes: Error Analysis Report - Detailed breakdown of remaining issues Manual Fix Instructions - Step-by-step guidance for manual fixes Fallback Template - Option to use a simpler, validated template Support Contact - Instructions for getting help
You receive validated, runnable code including: Validated Python strategy file - Fully tested and fixed Configuration template - Strategy parameters and settings Validation report - Summary of validation results and fixes applied Usage instructions - How to run and monitor the strategy Troubleshooting guide - Common issues and solutions Risk warnings - Important safety information
The generated code uses mature Hyperliquid API implementations that support:
Spot trading (buy/sell with limit/market orders) Perpetual contracts (long/short with leverage) Order management (cancel, modify, query) Position management (reduce, hedge)
Real-time prices and OHLCV data Funding rates and open interest Order book depth Historical data access
Balance queries (spot and futures) Position tracking PNL calculation Risk metrics
Each template includes: Strategy class with initialization and main logic Configuration section for easy parameter tuning Error handling with comprehensive logging Risk management features Monitoring loop for continuous operation
Grid Trading Template grid_trading.py - Grid trading within price ranges (Python 3.5+ compatible) No f-strings No type annotations Proper encoding declaration Logger initialized before API client
Generated strategies include configurable parameters: STRATEGY_CONFIG = { "symbol": "BTC", "timeframe": "1h", "parameters": { "rsi_period": 14, "oversold": 30, "overbought": 70 }, "risk_management": { "position_size": 0.01, "stop_loss": 0.05, "take_profit": 0.10, "max_drawdown": 0.20 } }
# Required environment variables export HYPERLIQUID_API_KEY="your_api_key_here" export HYPERLIQUID_ACCOUNT_ADDRESS="your_address_here" export TELEGRAM_BOT_TOKEN="optional_for_alerts"
All generated strategies include:
Fixed percentage of portfolio Dynamic position sizing based on volatility Maximum position limits
Percentage-based stop loss Trailing stops Time-based exits
Maximum daily loss limits Drawdown protection Correlation checks Market condition filters
Real-time position tracking Telegram/Slack notifications Performance reporting Error alerts and recovery
Generated strategies can integrate with VibeTrading Global Signals: from vibetrading import get_latest_signals # Get AI-generated signals signals = get_latest_signals("BTC,ETH") # Use signals in trading logic if signals["BTC"]["sentiment"] == "BULLISH": strategy.execute_buy("BTC", amount=0.01)
Prompt: "Generate a BTC RSI strategy, buy 0.01 BTC when RSI below 30, sell when above 70" Generated Code Features: RSI calculation with 14-period default Configurable oversold/overbought thresholds Proper error handling for API calls Logging for all trading actions 1-hour check interval
Prompt: "ETH grid trading strategy, price range 3000-4000, 20 grids, 0.1 ETH per grid" Generated Code Features: Automatic grid price calculation Order placement and management Grid rebalancing logic Price monitoring and adjustment Comprehensive logging
Prompt: "SOL trading strategy based on VibeTrading signals, buy on bullish signals, sell on bearish signals, 10 SOL per trade" Generated Code Features: VibeTrading API integration Signal polling and parsing Trade execution based on sentiment Position management Performance tracking
Always test strategies in simulation mode first Use small position sizes initially Monitor performance for at least 1-2 weeks
Never risk more than 1-2% per trade Use stop losses on all positions Diversify across multiple strategies Monitor correlation between strategies
Regularly review strategy performance Adjust parameters based on market conditions Keep logs for audit and analysis Set up alerts for critical events
Store API keys securely (environment variables) Use separate accounts for different strategies Regularly rotate API keys Monitor for unauthorized access
1. API Connection Errors # Check API key and account address echo $HYPERLIQUID_API_KEY echo $HYPERLIQUID_ACCOUNT_ADDRESS # Test API connection python scripts/test_connection.py 2. Strategy Not Executing Trades Check balance and available funds Verify symbol is correctly specified Check order size meets minimum requirements Review logs for error messages 3. Performance Issues Adjust check intervals (too frequent may cause rate limiting) Optimize data fetching (cache where possible) Review market conditions (low liquidity periods) 4. Integration Issues with VibeTrading Verify VibeTrading API is accessible Check signal availability for your symbols Review signal parsing logic 5. Validation Errors # Common validation errors and solutions: # Error: "SyntaxError: invalid syntax" # Solution: Check for f-strings or type annotations python scripts/code_validator.py strategy.py --fix # Error: "ImportError: No module named 'typing'" # Solution: Remove typing imports (Python 3.4 compatibility) sed -i '' 's/from typing import.*//g' strategy.py # Error: "SyntaxError: Non-ASCII character" # Solution: Add encoding declaration echo -e '# -*- coding: utf-8 -*-\n' | cat - strategy.py > temp && mv temp strategy.py # Error: "NameError: name 'List' is not defined" # Solution: Remove type annotations or add typing import sed -i '' 's/: List//g; s/: Dict//g; s/: Optional//g' strategy.py # Manual validation check python -m py_compile strategy.py 6. Code Generation Failures Check prompt clarity (be specific about parameters) Ensure template exists for requested strategy type Verify Python version compatibility (3.5+ recommended) Check available disk space for output files
You can create custom templates in templates/custom/: Create a new template file Define template variables with {{variable_name}} Add to template registry in scripts/template_registry.py Test with the generator
While this generator focuses on live trading, you can: Export generated code to backtesting frameworks Use historical data for strategy validation Add performance metrics and analysis
For running multiple strategies: Generate separate strategy files Use different configuration files Monitor overall portfolio risk Implement strategy allocation logic
Review generated code comments Check example strategies in examples/ Consult Hyperliquid API documentation Review VibeTrading signal documentation
This skill will be updated with: New strategy templates Improved prompt understanding Additional risk management features Integration with more data sources
After generating a strategy, you can now evaluate its performance using our integrated backtesting system: # Generate a strategy python scripts/strategy_generator.py "BTC grid trading 50000-60000 10 grids 0.01 BTC per grid" # Run backtest on the generated strategy python scripts/backtest_runner.py generated_strategies/btc_grid_trading_strategy.py # Run backtest with custom parameters python scripts/backtest_runner.py generated_strategies/btc_grid_trading_strategy.py \ --start-date 2025-01-01 \ --end-date 2025-03-01 \ --initial-balance 10000 \ --interval 1h
The backtesting system provides: Historical Data Simulation - Uses historical price data for realistic testing Performance Metrics - Calculates key metrics: Total Return (%) Maximum Drawdown (%) Sharpe Ratio Win Rate (%) Total Trades Average Trade Duration Risk Analysis - Evaluates strategy risk characteristics Visual Reports - Generates charts and performance reports Comparative Analysis - Compares strategy performance against benchmarks
You can configure backtests with these parameters: BACKTEST_CONFIG = { "start_date": "2025-01-01", "end_date": "2025-03-01", "initial_balance": 10000, # USDC "interval": "1h", # 1m, 5m, 15m, 30m, 1h, 4h, 1d "symbols": ["BTC", "ETH"], # Trading symbols "commission_rate": 0.001, # 0.1% trading commission "slippage": 0.001, # 0.1% slippage }
๐ Backtest Results for BTC Grid Trading Strategy ================================================ ๐ Period: 2025-01-01 to 2025-03-01 (60 days) ๐ฐ Initial Balance: $10,000.00 ๐ฐ Final Balance: $11,234.56 ๐ Performance Metrics: โข Total Return: +12.35% โข Max Drawdown: -5.67% โข Sharpe Ratio: 1.45 โข Win Rate: 58.3% โข Total Trades: 120 โข Avg Trade Duration: 12.5 hours ๐ Trade Analysis: โข Winning Trades: 70 โข Losing Trades: 50 โข Largest Win: +$245.67 โข Largest Loss: -$123.45 โข Avg Win: +$89.12 โข Avg Loss: -$56.78 โ ๏ธ Risk Assessment: โข Risk-Adjusted Return: Good โข Drawdown Control: Acceptable โข Consistency: Moderate
Generated strategies now include backtest compatibility: # Generated strategy includes backtest method strategy = GridTradingStrategy(api_key, account_address, config) # Run backtest backtest_results = strategy.run_backtest( start_date="2025-01-01", end_date="2025-03-01", initial_balance=10000 ) # Generate backtest report strategy.generate_backtest_report(backtest_results)
The backtesting system uses: Historical price data from Hyperliquid API Realistic order execution with configurable slippage Accurate commission modeling based on exchange fees Market impact simulation for large orders
Important Notes: Past performance โ future results - Historical success doesn't guarantee future profits Data quality - Results depend on historical data accuracy Market conditions - Past market conditions may differ from future Execution assumptions - Assumes perfect order execution (configurable slippage) Liquidity assumptions - Assumes sufficient market liquidity Best Practices: Always backtest with multiple time periods Test different market conditions (bull, bear, sideways) Use realistic commission and slippage settings Start with small position sizes in live trading Monitor strategy performance and adjust as needed
Validation Limitations: While the code validation system automatically fixes common issues, it cannot guarantee: Trading logic correctness - Validation checks syntax, not trading logic Financial performance - No guarantee of profitability API compatibility - Hyperliquid API changes may break generated code Security vulnerabilities - Manual security review is recommended Edge case handling - All possible error conditions may not be covered Validation Success Criteria: Code is considered "valid" when: No syntax errors All imports are resolvable Python 3.6+ compatible Basic structure is correct Not Validated: Trading logic accuracy Risk management effectiveness Financial calculations Market condition handling Performance optimization
# Check Python version python scripts/check_python_version.py # Minimum: Python 3.6+ (for f-string support)
# Generate strategy python scripts/strategy_generator.py "BTC grid trading 50000-60000 10 grids" # Run backtest python scripts/backtest_runner.py generated_strategies/btc_grid_trading_strategy.py
Python 3.6+ Compatibility - Modern Python features including f-strings Automatic Backtest Integration - Evaluate strategies before live trading Comprehensive Validation - Syntax and compatibility checking Risk Management - Built-in risk controls in all strategies
Important: Trading cryptocurrencies involves significant risk. Generated strategies should be thoroughly tested before use with real funds. Past performance is not indicative of future results. Always use proper risk management and never trade with money you cannot afford to lose. The code generator provides tools for strategy creation, but ultimate responsibility for trading decisions and risk management lies with the user. Validation is not a substitute for: Thorough testing - Always test in simulation first Code review - Have experienced developers review generated code Security audit - Check for vulnerabilities before deployment Performance testing - Test under various market conditions Risk assessment - Evaluate strategy risks independently Backtesting Limitations: Historical data quality - Results depend on data accuracy Market condition changes - Past conditions may differ from future Execution assumptions - Assumes perfect order execution Liquidity assumptions - Assumes sufficient market liquidity No guarantee of future performance - Past success โ future profits
Code helpers, APIs, CLIs, browser automation, testing, and developer operations.
Largest current source with strong distribution and engagement signals.