whchien/ai-trader/add-strategy
Claude Code and agent skill by whchien/ai-trader
- community
Checking that the SKILL.md file is still in the repository.
Create a new trading strategy for the ai-trader backtesting framework. Handles file creation, registration, docstrings, and backtest scaffolding.
Install
npx vskill@latest install whchien/ai-trader/add-strategySKILL.md
add-strategy Skill
Create a new trading strategy for the ai-trader backtesting framework with automatic file generation, registration, and validation.
Overview
This skill automates the creation of trading strategies following established patterns in the ai-trader project. It handles:
- File creation with proper naming conventions (PascalCase class → snake_case filename)
- Comprehensive docstrings (module and class level)
- Parameter validation and defaults
- Automatic registration in
__init__.pyfiles - Standalone backtest scaffolding
- Pre-flight validation for name conflicts and custom indicators
Two strategy types are supported:
- Classic: Single-stock strategies (e.g., DoubleTopStrategy, BBandsStrategy)
- Portfolio: Multi-asset rotation strategies (e.g., ROCRotationStrategy, MultiBBandsRotationStrategy)
Interactive Workflow
The skill guides you through the following steps:
Step 1: Strategy Type
Confirm whether this is a classic (single-stock) or portfolio (multi-asset) strategy.
Step 2: Name & Description
- Provide the strategy name in PascalCase (e.g., "MACDBBands")
- Provide a 1-2 sentence description
- The skill automatically converts to snake_case for the filename (macd_bbands.py)
Step 3: Parameters
Define parameters as comma-separated name=value pairs:
- Example:
fast=12, slow=26, signal=9, bb_period=20 - All parameters must have default values
- Parameter names must be valid Python identifiers
Step 4: Entry & Exit Logic
- Describe the entry condition (buy signal)
- Describe the exit condition (sell signal)
- For portfolio strategies, describe rotation/rebalancing logic
Step 5: Custom Indicators (Optional)
If your strategy uses custom indicators from indicators.py, list them:
- Available: DoubleTop, RSRS, NormRSRS, RecentHigh, TripleRSI, etc.
- The skill verifies they exist and generates the import statement
Step 6: Preview & Confirmation
Review the generated file structure before creation:
- Target file path
- Class name and type
- Parameters
- Files to be modified (__init__.py imports and __all__)
Step 7: Creation & Verification
The skill creates:
- Strategy file with complete structure
- Updates imports and __all__ list in __init__.py
- Validates syntax by attempting import
- Shows git status for verification
Usage Examples
Creating a Classic Strategy
Creating a Portfolio Strategy
File Templates
Classic Strategy Template
Portfolio Strategy Template
Registration Logic
When creating a strategy, the skill updates the appropriate __init__.py file:
Example for classic/macd_bbands.py:
Key points:
- Imports are added in alphabetical order by filename
__all__list is maintained in alphabetical order- Existing structure and formatting are preserved
Validation
Pre-Creation Checks
- Name Validation:
- Class name must be PascalCase (e.g., MACDBBands)
- Converts to snake_case for filename (macd_bbands.py)
- No file exists at target path
- Class name not already in
__all__
- Type Validation:
- Strategy type is "classic" or "portfolio"
- Target directory exists
- Parameter Validation:
- All parameters have default values
- Parameter names are valid Python identifiers
- No reserved Python keywords as parameter names
- Indicator Validation:
- If custom indicators mentioned, verify they exist in indicators.py
- Generate correct import statements
Post-Creation Verification
- File created successfully
- Imports added to
__init__.py - Name added to
__all__list in correct position - File is syntactically valid (test import)
- Git recognizes new/modified files
Next Steps After Creation
- Review Generated Code:
- The generated template provides the structure; you'll add the specific trading logic
- Implement
next()method with your trading signals - For portfolio strategies, implement
_is_buy_signal()and_is_exit_signal()
- Test Standalone:
``bash python ai_trader/backtesting/strategies/classic/your_strategy.py ``
- Refine Parameters:
- Update default values based on backtesting results
- Add parameter optimization later if needed
- Integration Testing:
``bash ai-trader quick YourStrategyName your_data.csv ``
- Commit Changes:
``bash git add ai_trader/backtesting/strategies/classic/your_strategy.py git add ai_trader/backtesting/strategies/classic/__init__.py git commit -m "Add YourStrategyName strategy" ``
Related Documentation
- PATTERNS.md - Complete examples of implemented strategies with annotations
- CONVENTIONS.md - Naming rules, import ordering, parameter format, docstring structure
- VALIDATION.md - Detailed validation rules and error handling
Tips & Best Practices
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/add-strategy/SKILL.md
Popularity
- Repository stars
- 1,094
- Repository forks
- 147
- 7-day trend score
- 35
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 19 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/whchien/ai-trader/add-strategy)