Skip to content

MadBomber/sqa-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SQA CLI - Simple Qualitative Analysis

Command-line interface for financial market analysis, backtesting, and portfolio optimization.
Part of the SQA (Simple Qualitative Analysis) ecosystem.

Ruby Turns Information into Knowledge

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 - Full documentation at madbomber.github.io/sqa-cli

Quick Links

Installation

From RubyGems (Recommended)

Once published, install the gem:

gem install sqa-cli

From Source (Development)

Clone the repository and install dependencies:

git clone https://github.com/madbomber/sqa-cli.git
cd sqa-cli
bundle install

Local Development

For local development with the SQA gem:

bundle install
# The Gemfile points to the local SQA gem for development

Usage

sqa-cli <command> [options]

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

bundle exec rake test

Or run tests directly:

ruby -Ilib:test test/sqa/cli/version_test.rb

Running Linters

bundle exec rake rubocop

Auto-correct Linting Issues

bundle exec rake rubocop:autocorrect

Run All Tests and Linters

bundle exec rake all

Interactive Console

bundle exec rake 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

  1. 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
  1. Add the command name to COMMANDS array in lib/sqa/cli/dispatcher.rb

  2. The command is now available: sqa-cli my_command --help

Documentation

Full documentation available at:

Contributing

Bug reports and pull requests are welcome at https://github.com/MadBomber/sqa-cli.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Create a Pull Request

Building and Releasing the Gem

Build the Gem

rake build

This creates pkg/sqa-cli-X.Y.Z.gem.

Install Locally

rake install

Release to RubyGems

Ensure you're authenticated with RubyGems:

gem signin

Then release:

rake release

This will:

  1. Create a git tag for the version
  2. Build the gem
  3. Push to rubygems.org

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

About

CLI tool to work with the SQA library

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages