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
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
# 📦 SQA::Stock
|
|
2
|
+
|
|
3
|
+
!!! note "Description"
|
|
4
|
+
Represents a stock with price history, metadata, and technical analysis capabilities.
|
|
5
|
+
This is the primary domain object for interacting with stock data.
|
|
6
|
+
|
|
7
|
+
!!! abstract "Source Information"
|
|
8
|
+
**Defined in:** `lib/sqa/stock.rb:14`
|
|
9
|
+
|
|
10
|
+
**Inherits from:** `Object`
|
|
11
|
+
|
|
12
|
+
## 🏭 Class Methods
|
|
13
|
+
|
|
14
|
+
### `.connection()`
|
|
15
|
+
|
|
16
|
+
Returns the current Faraday connection for API requests.
|
|
17
|
+
Allows injection of custom connections for testing or different configurations.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
!!! success "Returns"
|
|
21
|
+
|
|
22
|
+
**Type:** `Faraday::Connection`
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
The current connection instance
|
|
27
|
+
|
|
28
|
+
??? info "Source Location"
|
|
29
|
+
`lib/sqa/stock.rb:30`
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
### `.connection=(conn)`
|
|
34
|
+
|
|
35
|
+
Sets a custom Faraday connection.
|
|
36
|
+
Useful for testing with mocks/stubs or configuring different API endpoints.
|
|
37
|
+
|
|
38
|
+
!!! info "Parameters"
|
|
39
|
+
|
|
40
|
+
| Name | Type | Description |
|
|
41
|
+
|------|------|-------------|
|
|
42
|
+
| `conn` | `Faraday::Connection` | Custom Faraday connection to use |
|
|
43
|
+
!!! success "Returns"
|
|
44
|
+
|
|
45
|
+
**Type:** `Faraday::Connection`
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
The connection that was set
|
|
50
|
+
|
|
51
|
+
??? info "Source Location"
|
|
52
|
+
`lib/sqa/stock.rb:39`
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### `.default_connection()`
|
|
57
|
+
|
|
58
|
+
Creates the default Faraday connection to Alpha Vantage.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
!!! success "Returns"
|
|
62
|
+
|
|
63
|
+
**Type:** `Faraday::Connection`
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
A new connection to Alpha Vantage API
|
|
68
|
+
|
|
69
|
+
??? info "Source Location"
|
|
70
|
+
`lib/sqa/stock.rb:46`
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### `.reset_connection!()`
|
|
75
|
+
|
|
76
|
+
Resets the connection to default.
|
|
77
|
+
Useful for testing cleanup to ensure fresh state between tests.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
!!! success "Returns"
|
|
81
|
+
|
|
82
|
+
**Type:** `nil`
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
??? info "Source Location"
|
|
87
|
+
`lib/sqa/stock.rb:54`
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### `.top()`
|
|
92
|
+
|
|
93
|
+
Fetches top gainers, losers, and most actively traded stocks from Alpha Vantage.
|
|
94
|
+
Results are cached after the first call.
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
!!! success "Returns"
|
|
98
|
+
|
|
99
|
+
**Type:** `Hashie::Mash`
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
Object with top_gainers, top_losers, and most_actively_traded arrays
|
|
104
|
+
!!! example "Usage Examples"
|
|
105
|
+
|
|
106
|
+
```ruby
|
|
107
|
+
top = SQA::Stock.top
|
|
108
|
+
top.top_gainers.each { |stock| puts "#{stock.ticker}: +#{stock.change_percentage}%" }
|
|
109
|
+
top.top_losers.first.ticker # => "XYZ"
|
|
110
|
+
```
|
|
111
|
+
??? info "Source Location"
|
|
112
|
+
`lib/sqa/stock.rb:341`
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### `.reset_top!()`
|
|
117
|
+
|
|
118
|
+
Resets the cached top gainers/losers data.
|
|
119
|
+
Useful for testing or forcing a refresh.
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
!!! success "Returns"
|
|
123
|
+
|
|
124
|
+
**Type:** `nil`
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
??? info "Source Location"
|
|
129
|
+
`lib/sqa/stock.rb:372`
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 🔨 Instance Methods
|
|
134
|
+
|
|
135
|
+
### `#data()`
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
!!! success "Returns"
|
|
139
|
+
|
|
140
|
+
**Type:** `SQA::DataFrame::Data`
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
Stock metadata (ticker, name, exchange, etc.)
|
|
145
|
+
|
|
146
|
+
??? info "Source Location"
|
|
147
|
+
`lib/sqa/stock.rb:69`
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### `#data=(value)`
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
!!! success "Returns"
|
|
155
|
+
|
|
156
|
+
**Type:** `SQA::DataFrame::Data`
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
Stock metadata (ticker, name, exchange, etc.)
|
|
161
|
+
|
|
162
|
+
??? info "Source Location"
|
|
163
|
+
`lib/sqa/stock.rb:69`
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### `#df()`
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
!!! success "Returns"
|
|
171
|
+
|
|
172
|
+
**Type:** `SQA::DataFrame`
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
Price and volume data as a DataFrame
|
|
177
|
+
|
|
178
|
+
??? info "Source Location"
|
|
179
|
+
`lib/sqa/stock.rb:69`
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
### `#df=(value)`
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
!!! success "Returns"
|
|
187
|
+
|
|
188
|
+
**Type:** `SQA::DataFrame`
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
Price and volume data as a DataFrame
|
|
193
|
+
|
|
194
|
+
??? info "Source Location"
|
|
195
|
+
`lib/sqa/stock.rb:69`
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
### `#klass()`
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
!!! success "Returns"
|
|
203
|
+
|
|
204
|
+
**Type:** `Class`
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
The data source class (e.g., SQA::DataFrame::AlphaVantage)
|
|
209
|
+
|
|
210
|
+
??? info "Source Location"
|
|
211
|
+
`lib/sqa/stock.rb:69`
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
### `#klass=(value)`
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
!!! success "Returns"
|
|
219
|
+
|
|
220
|
+
**Type:** `Class`
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
The data source class (e.g., SQA::DataFrame::AlphaVantage)
|
|
225
|
+
|
|
226
|
+
??? info "Source Location"
|
|
227
|
+
`lib/sqa/stock.rb:69`
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
### `#transformers()`
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
!!! success "Returns"
|
|
235
|
+
|
|
236
|
+
**Type:** `Hash`
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
Column transformers for data normalization
|
|
241
|
+
|
|
242
|
+
??? info "Source Location"
|
|
243
|
+
`lib/sqa/stock.rb:69`
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
### `#transformers=(value)`
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
!!! success "Returns"
|
|
251
|
+
|
|
252
|
+
**Type:** `Hash`
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
Column transformers for data normalization
|
|
257
|
+
|
|
258
|
+
??? info "Source Location"
|
|
259
|
+
`lib/sqa/stock.rb:69`
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
### `#strategy()`
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
!!! success "Returns"
|
|
267
|
+
|
|
268
|
+
**Type:** `SQA::Strategy, nil`
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
Optional trading strategy attached to this stock
|
|
273
|
+
|
|
274
|
+
??? info "Source Location"
|
|
275
|
+
`lib/sqa/stock.rb:69`
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
### `#strategy=(value)`
|
|
280
|
+
|
|
281
|
+
Sets the attribute strategy
|
|
282
|
+
|
|
283
|
+
!!! info "Parameters"
|
|
284
|
+
|
|
285
|
+
| Name | Type | Description |
|
|
286
|
+
|------|------|-------------|
|
|
287
|
+
| `value` | `Any` | the value to set the attribute strategy to. |
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
??? info "Source Location"
|
|
291
|
+
`lib/sqa/stock.rb:69`
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
### `#initialize(ticker:, source: = :alpha_vantage)`
|
|
296
|
+
|
|
297
|
+
Creates a new Stock instance and loads or fetches its data.
|
|
298
|
+
|
|
299
|
+
!!! info "Parameters"
|
|
300
|
+
|
|
301
|
+
| Name | Type | Description |
|
|
302
|
+
|------|------|-------------|
|
|
303
|
+
| `ticker` | `String` | The stock ticker symbol (e.g., 'AAPL', 'MSFT') |
|
|
304
|
+
| `source` | `Symbol` | The data source to use (:alpha_vantage or :yahoo_finance) |
|
|
305
|
+
!!! success "Returns"
|
|
306
|
+
|
|
307
|
+
**Type:** `Stock`
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
a new instance of Stock
|
|
312
|
+
!!! example "Usage Examples"
|
|
313
|
+
|
|
314
|
+
```ruby
|
|
315
|
+
stock = SQA::Stock.new(ticker: 'AAPL')
|
|
316
|
+
stock = SQA::Stock.new(ticker: 'GOOG', source: :yahoo_finance)
|
|
317
|
+
```
|
|
318
|
+
??? info "Source Location"
|
|
319
|
+
`lib/sqa/stock.rb:81`
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
### `#load_or_create_data()`
|
|
324
|
+
|
|
325
|
+
Loads existing data from cache or creates new data structure.
|
|
326
|
+
If cached data exists, loads from JSON file. Otherwise creates
|
|
327
|
+
minimal structure and attempts to fetch overview from API.
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
!!! success "Returns"
|
|
331
|
+
|
|
332
|
+
**Type:** `void`
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
??? info "Source Location"
|
|
337
|
+
`lib/sqa/stock.rb:107`
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
### `#create_data()`
|
|
342
|
+
|
|
343
|
+
Creates a new minimal data structure for the stock.
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
!!! success "Returns"
|
|
347
|
+
|
|
348
|
+
**Type:** `SQA::DataFrame::Data`
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
The newly created data object
|
|
353
|
+
|
|
354
|
+
??? info "Source Location"
|
|
355
|
+
`lib/sqa/stock.rb:126`
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
### `#update()`
|
|
360
|
+
|
|
361
|
+
Updates the stock's overview data from the API.
|
|
362
|
+
Silently handles errors since overview data is optional.
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
!!! success "Returns"
|
|
366
|
+
|
|
367
|
+
**Type:** `void`
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
??? info "Source Location"
|
|
372
|
+
`lib/sqa/stock.rb:134`
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
### `#save_data()`
|
|
377
|
+
|
|
378
|
+
Persists the stock's metadata to a JSON file.
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
!!! success "Returns"
|
|
382
|
+
|
|
383
|
+
**Type:** `Integer`
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
Number of bytes written
|
|
388
|
+
|
|
389
|
+
??? info "Source Location"
|
|
390
|
+
`lib/sqa/stock.rb:147`
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
### `#ticker()`
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
!!! success "Returns"
|
|
398
|
+
|
|
399
|
+
**Type:** `String`
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
The stock's ticker symbol
|
|
404
|
+
|
|
405
|
+
??? info "Source Location"
|
|
406
|
+
`lib/sqa/stock.rb:165`
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
### `#name()`
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
!!! success "Returns"
|
|
414
|
+
|
|
415
|
+
**Type:** `String, nil`
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
The company name
|
|
420
|
+
|
|
421
|
+
??? info "Source Location"
|
|
422
|
+
`lib/sqa/stock.rb:165`
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
### `#exchange()`
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
!!! success "Returns"
|
|
430
|
+
|
|
431
|
+
**Type:** `String, nil`
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
The exchange where the stock trades
|
|
436
|
+
|
|
437
|
+
??? info "Source Location"
|
|
438
|
+
`lib/sqa/stock.rb:165`
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
### `#source()`
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
!!! success "Returns"
|
|
446
|
+
|
|
447
|
+
**Type:** `Symbol`
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
The data source (:alpha_vantage or :yahoo_finance)
|
|
452
|
+
|
|
453
|
+
??? info "Source Location"
|
|
454
|
+
`lib/sqa/stock.rb:165`
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
### `#indicators()`
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
!!! success "Returns"
|
|
462
|
+
|
|
463
|
+
**Type:** `Hash`
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
Cached indicator values
|
|
468
|
+
|
|
469
|
+
??? info "Source Location"
|
|
470
|
+
`lib/sqa/stock.rb:165`
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
### `#indicators=(value)`
|
|
475
|
+
|
|
476
|
+
!!! info "Parameters"
|
|
477
|
+
|
|
478
|
+
| Name | Type | Description |
|
|
479
|
+
|------|------|-------------|
|
|
480
|
+
| `value` | `Hash` | New indicator values |
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
??? info "Source Location"
|
|
484
|
+
`lib/sqa/stock.rb:165`
|
|
485
|
+
|
|
486
|
+
---
|
|
487
|
+
|
|
488
|
+
### `#overview()`
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
!!! success "Returns"
|
|
492
|
+
|
|
493
|
+
**Type:** `Hash, nil`
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
Company overview data from API
|
|
498
|
+
|
|
499
|
+
??? info "Source Location"
|
|
500
|
+
`lib/sqa/stock.rb:165`
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
|
|
504
|
+
### `#update_dataframe()`
|
|
505
|
+
|
|
506
|
+
Updates the DataFrame with price data.
|
|
507
|
+
Loads from cache if available, otherwise fetches from API.
|
|
508
|
+
Applies migrations for old data formats and updates with recent data.
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
!!! success "Returns"
|
|
512
|
+
|
|
513
|
+
**Type:** `void`
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
??? info "Source Location"
|
|
518
|
+
`lib/sqa/stock.rb:173`
|
|
519
|
+
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
### `#update_dataframe_with_recent_data()`
|
|
523
|
+
|
|
524
|
+
Fetches recent data from API and appends to existing DataFrame.
|
|
525
|
+
Only called if should_update? returns true.
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
!!! success "Returns"
|
|
529
|
+
|
|
530
|
+
**Type:** `void`
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
??? info "Source Location"
|
|
535
|
+
`lib/sqa/stock.rb:228`
|
|
536
|
+
|
|
537
|
+
---
|
|
538
|
+
|
|
539
|
+
### `#update_the_dataframe()`
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
!!! success "Returns"
|
|
543
|
+
|
|
544
|
+
**Type:** `void`
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
??? info "Source Location"
|
|
549
|
+
`lib/sqa/stock.rb:250`
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
### `#should_update?()`
|
|
554
|
+
|
|
555
|
+
Determines whether the DataFrame should be updated from the API.
|
|
556
|
+
Returns false if lazy_update is enabled, API key is missing,
|
|
557
|
+
or data is already current.
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
!!! success "Returns"
|
|
561
|
+
|
|
562
|
+
**Type:** `Boolean`
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
true if update should proceed, false otherwise
|
|
567
|
+
|
|
568
|
+
??? info "Source Location"
|
|
569
|
+
`lib/sqa/stock.rb:260`
|
|
570
|
+
|
|
571
|
+
---
|
|
572
|
+
|
|
573
|
+
### `#to_s()`
|
|
574
|
+
|
|
575
|
+
Returns a human-readable string representation of the stock.
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
!!! success "Returns"
|
|
579
|
+
|
|
580
|
+
**Type:** `String`
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
Summary including ticker, data points count, and date range
|
|
585
|
+
!!! example "Usage Examples"
|
|
586
|
+
|
|
587
|
+
```ruby
|
|
588
|
+
stock.to_s # => "aapl with 252 data points from 2023-01-03 to 2023-12-29"
|
|
589
|
+
```
|
|
590
|
+
??? info "Source Location"
|
|
591
|
+
`lib/sqa/stock.rb:294`
|
|
592
|
+
|
|
593
|
+
---
|
|
594
|
+
|
|
595
|
+
### `#inspect()`
|
|
596
|
+
|
|
597
|
+
Returns a human-readable string representation of the stock.
|
|
598
|
+
Note: CSV data is stored in ascending chronological order (oldest to newest)
|
|
599
|
+
This ensures compatibility with TA-Lib indicators which expect arrays in this order
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
!!! success "Returns"
|
|
603
|
+
|
|
604
|
+
**Type:** `String`
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
Summary including ticker, data points count, and date range
|
|
609
|
+
!!! example "Usage Examples"
|
|
610
|
+
|
|
611
|
+
```ruby
|
|
612
|
+
stock.to_s # => "aapl with 252 data points from 2023-01-03 to 2023-12-29"
|
|
613
|
+
```
|
|
614
|
+
??? info "Source Location"
|
|
615
|
+
`lib/sqa/stock.rb:299`
|
|
616
|
+
|
|
617
|
+
---
|
|
618
|
+
|
|
619
|
+
### `#merge_overview()`
|
|
620
|
+
|
|
621
|
+
Fetches and merges company overview data from Alpha Vantage API.
|
|
622
|
+
Converts API response keys to snake_case and appropriate data types.
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
!!! success "Returns"
|
|
626
|
+
|
|
627
|
+
**Type:** `Hash`
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
The merged overview data
|
|
632
|
+
|
|
633
|
+
??? info "Source Location"
|
|
634
|
+
`lib/sqa/stock.rb:306`
|
|
635
|
+
|
|
636
|
+
---
|
|
637
|
+
|
|
638
|
+
## 📝 Attributes
|
|
639
|
+
|
|
640
|
+
### 🔄 `data` <small>read/write</small>
|
|
641
|
+
|
|
642
|
+
### 🔄 `df` <small>read/write</small>
|
|
643
|
+
|
|
644
|
+
### 🔄 `klass` <small>read/write</small>
|
|
645
|
+
|
|
646
|
+
### 🔄 `transformers` <small>read/write</small>
|
|
647
|
+
|
|
648
|
+
### 🔄 `strategy` <small>read/write</small>
|
|
649
|
+
|