Command-line interface for financial market analysis, backtesting, and portfolio optimization.
Part of the SQA (Simple Qualitative Analysis) ecosystem.
|
|
- π Quick Start Guide - 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
Once published, install the gem:
gem install sqa-cliClone the repository and install dependencies:
git clone https://github.com/madbomber/sqa-cli.git
cd sqa-cli
bundle installFor local development with the SQA gem:
bundle install
# The Gemfile points to the local SQA gem for developmentsqa-cli <command> [options]Core Commands:
help- Show help messageversion- Show version information
Analysis Commands:
analyze- Run various analysis methods (FPOP, regime, seasonal)backtest- Run strategy backtests on historical datagenetic- Evolve strategy parameters using genetic programmingpattern- Discover profitable trading patternskbs- Knowledge-based strategy using RETE inferencestream- Simulate real-time price streamingoptimize- Portfolio optimization and risk management
# 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 sharpebundle exec rake testOr run tests directly:
ruby -Ilib:test test/sqa/cli/version_test.rbbundle exec rake rubocopbundle exec rake rubocop:autocorrectbundle exec rake allbundle exec rake consolesqa-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
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
- 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
- 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
Full documentation available at:
- Online: madbomber.github.io/sqa-cli
- Getting Started: QUICKSTART.md
- Examples: USAGE_EXAMPLES.md
- Architecture: Detailed in this README
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
rake buildThis creates pkg/sqa-cli-X.Y.Z.gem.
rake installEnsure you're authenticated with RubyGems:
gem signinThen release:
rake releaseThis will:
- Create a git tag for the version
- Build the gem
- Push to rubygems.org
The gem is available as open source under the terms of the MIT License.
- SQA - The underlying analysis framework
- SQA-TAI - Technical analysis indicators
- TA-Lib - Technical analysis library
- π Issues: GitHub Issues
- π Docs: Documentation Site
- π¬ Discussions: GitHub Discussions
