SQA - Simple Qualitative Analysis¶
Key Features
- High Performance - Rust-backed Polars DataFrames (30x faster)
- 150+ Technical Indicators - TA-Lib integration via sqa-tai
- 13+ Trading Strategies - RSI, MACD, Bollinger Bands, and more
- Portfolio Management - Track positions, P&L, commissions
- Backtesting Framework - Comprehensive performance metrics
- Real-Time Streaming - Live price data with callbacks
- Strategy Generation - Discover patterns from profitable trades
- Genetic Programming - Evolve optimal parameters
- Risk Management - VaR, CVaR, position sizing
- Pattern Matching - Find similar historical patterns
Welcome to SQA¶
SQA (Simple Qualitative Analysis) is an educational Ruby library designed for stock market technical analysis and trading strategy development. Built with high-performance data structures and seamlessly integrated with TA-Lib, SQA provides a comprehensive toolkit for analyzing historical stock data, implementing trading strategies, and backtesting your ideas.
Educational Purpose Only
SQA is designed for educational purposes only. It should not be used for actual trading without extensive testing and professional financial advice. Trading stocks involves substantial risk of loss.
Why SQA?¶
High Performance¶
- Polars DataFrames: Rust-backed data structures providing 30x faster operations than pure Ruby
- TA-Lib Integration: Access to 150+ battle-tested technical indicators via the
sqa-taigem - Efficient Algorithms: Optimized for large historical datasets
Comprehensive Feature Set¶
- 13+ Trading Strategies: From simple moving averages to advanced machine learning-based strategies
- Portfolio Management: Track positions, calculate P&L, manage commissions
- Backtesting Framework: Simulate strategies with comprehensive performance metrics
- Real-Time Streaming: Process live price data with callback support
- Strategy Generation: Reverse-engineer profitable trades to discover patterns
- Genetic Programming: Evolve optimal strategy parameters
Educational Focus¶
- Clear Documentation: Extensive guides and examples
- Transparent Algorithms: Understand how each indicator and strategy works
- Modular Design: Learn by building custom strategies
- Risk Disclaimers: Honest about limitations and risks
Quick Example¶
require 'sqa'
# Initialize SQA
SQA.init
# Load stock data
stock = SQA::Stock.new(ticker: 'AAPL')
# Get price data
prices = stock.df["adj_close_price"].to_a
# Calculate RSI indicator
rsi = SQAI.rsi(prices, period: 14)
# Execute RSI trading strategy
require 'ostruct'
vector = OpenStruct.new(rsi: { trend: rsi.last < 30 ? :over_sold : :over_bought })
signal = SQA::Strategy::RSI.trade(vector) # => :buy, :sell, or :hold
# Backtest the strategy
backtest = SQA::Backtest.new(
stock: stock,
strategy: SQA::Strategy::RSI,
initial_cash: 10_000
)
results = backtest.run
puts "Total Return: #{results.total_return}%"
puts "Sharpe Ratio: #{results.sharpe_ratio}"
puts "Max Drawdown: #{results.max_drawdown}%"
Core Features¶
Data Management¶
- Multiple Data Sources: Alpha Vantage, Yahoo Finance, CSV imports
- Polars DataFrames: High-performance time series data manipulation
- Automatic Updates: Keep historical data current
Technical Analysis¶
- 150+ Indicators: SMA, EMA, RSI, MACD, Bollinger Bands, Stochastic, ADX, ATR, and more
- Custom Calculations: Build your own indicators
- Trend Detection: Identify market conditions automatically
Trading Strategies¶
- Built-in Strategies: RSI, MACD, Bollinger Bands, Moving Average crossovers, Volume Breakout
- Strategy Framework: Plugin architecture for custom strategies
- Consensus Approach: Combine multiple strategies
- Rule-Based (KBS): RETE-based forward-chaining inference engine
Advanced Analytics¶
- Portfolio Tracking: Monitor positions, P&L, commissions
- Backtesting: Historical simulation with performance metrics
- Strategy Generator: Mine patterns from profitable trades
- Genetic Programming: Evolutionary parameter optimization
- FPOP Analysis: Future Period of Performance calculations
- Real-Time Streaming: Process live data with event callbacks
Architecture¶
Getting Started¶
Ready to dive in? Check out our guides:
- Installation Guide - Get SQA up and running
- Quick Start - Your first analysis in minutes
Key Resources¶
For Beginners¶
- Core Concepts - Understand the fundamentals
- Technical Indicators - Learn about indicators
- Trading Strategies - Explore built-in strategies
For Advanced Users¶
- Portfolio Management - Track your trades
- Backtesting - Test strategies historically
- Strategy Generator - Discover patterns
- Genetic Programming - Optimize parameters
Reference¶
- API Documentation - Complete API reference
- Data Sources - Working with data
- Terms of Use - Important legal information
Demo Application¶
Want to see SQA in action? Check out the sqa_demo-sinatra gem - a web-based demonstration application that provides a visual interface for exploring stock analysis, technical indicators, and trading strategies.
Community & Support¶
- GitHub: github.com/madbomber/sqa
- RubyGems: rubygems.org/gems/sqa
- Demo App: sqa_demo-sinatra - Web-based SQA demonstration
- Issues: Report bugs or request features on GitHub Issues
License¶
SQA is released under the MIT License. See the LICENSE file for details.
Remember: The House Always Wins
Trade responsibly. Never risk more than you can afford to lose.