sqa 0.0.31 → 0.0.37
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/CHANGELOG.md +104 -0
- data/CLAUDE.md +21 -0
- data/README.md +60 -32
- data/Rakefile +52 -10
- data/docs/IMPROVEMENT_PLAN.md +531 -0
- data/docs/advanced/index.md +1 -13
- data/docs/api/dataframe.md +0 -1
- data/docs/api/index.md +547 -61
- data/docs/api-reference/alphavantageapi.md +1057 -0
- data/docs/api-reference/apierror.md +31 -0
- data/docs/api-reference/index.md +221 -0
- data/docs/api-reference/notimplemented.md +27 -0
- data/docs/api-reference/sqa.md +267 -0
- data/docs/api-reference/sqa_backtest.md +137 -0
- data/docs/api-reference/sqa_backtest_results.md +530 -0
- data/docs/api-reference/sqa_badparametererror.md +13 -0
- data/docs/api-reference/sqa_config.md +538 -0
- data/docs/api-reference/sqa_configurationerror.md +13 -0
- data/docs/api-reference/sqa_datafetcherror.md +56 -0
- data/docs/api-reference/sqa_dataframe.md +752 -0
- data/docs/api-reference/sqa_dataframe_alphavantage.md +30 -0
- data/docs/api-reference/sqa_dataframe_data.md +325 -0
- data/docs/api-reference/sqa_dataframe_yahoofinance.md +25 -0
- data/docs/api-reference/sqa_ensemble.md +413 -0
- data/docs/api-reference/sqa_fpop.md +211 -0
- data/docs/api-reference/sqa_geneticprogram.md +325 -0
- data/docs/api-reference/sqa_geneticprogram_individual.md +114 -0
- data/docs/api-reference/sqa_marketregime.md +212 -0
- data/docs/api-reference/sqa_multitimeframe.md +227 -0
- data/docs/api-reference/sqa_patternmatcher.md +195 -0
- data/docs/api-reference/sqa_pluginmanager.md +55 -0
- data/docs/api-reference/sqa_portfolio.md +455 -0
- data/docs/api-reference/sqa_portfolio_position.md +220 -0
- data/docs/api-reference/sqa_portfolio_trade.md +332 -0
- data/docs/api-reference/sqa_portfoliooptimizer.md +248 -0
- data/docs/api-reference/sqa_riskmanager.md +388 -0
- data/docs/api-reference/sqa_seasonalanalyzer.md +121 -0
- data/docs/api-reference/sqa_sectoranalyzer.md +163 -0
- data/docs/api-reference/sqa_stock.md +649 -0
- data/docs/api-reference/sqa_strategy.md +178 -0
- data/docs/api-reference/sqa_strategy_bollingerbands.md +26 -0
- data/docs/api-reference/sqa_strategy_common.md +29 -0
- data/docs/api-reference/sqa_strategy_consensus.md +129 -0
- data/docs/api-reference/sqa_strategy_ema.md +41 -0
- data/docs/api-reference/sqa_strategy_kbs.md +154 -0
- data/docs/api-reference/sqa_strategy_macd.md +26 -0
- data/docs/api-reference/sqa_strategy_mp.md +41 -0
- data/docs/api-reference/sqa_strategy_mr.md +41 -0
- data/docs/api-reference/sqa_strategy_random.md +41 -0
- data/docs/api-reference/sqa_strategy_rsi.md +41 -0
- data/docs/api-reference/sqa_strategy_sma.md +41 -0
- data/docs/api-reference/sqa_strategy_stochastic.md +26 -0
- data/docs/api-reference/sqa_strategy_volumebreakout.md +26 -0
- data/docs/api-reference/sqa_strategygenerator.md +298 -0
- data/docs/api-reference/sqa_strategygenerator_pattern.md +264 -0
- data/docs/api-reference/sqa_strategygenerator_patterncontext.md +326 -0
- data/docs/api-reference/sqa_strategygenerator_profitablepoint.md +424 -0
- data/docs/api-reference/sqa_stream.md +256 -0
- data/docs/api-reference/sqa_ticker.md +175 -0
- data/docs/api-reference/string.md +135 -0
- data/docs/assets/images/advanced-workflow.svg +89 -0
- data/docs/assets/images/architecture.svg +107 -0
- data/docs/assets/images/data-flow.svg +138 -0
- data/docs/assets/images/getting-started-workflow.svg +88 -0
- data/docs/assets/images/sqa.jpg +0 -0
- data/docs/assets/images/strategy-flow.svg +78 -0
- data/docs/assets/images/system-architecture.svg +150 -0
- data/docs/concepts/index.md +292 -27
- data/docs/data_frame.md +0 -1
- data/docs/getting-started/index.md +1 -30
- data/docs/getting-started/installation.md +2 -2
- data/docs/getting-started/quick-start.md +4 -4
- data/docs/index.md +26 -25
- data/docs/llms.txt +109 -0
- data/docs/strategies/bollinger-bands.md +1 -1
- data/docs/strategies/kbs.md +15 -14
- data/docs/strategies/rsi.md +1 -1
- data/docs/strategy.md +381 -3
- data/docs/terms_of_use.md +1 -1
- data/examples/README.md +10 -0
- data/lib/api/alpha_vantage_api.rb +3 -7
- data/lib/sqa/config.rb +109 -28
- data/lib/sqa/data_frame/alpha_vantage.rb +13 -3
- data/lib/sqa/data_frame/data.rb +13 -1
- data/lib/sqa/data_frame.rb +189 -41
- data/lib/sqa/errors.rb +79 -17
- data/lib/sqa/indicator.rb +17 -4
- data/lib/sqa/init.rb +70 -15
- data/lib/sqa/pattern_matcher.rb +4 -4
- data/lib/sqa/portfolio.rb +1 -1
- data/lib/sqa/sector_analyzer.rb +3 -11
- data/lib/sqa/stock.rb +236 -20
- data/lib/sqa/strategy.rb +62 -4
- data/lib/sqa/ticker.rb +107 -42
- data/lib/sqa/version.rb +1 -1
- data/lib/sqa.rb +16 -8
- data/mkdocs.yml +68 -117
- metadata +90 -36
- data/docs/README.md +0 -43
- data/docs/alpha_vantage_technical_indicators.md +0 -62
- data/docs/average_true_range.md +0 -9
- data/docs/bollinger_bands.md +0 -15
- data/docs/candlestick_pattern_recognizer.md +0 -4
- data/docs/donchian_channel.md +0 -5
- data/docs/double_top_bottom_pattern.md +0 -3
- data/docs/exponential_moving_average.md +0 -19
- data/docs/fibonacci_retracement.md +0 -30
- data/docs/head_and_shoulders_pattern.md +0 -3
- data/docs/market_profile.md +0 -4
- data/docs/momentum.md +0 -19
- data/docs/moving_average_convergence_divergence.md +0 -23
- data/docs/peaks_and_valleys.md +0 -11
- data/docs/relative_strength_index.md +0 -6
- data/docs/simple_moving_average.md +0 -8
- data/docs/stochastic_oscillator.md +0 -4
- data/docs/ta_lib.md +0 -160
- data/docs/true_range.md +0 -12
- data/docs/true_strength_index.md +0 -46
- data/docs/weighted_moving_average.md +0 -48
- data/examples/sinatra_app/Gemfile +0 -22
- data/examples/sinatra_app/QUICKSTART.md +0 -159
- data/examples/sinatra_app/README.md +0 -461
- data/examples/sinatra_app/app.rb +0 -344
- data/examples/sinatra_app/config.ru +0 -5
- data/examples/sinatra_app/public/css/style.css +0 -659
- data/examples/sinatra_app/public/js/app.js +0 -107
- data/examples/sinatra_app/views/analyze.erb +0 -306
- data/examples/sinatra_app/views/backtest.erb +0 -325
- data/examples/sinatra_app/views/dashboard.erb +0 -419
- data/examples/sinatra_app/views/error.erb +0 -58
- data/examples/sinatra_app/views/index.erb +0 -118
- data/examples/sinatra_app/views/layout.erb +0 -61
- data/examples/sinatra_app/views/portfolio.erb +0 -43
|
@@ -40,42 +40,13 @@ Before you begin, make sure you have:
|
|
|
40
40
|
|
|
41
41
|
[:octicons-arrow-right-24: Quick Start Guide](quick-start.md)
|
|
42
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
43
|
</div>
|
|
60
44
|
|
|
61
45
|
## Typical Workflow
|
|
62
46
|
|
|
63
47
|
Here's the typical workflow when using SQA:
|
|
64
48
|
|
|
65
|
-
|
|
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
|
-
```
|
|
49
|
+

|
|
79
50
|
|
|
80
51
|
## What's Next?
|
|
81
52
|
|
|
@@ -192,8 +192,8 @@ bundle install
|
|
|
192
192
|
Now that you have SQA installed:
|
|
193
193
|
|
|
194
194
|
1. **[Quick Start Guide](quick-start.md)** - Run your first analysis
|
|
195
|
-
2. **[
|
|
196
|
-
3. **[
|
|
195
|
+
2. **[Core Concepts](../concepts/index.md)** - Understand SQA's architecture
|
|
196
|
+
3. **[Trading Strategies](../strategies/index.md)** - Explore built-in strategies
|
|
197
197
|
|
|
198
198
|
## Additional Dependencies
|
|
199
199
|
|
|
@@ -204,10 +204,10 @@ SQA::Strategy.descendants # List all strategy classes
|
|
|
204
204
|
|
|
205
205
|
Now that you've run your first analyses:
|
|
206
206
|
|
|
207
|
-
1. **[
|
|
208
|
-
2. **[
|
|
209
|
-
3. **[
|
|
210
|
-
4. **[
|
|
207
|
+
1. **[Core Concepts](../concepts/index.md)** - Understand SQA's architecture
|
|
208
|
+
2. **[Trading Strategies](../strategies/index.md)** - Explore built-in strategies
|
|
209
|
+
3. **[Advanced Features](../advanced/index.md)** - Portfolio management, streaming, etc.
|
|
210
|
+
4. **[API Reference](../api/index.md)** - Complete API documentation
|
|
211
211
|
|
|
212
212
|
## Common Patterns
|
|
213
213
|
|
data/docs/index.md
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
# SQA - Simple Qualitative Analysis
|
|
2
2
|
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
3
|
+
<div style="display: flex; align-items: flex-start; gap: 2rem; margin-bottom: 2rem;">
|
|
4
|
+
<div style="flex: 0 0 400px;">
|
|
5
|
+
<img src="assets/images/sqa.jpg" alt="SQA - Simple Qualitative Analysis" style="width: 100%; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
|
|
6
|
+
</div>
|
|
7
|
+
<div style="flex: 1;">
|
|
8
|
+
<h2 style="margin-top: 0;">Key Features</h2>
|
|
9
|
+
<ul>
|
|
10
|
+
<li><strong>High Performance</strong> - Rust-backed Polars DataFrames (30x faster)</li>
|
|
11
|
+
<li><strong>150+ Technical Indicators</strong> - TA-Lib integration via sqa-tai</li>
|
|
12
|
+
<li><strong>13+ Trading Strategies</strong> - RSI, MACD, Bollinger Bands, and more</li>
|
|
13
|
+
<li><strong>Portfolio Management</strong> - Track positions, P&L, commissions</li>
|
|
14
|
+
<li><strong>Backtesting Framework</strong> - Comprehensive performance metrics</li>
|
|
15
|
+
<li><strong>Real-Time Streaming</strong> - Live price data with callbacks</li>
|
|
16
|
+
<li><strong>Strategy Generation</strong> - Discover patterns from profitable trades</li>
|
|
17
|
+
<li><strong>Genetic Programming</strong> - Evolve optimal parameters</li>
|
|
18
|
+
<li><strong>Risk Management</strong> - VaR, CVaR, position sizing</li>
|
|
19
|
+
<li><strong>Pattern Matching</strong> - Find similar historical patterns</li>
|
|
20
|
+
</ul>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
6
23
|
|
|
7
24
|
---
|
|
8
25
|
|
|
@@ -97,26 +114,7 @@ puts "Max Drawdown: #{results.max_drawdown}%"
|
|
|
97
114
|
|
|
98
115
|
## Architecture
|
|
99
116
|
|
|
100
|
-
|
|
101
|
-
graph TD
|
|
102
|
-
A[Stock Data] --> B[SQA::DataFrame]
|
|
103
|
-
B --> C[Technical Indicators]
|
|
104
|
-
C --> D[Trading Strategies]
|
|
105
|
-
D --> E{Strategy Type}
|
|
106
|
-
E -->|Simple| F[SMA/EMA/RSI]
|
|
107
|
-
E -->|Advanced| G[MACD/Bollinger]
|
|
108
|
-
E -->|Rule-Based| H[KBS Strategy]
|
|
109
|
-
D --> I[Portfolio Management]
|
|
110
|
-
I --> J[Backtesting]
|
|
111
|
-
J --> K[Performance Metrics]
|
|
112
|
-
|
|
113
|
-
L[Real-Time Data] --> M[SQA::Stream]
|
|
114
|
-
M --> D
|
|
115
|
-
|
|
116
|
-
N[Pattern Discovery] --> O[StrategyGenerator]
|
|
117
|
-
O --> P[Generated Strategies]
|
|
118
|
-
P --> D
|
|
119
|
-
```
|
|
117
|
+

|
|
120
118
|
|
|
121
119
|
## Getting Started
|
|
122
120
|
|
|
@@ -124,8 +122,6 @@ Ready to dive in? Check out our guides:
|
|
|
124
122
|
|
|
125
123
|
- **[Installation Guide](getting-started/installation.md)** - Get SQA up and running
|
|
126
124
|
- **[Quick Start](getting-started/quick-start.md)** - Your first analysis in minutes
|
|
127
|
-
- **[Configuration](getting-started/configuration.md)** - Customize SQA for your needs
|
|
128
|
-
- **[Console Usage](getting-started/console-usage.md)** - Interactive exploration with `sqa-console`
|
|
129
125
|
|
|
130
126
|
## Key Resources
|
|
131
127
|
|
|
@@ -145,10 +141,15 @@ Ready to dive in? Check out our guides:
|
|
|
145
141
|
- [Data Sources](data-sources/index.md) - Working with data
|
|
146
142
|
- [Terms of Use](terms_of_use.md) - Important legal information
|
|
147
143
|
|
|
144
|
+
## Demo Application
|
|
145
|
+
|
|
146
|
+
Want to see SQA in action? Check out the **[sqa_demo-sinatra](https://github.com/MadBomber/sqa_demo-sinatra)** gem - a web-based demonstration application that provides a visual interface for exploring stock analysis, technical indicators, and trading strategies.
|
|
147
|
+
|
|
148
148
|
## Community & Support
|
|
149
149
|
|
|
150
150
|
- **GitHub**: [github.com/madbomber/sqa](https://github.com/madbomber/sqa)
|
|
151
151
|
- **RubyGems**: [rubygems.org/gems/sqa](https://rubygems.org/gems/sqa)
|
|
152
|
+
- **Demo App**: [sqa_demo-sinatra](https://github.com/MadBomber/sqa_demo-sinatra) - Web-based SQA demonstration
|
|
152
153
|
- **Issues**: Report bugs or request features on [GitHub Issues](https://github.com/madbomber/sqa/issues)
|
|
153
154
|
|
|
154
155
|
## License
|
data/docs/llms.txt
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# SQA - Simple Qualitative Analysis
|
|
2
|
+
|
|
3
|
+
> A powerful Ruby library for stock market technical analysis and trading strategy development
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
- 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-tai gem - Efficient Algorithms: Optimized for large historical datasets
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
- [Index](https://madbomber.github.io/sqa/getting-started/index): Welcome to SQA! This guide will help you get up and running with stock market technical analysis in just a few minutes.
|
|
14
|
+
- [Installation](https://madbomber.github.io/sqa/getting-started/installation): This guide walks you through installing SQA and all its dependencies.
|
|
15
|
+
- [Quick Start](https://madbomber.github.io/sqa/getting-started/quick-start): Get up and running with SQA in just a few minutes!
|
|
16
|
+
|
|
17
|
+
## Core Concepts
|
|
18
|
+
|
|
19
|
+
- [Index](https://madbomber.github.io/sqa/concepts/index): Understanding the fundamental building blocks of SQA.
|
|
20
|
+
- [Dataframes](https://madbomber.github.io/sqa/data_frame): The SQA::DataFrame class is a high-performance wrapper around the Polars DataFrame library, specifically designed for time series financial data...
|
|
21
|
+
- [Technical Indicators](https://madbomber.github.io/sqa/indicators/index): SQA provides access to 150+ technical indicators via the sqa-tai gem, which wraps the industry-standard TA-Lib library.
|
|
22
|
+
- [Trading Strategies](https://madbomber.github.io/sqa/strategy): A strategy is a recipe that cooks all the indicators together to make a decision on a potential trade. The SQA::Strategy class provides the...
|
|
23
|
+
|
|
24
|
+
## Technical Indicators
|
|
25
|
+
|
|
26
|
+
- [Index](https://madbomber.github.io/sqa/indicators/index): SQA provides access to 150+ technical indicators via the sqa-tai gem, which wraps the industry-standard TA-Lib library.
|
|
27
|
+
- [Overview](https://madbomber.github.io/sqa/indicators): ## The Philosophy of Indicators
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Trading Strategies
|
|
32
|
+
|
|
33
|
+
- [Index](https://madbomber.github.io/sqa/strategies/index): Explore SQA's comprehensive suite of trading strategies.
|
|
34
|
+
|
|
35
|
+
### Built-in Strategies
|
|
36
|
+
|
|
37
|
+
- [Bollinger Bands Strategy](https://madbomber.github.io/sqa/strategies/bollinger-bands): The Bollinger Bands strategy uses volatility bands to identify oversold and overbought conditions. The strategy generates buy signals when price...
|
|
38
|
+
- [Rsi Strategy](https://madbomber.github.io/sqa/strategies/rsi): The Relative Strength Index (RSI) strategy identifies overbought and oversold conditions using momentum oscillators. It generates signals when RSI...
|
|
39
|
+
- [Macd Strategy](https://madbomber.github.io/sqa/strategies/macd): Moving Average Convergence Divergence (MACD) is a trend-following momentum indicator that shows the relationship between two moving averages.
|
|
40
|
+
- [Sma Strategy](https://madbomber.github.io/sqa/strategies/sma): The SMA strategy uses crossovers of short-term and long-term simple moving averages to identify trend changes and generate trading signals.
|
|
41
|
+
- [Ema Strategy](https://madbomber.github.io/sqa/strategies/ema): Similar to SMA but gives more weight to recent prices, making it more responsive to price changes.
|
|
42
|
+
- [Stochastic Strategy](https://madbomber.github.io/sqa/strategies/stochastic): Compares closing price to the price range over a period to identify overbought/oversold conditions and momentum changes.
|
|
43
|
+
- [Volume Breakout](https://madbomber.github.io/sqa/strategies/volume-breakout): Identifies price breakouts confirmed by high trading volume for stronger signal reliability.
|
|
44
|
+
- [Mean Reversion](https://madbomber.github.io/sqa/strategies/mean-reversion): Based on the theory that prices tend to return to their average over time. Buys when price is below average and sells when above.
|
|
45
|
+
- [Market Profile](https://madbomber.github.io/sqa/strategies/market-profile): Uses market profile analysis to identify support and resistance levels, generating signals when price reaches these key levels.
|
|
46
|
+
- [Consensus Strategy](https://madbomber.github.io/sqa/strategies/consensus): Aggregates signals from multiple strategies and makes trading decisions based on majority vote. Reduces risk of acting on single false signals.
|
|
47
|
+
|
|
48
|
+
### Advanced Strategies
|
|
49
|
+
|
|
50
|
+
- [Knowledge Based Strategy (kbs)](https://madbomber.github.io/sqa/strategies/kbs): Advanced rule-based trading system using RETE forward-chaining inference engine. Combines multiple indicators with custom logic rules.
|
|
51
|
+
- [Custom Strategies](https://madbomber.github.io/sqa/strategies/custom): Learn how to create your own trading strategies in the SQA framework.
|
|
52
|
+
|
|
53
|
+
## Advanced Features
|
|
54
|
+
|
|
55
|
+
- [Index](https://madbomber.github.io/sqa/advanced/index): Explore SQA's advanced capabilities for professional-grade analysis.
|
|
56
|
+
- [Portfolio Management](https://madbomber.github.io/sqa/advanced/portfolio): The Portfolio class tracks positions, calculates P&L, manages commissions, and monitors portfolio performance over time.
|
|
57
|
+
- [Backtesting](https://madbomber.github.io/sqa/advanced/backtesting): Simulate trading strategies on historical data to evaluate performance before risking real capital.
|
|
58
|
+
- [Strategy Generator](https://madbomber.github.io/sqa/advanced/strategy-generator): Reverse-engineer profitable trades to discover patterns and automatically generate executable trading strategies.
|
|
59
|
+
- [Genetic Programming](https://madbomber.github.io/sqa/genetic_programming): ### Overview of Genetic Programming (GP)
|
|
60
|
+
- [Real Time Streaming](https://madbomber.github.io/sqa/advanced/streaming): Process live price data with event callbacks and parallel strategy execution for real-time trading signals.
|
|
61
|
+
- [Fpop Analysis](https://madbomber.github.io/sqa/advanced/fpop): Calculate future returns, risk metrics, and direction classification to evaluate trading opportunities.
|
|
62
|
+
- [Risk Management](https://madbomber.github.io/sqa/advanced/risk-management): Comprehensive risk management tools including VaR, position sizing, and risk metrics.
|
|
63
|
+
- [Portfolio Optimizer](https://madbomber.github.io/sqa/advanced/portfolio-optimizer): Multi-objective portfolio optimization for optimal asset allocation and rebalancing.
|
|
64
|
+
- [Ensemble Strategies](https://madbomber.github.io/sqa/advanced/ensemble): Combine multiple strategies with voting and meta-learning.
|
|
65
|
+
- [Multi Timeframe Analysis](https://madbomber.github.io/sqa/advanced/multi-timeframe): Analyze multiple timeframes simultaneously for better trade timing.
|
|
66
|
+
- [Pattern Matcher](https://madbomber.github.io/sqa/advanced/pattern-matcher): Pattern recognition and similarity search for forecasting.
|
|
67
|
+
|
|
68
|
+
## AI & Machine Learning
|
|
69
|
+
|
|
70
|
+
- [Ai And Ml](https://madbomber.github.io/sqa/ai_and_ml): ## AI and ML in Trading -- Advancing Decision-Making
|
|
71
|
+
- [Mean Reversion](https://madbomber.github.io/sqa/mean_reversion): Determines if a stock exhibits mean reversion behavior based on a given price series.
|
|
72
|
+
- [Predict Next Value](https://madbomber.github.io/sqa/predict_next_value): As a stock quantitative analyst, having a predict next value method on a timeseries array of closing day stock price data would be extremely helpful....
|
|
73
|
+
- [Identify Wave Condition](https://madbomber.github.io/sqa/identify_wave_condition): The Elliott Wave Theory is a popular method used in stock technical analysis to predict future price movements in financial markets. It is based on...
|
|
74
|
+
- [Libsvm Format](https://madbomber.github.io/sqa/libsvm_file_format): This file format is used by rumale.
|
|
75
|
+
|
|
76
|
+
## API Reference
|
|
77
|
+
|
|
78
|
+
- [Index](https://madbomber.github.io/sqa/api/index): Complete API documentation for SQA classes and modules.
|
|
79
|
+
- [Dataframe Class](https://madbomber.github.io/sqa/api/dataframe): SQA::DataFrame is a high-performance wrapper around the Polars DataFrame library, specifically optimized for time series financial data manipulation....
|
|
80
|
+
|
|
81
|
+
## Data Sources
|
|
82
|
+
|
|
83
|
+
- [Index](https://madbomber.github.io/sqa/data-sources/index): SQA supports multiple data sources for historical stock price data.
|
|
84
|
+
|
|
85
|
+
## Resources
|
|
86
|
+
|
|
87
|
+
- [Tags](https://madbomber.github.io/sqa/tags): Browse documentation by topic.
|
|
88
|
+
- [Requirements](https://madbomber.github.io/sqa/requirements): ... otherwise know as what I want to do. Some people would call it a roadmap; but, where I'm going "we don't need no stinking roads!"
|
|
89
|
+
- [Terms Of Use](https://madbomber.github.io/sqa/terms_of_use): Some sections of these Terms of Use are aspirational. If found to be so, they shall not invalidate any other section which shall remain in full...
|
|
90
|
+
- [Trading Ideas](https://madbomber.github.io/sqa/i_gotta_an_idea): ... based upon my prior work with sports outcome predictions and sensor net architecture.
|
|
91
|
+
- [Factor Analysis](https://madbomber.github.io/sqa/factors_that_impact_price): ## Factors that Impact Price
|
|
92
|
+
|
|
93
|
+
### External Tools
|
|
94
|
+
|
|
95
|
+
- [Finviz](https://madbomber.github.io/sqa/finviz): The original finviz unofficial gem has been untouched for 3 years. I just forked it in the hope that I can bring it forward to current versions of...
|
|
96
|
+
- [Fx Pro Bit](https://madbomber.github.io/sqa/fx_pro_bit): FXProBot is a new trading software by Avenix Fzco, a major fintech firm located in Dubai that specializes in automated trading. This advanced robot...
|
|
97
|
+
- [Options Trading](https://madbomber.github.io/sqa/options): https://www.youtube.com/watch?v=A5w-dEgIU1M
|
|
98
|
+
|
|
99
|
+
## Contributing
|
|
100
|
+
|
|
101
|
+
- [Index](https://madbomber.github.io/sqa/contributing/index): Thank you for your interest in contributing to SQA!
|
|
102
|
+
|
|
103
|
+
## Optional
|
|
104
|
+
|
|
105
|
+
These resources provide supplementary information that may be skipped for shorter context:
|
|
106
|
+
|
|
107
|
+
- [Tags](https://madbomber.github.io/sqa/tags): Browse documentation by topic.
|
|
108
|
+
- [Requirements](https://madbomber.github.io/sqa/requirements): ... otherwise know as what I want to do. Some people would call it a roadmap; but, where I'm going "we don't need no stinking roads!"
|
|
109
|
+
- [Terms of Use](https://madbomber.github.io/sqa/terms_of_use): Some sections of these Terms of Use are aspirational. If found to be so, they shall not invalidate any other section which shall remain in full...
|
|
@@ -143,4 +143,4 @@ end
|
|
|
143
143
|
|
|
144
144
|
- [Bollinger Bands on Wikipedia](https://en.wikipedia.org/wiki/Bollinger_Bands)
|
|
145
145
|
- [John Bollinger's Official Site](https://www.bollingerbands.com/)
|
|
146
|
-
- [
|
|
146
|
+
- [Technical Indicators](../indicators/index.md)
|
data/docs/strategies/kbs.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
Advanced rule-based trading system using RETE forward-chaining inference engine. Combines multiple indicators with custom logic rules.
|
|
5
|
+
Advanced rule-based trading system using RETE forward-chaining inference engine. Combines multiple indicators with custom logic rules using the `kbs` (knowledge-based system) ruby gem. A complete [documentation website for the `kbs` ruby gem is available.](https://madbomber.github.io/kbs)
|
|
6
6
|
|
|
7
7
|
## How It Works
|
|
8
8
|
|
|
@@ -29,6 +29,7 @@ end
|
|
|
29
29
|
## Default Rules
|
|
30
30
|
|
|
31
31
|
The KBS strategy includes 10 default rules:
|
|
32
|
+
|
|
32
33
|
1. Buy on RSI oversold in uptrend
|
|
33
34
|
2. Sell on RSI overbought in downtrend
|
|
34
35
|
3. Buy on bullish MACD crossover
|
|
@@ -71,10 +72,10 @@ strategy.add_rule :strong_buy do
|
|
|
71
72
|
without :position # Don't buy if already holding
|
|
72
73
|
|
|
73
74
|
perform do
|
|
74
|
-
kb.assert(:signal, {
|
|
75
|
-
action: :buy,
|
|
75
|
+
kb.assert(:signal, {
|
|
76
|
+
action: :buy,
|
|
76
77
|
confidence: :high,
|
|
77
|
-
reason: :triple_confirmation
|
|
78
|
+
reason: :triple_confirmation
|
|
78
79
|
})
|
|
79
80
|
end
|
|
80
81
|
end
|
|
@@ -100,18 +101,18 @@ Multiple rules can fire, with aggregate confidence determining final signal.
|
|
|
100
101
|
|
|
101
102
|
## Strengths
|
|
102
103
|
|
|
103
|
-
✅ Highly customizable
|
|
104
|
-
✅ Combines multiple indicators
|
|
105
|
-
✅ Confidence scoring
|
|
106
|
-
✅ Forward-chaining inference
|
|
107
|
-
✅ Can encode expert knowledge
|
|
104
|
+
- ✅ Highly customizable
|
|
105
|
+
- ✅ Combines multiple indicators
|
|
106
|
+
- ✅ Confidence scoring
|
|
107
|
+
- ✅ Forward-chaining inference
|
|
108
|
+
- ✅ Can encode expert knowledge
|
|
108
109
|
|
|
109
110
|
## Weaknesses
|
|
110
111
|
|
|
111
|
-
❌ Complex to configure
|
|
112
|
-
❌ Requires domain knowledge
|
|
113
|
-
❌ Can be slow with many rules
|
|
114
|
-
❌ Overfitting risk
|
|
112
|
+
- ❌ Complex to configure
|
|
113
|
+
- ❌ Requires domain knowledge
|
|
114
|
+
- ❌ Can be slow with many rules
|
|
115
|
+
- ❌ Overfitting risk
|
|
115
116
|
|
|
116
117
|
## Tips
|
|
117
118
|
|
|
@@ -124,6 +125,7 @@ Multiple rules can fire, with aggregate confidence determining final signal.
|
|
|
124
125
|
## Available Facts
|
|
125
126
|
|
|
126
127
|
The KBS strategy processes these fact types:
|
|
128
|
+
|
|
127
129
|
- `:rsi` - RSI indicator data
|
|
128
130
|
- `:macd` - MACD crossovers
|
|
129
131
|
- `:trend` - Price trend analysis
|
|
@@ -161,4 +163,3 @@ end
|
|
|
161
163
|
|
|
162
164
|
- [Strategy Generator](../advanced/strategy-generator.md) - Auto-generate rules
|
|
163
165
|
- [Genetic Programming](../genetic_programming.md) - Optimize rule parameters
|
|
164
|
-
|
data/docs/strategies/rsi.md
CHANGED