SQA CLI - Simple Qualitative Analysis
Command-line interface for financial market analysis, backtesting, and portfolio optimization.
Part of the SQA (Simple Qualitative Analysis) ecosystem.
|
Features🎯 **7 Analysis Commands** - Comprehensive market analysis toolkit⚡ **Fast Execution** - Built on the powerful SQA gem 📊 **Multiple Strategies** - RSI, MACD, Bollinger Bands, and more 🧬 **Genetic Programming** - Evolve optimal strategy parameters 🔍 **Pattern Discovery** - Find profitable trading patterns 🧠 **Knowledge-Based Strategy** - RETE inference engine for trading rules 📈 **Portfolio Optimization** - Modern portfolio theory and risk management 🌊 **Real-Time Streaming** - Simulate live market data 🎨 **Clean Interface** - Intuitive command structure 📚 **Well Documented** - Complete guides and API reference |
Quick Links¶
- 📘 Quick Start - Get started quickly, see what works now
- 💡 Usage Examples - Comprehensive command examples
- 📊 Project Status - Detailed project status and next steps
- 📁 Sample Data - Sample data documentation
Installation¶
From RubyGems (Recommended)¶
From Source (Development)¶
Usage¶
Available Commands¶
Core Commands:
- help - Show help message
- version - Show version information
Analysis Commands:
- analyze - Run various analysis methods (FPOP, regime, seasonal)
- backtest - Run strategy backtests on historical data
- genetic - Evolve strategy parameters using genetic programming
- pattern - Discover profitable trading patterns
- kbs - Knowledge-based strategy using RETE inference
- stream - Simulate real-time price streaming
- optimize - Portfolio optimization and risk management
Examples¶
# Show version
sqa-cli version
sqa-cli --version
sqa-cli -v
# Show help
sqa-cli help
sqa-cli --help
sqa-cli -h
# Run stock analysis
sqa-cli analyze --ticker AAPL --methods all
sqa-cli analyze --ticker MSFT --methods fpop,regime
# Backtest strategies
sqa-cli backtest --ticker AAPL --strategy RSI
sqa-cli backtest --ticker GOOGL --compare
# Discover patterns
sqa-cli pattern --ticker AAPL --min-gain 10
sqa-cli pattern --ticker TSLA --min-gain 15 --generate
# Genetic programming
sqa-cli genetic --ticker AAPL --population 30 --generations 20
# Knowledge-based strategy
sqa-cli kbs --ticker AAPL --rules default --backtest
# Real-time streaming simulation
sqa-cli stream --ticker AAPL --strategies RSI,MACD
# Portfolio optimization
sqa-cli optimize --tickers AAPL,MSFT,GOOGL --method sharpe
Development¶
Running Tests¶
Or run tests directly:
Running Linters¶
Auto-correct Linting Issues¶
Run All Tests and Linters¶
Interactive Console¶
SQA Ecosystem¶
sqa-cli is part of the SQA project:
- sqa - Core trading strategy framework and analysis library
- sqa-tai - 136 technical analysis indicators (TA-Lib wrapper)
- sqa-cli - Command-line interface (this tool)
SQA provides a complete Ruby ecosystem for financial analysis:
- 📊 Technical analysis and backtesting
- 🔍 Pattern recognition and discovery
- 📈 Portfolio optimization and risk management
- 🌊 Real-time market data streaming
- 🧠 Knowledge-based trading strategies with AI integration
Architecture¶
This CLI follows a command-based architecture inspired by modern CLI tools:
sqa-cli/
├── bin/
│ └── sqa-cli # Executable entry point
├── lib/
│ ├── sqa.rb # Main module loader
│ └── sqa/
│ └── cli/
│ ├── version.rb # Version constant
│ ├── dispatcher.rb # Command dispatcher
│ └── commands/
│ ├── base.rb # Base command class
│ ├── analyze.rb # Stock analysis
│ ├── backtest.rb # Strategy backtesting
│ ├── genetic.rb # Genetic programming
│ ├── pattern.rb # Pattern discovery
│ ├── kbs.rb # Knowledge-based strategy
│ ├── stream.rb # Real-time streaming
│ └── optimize.rb # Portfolio optimization
├── test/ # Minitest tests
│ ├── test_helper.rb
│ └── sqa/
│ └── cli/
│ ├── version_test.rb
│ └── dispatcher_test.rb
├── Gemfile # Dependencies
├── Rakefile # Rake tasks
└── README.md # This file
Key Components¶
- Dispatcher: Routes commands to their respective handlers
- Commands::Base: Base class for all commands with common functionality
- DebugMe Integration: Built-in debugging support using debug_me gem
Adding New Commands¶
- Create a command file in
lib/sqa/cli/commands/:
# lib/sqa/cli/commands/my_command.rb
module SQA
module CLI
module Commands
class MyCommand < Base
def execute
print_header "My Command"
# Your command logic here
end
private
def add_command_options(opts)
opts.on('--my-option VALUE', 'Description') do |value|
@options[:my_option] = value
end
end
def banner
"Usage: sqa-cli my_command [options]"
end
end
end
end
end
-
Add the command name to
COMMANDSarray inlib/sqa/cli/dispatcher.rb -
The command is now available:
sqa-cli my_command --help
Contributing¶
Bug reports and pull requests are welcome at https://github.com/MadBomber/sqa-cli.
- Fork the repository
- Create your feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin feature/my-feature) - Create a Pull Request
License¶
The gem is available as open source under the terms of the MIT License.
Acknowledgments¶
- SQA - The underlying analysis framework
- SQA-TAI - Technical analysis indicators
- TA-Lib - Technical analysis library
Support¶
- 🐛 Issues: GitHub Issues
- 📚 Docs: Documentation Site
- 💬 Discussions: GitHub Discussions