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.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +104 -0
  3. data/CLAUDE.md +21 -0
  4. data/README.md +60 -32
  5. data/Rakefile +52 -10
  6. data/docs/IMPROVEMENT_PLAN.md +531 -0
  7. data/docs/advanced/index.md +1 -13
  8. data/docs/api/dataframe.md +0 -1
  9. data/docs/api/index.md +547 -61
  10. data/docs/api-reference/alphavantageapi.md +1057 -0
  11. data/docs/api-reference/apierror.md +31 -0
  12. data/docs/api-reference/index.md +221 -0
  13. data/docs/api-reference/notimplemented.md +27 -0
  14. data/docs/api-reference/sqa.md +267 -0
  15. data/docs/api-reference/sqa_backtest.md +137 -0
  16. data/docs/api-reference/sqa_backtest_results.md +530 -0
  17. data/docs/api-reference/sqa_badparametererror.md +13 -0
  18. data/docs/api-reference/sqa_config.md +538 -0
  19. data/docs/api-reference/sqa_configurationerror.md +13 -0
  20. data/docs/api-reference/sqa_datafetcherror.md +56 -0
  21. data/docs/api-reference/sqa_dataframe.md +752 -0
  22. data/docs/api-reference/sqa_dataframe_alphavantage.md +30 -0
  23. data/docs/api-reference/sqa_dataframe_data.md +325 -0
  24. data/docs/api-reference/sqa_dataframe_yahoofinance.md +25 -0
  25. data/docs/api-reference/sqa_ensemble.md +413 -0
  26. data/docs/api-reference/sqa_fpop.md +211 -0
  27. data/docs/api-reference/sqa_geneticprogram.md +325 -0
  28. data/docs/api-reference/sqa_geneticprogram_individual.md +114 -0
  29. data/docs/api-reference/sqa_marketregime.md +212 -0
  30. data/docs/api-reference/sqa_multitimeframe.md +227 -0
  31. data/docs/api-reference/sqa_patternmatcher.md +195 -0
  32. data/docs/api-reference/sqa_pluginmanager.md +55 -0
  33. data/docs/api-reference/sqa_portfolio.md +455 -0
  34. data/docs/api-reference/sqa_portfolio_position.md +220 -0
  35. data/docs/api-reference/sqa_portfolio_trade.md +332 -0
  36. data/docs/api-reference/sqa_portfoliooptimizer.md +248 -0
  37. data/docs/api-reference/sqa_riskmanager.md +388 -0
  38. data/docs/api-reference/sqa_seasonalanalyzer.md +121 -0
  39. data/docs/api-reference/sqa_sectoranalyzer.md +163 -0
  40. data/docs/api-reference/sqa_stock.md +649 -0
  41. data/docs/api-reference/sqa_strategy.md +178 -0
  42. data/docs/api-reference/sqa_strategy_bollingerbands.md +26 -0
  43. data/docs/api-reference/sqa_strategy_common.md +29 -0
  44. data/docs/api-reference/sqa_strategy_consensus.md +129 -0
  45. data/docs/api-reference/sqa_strategy_ema.md +41 -0
  46. data/docs/api-reference/sqa_strategy_kbs.md +154 -0
  47. data/docs/api-reference/sqa_strategy_macd.md +26 -0
  48. data/docs/api-reference/sqa_strategy_mp.md +41 -0
  49. data/docs/api-reference/sqa_strategy_mr.md +41 -0
  50. data/docs/api-reference/sqa_strategy_random.md +41 -0
  51. data/docs/api-reference/sqa_strategy_rsi.md +41 -0
  52. data/docs/api-reference/sqa_strategy_sma.md +41 -0
  53. data/docs/api-reference/sqa_strategy_stochastic.md +26 -0
  54. data/docs/api-reference/sqa_strategy_volumebreakout.md +26 -0
  55. data/docs/api-reference/sqa_strategygenerator.md +298 -0
  56. data/docs/api-reference/sqa_strategygenerator_pattern.md +264 -0
  57. data/docs/api-reference/sqa_strategygenerator_patterncontext.md +326 -0
  58. data/docs/api-reference/sqa_strategygenerator_profitablepoint.md +424 -0
  59. data/docs/api-reference/sqa_stream.md +256 -0
  60. data/docs/api-reference/sqa_ticker.md +175 -0
  61. data/docs/api-reference/string.md +135 -0
  62. data/docs/assets/images/advanced-workflow.svg +89 -0
  63. data/docs/assets/images/architecture.svg +107 -0
  64. data/docs/assets/images/data-flow.svg +138 -0
  65. data/docs/assets/images/getting-started-workflow.svg +88 -0
  66. data/docs/assets/images/sqa.jpg +0 -0
  67. data/docs/assets/images/strategy-flow.svg +78 -0
  68. data/docs/assets/images/system-architecture.svg +150 -0
  69. data/docs/concepts/index.md +292 -27
  70. data/docs/data_frame.md +0 -1
  71. data/docs/getting-started/index.md +1 -30
  72. data/docs/getting-started/installation.md +2 -2
  73. data/docs/getting-started/quick-start.md +4 -4
  74. data/docs/index.md +26 -25
  75. data/docs/llms.txt +109 -0
  76. data/docs/strategies/bollinger-bands.md +1 -1
  77. data/docs/strategies/kbs.md +15 -14
  78. data/docs/strategies/rsi.md +1 -1
  79. data/docs/strategy.md +381 -3
  80. data/docs/terms_of_use.md +1 -1
  81. data/examples/README.md +10 -0
  82. data/lib/api/alpha_vantage_api.rb +3 -7
  83. data/lib/sqa/config.rb +109 -28
  84. data/lib/sqa/data_frame/alpha_vantage.rb +13 -3
  85. data/lib/sqa/data_frame/data.rb +13 -1
  86. data/lib/sqa/data_frame.rb +189 -41
  87. data/lib/sqa/errors.rb +79 -17
  88. data/lib/sqa/indicator.rb +17 -4
  89. data/lib/sqa/init.rb +70 -15
  90. data/lib/sqa/pattern_matcher.rb +4 -4
  91. data/lib/sqa/portfolio.rb +1 -1
  92. data/lib/sqa/sector_analyzer.rb +3 -11
  93. data/lib/sqa/stock.rb +236 -20
  94. data/lib/sqa/strategy.rb +62 -4
  95. data/lib/sqa/ticker.rb +107 -42
  96. data/lib/sqa/version.rb +1 -1
  97. data/lib/sqa.rb +16 -8
  98. data/mkdocs.yml +68 -117
  99. metadata +90 -36
  100. data/docs/README.md +0 -43
  101. data/docs/alpha_vantage_technical_indicators.md +0 -62
  102. data/docs/average_true_range.md +0 -9
  103. data/docs/bollinger_bands.md +0 -15
  104. data/docs/candlestick_pattern_recognizer.md +0 -4
  105. data/docs/donchian_channel.md +0 -5
  106. data/docs/double_top_bottom_pattern.md +0 -3
  107. data/docs/exponential_moving_average.md +0 -19
  108. data/docs/fibonacci_retracement.md +0 -30
  109. data/docs/head_and_shoulders_pattern.md +0 -3
  110. data/docs/market_profile.md +0 -4
  111. data/docs/momentum.md +0 -19
  112. data/docs/moving_average_convergence_divergence.md +0 -23
  113. data/docs/peaks_and_valleys.md +0 -11
  114. data/docs/relative_strength_index.md +0 -6
  115. data/docs/simple_moving_average.md +0 -8
  116. data/docs/stochastic_oscillator.md +0 -4
  117. data/docs/ta_lib.md +0 -160
  118. data/docs/true_range.md +0 -12
  119. data/docs/true_strength_index.md +0 -46
  120. data/docs/weighted_moving_average.md +0 -48
  121. data/examples/sinatra_app/Gemfile +0 -22
  122. data/examples/sinatra_app/QUICKSTART.md +0 -159
  123. data/examples/sinatra_app/README.md +0 -461
  124. data/examples/sinatra_app/app.rb +0 -344
  125. data/examples/sinatra_app/config.ru +0 -5
  126. data/examples/sinatra_app/public/css/style.css +0 -659
  127. data/examples/sinatra_app/public/js/app.js +0 -107
  128. data/examples/sinatra_app/views/analyze.erb +0 -306
  129. data/examples/sinatra_app/views/backtest.erb +0 -325
  130. data/examples/sinatra_app/views/dashboard.erb +0 -419
  131. data/examples/sinatra_app/views/error.erb +0 -58
  132. data/examples/sinatra_app/views/index.erb +0 -118
  133. data/examples/sinatra_app/views/layout.erb +0 -61
  134. data/examples/sinatra_app/views/portfolio.erb +0 -43
@@ -0,0 +1,227 @@
1
+ # 📦 SQA::MultiTimeframe
2
+
3
+ !!! note "Description"
4
+ MultiTimeframe - Analyze patterns across multiple timeframes
5
+
6
+ Provides methods for:
7
+ - Timeframe conversion (daily → weekly → monthly)
8
+ - Multi-timeframe signal confirmation
9
+ - Trend alignment across timeframes
10
+ - Support/resistance across timeframes
11
+
12
+ Common timeframe strategy:
13
+ - Use higher timeframe for trend direction
14
+ - Use lower timeframe for entry timing
15
+
16
+ !!! abstract "Source Information"
17
+ **Defined in:** `lib/sqa/multi_timeframe.rb:23`
18
+
19
+ **Inherits from:** `Object`
20
+
21
+ ## 🔨 Instance Methods
22
+
23
+ ### `#stock()`
24
+
25
+ Returns the value of attribute stock.
26
+
27
+
28
+
29
+
30
+ ??? info "Source Location"
31
+ `lib/sqa/multi_timeframe.rb:24`
32
+
33
+ ---
34
+
35
+ ### `#timeframes()`
36
+
37
+ Returns the value of attribute timeframes.
38
+
39
+
40
+
41
+
42
+ ??? info "Source Location"
43
+ `lib/sqa/multi_timeframe.rb:24`
44
+
45
+ ---
46
+
47
+ ### `#initialize(stock:)`
48
+
49
+ Initialize multi-timeframe analyzer
50
+
51
+ !!! info "Parameters"
52
+
53
+ | Name | Type | Description |
54
+ |------|------|-------------|
55
+ | `stock` | `SQA::Stock` | Stock object with daily data |
56
+ !!! success "Returns"
57
+
58
+ **Type:** `MultiTimeframe`
59
+
60
+
61
+
62
+ a new instance of MultiTimeframe
63
+
64
+ ??? info "Source Location"
65
+ `lib/sqa/multi_timeframe.rb:31`
66
+
67
+ ---
68
+
69
+ ### `#convert_timeframes()`
70
+
71
+ Convert daily data to weekly and monthly
72
+
73
+
74
+
75
+
76
+ ??? info "Source Location"
77
+ `lib/sqa/multi_timeframe.rb:42`
78
+
79
+ ---
80
+
81
+ ### `#trend_alignment(lookback: = 20)`
82
+
83
+ Check trend alignment across timeframes
84
+
85
+ !!! info "Parameters"
86
+
87
+ | Name | Type | Description |
88
+ |------|------|-------------|
89
+ | `lookback` | `Integer` | Periods to look back for trend |
90
+ !!! success "Returns"
91
+
92
+ **Type:** `Hash`
93
+
94
+
95
+
96
+ Trend direction for each timeframe
97
+
98
+ ??? info "Source Location"
99
+ `lib/sqa/multi_timeframe.rb:56`
100
+
101
+ ---
102
+
103
+ ### `#signal(strategy_class:, higher_timeframe: = :weekly, lower_timeframe: = :daily)`
104
+
105
+ Generate multi-timeframe signal
106
+
107
+ Uses higher timeframe for trend, lower for timing.
108
+
109
+ !!! info "Parameters"
110
+
111
+ | Name | Type | Description |
112
+ |------|------|-------------|
113
+ | `strategy_class` | `Class` | Strategy to apply |
114
+ | `higher_timeframe` | `Symbol` | Timeframe for trend (:weekly, :monthly) |
115
+ | `lower_timeframe` | `Symbol` | Timeframe for entry (:daily, :weekly) |
116
+ !!! success "Returns"
117
+
118
+ **Type:** `Symbol`
119
+
120
+
121
+
122
+ :buy, :sell, or :hold
123
+
124
+ ??? info "Source Location"
125
+ `lib/sqa/multi_timeframe.rb:102`
126
+
127
+ ---
128
+
129
+ ### `#support_resistance(tolerance: = 0.02)`
130
+
131
+ Find support/resistance levels across timeframes
132
+
133
+ Levels that appear on multiple timeframes are stronger.
134
+
135
+ !!! info "Parameters"
136
+
137
+ | Name | Type | Description |
138
+ |------|------|-------------|
139
+ | `tolerance` | `Float` | Price tolerance for matching levels (default: 0.02 for 2%) |
140
+ !!! success "Returns"
141
+
142
+ **Type:** `Hash`
143
+
144
+
145
+
146
+ Support and resistance levels
147
+
148
+ ??? info "Source Location"
149
+ `lib/sqa/multi_timeframe.rb:138`
150
+
151
+ ---
152
+
153
+ ### `#indicators(indicator:, **options)`
154
+
155
+ Calculate indicators for each timeframe
156
+
157
+ !!! info "Parameters"
158
+
159
+ | Name | Type | Description |
160
+ |------|------|-------------|
161
+ | `indicator` | `Symbol` | Indicator to calculate |
162
+ | `options` | `Hash` | Indicator options |
163
+ !!! success "Returns"
164
+
165
+ **Type:** `Hash`
166
+
167
+
168
+
169
+ Indicator values for each timeframe
170
+
171
+ ??? info "Source Location"
172
+ `lib/sqa/multi_timeframe.rb:167`
173
+
174
+ ---
175
+
176
+ ### `#detect_divergence()`
177
+
178
+ Detect divergence across timeframes
179
+
180
+ Divergence occurs when price and indicator move in opposite directions.
181
+
182
+
183
+ !!! success "Returns"
184
+
185
+ **Type:** `Hash`
186
+
187
+
188
+
189
+ Divergence information
190
+
191
+ ??? info "Source Location"
192
+ `lib/sqa/multi_timeframe.rb:197`
193
+
194
+ ---
195
+
196
+ ### `#confirmation(strategy_class:)`
197
+
198
+ Check if timeframes confirm each other
199
+
200
+ !!! info "Parameters"
201
+
202
+ | Name | Type | Description |
203
+ |------|------|-------------|
204
+ | `strategy_class` | `Class` | Strategy to use |
205
+ !!! success "Returns"
206
+
207
+ **Type:** `Hash`
208
+
209
+
210
+
211
+ Confirmation status
212
+
213
+ ??? info "Source Location"
214
+ `lib/sqa/multi_timeframe.rb:228`
215
+
216
+ ---
217
+
218
+ ## 📝 Attributes
219
+
220
+ ### 👁️ `stock` <small>read-only</small>
221
+
222
+ Returns the value of attribute stock.
223
+
224
+ ### 👁️ `timeframes` <small>read-only</small>
225
+
226
+ Returns the value of attribute timeframes.
227
+
@@ -0,0 +1,195 @@
1
+ # 📦 SQA::PatternMatcher
2
+
3
+ !!! note "Description"
4
+ PatternMatcher - Find similar historical patterns
5
+
6
+ Provides methods for:
7
+ - Pattern similarity search (nearest-neighbor)
8
+ - Shape-based pattern matching
9
+ - Predict future moves based on similar past patterns
10
+ - Pattern clustering
11
+
12
+ Uses techniques:
13
+ - Euclidean distance
14
+ - Dynamic Time Warping (DTW)
15
+ - Pearson correlation
16
+
17
+ !!! abstract "Source Information"
18
+ **Defined in:** `lib/sqa/pattern_matcher.rb:24`
19
+
20
+ **Inherits from:** `Object`
21
+
22
+ ## 🔨 Instance Methods
23
+
24
+ ### `#stock()`
25
+
26
+ Returns the value of attribute stock.
27
+
28
+
29
+
30
+
31
+ ??? info "Source Location"
32
+ `lib/sqa/pattern_matcher.rb:25`
33
+
34
+ ---
35
+
36
+ ### `#prices()`
37
+
38
+ Returns the value of attribute prices.
39
+
40
+
41
+
42
+
43
+ ??? info "Source Location"
44
+ `lib/sqa/pattern_matcher.rb:25`
45
+
46
+ ---
47
+
48
+ ### `#initialize(stock:)`
49
+
50
+ Initialize pattern matcher
51
+
52
+ !!! info "Parameters"
53
+
54
+ | Name | Type | Description |
55
+ |------|------|-------------|
56
+ | `stock` | `SQA::Stock` | Stock object |
57
+ !!! success "Returns"
58
+
59
+ **Type:** `PatternMatcher`
60
+
61
+
62
+
63
+ a new instance of PatternMatcher
64
+
65
+ ??? info "Source Location"
66
+ `lib/sqa/pattern_matcher.rb:32`
67
+
68
+ ---
69
+
70
+ ### `#find_similar(lookback: = 10, num_matches: = 5, method: = :euclidean, normalize: = true)`
71
+
72
+ Find similar historical patterns to current pattern
73
+
74
+ !!! info "Parameters"
75
+
76
+ | Name | Type | Description |
77
+ |------|------|-------------|
78
+ | `lookback` | `Integer` | Pattern length (days) |
79
+ | `num_matches` | `Integer` | Number of similar patterns to find |
80
+ | `method` | `Symbol` | Distance method (:euclidean, :dtw, :correlation) |
81
+ | `normalize` | `Boolean` | Normalize patterns before comparison |
82
+ !!! success "Returns"
83
+
84
+ **Type:** `Array<Hash>`
85
+
86
+
87
+
88
+ Similar patterns with metadata
89
+
90
+ ??? info "Source Location"
91
+ `lib/sqa/pattern_matcher.rb:46`
92
+
93
+ ---
94
+
95
+ ### `#forecast(lookback: = 10, forecast_periods: = 5, num_matches: = 10)`
96
+
97
+ Predict future price movement based on similar patterns
98
+
99
+ !!! info "Parameters"
100
+
101
+ | Name | Type | Description |
102
+ |------|------|-------------|
103
+ | `lookback` | `Integer` | Pattern length |
104
+ | `forecast_periods` | `Integer` | Periods to forecast |
105
+ | `num_matches` | `Integer` | Number of similar patterns to use |
106
+ !!! success "Returns"
107
+
108
+ **Type:** `Hash`
109
+
110
+
111
+
112
+ Forecast with confidence intervals
113
+
114
+ ??? info "Source Location"
115
+ `lib/sqa/pattern_matcher.rb:107`
116
+
117
+ ---
118
+
119
+ ### `#detect_chart_pattern(pattern_type)`
120
+
121
+ Detect chart patterns (head & shoulders, double top, etc.)
122
+
123
+ !!! info "Parameters"
124
+
125
+ | Name | Type | Description |
126
+ |------|------|-------------|
127
+ | `pattern_type` | `Symbol` | Pattern to detect |
128
+ !!! success "Returns"
129
+
130
+ **Type:** `Array<Hash>`
131
+
132
+
133
+
134
+ Detected patterns
135
+
136
+ ??? info "Source Location"
137
+ `lib/sqa/pattern_matcher.rb:141`
138
+
139
+ ---
140
+
141
+ ### `#cluster_patterns(pattern_length: = 10, num_clusters: = 5)`
142
+
143
+ Cluster patterns by similarity
144
+
145
+ !!! info "Parameters"
146
+
147
+ | Name | Type | Description |
148
+ |------|------|-------------|
149
+ | `pattern_length` | `Integer` | Length of patterns |
150
+ | `num_clusters` | `Integer` | Number of clusters |
151
+ !!! success "Returns"
152
+
153
+ **Type:** `Array<Array<Hash>>`
154
+
155
+
156
+
157
+ Clusters of similar patterns
158
+
159
+ ??? info "Source Location"
160
+ `lib/sqa/pattern_matcher.rb:163`
161
+
162
+ ---
163
+
164
+ ### `#pattern_quality(pattern)`
165
+
166
+ Calculate pattern strength/quality
167
+
168
+ !!! info "Parameters"
169
+
170
+ | Name | Type | Description |
171
+ |------|------|-------------|
172
+ | `pattern` | `Array<Float>` | Price pattern |
173
+ !!! success "Returns"
174
+
175
+ **Type:** `Hash`
176
+
177
+
178
+
179
+ Pattern quality metrics
180
+
181
+ ??? info "Source Location"
182
+ `lib/sqa/pattern_matcher.rb:214`
183
+
184
+ ---
185
+
186
+ ## 📝 Attributes
187
+
188
+ ### 👁️ `stock` <small>read-only</small>
189
+
190
+ Returns the value of attribute stock.
191
+
192
+ ### 👁️ `prices` <small>read-only</small>
193
+
194
+ Returns the value of attribute prices.
195
+
@@ -0,0 +1,55 @@
1
+ # 📦 SQA::PluginManager
2
+
3
+ !!! abstract "Source Information"
4
+ **Defined in:** `lib/sqa/plugin_manager.rb:7`
5
+
6
+ **Inherits from:** `Object`
7
+
8
+ ## 🏭 Class Methods
9
+
10
+ ### `.registered_properties()`
11
+
12
+ Returns the value of attribute registered_properties.
13
+
14
+
15
+
16
+
17
+ ??? info "Source Location"
18
+ `lib/sqa/plugin_manager.rb:11`
19
+
20
+ ---
21
+
22
+ ### `.registered_properties=(value)`
23
+
24
+ Sets the attribute registered_properties
25
+
26
+ !!! info "Parameters"
27
+
28
+ | Name | Type | Description |
29
+ |------|------|-------------|
30
+ | `value` | `Any` | the value to set the attribute registered_properties to. |
31
+
32
+
33
+ ??? info "Source Location"
34
+ `lib/sqa/plugin_manager.rb:11`
35
+
36
+ ---
37
+
38
+ ### `.new_property(name, options = {})`
39
+
40
+ name (Symbol)
41
+
42
+
43
+
44
+
45
+ ??? info "Source Location"
46
+ `lib/sqa/plugin_manager.rb:15`
47
+
48
+ ---
49
+
50
+ ## 📝 Attributes
51
+
52
+ ### 🔄 `registered_properties` <small>read/write</small>
53
+
54
+ Returns the value of attribute registered_properties.
55
+