sqa-tai 0.1.0 → 0.1.2
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 +39 -0
- data/Gemfile.lock +1 -1
- data/README.md +30 -2
- data/Rakefile +69 -0
- data/lib/sqa/tai/cycle_indicators.rb +72 -0
- data/lib/sqa/tai/help/data.json +697 -0
- data/lib/sqa/tai/help/resource.rb +66 -0
- data/lib/sqa/tai/help.rb +41 -0
- data/lib/sqa/tai/momentum_indicators.rb +517 -0
- data/lib/sqa/tai/overlap_studies.rb +144 -0
- data/lib/sqa/tai/pattern_recognition.rb +684 -0
- data/lib/sqa/tai/price_transform.rb +64 -0
- data/lib/sqa/tai/statistical_functions.rb +122 -0
- data/lib/sqa/tai/version.rb +1 -1
- data/lib/sqa/tai/volatility_indicators.rb +179 -0
- data/lib/sqa/tai/volume_indicators.rb +54 -0
- data/lib/sqa/tai.rb +73 -1792
- data/mkdocs.yml +8 -10
- metadata +12 -1
data/lib/sqa/tai.rb
CHANGED
|
@@ -6,12 +6,35 @@ require "ta_lib_ffi"
|
|
|
6
6
|
# Apply monkey patch to fix ta_lib_ffi 0.3.0 multi-array parameter bug
|
|
7
7
|
require_relative "../extensions/ta_lib_ffi"
|
|
8
8
|
|
|
9
|
+
# Require all indicator modules
|
|
10
|
+
require_relative "tai/overlap_studies"
|
|
11
|
+
require_relative "tai/momentum_indicators"
|
|
12
|
+
require_relative "tai/volatility_indicators"
|
|
13
|
+
require_relative "tai/volume_indicators"
|
|
14
|
+
require_relative "tai/price_transform"
|
|
15
|
+
require_relative "tai/cycle_indicators"
|
|
16
|
+
require_relative "tai/statistical_functions"
|
|
17
|
+
require_relative "tai/pattern_recognition"
|
|
18
|
+
|
|
19
|
+
# Require help system
|
|
20
|
+
require_relative "tai/help"
|
|
21
|
+
|
|
9
22
|
module SQA
|
|
10
23
|
module TAI
|
|
11
24
|
class Error < StandardError; end
|
|
12
25
|
class TAINotInstalledError < Error; end
|
|
13
26
|
class InvalidParameterError < Error; end
|
|
14
27
|
|
|
28
|
+
# Include all indicator modules
|
|
29
|
+
extend OverlapStudies
|
|
30
|
+
extend MomentumIndicators
|
|
31
|
+
extend VolatilityIndicators
|
|
32
|
+
extend VolumeIndicators
|
|
33
|
+
extend PriceTransform
|
|
34
|
+
extend CycleIndicators
|
|
35
|
+
extend StatisticalFunctions
|
|
36
|
+
extend PatternRecognition
|
|
37
|
+
|
|
15
38
|
class << self
|
|
16
39
|
# Check if TA-Lib C library is available
|
|
17
40
|
def available?
|
|
@@ -29,1810 +52,68 @@ module SQA
|
|
|
29
52
|
"Please install it from https://ta-lib.org/"
|
|
30
53
|
end
|
|
31
54
|
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
|
|
36
|
-
#
|
|
37
|
-
# @
|
|
38
|
-
# @
|
|
39
|
-
# @
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
#
|
|
50
|
-
# @
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
# Exponential Moving Average
|
|
62
|
-
# @param prices [Array<Float>] Array of prices
|
|
63
|
-
# @param period [Integer] Time period (default: 30)
|
|
64
|
-
# @return [Array<Float>] EMA values
|
|
65
|
-
def ema(prices, period: 30)
|
|
66
|
-
check_available!
|
|
67
|
-
validate_prices!(prices)
|
|
68
|
-
validate_period!(period, prices.size)
|
|
69
|
-
|
|
70
|
-
TALibFFI.ema(prices, time_period: period)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# Weighted Moving Average
|
|
74
|
-
# @param prices [Array<Float>] Array of prices
|
|
75
|
-
# @param period [Integer] Time period (default: 30)
|
|
76
|
-
# @return [Array<Float>] WMA values
|
|
77
|
-
def wma(prices, period: 30)
|
|
78
|
-
check_available!
|
|
79
|
-
validate_prices!(prices)
|
|
80
|
-
validate_period!(period, prices.size)
|
|
81
|
-
|
|
82
|
-
TALibFFI.wma(prices, time_period: period)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# Double Exponential Moving Average
|
|
86
|
-
# @param prices [Array<Float>] Array of prices
|
|
87
|
-
# @param period [Integer] Time period (default: 30)
|
|
88
|
-
# @return [Array<Float>] DEMA values
|
|
89
|
-
def dema(prices, period: 30)
|
|
90
|
-
check_available!
|
|
91
|
-
validate_prices!(prices)
|
|
92
|
-
validate_period!(period, prices.size)
|
|
93
|
-
|
|
94
|
-
TALibFFI.dema(prices, time_period: period)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
# Triple Exponential Moving Average
|
|
98
|
-
# @param prices [Array<Float>] Array of prices
|
|
99
|
-
# @param period [Integer] Time period (default: 30)
|
|
100
|
-
# @return [Array<Float>] TEMA values
|
|
101
|
-
def tema(prices, period: 30)
|
|
102
|
-
check_available!
|
|
103
|
-
validate_prices!(prices)
|
|
104
|
-
validate_period!(period, prices.size)
|
|
105
|
-
|
|
106
|
-
TALibFFI.tema(prices, time_period: period)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# Triangular Moving Average
|
|
110
|
-
# @param prices [Array<Float>] Array of prices
|
|
111
|
-
# @param period [Integer] Time period (default: 30)
|
|
112
|
-
# @return [Array<Float>] TRIMA values
|
|
113
|
-
def trima(prices, period: 30)
|
|
114
|
-
check_available!
|
|
115
|
-
validate_prices!(prices)
|
|
116
|
-
validate_period!(period, prices.size)
|
|
117
|
-
|
|
118
|
-
TALibFFI.trima(prices, time_period: period)
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
# Kaufman Adaptive Moving Average
|
|
122
|
-
# @param prices [Array<Float>] Array of prices
|
|
123
|
-
# @param period [Integer] Time period (default: 30)
|
|
124
|
-
# @return [Array<Float>] KAMA values
|
|
125
|
-
def kama(prices, period: 30)
|
|
126
|
-
check_available!
|
|
127
|
-
validate_prices!(prices)
|
|
128
|
-
validate_period!(period, prices.size)
|
|
129
|
-
|
|
130
|
-
TALibFFI.kama(prices, time_period: period)
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
# Triple Exponential Moving Average (T3)
|
|
134
|
-
# @param prices [Array<Float>] Array of prices
|
|
135
|
-
# @param period [Integer] Time period (default: 5)
|
|
136
|
-
# @param vfactor [Float] Volume factor (default: 0.7)
|
|
137
|
-
# @return [Array<Float>] T3 values
|
|
138
|
-
def t3(prices, period: 5, vfactor: 0.7)
|
|
139
|
-
check_available!
|
|
140
|
-
validate_prices!(prices)
|
|
141
|
-
validate_period!(period, prices.size)
|
|
142
|
-
|
|
143
|
-
TALibFFI.t3(prices, time_period: period, vfactor: vfactor)
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
# Bollinger Bands
|
|
147
|
-
# @param prices [Array<Float>] Array of prices
|
|
148
|
-
# @param period [Integer] Time period (default: 5)
|
|
149
|
-
# @param nbdev_up [Float] Upper deviation (default: 2.0)
|
|
150
|
-
# @param nbdev_down [Float] Lower deviation (default: 2.0)
|
|
151
|
-
# @return [Array<Array<Float>>] [upper_band, middle_band, lower_band]
|
|
152
|
-
def bbands(prices, period: 5, nbdev_up: 2.0, nbdev_down: 2.0)
|
|
153
|
-
check_available!
|
|
154
|
-
validate_prices!(prices)
|
|
155
|
-
validate_period!(period, prices.size)
|
|
156
|
-
|
|
157
|
-
result = TALibFFI.bbands(
|
|
158
|
-
prices,
|
|
159
|
-
time_period: period,
|
|
160
|
-
nbdev_up: nbdev_up,
|
|
161
|
-
nbdev_dn: nbdev_down
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
# Handle hash return format from newer ta_lib_ffi versions
|
|
165
|
-
if result.is_a?(Hash)
|
|
166
|
-
[result[:upper_band], result[:middle_band], result[:lower_band]]
|
|
167
|
-
else
|
|
168
|
-
result
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
# ========================================
|
|
173
|
-
# Momentum Indicators
|
|
174
|
-
# ========================================
|
|
175
|
-
|
|
176
|
-
# Relative Strength Index
|
|
177
|
-
# @param prices [Array<Float>] Array of prices
|
|
178
|
-
# @param period [Integer] Time period (default: 14)
|
|
179
|
-
# @return [Array<Float>] RSI values
|
|
180
|
-
def rsi(prices, period: 14)
|
|
181
|
-
check_available!
|
|
182
|
-
validate_prices!(prices)
|
|
183
|
-
validate_period!(period, prices.size)
|
|
184
|
-
|
|
185
|
-
TALibFFI.rsi(prices, time_period: period)
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
# Intraday Momentum Index
|
|
189
|
-
# @param open_prices [Array<Float>] Array of open prices
|
|
190
|
-
# @param close_prices [Array<Float>] Array of close prices
|
|
191
|
-
# @param period [Integer] Time period (default: 14)
|
|
192
|
-
# @return [Array<Float>] IMI values
|
|
193
|
-
def imi(open_prices, close_prices, period: 14)
|
|
194
|
-
check_available!
|
|
195
|
-
validate_prices!(open_prices)
|
|
196
|
-
validate_prices!(close_prices)
|
|
197
|
-
validate_period!(period, [open_prices.size, close_prices.size].min)
|
|
198
|
-
|
|
199
|
-
TALibFFI.imi(open_prices, close_prices, time_period: period)
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
# Moving Average Convergence/Divergence
|
|
203
|
-
# @param prices [Array<Float>] Array of prices
|
|
204
|
-
# @param fast_period [Integer] Fast period (default: 12)
|
|
205
|
-
# @param slow_period [Integer] Slow period (default: 26)
|
|
206
|
-
# @param signal_period [Integer] Signal period (default: 9)
|
|
207
|
-
# @return [Array<Array<Float>>] [macd, signal, histogram]
|
|
208
|
-
def macd(prices, fast_period: 12, slow_period: 26, signal_period: 9)
|
|
209
|
-
check_available!
|
|
210
|
-
validate_prices!(prices)
|
|
211
|
-
|
|
212
|
-
result = TALibFFI.macd(
|
|
213
|
-
prices,
|
|
214
|
-
fast_period: fast_period,
|
|
215
|
-
slow_period: slow_period,
|
|
216
|
-
signal_period: signal_period
|
|
217
|
-
)
|
|
218
|
-
|
|
219
|
-
# Handle hash return format from newer ta_lib_ffi versions
|
|
220
|
-
if result.is_a?(Hash)
|
|
221
|
-
[result[:macd], result[:macd_signal], result[:macd_hist]]
|
|
222
|
-
else
|
|
223
|
-
result
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
# Stochastic Oscillator
|
|
228
|
-
# @param high [Array<Float>] High prices
|
|
229
|
-
# @param low [Array<Float>] Low prices
|
|
230
|
-
# @param close [Array<Float>] Close prices
|
|
231
|
-
# @param fastk_period [Integer] Fast K period (default: 5)
|
|
232
|
-
# @param slowk_period [Integer] Slow K period (default: 3)
|
|
233
|
-
# @param slowd_period [Integer] Slow D period (default: 3)
|
|
234
|
-
# @return [Array<Array<Float>>] [slowk, slowd]
|
|
235
|
-
def stoch(high, low, close, fastk_period: 5, slowk_period: 3, slowd_period: 3)
|
|
236
|
-
check_available!
|
|
237
|
-
validate_prices!(high)
|
|
238
|
-
validate_prices!(low)
|
|
239
|
-
validate_prices!(close)
|
|
240
|
-
|
|
241
|
-
result = TALibFFI.stoch(
|
|
242
|
-
high,
|
|
243
|
-
low,
|
|
244
|
-
close,
|
|
245
|
-
fastk_period: fastk_period,
|
|
246
|
-
slowk_period: slowk_period,
|
|
247
|
-
slowd_period: slowd_period
|
|
248
|
-
)
|
|
249
|
-
|
|
250
|
-
# Handle hash return format from newer ta_lib_ffi versions
|
|
251
|
-
if result.is_a?(Hash)
|
|
252
|
-
[result[:slow_k], result[:slow_d]]
|
|
253
|
-
else
|
|
254
|
-
result
|
|
255
|
-
end
|
|
256
|
-
end
|
|
257
|
-
|
|
258
|
-
# Momentum
|
|
259
|
-
# @param prices [Array<Float>] Array of prices
|
|
260
|
-
# @param period [Integer] Time period (default: 10)
|
|
261
|
-
# @return [Array<Float>] Momentum values
|
|
262
|
-
def mom(prices, period: 10)
|
|
263
|
-
check_available!
|
|
264
|
-
validate_prices!(prices)
|
|
265
|
-
validate_period!(period, prices.size)
|
|
266
|
-
|
|
267
|
-
TALibFFI.mom(prices, time_period: period)
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
# Commodity Channel Index
|
|
271
|
-
# @param high [Array<Float>] High prices
|
|
272
|
-
# @param low [Array<Float>] Low prices
|
|
273
|
-
# @param close [Array<Float>] Close prices
|
|
274
|
-
# @param period [Integer] Time period (default: 14)
|
|
275
|
-
# @return [Array<Float>] CCI values
|
|
276
|
-
def cci(high, low, close, period: 14)
|
|
277
|
-
check_available!
|
|
278
|
-
validate_prices!(high)
|
|
279
|
-
validate_prices!(low)
|
|
280
|
-
validate_prices!(close)
|
|
281
|
-
|
|
282
|
-
TALibFFI.cci(high, low, close, time_period: period)
|
|
283
|
-
end
|
|
284
|
-
|
|
285
|
-
# Williams' %R
|
|
286
|
-
# @param high [Array<Float>] High prices
|
|
287
|
-
# @param low [Array<Float>] Low prices
|
|
288
|
-
# @param close [Array<Float>] Close prices
|
|
289
|
-
# @param period [Integer] Time period (default: 14)
|
|
290
|
-
# @return [Array<Float>] WILLR values
|
|
291
|
-
def willr(high, low, close, period: 14)
|
|
292
|
-
check_available!
|
|
293
|
-
validate_prices!(high)
|
|
294
|
-
validate_prices!(low)
|
|
295
|
-
validate_prices!(close)
|
|
296
|
-
|
|
297
|
-
TALibFFI.willr(high, low, close, time_period: period)
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
# Rate of Change
|
|
301
|
-
# @param prices [Array<Float>] Array of prices
|
|
302
|
-
# @param period [Integer] Time period (default: 10)
|
|
303
|
-
# @return [Array<Float>] ROC values
|
|
304
|
-
def roc(prices, period: 10)
|
|
305
|
-
check_available!
|
|
306
|
-
validate_prices!(prices)
|
|
307
|
-
validate_period!(period, prices.size)
|
|
308
|
-
|
|
309
|
-
TALibFFI.roc(prices, time_period: period)
|
|
310
|
-
end
|
|
311
|
-
|
|
312
|
-
# Rate of Change Percentage
|
|
313
|
-
# @param prices [Array<Float>] Array of prices
|
|
314
|
-
# @param period [Integer] Time period (default: 10)
|
|
315
|
-
# @return [Array<Float>] ROCP values
|
|
316
|
-
def rocp(prices, period: 10)
|
|
317
|
-
check_available!
|
|
318
|
-
validate_prices!(prices)
|
|
319
|
-
validate_period!(period, prices.size)
|
|
320
|
-
|
|
321
|
-
TALibFFI.rocp(prices, time_period: period)
|
|
322
|
-
end
|
|
323
|
-
|
|
324
|
-
# Rate of Change Ratio
|
|
325
|
-
# @param prices [Array<Float>] Array of prices
|
|
326
|
-
# @param period [Integer] Time period (default: 10)
|
|
327
|
-
# @return [Array<Float>] ROCR values
|
|
328
|
-
def rocr(prices, period: 10)
|
|
329
|
-
check_available!
|
|
330
|
-
validate_prices!(prices)
|
|
331
|
-
validate_period!(period, prices.size)
|
|
332
|
-
|
|
333
|
-
TALibFFI.rocr(prices, time_period: period)
|
|
334
|
-
end
|
|
335
|
-
|
|
336
|
-
# Percentage Price Oscillator
|
|
337
|
-
# @param prices [Array<Float>] Array of prices
|
|
338
|
-
# @param fast_period [Integer] Fast period (default: 12)
|
|
339
|
-
# @param slow_period [Integer] Slow period (default: 26)
|
|
340
|
-
# @param ma_type [Integer] Moving average type (default: 0)
|
|
341
|
-
# @return [Array<Float>] PPO values
|
|
342
|
-
def ppo(prices, fast_period: 12, slow_period: 26, ma_type: 0)
|
|
343
|
-
check_available!
|
|
344
|
-
validate_prices!(prices)
|
|
345
|
-
|
|
346
|
-
TALibFFI.ppo(prices, fast_period: fast_period, slow_period: slow_period, ma_type: ma_type)
|
|
347
|
-
end
|
|
348
|
-
|
|
349
|
-
# Average Directional Movement Index
|
|
350
|
-
# @param high [Array<Float>] High prices
|
|
351
|
-
# @param low [Array<Float>] Low prices
|
|
352
|
-
# @param close [Array<Float>] Close prices
|
|
353
|
-
# @param period [Integer] Time period (default: 14)
|
|
354
|
-
# @return [Array<Float>] ADX values
|
|
355
|
-
def adx(high, low, close, period: 14)
|
|
356
|
-
check_available!
|
|
357
|
-
validate_prices!(high)
|
|
358
|
-
validate_prices!(low)
|
|
359
|
-
validate_prices!(close)
|
|
360
|
-
|
|
361
|
-
TALibFFI.adx(high, low, close, time_period: period)
|
|
362
|
-
end
|
|
363
|
-
|
|
364
|
-
# Average Directional Movement Index Rating
|
|
365
|
-
# @param high [Array<Float>] High prices
|
|
366
|
-
# @param low [Array<Float>] Low prices
|
|
367
|
-
# @param close [Array<Float>] Close prices
|
|
368
|
-
# @param period [Integer] Time period (default: 14)
|
|
369
|
-
# @return [Array<Float>] ADXR values
|
|
370
|
-
def adxr(high, low, close, period: 14)
|
|
371
|
-
check_available!
|
|
372
|
-
validate_prices!(high)
|
|
373
|
-
validate_prices!(low)
|
|
374
|
-
validate_prices!(close)
|
|
375
|
-
|
|
376
|
-
TALibFFI.adxr(high, low, close, time_period: period)
|
|
377
|
-
end
|
|
378
|
-
|
|
379
|
-
# Absolute Price Oscillator
|
|
380
|
-
# @param prices [Array<Float>] Array of prices
|
|
381
|
-
# @param fast_period [Integer] Fast period (default: 12)
|
|
382
|
-
# @param slow_period [Integer] Slow period (default: 26)
|
|
383
|
-
# @param ma_type [Integer] Moving average type (default: 0)
|
|
384
|
-
# @return [Array<Float>] APO values
|
|
385
|
-
def apo(prices, fast_period: 12, slow_period: 26, ma_type: 0)
|
|
386
|
-
check_available!
|
|
387
|
-
validate_prices!(prices)
|
|
388
|
-
|
|
389
|
-
TALibFFI.apo(prices, fast_period: fast_period, slow_period: slow_period, ma_type: ma_type)
|
|
390
|
-
end
|
|
391
|
-
|
|
392
|
-
# Aroon
|
|
393
|
-
# @param high [Array<Float>] High prices
|
|
394
|
-
# @param low [Array<Float>] Low prices
|
|
395
|
-
# @param period [Integer] Time period (default: 14)
|
|
396
|
-
# @return [Array<Array<Float>>] [aroon_down, aroon_up]
|
|
397
|
-
def aroon(high, low, period: 14)
|
|
398
|
-
check_available!
|
|
399
|
-
validate_prices!(high)
|
|
400
|
-
validate_prices!(low)
|
|
401
|
-
|
|
402
|
-
result = TALibFFI.aroon(high, low, time_period: period)
|
|
403
|
-
|
|
404
|
-
# Handle hash return format from newer ta_lib_ffi versions
|
|
405
|
-
if result.is_a?(Hash)
|
|
406
|
-
[result[:aroon_down], result[:aroon_up]]
|
|
407
|
-
else
|
|
408
|
-
result
|
|
409
|
-
end
|
|
410
|
-
end
|
|
411
|
-
|
|
412
|
-
# Aroon Oscillator
|
|
413
|
-
# @param high [Array<Float>] High prices
|
|
414
|
-
# @param low [Array<Float>] Low prices
|
|
415
|
-
# @param period [Integer] Time period (default: 14)
|
|
416
|
-
# @return [Array<Float>] AROONOSC values
|
|
417
|
-
def aroonosc(high, low, period: 14)
|
|
418
|
-
check_available!
|
|
419
|
-
validate_prices!(high)
|
|
420
|
-
validate_prices!(low)
|
|
421
|
-
|
|
422
|
-
TALibFFI.aroonosc(high, low, time_period: period)
|
|
423
|
-
end
|
|
424
|
-
|
|
425
|
-
# Balance of Power
|
|
426
|
-
# @param open [Array<Float>] Open prices
|
|
427
|
-
# @param high [Array<Float>] High prices
|
|
428
|
-
# @param low [Array<Float>] Low prices
|
|
429
|
-
# @param close [Array<Float>] Close prices
|
|
430
|
-
# @return [Array<Float>] BOP values
|
|
431
|
-
def bop(open, high, low, close)
|
|
432
|
-
check_available!
|
|
433
|
-
validate_prices!(open)
|
|
434
|
-
validate_prices!(high)
|
|
435
|
-
validate_prices!(low)
|
|
436
|
-
validate_prices!(close)
|
|
437
|
-
|
|
438
|
-
TALibFFI.bop(open, high, low, close)
|
|
439
|
-
end
|
|
440
|
-
|
|
441
|
-
# Chande Momentum Oscillator
|
|
442
|
-
# @param prices [Array<Float>] Array of prices
|
|
443
|
-
# @param period [Integer] Time period (default: 14)
|
|
444
|
-
# @return [Array<Float>] CMO values
|
|
445
|
-
def cmo(prices, period: 14)
|
|
446
|
-
check_available!
|
|
447
|
-
validate_prices!(prices)
|
|
448
|
-
validate_period!(period, prices.size)
|
|
449
|
-
|
|
450
|
-
TALibFFI.cmo(prices, time_period: period)
|
|
451
|
-
end
|
|
452
|
-
|
|
453
|
-
# Directional Movement Index
|
|
454
|
-
# @param high [Array<Float>] High prices
|
|
455
|
-
# @param low [Array<Float>] Low prices
|
|
456
|
-
# @param close [Array<Float>] Close prices
|
|
457
|
-
# @param period [Integer] Time period (default: 14)
|
|
458
|
-
# @return [Array<Float>] DX values
|
|
459
|
-
def dx(high, low, close, period: 14)
|
|
460
|
-
check_available!
|
|
461
|
-
validate_prices!(high)
|
|
462
|
-
validate_prices!(low)
|
|
463
|
-
validate_prices!(close)
|
|
464
|
-
|
|
465
|
-
TALibFFI.dx(high, low, close, time_period: period)
|
|
466
|
-
end
|
|
467
|
-
|
|
468
|
-
# MACD with Controllable MA Type
|
|
469
|
-
# @param prices [Array<Float>] Array of prices
|
|
470
|
-
# @param fast_period [Integer] Fast period (default: 12)
|
|
471
|
-
# @param fast_ma_type [Integer] Fast MA type (default: 0)
|
|
472
|
-
# @param slow_period [Integer] Slow period (default: 26)
|
|
473
|
-
# @param slow_ma_type [Integer] Slow MA type (default: 0)
|
|
474
|
-
# @param signal_period [Integer] Signal period (default: 9)
|
|
475
|
-
# @param signal_ma_type [Integer] Signal MA type (default: 0)
|
|
476
|
-
# @return [Array<Array<Float>>] [macd, signal, histogram]
|
|
477
|
-
def macdext(prices, fast_period: 12, fast_ma_type: 0, slow_period: 26, slow_ma_type: 0, signal_period: 9, signal_ma_type: 0)
|
|
478
|
-
check_available!
|
|
479
|
-
validate_prices!(prices)
|
|
480
|
-
|
|
481
|
-
result = TALibFFI.macdext(
|
|
482
|
-
prices,
|
|
483
|
-
fast_period: fast_period,
|
|
484
|
-
fast_ma_type: fast_ma_type,
|
|
485
|
-
slow_period: slow_period,
|
|
486
|
-
slow_ma_type: slow_ma_type,
|
|
487
|
-
signal_period: signal_period,
|
|
488
|
-
signal_ma_type: signal_ma_type
|
|
489
|
-
)
|
|
490
|
-
|
|
491
|
-
# Handle hash return format from newer ta_lib_ffi versions
|
|
492
|
-
if result.is_a?(Hash)
|
|
493
|
-
[result[:macd], result[:macd_signal], result[:macd_hist]]
|
|
494
|
-
else
|
|
495
|
-
result
|
|
496
|
-
end
|
|
497
|
-
end
|
|
498
|
-
|
|
499
|
-
# MACD Fix 12/26
|
|
500
|
-
# @param prices [Array<Float>] Array of prices
|
|
501
|
-
# @param signal_period [Integer] Signal period (default: 9)
|
|
502
|
-
# @return [Array<Array<Float>>] [macd, signal, histogram]
|
|
503
|
-
def macdfix(prices, signal_period: 9)
|
|
504
|
-
check_available!
|
|
505
|
-
validate_prices!(prices)
|
|
506
|
-
|
|
507
|
-
result = TALibFFI.macdfix(prices, signal_period: signal_period)
|
|
508
|
-
|
|
509
|
-
# Handle hash return format from newer ta_lib_ffi versions
|
|
510
|
-
if result.is_a?(Hash)
|
|
511
|
-
[result[:macd], result[:macd_signal], result[:macd_hist]]
|
|
512
|
-
else
|
|
513
|
-
result
|
|
514
|
-
end
|
|
515
|
-
end
|
|
516
|
-
|
|
517
|
-
# Money Flow Index
|
|
518
|
-
# @param high [Array<Float>] High prices
|
|
519
|
-
# @param low [Array<Float>] Low prices
|
|
520
|
-
# @param close [Array<Float>] Close prices
|
|
521
|
-
# @param volume [Array<Float>] Volume values
|
|
522
|
-
# @param period [Integer] Time period (default: 14)
|
|
523
|
-
# @return [Array<Float>] MFI values
|
|
524
|
-
def mfi(high, low, close, volume, period: 14)
|
|
525
|
-
check_available!
|
|
526
|
-
validate_prices!(high)
|
|
527
|
-
validate_prices!(low)
|
|
528
|
-
validate_prices!(close)
|
|
529
|
-
validate_prices!(volume)
|
|
530
|
-
|
|
531
|
-
TALibFFI.mfi(high, low, close, volume, time_period: period)
|
|
532
|
-
end
|
|
533
|
-
|
|
534
|
-
# Minus Directional Indicator
|
|
535
|
-
# @param high [Array<Float>] High prices
|
|
536
|
-
# @param low [Array<Float>] Low prices
|
|
537
|
-
# @param close [Array<Float>] Close prices
|
|
538
|
-
# @param period [Integer] Time period (default: 14)
|
|
539
|
-
# @return [Array<Float>] MINUS_DI values
|
|
540
|
-
def minus_di(high, low, close, period: 14)
|
|
541
|
-
check_available!
|
|
542
|
-
validate_prices!(high)
|
|
543
|
-
validate_prices!(low)
|
|
544
|
-
validate_prices!(close)
|
|
545
|
-
|
|
546
|
-
TALibFFI.minus_di(high, low, close, time_period: period)
|
|
547
|
-
end
|
|
548
|
-
|
|
549
|
-
# Minus Directional Movement
|
|
550
|
-
# @param high [Array<Float>] High prices
|
|
551
|
-
# @param low [Array<Float>] Low prices
|
|
552
|
-
# @param period [Integer] Time period (default: 14)
|
|
553
|
-
# @return [Array<Float>] MINUS_DM values
|
|
554
|
-
def minus_dm(high, low, period: 14)
|
|
555
|
-
check_available!
|
|
556
|
-
validate_prices!(high)
|
|
557
|
-
validate_prices!(low)
|
|
558
|
-
|
|
559
|
-
TALibFFI.minus_dm(high, low, time_period: period)
|
|
560
|
-
end
|
|
561
|
-
|
|
562
|
-
# Plus Directional Indicator
|
|
563
|
-
# @param high [Array<Float>] High prices
|
|
564
|
-
# @param low [Array<Float>] Low prices
|
|
565
|
-
# @param close [Array<Float>] Close prices
|
|
566
|
-
# @param period [Integer] Time period (default: 14)
|
|
567
|
-
# @return [Array<Float>] PLUS_DI values
|
|
568
|
-
def plus_di(high, low, close, period: 14)
|
|
569
|
-
check_available!
|
|
570
|
-
validate_prices!(high)
|
|
571
|
-
validate_prices!(low)
|
|
572
|
-
validate_prices!(close)
|
|
573
|
-
|
|
574
|
-
TALibFFI.plus_di(high, low, close, time_period: period)
|
|
575
|
-
end
|
|
576
|
-
|
|
577
|
-
# Plus Directional Movement
|
|
578
|
-
# @param high [Array<Float>] High prices
|
|
579
|
-
# @param low [Array<Float>] Low prices
|
|
580
|
-
# @param period [Integer] Time period (default: 14)
|
|
581
|
-
# @return [Array<Float>] PLUS_DM values
|
|
582
|
-
def plus_dm(high, low, period: 14)
|
|
583
|
-
check_available!
|
|
584
|
-
validate_prices!(high)
|
|
585
|
-
validate_prices!(low)
|
|
586
|
-
|
|
587
|
-
TALibFFI.plus_dm(high, low, time_period: period)
|
|
588
|
-
end
|
|
589
|
-
|
|
590
|
-
# Rate of Change Ratio 100 scale
|
|
591
|
-
# @param prices [Array<Float>] Array of prices
|
|
592
|
-
# @param period [Integer] Time period (default: 10)
|
|
593
|
-
# @return [Array<Float>] ROCR100 values
|
|
594
|
-
def rocr100(prices, period: 10)
|
|
595
|
-
check_available!
|
|
596
|
-
validate_prices!(prices)
|
|
597
|
-
validate_period!(period, prices.size)
|
|
598
|
-
|
|
599
|
-
TALibFFI.rocr100(prices, time_period: period)
|
|
600
|
-
end
|
|
601
|
-
|
|
602
|
-
# Stochastic Fast
|
|
603
|
-
# @param high [Array<Float>] High prices
|
|
604
|
-
# @param low [Array<Float>] Low prices
|
|
605
|
-
# @param close [Array<Float>] Close prices
|
|
606
|
-
# @param fastk_period [Integer] Fast K period (default: 5)
|
|
607
|
-
# @param fastd_period [Integer] Fast D period (default: 3)
|
|
608
|
-
# @return [Array<Array<Float>>] [fastk, fastd]
|
|
609
|
-
def stochf(high, low, close, fastk_period: 5, fastd_period: 3)
|
|
610
|
-
check_available!
|
|
611
|
-
validate_prices!(high)
|
|
612
|
-
validate_prices!(low)
|
|
613
|
-
validate_prices!(close)
|
|
614
|
-
|
|
615
|
-
result = TALibFFI.stochf(
|
|
616
|
-
high,
|
|
617
|
-
low,
|
|
618
|
-
close,
|
|
619
|
-
fastk_period: fastk_period,
|
|
620
|
-
fastd_period: fastd_period
|
|
621
|
-
)
|
|
622
|
-
|
|
623
|
-
# Handle hash return format from newer ta_lib_ffi versions
|
|
624
|
-
if result.is_a?(Hash)
|
|
625
|
-
[result[:fast_k], result[:fast_d]]
|
|
626
|
-
else
|
|
627
|
-
result
|
|
55
|
+
# Get help documentation for indicators
|
|
56
|
+
#
|
|
57
|
+
# @param indicator [Symbol, nil] The indicator to get help for
|
|
58
|
+
# @param options [Hash] Options for help output
|
|
59
|
+
# @option options [Symbol] :category Filter by category
|
|
60
|
+
# @option options [String] :search Search for indicators
|
|
61
|
+
# @option options [Boolean] :open Open URL in browser
|
|
62
|
+
# @option options [Symbol] :format Return format (:uri, :hash, or Help::Resource)
|
|
63
|
+
#
|
|
64
|
+
# @return [Help::Resource, Hash, String, URI] Help information
|
|
65
|
+
#
|
|
66
|
+
# @example Get help for SMA
|
|
67
|
+
# SQA::TAI.help(:sma)
|
|
68
|
+
# # => #<SQA::TAI::Help::Resource ...>
|
|
69
|
+
#
|
|
70
|
+
# @example Open help in browser
|
|
71
|
+
# SQA::TAI.help(:rsi, open: true)
|
|
72
|
+
#
|
|
73
|
+
# @example List all momentum indicators
|
|
74
|
+
# SQA::TAI.help(category: :momentum_indicators)
|
|
75
|
+
#
|
|
76
|
+
# @example Search for indicators
|
|
77
|
+
# SQA::TAI.help(search: "moving average")
|
|
78
|
+
#
|
|
79
|
+
def help(indicator = nil, **options)
|
|
80
|
+
# List all indicators
|
|
81
|
+
if indicator == :all
|
|
82
|
+
return Help.indicators.transform_values { |meta| "#{Help::BASE_URL}/#{meta[:path]}/" }
|
|
628
83
|
end
|
|
629
|
-
end
|
|
630
|
-
|
|
631
|
-
# Stochastic RSI
|
|
632
|
-
# @param prices [Array<Float>] Array of prices
|
|
633
|
-
# @param period [Integer] Time period (default: 14)
|
|
634
|
-
# @param fastk_period [Integer] Fast K period (default: 5)
|
|
635
|
-
# @param fastd_period [Integer] Fast D period (default: 3)
|
|
636
|
-
# @return [Array<Array<Float>>] [fastk, fastd]
|
|
637
|
-
def stochrsi(prices, period: 14, fastk_period: 5, fastd_period: 3)
|
|
638
|
-
check_available!
|
|
639
|
-
validate_prices!(prices)
|
|
640
|
-
|
|
641
|
-
result = TALibFFI.stochrsi(
|
|
642
|
-
prices,
|
|
643
|
-
time_period: period,
|
|
644
|
-
fastk_period: fastk_period,
|
|
645
|
-
fastd_period: fastd_period
|
|
646
|
-
)
|
|
647
|
-
|
|
648
|
-
# Handle hash return format from newer ta_lib_ffi versions
|
|
649
|
-
if result.is_a?(Hash)
|
|
650
|
-
[result[:fast_k], result[:fast_d]]
|
|
651
|
-
else
|
|
652
|
-
result
|
|
653
|
-
end
|
|
654
|
-
end
|
|
655
|
-
|
|
656
|
-
# 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA
|
|
657
|
-
# @param prices [Array<Float>] Array of prices
|
|
658
|
-
# @param period [Integer] Time period (default: 30)
|
|
659
|
-
# @return [Array<Float>] TRIX values
|
|
660
|
-
def trix(prices, period: 30)
|
|
661
|
-
check_available!
|
|
662
|
-
validate_prices!(prices)
|
|
663
|
-
validate_period!(period, prices.size)
|
|
664
|
-
|
|
665
|
-
TALibFFI.trix(prices, time_period: period)
|
|
666
|
-
end
|
|
667
|
-
|
|
668
|
-
# Ultimate Oscillator
|
|
669
|
-
# @param high [Array<Float>] High prices
|
|
670
|
-
# @param low [Array<Float>] Low prices
|
|
671
|
-
# @param close [Array<Float>] Close prices
|
|
672
|
-
# @param period1 [Integer] First period (default: 7)
|
|
673
|
-
# @param period2 [Integer] Second period (default: 14)
|
|
674
|
-
# @param period3 [Integer] Third period (default: 28)
|
|
675
|
-
# @return [Array<Float>] ULTOSC values
|
|
676
|
-
def ultosc(high, low, close, period1: 7, period2: 14, period3: 28)
|
|
677
|
-
check_available!
|
|
678
|
-
validate_prices!(high)
|
|
679
|
-
validate_prices!(low)
|
|
680
|
-
validate_prices!(close)
|
|
681
|
-
|
|
682
|
-
TALibFFI.ultosc(high, low, close, time_period1: period1, time_period2: period2, time_period3: period3)
|
|
683
|
-
end
|
|
684
|
-
|
|
685
|
-
# ========================================
|
|
686
|
-
# Volatility Indicators
|
|
687
|
-
# ========================================
|
|
688
|
-
|
|
689
|
-
# Average True Range
|
|
690
|
-
# @param high [Array<Float>] High prices
|
|
691
|
-
# @param low [Array<Float>] Low prices
|
|
692
|
-
# @param close [Array<Float>] Close prices
|
|
693
|
-
# @param period [Integer] Time period (default: 14)
|
|
694
|
-
# @return [Array<Float>] ATR values
|
|
695
|
-
def atr(high, low, close, period: 14)
|
|
696
|
-
check_available!
|
|
697
|
-
validate_prices!(high)
|
|
698
|
-
validate_prices!(low)
|
|
699
|
-
validate_prices!(close)
|
|
700
|
-
|
|
701
|
-
TALibFFI.atr(high, low, close, time_period: period)
|
|
702
|
-
end
|
|
703
|
-
|
|
704
|
-
# True Range
|
|
705
|
-
# @param high [Array<Float>] High prices
|
|
706
|
-
# @param low [Array<Float>] Low prices
|
|
707
|
-
# @param close [Array<Float>] Close prices
|
|
708
|
-
# @return [Array<Float>] True Range values
|
|
709
|
-
def trange(high, low, close)
|
|
710
|
-
check_available!
|
|
711
|
-
validate_prices!(high)
|
|
712
|
-
validate_prices!(low)
|
|
713
|
-
validate_prices!(close)
|
|
714
|
-
|
|
715
|
-
TALibFFI.trange(high, low, close)
|
|
716
|
-
end
|
|
717
|
-
|
|
718
|
-
# Normalized Average True Range
|
|
719
|
-
# @param high [Array<Float>] High prices
|
|
720
|
-
# @param low [Array<Float>] Low prices
|
|
721
|
-
# @param close [Array<Float>] Close prices
|
|
722
|
-
# @param period [Integer] Time period (default: 14)
|
|
723
|
-
# @return [Array<Float>] NATR values
|
|
724
|
-
def natr(high, low, close, period: 14)
|
|
725
|
-
check_available!
|
|
726
|
-
validate_prices!(high)
|
|
727
|
-
validate_prices!(low)
|
|
728
|
-
validate_prices!(close)
|
|
729
|
-
|
|
730
|
-
TALibFFI.natr(high, low, close, time_period: period)
|
|
731
|
-
end
|
|
732
|
-
|
|
733
|
-
# Parabolic SAR
|
|
734
|
-
# @param high [Array<Float>] High prices
|
|
735
|
-
# @param low [Array<Float>] Low prices
|
|
736
|
-
# @param acceleration [Float] Acceleration factor (default: 0.02)
|
|
737
|
-
# @param maximum [Float] Maximum acceleration (default: 0.20)
|
|
738
|
-
# @return [Array<Float>] SAR values
|
|
739
|
-
def sar(high, low, acceleration: 0.02, maximum: 0.20)
|
|
740
|
-
check_available!
|
|
741
|
-
validate_prices!(high)
|
|
742
|
-
validate_prices!(low)
|
|
743
|
-
|
|
744
|
-
TALibFFI.sar(high, low, acceleration: acceleration, maximum: maximum)
|
|
745
|
-
end
|
|
746
|
-
|
|
747
|
-
# Parabolic SAR - Extended
|
|
748
|
-
# @param high [Array<Float>] High prices
|
|
749
|
-
# @param low [Array<Float>] Low prices
|
|
750
|
-
# @param start_value [Float] Start value (default: 0.0)
|
|
751
|
-
# @param offset_on_reverse [Float] Offset on reverse (default: 0.0)
|
|
752
|
-
# @param acceleration_init [Float] Acceleration init (default: 0.02)
|
|
753
|
-
# @param acceleration_step [Float] Acceleration step (default: 0.02)
|
|
754
|
-
# @param acceleration_max [Float] Acceleration max (default: 0.20)
|
|
755
|
-
# @return [Array<Float>] SAREXT values
|
|
756
|
-
def sarext(high, low, start_value: 0.0, offset_on_reverse: 0.0, acceleration_init: 0.02, acceleration_step: 0.02, acceleration_max: 0.20)
|
|
757
|
-
check_available!
|
|
758
|
-
validate_prices!(high)
|
|
759
|
-
validate_prices!(low)
|
|
760
|
-
|
|
761
|
-
TALibFFI.sarext(high, low,
|
|
762
|
-
start_value: start_value,
|
|
763
|
-
offset_on_reverse: offset_on_reverse,
|
|
764
|
-
af_init: acceleration_init,
|
|
765
|
-
af_increment: acceleration_step,
|
|
766
|
-
af_max: acceleration_max)
|
|
767
|
-
end
|
|
768
|
-
|
|
769
|
-
# Acceleration Bands
|
|
770
|
-
# @param high [Array<Float>] High prices
|
|
771
|
-
# @param low [Array<Float>] Low prices
|
|
772
|
-
# @param close [Array<Float>] Close prices
|
|
773
|
-
# @param period [Integer] Time period (default: 20)
|
|
774
|
-
# @return [Array<Array<Float>>] [upper_band, middle_band, lower_band]
|
|
775
|
-
def accbands(high, low, close, period: 20)
|
|
776
|
-
check_available!
|
|
777
|
-
validate_prices!(high)
|
|
778
|
-
validate_prices!(low)
|
|
779
|
-
validate_prices!(close)
|
|
780
|
-
validate_period!(period, [high.size, low.size, close.size].min)
|
|
781
|
-
|
|
782
|
-
result = TALibFFI.accbands(high, low, close, time_period: period)
|
|
783
84
|
|
|
784
|
-
#
|
|
785
|
-
if
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
result
|
|
85
|
+
# Category listing
|
|
86
|
+
if options[:category]
|
|
87
|
+
category_indicators = Help.indicators.select { |_k, v| v[:category] == options[:category] }
|
|
88
|
+
return category_indicators.transform_values { |meta| "#{Help::BASE_URL}/#{meta[:path]}/" }
|
|
789
89
|
end
|
|
790
|
-
end
|
|
791
|
-
|
|
792
|
-
# Hilbert Transform - Instantaneous Trendline
|
|
793
|
-
# @param prices [Array<Float>] Array of prices
|
|
794
|
-
# @return [Array<Float>] Trendline values
|
|
795
|
-
def ht_trendline(prices)
|
|
796
|
-
check_available!
|
|
797
|
-
validate_prices!(prices)
|
|
798
|
-
|
|
799
|
-
TALibFFI.ht_trendline(prices)
|
|
800
|
-
end
|
|
801
90
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
validate_prices!(prices)
|
|
810
|
-
|
|
811
|
-
result = TALibFFI.mama(prices, fastlimit: fast_limit, slowlimit: slow_limit)
|
|
812
|
-
|
|
813
|
-
# Handle hash return format from newer ta_lib_ffi versions
|
|
814
|
-
if result.is_a?(Hash)
|
|
815
|
-
[result[:mama], result[:fama]]
|
|
816
|
-
else
|
|
817
|
-
result
|
|
91
|
+
# Search
|
|
92
|
+
if options[:search]
|
|
93
|
+
query = options[:search].downcase
|
|
94
|
+
matches = Help.indicators.select do |k, v|
|
|
95
|
+
k.to_s.include?(query) || v[:name].downcase.include?(query)
|
|
96
|
+
end
|
|
97
|
+
return matches.transform_values { |meta| "#{Help::BASE_URL}/#{meta[:path]}/" }
|
|
818
98
|
end
|
|
819
|
-
end
|
|
820
|
-
|
|
821
|
-
# Moving Average with Variable Period
|
|
822
|
-
# @param prices [Array<Float>] Array of prices
|
|
823
|
-
# @param periods [Array<Integer>] Array of periods for each data point
|
|
824
|
-
# @param ma_type [Integer] Moving average type (default: 0)
|
|
825
|
-
# @return [Array<Float>] MAVP values
|
|
826
|
-
def mavp(prices, periods, ma_type: 0)
|
|
827
|
-
check_available!
|
|
828
|
-
validate_prices!(prices)
|
|
829
|
-
validate_prices!(periods)
|
|
830
|
-
|
|
831
|
-
TALibFFI.mavp(prices, periods, ma_type: ma_type)
|
|
832
|
-
end
|
|
833
|
-
|
|
834
|
-
# Midpoint over period
|
|
835
|
-
# @param prices [Array<Float>] Array of prices
|
|
836
|
-
# @param period [Integer] Time period (default: 14)
|
|
837
|
-
# @return [Array<Float>] Midpoint values
|
|
838
|
-
def midpoint(prices, period: 14)
|
|
839
|
-
check_available!
|
|
840
|
-
validate_prices!(prices)
|
|
841
|
-
validate_period!(period, prices.size)
|
|
842
|
-
|
|
843
|
-
TALibFFI.midpoint(prices, time_period: period)
|
|
844
|
-
end
|
|
845
|
-
|
|
846
|
-
# Midpoint Price over period
|
|
847
|
-
# @param high [Array<Float>] High prices
|
|
848
|
-
# @param low [Array<Float>] Low prices
|
|
849
|
-
# @param period [Integer] Time period (default: 14)
|
|
850
|
-
# @return [Array<Float>] Midpoint price values
|
|
851
|
-
def midprice(high, low, period: 14)
|
|
852
|
-
check_available!
|
|
853
|
-
validate_prices!(high)
|
|
854
|
-
validate_prices!(low)
|
|
855
|
-
validate_period!(period, [high.size, low.size].min)
|
|
856
|
-
|
|
857
|
-
TALibFFI.midprice(high, low, time_period: period)
|
|
858
|
-
end
|
|
859
|
-
|
|
860
|
-
# ========================================
|
|
861
|
-
# Volume Indicators
|
|
862
|
-
# ========================================
|
|
863
|
-
|
|
864
|
-
# On Balance Volume
|
|
865
|
-
# @param close [Array<Float>] Close prices
|
|
866
|
-
# @param volume [Array<Float>] Volume values
|
|
867
|
-
# @return [Array<Float>] OBV values
|
|
868
|
-
def obv(close, volume)
|
|
869
|
-
check_available!
|
|
870
|
-
validate_prices!(close)
|
|
871
|
-
validate_prices!(volume)
|
|
872
|
-
|
|
873
|
-
TALibFFI.obv(close, volume)
|
|
874
|
-
end
|
|
875
|
-
|
|
876
|
-
# Chaikin A/D Line
|
|
877
|
-
# @param high [Array<Float>] High prices
|
|
878
|
-
# @param low [Array<Float>] Low prices
|
|
879
|
-
# @param close [Array<Float>] Close prices
|
|
880
|
-
# @param volume [Array<Float>] Volume values
|
|
881
|
-
# @return [Array<Float>] AD values
|
|
882
|
-
def ad(high, low, close, volume)
|
|
883
|
-
check_available!
|
|
884
|
-
validate_prices!(high)
|
|
885
|
-
validate_prices!(low)
|
|
886
|
-
validate_prices!(close)
|
|
887
|
-
validate_prices!(volume)
|
|
888
|
-
|
|
889
|
-
TALibFFI.ad(high, low, close, volume)
|
|
890
|
-
end
|
|
891
|
-
|
|
892
|
-
# Chaikin A/D Oscillator
|
|
893
|
-
# @param high [Array<Float>] High prices
|
|
894
|
-
# @param low [Array<Float>] Low prices
|
|
895
|
-
# @param close [Array<Float>] Close prices
|
|
896
|
-
# @param volume [Array<Float>] Volume values
|
|
897
|
-
# @param fast_period [Integer] Fast period (default: 3)
|
|
898
|
-
# @param slow_period [Integer] Slow period (default: 10)
|
|
899
|
-
# @return [Array<Float>] ADOSC values
|
|
900
|
-
def adosc(high, low, close, volume, fast_period: 3, slow_period: 10)
|
|
901
|
-
check_available!
|
|
902
|
-
validate_prices!(high)
|
|
903
|
-
validate_prices!(low)
|
|
904
|
-
validate_prices!(close)
|
|
905
|
-
validate_prices!(volume)
|
|
906
|
-
|
|
907
|
-
TALibFFI.adosc(high, low, close, volume, fast_period: fast_period, slow_period: slow_period)
|
|
908
|
-
end
|
|
909
|
-
|
|
910
|
-
# ========================================
|
|
911
|
-
# Price Transform
|
|
912
|
-
# ========================================
|
|
913
99
|
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
# @param low [Array<Float>] Low prices
|
|
918
|
-
# @param close [Array<Float>] Close prices
|
|
919
|
-
# @return [Array<Float>] Average price values
|
|
920
|
-
def avgprice(open, high, low, close)
|
|
921
|
-
check_available!
|
|
922
|
-
validate_prices!(open)
|
|
923
|
-
validate_prices!(high)
|
|
924
|
-
validate_prices!(low)
|
|
925
|
-
validate_prices!(close)
|
|
926
|
-
|
|
927
|
-
TALibFFI.avgprice(open, high, low, close)
|
|
928
|
-
end
|
|
929
|
-
|
|
930
|
-
# Median Price
|
|
931
|
-
# @param high [Array<Float>] High prices
|
|
932
|
-
# @param low [Array<Float>] Low prices
|
|
933
|
-
# @return [Array<Float>] Median price values
|
|
934
|
-
def medprice(high, low)
|
|
935
|
-
check_available!
|
|
936
|
-
validate_prices!(high)
|
|
937
|
-
validate_prices!(low)
|
|
938
|
-
|
|
939
|
-
TALibFFI.medprice(high, low)
|
|
940
|
-
end
|
|
941
|
-
|
|
942
|
-
# Typical Price
|
|
943
|
-
# @param high [Array<Float>] High prices
|
|
944
|
-
# @param low [Array<Float>] Low prices
|
|
945
|
-
# @param close [Array<Float>] Close prices
|
|
946
|
-
# @return [Array<Float>] Typical price values
|
|
947
|
-
def typprice(high, low, close)
|
|
948
|
-
check_available!
|
|
949
|
-
validate_prices!(high)
|
|
950
|
-
validate_prices!(low)
|
|
951
|
-
validate_prices!(close)
|
|
952
|
-
|
|
953
|
-
TALibFFI.typprice(high, low, close)
|
|
954
|
-
end
|
|
955
|
-
|
|
956
|
-
# Weighted Close Price
|
|
957
|
-
# @param high [Array<Float>] High prices
|
|
958
|
-
# @param low [Array<Float>] Low prices
|
|
959
|
-
# @param close [Array<Float>] Close prices
|
|
960
|
-
# @return [Array<Float>] Weighted close price values
|
|
961
|
-
def wclprice(high, low, close)
|
|
962
|
-
check_available!
|
|
963
|
-
validate_prices!(high)
|
|
964
|
-
validate_prices!(low)
|
|
965
|
-
validate_prices!(close)
|
|
966
|
-
|
|
967
|
-
TALibFFI.wclprice(high, low, close)
|
|
968
|
-
end
|
|
969
|
-
|
|
970
|
-
# ========================================
|
|
971
|
-
# Cycle Indicators
|
|
972
|
-
# ========================================
|
|
973
|
-
|
|
974
|
-
# Hilbert Transform - Dominant Cycle Period
|
|
975
|
-
# @param prices [Array<Float>] Array of prices
|
|
976
|
-
# @return [Array<Float>] Dominant cycle period values
|
|
977
|
-
def ht_dcperiod(prices)
|
|
978
|
-
check_available!
|
|
979
|
-
validate_prices!(prices)
|
|
980
|
-
|
|
981
|
-
TALibFFI.ht_dcperiod(prices)
|
|
982
|
-
end
|
|
983
|
-
|
|
984
|
-
# Hilbert Transform - Trend vs Cycle Mode
|
|
985
|
-
# @param prices [Array<Float>] Array of prices
|
|
986
|
-
# @return [Array<Integer>] Trend mode (1) or cycle mode (0)
|
|
987
|
-
def ht_trendmode(prices)
|
|
988
|
-
check_available!
|
|
989
|
-
validate_prices!(prices)
|
|
990
|
-
|
|
991
|
-
TALibFFI.ht_trendmode(prices)
|
|
992
|
-
end
|
|
993
|
-
|
|
994
|
-
# Hilbert Transform - Dominant Cycle Phase
|
|
995
|
-
# @param prices [Array<Float>] Array of prices
|
|
996
|
-
# @return [Array<Float>] Dominant cycle phase values
|
|
997
|
-
def ht_dcphase(prices)
|
|
998
|
-
check_available!
|
|
999
|
-
validate_prices!(prices)
|
|
1000
|
-
|
|
1001
|
-
TALibFFI.ht_dcphase(prices)
|
|
1002
|
-
end
|
|
1003
|
-
|
|
1004
|
-
# Hilbert Transform - Phasor Components
|
|
1005
|
-
# @param prices [Array<Float>] Array of prices
|
|
1006
|
-
# @return [Array<Array<Float>>] [inphase, quadrature]
|
|
1007
|
-
def ht_phasor(prices)
|
|
1008
|
-
check_available!
|
|
1009
|
-
validate_prices!(prices)
|
|
1010
|
-
|
|
1011
|
-
result = TALibFFI.ht_phasor(prices)
|
|
1012
|
-
|
|
1013
|
-
# Handle hash return format from newer ta_lib_ffi versions
|
|
1014
|
-
if result.is_a?(Hash)
|
|
1015
|
-
[result[:in_phase], result[:quadrature]]
|
|
1016
|
-
else
|
|
1017
|
-
result
|
|
1018
|
-
end
|
|
1019
|
-
end
|
|
100
|
+
# Single indicator
|
|
101
|
+
meta = Help.indicators[indicator]
|
|
102
|
+
raise ArgumentError, "Unknown indicator: #{indicator}" unless meta
|
|
1020
103
|
|
|
1021
|
-
|
|
1022
|
-
# @param prices [Array<Float>] Array of prices
|
|
1023
|
-
# @return [Array<Array<Float>>] [sine, lead_sine]
|
|
1024
|
-
def ht_sine(prices)
|
|
1025
|
-
check_available!
|
|
1026
|
-
validate_prices!(prices)
|
|
104
|
+
resource = Help::Resource.new(indicator, meta[:name], meta[:category], meta[:path])
|
|
1027
105
|
|
|
1028
|
-
|
|
106
|
+
# Open in browser if requested
|
|
107
|
+
resource.open if options[:open]
|
|
1029
108
|
|
|
1030
|
-
#
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
109
|
+
# Return format
|
|
110
|
+
case options[:format]
|
|
111
|
+
when :uri then resource.uri
|
|
112
|
+
when :hash then {name: meta[:name], category: meta[:category], url: resource.url}
|
|
113
|
+
else resource # Return Help::Resource object (responds to to_s)
|
|
1035
114
|
end
|
|
1036
115
|
end
|
|
1037
116
|
|
|
1038
|
-
# ========================================
|
|
1039
|
-
# Statistical Functions
|
|
1040
|
-
# ========================================
|
|
1041
|
-
|
|
1042
|
-
# Pearson's Correlation Coefficient
|
|
1043
|
-
# @param prices1 [Array<Float>] First array of prices
|
|
1044
|
-
# @param prices2 [Array<Float>] Second array of prices
|
|
1045
|
-
# @param period [Integer] Time period (default: 30)
|
|
1046
|
-
# @return [Array<Float>] Correlation values
|
|
1047
|
-
def correl(prices1, prices2, period: 30)
|
|
1048
|
-
check_available!
|
|
1049
|
-
validate_prices!(prices1)
|
|
1050
|
-
validate_prices!(prices2)
|
|
1051
|
-
validate_period!(period, [prices1.size, prices2.size].min)
|
|
1052
|
-
|
|
1053
|
-
TALibFFI.correl(prices1, prices2, time_period: period)
|
|
1054
|
-
end
|
|
1055
|
-
|
|
1056
|
-
# Beta
|
|
1057
|
-
# @param prices1 [Array<Float>] First array of prices
|
|
1058
|
-
# @param prices2 [Array<Float>] Second array of prices
|
|
1059
|
-
# @param period [Integer] Time period (default: 5)
|
|
1060
|
-
# @return [Array<Float>] Beta values
|
|
1061
|
-
def beta(prices1, prices2, period: 5)
|
|
1062
|
-
check_available!
|
|
1063
|
-
validate_prices!(prices1)
|
|
1064
|
-
validate_prices!(prices2)
|
|
1065
|
-
validate_period!(period, [prices1.size, prices2.size].min)
|
|
1066
|
-
|
|
1067
|
-
TALibFFI.beta(prices1, prices2, time_period: period)
|
|
1068
|
-
end
|
|
1069
|
-
|
|
1070
|
-
# Variance
|
|
1071
|
-
# @param prices [Array<Float>] Array of prices
|
|
1072
|
-
# @param period [Integer] Time period (default: 5)
|
|
1073
|
-
# @param nbdev [Float] Number of deviations (default: 1.0)
|
|
1074
|
-
# @return [Array<Float>] Variance values
|
|
1075
|
-
def var(prices, period: 5, nbdev: 1.0)
|
|
1076
|
-
check_available!
|
|
1077
|
-
validate_prices!(prices)
|
|
1078
|
-
validate_period!(period, prices.size)
|
|
1079
|
-
|
|
1080
|
-
TALibFFI.var(prices, time_period: period, nbdev: nbdev)
|
|
1081
|
-
end
|
|
1082
|
-
|
|
1083
|
-
# Standard Deviation
|
|
1084
|
-
# @param prices [Array<Float>] Array of prices
|
|
1085
|
-
# @param period [Integer] Time period (default: 5)
|
|
1086
|
-
# @param nbdev [Float] Number of deviations (default: 1.0)
|
|
1087
|
-
# @return [Array<Float>] Standard deviation values
|
|
1088
|
-
def stddev(prices, period: 5, nbdev: 1.0)
|
|
1089
|
-
check_available!
|
|
1090
|
-
validate_prices!(prices)
|
|
1091
|
-
validate_period!(period, prices.size)
|
|
1092
|
-
|
|
1093
|
-
TALibFFI.stddev(prices, time_period: period, nbdev: nbdev)
|
|
1094
|
-
end
|
|
1095
|
-
|
|
1096
|
-
# Linear Regression
|
|
1097
|
-
# @param prices [Array<Float>] Array of prices
|
|
1098
|
-
# @param period [Integer] Time period (default: 14)
|
|
1099
|
-
# @return [Array<Float>] Linear regression values
|
|
1100
|
-
def linearreg(prices, period: 14)
|
|
1101
|
-
check_available!
|
|
1102
|
-
validate_prices!(prices)
|
|
1103
|
-
validate_period!(period, prices.size)
|
|
1104
|
-
|
|
1105
|
-
TALibFFI.linearreg(prices, time_period: period)
|
|
1106
|
-
end
|
|
1107
|
-
|
|
1108
|
-
# Linear Regression Angle
|
|
1109
|
-
# @param prices [Array<Float>] Array of prices
|
|
1110
|
-
# @param period [Integer] Time period (default: 14)
|
|
1111
|
-
# @return [Array<Float>] Linear regression angle values
|
|
1112
|
-
def linearreg_angle(prices, period: 14)
|
|
1113
|
-
check_available!
|
|
1114
|
-
validate_prices!(prices)
|
|
1115
|
-
validate_period!(period, prices.size)
|
|
1116
|
-
|
|
1117
|
-
TALibFFI.linearreg_angle(prices, time_period: period)
|
|
1118
|
-
end
|
|
1119
|
-
|
|
1120
|
-
# Linear Regression Intercept
|
|
1121
|
-
# @param prices [Array<Float>] Array of prices
|
|
1122
|
-
# @param period [Integer] Time period (default: 14)
|
|
1123
|
-
# @return [Array<Float>] Linear regression intercept values
|
|
1124
|
-
def linearreg_intercept(prices, period: 14)
|
|
1125
|
-
check_available!
|
|
1126
|
-
validate_prices!(prices)
|
|
1127
|
-
validate_period!(period, prices.size)
|
|
1128
|
-
|
|
1129
|
-
TALibFFI.linearreg_intercept(prices, time_period: period)
|
|
1130
|
-
end
|
|
1131
|
-
|
|
1132
|
-
# Linear Regression Slope
|
|
1133
|
-
# @param prices [Array<Float>] Array of prices
|
|
1134
|
-
# @param period [Integer] Time period (default: 14)
|
|
1135
|
-
# @return [Array<Float>] Linear regression slope values
|
|
1136
|
-
def linearreg_slope(prices, period: 14)
|
|
1137
|
-
check_available!
|
|
1138
|
-
validate_prices!(prices)
|
|
1139
|
-
validate_period!(period, prices.size)
|
|
1140
|
-
|
|
1141
|
-
TALibFFI.linearreg_slope(prices, time_period: period)
|
|
1142
|
-
end
|
|
1143
|
-
|
|
1144
|
-
# Time Series Forecast
|
|
1145
|
-
# @param prices [Array<Float>] Array of prices
|
|
1146
|
-
# @param period [Integer] Time period (default: 14)
|
|
1147
|
-
# @return [Array<Float>] Time series forecast values
|
|
1148
|
-
def tsf(prices, period: 14)
|
|
1149
|
-
check_available!
|
|
1150
|
-
validate_prices!(prices)
|
|
1151
|
-
validate_period!(period, prices.size)
|
|
1152
|
-
|
|
1153
|
-
TALibFFI.tsf(prices, time_period: period)
|
|
1154
|
-
end
|
|
1155
|
-
|
|
1156
|
-
# ========================================
|
|
1157
|
-
# Pattern Recognition
|
|
1158
|
-
# ========================================
|
|
1159
|
-
|
|
1160
|
-
# Doji candlestick pattern
|
|
1161
|
-
# @param open [Array<Float>] Open prices
|
|
1162
|
-
# @param high [Array<Float>] High prices
|
|
1163
|
-
# @param low [Array<Float>] Low prices
|
|
1164
|
-
# @param close [Array<Float>] Close prices
|
|
1165
|
-
# @return [Array<Integer>] Pattern signals (-100 to 100)
|
|
1166
|
-
def cdl_doji(open, high, low, close)
|
|
1167
|
-
check_available!
|
|
1168
|
-
validate_prices!(open)
|
|
1169
|
-
validate_prices!(high)
|
|
1170
|
-
validate_prices!(low)
|
|
1171
|
-
validate_prices!(close)
|
|
1172
|
-
|
|
1173
|
-
TALibFFI.cdldoji(open, high, low, close)
|
|
1174
|
-
end
|
|
1175
|
-
|
|
1176
|
-
# Hammer candlestick pattern
|
|
1177
|
-
def cdl_hammer(open, high, low, close)
|
|
1178
|
-
check_available!
|
|
1179
|
-
validate_prices!(open)
|
|
1180
|
-
validate_prices!(high)
|
|
1181
|
-
validate_prices!(low)
|
|
1182
|
-
validate_prices!(close)
|
|
1183
|
-
|
|
1184
|
-
TALibFFI.cdlhammer(open, high, low, close)
|
|
1185
|
-
end
|
|
1186
|
-
|
|
1187
|
-
# Engulfing pattern
|
|
1188
|
-
def cdl_engulfing(open, high, low, close)
|
|
1189
|
-
check_available!
|
|
1190
|
-
validate_prices!(open)
|
|
1191
|
-
validate_prices!(high)
|
|
1192
|
-
validate_prices!(low)
|
|
1193
|
-
validate_prices!(close)
|
|
1194
|
-
|
|
1195
|
-
TALibFFI.cdlengulfing(open, high, low, close)
|
|
1196
|
-
end
|
|
1197
|
-
|
|
1198
|
-
# Morning Star pattern
|
|
1199
|
-
def cdl_morningstar(open, high, low, close, penetration: 0.3)
|
|
1200
|
-
check_available!
|
|
1201
|
-
validate_prices!(open)
|
|
1202
|
-
validate_prices!(high)
|
|
1203
|
-
validate_prices!(low)
|
|
1204
|
-
validate_prices!(close)
|
|
1205
|
-
|
|
1206
|
-
TALibFFI.cdlmorningstar(open, high, low, close, penetration: penetration)
|
|
1207
|
-
end
|
|
1208
|
-
|
|
1209
|
-
# Evening Star pattern
|
|
1210
|
-
def cdl_eveningstar(open, high, low, close, penetration: 0.3)
|
|
1211
|
-
check_available!
|
|
1212
|
-
validate_prices!(open)
|
|
1213
|
-
validate_prices!(high)
|
|
1214
|
-
validate_prices!(low)
|
|
1215
|
-
validate_prices!(close)
|
|
1216
|
-
|
|
1217
|
-
TALibFFI.cdleveningstar(open, high, low, close, penetration: penetration)
|
|
1218
|
-
end
|
|
1219
|
-
|
|
1220
|
-
# Harami pattern
|
|
1221
|
-
def cdl_harami(open, high, low, close)
|
|
1222
|
-
check_available!
|
|
1223
|
-
validate_prices!(open)
|
|
1224
|
-
validate_prices!(high)
|
|
1225
|
-
validate_prices!(low)
|
|
1226
|
-
validate_prices!(close)
|
|
1227
|
-
|
|
1228
|
-
TALibFFI.cdlharami(open, high, low, close)
|
|
1229
|
-
end
|
|
1230
|
-
|
|
1231
|
-
# Piercing pattern
|
|
1232
|
-
def cdl_piercing(open, high, low, close)
|
|
1233
|
-
check_available!
|
|
1234
|
-
validate_prices!(open)
|
|
1235
|
-
validate_prices!(high)
|
|
1236
|
-
validate_prices!(low)
|
|
1237
|
-
validate_prices!(close)
|
|
1238
|
-
|
|
1239
|
-
TALibFFI.cdlpiercing(open, high, low, close)
|
|
1240
|
-
end
|
|
1241
|
-
|
|
1242
|
-
# Shooting Star pattern
|
|
1243
|
-
def cdl_shootingstar(open, high, low, close)
|
|
1244
|
-
check_available!
|
|
1245
|
-
validate_prices!(open)
|
|
1246
|
-
validate_prices!(high)
|
|
1247
|
-
validate_prices!(low)
|
|
1248
|
-
validate_prices!(close)
|
|
1249
|
-
|
|
1250
|
-
TALibFFI.cdlshootingstar(open, high, low, close)
|
|
1251
|
-
end
|
|
1252
|
-
|
|
1253
|
-
# Marubozu pattern
|
|
1254
|
-
def cdl_marubozu(open, high, low, close)
|
|
1255
|
-
check_available!
|
|
1256
|
-
validate_prices!(open)
|
|
1257
|
-
validate_prices!(high)
|
|
1258
|
-
validate_prices!(low)
|
|
1259
|
-
validate_prices!(close)
|
|
1260
|
-
|
|
1261
|
-
TALibFFI.cdlmarubozu(open, high, low, close)
|
|
1262
|
-
end
|
|
1263
|
-
|
|
1264
|
-
# Spinning Top pattern
|
|
1265
|
-
def cdl_spinningtop(open, high, low, close)
|
|
1266
|
-
check_available!
|
|
1267
|
-
validate_prices!(open)
|
|
1268
|
-
validate_prices!(high)
|
|
1269
|
-
validate_prices!(low)
|
|
1270
|
-
validate_prices!(close)
|
|
1271
|
-
|
|
1272
|
-
TALibFFI.cdlspinningtop(open, high, low, close)
|
|
1273
|
-
end
|
|
1274
|
-
|
|
1275
|
-
# Dragonfly Doji pattern
|
|
1276
|
-
def cdl_dragonflydoji(open, high, low, close)
|
|
1277
|
-
check_available!
|
|
1278
|
-
validate_prices!(open)
|
|
1279
|
-
validate_prices!(high)
|
|
1280
|
-
validate_prices!(low)
|
|
1281
|
-
validate_prices!(close)
|
|
1282
|
-
|
|
1283
|
-
TALibFFI.cdldragonflydoji(open, high, low, close)
|
|
1284
|
-
end
|
|
1285
|
-
|
|
1286
|
-
# Gravestone Doji pattern
|
|
1287
|
-
def cdl_gravestonedoji(open, high, low, close)
|
|
1288
|
-
check_available!
|
|
1289
|
-
validate_prices!(open)
|
|
1290
|
-
validate_prices!(high)
|
|
1291
|
-
validate_prices!(low)
|
|
1292
|
-
validate_prices!(close)
|
|
1293
|
-
|
|
1294
|
-
TALibFFI.cdlgravestonedoji(open, high, low, close)
|
|
1295
|
-
end
|
|
1296
|
-
|
|
1297
|
-
# Two Crows pattern
|
|
1298
|
-
def cdl_2crows(open, high, low, close)
|
|
1299
|
-
check_available!
|
|
1300
|
-
validate_prices!(open)
|
|
1301
|
-
validate_prices!(high)
|
|
1302
|
-
validate_prices!(low)
|
|
1303
|
-
validate_prices!(close)
|
|
1304
|
-
|
|
1305
|
-
TALibFFI.cdl2crows(open, high, low, close)
|
|
1306
|
-
end
|
|
1307
|
-
|
|
1308
|
-
# Three Black Crows pattern
|
|
1309
|
-
def cdl_3blackcrows(open, high, low, close)
|
|
1310
|
-
check_available!
|
|
1311
|
-
validate_prices!(open)
|
|
1312
|
-
validate_prices!(high)
|
|
1313
|
-
validate_prices!(low)
|
|
1314
|
-
validate_prices!(close)
|
|
1315
|
-
|
|
1316
|
-
TALibFFI.cdl3blackcrows(open, high, low, close)
|
|
1317
|
-
end
|
|
1318
|
-
|
|
1319
|
-
# Three Inside Up/Down pattern
|
|
1320
|
-
def cdl_3inside(open, high, low, close)
|
|
1321
|
-
check_available!
|
|
1322
|
-
validate_prices!(open)
|
|
1323
|
-
validate_prices!(high)
|
|
1324
|
-
validate_prices!(low)
|
|
1325
|
-
validate_prices!(close)
|
|
1326
|
-
|
|
1327
|
-
TALibFFI.cdl3inside(open, high, low, close)
|
|
1328
|
-
end
|
|
1329
|
-
|
|
1330
|
-
# Three Line Strike pattern
|
|
1331
|
-
def cdl_3linestrike(open, high, low, close)
|
|
1332
|
-
check_available!
|
|
1333
|
-
validate_prices!(open)
|
|
1334
|
-
validate_prices!(high)
|
|
1335
|
-
validate_prices!(low)
|
|
1336
|
-
validate_prices!(close)
|
|
1337
|
-
|
|
1338
|
-
TALibFFI.cdl3linestrike(open, high, low, close)
|
|
1339
|
-
end
|
|
1340
|
-
|
|
1341
|
-
# Three Outside Up/Down pattern
|
|
1342
|
-
def cdl_3outside(open, high, low, close)
|
|
1343
|
-
check_available!
|
|
1344
|
-
validate_prices!(open)
|
|
1345
|
-
validate_prices!(high)
|
|
1346
|
-
validate_prices!(low)
|
|
1347
|
-
validate_prices!(close)
|
|
1348
|
-
|
|
1349
|
-
TALibFFI.cdl3outside(open, high, low, close)
|
|
1350
|
-
end
|
|
1351
|
-
|
|
1352
|
-
# Three Stars In The South pattern
|
|
1353
|
-
def cdl_3starsinsouth(open, high, low, close)
|
|
1354
|
-
check_available!
|
|
1355
|
-
validate_prices!(open)
|
|
1356
|
-
validate_prices!(high)
|
|
1357
|
-
validate_prices!(low)
|
|
1358
|
-
validate_prices!(close)
|
|
1359
|
-
|
|
1360
|
-
TALibFFI.cdl3starsinsouth(open, high, low, close)
|
|
1361
|
-
end
|
|
1362
|
-
|
|
1363
|
-
# Three Advancing White Soldiers pattern
|
|
1364
|
-
def cdl_3whitesoldiers(open, high, low, close)
|
|
1365
|
-
check_available!
|
|
1366
|
-
validate_prices!(open)
|
|
1367
|
-
validate_prices!(high)
|
|
1368
|
-
validate_prices!(low)
|
|
1369
|
-
validate_prices!(close)
|
|
1370
|
-
|
|
1371
|
-
TALibFFI.cdl3whitesoldiers(open, high, low, close)
|
|
1372
|
-
end
|
|
1373
|
-
|
|
1374
|
-
# Abandoned Baby pattern
|
|
1375
|
-
def cdl_abandonedbaby(open, high, low, close, penetration: 0.3)
|
|
1376
|
-
check_available!
|
|
1377
|
-
validate_prices!(open)
|
|
1378
|
-
validate_prices!(high)
|
|
1379
|
-
validate_prices!(low)
|
|
1380
|
-
validate_prices!(close)
|
|
1381
|
-
|
|
1382
|
-
TALibFFI.cdlabandonedbaby(open, high, low, close, penetration: penetration)
|
|
1383
|
-
end
|
|
1384
|
-
|
|
1385
|
-
# Advance Block pattern
|
|
1386
|
-
def cdl_advanceblock(open, high, low, close)
|
|
1387
|
-
check_available!
|
|
1388
|
-
validate_prices!(open)
|
|
1389
|
-
validate_prices!(high)
|
|
1390
|
-
validate_prices!(low)
|
|
1391
|
-
validate_prices!(close)
|
|
1392
|
-
|
|
1393
|
-
TALibFFI.cdladvanceblock(open, high, low, close)
|
|
1394
|
-
end
|
|
1395
|
-
|
|
1396
|
-
# Belt-hold pattern
|
|
1397
|
-
def cdl_belthold(open, high, low, close)
|
|
1398
|
-
check_available!
|
|
1399
|
-
validate_prices!(open)
|
|
1400
|
-
validate_prices!(high)
|
|
1401
|
-
validate_prices!(low)
|
|
1402
|
-
validate_prices!(close)
|
|
1403
|
-
|
|
1404
|
-
TALibFFI.cdlbelthold(open, high, low, close)
|
|
1405
|
-
end
|
|
1406
|
-
|
|
1407
|
-
# Breakaway pattern
|
|
1408
|
-
def cdl_breakaway(open, high, low, close)
|
|
1409
|
-
check_available!
|
|
1410
|
-
validate_prices!(open)
|
|
1411
|
-
validate_prices!(high)
|
|
1412
|
-
validate_prices!(low)
|
|
1413
|
-
validate_prices!(close)
|
|
1414
|
-
|
|
1415
|
-
TALibFFI.cdlbreakaway(open, high, low, close)
|
|
1416
|
-
end
|
|
1417
|
-
|
|
1418
|
-
# Closing Marubozu pattern
|
|
1419
|
-
def cdl_closingmarubozu(open, high, low, close)
|
|
1420
|
-
check_available!
|
|
1421
|
-
validate_prices!(open)
|
|
1422
|
-
validate_prices!(high)
|
|
1423
|
-
validate_prices!(low)
|
|
1424
|
-
validate_prices!(close)
|
|
1425
|
-
|
|
1426
|
-
TALibFFI.cdlclosingmarubozu(open, high, low, close)
|
|
1427
|
-
end
|
|
1428
|
-
|
|
1429
|
-
# Concealing Baby Swallow pattern
|
|
1430
|
-
def cdl_concealbabyswall(open, high, low, close)
|
|
1431
|
-
check_available!
|
|
1432
|
-
validate_prices!(open)
|
|
1433
|
-
validate_prices!(high)
|
|
1434
|
-
validate_prices!(low)
|
|
1435
|
-
validate_prices!(close)
|
|
1436
|
-
|
|
1437
|
-
TALibFFI.cdlconcealbabyswall(open, high, low, close)
|
|
1438
|
-
end
|
|
1439
|
-
|
|
1440
|
-
# Counterattack pattern
|
|
1441
|
-
def cdl_counterattack(open, high, low, close)
|
|
1442
|
-
check_available!
|
|
1443
|
-
validate_prices!(open)
|
|
1444
|
-
validate_prices!(high)
|
|
1445
|
-
validate_prices!(low)
|
|
1446
|
-
validate_prices!(close)
|
|
1447
|
-
|
|
1448
|
-
TALibFFI.cdlcounterattack(open, high, low, close)
|
|
1449
|
-
end
|
|
1450
|
-
|
|
1451
|
-
# Dark Cloud Cover pattern
|
|
1452
|
-
def cdl_darkcloudcover(open, high, low, close, penetration: 0.5)
|
|
1453
|
-
check_available!
|
|
1454
|
-
validate_prices!(open)
|
|
1455
|
-
validate_prices!(high)
|
|
1456
|
-
validate_prices!(low)
|
|
1457
|
-
validate_prices!(close)
|
|
1458
|
-
|
|
1459
|
-
TALibFFI.cdldarkcloudcover(open, high, low, close, penetration: penetration)
|
|
1460
|
-
end
|
|
1461
|
-
|
|
1462
|
-
# Doji Star pattern
|
|
1463
|
-
def cdl_dojistar(open, high, low, close)
|
|
1464
|
-
check_available!
|
|
1465
|
-
validate_prices!(open)
|
|
1466
|
-
validate_prices!(high)
|
|
1467
|
-
validate_prices!(low)
|
|
1468
|
-
validate_prices!(close)
|
|
1469
|
-
|
|
1470
|
-
TALibFFI.cdldojistar(open, high, low, close)
|
|
1471
|
-
end
|
|
1472
|
-
|
|
1473
|
-
# Evening Doji Star pattern
|
|
1474
|
-
def cdl_eveningdojistar(open, high, low, close, penetration: 0.3)
|
|
1475
|
-
check_available!
|
|
1476
|
-
validate_prices!(open)
|
|
1477
|
-
validate_prices!(high)
|
|
1478
|
-
validate_prices!(low)
|
|
1479
|
-
validate_prices!(close)
|
|
1480
|
-
|
|
1481
|
-
TALibFFI.cdleveningdojistar(open, high, low, close, penetration: penetration)
|
|
1482
|
-
end
|
|
1483
|
-
|
|
1484
|
-
# Up/Down-gap side-by-side white lines pattern
|
|
1485
|
-
def cdl_gapsidesidewhite(open, high, low, close)
|
|
1486
|
-
check_available!
|
|
1487
|
-
validate_prices!(open)
|
|
1488
|
-
validate_prices!(high)
|
|
1489
|
-
validate_prices!(low)
|
|
1490
|
-
validate_prices!(close)
|
|
1491
|
-
|
|
1492
|
-
TALibFFI.cdlgapsidesidewhite(open, high, low, close)
|
|
1493
|
-
end
|
|
1494
|
-
|
|
1495
|
-
# Hanging Man pattern
|
|
1496
|
-
def cdl_hangingman(open, high, low, close)
|
|
1497
|
-
check_available!
|
|
1498
|
-
validate_prices!(open)
|
|
1499
|
-
validate_prices!(high)
|
|
1500
|
-
validate_prices!(low)
|
|
1501
|
-
validate_prices!(close)
|
|
1502
|
-
|
|
1503
|
-
TALibFFI.cdlhangingman(open, high, low, close)
|
|
1504
|
-
end
|
|
1505
|
-
|
|
1506
|
-
# Harami Cross pattern
|
|
1507
|
-
def cdl_haramicross(open, high, low, close)
|
|
1508
|
-
check_available!
|
|
1509
|
-
validate_prices!(open)
|
|
1510
|
-
validate_prices!(high)
|
|
1511
|
-
validate_prices!(low)
|
|
1512
|
-
validate_prices!(close)
|
|
1513
|
-
|
|
1514
|
-
TALibFFI.cdlharamicross(open, high, low, close)
|
|
1515
|
-
end
|
|
1516
|
-
|
|
1517
|
-
# High-Wave Candle pattern
|
|
1518
|
-
def cdl_highwave(open, high, low, close)
|
|
1519
|
-
check_available!
|
|
1520
|
-
validate_prices!(open)
|
|
1521
|
-
validate_prices!(high)
|
|
1522
|
-
validate_prices!(low)
|
|
1523
|
-
validate_prices!(close)
|
|
1524
|
-
|
|
1525
|
-
TALibFFI.cdlhighwave(open, high, low, close)
|
|
1526
|
-
end
|
|
1527
|
-
|
|
1528
|
-
# Hikkake pattern
|
|
1529
|
-
def cdl_hikkake(open, high, low, close)
|
|
1530
|
-
check_available!
|
|
1531
|
-
validate_prices!(open)
|
|
1532
|
-
validate_prices!(high)
|
|
1533
|
-
validate_prices!(low)
|
|
1534
|
-
validate_prices!(close)
|
|
1535
|
-
|
|
1536
|
-
TALibFFI.cdlhikkake(open, high, low, close)
|
|
1537
|
-
end
|
|
1538
|
-
|
|
1539
|
-
# Modified Hikkake pattern
|
|
1540
|
-
def cdl_hikkakemod(open, high, low, close)
|
|
1541
|
-
check_available!
|
|
1542
|
-
validate_prices!(open)
|
|
1543
|
-
validate_prices!(high)
|
|
1544
|
-
validate_prices!(low)
|
|
1545
|
-
validate_prices!(close)
|
|
1546
|
-
|
|
1547
|
-
TALibFFI.cdlhikkakemod(open, high, low, close)
|
|
1548
|
-
end
|
|
1549
|
-
|
|
1550
|
-
# Homing Pigeon pattern
|
|
1551
|
-
def cdl_homingpigeon(open, high, low, close)
|
|
1552
|
-
check_available!
|
|
1553
|
-
validate_prices!(open)
|
|
1554
|
-
validate_prices!(high)
|
|
1555
|
-
validate_prices!(low)
|
|
1556
|
-
validate_prices!(close)
|
|
1557
|
-
|
|
1558
|
-
TALibFFI.cdlhomingpigeon(open, high, low, close)
|
|
1559
|
-
end
|
|
1560
|
-
|
|
1561
|
-
# Identical Three Crows pattern
|
|
1562
|
-
def cdl_identical3crows(open, high, low, close)
|
|
1563
|
-
check_available!
|
|
1564
|
-
validate_prices!(open)
|
|
1565
|
-
validate_prices!(high)
|
|
1566
|
-
validate_prices!(low)
|
|
1567
|
-
validate_prices!(close)
|
|
1568
|
-
|
|
1569
|
-
TALibFFI.cdlidentical3crows(open, high, low, close)
|
|
1570
|
-
end
|
|
1571
|
-
|
|
1572
|
-
# In-Neck pattern
|
|
1573
|
-
def cdl_inneck(open, high, low, close)
|
|
1574
|
-
check_available!
|
|
1575
|
-
validate_prices!(open)
|
|
1576
|
-
validate_prices!(high)
|
|
1577
|
-
validate_prices!(low)
|
|
1578
|
-
validate_prices!(close)
|
|
1579
|
-
|
|
1580
|
-
TALibFFI.cdlinneck(open, high, low, close)
|
|
1581
|
-
end
|
|
1582
|
-
|
|
1583
|
-
# Inverted Hammer pattern
|
|
1584
|
-
def cdl_invertedhammer(open, high, low, close)
|
|
1585
|
-
check_available!
|
|
1586
|
-
validate_prices!(open)
|
|
1587
|
-
validate_prices!(high)
|
|
1588
|
-
validate_prices!(low)
|
|
1589
|
-
validate_prices!(close)
|
|
1590
|
-
|
|
1591
|
-
TALibFFI.cdlinvertedhammer(open, high, low, close)
|
|
1592
|
-
end
|
|
1593
|
-
|
|
1594
|
-
# Kicking pattern
|
|
1595
|
-
def cdl_kicking(open, high, low, close)
|
|
1596
|
-
check_available!
|
|
1597
|
-
validate_prices!(open)
|
|
1598
|
-
validate_prices!(high)
|
|
1599
|
-
validate_prices!(low)
|
|
1600
|
-
validate_prices!(close)
|
|
1601
|
-
|
|
1602
|
-
TALibFFI.cdlkicking(open, high, low, close)
|
|
1603
|
-
end
|
|
1604
|
-
|
|
1605
|
-
# Kicking - bull/bear determined by the longer marubozu
|
|
1606
|
-
def cdl_kickingbylength(open, high, low, close)
|
|
1607
|
-
check_available!
|
|
1608
|
-
validate_prices!(open)
|
|
1609
|
-
validate_prices!(high)
|
|
1610
|
-
validate_prices!(low)
|
|
1611
|
-
validate_prices!(close)
|
|
1612
|
-
|
|
1613
|
-
TALibFFI.cdlkickingbylength(open, high, low, close)
|
|
1614
|
-
end
|
|
1615
|
-
|
|
1616
|
-
# Ladder Bottom pattern
|
|
1617
|
-
def cdl_ladderbottom(open, high, low, close)
|
|
1618
|
-
check_available!
|
|
1619
|
-
validate_prices!(open)
|
|
1620
|
-
validate_prices!(high)
|
|
1621
|
-
validate_prices!(low)
|
|
1622
|
-
validate_prices!(close)
|
|
1623
|
-
|
|
1624
|
-
TALibFFI.cdlladderbottom(open, high, low, close)
|
|
1625
|
-
end
|
|
1626
|
-
|
|
1627
|
-
# Long Legged Doji pattern
|
|
1628
|
-
def cdl_longleggeddoji(open, high, low, close)
|
|
1629
|
-
check_available!
|
|
1630
|
-
validate_prices!(open)
|
|
1631
|
-
validate_prices!(high)
|
|
1632
|
-
validate_prices!(low)
|
|
1633
|
-
validate_prices!(close)
|
|
1634
|
-
|
|
1635
|
-
TALibFFI.cdllongleggeddoji(open, high, low, close)
|
|
1636
|
-
end
|
|
1637
|
-
|
|
1638
|
-
# Long Line Candle pattern
|
|
1639
|
-
def cdl_longline(open, high, low, close)
|
|
1640
|
-
check_available!
|
|
1641
|
-
validate_prices!(open)
|
|
1642
|
-
validate_prices!(high)
|
|
1643
|
-
validate_prices!(low)
|
|
1644
|
-
validate_prices!(close)
|
|
1645
|
-
|
|
1646
|
-
TALibFFI.cdllongline(open, high, low, close)
|
|
1647
|
-
end
|
|
1648
|
-
|
|
1649
|
-
# Matching Low pattern
|
|
1650
|
-
def cdl_matchinglow(open, high, low, close)
|
|
1651
|
-
check_available!
|
|
1652
|
-
validate_prices!(open)
|
|
1653
|
-
validate_prices!(high)
|
|
1654
|
-
validate_prices!(low)
|
|
1655
|
-
validate_prices!(close)
|
|
1656
|
-
|
|
1657
|
-
TALibFFI.cdlmatchinglow(open, high, low, close)
|
|
1658
|
-
end
|
|
1659
|
-
|
|
1660
|
-
# Mat Hold pattern
|
|
1661
|
-
def cdl_mathold(open, high, low, close, penetration: 0.5)
|
|
1662
|
-
check_available!
|
|
1663
|
-
validate_prices!(open)
|
|
1664
|
-
validate_prices!(high)
|
|
1665
|
-
validate_prices!(low)
|
|
1666
|
-
validate_prices!(close)
|
|
1667
|
-
|
|
1668
|
-
TALibFFI.cdlmathold(open, high, low, close, penetration: penetration)
|
|
1669
|
-
end
|
|
1670
|
-
|
|
1671
|
-
# Morning Doji Star pattern
|
|
1672
|
-
def cdl_morningdojistar(open, high, low, close, penetration: 0.3)
|
|
1673
|
-
check_available!
|
|
1674
|
-
validate_prices!(open)
|
|
1675
|
-
validate_prices!(high)
|
|
1676
|
-
validate_prices!(low)
|
|
1677
|
-
validate_prices!(close)
|
|
1678
|
-
|
|
1679
|
-
TALibFFI.cdlmorningdojistar(open, high, low, close, penetration: penetration)
|
|
1680
|
-
end
|
|
1681
|
-
|
|
1682
|
-
# On-Neck pattern
|
|
1683
|
-
def cdl_onneck(open, high, low, close)
|
|
1684
|
-
check_available!
|
|
1685
|
-
validate_prices!(open)
|
|
1686
|
-
validate_prices!(high)
|
|
1687
|
-
validate_prices!(low)
|
|
1688
|
-
validate_prices!(close)
|
|
1689
|
-
|
|
1690
|
-
TALibFFI.cdlonneck(open, high, low, close)
|
|
1691
|
-
end
|
|
1692
|
-
|
|
1693
|
-
# Rickshaw Man pattern
|
|
1694
|
-
def cdl_rickshawman(open, high, low, close)
|
|
1695
|
-
check_available!
|
|
1696
|
-
validate_prices!(open)
|
|
1697
|
-
validate_prices!(high)
|
|
1698
|
-
validate_prices!(low)
|
|
1699
|
-
validate_prices!(close)
|
|
1700
|
-
|
|
1701
|
-
TALibFFI.cdlrickshawman(open, high, low, close)
|
|
1702
|
-
end
|
|
1703
|
-
|
|
1704
|
-
# Rising/Falling Three Methods pattern
|
|
1705
|
-
def cdl_risefall3methods(open, high, low, close)
|
|
1706
|
-
check_available!
|
|
1707
|
-
validate_prices!(open)
|
|
1708
|
-
validate_prices!(high)
|
|
1709
|
-
validate_prices!(low)
|
|
1710
|
-
validate_prices!(close)
|
|
1711
|
-
|
|
1712
|
-
TALibFFI.cdlrisefall3methods(open, high, low, close)
|
|
1713
|
-
end
|
|
1714
|
-
|
|
1715
|
-
# Separating Lines pattern
|
|
1716
|
-
def cdl_separatinglines(open, high, low, close)
|
|
1717
|
-
check_available!
|
|
1718
|
-
validate_prices!(open)
|
|
1719
|
-
validate_prices!(high)
|
|
1720
|
-
validate_prices!(low)
|
|
1721
|
-
validate_prices!(close)
|
|
1722
|
-
|
|
1723
|
-
TALibFFI.cdlseparatinglines(open, high, low, close)
|
|
1724
|
-
end
|
|
1725
|
-
|
|
1726
|
-
# Short Line Candle pattern
|
|
1727
|
-
def cdl_shortline(open, high, low, close)
|
|
1728
|
-
check_available!
|
|
1729
|
-
validate_prices!(open)
|
|
1730
|
-
validate_prices!(high)
|
|
1731
|
-
validate_prices!(low)
|
|
1732
|
-
validate_prices!(close)
|
|
1733
|
-
|
|
1734
|
-
TALibFFI.cdlshortline(open, high, low, close)
|
|
1735
|
-
end
|
|
1736
|
-
|
|
1737
|
-
# Stalled Pattern
|
|
1738
|
-
def cdl_stalledpattern(open, high, low, close)
|
|
1739
|
-
check_available!
|
|
1740
|
-
validate_prices!(open)
|
|
1741
|
-
validate_prices!(high)
|
|
1742
|
-
validate_prices!(low)
|
|
1743
|
-
validate_prices!(close)
|
|
1744
|
-
|
|
1745
|
-
TALibFFI.cdlstalledpattern(open, high, low, close)
|
|
1746
|
-
end
|
|
1747
|
-
|
|
1748
|
-
# Stick Sandwich pattern
|
|
1749
|
-
def cdl_sticksandwich(open, high, low, close)
|
|
1750
|
-
check_available!
|
|
1751
|
-
validate_prices!(open)
|
|
1752
|
-
validate_prices!(high)
|
|
1753
|
-
validate_prices!(low)
|
|
1754
|
-
validate_prices!(close)
|
|
1755
|
-
|
|
1756
|
-
TALibFFI.cdlsticksandwich(open, high, low, close)
|
|
1757
|
-
end
|
|
1758
|
-
|
|
1759
|
-
# Takuri (Dragonfly Doji with very long lower shadow) pattern
|
|
1760
|
-
def cdl_takuri(open, high, low, close)
|
|
1761
|
-
check_available!
|
|
1762
|
-
validate_prices!(open)
|
|
1763
|
-
validate_prices!(high)
|
|
1764
|
-
validate_prices!(low)
|
|
1765
|
-
validate_prices!(close)
|
|
1766
|
-
|
|
1767
|
-
TALibFFI.cdltakuri(open, high, low, close)
|
|
1768
|
-
end
|
|
1769
|
-
|
|
1770
|
-
# Tasuki Gap pattern
|
|
1771
|
-
def cdl_tasukigap(open, high, low, close)
|
|
1772
|
-
check_available!
|
|
1773
|
-
validate_prices!(open)
|
|
1774
|
-
validate_prices!(high)
|
|
1775
|
-
validate_prices!(low)
|
|
1776
|
-
validate_prices!(close)
|
|
1777
|
-
|
|
1778
|
-
TALibFFI.cdltasukigap(open, high, low, close)
|
|
1779
|
-
end
|
|
1780
|
-
|
|
1781
|
-
# Thrusting pattern
|
|
1782
|
-
def cdl_thrusting(open, high, low, close)
|
|
1783
|
-
check_available!
|
|
1784
|
-
validate_prices!(open)
|
|
1785
|
-
validate_prices!(high)
|
|
1786
|
-
validate_prices!(low)
|
|
1787
|
-
validate_prices!(close)
|
|
1788
|
-
|
|
1789
|
-
TALibFFI.cdlthrusting(open, high, low, close)
|
|
1790
|
-
end
|
|
1791
|
-
|
|
1792
|
-
# Tristar pattern
|
|
1793
|
-
def cdl_tristar(open, high, low, close)
|
|
1794
|
-
check_available!
|
|
1795
|
-
validate_prices!(open)
|
|
1796
|
-
validate_prices!(high)
|
|
1797
|
-
validate_prices!(low)
|
|
1798
|
-
validate_prices!(close)
|
|
1799
|
-
|
|
1800
|
-
TALibFFI.cdltristar(open, high, low, close)
|
|
1801
|
-
end
|
|
1802
|
-
|
|
1803
|
-
# Unique 3 River pattern
|
|
1804
|
-
def cdl_unique3river(open, high, low, close)
|
|
1805
|
-
check_available!
|
|
1806
|
-
validate_prices!(open)
|
|
1807
|
-
validate_prices!(high)
|
|
1808
|
-
validate_prices!(low)
|
|
1809
|
-
validate_prices!(close)
|
|
1810
|
-
|
|
1811
|
-
TALibFFI.cdlunique3river(open, high, low, close)
|
|
1812
|
-
end
|
|
1813
|
-
|
|
1814
|
-
# Upside Gap Two Crows pattern
|
|
1815
|
-
def cdl_upsidegap2crows(open, high, low, close)
|
|
1816
|
-
check_available!
|
|
1817
|
-
validate_prices!(open)
|
|
1818
|
-
validate_prices!(high)
|
|
1819
|
-
validate_prices!(low)
|
|
1820
|
-
validate_prices!(close)
|
|
1821
|
-
|
|
1822
|
-
TALibFFI.cdlupsidegap2crows(open, high, low, close)
|
|
1823
|
-
end
|
|
1824
|
-
|
|
1825
|
-
# Upside/Downside Gap Three Methods pattern
|
|
1826
|
-
def cdl_xsidegap3methods(open, high, low, close)
|
|
1827
|
-
check_available!
|
|
1828
|
-
validate_prices!(open)
|
|
1829
|
-
validate_prices!(high)
|
|
1830
|
-
validate_prices!(low)
|
|
1831
|
-
validate_prices!(close)
|
|
1832
|
-
|
|
1833
|
-
TALibFFI.cdlxsidegap3methods(open, high, low, close)
|
|
1834
|
-
end
|
|
1835
|
-
|
|
1836
117
|
private
|
|
1837
118
|
|
|
1838
119
|
def validate_prices!(prices)
|