ta_lib_ffi 0.3.0 → 0.4.0
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 +16 -0
- data/README.md +50 -68
- data/Rakefile +5 -4
- data/lib/ta_lib_ffi/version.rb +5 -0
- data/lib/ta_lib_ffi.rb +1035 -308
- data/ta_lib_ffi.gemspec +3 -2
- metadata +20 -8
data/lib/ta_lib_ffi.rb
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
require "fiddle"
|
|
4
4
|
require "fiddle/import"
|
|
5
|
+
require "rubygems/version"
|
|
6
|
+
require_relative "ta_lib_ffi/version"
|
|
5
7
|
|
|
6
8
|
# Ruby FFI wrapper for TA-Lib (Technical Analysis Library)
|
|
7
9
|
#
|
|
@@ -18,8 +20,6 @@ require "fiddle/import"
|
|
|
18
20
|
#
|
|
19
21
|
# @see https://ta-lib.org/ TA-Lib Official Website
|
|
20
22
|
module TALibFFI
|
|
21
|
-
VERSION = "0.3.0"
|
|
22
|
-
|
|
23
23
|
if defined?(Zeitwerk)
|
|
24
24
|
# https://github.com/fxn/zeitwerk?tab=readme-ov-file#custom-inflector
|
|
25
25
|
# @!visibility private
|
|
@@ -37,17 +37,14 @@ module TALibFFI
|
|
|
37
37
|
|
|
38
38
|
extend Fiddle::Importer
|
|
39
39
|
|
|
40
|
-
lib_path =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
else
|
|
49
|
-
raise "Unsupported platform"
|
|
50
|
-
end
|
|
40
|
+
lib_path = ENV.fetch("TA_LIB_PATH") do
|
|
41
|
+
case RUBY_PLATFORM
|
|
42
|
+
when /darwin/ then "#{`brew --prefix`.chomp}/lib/libta-lib.dylib"
|
|
43
|
+
when /linux/ then "libta-lib.so"
|
|
44
|
+
when /cygwin|mswin|mingw|bccwin|wince|emx/ then "C:/Program Files/TA-Lib/bin/ta-lib.dll"
|
|
45
|
+
else raise "Unsupported platform: #{RUBY_PLATFORM}"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
51
48
|
|
|
52
49
|
dlload lib_path
|
|
53
50
|
|
|
@@ -73,16 +70,6 @@ module TALibFFI
|
|
|
73
70
|
TA_INTERNAL_ERROR = 5000
|
|
74
71
|
TA_UNKNOWN_ERR = 0xFFFF
|
|
75
72
|
|
|
76
|
-
# {0,"SMA"},
|
|
77
|
-
# {1,"EMA"},
|
|
78
|
-
# {2,"WMA"},
|
|
79
|
-
# {3,"DEMA" },
|
|
80
|
-
# {4,"TEMA" },
|
|
81
|
-
# {5,"TRIMA"},
|
|
82
|
-
# {6,"KAMA" },
|
|
83
|
-
# {7,"MAMA" },
|
|
84
|
-
# {8,"T3"}
|
|
85
|
-
|
|
86
73
|
typealias "TA_Real", "double"
|
|
87
74
|
typealias "TA_Integer", "int"
|
|
88
75
|
typealias "TA_RetCode", "int"
|
|
@@ -102,11 +89,19 @@ module TALibFFI
|
|
|
102
89
|
"void *hiddenData"
|
|
103
90
|
]
|
|
104
91
|
|
|
92
|
+
# TA-Lib 0.8.1 removed camelCaseName. Older Windows DLLs can omit
|
|
93
|
+
# TA_GetVersionString entirely and use the original struct layout.
|
|
94
|
+
version_export = handler.sym("TA_GetVersionString")
|
|
95
|
+
if version_export
|
|
96
|
+
version_string = Fiddle::Function.new(version_export, [], Fiddle::TYPE_VOIDP).call.to_s
|
|
97
|
+
native_version = Gem::Version.new(version_string.split.first)
|
|
98
|
+
end
|
|
99
|
+
legacy_func_info = !native_version || native_version < Gem::Version.new("0.8.1")
|
|
105
100
|
TA_FuncInfo = struct [
|
|
106
101
|
"const char *name",
|
|
107
102
|
"const char *group",
|
|
108
103
|
"const char *hint",
|
|
109
|
-
"const char *camelCaseName",
|
|
104
|
+
*(["const char *camelCaseName"] if legacy_func_info),
|
|
110
105
|
"TA_FuncFlags flags",
|
|
111
106
|
"unsigned int nbInput",
|
|
112
107
|
"unsigned int nbOptInput",
|
|
@@ -153,6 +148,13 @@ module TALibFFI
|
|
|
153
148
|
TA_Output_Integer: 1
|
|
154
149
|
}.freeze
|
|
155
150
|
|
|
151
|
+
PRICE_FIELDS = %w[open high low close volume open_interest].freeze
|
|
152
|
+
OUTPUT_LAYOUTS = {
|
|
153
|
+
TA_PARAM_TYPE[:TA_Output_Real] => ["d", Fiddle::SIZEOF_DOUBLE, :TA_SetOutputParamRealPtr].freeze,
|
|
154
|
+
TA_PARAM_TYPE[:TA_Output_Integer] => ["i!", Fiddle::SIZEOF_INT, :TA_SetOutputParamIntegerPtr].freeze
|
|
155
|
+
}.freeze
|
|
156
|
+
private_constant :PRICE_FIELDS, :OUTPUT_LAYOUTS
|
|
157
|
+
|
|
156
158
|
TA_FLAGS = {
|
|
157
159
|
TA_InputFlags: {
|
|
158
160
|
TA_IN_PRICE_OPEN: 0x00000001,
|
|
@@ -182,7 +184,10 @@ module TALibFFI
|
|
|
182
184
|
TA_OUT_NEGATIVE: 0x00000200,
|
|
183
185
|
TA_OUT_ZERO: 0x00000400,
|
|
184
186
|
TA_OUT_UPPER_LIMIT: 0x00000800,
|
|
185
|
-
TA_OUT_LOWER_LIMIT: 0x00001000
|
|
187
|
+
TA_OUT_LOWER_LIMIT: 0x00001000,
|
|
188
|
+
TA_OUT_NULLABLE: 0x00002000,
|
|
189
|
+
TA_OUT_DISPLAY_SHIFT: 0x00004000,
|
|
190
|
+
TA_OUT_PATTERN_WEAK: 0x00008000
|
|
186
191
|
}
|
|
187
192
|
}.freeze
|
|
188
193
|
|
|
@@ -192,7 +197,7 @@ module TALibFFI
|
|
|
192
197
|
extern "int TA_GroupTableFree(TA_StringTable*)"
|
|
193
198
|
extern "TA_RetCode TA_FuncTableAlloc(const char *group, TA_StringTable **table)"
|
|
194
199
|
extern "TA_RetCode TA_FuncTableFree(TA_StringTable *table)"
|
|
195
|
-
extern "
|
|
200
|
+
extern "TA_RetCode TA_GetFuncHandle(const char *name, const TA_FuncHandle **handle)"
|
|
196
201
|
extern "TA_RetCode TA_GetFuncInfo(const TA_FuncHandle *handle, const TA_FuncInfo **funcInfo)"
|
|
197
202
|
extern "TA_RetCode TA_ForEachFunc(TA_CallForEachFunc functionToCall, void *opaqueData)"
|
|
198
203
|
extern "TA_RetCode TA_GetInputParameterInfo(const TA_FuncHandle *handle, unsigned int paramIndex, const TA_InputParameterInfo **info)"
|
|
@@ -230,26 +235,34 @@ module TALibFFI
|
|
|
230
235
|
# @param type [Symbol] The type of flags to extract (:TA_InputFlags, :TA_OptInputFlags, or :TA_OutputFlags)
|
|
231
236
|
# @return [Array<Symbol>] Array of flag names that are set in the bitmask
|
|
232
237
|
def extract_flags(value, type)
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
+
TA_FLAGS.fetch(type).filter_map { |name, bit| name if (value & bit) != 0 }
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# The caller owns only the pointer-sized output slot. TA-Lib determines the
|
|
242
|
+
# lifetime of the address written into it (static metadata, a table or a holder).
|
|
243
|
+
def native_pointer
|
|
244
|
+
slot = [0].pack("J")
|
|
245
|
+
check_ta_return_code(yield(slot))
|
|
246
|
+
Fiddle::Pointer.new(slot.unpack1("J"))
|
|
238
247
|
end
|
|
248
|
+
private_class_method :native_pointer
|
|
249
|
+
|
|
250
|
+
def string_table_names(pointer)
|
|
251
|
+
table = TA_StringTable.new(pointer)
|
|
252
|
+
return [] if table["size"].zero?
|
|
253
|
+
|
|
254
|
+
table["string"].to_s(table["size"] * Fiddle::SIZEOF_VOIDP).unpack("J*").map { |address| Fiddle::Pointer.new(address).to_s }
|
|
255
|
+
end
|
|
256
|
+
private_class_method :string_table_names
|
|
239
257
|
|
|
240
258
|
# Returns a list of all available function groups in TA-Lib
|
|
241
259
|
#
|
|
242
260
|
# @return [Array<String>] Array of group names
|
|
243
261
|
def group_table
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
string_table = TA_StringTable.new(string_table_ptr)
|
|
249
|
-
group_names = Fiddle::Pointer.new(string_table["string"])[0, Fiddle::SIZEOF_VOIDP * string_table["size"]].unpack("Q*").collect { |ptr| Fiddle::Pointer.new(ptr).to_s }
|
|
250
|
-
TA_GroupTableFree(string_table_ptr)
|
|
251
|
-
|
|
252
|
-
group_names
|
|
262
|
+
table = native_pointer { |slot| TA_GroupTableAlloc(slot) }
|
|
263
|
+
string_table_names(table)
|
|
264
|
+
ensure
|
|
265
|
+
TA_GroupTableFree(table) if table
|
|
253
266
|
end
|
|
254
267
|
|
|
255
268
|
# Returns a list of all functions in a specific group
|
|
@@ -257,16 +270,10 @@ module TALibFFI
|
|
|
257
270
|
# @param group [String] The name of the group to get functions for
|
|
258
271
|
# @return [Array<String>] Array of function names in the group
|
|
259
272
|
def function_table(group)
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
string_table = TA_StringTable.new(string_table_ptr)
|
|
265
|
-
func_names = Fiddle::Pointer.new(string_table["string"])[0, Fiddle::SIZEOF_VOIDP * string_table["size"]].unpack("Q*").collect { |ptr| Fiddle::Pointer.new(ptr).to_s }
|
|
266
|
-
|
|
267
|
-
TA_FuncTableFree(string_table)
|
|
268
|
-
|
|
269
|
-
func_names
|
|
273
|
+
table = native_pointer { |slot| TA_FuncTableAlloc(group, slot) }
|
|
274
|
+
string_table_names(table)
|
|
275
|
+
ensure
|
|
276
|
+
TA_FuncTableFree(table) if table
|
|
270
277
|
end
|
|
271
278
|
|
|
272
279
|
# Gets detailed information about a specific TA-Lib function
|
|
@@ -274,15 +281,8 @@ module TALibFFI
|
|
|
274
281
|
# @param name [String] The name of the function to get information for
|
|
275
282
|
# @return [Fiddle::CStructEntity] Struct containing function information
|
|
276
283
|
def function_info(name)
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
check_ta_return_code(ret_code)
|
|
280
|
-
|
|
281
|
-
info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
|
|
282
|
-
ret_code = TA_GetFuncInfo(handle_ptr, info_ptr.ref)
|
|
283
|
-
check_ta_return_code(ret_code)
|
|
284
|
-
|
|
285
|
-
TA_FuncInfo.new(info_ptr)
|
|
284
|
+
handle = get_function_handle(name)
|
|
285
|
+
TA_FuncInfo.new(native_pointer { |slot| TA_GetFuncInfo(handle, slot) })
|
|
286
286
|
end
|
|
287
287
|
|
|
288
288
|
# Iterates over all available TA-Lib functions
|
|
@@ -309,7 +309,7 @@ module TALibFFI
|
|
|
309
309
|
puts "Function Name: #{func_info["name"]}"
|
|
310
310
|
puts "Function Group: #{func_info["group"]}"
|
|
311
311
|
puts "Function Hint: #{func_info["hint"]}"
|
|
312
|
-
puts "Camel Case Name: #{func_info["camelCaseName"]}"
|
|
312
|
+
puts "Camel Case Name: #{func_info["camelCaseName"]}" if TA_FuncInfo.members.include?("camelCaseName")
|
|
313
313
|
puts "Flags: #{func_info["flags"]}"
|
|
314
314
|
puts "Number of Inputs: #{func_info["nbInput"]}"
|
|
315
315
|
puts "Number of Optional Inputs: #{func_info["nbOptInput"]}"
|
|
@@ -317,11 +317,7 @@ module TALibFFI
|
|
|
317
317
|
puts "Function Handle: #{func_info["handle"].to_i}"
|
|
318
318
|
|
|
319
319
|
puts "\nInput Parameter Info:"
|
|
320
|
-
func_info
|
|
321
|
-
param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
|
|
322
|
-
ret_code = TA_GetInputParameterInfo(func_info["handle"], i, param_info_ptr.ref)
|
|
323
|
-
check_ta_return_code(ret_code)
|
|
324
|
-
param_info = TA_InputParameterInfo.new(param_info_ptr)
|
|
320
|
+
collect_input_info(func_info).each_with_index do |param_info, i|
|
|
325
321
|
puts " Parameter #{i + 1}:"
|
|
326
322
|
puts " Name: #{param_info["paramName"]}"
|
|
327
323
|
puts " Type: #{param_info["type"]}"
|
|
@@ -329,11 +325,7 @@ module TALibFFI
|
|
|
329
325
|
end
|
|
330
326
|
|
|
331
327
|
puts "\nOptional Input Parameter Info:"
|
|
332
|
-
func_info
|
|
333
|
-
param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
|
|
334
|
-
ret_code = TA_GetOptInputParameterInfo(func_info["handle"], i, param_info_ptr.ref)
|
|
335
|
-
check_ta_return_code(ret_code)
|
|
336
|
-
param_info = TA_OptInputParameterInfo.new(param_info_ptr)
|
|
328
|
+
collect_opt_input_info(func_info).each_with_index do |param_info, i|
|
|
337
329
|
puts " Parameter #{i + 1}:"
|
|
338
330
|
puts " Name: #{param_info["paramName"]}"
|
|
339
331
|
puts " Type: #{param_info["type"]}"
|
|
@@ -344,11 +336,7 @@ module TALibFFI
|
|
|
344
336
|
end
|
|
345
337
|
|
|
346
338
|
puts "\nOutput Parameter Info:"
|
|
347
|
-
func_info
|
|
348
|
-
param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
|
|
349
|
-
ret_code = TA_GetOutputParameterInfo(func_info["handle"], i, param_info_ptr.ref)
|
|
350
|
-
check_ta_return_code(ret_code)
|
|
351
|
-
param_info = TA_OutputParameterInfo.new(param_info_ptr)
|
|
339
|
+
collect_output_info(func_info).each_with_index do |param_info, i|
|
|
352
340
|
puts " Parameter #{i + 1}:"
|
|
353
341
|
puts " Name: #{param_info["paramName"]}"
|
|
354
342
|
puts " Type: #{param_info["type"]}"
|
|
@@ -362,64 +350,97 @@ module TALibFFI
|
|
|
362
350
|
# @param args [Array] Array of input arrays and optional parameters
|
|
363
351
|
# @return [Array, Hash] Function results (single array or hash of named outputs)
|
|
364
352
|
# @raise [TALibError] If there is an error in function execution
|
|
365
|
-
def call_func(func_name, args)
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
353
|
+
def call_func(func_name, args)
|
|
354
|
+
info = function_info_map.fetch(func_name) { raise TALibError, "Unknown TA-Lib function #{func_name.inspect}" }
|
|
355
|
+
inputs, options = args.last.is_a?(Hash) ? [args[0...-1], args.last] : [args, {}]
|
|
356
|
+
size = validate_inputs!(inputs, func_name)
|
|
357
|
+
validate_options!(func_name, options, info[:keywords])
|
|
358
|
+
run_indicator(info[:handle], func_name, inputs, options, size)
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
def run_indicator(handle, name, inputs, options, size)
|
|
362
|
+
params = create_parameter_holder(handle)
|
|
363
|
+
setup_input_parameters(params, inputs, name, size: size)
|
|
364
|
+
setup_optional_parameters(params, options, name)
|
|
365
|
+
calculate_results(params, inputs, name, input_size: size)
|
|
366
|
+
rescue TALibError, TypeError, RangeError => e
|
|
367
|
+
arguments = options.map { |key, value| "#{key}=#{value.inspect}" }.join(", ")
|
|
368
|
+
raise TALibError, "#{name}(#{arguments}): #{e.message}"
|
|
369
|
+
ensure
|
|
370
|
+
TA_ParamHolderFree(params) if params
|
|
382
371
|
end
|
|
372
|
+
private_class_method :run_indicator
|
|
383
373
|
|
|
384
374
|
# Calculates the lookback period for a function with given parameters
|
|
385
375
|
#
|
|
386
376
|
# @param params_ptr [Fiddle::Pointer] Pointer to parameter holder
|
|
387
377
|
# @return [Integer] The lookback period
|
|
388
378
|
def calculate_lookback(params_ptr)
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
lookback_ptr[0, Fiddle::SIZEOF_INT].unpack1("l")
|
|
379
|
+
lookback = [0].pack("i!")
|
|
380
|
+
check_ta_return_code(TA_GetLookback(params_ptr, lookback))
|
|
381
|
+
lookback.unpack1("i!")
|
|
393
382
|
end
|
|
394
383
|
|
|
395
384
|
# Validates input arrays for TA-Lib functions
|
|
396
385
|
#
|
|
397
386
|
# @param arrays [Array<Array>] Arrays to validate
|
|
398
387
|
# @raise [TALibError] If any array is invalid
|
|
399
|
-
def validate_inputs!(arrays
|
|
400
|
-
|
|
388
|
+
def validate_inputs!(arrays, func_name = nil)
|
|
389
|
+
series = if func_name
|
|
390
|
+
input_series(func_name, arrays)
|
|
391
|
+
else
|
|
392
|
+
arrays.flat_map { |arg| arg.is_a?(Array) && arg.first.is_a?(Array) ? arg : [arg] }
|
|
393
|
+
end
|
|
394
|
+
series_length!(series, func_name)
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
def series_length!(series, func_name)
|
|
398
|
+
raise TALibError, "Expected input arrays" unless series.all?(Array)
|
|
399
|
+
|
|
400
|
+
lengths = series.map(&:length).uniq
|
|
401
|
+
raise TALibError, "Input arrays cannot be empty" unless lengths.fetch(0, 0).positive?
|
|
402
|
+
raise TALibError, "#{func_name} input series must have equal lengths (got #{lengths.join(", ")})" unless lengths.one?
|
|
403
|
+
raise TALibError, "Input arrays must contain only numbers" unless series.all? { |values| values.all?(Numeric) }
|
|
404
|
+
|
|
405
|
+
lengths.first
|
|
406
|
+
end
|
|
407
|
+
private_class_method :series_length!
|
|
408
|
+
|
|
409
|
+
def input_series(name, args)
|
|
410
|
+
layout = function_info_map.fetch(name)[:input_names]
|
|
411
|
+
input_shape_error!(name, layout) unless layout.size == args.size
|
|
412
|
+
args.zip(layout).flat_map do |arg, fields|
|
|
413
|
+
next [arg] unless fields.is_a?(Array)
|
|
401
414
|
|
|
402
|
-
|
|
403
|
-
|
|
415
|
+
input_shape_error!(name, layout) unless arg.is_a?(Array) && arg.size == fields.size && arg.all?(Array)
|
|
416
|
+
arg
|
|
404
417
|
end
|
|
418
|
+
end
|
|
419
|
+
private_class_method :input_series
|
|
405
420
|
|
|
406
|
-
|
|
407
|
-
|
|
421
|
+
def input_shape_error!(name, layout)
|
|
422
|
+
args = layout.map { |input| input.is_a?(Array) ? "[#{input.join(", ")}]" : input }
|
|
423
|
+
raise TALibError, "Expected TALibFFI.#{name.downcase}(#{args.join(", ")}) with optional parameters passed by keyword"
|
|
424
|
+
end
|
|
425
|
+
private_class_method :input_shape_error!
|
|
408
426
|
|
|
409
|
-
|
|
410
|
-
|
|
427
|
+
def validate_options!(name, options, keywords)
|
|
428
|
+
options.each do |key, value|
|
|
429
|
+
unless keywords.key?(key)
|
|
430
|
+
allowed = keywords.empty? ? "no keywords accepted" : "available keywords: #{keywords.keys.join(", ")}"
|
|
431
|
+
raise TALibError, "#{name} unknown keyword #{key.inspect} (#{allowed})"
|
|
432
|
+
end
|
|
433
|
+
raise TALibError, "#{name} keyword #{key.inspect} requires a number" unless value.is_a?(Numeric)
|
|
411
434
|
end
|
|
412
435
|
end
|
|
436
|
+
private_class_method :validate_options!
|
|
413
437
|
|
|
414
438
|
# Gets a function handle for a given function name
|
|
415
439
|
#
|
|
416
440
|
# @param func_name [String] The name of the function
|
|
417
441
|
# @return [Fiddle::Pointer] Pointer to function handle
|
|
418
442
|
def get_function_handle(func_name)
|
|
419
|
-
|
|
420
|
-
ret_code = TA_GetFuncHandle(func_name, handle_ptr.ref)
|
|
421
|
-
check_ta_return_code(ret_code)
|
|
422
|
-
handle_ptr
|
|
443
|
+
native_pointer { |slot| TA_GetFuncHandle(func_name, slot) }
|
|
423
444
|
end
|
|
424
445
|
|
|
425
446
|
# Creates a parameter holder for a function
|
|
@@ -427,10 +448,7 @@ module TALibFFI
|
|
|
427
448
|
# @param handle_ptr [Fiddle::Pointer] Function handle pointer
|
|
428
449
|
# @return [Fiddle::Pointer] Pointer to parameter holder
|
|
429
450
|
def create_parameter_holder(handle_ptr)
|
|
430
|
-
|
|
431
|
-
ret_code = TA_ParamHolderAlloc(handle_ptr, params_ptr.ref)
|
|
432
|
-
check_ta_return_code(ret_code)
|
|
433
|
-
params_ptr
|
|
451
|
+
native_pointer { |slot| TA_ParamHolderAlloc(handle_ptr, slot) }
|
|
434
452
|
end
|
|
435
453
|
|
|
436
454
|
# Sets up input parameters for a function call
|
|
@@ -438,11 +456,11 @@ module TALibFFI
|
|
|
438
456
|
# @param params_ptr [Fiddle::Pointer] Parameter holder pointer
|
|
439
457
|
# @param input_arrays [Array<Array>] Input data arrays
|
|
440
458
|
# @param func_name [String] Function name
|
|
441
|
-
def setup_input_parameters(params_ptr, input_arrays, func_name)
|
|
459
|
+
def setup_input_parameters(params_ptr, input_arrays, func_name, size: nil)
|
|
442
460
|
func_info = function_info_map[func_name]
|
|
443
461
|
input_arrays.each_with_index do |array, index|
|
|
444
462
|
input_info = func_info[:inputs][index]
|
|
445
|
-
ret_code = set_input_parameter(params_ptr, index, array, input_info)
|
|
463
|
+
ret_code = set_input_parameter(params_ptr, index, array, input_info, size: size)
|
|
446
464
|
check_ta_return_code(ret_code)
|
|
447
465
|
end
|
|
448
466
|
end
|
|
@@ -454,53 +472,64 @@ module TALibFFI
|
|
|
454
472
|
# @param array [Array] Input data array
|
|
455
473
|
# @param input_info [Hash] Input parameter information
|
|
456
474
|
# @return [Integer] TA-Lib return code
|
|
457
|
-
def set_input_parameter(params_ptr, index, array, input_info)
|
|
475
|
+
def set_input_parameter(params_ptr, index, array, input_info, size: nil)
|
|
458
476
|
case input_info["type"]
|
|
459
477
|
when TA_PARAM_TYPE[:TA_Input_Real]
|
|
460
|
-
|
|
461
|
-
TA_SetInputParamRealPtr(params_ptr, index, input_ptr)
|
|
478
|
+
bind_input(params_ptr, index, prepare_double_array(array, size: size)) { |ptr| TA_SetInputParamRealPtr(params_ptr, index, ptr) }
|
|
462
479
|
when TA_PARAM_TYPE[:TA_Input_Integer]
|
|
463
|
-
|
|
464
|
-
TA_SetInputParamIntegerPtr(params_ptr, index, input_ptr)
|
|
480
|
+
bind_input(params_ptr, index, prepare_integer_array(array, size: size)) { |ptr| TA_SetInputParamIntegerPtr(params_ptr, index, ptr) }
|
|
465
481
|
when TA_PARAM_TYPE[:TA_Input_Price]
|
|
466
|
-
setup_price_inputs(params_ptr, index, array, input_info["flags"])
|
|
482
|
+
setup_price_inputs(params_ptr, index, array, input_info["flags"], size: size)
|
|
467
483
|
end
|
|
468
484
|
end
|
|
469
485
|
|
|
486
|
+
# TA-Lib borrows these pointers until TA_CallFunc returns. Keep the pointers
|
|
487
|
+
# (and the packed Ruby strings they pin) alive on this particular holder.
|
|
488
|
+
def bind_input(holder, index, buffer)
|
|
489
|
+
status = yield(buffer)
|
|
490
|
+
if status == TA_SUCCESS
|
|
491
|
+
inputs = holder.instance_variable_get(:@ta_input_buffers) || holder.instance_variable_set(:@ta_input_buffers, [])
|
|
492
|
+
inputs[index] = buffer
|
|
493
|
+
end
|
|
494
|
+
status
|
|
495
|
+
end
|
|
496
|
+
private_class_method :bind_input
|
|
497
|
+
|
|
470
498
|
# Prepares a double array for TA-Lib input
|
|
471
499
|
#
|
|
472
500
|
# @param array [Array<Numeric>] Array of numbers to prepare
|
|
473
501
|
# @return [Fiddle::Pointer] Pointer to prepared array
|
|
474
|
-
def prepare_double_array(array)
|
|
475
|
-
|
|
476
|
-
array.each_with_index do |value, i|
|
|
477
|
-
array_ptr[i * Fiddle::SIZEOF_DOUBLE, Fiddle::SIZEOF_DOUBLE] = [value.to_f].pack("d")
|
|
478
|
-
end
|
|
479
|
-
array_ptr
|
|
502
|
+
def prepare_double_array(array, size: nil)
|
|
503
|
+
packed_input(array.pack("d*"), Fiddle::SIZEOF_DOUBLE, size)
|
|
480
504
|
end
|
|
481
505
|
|
|
482
506
|
# Prepares an integer array for TA-Lib input
|
|
483
507
|
#
|
|
484
508
|
# @param array [Array<Numeric>] Array of numbers to prepare
|
|
485
509
|
# @return [Fiddle::Pointer] Pointer to prepared array
|
|
486
|
-
def prepare_integer_array(array)
|
|
487
|
-
|
|
488
|
-
array.each_with_index do |value, i|
|
|
489
|
-
array_ptr[i * Fiddle::SIZEOF_INT, Fiddle::SIZEOF_INT] = [value.to_i].pack("l")
|
|
490
|
-
end
|
|
491
|
-
array_ptr
|
|
510
|
+
def prepare_integer_array(array, size: nil)
|
|
511
|
+
packed_input(array.pack("i!*"), Fiddle::SIZEOF_INT, size)
|
|
492
512
|
end
|
|
493
513
|
|
|
514
|
+
# Check the actual snapshot too. Other Ruby threads can change an input
|
|
515
|
+
# array between validation and packing while Fiddle releases the GVL.
|
|
516
|
+
def packed_input(bytes, width, size)
|
|
517
|
+
raise TALibError, "Input length changed during calculation" if size && bytes.bytesize != size * width
|
|
518
|
+
|
|
519
|
+
Fiddle::Pointer[bytes]
|
|
520
|
+
end
|
|
521
|
+
private_class_method :packed_input
|
|
522
|
+
|
|
494
523
|
# Sets up optional parameters for a function call
|
|
495
524
|
#
|
|
496
525
|
# @param params_ptr [Fiddle::Pointer] Parameter holder pointer
|
|
497
526
|
# @param options [Hash] Optional parameters
|
|
498
527
|
# @param func_name [String] Function name
|
|
499
528
|
def setup_optional_parameters(params_ptr, options, func_name)
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
set_optional_parameter(params_ptr, index,
|
|
529
|
+
keywords = function_info_map.fetch(func_name)[:keywords]
|
|
530
|
+
options.each do |name, value|
|
|
531
|
+
index, type = keywords.fetch(name)
|
|
532
|
+
set_optional_parameter(params_ptr, index, value, type)
|
|
504
533
|
end
|
|
505
534
|
end
|
|
506
535
|
|
|
@@ -526,29 +555,15 @@ module TALibFFI
|
|
|
526
555
|
# @param input_arrays [Array] Input data
|
|
527
556
|
# @param func_name [String] Function name
|
|
528
557
|
# @return [Array, Hash] Function results
|
|
529
|
-
def calculate_results(params_ptr, input_arrays, func_name
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
out_size = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT)
|
|
539
|
-
output_arrays = setup_output_buffers(params_ptr, input_size, func_name)
|
|
540
|
-
|
|
541
|
-
begin
|
|
542
|
-
ret_code = TA_CallFunc(params_ptr, 0, input_size - 1, out_begin, out_size)
|
|
543
|
-
check_ta_return_code(ret_code)
|
|
544
|
-
|
|
545
|
-
actual_size = out_size[0, Fiddle::SIZEOF_INT].unpack1("l")
|
|
546
|
-
format_output_results(output_arrays, actual_size, func_name)
|
|
547
|
-
ensure
|
|
548
|
-
out_begin.free
|
|
549
|
-
out_size.free
|
|
550
|
-
output_arrays.each(&:free)
|
|
551
|
-
end
|
|
558
|
+
def calculate_results(params_ptr, input_arrays, func_name, input_size: validate_inputs!(input_arrays, func_name))
|
|
559
|
+
out_begin = [0].pack("i!")
|
|
560
|
+
out_size = [0].pack("i!")
|
|
561
|
+
buffers = setup_output_buffers(params_ptr, input_size, func_name)
|
|
562
|
+
check_ta_return_code(TA_CallFunc(params_ptr, 0, input_size - 1, out_begin, out_size))
|
|
563
|
+
count = out_size.unpack1("i!")
|
|
564
|
+
raise TALibError, "Invalid output count #{count} for #{func_name}" unless count.between?(0, input_size)
|
|
565
|
+
|
|
566
|
+
format_output_results(buffers, count, func_name)
|
|
552
567
|
end
|
|
553
568
|
|
|
554
569
|
# Sets up output buffers for function results
|
|
@@ -557,31 +572,12 @@ module TALibFFI
|
|
|
557
572
|
# @param size [Integer] Size of output buffer
|
|
558
573
|
# @param func_name [String] Function name
|
|
559
574
|
# @return [Array<Fiddle::Pointer>] Array of output buffer pointers
|
|
560
|
-
def setup_output_buffers(params_ptr, size, func_name)
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
ptr = case output["type"]
|
|
566
|
-
when TA_PARAM_TYPE[:TA_Output_Real]
|
|
567
|
-
Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE * size)
|
|
568
|
-
when TA_PARAM_TYPE[:TA_Output_Integer]
|
|
569
|
-
Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT * size)
|
|
570
|
-
end
|
|
571
|
-
|
|
572
|
-
output_ptrs << ptr
|
|
573
|
-
|
|
574
|
-
ret_code = case output["type"]
|
|
575
|
-
when TA_PARAM_TYPE[:TA_Output_Real]
|
|
576
|
-
TA_SetOutputParamRealPtr(params_ptr, index, ptr)
|
|
577
|
-
when TA_PARAM_TYPE[:TA_Output_Integer]
|
|
578
|
-
TA_SetOutputParamIntegerPtr(params_ptr, index, ptr)
|
|
579
|
-
end
|
|
580
|
-
|
|
581
|
-
check_ta_return_code(ret_code)
|
|
575
|
+
def setup_output_buffers(params_ptr, size, func_name)
|
|
576
|
+
function_info_map.fetch(func_name)[:output_layout].map.with_index do |(_format, width, setter), index|
|
|
577
|
+
ptr = Fiddle::Pointer["\0".b * (size * width)]
|
|
578
|
+
check_ta_return_code(public_send(setter, params_ptr, index, ptr))
|
|
579
|
+
ptr
|
|
582
580
|
end
|
|
583
|
-
|
|
584
|
-
output_ptrs
|
|
585
581
|
end
|
|
586
582
|
|
|
587
583
|
# Formats output results from TA-Lib function
|
|
@@ -590,23 +586,12 @@ module TALibFFI
|
|
|
590
586
|
# @param size [Integer] Size of output data
|
|
591
587
|
# @param func_name [String] Function name
|
|
592
588
|
# @return [Array, Hash] Formatted results
|
|
593
|
-
def format_output_results(output_ptrs, size, func_name)
|
|
594
|
-
|
|
595
|
-
results = output_ptrs.zip(
|
|
596
|
-
|
|
597
|
-
when TA_PARAM_TYPE[:TA_Output_Real]
|
|
598
|
-
ptr[0, Fiddle::SIZEOF_DOUBLE * size].unpack("d#{size}")
|
|
599
|
-
when TA_PARAM_TYPE[:TA_Output_Integer]
|
|
600
|
-
ptr[0, Fiddle::SIZEOF_INT * size].unpack("l#{size}")
|
|
601
|
-
end
|
|
602
|
-
end
|
|
603
|
-
|
|
604
|
-
return results.first if results.length == 1
|
|
605
|
-
|
|
606
|
-
output_names = func_info[:outputs].map do |output|
|
|
607
|
-
normalize_parameter_name(output["paramName"].to_s).to_sym
|
|
589
|
+
def format_output_results(output_ptrs, size, func_name)
|
|
590
|
+
info = function_info_map.fetch(func_name)
|
|
591
|
+
results = output_ptrs.zip(info[:output_layout]).map do |ptr, (format, width, _)|
|
|
592
|
+
ptr.to_s(size * width).unpack("#{format}*")
|
|
608
593
|
end
|
|
609
|
-
output_names.zip(results).to_h
|
|
594
|
+
results.one? ? results.first : info[:output_names].zip(results).to_h
|
|
610
595
|
end
|
|
611
596
|
|
|
612
597
|
# Gets XML description of all TA-Lib functions
|
|
@@ -629,25 +614,56 @@ module TALibFFI
|
|
|
629
614
|
def build_function_info_map
|
|
630
615
|
info_map = {}
|
|
631
616
|
each_function do |func_info|
|
|
632
|
-
info_map[func_info["name"].to_s] =
|
|
633
|
-
info: func_info,
|
|
634
|
-
inputs: collect_input_info(func_info),
|
|
635
|
-
outputs: collect_output_info(func_info),
|
|
636
|
-
opt_inputs: collect_opt_input_info(func_info)
|
|
637
|
-
}
|
|
617
|
+
info_map[func_info["name"].to_s] = function_parameters(func_info)
|
|
638
618
|
end
|
|
639
619
|
info_map
|
|
640
620
|
end
|
|
641
621
|
|
|
622
|
+
def function_parameters(info)
|
|
623
|
+
inputs = collect_input_info(info)
|
|
624
|
+
options = collect_opt_input_info(info)
|
|
625
|
+
outputs = collect_output_info(info)
|
|
626
|
+
{
|
|
627
|
+
info: info, handle: info["handle"], inputs: inputs, opt_inputs: options, outputs: outputs,
|
|
628
|
+
input_names: inputs.map { |input| input_name(input) },
|
|
629
|
+
keywords: keyword_index(options),
|
|
630
|
+
output_layout: outputs.map { |output| OUTPUT_LAYOUTS.fetch(output["type"]) },
|
|
631
|
+
output_names: outputs.map { |output| parameter_key(output) }
|
|
632
|
+
}
|
|
633
|
+
end
|
|
634
|
+
private_class_method :function_parameters
|
|
635
|
+
|
|
636
|
+
def keyword_index(options)
|
|
637
|
+
options.each_with_index.to_h { |option, index| [parameter_key(option), [index, option["type"]]] }
|
|
638
|
+
end
|
|
639
|
+
private_class_method :keyword_index
|
|
640
|
+
|
|
641
|
+
def parameter_key(parameter)
|
|
642
|
+
normalize_parameter_name(parameter["paramName"].to_s).to_sym
|
|
643
|
+
end
|
|
644
|
+
private_class_method :parameter_key
|
|
645
|
+
def input_name(input)
|
|
646
|
+
return normalize_parameter_name(input["paramName"].to_s) unless input["type"] == TA_PARAM_TYPE[:TA_Input_Price]
|
|
647
|
+
|
|
648
|
+
PRICE_FIELDS.values_at(*price_indexes(input["flags"]))
|
|
649
|
+
end
|
|
650
|
+
private_class_method :input_name
|
|
651
|
+
|
|
652
|
+
def price_indexes(flags)
|
|
653
|
+
raise TALibError, "Unsupported TA-Lib price flags #{flags}" unless (flags >> PRICE_FIELDS.size).zero?
|
|
654
|
+
|
|
655
|
+
PRICE_FIELDS.each_index.select { |i| flags.anybits?(1 << i) }
|
|
656
|
+
end
|
|
657
|
+
private_class_method :price_indexes
|
|
658
|
+
|
|
642
659
|
# Collects input parameter information for a function
|
|
643
660
|
#
|
|
644
661
|
# @param func_info [Fiddle::CStructEntity] Function information
|
|
645
662
|
# @return [Array<Fiddle::CStructEntity>] Array of input parameter information
|
|
646
663
|
def collect_input_info(func_info)
|
|
647
|
-
func_info["
|
|
648
|
-
|
|
649
|
-
TA_GetInputParameterInfo(
|
|
650
|
-
TA_InputParameterInfo.new(param_info_ptr)
|
|
664
|
+
handle = func_info["handle"]
|
|
665
|
+
func_info["nbInput"].times.map do |index|
|
|
666
|
+
TA_InputParameterInfo.new(native_pointer { |slot| TA_GetInputParameterInfo(handle, index, slot) })
|
|
651
667
|
end
|
|
652
668
|
end
|
|
653
669
|
|
|
@@ -656,10 +672,9 @@ module TALibFFI
|
|
|
656
672
|
# @param func_info [Fiddle::CStructEntity] Function information
|
|
657
673
|
# @return [Array<Fiddle::CStructEntity>] Array of optional input parameter information
|
|
658
674
|
def collect_opt_input_info(func_info)
|
|
659
|
-
func_info["
|
|
660
|
-
|
|
661
|
-
TA_GetOptInputParameterInfo(
|
|
662
|
-
TA_OptInputParameterInfo.new(param_info_ptr)
|
|
675
|
+
handle = func_info["handle"]
|
|
676
|
+
func_info["nbOptInput"].times.map do |index|
|
|
677
|
+
TA_OptInputParameterInfo.new(native_pointer { |slot| TA_GetOptInputParameterInfo(handle, index, slot) })
|
|
663
678
|
end
|
|
664
679
|
end
|
|
665
680
|
|
|
@@ -668,10 +683,9 @@ module TALibFFI
|
|
|
668
683
|
# @param func_info [Fiddle::CStructEntity] Function information
|
|
669
684
|
# @return [Array<Fiddle::CStructEntity>] Array of output parameter information
|
|
670
685
|
def collect_output_info(func_info)
|
|
671
|
-
func_info["
|
|
672
|
-
|
|
673
|
-
TA_GetOutputParameterInfo(
|
|
674
|
-
TA_OutputParameterInfo.new(param_info_ptr)
|
|
686
|
+
handle = func_info["handle"]
|
|
687
|
+
func_info["nbOutput"].times.map do |index|
|
|
688
|
+
TA_OutputParameterInfo.new(native_pointer { |slot| TA_GetOutputParameterInfo(handle, index, slot) })
|
|
675
689
|
end
|
|
676
690
|
end
|
|
677
691
|
|
|
@@ -680,9 +694,7 @@ module TALibFFI
|
|
|
680
694
|
# This method iterates through all available TA-Lib functions and creates
|
|
681
695
|
# corresponding Ruby methods with proper documentation.
|
|
682
696
|
def generate_ta_functions
|
|
683
|
-
|
|
684
|
-
define_ta_function(func_info["name"].to_s.downcase, func_info["name"].to_s)
|
|
685
|
-
end
|
|
697
|
+
function_info_map.each_key { |name| define_ta_function(name.downcase, name) }
|
|
686
698
|
end
|
|
687
699
|
|
|
688
700
|
# Normalizes parameter names to Ruby style
|
|
@@ -775,30 +787,35 @@ module TALibFFI
|
|
|
775
787
|
# @param index [Integer] Parameter index
|
|
776
788
|
# @param price_data [Array] Price data array
|
|
777
789
|
# @param flags [Integer] Input flags
|
|
778
|
-
def setup_price_inputs(params_ptr, index, price_data, flags)
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
flag_index = TA_FLAGS[:TA_InputFlags].keys.index(flag)
|
|
783
|
-
data_pointers[flag_index] = prepare_double_array(price_data[i]) if required_flags.include?(flag)
|
|
784
|
-
end
|
|
785
|
-
|
|
786
|
-
TA_SetInputParamPricePtr(params_ptr, index, *data_pointers)
|
|
790
|
+
def setup_price_inputs(params_ptr, index, price_data, flags, size: nil)
|
|
791
|
+
pointers = Array.new(PRICE_FIELDS.size)
|
|
792
|
+
price_indexes(flags).zip(price_data) { |slot, series| pointers[slot] = prepare_double_array(series, size: size) }
|
|
793
|
+
bind_input(params_ptr, index, pointers) { |prices| TA_SetInputParamPricePtr(params_ptr, index, *prices) }
|
|
787
794
|
end
|
|
788
795
|
|
|
789
796
|
initialize_ta_lib
|
|
790
797
|
generate_ta_functions
|
|
791
798
|
|
|
792
799
|
# Placeholder for generated TA-Lib function documentation.
|
|
793
|
-
#
|
|
800
|
+
# Available functions and their defaults depend on the installed C library.
|
|
794
801
|
# Run: rake yard
|
|
795
802
|
class << self
|
|
796
803
|
### GENERATED DOCUMENTATION START ###
|
|
804
|
+
# @!method ac(price_hl, fast_period: 5.0, slow_period: 34.0, signal_period: 5.0)
|
|
805
|
+
# Accelerator/Decelerator Oscillator
|
|
806
|
+
#
|
|
807
|
+
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
808
|
+
# @param fast_period [Integer] Period of the fast MA (default: 5.0)
|
|
809
|
+
# @param slow_period [Integer] Period of the slow MA (default: 34.0)
|
|
810
|
+
# @param signal_period [Integer] Smoothing for the signal line (period length) (default: 5.0)
|
|
811
|
+
# @return [Array<Float>]
|
|
812
|
+
# @raise [TALibError] If there is an error in function execution
|
|
813
|
+
|
|
797
814
|
# @!method accbands(price_hlc, time_period: 20.0)
|
|
798
815
|
# Acceleration Bands
|
|
799
816
|
#
|
|
800
817
|
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
801
|
-
# @param time_period [Integer]
|
|
818
|
+
# @param time_period [Integer] Time period (default: 20.0)
|
|
802
819
|
# @return [Hash] Hash containing the following arrays:
|
|
803
820
|
# @option result [Array<Float>] :upper_band Output values
|
|
804
821
|
# @option result [Array<Float>] :middle_band Output values
|
|
@@ -831,8 +848,16 @@ module TALibFFI
|
|
|
831
848
|
# Chaikin A/D Oscillator
|
|
832
849
|
#
|
|
833
850
|
# @param price_hlcv [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close, volume
|
|
834
|
-
# @param fast_period [Integer]
|
|
835
|
-
# @param slow_period [Integer]
|
|
851
|
+
# @param fast_period [Integer] Period of the fast MA (default: 3.0)
|
|
852
|
+
# @param slow_period [Integer] Period of the slow MA (default: 10.0)
|
|
853
|
+
# @return [Array<Float>]
|
|
854
|
+
# @raise [TALibError] If there is an error in function execution
|
|
855
|
+
|
|
856
|
+
# @!method adr(price_hl, time_period: 14.0)
|
|
857
|
+
# Average Day Range
|
|
858
|
+
#
|
|
859
|
+
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
860
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
836
861
|
# @return [Array<Float>]
|
|
837
862
|
# @raise [TALibError] If there is an error in function execution
|
|
838
863
|
|
|
@@ -840,7 +865,7 @@ module TALibFFI
|
|
|
840
865
|
# Average Directional Movement Index
|
|
841
866
|
#
|
|
842
867
|
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
843
|
-
# @param time_period [Integer]
|
|
868
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
844
869
|
# @return [Array<Float>]
|
|
845
870
|
# @raise [TALibError] If there is an error in function execution
|
|
846
871
|
|
|
@@ -848,17 +873,36 @@ module TALibFFI
|
|
|
848
873
|
# Average Directional Movement Index Rating
|
|
849
874
|
#
|
|
850
875
|
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
851
|
-
# @param time_period [Integer]
|
|
876
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
852
877
|
# @return [Array<Float>]
|
|
853
878
|
# @raise [TALibError] If there is an error in function execution
|
|
854
879
|
|
|
855
|
-
# @!method
|
|
880
|
+
# @!method alma(real, time_period: 9.0, sigma: 6.0, offset: 0.85)
|
|
881
|
+
# Arnaud Legoux Moving Average
|
|
882
|
+
#
|
|
883
|
+
# @param real [Array<Float>] Input values
|
|
884
|
+
# @param time_period [Integer] Time period (default: 9.0)
|
|
885
|
+
# @param sigma [Float] Gaussian width divisor (default: 6.0)
|
|
886
|
+
# @param offset [Float] Position of the peak weight (default: 0.85)
|
|
887
|
+
# @return [Array<Float>]
|
|
888
|
+
# @raise [TALibError] If there is an error in function execution
|
|
889
|
+
|
|
890
|
+
# @!method ao(price_hl, fast_period: 5.0, slow_period: 34.0)
|
|
891
|
+
# Awesome Oscillator
|
|
892
|
+
#
|
|
893
|
+
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
894
|
+
# @param fast_period [Integer] Period of the fast MA (default: 5.0)
|
|
895
|
+
# @param slow_period [Integer] Period of the slow MA (default: 34.0)
|
|
896
|
+
# @return [Array<Float>]
|
|
897
|
+
# @raise [TALibError] If there is an error in function execution
|
|
898
|
+
|
|
899
|
+
# @!method apo(real, fast_period: 12.0, slow_period: 26.0, ma_type: 1.0)
|
|
856
900
|
# Absolute Price Oscillator
|
|
857
901
|
#
|
|
858
902
|
# @param real [Array<Float>] Input values
|
|
859
|
-
# @param fast_period [Integer]
|
|
860
|
-
# @param slow_period [Integer]
|
|
861
|
-
# @param ma_type [Integer] Type of Moving Average (default:
|
|
903
|
+
# @param fast_period [Integer] Period of the fast MA (default: 12.0)
|
|
904
|
+
# @param slow_period [Integer] Period of the slow MA (default: 26.0)
|
|
905
|
+
# @param ma_type [Integer] Type of Moving Average (default: 1.0)
|
|
862
906
|
# @return [Array<Float>]
|
|
863
907
|
# @raise [TALibError] If there is an error in function execution
|
|
864
908
|
|
|
@@ -866,7 +910,7 @@ module TALibFFI
|
|
|
866
910
|
# Aroon
|
|
867
911
|
#
|
|
868
912
|
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
869
|
-
# @param time_period [Integer]
|
|
913
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
870
914
|
# @return [Hash] Hash containing the following arrays:
|
|
871
915
|
# @option result [Array<Float>] :aroon_down Output values
|
|
872
916
|
# @option result [Array<Float>] :aroon_up Output values
|
|
@@ -876,7 +920,15 @@ module TALibFFI
|
|
|
876
920
|
# Aroon Oscillator
|
|
877
921
|
#
|
|
878
922
|
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
879
|
-
# @param time_period [Integer]
|
|
923
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
924
|
+
# @return [Array<Float>]
|
|
925
|
+
# @raise [TALibError] If there is an error in function execution
|
|
926
|
+
|
|
927
|
+
# @!method asi(price_ohlc, limit_move: 3.0)
|
|
928
|
+
# Wilder Accumulative Swing Index
|
|
929
|
+
#
|
|
930
|
+
# @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
|
|
931
|
+
# @param limit_move [Float] Largest one-bar price move the index is scaled against, in price units (default: 3.0)
|
|
880
932
|
# @return [Array<Float>]
|
|
881
933
|
# @raise [TALibError] If there is an error in function execution
|
|
882
934
|
|
|
@@ -898,30 +950,30 @@ module TALibFFI
|
|
|
898
950
|
# Average True Range
|
|
899
951
|
#
|
|
900
952
|
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
901
|
-
# @param time_period [Integer]
|
|
953
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
902
954
|
# @return [Array<Float>]
|
|
903
955
|
# @raise [TALibError] If there is an error in function execution
|
|
904
956
|
|
|
905
|
-
# @!method
|
|
906
|
-
# Average
|
|
957
|
+
# @!method avgdev(real, time_period: 14.0)
|
|
958
|
+
# Average Deviation
|
|
907
959
|
#
|
|
908
|
-
# @param
|
|
960
|
+
# @param real [Array<Float>] Input values
|
|
961
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
909
962
|
# @return [Array<Float>]
|
|
910
963
|
# @raise [TALibError] If there is an error in function execution
|
|
911
964
|
|
|
912
|
-
# @!method
|
|
913
|
-
# Average
|
|
965
|
+
# @!method avgprice(price_ohlc)
|
|
966
|
+
# Average Price
|
|
914
967
|
#
|
|
915
|
-
# @param
|
|
916
|
-
# @param time_period [Integer] Number of period (default: 14.0)
|
|
968
|
+
# @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
|
|
917
969
|
# @return [Array<Float>]
|
|
918
970
|
# @raise [TALibError] If there is an error in function execution
|
|
919
971
|
|
|
920
|
-
# @!method bbands(real, time_period:
|
|
972
|
+
# @!method bbands(real, time_period: 20.0, nb_dev_up: 2.0, nb_dev_dn: 2.0, ma_type: 0.0)
|
|
921
973
|
# Bollinger Bands
|
|
922
974
|
#
|
|
923
975
|
# @param real [Array<Float>] Input values
|
|
924
|
-
# @param time_period [Integer]
|
|
976
|
+
# @param time_period [Integer] Time period (default: 20.0)
|
|
925
977
|
# @param nb_dev_up [Float] Deviation multiplier for upper band (default: 2.0)
|
|
926
978
|
# @param nb_dev_dn [Float] Deviation multiplier for lower band (default: 2.0)
|
|
927
979
|
# @param ma_type [Integer] Type of Moving Average (default: 0.0)
|
|
@@ -931,12 +983,23 @@ module TALibFFI
|
|
|
931
983
|
# @option result [Array<Float>] :lower_band Output values
|
|
932
984
|
# @raise [TALibError] If there is an error in function execution
|
|
933
985
|
|
|
986
|
+
# @!method bbw(real, time_period: 20.0, nb_dev_up: 2.0, nb_dev_dn: 2.0, ma_type: 0.0)
|
|
987
|
+
# Bollinger BandWidth
|
|
988
|
+
#
|
|
989
|
+
# @param real [Array<Float>] Input values
|
|
990
|
+
# @param time_period [Integer] Time period (default: 20.0)
|
|
991
|
+
# @param nb_dev_up [Float] Deviation multiplier for upper band (default: 2.0)
|
|
992
|
+
# @param nb_dev_dn [Float] Deviation multiplier for lower band (default: 2.0)
|
|
993
|
+
# @param ma_type [Integer] Type of Moving Average (default: 0.0)
|
|
994
|
+
# @return [Array<Float>]
|
|
995
|
+
# @raise [TALibError] If there is an error in function execution
|
|
996
|
+
|
|
934
997
|
# @!method beta(real0, real1, time_period: 5.0)
|
|
935
998
|
# Beta
|
|
936
999
|
#
|
|
937
1000
|
# @param real0 [Array<Float>] Input values
|
|
938
1001
|
# @param real1 [Array<Float>] Input values
|
|
939
|
-
# @param time_period [Integer]
|
|
1002
|
+
# @param time_period [Integer] Time period (default: 5.0)
|
|
940
1003
|
# @return [Array<Float>]
|
|
941
1004
|
# @raise [TALibError] If there is an error in function execution
|
|
942
1005
|
|
|
@@ -951,7 +1014,7 @@ module TALibFFI
|
|
|
951
1014
|
# Commodity Channel Index
|
|
952
1015
|
#
|
|
953
1016
|
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
954
|
-
# @param time_period [Integer]
|
|
1017
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
955
1018
|
# @return [Array<Float>]
|
|
956
1019
|
# @raise [TALibError] If there is an error in function execution
|
|
957
1020
|
|
|
@@ -1396,11 +1459,73 @@ module TALibFFI
|
|
|
1396
1459
|
# @return [Array<Float>]
|
|
1397
1460
|
# @raise [TALibError] If there is an error in function execution
|
|
1398
1461
|
|
|
1462
|
+
# @!method cg(real, time_period: 10.0)
|
|
1463
|
+
# Center of Gravity Oscillator
|
|
1464
|
+
#
|
|
1465
|
+
# @param real [Array<Float>] Input values
|
|
1466
|
+
# @param time_period [Integer] Number of bars in the window (default: 10.0)
|
|
1467
|
+
# @return [Array<Float>]
|
|
1468
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1469
|
+
|
|
1470
|
+
# @!method chop(price_hlc, time_period: 14.0)
|
|
1471
|
+
# Choppiness Index
|
|
1472
|
+
#
|
|
1473
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
1474
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1475
|
+
# @return [Array<Float>]
|
|
1476
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1477
|
+
|
|
1478
|
+
# @!method choptr(price_hlc, time_period: 14.0)
|
|
1479
|
+
# Choppiness Index (True Range Box)
|
|
1480
|
+
#
|
|
1481
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
1482
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1483
|
+
# @return [Array<Float>]
|
|
1484
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1485
|
+
|
|
1486
|
+
# @!method cksp(price_hlc, time_period: 10.0, multiplier: 1.0, stop_period: 9.0)
|
|
1487
|
+
# Chande Kroll Stop
|
|
1488
|
+
#
|
|
1489
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
1490
|
+
# @param time_period [Integer] ATR and extreme window (default: 10.0)
|
|
1491
|
+
# @param multiplier [Float] ATR multiplier (default: 1.0)
|
|
1492
|
+
# @param stop_period [Integer] Stop window (default: 9.0)
|
|
1493
|
+
# @return [Hash] Hash containing the following arrays:
|
|
1494
|
+
# @option result [Array<Float>] :high_stop Output values
|
|
1495
|
+
# @option result [Array<Float>] :low_stop Output values
|
|
1496
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1497
|
+
|
|
1498
|
+
# @!method cmf(price_hlcv, time_period: 20.0)
|
|
1499
|
+
# Chaikin Money Flow
|
|
1500
|
+
#
|
|
1501
|
+
# @param price_hlcv [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close, volume
|
|
1502
|
+
# @param time_period [Integer] Time period (default: 20.0)
|
|
1503
|
+
# @return [Array<Float>]
|
|
1504
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1505
|
+
|
|
1399
1506
|
# @!method cmo(real, time_period: 14.0)
|
|
1400
1507
|
# Chande Momentum Oscillator
|
|
1401
1508
|
#
|
|
1402
1509
|
# @param real [Array<Float>] Input values
|
|
1403
|
-
# @param time_period [Integer]
|
|
1510
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1511
|
+
# @return [Array<Float>]
|
|
1512
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1513
|
+
|
|
1514
|
+
# @!method cmou(real, time_period: 14.0)
|
|
1515
|
+
# Chande Momentum Oscillator (Unsmoothed)
|
|
1516
|
+
#
|
|
1517
|
+
# @param real [Array<Float>] Input values
|
|
1518
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1519
|
+
# @return [Array<Float>]
|
|
1520
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1521
|
+
|
|
1522
|
+
# @!method coppock(real, wma_period: 10.0, roc1_period: 11.0, roc2_period: 14.0)
|
|
1523
|
+
# Coppock Curve
|
|
1524
|
+
#
|
|
1525
|
+
# @param real [Array<Float>] Input values
|
|
1526
|
+
# @param wma_period [Integer] Smoothing period for the ROC sum (default: 10.0)
|
|
1527
|
+
# @param roc1_period [Integer] Short rate-of-change period (default: 11.0)
|
|
1528
|
+
# @param roc2_period [Integer] Long rate-of-change period (default: 14.0)
|
|
1404
1529
|
# @return [Array<Float>]
|
|
1405
1530
|
# @raise [TALibError] If there is an error in function execution
|
|
1406
1531
|
|
|
@@ -1409,7 +1534,7 @@ module TALibFFI
|
|
|
1409
1534
|
#
|
|
1410
1535
|
# @param real0 [Array<Float>] Input values
|
|
1411
1536
|
# @param real1 [Array<Float>] Input values
|
|
1412
|
-
# @param time_period [Integer]
|
|
1537
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1413
1538
|
# @return [Array<Float>]
|
|
1414
1539
|
# @raise [TALibError] If there is an error in function execution
|
|
1415
1540
|
|
|
@@ -1427,11 +1552,45 @@ module TALibFFI
|
|
|
1427
1552
|
# @return [Array<Float>]
|
|
1428
1553
|
# @raise [TALibError] If there is an error in function execution
|
|
1429
1554
|
|
|
1555
|
+
# @!method crsi(real, time_period: 3.0, streak_period: 2.0, rank_period: 100.0)
|
|
1556
|
+
# Connors Relative Strength Index
|
|
1557
|
+
#
|
|
1558
|
+
# @param real [Array<Float>] Input values
|
|
1559
|
+
# @param time_period [Integer] Time period (default: 3.0)
|
|
1560
|
+
# @param streak_period [Integer] Time period of the RSI of the up/down streak (default: 2.0)
|
|
1561
|
+
# @param rank_period [Integer] Number of previous one-bar returns the current one is ranked against (default: 100.0)
|
|
1562
|
+
# @return [Array<Float>]
|
|
1563
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1564
|
+
|
|
1565
|
+
# @!method cti(real, time_period: 20.0)
|
|
1566
|
+
# Correlation Trend Indicator
|
|
1567
|
+
#
|
|
1568
|
+
# @param real [Array<Float>] Input values
|
|
1569
|
+
# @param time_period [Integer] Number of bars correlated against the ramp (default: 20.0)
|
|
1570
|
+
# @return [Array<Float>]
|
|
1571
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1572
|
+
|
|
1573
|
+
# @!method cumsum(real)
|
|
1574
|
+
# Cumulative Sum
|
|
1575
|
+
#
|
|
1576
|
+
# @param real [Array<Float>] Input values
|
|
1577
|
+
# @return [Array<Float>]
|
|
1578
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1579
|
+
|
|
1580
|
+
# @!method cvi(price_hl, time_period: 10.0, roc_period: 10.0)
|
|
1581
|
+
# Chaikin's Volatility
|
|
1582
|
+
#
|
|
1583
|
+
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
1584
|
+
# @param time_period [Integer] Period of the EMA smoothing the high-low spread (default: 10.0)
|
|
1585
|
+
# @param roc_period [Integer] Number of bars the rate of change reaches back (default: 10.0)
|
|
1586
|
+
# @return [Array<Float>]
|
|
1587
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1588
|
+
|
|
1430
1589
|
# @!method dema(real, time_period: 30.0)
|
|
1431
1590
|
# Double Exponential Moving Average
|
|
1432
1591
|
#
|
|
1433
1592
|
# @param real [Array<Float>] Input values
|
|
1434
|
-
# @param time_period [Integer]
|
|
1593
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1435
1594
|
# @return [Array<Float>]
|
|
1436
1595
|
# @raise [TALibError] If there is an error in function execution
|
|
1437
1596
|
|
|
@@ -1443,11 +1602,49 @@ module TALibFFI
|
|
|
1443
1602
|
# @return [Array<Float>]
|
|
1444
1603
|
# @raise [TALibError] If there is an error in function execution
|
|
1445
1604
|
|
|
1605
|
+
# @!method donchian(price_hl, time_period: 20.0)
|
|
1606
|
+
# Donchian Channels
|
|
1607
|
+
#
|
|
1608
|
+
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
1609
|
+
# @param time_period [Integer] Time period (default: 20.0)
|
|
1610
|
+
# @return [Hash] Hash containing the following arrays:
|
|
1611
|
+
# @option result [Array<Float>] :upper_band Output values
|
|
1612
|
+
# @option result [Array<Float>] :middle_band Output values
|
|
1613
|
+
# @option result [Array<Float>] :lower_band Output values
|
|
1614
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1615
|
+
|
|
1616
|
+
# @!method dosc(real, time_period: 14.0, first_period: 5.0, second_period: 3.0, signal_period: 9.0)
|
|
1617
|
+
# Derivative Oscillator
|
|
1618
|
+
#
|
|
1619
|
+
# @param real [Array<Float>] Input values
|
|
1620
|
+
# @param time_period [Integer] Period of the RSI (default: 14.0)
|
|
1621
|
+
# @param first_period [Integer] Period of the first smoothing, applied to the RSI (default: 5.0)
|
|
1622
|
+
# @param second_period [Integer] Period of the second smoothing, applied to the first (default: 3.0)
|
|
1623
|
+
# @param signal_period [Integer] Period of the simple average subtracted from the smoothed line (default: 9.0)
|
|
1624
|
+
# @return [Array<Float>]
|
|
1625
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1626
|
+
|
|
1627
|
+
# @!method dpo(real, time_period: 20.0)
|
|
1628
|
+
# Detrended Price Oscillator
|
|
1629
|
+
#
|
|
1630
|
+
# @param real [Array<Float>] Input values
|
|
1631
|
+
# @param time_period [Integer] Time period (default: 20.0)
|
|
1632
|
+
# @return [Array<Float>]
|
|
1633
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1634
|
+
|
|
1446
1635
|
# @!method dx(price_hlc, time_period: 14.0)
|
|
1447
1636
|
# Directional Movement Index
|
|
1448
1637
|
#
|
|
1449
1638
|
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
1450
|
-
# @param time_period [Integer]
|
|
1639
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1640
|
+
# @return [Array<Float>]
|
|
1641
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1642
|
+
|
|
1643
|
+
# @!method efi(price_cv, time_period: 13.0)
|
|
1644
|
+
# Elder's Force Index
|
|
1645
|
+
#
|
|
1646
|
+
# @param price_cv [Array(Array<Float>, Array<Float>)] Required price arrays: close, volume
|
|
1647
|
+
# @param time_period [Integer] Time period (default: 13.0)
|
|
1451
1648
|
# @return [Array<Float>]
|
|
1452
1649
|
# @raise [TALibError] If there is an error in function execution
|
|
1453
1650
|
|
|
@@ -1455,10 +1652,37 @@ module TALibFFI
|
|
|
1455
1652
|
# Exponential Moving Average
|
|
1456
1653
|
#
|
|
1457
1654
|
# @param real [Array<Float>] Input values
|
|
1458
|
-
# @param time_period [Integer]
|
|
1655
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1459
1656
|
# @return [Array<Float>]
|
|
1460
1657
|
# @raise [TALibError] If there is an error in function execution
|
|
1461
1658
|
|
|
1659
|
+
# @!method emv(price_hlv, time_period: 14.0, volume_divisor: 10000.0)
|
|
1660
|
+
# Arms Ease of Movement
|
|
1661
|
+
#
|
|
1662
|
+
# @param price_hlv [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, volume
|
|
1663
|
+
# @param time_period [Integer] Bars in the SMA of the one-bar values (1 = unsmoothed) (default: 14.0)
|
|
1664
|
+
# @param volume_divisor [Float] Volume is divided by this before forming the box ratio (default: 10000.0)
|
|
1665
|
+
# @return [Array<Float>]
|
|
1666
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1667
|
+
|
|
1668
|
+
# @!method er(real, time_period: 10.0)
|
|
1669
|
+
# Kaufman Efficiency Ratio
|
|
1670
|
+
#
|
|
1671
|
+
# @param real [Array<Float>] Input values
|
|
1672
|
+
# @param time_period [Integer] Number of one-bar changes in the path sum (default: 10.0)
|
|
1673
|
+
# @return [Array<Float>]
|
|
1674
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1675
|
+
|
|
1676
|
+
# @!method eri(price_hlc, time_period: 13.0)
|
|
1677
|
+
# Elder Ray Index (Bull Power / Bear Power)
|
|
1678
|
+
#
|
|
1679
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
1680
|
+
# @param time_period [Integer] Number of bars in the EMA of close (default: 13.0)
|
|
1681
|
+
# @return [Hash] Hash containing the following arrays:
|
|
1682
|
+
# @option result [Array<Float>] :bull_power Output values
|
|
1683
|
+
# @option result [Array<Float>] :bear_power Output values
|
|
1684
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1685
|
+
|
|
1462
1686
|
# @!method exp(real)
|
|
1463
1687
|
# Vector Arithmetic Exp
|
|
1464
1688
|
#
|
|
@@ -1466,6 +1690,16 @@ module TALibFFI
|
|
|
1466
1690
|
# @return [Array<Float>]
|
|
1467
1691
|
# @raise [TALibError] If there is an error in function execution
|
|
1468
1692
|
|
|
1693
|
+
# @!method fisher(price_hl, time_period: 10.0)
|
|
1694
|
+
# Fisher Transform
|
|
1695
|
+
#
|
|
1696
|
+
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
1697
|
+
# @param time_period [Integer] Time period (default: 10.0)
|
|
1698
|
+
# @return [Hash] Hash containing the following arrays:
|
|
1699
|
+
# @option result [Array<Float>] :fisher Output values
|
|
1700
|
+
# @option result [Array<Float>] :trigger Output values
|
|
1701
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1702
|
+
|
|
1469
1703
|
# @!method floor(real)
|
|
1470
1704
|
# Vector Floor
|
|
1471
1705
|
#
|
|
@@ -1473,6 +1707,52 @@ module TALibFFI
|
|
|
1473
1707
|
# @return [Array<Float>]
|
|
1474
1708
|
# @raise [TALibError] If there is an error in function execution
|
|
1475
1709
|
|
|
1710
|
+
# @!method fosc(real, time_period: 5.0)
|
|
1711
|
+
# Forecast Oscillator
|
|
1712
|
+
#
|
|
1713
|
+
# @param real [Array<Float>] Input values
|
|
1714
|
+
# @param time_period [Integer] Time period (default: 5.0)
|
|
1715
|
+
# @return [Array<Float>]
|
|
1716
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1717
|
+
|
|
1718
|
+
# @!method fractal(price_hl, left_bars: 2.0, right_bars: 2.0)
|
|
1719
|
+
# Williams Fractal
|
|
1720
|
+
#
|
|
1721
|
+
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
1722
|
+
# @param left_bars [Integer] Number of bars required to be lower/higher before the pivot (default: 2.0)
|
|
1723
|
+
# @param right_bars [Integer] Number of bars required to be lower/higher after the pivot (default: 2.0)
|
|
1724
|
+
# @return [Hash] Hash containing the following arrays:
|
|
1725
|
+
# @option result [Array<Integer>] :swing_high Output values
|
|
1726
|
+
# @option result [Array<Integer>] :swing_low Output values
|
|
1727
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1728
|
+
|
|
1729
|
+
# @!method frama(price_hl, time_period: 16.0)
|
|
1730
|
+
# Fractal Adaptive Moving Average
|
|
1731
|
+
#
|
|
1732
|
+
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
1733
|
+
# @param time_period [Integer] Number of bars, even; the window is split into two halves of optInTimePeriod/2 bars (default: 16.0)
|
|
1734
|
+
# @return [Array<Float>]
|
|
1735
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1736
|
+
|
|
1737
|
+
# @!method ha(price_ohlc)
|
|
1738
|
+
# Heikin-Ashi Candles
|
|
1739
|
+
#
|
|
1740
|
+
# @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
|
|
1741
|
+
# @return [Hash] Hash containing the following arrays:
|
|
1742
|
+
# @option result [Array<Float>] :ha_open Output values
|
|
1743
|
+
# @option result [Array<Float>] :ha_high Output values
|
|
1744
|
+
# @option result [Array<Float>] :ha_low Output values
|
|
1745
|
+
# @option result [Array<Float>] :ha_close Output values
|
|
1746
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1747
|
+
|
|
1748
|
+
# @!method hma(real, time_period: 20.0)
|
|
1749
|
+
# Hull Moving Average
|
|
1750
|
+
#
|
|
1751
|
+
# @param real [Array<Float>] Input values
|
|
1752
|
+
# @param time_period [Integer] Time period (default: 20.0)
|
|
1753
|
+
# @return [Array<Float>]
|
|
1754
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1755
|
+
|
|
1476
1756
|
# @!method ht_dcperiod(real)
|
|
1477
1757
|
# Hilbert Transform - Dominant Cycle Period
|
|
1478
1758
|
#
|
|
@@ -1519,11 +1799,32 @@ module TALibFFI
|
|
|
1519
1799
|
# @return [Array<Integer>]
|
|
1520
1800
|
# @raise [TALibError] If there is an error in function execution
|
|
1521
1801
|
|
|
1802
|
+
# @!method ibs(price_hlc)
|
|
1803
|
+
# Internal Bar Strength
|
|
1804
|
+
#
|
|
1805
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
1806
|
+
# @return [Array<Float>]
|
|
1807
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1808
|
+
|
|
1809
|
+
# @!method ichimoku(price_hl, tenkan_period: 9.0, kijun_period: 26.0, senkou_b_period: 52.0)
|
|
1810
|
+
# Ichimoku Kinko Hyo
|
|
1811
|
+
#
|
|
1812
|
+
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
1813
|
+
# @param tenkan_period [Integer] Period of the conversion line (default: 9.0)
|
|
1814
|
+
# @param kijun_period [Integer] Period of the base line, and the forward shift of the two spans (default: 26.0)
|
|
1815
|
+
# @param senkou_b_period [Integer] Period of the second leading span (default: 52.0)
|
|
1816
|
+
# @return [Hash] Hash containing the following arrays:
|
|
1817
|
+
# @option result [Array<Float>] :tenkan_sen Output values
|
|
1818
|
+
# @option result [Array<Float>] :kijun_sen Output values
|
|
1819
|
+
# @option result [Array<Float>] :senkou_span_a Output values
|
|
1820
|
+
# @option result [Array<Float>] :senkou_span_b Output values
|
|
1821
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1822
|
+
|
|
1522
1823
|
# @!method imi(price_oc, time_period: 14.0)
|
|
1523
1824
|
# Intraday Momentum Index
|
|
1524
1825
|
#
|
|
1525
1826
|
# @param price_oc [Array(Array<Float>, Array<Float>)] Required price arrays: open, close
|
|
1526
|
-
# @param time_period [Integer]
|
|
1827
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1527
1828
|
# @return [Array<Float>]
|
|
1528
1829
|
# @raise [TALibError] If there is an error in function execution
|
|
1529
1830
|
|
|
@@ -1531,15 +1832,101 @@ module TALibFFI
|
|
|
1531
1832
|
# Kaufman Adaptive Moving Average
|
|
1532
1833
|
#
|
|
1533
1834
|
# @param real [Array<Float>] Input values
|
|
1534
|
-
# @param time_period [Integer]
|
|
1835
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1836
|
+
# @return [Array<Float>]
|
|
1837
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1838
|
+
|
|
1839
|
+
# @!method kc(price_hlc, time_period: 20.0, atr_period: 10.0, nb_dev: 2.0)
|
|
1840
|
+
# Keltner Channels
|
|
1841
|
+
#
|
|
1842
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
1843
|
+
# @param time_period [Integer] Time period for the typical price moving average (default: 20.0)
|
|
1844
|
+
# @param atr_period [Integer] Time period for the Average True Range (default: 10.0)
|
|
1845
|
+
# @param nb_dev [Float] Multiplier applied to the Average True Range (default: 2.0)
|
|
1846
|
+
# @return [Hash] Hash containing the following arrays:
|
|
1847
|
+
# @option result [Array<Float>] :upper_band Output values
|
|
1848
|
+
# @option result [Array<Float>] :middle_band Output values
|
|
1849
|
+
# @option result [Array<Float>] :lower_band Output values
|
|
1850
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1851
|
+
|
|
1852
|
+
# @!method kdj(price_hlc, fast_k_period: 9.0, slow_k_period: 3.0, slow_k_ma_type: 13.0, slow_d_period: 3.0, slow_d_ma_type: 13.0)
|
|
1853
|
+
# KDJ Stochastic
|
|
1854
|
+
#
|
|
1855
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
1856
|
+
# @param fast_k_period [Integer] Time period for building the Fast-K line (default: 9.0)
|
|
1857
|
+
# @param slow_k_period [Integer] Smoothing for making the Slow-K line. Usually set to 3 (default: 3.0)
|
|
1858
|
+
# @param slow_k_ma_type [Integer] Type of Moving Average for Slow-K (default: 13.0)
|
|
1859
|
+
# @param slow_d_period [Integer] Smoothing for making the Slow-D line (default: 3.0)
|
|
1860
|
+
# @param slow_d_ma_type [Integer] Type of Moving Average for Slow-D (default: 13.0)
|
|
1861
|
+
# @return [Hash] Hash containing the following arrays:
|
|
1862
|
+
# @option result [Array<Float>] :k Output values
|
|
1863
|
+
# @option result [Array<Float>] :d Output values
|
|
1864
|
+
# @option result [Array<Float>] :j Output values
|
|
1865
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1866
|
+
|
|
1867
|
+
# @!method kst(real, roc1_period: 10.0, roc2_period: 15.0, roc3_period: 20.0, roc4_period: 30.0, sma1_period: 10.0, sma2_period: 10.0, sma3_period: 10.0, sma4_period: 15.0, signal_period: 9.0)
|
|
1868
|
+
# Know Sure Thing (Pring)
|
|
1869
|
+
#
|
|
1870
|
+
# @param real [Array<Float>] Input values
|
|
1871
|
+
# @param roc1_period [Integer] Rate-of-change period of leg 1 (default: 10.0)
|
|
1872
|
+
# @param roc2_period [Integer] Rate-of-change period of leg 2 (default: 15.0)
|
|
1873
|
+
# @param roc3_period [Integer] Rate-of-change period of leg 3 (default: 20.0)
|
|
1874
|
+
# @param roc4_period [Integer] Rate-of-change period of leg 4 (default: 30.0)
|
|
1875
|
+
# @param sma1_period [Integer] Smoothing period of leg 1 (default: 10.0)
|
|
1876
|
+
# @param sma2_period [Integer] Smoothing period of leg 2 (default: 10.0)
|
|
1877
|
+
# @param sma3_period [Integer] Smoothing period of leg 3 (default: 10.0)
|
|
1878
|
+
# @param sma4_period [Integer] Smoothing period of leg 4 (default: 15.0)
|
|
1879
|
+
# @param signal_period [Integer] Smoothing period of the signal line (default: 9.0)
|
|
1880
|
+
# @return [Hash] Hash containing the following arrays:
|
|
1881
|
+
# @option result [Array<Float>] :kst Output values
|
|
1882
|
+
# @option result [Array<Float>] :kst_signal Output values
|
|
1883
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1884
|
+
|
|
1885
|
+
# @!method kstext(real, roc1_period: 10.0, roc2_period: 15.0, roc3_period: 20.0, roc4_period: 30.0, ma1_period: 10.0, ma2_period: 10.0, ma3_period: 10.0, ma4_period: 15.0, signal_period: 9.0, rocma_type: 0.0, signal_ma_type: 0.0)
|
|
1886
|
+
# Know Sure Thing with controllable MA type
|
|
1887
|
+
#
|
|
1888
|
+
# @param real [Array<Float>] Input values
|
|
1889
|
+
# @param roc1_period [Integer] Rate-of-change period of leg 1 (default: 10.0)
|
|
1890
|
+
# @param roc2_period [Integer] Rate-of-change period of leg 2 (default: 15.0)
|
|
1891
|
+
# @param roc3_period [Integer] Rate-of-change period of leg 3 (default: 20.0)
|
|
1892
|
+
# @param roc4_period [Integer] Rate-of-change period of leg 4 (default: 30.0)
|
|
1893
|
+
# @param ma1_period [Integer] Smoothing period of leg 1 (default: 10.0)
|
|
1894
|
+
# @param ma2_period [Integer] Smoothing period of leg 2 (default: 10.0)
|
|
1895
|
+
# @param ma3_period [Integer] Smoothing period of leg 3 (default: 10.0)
|
|
1896
|
+
# @param ma4_period [Integer] Smoothing period of leg 4 (default: 15.0)
|
|
1897
|
+
# @param signal_period [Integer] Smoothing period of the signal line (default: 9.0)
|
|
1898
|
+
# @param rocma_type [Integer] Type of Moving Average smoothing the four legs (default: 0.0)
|
|
1899
|
+
# @param signal_ma_type [Integer] Type of Moving Average for signal line (default: 0.0)
|
|
1900
|
+
# @return [Hash] Hash containing the following arrays:
|
|
1901
|
+
# @option result [Array<Float>] :kst Output values
|
|
1902
|
+
# @option result [Array<Float>] :kst_signal Output values
|
|
1903
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1904
|
+
|
|
1905
|
+
# @!method kurtosis(real, time_period: 30.0)
|
|
1906
|
+
# Rolling Excess Kurtosis
|
|
1907
|
+
#
|
|
1908
|
+
# @param real [Array<Float>] Input values
|
|
1909
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1535
1910
|
# @return [Array<Float>]
|
|
1536
1911
|
# @raise [TALibError] If there is an error in function execution
|
|
1537
1912
|
|
|
1913
|
+
# @!method kvo(price_hlcv, fast_period: 34.0, slow_period: 55.0, signal_period: 13.0)
|
|
1914
|
+
# Klinger Volume Oscillator
|
|
1915
|
+
#
|
|
1916
|
+
# @param price_hlcv [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close, volume
|
|
1917
|
+
# @param fast_period [Integer] Period of the faster smoothing of the volume force (default: 34.0)
|
|
1918
|
+
# @param slow_period [Integer] Period of the slower smoothing of the volume force (default: 55.0)
|
|
1919
|
+
# @param signal_period [Integer] Smoothing for the trigger line (default: 13.0)
|
|
1920
|
+
# @return [Hash] Hash containing the following arrays:
|
|
1921
|
+
# @option result [Array<Float>] :kvo Output values
|
|
1922
|
+
# @option result [Array<Float>] :kvo_signal Output values
|
|
1923
|
+
# @raise [TALibError] If there is an error in function execution
|
|
1924
|
+
|
|
1538
1925
|
# @!method linearreg(real, time_period: 14.0)
|
|
1539
1926
|
# Linear Regression
|
|
1540
1927
|
#
|
|
1541
1928
|
# @param real [Array<Float>] Input values
|
|
1542
|
-
# @param time_period [Integer]
|
|
1929
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1543
1930
|
# @return [Array<Float>]
|
|
1544
1931
|
# @raise [TALibError] If there is an error in function execution
|
|
1545
1932
|
|
|
@@ -1547,7 +1934,7 @@ module TALibFFI
|
|
|
1547
1934
|
# Linear Regression Angle
|
|
1548
1935
|
#
|
|
1549
1936
|
# @param real [Array<Float>] Input values
|
|
1550
|
-
# @param time_period [Integer]
|
|
1937
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1551
1938
|
# @return [Array<Float>]
|
|
1552
1939
|
# @raise [TALibError] If there is an error in function execution
|
|
1553
1940
|
|
|
@@ -1555,7 +1942,7 @@ module TALibFFI
|
|
|
1555
1942
|
# Linear Regression Intercept
|
|
1556
1943
|
#
|
|
1557
1944
|
# @param real [Array<Float>] Input values
|
|
1558
|
-
# @param time_period [Integer]
|
|
1945
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1559
1946
|
# @return [Array<Float>]
|
|
1560
1947
|
# @raise [TALibError] If there is an error in function execution
|
|
1561
1948
|
|
|
@@ -1563,7 +1950,7 @@ module TALibFFI
|
|
|
1563
1950
|
# Linear Regression Slope
|
|
1564
1951
|
#
|
|
1565
1952
|
# @param real [Array<Float>] Input values
|
|
1566
|
-
# @param time_period [Integer]
|
|
1953
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1567
1954
|
# @return [Array<Float>]
|
|
1568
1955
|
# @raise [TALibError] If there is an error in function execution
|
|
1569
1956
|
|
|
@@ -1585,7 +1972,7 @@ module TALibFFI
|
|
|
1585
1972
|
# Moving average
|
|
1586
1973
|
#
|
|
1587
1974
|
# @param real [Array<Float>] Input values
|
|
1588
|
-
# @param time_period [Integer]
|
|
1975
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1589
1976
|
# @param ma_type [Integer] Type of Moving Average (default: 0.0)
|
|
1590
1977
|
# @return [Array<Float>]
|
|
1591
1978
|
# @raise [TALibError] If there is an error in function execution
|
|
@@ -1594,9 +1981,9 @@ module TALibFFI
|
|
|
1594
1981
|
# Moving Average Convergence/Divergence
|
|
1595
1982
|
#
|
|
1596
1983
|
# @param real [Array<Float>] Input values
|
|
1597
|
-
# @param fast_period [Integer]
|
|
1598
|
-
# @param slow_period [Integer]
|
|
1599
|
-
# @param signal_period [Integer] Smoothing for the signal line (
|
|
1984
|
+
# @param fast_period [Integer] Period of the fast MA (default: 12.0)
|
|
1985
|
+
# @param slow_period [Integer] Period of the slow MA (default: 26.0)
|
|
1986
|
+
# @param signal_period [Integer] Smoothing for the signal line (period length) (default: 9.0)
|
|
1600
1987
|
# @return [Hash] Hash containing the following arrays:
|
|
1601
1988
|
# @option result [Array<Float>] :macd Output values
|
|
1602
1989
|
# @option result [Array<Float>] :macd_signal Output values
|
|
@@ -1607,11 +1994,11 @@ module TALibFFI
|
|
|
1607
1994
|
# MACD with controllable MA type
|
|
1608
1995
|
#
|
|
1609
1996
|
# @param real [Array<Float>] Input values
|
|
1610
|
-
# @param fast_period [Integer]
|
|
1997
|
+
# @param fast_period [Integer] Period of the fast MA (default: 12.0)
|
|
1611
1998
|
# @param fast_ma_type [Integer] Type of Moving Average for fast MA (default: 0.0)
|
|
1612
|
-
# @param slow_period [Integer]
|
|
1999
|
+
# @param slow_period [Integer] Period of the slow MA (default: 26.0)
|
|
1613
2000
|
# @param slow_ma_type [Integer] Type of Moving Average for slow MA (default: 0.0)
|
|
1614
|
-
# @param signal_period [Integer] Smoothing for the signal line (
|
|
2001
|
+
# @param signal_period [Integer] Smoothing for the signal line (period length) (default: 9.0)
|
|
1615
2002
|
# @param signal_ma_type [Integer] Type of Moving Average for signal line (default: 0.0)
|
|
1616
2003
|
# @return [Hash] Hash containing the following arrays:
|
|
1617
2004
|
# @option result [Array<Float>] :macd Output values
|
|
@@ -1623,7 +2010,7 @@ module TALibFFI
|
|
|
1623
2010
|
# Moving Average Convergence/Divergence Fix 12/26
|
|
1624
2011
|
#
|
|
1625
2012
|
# @param real [Array<Float>] Input values
|
|
1626
|
-
# @param signal_period [Integer] Smoothing for the signal line (
|
|
2013
|
+
# @param signal_period [Integer] Smoothing for the signal line (period length) (default: 9.0)
|
|
1627
2014
|
# @return [Hash] Hash containing the following arrays:
|
|
1628
2015
|
# @option result [Array<Float>] :macd Output values
|
|
1629
2016
|
# @option result [Array<Float>] :macd_signal Output values
|
|
@@ -1641,6 +2028,22 @@ module TALibFFI
|
|
|
1641
2028
|
# @option result [Array<Float>] :fama Output values
|
|
1642
2029
|
# @raise [TALibError] If there is an error in function execution
|
|
1643
2030
|
|
|
2031
|
+
# @!method marketfi(price_hlv)
|
|
2032
|
+
# Market Facilitation Index
|
|
2033
|
+
#
|
|
2034
|
+
# @param price_hlv [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, volume
|
|
2035
|
+
# @return [Array<Float>]
|
|
2036
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2037
|
+
|
|
2038
|
+
# @!method massi(price_hl, fast_period: 9.0, slow_period: 25.0)
|
|
2039
|
+
# Mass Index
|
|
2040
|
+
#
|
|
2041
|
+
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
2042
|
+
# @param fast_period [Integer] Period of both exponential averages of the high-low range (default: 9.0)
|
|
2043
|
+
# @param slow_period [Integer] Number of bars the ratio is summed over (default: 25.0)
|
|
2044
|
+
# @return [Array<Float>]
|
|
2045
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2046
|
+
|
|
1644
2047
|
# @!method mavp(real, periods, min_period: 2.0, max_period: 30.0, ma_type: 0.0)
|
|
1645
2048
|
# Moving average with variable period
|
|
1646
2049
|
#
|
|
@@ -1656,7 +2059,7 @@ module TALibFFI
|
|
|
1656
2059
|
# Highest value over a specified period
|
|
1657
2060
|
#
|
|
1658
2061
|
# @param real [Array<Float>] Input values
|
|
1659
|
-
# @param time_period [Integer]
|
|
2062
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1660
2063
|
# @return [Array<Float>]
|
|
1661
2064
|
# @raise [TALibError] If there is an error in function execution
|
|
1662
2065
|
|
|
@@ -1664,10 +2067,26 @@ module TALibFFI
|
|
|
1664
2067
|
# Index of highest value over a specified period
|
|
1665
2068
|
#
|
|
1666
2069
|
# @param real [Array<Float>] Input values
|
|
1667
|
-
# @param time_period [Integer]
|
|
2070
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1668
2071
|
# @return [Array<Integer>]
|
|
1669
2072
|
# @raise [TALibError] If there is an error in function execution
|
|
1670
2073
|
|
|
2074
|
+
# @!method mcgd(real, time_period: 14.0)
|
|
2075
|
+
# McGinley Dynamic
|
|
2076
|
+
#
|
|
2077
|
+
# @param real [Array<Float>] Input values
|
|
2078
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
2079
|
+
# @return [Array<Float>]
|
|
2080
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2081
|
+
|
|
2082
|
+
# @!method median(real, time_period: 30.0)
|
|
2083
|
+
# Rolling Median
|
|
2084
|
+
#
|
|
2085
|
+
# @param real [Array<Float>] Input values
|
|
2086
|
+
# @param time_period [Integer] Number of bars in the window (default: 30.0)
|
|
2087
|
+
# @return [Array<Float>]
|
|
2088
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2089
|
+
|
|
1671
2090
|
# @!method medprice(price_hl)
|
|
1672
2091
|
# Median Price
|
|
1673
2092
|
#
|
|
@@ -1679,7 +2098,7 @@ module TALibFFI
|
|
|
1679
2098
|
# Money Flow Index
|
|
1680
2099
|
#
|
|
1681
2100
|
# @param price_hlcv [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close, volume
|
|
1682
|
-
# @param time_period [Integer]
|
|
2101
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1683
2102
|
# @return [Array<Float>]
|
|
1684
2103
|
# @raise [TALibError] If there is an error in function execution
|
|
1685
2104
|
|
|
@@ -1687,7 +2106,7 @@ module TALibFFI
|
|
|
1687
2106
|
# MidPoint over period
|
|
1688
2107
|
#
|
|
1689
2108
|
# @param real [Array<Float>] Input values
|
|
1690
|
-
# @param time_period [Integer]
|
|
2109
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1691
2110
|
# @return [Array<Float>]
|
|
1692
2111
|
# @raise [TALibError] If there is an error in function execution
|
|
1693
2112
|
|
|
@@ -1695,7 +2114,7 @@ module TALibFFI
|
|
|
1695
2114
|
# Midpoint Price over period
|
|
1696
2115
|
#
|
|
1697
2116
|
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
1698
|
-
# @param time_period [Integer]
|
|
2117
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1699
2118
|
# @return [Array<Float>]
|
|
1700
2119
|
# @raise [TALibError] If there is an error in function execution
|
|
1701
2120
|
|
|
@@ -1703,7 +2122,7 @@ module TALibFFI
|
|
|
1703
2122
|
# Lowest value over a specified period
|
|
1704
2123
|
#
|
|
1705
2124
|
# @param real [Array<Float>] Input values
|
|
1706
|
-
# @param time_period [Integer]
|
|
2125
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1707
2126
|
# @return [Array<Float>]
|
|
1708
2127
|
# @raise [TALibError] If there is an error in function execution
|
|
1709
2128
|
|
|
@@ -1711,7 +2130,7 @@ module TALibFFI
|
|
|
1711
2130
|
# Index of lowest value over a specified period
|
|
1712
2131
|
#
|
|
1713
2132
|
# @param real [Array<Float>] Input values
|
|
1714
|
-
# @param time_period [Integer]
|
|
2133
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1715
2134
|
# @return [Array<Integer>]
|
|
1716
2135
|
# @raise [TALibError] If there is an error in function execution
|
|
1717
2136
|
|
|
@@ -1719,7 +2138,7 @@ module TALibFFI
|
|
|
1719
2138
|
# Lowest and highest values over a specified period
|
|
1720
2139
|
#
|
|
1721
2140
|
# @param real [Array<Float>] Input values
|
|
1722
|
-
# @param time_period [Integer]
|
|
2141
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1723
2142
|
# @return [Hash] Hash containing the following arrays:
|
|
1724
2143
|
# @option result [Array<Float>] :min Output values
|
|
1725
2144
|
# @option result [Array<Float>] :max Output values
|
|
@@ -1729,7 +2148,7 @@ module TALibFFI
|
|
|
1729
2148
|
# Indexes of lowest and highest values over a specified period
|
|
1730
2149
|
#
|
|
1731
2150
|
# @param real [Array<Float>] Input values
|
|
1732
|
-
# @param time_period [Integer]
|
|
2151
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1733
2152
|
# @return [Hash] Hash containing the following arrays:
|
|
1734
2153
|
# @option result [Array<Integer>] :min_idx Output values
|
|
1735
2154
|
# @option result [Array<Integer>] :max_idx Output values
|
|
@@ -1739,7 +2158,7 @@ module TALibFFI
|
|
|
1739
2158
|
# Minus Directional Indicator
|
|
1740
2159
|
#
|
|
1741
2160
|
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
1742
|
-
# @param time_period [Integer]
|
|
2161
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1743
2162
|
# @return [Array<Float>]
|
|
1744
2163
|
# @raise [TALibError] If there is an error in function execution
|
|
1745
2164
|
|
|
@@ -1747,7 +2166,7 @@ module TALibFFI
|
|
|
1747
2166
|
# Minus Directional Movement
|
|
1748
2167
|
#
|
|
1749
2168
|
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
1750
|
-
# @param time_period [Integer]
|
|
2169
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1751
2170
|
# @return [Array<Float>]
|
|
1752
2171
|
# @raise [TALibError] If there is an error in function execution
|
|
1753
2172
|
|
|
@@ -1755,7 +2174,7 @@ module TALibFFI
|
|
|
1755
2174
|
# Momentum
|
|
1756
2175
|
#
|
|
1757
2176
|
# @param real [Array<Float>] Input values
|
|
1758
|
-
# @param time_period [Integer]
|
|
2177
|
+
# @param time_period [Integer] Time period (default: 10.0)
|
|
1759
2178
|
# @return [Array<Float>]
|
|
1760
2179
|
# @raise [TALibError] If there is an error in function execution
|
|
1761
2180
|
|
|
@@ -1771,7 +2190,14 @@ module TALibFFI
|
|
|
1771
2190
|
# Normalized Average True Range
|
|
1772
2191
|
#
|
|
1773
2192
|
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
1774
|
-
# @param time_period [Integer]
|
|
2193
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
2194
|
+
# @return [Array<Float>]
|
|
2195
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2196
|
+
|
|
2197
|
+
# @!method nvi(price_cv)
|
|
2198
|
+
# Negative Volume Index
|
|
2199
|
+
#
|
|
2200
|
+
# @param price_cv [Array(Array<Float>, Array<Float>)] Required price arrays: close, volume
|
|
1775
2201
|
# @return [Array<Float>]
|
|
1776
2202
|
# @raise [TALibError] If there is an error in function execution
|
|
1777
2203
|
|
|
@@ -1783,11 +2209,39 @@ module TALibFFI
|
|
|
1783
2209
|
# @return [Array<Float>]
|
|
1784
2210
|
# @raise [TALibError] If there is an error in function execution
|
|
1785
2211
|
|
|
2212
|
+
# @!method percentb(real, time_period: 20.0, nb_dev_up: 2.0, nb_dev_dn: 2.0, ma_type: 0.0)
|
|
2213
|
+
# Bollinger Bands %B
|
|
2214
|
+
#
|
|
2215
|
+
# @param real [Array<Float>] Input values
|
|
2216
|
+
# @param time_period [Integer] Time period (default: 20.0)
|
|
2217
|
+
# @param nb_dev_up [Float] Deviation multiplier for upper band (default: 2.0)
|
|
2218
|
+
# @param nb_dev_dn [Float] Deviation multiplier for lower band (default: 2.0)
|
|
2219
|
+
# @param ma_type [Integer] Type of Moving Average (default: 0.0)
|
|
2220
|
+
# @return [Array<Float>]
|
|
2221
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2222
|
+
|
|
2223
|
+
# @!method percentile(real, time_period: 100.0, percentile: 50.0)
|
|
2224
|
+
# Percentile (nearest rank)
|
|
2225
|
+
#
|
|
2226
|
+
# @param real [Array<Float>] Input values
|
|
2227
|
+
# @param time_period [Integer] Number of bars in the window (default: 100.0)
|
|
2228
|
+
# @param percentile [Float] Percentile to report (default: 50.0)
|
|
2229
|
+
# @return [Array<Float>]
|
|
2230
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2231
|
+
|
|
2232
|
+
# @!method percentrank(real, time_period: 100.0)
|
|
2233
|
+
# Percent Rank
|
|
2234
|
+
#
|
|
2235
|
+
# @param real [Array<Float>] Input values
|
|
2236
|
+
# @param time_period [Integer] Time period (default: 100.0)
|
|
2237
|
+
# @return [Array<Float>]
|
|
2238
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2239
|
+
|
|
1786
2240
|
# @!method plus_di(price_hlc, time_period: 14.0)
|
|
1787
2241
|
# Plus Directional Indicator
|
|
1788
2242
|
#
|
|
1789
2243
|
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
1790
|
-
# @param time_period [Integer]
|
|
2244
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1791
2245
|
# @return [Array<Float>]
|
|
1792
2246
|
# @raise [TALibError] If there is an error in function execution
|
|
1793
2247
|
|
|
@@ -1795,17 +2249,66 @@ module TALibFFI
|
|
|
1795
2249
|
# Plus Directional Movement
|
|
1796
2250
|
#
|
|
1797
2251
|
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
1798
|
-
# @param time_period [Integer]
|
|
2252
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1799
2253
|
# @return [Array<Float>]
|
|
1800
2254
|
# @raise [TALibError] If there is an error in function execution
|
|
1801
2255
|
|
|
1802
|
-
# @!method ppo(real, fast_period: 12.0, slow_period: 26.0, ma_type:
|
|
2256
|
+
# @!method ppo(real, fast_period: 12.0, slow_period: 26.0, ma_type: 1.0)
|
|
1803
2257
|
# Percentage Price Oscillator
|
|
1804
2258
|
#
|
|
1805
2259
|
# @param real [Array<Float>] Input values
|
|
1806
|
-
# @param fast_period [Integer]
|
|
1807
|
-
# @param slow_period [Integer]
|
|
1808
|
-
# @param ma_type [Integer] Type of Moving Average (default:
|
|
2260
|
+
# @param fast_period [Integer] Period of the fast MA (default: 12.0)
|
|
2261
|
+
# @param slow_period [Integer] Period of the slow MA (default: 26.0)
|
|
2262
|
+
# @param ma_type [Integer] Type of Moving Average (default: 1.0)
|
|
2263
|
+
# @return [Array<Float>]
|
|
2264
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2265
|
+
|
|
2266
|
+
# @!method pso(price_hlc, fast_k_period: 8.0, ema_period: 5.0)
|
|
2267
|
+
# Premier Stochastic Oscillator
|
|
2268
|
+
#
|
|
2269
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
2270
|
+
# @param fast_k_period [Integer] Time period for building the Fast-K line (default: 8.0)
|
|
2271
|
+
# @param ema_period [Integer] Period of each of the two smoothing passes (default: 5.0)
|
|
2272
|
+
# @return [Array<Float>]
|
|
2273
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2274
|
+
|
|
2275
|
+
# @!method pvi(price_cv)
|
|
2276
|
+
# Positive Volume Index
|
|
2277
|
+
#
|
|
2278
|
+
# @param price_cv [Array(Array<Float>, Array<Float>)] Required price arrays: close, volume
|
|
2279
|
+
# @return [Array<Float>]
|
|
2280
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2281
|
+
|
|
2282
|
+
# @!method pvo(price_v, fast_period: 12.0, slow_period: 26.0, ma_type: 1.0)
|
|
2283
|
+
# Percentage Volume Oscillator
|
|
2284
|
+
#
|
|
2285
|
+
# @param price_v [Array(Array<Float>)] Required price arrays: volume
|
|
2286
|
+
# @param fast_period [Integer] Period of the fast MA (default: 12.0)
|
|
2287
|
+
# @param slow_period [Integer] Period of the slow MA (default: 26.0)
|
|
2288
|
+
# @param ma_type [Integer] Type of Moving Average (default: 1.0)
|
|
2289
|
+
# @return [Array<Float>]
|
|
2290
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2291
|
+
|
|
2292
|
+
# @!method pvt(price_cv)
|
|
2293
|
+
# Price Volume Trend
|
|
2294
|
+
#
|
|
2295
|
+
# @param price_cv [Array(Array<Float>, Array<Float>)] Required price arrays: close, volume
|
|
2296
|
+
# @return [Array<Float>]
|
|
2297
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2298
|
+
|
|
2299
|
+
# @!method qstick(price_oc, time_period: 10.0)
|
|
2300
|
+
# Qstick
|
|
2301
|
+
#
|
|
2302
|
+
# @param price_oc [Array(Array<Float>, Array<Float>)] Required price arrays: open, close
|
|
2303
|
+
# @param time_period [Integer] Time period (default: 10.0)
|
|
2304
|
+
# @return [Array<Float>]
|
|
2305
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2306
|
+
|
|
2307
|
+
# @!method rma(real, time_period: 30.0)
|
|
2308
|
+
# Wilder's Smoothed Moving Average
|
|
2309
|
+
#
|
|
2310
|
+
# @param real [Array<Float>] Input values
|
|
2311
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1809
2312
|
# @return [Array<Float>]
|
|
1810
2313
|
# @raise [TALibError] If there is an error in function execution
|
|
1811
2314
|
|
|
@@ -1813,7 +2316,7 @@ module TALibFFI
|
|
|
1813
2316
|
# Rate of change : ((price/prevPrice)-1)*100
|
|
1814
2317
|
#
|
|
1815
2318
|
# @param real [Array<Float>] Input values
|
|
1816
|
-
# @param time_period [Integer]
|
|
2319
|
+
# @param time_period [Integer] Time period (default: 10.0)
|
|
1817
2320
|
# @return [Array<Float>]
|
|
1818
2321
|
# @raise [TALibError] If there is an error in function execution
|
|
1819
2322
|
|
|
@@ -1821,7 +2324,7 @@ module TALibFFI
|
|
|
1821
2324
|
# Rate of change Percentage: (price-prevPrice)/prevPrice
|
|
1822
2325
|
#
|
|
1823
2326
|
# @param real [Array<Float>] Input values
|
|
1824
|
-
# @param time_period [Integer]
|
|
2327
|
+
# @param time_period [Integer] Time period (default: 10.0)
|
|
1825
2328
|
# @return [Array<Float>]
|
|
1826
2329
|
# @raise [TALibError] If there is an error in function execution
|
|
1827
2330
|
|
|
@@ -1829,7 +2332,7 @@ module TALibFFI
|
|
|
1829
2332
|
# Rate of change ratio: (price/prevPrice)
|
|
1830
2333
|
#
|
|
1831
2334
|
# @param real [Array<Float>] Input values
|
|
1832
|
-
# @param time_period [Integer]
|
|
2335
|
+
# @param time_period [Integer] Time period (default: 10.0)
|
|
1833
2336
|
# @return [Array<Float>]
|
|
1834
2337
|
# @raise [TALibError] If there is an error in function execution
|
|
1835
2338
|
|
|
@@ -1837,7 +2340,16 @@ module TALibFFI
|
|
|
1837
2340
|
# Rate of change ratio 100 scale: (price/prevPrice)*100
|
|
1838
2341
|
#
|
|
1839
2342
|
# @param real [Array<Float>] Input values
|
|
1840
|
-
# @param time_period [Integer]
|
|
2343
|
+
# @param time_period [Integer] Time period (default: 10.0)
|
|
2344
|
+
# @return [Array<Float>]
|
|
2345
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2346
|
+
|
|
2347
|
+
# @!method rogerssatchell(price_ohlc, time_period: 10.0, annualization: 252.0)
|
|
2348
|
+
# Rogers-Satchell Volatility
|
|
2349
|
+
#
|
|
2350
|
+
# @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
|
|
2351
|
+
# @param time_period [Integer] Number of bars in the window (default: 10.0)
|
|
2352
|
+
# @param annualization [Float] Periods per year; 1 leaves the per-bar figure (default: 252.0)
|
|
1841
2353
|
# @return [Array<Float>]
|
|
1842
2354
|
# @raise [TALibError] If there is an error in function execution
|
|
1843
2355
|
|
|
@@ -1845,7 +2357,33 @@ module TALibFFI
|
|
|
1845
2357
|
# Relative Strength Index
|
|
1846
2358
|
#
|
|
1847
2359
|
# @param real [Array<Float>] Input values
|
|
1848
|
-
# @param time_period [Integer]
|
|
2360
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
2361
|
+
# @return [Array<Float>]
|
|
2362
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2363
|
+
|
|
2364
|
+
# @!method rvi(real, time_period: 14.0, std_dev_period: 10.0)
|
|
2365
|
+
# Relative Volatility Index
|
|
2366
|
+
#
|
|
2367
|
+
# @param real [Array<Float>] Input values
|
|
2368
|
+
# @param time_period [Integer] Time period of the Wilder smoothing applied to both legs (default: 14.0)
|
|
2369
|
+
# @param std_dev_period [Integer] Time period of the standard deviation (default: 10.0)
|
|
2370
|
+
# @return [Array<Float>]
|
|
2371
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2372
|
+
|
|
2373
|
+
# @!method rvir(price_hl, time_period: 14.0, std_dev_period: 10.0)
|
|
2374
|
+
# Relative Volatility Index, refined high/low form
|
|
2375
|
+
#
|
|
2376
|
+
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
2377
|
+
# @param time_period [Integer] Time period of the Wilder smoothing applied to both indices (default: 14.0)
|
|
2378
|
+
# @param std_dev_period [Integer] Time period of the standard deviation (default: 10.0)
|
|
2379
|
+
# @return [Array<Float>]
|
|
2380
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2381
|
+
|
|
2382
|
+
# @!method rvol(price_v, time_period: 20.0)
|
|
2383
|
+
# Relative Volume
|
|
2384
|
+
#
|
|
2385
|
+
# @param price_v [Array(Array<Float>)] Required price arrays: volume
|
|
2386
|
+
# @param time_period [Integer] Time period (default: 20.0)
|
|
1849
2387
|
# @return [Array<Float>]
|
|
1850
2388
|
# @raise [TALibError] If there is an error in function execution
|
|
1851
2389
|
|
|
@@ -1873,6 +2411,14 @@ module TALibFFI
|
|
|
1873
2411
|
# @return [Array<Float>]
|
|
1874
2412
|
# @raise [TALibError] If there is an error in function execution
|
|
1875
2413
|
|
|
2414
|
+
# @!method si(price_ohlc, limit_move: 3.0)
|
|
2415
|
+
# Wilder Swing Index
|
|
2416
|
+
#
|
|
2417
|
+
# @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
|
|
2418
|
+
# @param limit_move [Float] Largest one-bar price move the index is scaled against, in price units (default: 3.0)
|
|
2419
|
+
# @return [Array<Float>]
|
|
2420
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2421
|
+
|
|
1876
2422
|
# @!method sin(real)
|
|
1877
2423
|
# Vector Trigonometric Sin
|
|
1878
2424
|
#
|
|
@@ -1891,10 +2437,23 @@ module TALibFFI
|
|
|
1891
2437
|
# Simple Moving Average
|
|
1892
2438
|
#
|
|
1893
2439
|
# @param real [Array<Float>] Input values
|
|
1894
|
-
# @param time_period [Integer]
|
|
2440
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1895
2441
|
# @return [Array<Float>]
|
|
1896
2442
|
# @raise [TALibError] If there is an error in function execution
|
|
1897
2443
|
|
|
2444
|
+
# @!method smi(price_hlc, time_period: 13.0, fast_period: 2.0, slow_period: 25.0, signal_period: 9.0)
|
|
2445
|
+
# Stochastic Momentum Index
|
|
2446
|
+
#
|
|
2447
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
2448
|
+
# @param time_period [Integer] Period of the high/low range (default: 13.0)
|
|
2449
|
+
# @param fast_period [Integer] Period of the second smoothing, applied to the first (default: 2.0)
|
|
2450
|
+
# @param slow_period [Integer] Period of the first smoothing, applied to the raw momentum (default: 25.0)
|
|
2451
|
+
# @param signal_period [Integer] Smoothing for the signal line (period length) (default: 9.0)
|
|
2452
|
+
# @return [Hash] Hash containing the following arrays:
|
|
2453
|
+
# @option result [Array<Float>] :smi Output values
|
|
2454
|
+
# @option result [Array<Float>] :smi_signal Output values
|
|
2455
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2456
|
+
|
|
1898
2457
|
# @!method sqrt(real)
|
|
1899
2458
|
# Vector Square Root
|
|
1900
2459
|
#
|
|
@@ -1902,11 +2461,36 @@ module TALibFFI
|
|
|
1902
2461
|
# @return [Array<Float>]
|
|
1903
2462
|
# @raise [TALibError] If there is an error in function execution
|
|
1904
2463
|
|
|
2464
|
+
# @!method sqzmom(price_hlc, bb_period: 20.0, nb_dev: 2.0, kc_period: 20.0, factor_wide: 2.0, factor_normal: 1.5, factor_narrow: 1.0)
|
|
2465
|
+
# Squeeze Momentum and Level
|
|
2466
|
+
#
|
|
2467
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
2468
|
+
# @param bb_period [Integer] Period of the Bollinger Bands (default: 20.0)
|
|
2469
|
+
# @param nb_dev [Float] Deviation multiplier for both Bollinger Bands (default: 2.0)
|
|
2470
|
+
# @param kc_period [Integer] Period of the Keltner Channel, and of the momentum regression (default: 20.0)
|
|
2471
|
+
# @param factor_wide [Float] Keltner width for the widest compression test (default: 2.0)
|
|
2472
|
+
# @param factor_normal [Float] Keltner width for the classic squeeze test (default: 1.5)
|
|
2473
|
+
# @param factor_narrow [Float] Keltner width for the tightest compression test (default: 1.0)
|
|
2474
|
+
# @return [Hash] Hash containing the following arrays:
|
|
2475
|
+
# @option result [Array<Float>] :momentum Output values
|
|
2476
|
+
# @option result [Array<Integer>] :squeeze Output values
|
|
2477
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2478
|
+
|
|
2479
|
+
# @!method stc(real, fast_period: 23.0, slow_period: 50.0, cycle_period: 10.0)
|
|
2480
|
+
# Schaff Trend Cycle
|
|
2481
|
+
#
|
|
2482
|
+
# @param real [Array<Float>] Input values
|
|
2483
|
+
# @param fast_period [Integer] Period of the fast EMA (default: 23.0)
|
|
2484
|
+
# @param slow_period [Integer] Period of the slow EMA (default: 50.0)
|
|
2485
|
+
# @param cycle_period [Integer] Window of both stochastic stages (default: 10.0)
|
|
2486
|
+
# @return [Array<Float>]
|
|
2487
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2488
|
+
|
|
1905
2489
|
# @!method stddev(real, time_period: 5.0, nb_dev: 1.0)
|
|
1906
2490
|
# Standard Deviation
|
|
1907
2491
|
#
|
|
1908
2492
|
# @param real [Array<Float>] Input values
|
|
1909
|
-
# @param time_period [Integer]
|
|
2493
|
+
# @param time_period [Integer] Time period (default: 5.0)
|
|
1910
2494
|
# @param nb_dev [Float] Nb of deviations (default: 1.0)
|
|
1911
2495
|
# @return [Array<Float>]
|
|
1912
2496
|
# @raise [TALibError] If there is an error in function execution
|
|
@@ -1941,7 +2525,7 @@ module TALibFFI
|
|
|
1941
2525
|
# Stochastic Relative Strength Index
|
|
1942
2526
|
#
|
|
1943
2527
|
# @param real [Array<Float>] Input values
|
|
1944
|
-
# @param time_period [Integer]
|
|
2528
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
1945
2529
|
# @param fast_k_period [Integer] Time period for building the Fast-K line (default: 5.0)
|
|
1946
2530
|
# @param fast_d_period [Integer] Smoothing for making the Fast-D line. Usually set to 3 (default: 3.0)
|
|
1947
2531
|
# @param fast_d_ma_type [Integer] Type of Moving Average for Fast-D (default: 0.0)
|
|
@@ -1962,7 +2546,59 @@ module TALibFFI
|
|
|
1962
2546
|
# Summation
|
|
1963
2547
|
#
|
|
1964
2548
|
# @param real [Array<Float>] Input values
|
|
1965
|
-
# @param time_period [Integer]
|
|
2549
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
2550
|
+
# @return [Array<Float>]
|
|
2551
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2552
|
+
|
|
2553
|
+
# @!method supertrend(price_hlc, time_period: 10.0, multiplier: 3.0)
|
|
2554
|
+
# SuperTrend
|
|
2555
|
+
#
|
|
2556
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
2557
|
+
# @param time_period [Integer] Time period for the Average True Range (default: 10.0)
|
|
2558
|
+
# @param multiplier [Float] ATR multiplier for band width (default: 3.0)
|
|
2559
|
+
# @return [Hash] Hash containing the following arrays:
|
|
2560
|
+
# @option result [Array<Float>] :supertrend Output values
|
|
2561
|
+
# @option result [Array<Integer>] :trend Output values
|
|
2562
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2563
|
+
|
|
2564
|
+
# @!method swak_2php(real, time_period: 20.0)
|
|
2565
|
+
# Swiss Army Knife - Two-Pole High-Pass Filter
|
|
2566
|
+
#
|
|
2567
|
+
# @param real [Array<Float>] Input values
|
|
2568
|
+
# @param time_period [Integer] Cutoff period (default: 20.0)
|
|
2569
|
+
# @return [Array<Float>]
|
|
2570
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2571
|
+
|
|
2572
|
+
# @!method swak_bp(real, time_period: 20.0, delta: 0.1)
|
|
2573
|
+
# Swiss Army Knife - Band-Pass Filter
|
|
2574
|
+
#
|
|
2575
|
+
# @param real [Array<Float>] Input values
|
|
2576
|
+
# @param time_period [Integer] Center period (default: 20.0)
|
|
2577
|
+
# @param delta [Float] Half-bandwidth as a fraction of the center period (default: 0.1)
|
|
2578
|
+
# @return [Array<Float>]
|
|
2579
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2580
|
+
|
|
2581
|
+
# @!method swak_butter(real, time_period: 20.0)
|
|
2582
|
+
# Swiss Army Knife - Butterworth Filter
|
|
2583
|
+
#
|
|
2584
|
+
# @param real [Array<Float>] Input values
|
|
2585
|
+
# @param time_period [Integer] Cutoff period (default: 20.0)
|
|
2586
|
+
# @return [Array<Float>]
|
|
2587
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2588
|
+
|
|
2589
|
+
# @!method swak_gauss(real, time_period: 20.0)
|
|
2590
|
+
# Swiss Army Knife - Gaussian Filter
|
|
2591
|
+
#
|
|
2592
|
+
# @param real [Array<Float>] Input values
|
|
2593
|
+
# @param time_period [Integer] Cutoff period (default: 20.0)
|
|
2594
|
+
# @return [Array<Float>]
|
|
2595
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2596
|
+
|
|
2597
|
+
# @!method swak_hp(real, time_period: 20.0)
|
|
2598
|
+
# Swiss Army Knife - High-Pass Filter
|
|
2599
|
+
#
|
|
2600
|
+
# @param real [Array<Float>] Input values
|
|
2601
|
+
# @param time_period [Integer] Cutoff period (default: 20.0)
|
|
1966
2602
|
# @return [Array<Float>]
|
|
1967
2603
|
# @raise [TALibError] If there is an error in function execution
|
|
1968
2604
|
|
|
@@ -1970,7 +2606,7 @@ module TALibFFI
|
|
|
1970
2606
|
# Triple Exponential Moving Average (T3)
|
|
1971
2607
|
#
|
|
1972
2608
|
# @param real [Array<Float>] Input values
|
|
1973
|
-
# @param time_period [Integer]
|
|
2609
|
+
# @param time_period [Integer] Time period (default: 5.0)
|
|
1974
2610
|
# @param v_factor [Float] Volume Factor (default: 0.7)
|
|
1975
2611
|
# @return [Array<Float>]
|
|
1976
2612
|
# @raise [TALibError] If there is an error in function execution
|
|
@@ -1993,7 +2629,7 @@ module TALibFFI
|
|
|
1993
2629
|
# Triple Exponential Moving Average
|
|
1994
2630
|
#
|
|
1995
2631
|
# @param real [Array<Float>] Input values
|
|
1996
|
-
# @param time_period [Integer]
|
|
2632
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
1997
2633
|
# @return [Array<Float>]
|
|
1998
2634
|
# @raise [TALibError] If there is an error in function execution
|
|
1999
2635
|
|
|
@@ -2008,7 +2644,7 @@ module TALibFFI
|
|
|
2008
2644
|
# Triangular Moving Average
|
|
2009
2645
|
#
|
|
2010
2646
|
# @param real [Array<Float>] Input values
|
|
2011
|
-
# @param time_period [Integer]
|
|
2647
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
2012
2648
|
# @return [Array<Float>]
|
|
2013
2649
|
# @raise [TALibError] If there is an error in function execution
|
|
2014
2650
|
|
|
@@ -2016,7 +2652,7 @@ module TALibFFI
|
|
|
2016
2652
|
# 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA
|
|
2017
2653
|
#
|
|
2018
2654
|
# @param real [Array<Float>] Input values
|
|
2019
|
-
# @param time_period [Integer]
|
|
2655
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
2020
2656
|
# @return [Array<Float>]
|
|
2021
2657
|
# @raise [TALibError] If there is an error in function execution
|
|
2022
2658
|
|
|
@@ -2024,7 +2660,16 @@ module TALibFFI
|
|
|
2024
2660
|
# Time Series Forecast
|
|
2025
2661
|
#
|
|
2026
2662
|
# @param real [Array<Float>] Input values
|
|
2027
|
-
# @param time_period [Integer]
|
|
2663
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
2664
|
+
# @return [Array<Float>]
|
|
2665
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2666
|
+
|
|
2667
|
+
# @!method tsi(real, first_period: 25.0, second_period: 13.0)
|
|
2668
|
+
# True Strength Index
|
|
2669
|
+
#
|
|
2670
|
+
# @param real [Array<Float>] Input values
|
|
2671
|
+
# @param first_period [Integer] Period of the first smoothing, applied to the raw momentum (default: 25.0)
|
|
2672
|
+
# @param second_period [Integer] Period of the second smoothing, applied to the first (default: 13.0)
|
|
2028
2673
|
# @return [Array<Float>]
|
|
2029
2674
|
# @raise [TALibError] If there is an error in function execution
|
|
2030
2675
|
|
|
@@ -2049,11 +2694,73 @@ module TALibFFI
|
|
|
2049
2694
|
# Variance
|
|
2050
2695
|
#
|
|
2051
2696
|
# @param real [Array<Float>] Input values
|
|
2052
|
-
# @param time_period [Integer]
|
|
2697
|
+
# @param time_period [Integer] Time period (default: 5.0)
|
|
2053
2698
|
# @param nb_dev [Float] Nb of deviations (default: 1.0)
|
|
2054
2699
|
# @return [Array<Float>]
|
|
2055
2700
|
# @raise [TALibError] If there is an error in function execution
|
|
2056
2701
|
|
|
2702
|
+
# @!method vhf(real, time_period: 28.0)
|
|
2703
|
+
# Vertical Horizontal Filter
|
|
2704
|
+
#
|
|
2705
|
+
# @param real [Array<Float>] Input values
|
|
2706
|
+
# @param time_period [Integer] Time period (default: 28.0)
|
|
2707
|
+
# @return [Array<Float>]
|
|
2708
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2709
|
+
|
|
2710
|
+
# @!method vidya(real, time_period: 12.0, cmo_period: 9.0)
|
|
2711
|
+
# Variable Index Dynamic Average
|
|
2712
|
+
#
|
|
2713
|
+
# @param real [Array<Float>] Input values
|
|
2714
|
+
# @param time_period [Integer] EMA-equivalent smoothing period, alpha = 2/(n+1) (default: 12.0)
|
|
2715
|
+
# @param cmo_period [Integer] Period of the unsmoothed CMO that scales alpha (default: 9.0)
|
|
2716
|
+
# @return [Array<Float>]
|
|
2717
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2718
|
+
|
|
2719
|
+
# @!method vortex(price_hlc, time_period: 14.0)
|
|
2720
|
+
# Vortex Indicator
|
|
2721
|
+
#
|
|
2722
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
2723
|
+
# @param time_period [Integer] Number of bars in the rolling sums (default: 14.0)
|
|
2724
|
+
# @return [Hash] Hash containing the following arrays:
|
|
2725
|
+
# @option result [Array<Float>] :plus_vi Output values
|
|
2726
|
+
# @option result [Array<Float>] :minus_vi Output values
|
|
2727
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2728
|
+
|
|
2729
|
+
# @!method vwap(price_hlcv)
|
|
2730
|
+
# Volume Weighted Average Price
|
|
2731
|
+
#
|
|
2732
|
+
# @param price_hlcv [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close, volume
|
|
2733
|
+
# @return [Array<Float>]
|
|
2734
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2735
|
+
|
|
2736
|
+
# @!method vwma(real, price_v, time_period: 30.0)
|
|
2737
|
+
# Volume Weighted Moving Average
|
|
2738
|
+
#
|
|
2739
|
+
# @param real [Array<Float>] Input values
|
|
2740
|
+
# @param price_v [Array(Array<Float>)] Required price arrays: volume
|
|
2741
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
2742
|
+
# @return [Array<Float>]
|
|
2743
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2744
|
+
|
|
2745
|
+
# @!method wad(price_hlc)
|
|
2746
|
+
# Williams' Accumulation/Distribution
|
|
2747
|
+
#
|
|
2748
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
2749
|
+
# @return [Array<Float>]
|
|
2750
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2751
|
+
|
|
2752
|
+
# @!method wavetrend(price_hlc, channel_period: 10.0, average_period: 21.0, signal_period: 4.0)
|
|
2753
|
+
# WaveTrend Oscillator
|
|
2754
|
+
#
|
|
2755
|
+
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
2756
|
+
# @param channel_period [Integer] Period of the price channel, used by both the average and the deviation (default: 10.0)
|
|
2757
|
+
# @param average_period [Integer] Smoothing for the oscillator line (default: 21.0)
|
|
2758
|
+
# @param signal_period [Integer] Simple average of the oscillator line, making the signal line (default: 4.0)
|
|
2759
|
+
# @return [Hash] Hash containing the following arrays:
|
|
2760
|
+
# @option result [Array<Float>] :wt1 Output values
|
|
2761
|
+
# @option result [Array<Float>] :wt2 Output values
|
|
2762
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2763
|
+
|
|
2057
2764
|
# @!method wclprice(price_hlc)
|
|
2058
2765
|
# Weighted Close Price
|
|
2059
2766
|
#
|
|
@@ -2065,7 +2772,7 @@ module TALibFFI
|
|
|
2065
2772
|
# Williams' %R
|
|
2066
2773
|
#
|
|
2067
2774
|
# @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
|
|
2068
|
-
# @param time_period [Integer]
|
|
2775
|
+
# @param time_period [Integer] Time period (default: 14.0)
|
|
2069
2776
|
# @return [Array<Float>]
|
|
2070
2777
|
# @raise [TALibError] If there is an error in function execution
|
|
2071
2778
|
|
|
@@ -2073,7 +2780,27 @@ module TALibFFI
|
|
|
2073
2780
|
# Weighted Moving Average
|
|
2074
2781
|
#
|
|
2075
2782
|
# @param real [Array<Float>] Input values
|
|
2076
|
-
# @param time_period [Integer]
|
|
2783
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
2784
|
+
# @return [Array<Float>]
|
|
2785
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2786
|
+
|
|
2787
|
+
# @!method zigzag(price_hl, sensitivity: 5.0, min_trend_length: 1.0)
|
|
2788
|
+
# Zig Zag
|
|
2789
|
+
#
|
|
2790
|
+
# @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
|
|
2791
|
+
# @param sensitivity [Float] Minimum move away from the current extreme that reverses the leg, in percent (default: 5.0)
|
|
2792
|
+
# @param min_trend_length [Integer] Minimum number of bars between two pivots (default: 1.0)
|
|
2793
|
+
# @return [Hash] Hash containing the following arrays:
|
|
2794
|
+
# @option result [Array<Float>] :zig_zag Output values
|
|
2795
|
+
# @option result [Array<Integer>] :trend Output values
|
|
2796
|
+
# @option result [Array<Integer>] :pivot_idx Output values
|
|
2797
|
+
# @raise [TALibError] If there is an error in function execution
|
|
2798
|
+
|
|
2799
|
+
# @!method zlema(real, time_period: 30.0)
|
|
2800
|
+
# Zero-Lag Exponential Moving Average
|
|
2801
|
+
#
|
|
2802
|
+
# @param real [Array<Float>] Input values
|
|
2803
|
+
# @param time_period [Integer] Time period (default: 30.0)
|
|
2077
2804
|
# @return [Array<Float>]
|
|
2078
2805
|
# @raise [TALibError] If there is an error in function execution
|
|
2079
2806
|
|