Skip to content

Ryan-Clinton/Freqtrade-Strategy-Analyser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FreqTrade Strategy Analyzer

A comprehensive tool for analyzing FreqTrade trading strategies, detecting issues, and generating detailed reports in multiple formats.

Python License Status

πŸš€ Features

  • πŸ” Comprehensive Analysis: Detects lookahead bias, global variables, memory leaks, and more
  • πŸ“Š Multiple Output Formats: Text, CSV, JSON, Markdown, and HTML reports
  • 🎨 Visual Dashboard: Beautiful HTML reports with color-coded ratings
  • ⚑ Bulk Processing: Analyze hundreds of strategies recursively
  • πŸ”§ Hyperopt Detection: Identifies optimization capabilities
  • πŸ“ˆ Statistics & Insights: Common issues and feature adoption metrics

πŸ“‹ What It Detects

Critical Issues

  • Lookahead Bias: dataframe.iloc[-1] usage and similar patterns
  • Global Variables: Dangerous global state that can cause issues
  • Dangerous Operations: Risky code patterns like exec(), eval()

Warnings

  • Hardcoded Values: Non-parameterized constants that should be optimizable
  • Memory Leaks: Growing data structures without cleanup
  • Missing Error Handling: Risky operations without try/catch blocks

Features Analysis

  • Strategy Structure: Required/optional methods validation
  • Optimization Capability: Hyperopt parameter detection
  • Indicators Used: Technical analysis indicators catalog

πŸ› οΈ Installation

Option 1: Clone Repository

git clone https://github.com/Facepipe/Freqtrade-Strategy-Analyser.git
cd Freqtrade-Strategy-Analyser
pip install -r requirements.txt

Option 2: Direct Download

wget https://raw.githubusercontent.com/Facepipe/Freqtrade-Strategy-Analyser/main/src/strategy_analyzer.py
chmod +x strategy_analyzer.py

πŸ“– Usage

Basic Analysis

# Analyze all strategies in a directory
python src/strategy_analyzer.py /path/to/strategies/

# Generate all output formats
python src/strategy_analyzer.py /path/to/strategies/ --all-formats

# Specific format outputs
python src/strategy_analyzer.py /path/to/strategies/ --csv summary.csv
python src/strategy_analyzer.py /path/to/strategies/ --html report.html

Output Formats

Format Best For Description
Text Detailed analysis Traditional comprehensive report
CSV Excel analysis Sortable data for spreadsheets
HTML Visual overview Interactive dashboard with charts
Markdown Documentation GitHub-friendly formatted report
JSON Integration Raw data for other tools

Command Line Options

python src/strategy_analyzer.py [directory] [options]

Arguments:
  directory              Directory to analyze recursively

Options:
  -o, --output FILE      Output file for report
  -f, --format FORMAT    Output format: text, csv, json, markdown, html
  --csv FILE            Export summary as CSV
  --json FILE           Export detailed results as JSON
  --markdown FILE       Export as Markdown
  --html FILE           Export as HTML
  --all-formats         Generate all formats with auto-naming
  -h, --help            Show help message

πŸ“Š Example Output

Quick Summary

πŸ“Š Total strategies: 465
βœ… Valid: 421 (90.5%)
🟒 Excellent: 23
πŸ”΅ Good: 186
🟑 Poor: 212
πŸ”΄ Broken: 44

Strategy Rating System

  • 🟒 Excellent: Well-structured, hyperoptable, no major issues
  • πŸ”΅ Good: Minor issues, functional, ready for use
  • 🟑 Poor: Multiple warnings, needs improvement
  • πŸ”΄ Broken: Critical issues, should not be used

🎯 Use Cases

For Strategy Developers

  • Code Quality: Identify and fix issues in your strategies
  • Best Practices: Learn from analysis recommendations
  • Optimization: Ensure strategies are hyperopt-ready

For Strategy Collections

  • Bulk Analysis: Analyze entire strategy repositories
  • Quality Assessment: Find the best strategies quickly
  • Issue Tracking: Identify common problems across strategies

For Trading Teams

  • Due Diligence: Vet strategies before deployment
  • Performance: Ensure strategies meet quality standards
  • Documentation: Generate reports for strategy reviews

πŸ”§ Configuration

The analyzer uses pattern matching to detect issues. You can customize detection patterns by modifying the StrategyAnalyzer class:

# Example: Add custom pattern detection
self.critical_patterns['custom_issue'] = [
    r'your_custom_pattern_here'
]

πŸ“ Examples

Analyzing FreqTrade Strategies Repository

# Clone the community strategies
git clone https://github.com/freqtrade/freqtrade-strategies.git

# Analyze all strategies
python src/strategy_analyzer.py freqtrade-strategies/user_data/strategies/ --all-formats

# Results in:
# - strategy_analysis.txt (detailed report)
# - strategy_analysis.csv (Excel-ready data)
# - strategy_analysis.html (visual dashboard)
# - strategy_analysis.md (GitHub documentation)
# - strategy_analysis.json (raw data)

Finding Excellent Strategies

# Generate CSV and open in Excel/LibreOffice
python src/strategy_analyzer.py strategies/ --csv results.csv

# Filter by rating="excellent" and critical_issues=0
# Sort by parameter_count (desc) for most optimizable strategies

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

git clone https://github.com/facepipe/Freqtrade-Strategy-Analyser.git
cd Freqtrade-Strategy-Analyser
pip install -r requirements-dev.txt
python -m pytest tests/

Adding New Detectors

  1. Add patterns to StrategyAnalyzer.__init__()
  2. Create detection method following _check_* pattern
  3. Add tests in tests/test_detectors.py
  4. Update documentation

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • FreqTrade Community: For the amazing trading framework
  • Strategy Authors: For sharing their strategies
  • Contributors: Everyone who helps improve this tool

πŸ“ž Support


Made with ❀️ for the FreqTrade community

About

Strategy Analyser for freqtrade. recursively searches a folder for strategies and checks them for faults or errors

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors