sqa 0.0.24 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.goose/memory/development.txt +3 -0
- data/.semver +6 -0
- data/ARCHITECTURE.md +648 -0
- data/CHANGELOG.md +82 -0
- data/CLAUDE.md +653 -0
- data/COMMITS.md +196 -0
- data/DATAFRAME_ARCHITECTURE_REVIEW.md +421 -0
- data/NEXT-STEPS.md +154 -0
- data/README.md +812 -262
- data/TASKS.md +358 -0
- data/TEST_RESULTS.md +140 -0
- data/TODO.md +42 -0
- data/_notes.txt +25 -0
- data/bin/sqa-console +11 -0
- data/data/talk_talk.json +103284 -0
- data/develop_summary.md +313 -0
- data/docs/advanced/backtesting.md +206 -0
- data/docs/advanced/ensemble.md +68 -0
- data/docs/advanced/fpop.md +153 -0
- data/docs/advanced/index.md +112 -0
- data/docs/advanced/multi-timeframe.md +67 -0
- data/docs/advanced/pattern-matcher.md +75 -0
- data/docs/advanced/portfolio-optimizer.md +79 -0
- data/docs/advanced/portfolio.md +166 -0
- data/docs/advanced/risk-management.md +210 -0
- data/docs/advanced/strategy-generator.md +158 -0
- data/docs/advanced/streaming.md +209 -0
- data/docs/ai_and_ml.md +80 -0
- data/docs/api/dataframe.md +1115 -0
- data/docs/api/index.md +126 -0
- data/docs/assets/css/custom.css +88 -0
- data/docs/assets/js/mathjax.js +18 -0
- data/docs/concepts/index.md +68 -0
- data/docs/contributing/index.md +60 -0
- data/docs/data-sources/index.md +66 -0
- data/docs/data_frame.md +317 -97
- data/docs/factors_that_impact_price.md +26 -0
- data/docs/finviz.md +11 -0
- data/docs/fx_pro_bit.md +25 -0
- data/docs/genetic_programming.md +104 -0
- data/docs/getting-started/index.md +123 -0
- data/docs/getting-started/installation.md +229 -0
- data/docs/getting-started/quick-start.md +244 -0
- data/docs/i_gotta_an_idea.md +22 -0
- data/docs/index.md +163 -0
- data/docs/indicators/index.md +97 -0
- data/docs/indicators.md +110 -24
- data/docs/options.md +8 -0
- data/docs/strategies/bollinger-bands.md +146 -0
- data/docs/strategies/consensus.md +64 -0
- data/docs/strategies/custom.md +310 -0
- data/docs/strategies/ema.md +53 -0
- data/docs/strategies/index.md +92 -0
- data/docs/strategies/kbs.md +164 -0
- data/docs/strategies/macd.md +96 -0
- data/docs/strategies/market-profile.md +54 -0
- data/docs/strategies/mean-reversion.md +58 -0
- data/docs/strategies/rsi.md +95 -0
- data/docs/strategies/sma.md +55 -0
- data/docs/strategies/stochastic.md +63 -0
- data/docs/strategies/volume-breakout.md +54 -0
- data/docs/tags.md +7 -0
- data/docs/true_strength_index.md +46 -0
- data/docs/weighted_moving_average.md +48 -0
- data/examples/README.md +354 -0
- data/examples/advanced_features_example.rb +350 -0
- data/examples/fpop_analysis_example.rb +191 -0
- data/examples/genetic_programming_example.rb +148 -0
- data/examples/kbs_strategy_example.rb +208 -0
- data/examples/pattern_context_example.rb +300 -0
- data/examples/rails_app/Gemfile +34 -0
- data/examples/rails_app/README.md +416 -0
- data/examples/rails_app/app/assets/javascripts/application.js +107 -0
- data/examples/rails_app/app/assets/stylesheets/application.css +659 -0
- data/examples/rails_app/app/controllers/analysis_controller.rb +11 -0
- data/examples/rails_app/app/controllers/api/v1/stocks_controller.rb +227 -0
- data/examples/rails_app/app/controllers/application_controller.rb +22 -0
- data/examples/rails_app/app/controllers/backtest_controller.rb +11 -0
- data/examples/rails_app/app/controllers/dashboard_controller.rb +21 -0
- data/examples/rails_app/app/controllers/portfolio_controller.rb +7 -0
- data/examples/rails_app/app/views/analysis/show.html.erb +209 -0
- data/examples/rails_app/app/views/backtest/show.html.erb +171 -0
- data/examples/rails_app/app/views/dashboard/index.html.erb +118 -0
- data/examples/rails_app/app/views/dashboard/show.html.erb +408 -0
- data/examples/rails_app/app/views/errors/show.html.erb +17 -0
- data/examples/rails_app/app/views/layouts/application.html.erb +60 -0
- data/examples/rails_app/app/views/portfolio/index.html.erb +33 -0
- data/examples/rails_app/bin/rails +6 -0
- data/examples/rails_app/config/application.rb +45 -0
- data/examples/rails_app/config/boot.rb +5 -0
- data/examples/rails_app/config/database.yml +18 -0
- data/examples/rails_app/config/environment.rb +11 -0
- data/examples/rails_app/config/routes.rb +26 -0
- data/examples/rails_app/config.ru +8 -0
- data/examples/realtime_stream_example.rb +274 -0
- data/examples/sinatra_app/Gemfile +22 -0
- data/examples/sinatra_app/QUICKSTART.md +159 -0
- data/examples/sinatra_app/README.md +461 -0
- data/examples/sinatra_app/app.rb +344 -0
- data/examples/sinatra_app/config.ru +5 -0
- data/examples/sinatra_app/public/css/style.css +659 -0
- data/examples/sinatra_app/public/js/app.js +107 -0
- data/examples/sinatra_app/views/analyze.erb +306 -0
- data/examples/sinatra_app/views/backtest.erb +325 -0
- data/examples/sinatra_app/views/dashboard.erb +419 -0
- data/examples/sinatra_app/views/error.erb +58 -0
- data/examples/sinatra_app/views/index.erb +118 -0
- data/examples/sinatra_app/views/layout.erb +61 -0
- data/examples/sinatra_app/views/portfolio.erb +43 -0
- data/examples/strategy_generator_example.rb +346 -0
- data/hsa_portfolio.csv +11 -0
- data/justfile +0 -0
- data/lib/api/alpha_vantage_api.rb +462 -0
- data/lib/sqa/backtest.rb +329 -0
- data/lib/sqa/data_frame/alpha_vantage.rb +43 -65
- data/lib/sqa/data_frame/data.rb +92 -0
- data/lib/sqa/data_frame/yahoo_finance.rb +35 -43
- data/lib/sqa/data_frame.rb +148 -243
- data/lib/sqa/ensemble.rb +359 -0
- data/lib/sqa/fpop.rb +199 -0
- data/lib/sqa/gp.rb +259 -0
- data/lib/sqa/indicator.rb +5 -8
- data/lib/sqa/init.rb +15 -8
- data/lib/sqa/market_regime.rb +240 -0
- data/lib/sqa/multi_timeframe.rb +379 -0
- data/lib/sqa/pattern_matcher.rb +497 -0
- data/lib/sqa/portfolio.rb +260 -6
- data/lib/sqa/portfolio_optimizer.rb +377 -0
- data/lib/sqa/risk_manager.rb +442 -0
- data/lib/sqa/seasonal_analyzer.rb +209 -0
- data/lib/sqa/sector_analyzer.rb +300 -0
- data/lib/sqa/stock.rb +67 -125
- data/lib/sqa/strategy/bollinger_bands.rb +42 -0
- data/lib/sqa/strategy/consensus.rb +5 -2
- data/lib/sqa/strategy/kbs_strategy.rb +470 -0
- data/lib/sqa/strategy/macd.rb +46 -0
- data/lib/sqa/strategy/mp.rb +1 -1
- data/lib/sqa/strategy/stochastic.rb +60 -0
- data/lib/sqa/strategy/volume_breakout.rb +57 -0
- data/lib/sqa/strategy.rb +5 -0
- data/lib/sqa/strategy_generator.rb +947 -0
- data/lib/sqa/stream.rb +361 -0
- data/lib/sqa/version.rb +1 -7
- data/lib/sqa.rb +23 -16
- data/main.just +81 -0
- data/mkdocs.yml +288 -0
- data/trace.log +0 -0
- metadata +261 -51
- data/bin/sqa +0 -6
- data/lib/patches/dry-cli.rb +0 -228
- data/lib/sqa/activity.rb +0 -10
- data/lib/sqa/cli.rb +0 -62
- data/lib/sqa/commands/analysis.rb +0 -309
- data/lib/sqa/commands/base.rb +0 -139
- data/lib/sqa/commands/web.rb +0 -199
- data/lib/sqa/commands.rb +0 -22
- data/lib/sqa/constants.rb +0 -23
- data/lib/sqa/indicator/average_true_range.rb +0 -33
- data/lib/sqa/indicator/bollinger_bands.rb +0 -28
- data/lib/sqa/indicator/candlestick_pattern_recognizer.rb +0 -60
- data/lib/sqa/indicator/donchian_channel.rb +0 -29
- data/lib/sqa/indicator/double_top_bottom_pattern.rb +0 -34
- data/lib/sqa/indicator/elliott_wave_theory.rb +0 -57
- data/lib/sqa/indicator/exponential_moving_average.rb +0 -25
- data/lib/sqa/indicator/exponential_moving_average_trend.rb +0 -36
- data/lib/sqa/indicator/fibonacci_retracement.rb +0 -23
- data/lib/sqa/indicator/head_and_shoulders_pattern.rb +0 -26
- data/lib/sqa/indicator/market_profile.rb +0 -32
- data/lib/sqa/indicator/mean_reversion.rb +0 -37
- data/lib/sqa/indicator/momentum.rb +0 -28
- data/lib/sqa/indicator/moving_average_convergence_divergence.rb +0 -29
- data/lib/sqa/indicator/peaks_and_valleys.rb +0 -29
- data/lib/sqa/indicator/predict_next_value.rb +0 -202
- data/lib/sqa/indicator/relative_strength_index.rb +0 -47
- data/lib/sqa/indicator/simple_moving_average.rb +0 -24
- data/lib/sqa/indicator/simple_moving_average_trend.rb +0 -32
- data/lib/sqa/indicator/stochastic_oscillator.rb +0 -68
- data/lib/sqa/indicator/true_range.rb +0 -39
- data/lib/sqa/trade.rb +0 -26
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Getting Started with SQA
|
|
2
|
+
|
|
3
|
+
Welcome to SQA! This guide will help you get up and running with stock market technical analysis in just a few minutes.
|
|
4
|
+
|
|
5
|
+
## What You'll Learn
|
|
6
|
+
|
|
7
|
+
In this section, you'll learn how to:
|
|
8
|
+
|
|
9
|
+
- Install SQA and its dependencies
|
|
10
|
+
- Configure your environment for data access
|
|
11
|
+
- Run your first analysis
|
|
12
|
+
- Use the interactive console
|
|
13
|
+
- Understand the basic workflow
|
|
14
|
+
|
|
15
|
+
## Prerequisites
|
|
16
|
+
|
|
17
|
+
Before you begin, make sure you have:
|
|
18
|
+
|
|
19
|
+
- **Ruby 3.2+** installed on your system
|
|
20
|
+
- **TA-Lib C library** (for technical indicators)
|
|
21
|
+
- **(Optional) Alpha Vantage API key** for live data access
|
|
22
|
+
|
|
23
|
+
## Quick Navigation
|
|
24
|
+
|
|
25
|
+
<div class="grid cards" markdown>
|
|
26
|
+
|
|
27
|
+
- :material-download:{ .lg .middle } __Installation__
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
Install SQA and set up TA-Lib for technical analysis
|
|
32
|
+
|
|
33
|
+
[:octicons-arrow-right-24: Installation Guide](installation.md)
|
|
34
|
+
|
|
35
|
+
- :material-rocket-launch:{ .lg .middle } __Quick Start__
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
Get your first analysis running in minutes
|
|
40
|
+
|
|
41
|
+
[:octicons-arrow-right-24: Quick Start Guide](quick-start.md)
|
|
42
|
+
|
|
43
|
+
- :material-cog:{ .lg .middle } __Configuration__
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
Configure data sources and customize settings
|
|
48
|
+
|
|
49
|
+
[:octicons-arrow-right-24: Configuration](configuration.md)
|
|
50
|
+
|
|
51
|
+
- :material-console:{ .lg .middle } __Console Usage__
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
Interactive exploration with sqa-console
|
|
56
|
+
|
|
57
|
+
[:octicons-arrow-right-24: Console Guide](console-usage.md)
|
|
58
|
+
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
## Typical Workflow
|
|
62
|
+
|
|
63
|
+
Here's the typical workflow when using SQA:
|
|
64
|
+
|
|
65
|
+
```mermaid
|
|
66
|
+
graph LR
|
|
67
|
+
A[Install SQA] --> B[Configure API Keys]
|
|
68
|
+
B --> C[Load Stock Data]
|
|
69
|
+
C --> D[Calculate Indicators]
|
|
70
|
+
D --> E[Apply Strategies]
|
|
71
|
+
E --> F{Analysis Type}
|
|
72
|
+
F -->|Backtest| G[Run Backtest]
|
|
73
|
+
F -->|Live| H[Stream Real-Time]
|
|
74
|
+
F -->|Research| I[Explore in Console]
|
|
75
|
+
G --> J[Review Results]
|
|
76
|
+
H --> J
|
|
77
|
+
I --> J
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## What's Next?
|
|
81
|
+
|
|
82
|
+
Once you've completed the getting started guides, you can explore:
|
|
83
|
+
|
|
84
|
+
- **[Core Concepts](../concepts/index.md)** - Deep dive into SQA's architecture
|
|
85
|
+
- **[Technical Indicators](../indicators/index.md)** - Learn about the 150+ indicators
|
|
86
|
+
- **[Trading Strategies](../strategies/index.md)** - Explore built-in and custom strategies
|
|
87
|
+
- **[Advanced Features](../advanced/index.md)** - Portfolio management, backtesting, and more
|
|
88
|
+
|
|
89
|
+
## Need Help?
|
|
90
|
+
|
|
91
|
+
If you run into issues:
|
|
92
|
+
|
|
93
|
+
1. Check the [Troubleshooting](#troubleshooting) section below
|
|
94
|
+
2. Review the [Requirements](../requirements.md) page
|
|
95
|
+
3. Visit our [GitHub Issues](https://github.com/madbomber/sqa/issues)
|
|
96
|
+
|
|
97
|
+
## Troubleshooting
|
|
98
|
+
|
|
99
|
+
### Common Issues
|
|
100
|
+
|
|
101
|
+
**Ruby Version Too Old**
|
|
102
|
+
```bash
|
|
103
|
+
ruby --version # Should be 3.2 or higher
|
|
104
|
+
rbenv install 3.3.6 # Or rvm install ruby-3.3.6
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**TA-Lib Not Found**
|
|
108
|
+
```bash
|
|
109
|
+
# See the Installation guide for TA-Lib setup
|
|
110
|
+
# Quick check:
|
|
111
|
+
ls /usr/local/lib/libta_lib.*
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**API Key Issues**
|
|
115
|
+
```bash
|
|
116
|
+
# Set your Alpha Vantage API key
|
|
117
|
+
export AV_API_KEY="your_key_here"
|
|
118
|
+
# Or add to ~/.bashrc for persistence
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
Ready to install? Let's get started with the **[Installation Guide](installation.md)**!
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# Installation Guide
|
|
2
|
+
|
|
3
|
+
This guide walks you through installing SQA and all its dependencies.
|
|
4
|
+
|
|
5
|
+
## System Requirements
|
|
6
|
+
|
|
7
|
+
- **Ruby**: 3.2 or higher
|
|
8
|
+
- **Operating System**: Linux, macOS, or Windows (with WSL)
|
|
9
|
+
- **Disk Space**: ~100MB for gem and dependencies
|
|
10
|
+
- **Internet**: Required for downloading stock data
|
|
11
|
+
|
|
12
|
+
## Step 1: Install TA-Lib
|
|
13
|
+
|
|
14
|
+
SQA requires the TA-Lib C library for technical analysis calculations.
|
|
15
|
+
|
|
16
|
+
### Linux (Ubuntu/Debian)
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Download and extract TA-Lib source
|
|
20
|
+
cd /tmp
|
|
21
|
+
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
|
|
22
|
+
tar -xzf ta-lib-0.4.0-src.tar.gz
|
|
23
|
+
|
|
24
|
+
# Compile and install
|
|
25
|
+
cd ta-lib
|
|
26
|
+
./configure --prefix=/usr/local
|
|
27
|
+
make
|
|
28
|
+
sudo make install
|
|
29
|
+
|
|
30
|
+
# Create symlink for compatibility
|
|
31
|
+
cd /usr/local/lib
|
|
32
|
+
sudo ln -s libta_lib.so libta-lib.so
|
|
33
|
+
sudo ldconfig
|
|
34
|
+
|
|
35
|
+
# Set library path (add to ~/.bashrc for persistence)
|
|
36
|
+
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### macOS
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Using Homebrew
|
|
43
|
+
brew install ta-lib
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Verify Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Check that TA-Lib is installed
|
|
50
|
+
ls -la /usr/local/lib/libta_lib.*
|
|
51
|
+
|
|
52
|
+
# Should show files like:
|
|
53
|
+
# libta_lib.a
|
|
54
|
+
# libta_lib.so
|
|
55
|
+
# libta_lib.so.0
|
|
56
|
+
# libta_lib.so.0.0.0
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Step 2: Install SQA Gem
|
|
60
|
+
|
|
61
|
+
### From RubyGems (Recommended)
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
gem install sqa
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### From Source
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Clone the repository
|
|
71
|
+
git clone https://github.com/madbomber/sqa.git
|
|
72
|
+
cd sqa
|
|
73
|
+
|
|
74
|
+
# Install dependencies
|
|
75
|
+
bundle install
|
|
76
|
+
|
|
77
|
+
# Install the gem locally
|
|
78
|
+
rake install
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Step 3: Verify Installation
|
|
82
|
+
|
|
83
|
+
Test that SQA is installed correctly:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Launch the SQA console
|
|
87
|
+
sqa-console
|
|
88
|
+
|
|
89
|
+
# In the console, try:
|
|
90
|
+
SQA::VERSION # Should display the version number
|
|
91
|
+
SQAI.methods.grep(/^[a-z]/).sort # List available indicators
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Expected output:
|
|
95
|
+
```ruby
|
|
96
|
+
=> "0.0.31" # Version number
|
|
97
|
+
|
|
98
|
+
=> [:acos, :ad, :add, :adosc, :adx, :adxr, ...] # 150+ indicators
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Step 4: Configure API Access (Optional)
|
|
102
|
+
|
|
103
|
+
To download live stock data, you'll need an Alpha Vantage API key.
|
|
104
|
+
|
|
105
|
+
### Get API Key
|
|
106
|
+
|
|
107
|
+
1. Visit [Alpha Vantage](https://www.alphavantage.co/support/#api-key)
|
|
108
|
+
2. Sign up for a free API key
|
|
109
|
+
3. Copy your API key
|
|
110
|
+
|
|
111
|
+
### Set Environment Variable
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Temporary (current session)
|
|
115
|
+
export AV_API_KEY="your_api_key_here"
|
|
116
|
+
|
|
117
|
+
# Permanent (add to ~/.bashrc or ~/.zshrc)
|
|
118
|
+
echo 'export AV_API_KEY="your_api_key_here"' >> ~/.bashrc
|
|
119
|
+
source ~/.bashrc
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Alternative: Configuration File
|
|
123
|
+
|
|
124
|
+
Create `~/.sqa.yml`:
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
data_dir: ~/sqa_data
|
|
128
|
+
debug: false
|
|
129
|
+
verbose: false
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The API key is read from environment variables, not the config file.
|
|
133
|
+
|
|
134
|
+
## Troubleshooting
|
|
135
|
+
|
|
136
|
+
### TA-Lib Not Found
|
|
137
|
+
|
|
138
|
+
**Error**: `cannot load such file -- sqa/tai (LoadError)`
|
|
139
|
+
|
|
140
|
+
**Solution**: Make sure TA-Lib is installed and `LD_LIBRARY_PATH` is set:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Permission Denied During Installation
|
|
147
|
+
|
|
148
|
+
**Error**: `Permission denied @ dir_s_mkdir`
|
|
149
|
+
|
|
150
|
+
**Solution**: Use `sudo` for system-wide installation:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
sudo gem install sqa
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Or install to user directory:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
gem install --user-install sqa
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Ruby Version Too Old
|
|
163
|
+
|
|
164
|
+
**Error**: `Required Ruby version is >= 3.2.0`
|
|
165
|
+
|
|
166
|
+
**Solution**: Update Ruby using rbenv or rvm:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Using rbenv
|
|
170
|
+
rbenv install 3.3.6
|
|
171
|
+
rbenv global 3.3.6
|
|
172
|
+
|
|
173
|
+
# Using rvm
|
|
174
|
+
rvm install 3.3.6
|
|
175
|
+
rvm use 3.3.6 --default
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Bundle Install Fails
|
|
179
|
+
|
|
180
|
+
**Error**: Various dependency errors
|
|
181
|
+
|
|
182
|
+
**Solution**: Update bundler and try again:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
gem update --system
|
|
186
|
+
gem install bundler
|
|
187
|
+
bundle install
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Next Steps
|
|
191
|
+
|
|
192
|
+
Now that you have SQA installed:
|
|
193
|
+
|
|
194
|
+
1. **[Quick Start Guide](quick-start.md)** - Run your first analysis
|
|
195
|
+
2. **[Configuration](configuration.md)** - Customize your setup
|
|
196
|
+
3. **[Console Usage](console-usage.md)** - Explore interactively
|
|
197
|
+
|
|
198
|
+
## Additional Dependencies
|
|
199
|
+
|
|
200
|
+
SQA automatically installs these dependencies:
|
|
201
|
+
|
|
202
|
+
- `polars-df` - High-performance DataFrames
|
|
203
|
+
- `sqa-tai` - TA-Lib wrapper for indicators
|
|
204
|
+
- `faraday` - HTTP client for API calls
|
|
205
|
+
- `hashie` - Enhanced hash objects
|
|
206
|
+
- `tty-table` - Terminal table formatting
|
|
207
|
+
- `kbs` - Knowledge-based strategy framework
|
|
208
|
+
- `toml-rb` - TOML configuration support
|
|
209
|
+
|
|
210
|
+
For development, you may also want:
|
|
211
|
+
|
|
212
|
+
- `amazing_print` - Pretty printing
|
|
213
|
+
- `debug_me` - Debugging utilities
|
|
214
|
+
- `minitest` - Testing framework
|
|
215
|
+
- `simplecov` - Code coverage
|
|
216
|
+
|
|
217
|
+
## Supported Platforms
|
|
218
|
+
|
|
219
|
+
SQA has been tested on:
|
|
220
|
+
|
|
221
|
+
- ✅ Ubuntu 20.04+
|
|
222
|
+
- ✅ Debian 11+
|
|
223
|
+
- ✅ macOS 12+ (Monterey and later)
|
|
224
|
+
- ✅ Fedora 35+
|
|
225
|
+
- ⚠️ Windows (via WSL recommended)
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
Having issues? Check our [GitHub Issues](https://github.com/madbomber/sqa/issues) or create a new one.
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# Quick Start Guide
|
|
2
|
+
|
|
3
|
+
Get up and running with SQA in just a few minutes!
|
|
4
|
+
|
|
5
|
+
## Your First Analysis (5 Minutes)
|
|
6
|
+
|
|
7
|
+
### 1. Create a Simple Script
|
|
8
|
+
|
|
9
|
+
Create a file called `my_first_analysis.rb`:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
require 'sqa'
|
|
13
|
+
|
|
14
|
+
# Initialize SQA
|
|
15
|
+
SQA.init
|
|
16
|
+
|
|
17
|
+
# Load Apple stock data
|
|
18
|
+
puts "Loading AAPL data..."
|
|
19
|
+
stock = SQA::Stock.new(ticker: 'AAPL')
|
|
20
|
+
|
|
21
|
+
# Display basic information
|
|
22
|
+
puts "\n#{stock}"
|
|
23
|
+
puts "Data points: #{stock.df.height}"
|
|
24
|
+
puts "Date range: #{stock.df['timestamp'].first} to #{stock.df['timestamp'].last}"
|
|
25
|
+
|
|
26
|
+
# Get closing prices
|
|
27
|
+
prices = stock.df["adj_close_price"].to_a
|
|
28
|
+
puts "\nCurrent price: $#{prices.last}"
|
|
29
|
+
|
|
30
|
+
# Calculate RSI (Relative Strength Index)
|
|
31
|
+
rsi_values = SQAI.rsi(prices, period: 14)
|
|
32
|
+
current_rsi = rsi_values.last.round(2)
|
|
33
|
+
|
|
34
|
+
puts "Current RSI: #{current_rsi}"
|
|
35
|
+
puts "Market condition: #{current_rsi < 30 ? 'Oversold' : current_rsi > 70 ? 'Overbought' : 'Neutral'}"
|
|
36
|
+
|
|
37
|
+
# Calculate Simple Moving Average
|
|
38
|
+
sma_20 = SQAI.sma(prices, period: 20)
|
|
39
|
+
sma_50 = SQAI.sma(prices, period: 50)
|
|
40
|
+
|
|
41
|
+
puts "\n20-day SMA: $#{sma_20.last.round(2)}"
|
|
42
|
+
puts "50-day SMA: $#{sma_50.last.round(2)}"
|
|
43
|
+
puts "Trend: #{sma_20.last > sma_50.last ? 'Bullish' : 'Bearish'}"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Run the Script
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ruby my_first_analysis.rb
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Expected output:
|
|
53
|
+
```
|
|
54
|
+
Loading AAPL data...
|
|
55
|
+
|
|
56
|
+
aapl with 1258 data points from 2019-11-09 to 2024-11-08
|
|
57
|
+
Data points: 1258
|
|
58
|
+
Date range: 2019-11-09 to 2024-11-08
|
|
59
|
+
|
|
60
|
+
Current price: $226.96
|
|
61
|
+
Current RSI: 48.23
|
|
62
|
+
Market condition: Neutral
|
|
63
|
+
|
|
64
|
+
20-day SMA: $225.45
|
|
65
|
+
50-day SMA: $218.32
|
|
66
|
+
Trend: Bullish
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Backtest a Strategy (10 Minutes)
|
|
70
|
+
|
|
71
|
+
Let's backtest a simple RSI trading strategy:
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
require 'sqa'
|
|
75
|
+
|
|
76
|
+
SQA.init
|
|
77
|
+
|
|
78
|
+
# Load stock data
|
|
79
|
+
stock = SQA::Stock.new(ticker: 'AAPL')
|
|
80
|
+
|
|
81
|
+
# Create and run backtest
|
|
82
|
+
backtest = SQA::Backtest.new(
|
|
83
|
+
stock: stock,
|
|
84
|
+
strategy: SQA::Strategy::RSI,
|
|
85
|
+
initial_cash: 10_000.0,
|
|
86
|
+
commission: 1.0 # $1 per trade
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
puts "Running backtest for RSI strategy..."
|
|
90
|
+
results = backtest.run
|
|
91
|
+
|
|
92
|
+
# Display results
|
|
93
|
+
puts "\n=== Backtest Results ==="
|
|
94
|
+
puts "Total Return: #{results.total_return.round(2)}%"
|
|
95
|
+
puts "Sharpe Ratio: #{results.sharpe_ratio.round(2)}"
|
|
96
|
+
puts "Max Drawdown: #{results.max_drawdown.round(2)}%"
|
|
97
|
+
puts "Win Rate: #{results.win_rate.round(2)}%"
|
|
98
|
+
puts "\nTotal Trades: #{results.total_trades}"
|
|
99
|
+
puts "Winning Trades: #{results.winning_trades}"
|
|
100
|
+
puts "Losing Trades: #{results.losing_trades}"
|
|
101
|
+
puts "\nFinal Portfolio Value: $#{results.final_value.round(2)}"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Use Multiple Indicators (15 Minutes)
|
|
105
|
+
|
|
106
|
+
Combine several indicators for better analysis:
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
require 'sqa'
|
|
110
|
+
|
|
111
|
+
SQA.init
|
|
112
|
+
|
|
113
|
+
stock = SQA::Stock.new(ticker: 'MSFT')
|
|
114
|
+
prices = stock.df["adj_close_price"].to_a
|
|
115
|
+
volumes = stock.df["volume"].to_a
|
|
116
|
+
|
|
117
|
+
# Calculate multiple indicators
|
|
118
|
+
puts "Calculating indicators..."
|
|
119
|
+
|
|
120
|
+
# Trend indicators
|
|
121
|
+
sma_20 = SQAI.sma(prices, period: 20)
|
|
122
|
+
ema_12 = SQAI.ema(prices, period: 12)
|
|
123
|
+
ema_26 = SQAI.ema(prices, period: 26)
|
|
124
|
+
|
|
125
|
+
# Momentum indicators
|
|
126
|
+
rsi = SQAI.rsi(prices, period: 14)
|
|
127
|
+
macd_line, signal_line, histogram = SQAI.macd(
|
|
128
|
+
prices,
|
|
129
|
+
fast_period: 12,
|
|
130
|
+
slow_period: 26,
|
|
131
|
+
signal_period: 9
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
# Volatility indicators
|
|
135
|
+
upper, middle, lower = SQAI.bbands(prices, period: 20)
|
|
136
|
+
|
|
137
|
+
# Display current values
|
|
138
|
+
puts "\n=== Technical Analysis for MSFT ==="
|
|
139
|
+
puts "Price: $#{prices.last.round(2)}"
|
|
140
|
+
puts "\nTrend:"
|
|
141
|
+
puts " SMA(20): $#{sma_20.last.round(2)}"
|
|
142
|
+
puts " EMA(12): $#{ema_12.last.round(2)}"
|
|
143
|
+
puts " EMA(26): $#{ema_26.last.round(2)}"
|
|
144
|
+
|
|
145
|
+
puts "\nMomentum:"
|
|
146
|
+
puts " RSI: #{rsi.last.round(2)}"
|
|
147
|
+
puts " MACD: #{macd_line.last.round(2)}"
|
|
148
|
+
puts " Signal: #{signal_line.last.round(2)}"
|
|
149
|
+
|
|
150
|
+
puts "\nVolatility (Bollinger Bands):"
|
|
151
|
+
puts " Upper: $#{upper.last.round(2)}"
|
|
152
|
+
puts " Middle: $#{middle.last.round(2)}"
|
|
153
|
+
puts " Lower: $#{lower.last.round(2)}"
|
|
154
|
+
|
|
155
|
+
# Generate trading signal
|
|
156
|
+
signal = case
|
|
157
|
+
when rsi.last < 30 && prices.last < lower.last
|
|
158
|
+
"STRONG BUY"
|
|
159
|
+
when rsi.last < 40 && macd_line.last > signal_line.last
|
|
160
|
+
"BUY"
|
|
161
|
+
when rsi.last > 70 && prices.last > upper.last
|
|
162
|
+
"STRONG SELL"
|
|
163
|
+
when rsi.last > 60 && macd_line.last < signal_line.last
|
|
164
|
+
"SELL"
|
|
165
|
+
else
|
|
166
|
+
"HOLD"
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
puts "\nRecommended Action: #{signal}"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Explore Interactively
|
|
173
|
+
|
|
174
|
+
Use the `sqa-console` for interactive exploration:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
sqa-console
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Try these commands in the console:
|
|
181
|
+
|
|
182
|
+
```ruby
|
|
183
|
+
# Load a stock
|
|
184
|
+
stock = SQA::Stock.new(ticker: 'GOOGL')
|
|
185
|
+
|
|
186
|
+
# Explore the dataframe
|
|
187
|
+
stock.df.head(10)
|
|
188
|
+
|
|
189
|
+
# Get column names
|
|
190
|
+
stock.df.columns
|
|
191
|
+
|
|
192
|
+
# Calculate any indicator
|
|
193
|
+
prices = stock.df["adj_close_price"].to_a
|
|
194
|
+
SQAI.sma(prices, period: 50)
|
|
195
|
+
|
|
196
|
+
# List all available indicators
|
|
197
|
+
SQAI.methods.grep(/^[a-z]/).sort
|
|
198
|
+
|
|
199
|
+
# Try different strategies
|
|
200
|
+
SQA::Strategy.descendants # List all strategy classes
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Next Steps
|
|
204
|
+
|
|
205
|
+
Now that you've run your first analyses:
|
|
206
|
+
|
|
207
|
+
1. **[Configuration Guide](configuration.md)** - Customize data sources and settings
|
|
208
|
+
2. **[Core Concepts](../concepts/index.md)** - Understand SQA's architecture
|
|
209
|
+
3. **[Trading Strategies](../strategies/index.md)** - Explore built-in strategies
|
|
210
|
+
4. **[Advanced Features](../advanced/index.md)** - Portfolio management, streaming, etc.
|
|
211
|
+
|
|
212
|
+
## Common Patterns
|
|
213
|
+
|
|
214
|
+
### Load Historical Data
|
|
215
|
+
|
|
216
|
+
```ruby
|
|
217
|
+
stock = SQA::Stock.new(ticker: 'TSLA')
|
|
218
|
+
prices = stock.df["adj_close_price"].to_a
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Calculate Indicator
|
|
222
|
+
|
|
223
|
+
```ruby
|
|
224
|
+
values = SQAI.indicator_name(prices, period: 14)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Apply Strategy
|
|
228
|
+
|
|
229
|
+
```ruby
|
|
230
|
+
require 'ostruct'
|
|
231
|
+
vector = OpenStruct.new(prices: prices, rsi: rsi_values)
|
|
232
|
+
signal = SQA::Strategy::RSI.trade(vector)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Run Backtest
|
|
236
|
+
|
|
237
|
+
```ruby
|
|
238
|
+
backtest = SQA::Backtest.new(stock: stock, strategy: SQA::Strategy::MACD)
|
|
239
|
+
results = backtest.run
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
**Tip**: Keep the [Technical Indicators Reference](../indicators/index.md) handy as you explore!
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
## In Idea
|
|
2
|
+
|
|
3
|
+
... based upon my prior work with sports outcome predictions and sensor net architecture.
|
|
4
|
+
|
|
5
|
+
### Conceptual Framework for Financial Technical Analysis and Future Position Prediction
|
|
6
|
+
|
|
7
|
+
#### Abstract
|
|
8
|
+
|
|
9
|
+
This paper proposes a novel approach to financial technical analysis and the prediction of future market positions by drawing upon a methodology previously applied in the assessment of professional football games. The core idea involves the development and application of a numerical rating system, similar to one created in the 1980s for evaluating the performance of football teams by analyzing the strengths and weaknesses of their offensive, defensive, and special teams' statistics. The aim of this approach is to extend the principles of this rating system to the evaluation of companies by examining their financial fundamentals and technical analysis metrics.
|
|
10
|
+
|
|
11
|
+
#### Introduction
|
|
12
|
+
|
|
13
|
+
In the realm of sports analytics, the creation of a power rating system transformed the evaluation of professional football games by quantifying the performance of teams based on a comprehensive analysis of their statistics. This methodology involved a comparative analysis between the offensive capabilities of one team against the defensive competencies of their opponents, in addition to assessing the performance of special teams. The derived power rating was instrumental in predicting the likelihood of a team to "cover the points" in a game, essentially forecasting game outcomes with a higher degree of accuracy.
|
|
14
|
+
|
|
15
|
+
The proposed study seeks to adapt this successful analytical framework to the financial domain, specifically to the assessment of company performance and market position prediction. The adaptation involves considering company financial fundamentals and technical analysis indicators as analogous to the offensive, defensive, and special teams' statistics in football.
|
|
16
|
+
|
|
17
|
+
#### Methodology
|
|
18
|
+
|
|
19
|
+
The methodology encompasses the conceptualization of financial fundamental and technical analysis indicators as individual "sensors," each attributed with a distinct reliability weight. This is inspired by prior work on sensor networks, where each sensor's input was weighted according to its reliability. Through historical analysis within 15-day windows, weights will be assigned to each "sensor" (i.e., financial indicator), determining its influence on buy, sell, or hold decisions.
|
|
20
|
+
|
|
21
|
+
The study will explore multiple combinations of these weighted sensors to establish a comprehensive set of indicators. These indicators will cover various trading horizons, specifically 15, 30, 45, 60, 90, 120, 180, 240, and 360 trading days. The intent is to produce a versatile suite of both short-term and long-term indicators that can guide investment decisions.
|
|
22
|
+
|