ta_lib_ffi 0.1.0 → 0.3.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.
data/lib/ta_lib_ffi.rb ADDED
@@ -0,0 +1,2082 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fiddle"
4
+ require "fiddle/import"
5
+
6
+ # Ruby FFI wrapper for TA-Lib (Technical Analysis Library)
7
+ #
8
+ # This module provides a Ruby interface to the TA-Lib technical analysis library
9
+ # using FFI (Foreign Function Interface). It allows you to perform various
10
+ # technical analysis calculations on financial market data.
11
+ #
12
+ # @example Basic usage
13
+ # require 'ta_lib_ffi'
14
+ #
15
+ # # Calculate Simple Moving Average
16
+ # prices = [10.0, 11.0, 12.0, 11.0, 10.0]
17
+ # result = TALibFFI.sma(prices, time_period: 3)
18
+ #
19
+ # @see https://ta-lib.org/ TA-Lib Official Website
20
+ module TALibFFI
21
+ VERSION = "0.3.0"
22
+
23
+ if defined?(Zeitwerk)
24
+ # https://github.com/fxn/zeitwerk?tab=readme-ov-file#custom-inflector
25
+ # @!visibility private
26
+ class Inflector < Zeitwerk::GemInflector
27
+ def camelize(basename, _abspath)
28
+ case basename
29
+ when "ta_lib_ffi"
30
+ "TALibFFI"
31
+ else
32
+ super
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ extend Fiddle::Importer
39
+
40
+ lib_path = case RUBY_PLATFORM
41
+ when /darwin/
42
+ brew_prefix = `brew --prefix`.chomp
43
+ "#{brew_prefix}/lib/libta-lib.dylib"
44
+ when /linux/
45
+ "libta-lib.so"
46
+ when /cygwin|mswin|mingw|bccwin|wince|emx/
47
+ "C:/Program Files/TA-Lib/bin/ta-lib.dll"
48
+ else
49
+ raise "Unsupported platform"
50
+ end
51
+
52
+ dlload lib_path
53
+
54
+ class TALibError < StandardError; end
55
+
56
+ TA_SUCCESS = 0
57
+ TA_LIB_NOT_INITIALIZE = 1
58
+ TA_BAD_PARAM = 2
59
+ TA_ALLOC_ERR = 3
60
+ TA_GROUP_NOT_FOUND = 4
61
+ TA_FUNC_NOT_FOUND = 5
62
+ TA_INVALID_HANDLE = 6
63
+ TA_INVALID_PARAM_HOLDER = 7
64
+ TA_INVALID_PARAM_HOLDER_TYPE = 8
65
+ TA_INVALID_PARAM_FUNCTION = 9
66
+ TA_INPUT_NOT_ALL_INITIALIZE = 10
67
+ TA_OUTPUT_NOT_ALL_INITIALIZE = 11
68
+ TA_OUT_OF_RANGE_START_INDEX = 12
69
+ TA_OUT_OF_RANGE_END_INDEX = 13
70
+ TA_INVALID_LIST_TYPE = 14
71
+ TA_BAD_OBJECT = 15
72
+ TA_NOT_SUPPORTED = 16
73
+ TA_INTERNAL_ERROR = 5000
74
+ TA_UNKNOWN_ERR = 0xFFFF
75
+
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
+ typealias "TA_Real", "double"
87
+ typealias "TA_Integer", "int"
88
+ typealias "TA_RetCode", "int"
89
+ typealias "TA_FuncHandle", "unsigned int"
90
+ typealias "TA_FuncFlags", "int"
91
+ typealias "TA_CallForEachFunc", "void *"
92
+ typealias "TA_InputParameterType", "int"
93
+ typealias "TA_InputFlags", "int"
94
+ typealias "TA_OptInputParameterType", "int"
95
+ typealias "TA_OptInputFlags", "int"
96
+ typealias "TA_OutputParameterType", "int"
97
+ typealias "TA_OutputFlags", "int"
98
+
99
+ TA_StringTable = struct [
100
+ "unsigned int size",
101
+ "const char **string",
102
+ "void *hiddenData"
103
+ ]
104
+
105
+ TA_FuncInfo = struct [
106
+ "const char *name",
107
+ "const char *group",
108
+ "const char *hint",
109
+ "const char *camelCaseName",
110
+ "TA_FuncFlags flags",
111
+ "unsigned int nbInput",
112
+ "unsigned int nbOptInput",
113
+ "unsigned int nbOutput",
114
+ "const TA_FuncHandle *handle"
115
+ ]
116
+
117
+ TA_ParamHolder = struct [
118
+ "void *hiddenData"
119
+ ]
120
+
121
+ TA_InputParameterInfo = struct [
122
+ "TA_InputParameterType type",
123
+ "const char *paramName",
124
+ "TA_InputFlags flags"
125
+ ]
126
+
127
+ TA_OptInputParameterInfo = struct [
128
+ "TA_OptInputParameterType type",
129
+ "const char *paramName",
130
+ "TA_OptInputFlags flags",
131
+ "const char *displayName",
132
+ "const void *dataSet",
133
+ "TA_Real defaultValue",
134
+ "const char *hint",
135
+ "const char *helpFile"
136
+ ]
137
+
138
+ TA_OutputParameterInfo = struct [
139
+ "TA_OutputParameterType type",
140
+ "const char *paramName",
141
+ "TA_OutputFlags flags"
142
+ ]
143
+
144
+ TA_PARAM_TYPE = {
145
+ TA_Input_Price: 0,
146
+ TA_Input_Real: 1,
147
+ TA_Input_Integer: 2,
148
+ TA_OptInput_RealRange: 0,
149
+ TA_OptInput_RealList: 1,
150
+ TA_OptInput_IntegerRange: 2,
151
+ TA_OptInput_IntegerList: 3,
152
+ TA_Output_Real: 0,
153
+ TA_Output_Integer: 1
154
+ }.freeze
155
+
156
+ TA_FLAGS = {
157
+ TA_InputFlags: {
158
+ TA_IN_PRICE_OPEN: 0x00000001,
159
+ TA_IN_PRICE_HIGH: 0x00000002,
160
+ TA_IN_PRICE_LOW: 0x00000004,
161
+ TA_IN_PRICE_CLOSE: 0x00000008,
162
+ TA_IN_PRICE_VOLUME: 0x00000010,
163
+ TA_IN_PRICE_OPENINTEREST: 0x00000020,
164
+ TA_IN_PRICE_TIMESTAMP: 0x00000040
165
+ },
166
+ TA_OptInputFlags: {
167
+ TA_OPTIN_IS_PERCENT: 0x00100000,
168
+ TA_OPTIN_IS_DEGREE: 0x00200000,
169
+ TA_OPTIN_IS_CURRENCY: 0x00400000,
170
+ TA_OPTIN_ADVANCED: 0x01000000
171
+ },
172
+ TA_OutputFlags: {
173
+ TA_OUT_LINE: 0x00000001,
174
+ TA_OUT_DOT_LINE: 0x00000002,
175
+ TA_OUT_DASH_LINE: 0x00000004,
176
+ TA_OUT_DOT: 0x00000008,
177
+ TA_OUT_HISTO: 0x00000010,
178
+ TA_OUT_PATTERN_BOOL: 0x00000020,
179
+ TA_OUT_PATTERN_BULL_BEAR: 0x00000040,
180
+ TA_OUT_PATTERN_STRENGTH: 0x00000080,
181
+ TA_OUT_POSITIVE: 0x00000100,
182
+ TA_OUT_NEGATIVE: 0x00000200,
183
+ TA_OUT_ZERO: 0x00000400,
184
+ TA_OUT_UPPER_LIMIT: 0x00000800,
185
+ TA_OUT_LOWER_LIMIT: 0x00001000
186
+ }
187
+ }.freeze
188
+
189
+ extern "int TA_Initialize()"
190
+ extern "int TA_Shutdown()"
191
+ extern "int TA_GroupTableAlloc(TA_StringTable**)"
192
+ extern "int TA_GroupTableFree(TA_StringTable*)"
193
+ extern "TA_RetCode TA_FuncTableAlloc(const char *group, TA_StringTable **table)"
194
+ extern "TA_RetCode TA_FuncTableFree(TA_StringTable *table)"
195
+ extern "TA_FuncHandle TA_GetFuncHandle(const char *name, const TA_FuncHandle **handle)"
196
+ extern "TA_RetCode TA_GetFuncInfo(const TA_FuncHandle *handle, const TA_FuncInfo **funcInfo)"
197
+ extern "TA_RetCode TA_ForEachFunc(TA_CallForEachFunc functionToCall, void *opaqueData)"
198
+ extern "TA_RetCode TA_GetInputParameterInfo(const TA_FuncHandle *handle, unsigned int paramIndex, const TA_InputParameterInfo **info)"
199
+ extern "TA_RetCode TA_GetOptInputParameterInfo(const TA_FuncHandle *handle, unsigned int paramIndex, const TA_OptInputParameterInfo **info)"
200
+ extern "TA_RetCode TA_GetOutputParameterInfo(const TA_FuncHandle *handle, unsigned int paramIndex, const TA_OutputParameterInfo **info)"
201
+ extern "TA_RetCode TA_ParamHolderAlloc(const TA_FuncHandle *handle, TA_ParamHolder **allocatedParams)"
202
+ extern "TA_RetCode TA_ParamHolderFree(TA_ParamHolder *params)"
203
+ extern "TA_RetCode TA_SetInputParamIntegerPtr(TA_ParamHolder *params, unsigned int paramIndex, const TA_Integer *value)"
204
+ extern "TA_RetCode TA_SetInputParamRealPtr(TA_ParamHolder *params, unsigned int paramIndex, const TA_Real *value)"
205
+ extern "TA_RetCode TA_SetInputParamPricePtr(TA_ParamHolder *params,
206
+ unsigned int paramIndex,
207
+ const TA_Real *open,
208
+ const TA_Real *high,
209
+ const TA_Real *low,
210
+ const TA_Real *close,
211
+ const TA_Real *volume,
212
+ const TA_Real *openInterest)"
213
+ extern "TA_RetCode TA_SetOptInputParamInteger(TA_ParamHolder *params, unsigned int paramIndex, TA_Integer optInValue)"
214
+ extern "TA_RetCode TA_SetOptInputParamReal(TA_ParamHolder *params, unsigned int paramIndex, TA_Real optInValue)"
215
+ extern "TA_RetCode TA_SetOutputParamIntegerPtr(TA_ParamHolder *params, unsigned int paramIndex, TA_Integer *out)"
216
+ extern "TA_RetCode TA_SetOutputParamRealPtr(TA_ParamHolder *params, unsigned int paramIndex, TA_Real *out)"
217
+ extern "TA_RetCode TA_GetLookback(const TA_ParamHolder *params, TA_Integer *lookback)"
218
+ extern "TA_RetCode TA_CallFunc(const TA_ParamHolder *params,
219
+ TA_Integer startIdx,
220
+ TA_Integer endIdx,
221
+ TA_Integer *outBegIdx,
222
+ TA_Integer *outNbElement)"
223
+ extern "const char *TA_FunctionDescriptionXML(void)"
224
+
225
+ module_function
226
+
227
+ # Extracts flags from a bitmask value based on the flag type
228
+ #
229
+ # @param value [Integer] The bitmask value to extract flags from
230
+ # @param type [Symbol] The type of flags to extract (:TA_InputFlags, :TA_OptInputFlags, or :TA_OutputFlags)
231
+ # @return [Array<Symbol>] Array of flag names that are set in the bitmask
232
+ def extract_flags(value, type)
233
+ flags_set = []
234
+ TA_FLAGS[type].each do |k, v|
235
+ flags_set << k if (value & v) != 0
236
+ end
237
+ flags_set
238
+ end
239
+
240
+ # Returns a list of all available function groups in TA-Lib
241
+ #
242
+ # @return [Array<String>] Array of group names
243
+ def group_table
244
+ string_table_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
245
+ ret_code = TA_GroupTableAlloc(string_table_ptr.ref)
246
+ check_ta_return_code(ret_code)
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
253
+ end
254
+
255
+ # Returns a list of all functions in a specific group
256
+ #
257
+ # @param group [String] The name of the group to get functions for
258
+ # @return [Array<String>] Array of function names in the group
259
+ def function_table(group)
260
+ string_table_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
261
+ ret_code = TA_FuncTableAlloc(group, string_table_ptr.ref)
262
+ check_ta_return_code(ret_code)
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
270
+ end
271
+
272
+ # Gets detailed information about a specific TA-Lib function
273
+ #
274
+ # @param name [String] The name of the function to get information for
275
+ # @return [Fiddle::CStructEntity] Struct containing function information
276
+ def function_info(name)
277
+ handle_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
278
+ ret_code = TA_GetFuncHandle(name, handle_ptr.ref)
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)
286
+ end
287
+
288
+ # Iterates over all available TA-Lib functions
289
+ #
290
+ # @yield [func_info] Yields function information for each function
291
+ # @yieldparam func_info [Fiddle::CStructEntity] Function information struct
292
+ def each_function(&block)
293
+ callback = Fiddle::Closure::BlockCaller.new(
294
+ Fiddle::TYPE_VOID,
295
+ [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
296
+ Fiddle::Function::DEFAULT
297
+ ) do |func_info_ptr, _|
298
+ block.call TA_FuncInfo.new(func_info_ptr)
299
+ end
300
+
301
+ ret_code = TA_ForEachFunc(callback, nil)
302
+ check_ta_return_code(ret_code)
303
+ end
304
+
305
+ # Prints detailed information about a TA-Lib function
306
+ #
307
+ # @param func_info [Fiddle::CStructEntity] Function information struct to print
308
+ def print_function_info(func_info) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
309
+ puts "Function Name: #{func_info["name"]}"
310
+ puts "Function Group: #{func_info["group"]}"
311
+ puts "Function Hint: #{func_info["hint"]}"
312
+ puts "Camel Case Name: #{func_info["camelCaseName"]}"
313
+ puts "Flags: #{func_info["flags"]}"
314
+ puts "Number of Inputs: #{func_info["nbInput"]}"
315
+ puts "Number of Optional Inputs: #{func_info["nbOptInput"]}"
316
+ puts "Number of Outputs: #{func_info["nbOutput"]}"
317
+ puts "Function Handle: #{func_info["handle"].to_i}"
318
+
319
+ puts "\nInput Parameter Info:"
320
+ func_info["nbInput"].times do |i|
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)
325
+ puts " Parameter #{i + 1}:"
326
+ puts " Name: #{param_info["paramName"]}"
327
+ puts " Type: #{param_info["type"]}"
328
+ puts " Flags: #{extract_flags(param_info["flags"], :TA_InputFlags)}"
329
+ end
330
+
331
+ puts "\nOptional Input Parameter Info:"
332
+ func_info["nbOptInput"].times do |i|
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)
337
+ puts " Parameter #{i + 1}:"
338
+ puts " Name: #{param_info["paramName"]}"
339
+ puts " Type: #{param_info["type"]}"
340
+ puts " Flags: #{extract_flags(param_info["flags"], :TA_OptInputFlags)}"
341
+ puts " Display Name: #{param_info["displayName"]}"
342
+ puts " Default Value: #{param_info["defaultValue"]}"
343
+ puts " Hint: #{param_info["hint"]}"
344
+ end
345
+
346
+ puts "\nOutput Parameter Info:"
347
+ func_info["nbOutput"].times do |i|
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)
352
+ puts " Parameter #{i + 1}:"
353
+ puts " Name: #{param_info["paramName"]}"
354
+ puts " Type: #{param_info["type"]}"
355
+ puts " Flags: #{extract_flags(param_info["flags"], :TA_OutputFlags)}"
356
+ end
357
+ end
358
+
359
+ # Calls a TA-Lib function with the given arguments
360
+ #
361
+ # @param func_name [String] The name of the function to call
362
+ # @param args [Array] Array of input arrays and optional parameters
363
+ # @return [Array, Hash] Function results (single array or hash of named outputs)
364
+ # @raise [TALibError] If there is an error in function execution
365
+ def call_func(func_name, args) # rubocop:disable Metrics/MethodLength
366
+ options = args.last.is_a?(Hash) ? args.pop : {}
367
+ input_arrays = args
368
+
369
+ validate_inputs!(input_arrays)
370
+
371
+ handle_ptr = get_function_handle(func_name)
372
+ params_ptr = create_parameter_holder(handle_ptr)
373
+
374
+ begin
375
+ setup_input_parameters(params_ptr, input_arrays, func_name)
376
+ setup_optional_parameters(params_ptr, options, func_name)
377
+ _lookback = calculate_lookback(params_ptr)
378
+ calculate_results(params_ptr, input_arrays, func_name)
379
+ ensure
380
+ TA_ParamHolderFree(params_ptr)
381
+ end
382
+ end
383
+
384
+ # Calculates the lookback period for a function with given parameters
385
+ #
386
+ # @param params_ptr [Fiddle::Pointer] Pointer to parameter holder
387
+ # @return [Integer] The lookback period
388
+ def calculate_lookback(params_ptr)
389
+ lookback_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT)
390
+ ret_code = TA_GetLookback(params_ptr, lookback_ptr)
391
+ check_ta_return_code(ret_code)
392
+ lookback_ptr[0, Fiddle::SIZEOF_INT].unpack1("l")
393
+ end
394
+
395
+ # Validates input arrays for TA-Lib functions
396
+ #
397
+ # @param arrays [Array<Array>] Arrays to validate
398
+ # @raise [TALibError] If any array is invalid
399
+ def validate_inputs!(arrays) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
400
+ raise TALibError, "Input arrays cannot be empty" if arrays.empty?
401
+
402
+ arrays.each do |arr|
403
+ raise TALibError, "Input must be arrays" unless arr.is_a?(Array)
404
+ end
405
+
406
+ sizes = arrays.map(&:length)
407
+ raise TALibError, "Input arrays cannot be empty" if sizes.any?(&:zero?)
408
+
409
+ arrays.each do |arr|
410
+ raise TALibError, "Input arrays must contain only numbers" unless arr.flatten.all? { |x| x.is_a?(Numeric) }
411
+ end
412
+ end
413
+
414
+ # Gets a function handle for a given function name
415
+ #
416
+ # @param func_name [String] The name of the function
417
+ # @return [Fiddle::Pointer] Pointer to function handle
418
+ def get_function_handle(func_name)
419
+ handle_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
420
+ ret_code = TA_GetFuncHandle(func_name, handle_ptr.ref)
421
+ check_ta_return_code(ret_code)
422
+ handle_ptr
423
+ end
424
+
425
+ # Creates a parameter holder for a function
426
+ #
427
+ # @param handle_ptr [Fiddle::Pointer] Function handle pointer
428
+ # @return [Fiddle::Pointer] Pointer to parameter holder
429
+ def create_parameter_holder(handle_ptr)
430
+ params_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
431
+ ret_code = TA_ParamHolderAlloc(handle_ptr, params_ptr.ref)
432
+ check_ta_return_code(ret_code)
433
+ params_ptr
434
+ end
435
+
436
+ # Sets up input parameters for a function call
437
+ #
438
+ # @param params_ptr [Fiddle::Pointer] Parameter holder pointer
439
+ # @param input_arrays [Array<Array>] Input data arrays
440
+ # @param func_name [String] Function name
441
+ def setup_input_parameters(params_ptr, input_arrays, func_name)
442
+ func_info = function_info_map[func_name]
443
+ input_arrays.each_with_index do |array, index|
444
+ input_info = func_info[:inputs][index]
445
+ ret_code = set_input_parameter(params_ptr, index, array, input_info)
446
+ check_ta_return_code(ret_code)
447
+ end
448
+ end
449
+
450
+ # Sets a single input parameter
451
+ #
452
+ # @param params_ptr [Fiddle::Pointer] Parameter holder pointer
453
+ # @param index [Integer] Parameter index
454
+ # @param array [Array] Input data array
455
+ # @param input_info [Hash] Input parameter information
456
+ # @return [Integer] TA-Lib return code
457
+ def set_input_parameter(params_ptr, index, array, input_info)
458
+ case input_info["type"]
459
+ when TA_PARAM_TYPE[:TA_Input_Real]
460
+ input_ptr = prepare_double_array(array)
461
+ TA_SetInputParamRealPtr(params_ptr, index, input_ptr)
462
+ when TA_PARAM_TYPE[:TA_Input_Integer]
463
+ input_ptr = prepare_integer_array(array)
464
+ TA_SetInputParamIntegerPtr(params_ptr, index, input_ptr)
465
+ when TA_PARAM_TYPE[:TA_Input_Price]
466
+ setup_price_inputs(params_ptr, index, array, input_info["flags"])
467
+ end
468
+ end
469
+
470
+ # Prepares a double array for TA-Lib input
471
+ #
472
+ # @param array [Array<Numeric>] Array of numbers to prepare
473
+ # @return [Fiddle::Pointer] Pointer to prepared array
474
+ def prepare_double_array(array)
475
+ array_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE * array.length)
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
480
+ end
481
+
482
+ # Prepares an integer array for TA-Lib input
483
+ #
484
+ # @param array [Array<Numeric>] Array of numbers to prepare
485
+ # @return [Fiddle::Pointer] Pointer to prepared array
486
+ def prepare_integer_array(array)
487
+ array_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT * array.length)
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
492
+ end
493
+
494
+ # Sets up optional parameters for a function call
495
+ #
496
+ # @param params_ptr [Fiddle::Pointer] Parameter holder pointer
497
+ # @param options [Hash] Optional parameters
498
+ # @param func_name [String] Function name
499
+ def setup_optional_parameters(params_ptr, options, func_name)
500
+ func_info = function_info_map[func_name]
501
+ func_info[:opt_inputs]&.each_with_index do |opt_input, index|
502
+ param_name = normalize_parameter_name(opt_input["paramName"].to_s)
503
+ set_optional_parameter(params_ptr, index, options[param_name.to_sym], opt_input["type"]) if options.key?(param_name.to_sym)
504
+ end
505
+ end
506
+
507
+ # Sets a single optional parameter
508
+ #
509
+ # @param params_ptr [Fiddle::Pointer] Parameter holder pointer
510
+ # @param index [Integer] Parameter index
511
+ # @param value [Numeric] Parameter value
512
+ # @param type [Integer] Parameter type
513
+ def set_optional_parameter(params_ptr, index, value, type)
514
+ case type
515
+ when TA_PARAM_TYPE[:TA_OptInput_RealRange], TA_PARAM_TYPE[:TA_OptInput_RealList]
516
+ ret_code = TA_SetOptInputParamReal(params_ptr, index, value)
517
+ when TA_PARAM_TYPE[:TA_OptInput_IntegerRange], TA_PARAM_TYPE[:TA_OptInput_IntegerList]
518
+ ret_code = TA_SetOptInputParamInteger(params_ptr, index, value)
519
+ end
520
+ check_ta_return_code(ret_code)
521
+ end
522
+
523
+ # Calculates function results
524
+ #
525
+ # @param params_ptr [Fiddle::Pointer] Parameter holder pointer
526
+ # @param input_arrays [Array] Input data
527
+ # @param func_name [String] Function name
528
+ # @return [Array, Hash] Function results
529
+ def calculate_results(params_ptr, input_arrays, func_name) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
530
+ func_info = function_info_map[func_name]
531
+ input_size = if func_info[:inputs].first["type"] == TA_PARAM_TYPE[:TA_Input_Price]
532
+ input_arrays[0][0].length
533
+ else
534
+ input_arrays[0].length
535
+ end
536
+
537
+ out_begin = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT)
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
552
+ end
553
+
554
+ # Sets up output buffers for function results
555
+ #
556
+ # @param params_ptr [Fiddle::Pointer] Parameter holder pointer
557
+ # @param size [Integer] Size of output buffer
558
+ # @param func_name [String] Function name
559
+ # @return [Array<Fiddle::Pointer>] Array of output buffer pointers
560
+ def setup_output_buffers(params_ptr, size, func_name) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
561
+ func_info = function_info_map[func_name]
562
+ output_ptrs = []
563
+
564
+ func_info[:outputs].each_with_index do |output, index|
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)
582
+ end
583
+
584
+ output_ptrs
585
+ end
586
+
587
+ # Formats output results from TA-Lib function
588
+ #
589
+ # @param output_ptrs [Array<Fiddle::Pointer>] Array of output buffer pointers
590
+ # @param size [Integer] Size of output data
591
+ # @param func_name [String] Function name
592
+ # @return [Array, Hash] Formatted results
593
+ def format_output_results(output_ptrs, size, func_name) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
594
+ func_info = function_info_map[func_name]
595
+ results = output_ptrs.zip(func_info[:outputs]).map do |ptr, output|
596
+ case output["type"]
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
608
+ end
609
+ output_names.zip(results).to_h
610
+ end
611
+
612
+ # Gets XML description of all TA-Lib functions
613
+ #
614
+ # @return [String] XML function descriptions
615
+ def function_description_xml
616
+ TA_FunctionDescriptionXML().to_s
617
+ end
618
+
619
+ # Gets or builds the function information map
620
+ #
621
+ # @return [Hash] Map of function information
622
+ def function_info_map
623
+ @function_info_map ||= build_function_info_map
624
+ end
625
+
626
+ # Builds a map of function information for all functions
627
+ #
628
+ # @return [Hash] Map of function information
629
+ def build_function_info_map
630
+ info_map = {}
631
+ 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
+ }
638
+ end
639
+ info_map
640
+ end
641
+
642
+ # Collects input parameter information for a function
643
+ #
644
+ # @param func_info [Fiddle::CStructEntity] Function information
645
+ # @return [Array<Fiddle::CStructEntity>] Array of input parameter information
646
+ def collect_input_info(func_info)
647
+ func_info["nbInput"].times.map do |i|
648
+ param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
649
+ TA_GetInputParameterInfo(func_info["handle"], i, param_info_ptr.ref)
650
+ TA_InputParameterInfo.new(param_info_ptr)
651
+ end
652
+ end
653
+
654
+ # Collects optional input parameter information for a function
655
+ #
656
+ # @param func_info [Fiddle::CStructEntity] Function information
657
+ # @return [Array<Fiddle::CStructEntity>] Array of optional input parameter information
658
+ def collect_opt_input_info(func_info)
659
+ func_info["nbOptInput"].times.map do |i|
660
+ param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
661
+ TA_GetOptInputParameterInfo(func_info["handle"], i, param_info_ptr.ref)
662
+ TA_OptInputParameterInfo.new(param_info_ptr)
663
+ end
664
+ end
665
+
666
+ # Collects output parameter information for a function
667
+ #
668
+ # @param func_info [Fiddle::CStructEntity] Function information
669
+ # @return [Array<Fiddle::CStructEntity>] Array of output parameter information
670
+ def collect_output_info(func_info)
671
+ func_info["nbOutput"].times.map do |i|
672
+ param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
673
+ TA_GetOutputParameterInfo(func_info["handle"], i, param_info_ptr.ref)
674
+ TA_OutputParameterInfo.new(param_info_ptr)
675
+ end
676
+ end
677
+
678
+ # Generates Ruby methods for all TA-Lib functions
679
+ #
680
+ # This method iterates through all available TA-Lib functions and creates
681
+ # corresponding Ruby methods with proper documentation.
682
+ def generate_ta_functions
683
+ each_function do |func_info|
684
+ define_ta_function(func_info["name"].to_s.downcase, func_info["name"].to_s)
685
+ end
686
+ end
687
+
688
+ # Normalizes parameter names to Ruby style
689
+ #
690
+ # @param name [String] Parameter name to normalize
691
+ # @return [String] Normalized parameter name
692
+ def normalize_parameter_name(name)
693
+ name.sub(/^(optIn|outReal|outInteger|out|in)/, "")
694
+ .gsub(/::/, "/")
695
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
696
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
697
+ .tr("-", "_")
698
+ .downcase
699
+ end
700
+
701
+ # Checks TA-Lib return codes and raises appropriate errors
702
+ #
703
+ # @param code [Integer] TA-Lib return code
704
+ # @raise [TALibError] If the return code indicates an error
705
+ def check_ta_return_code(code) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
706
+ return if code == TA_SUCCESS
707
+
708
+ error_message = case code
709
+ when TA_LIB_NOT_INITIALIZE
710
+ "TA-Lib not initialized, please call TA_Initialize first"
711
+ when TA_BAD_PARAM
712
+ "Bad parameter, please check input parameters"
713
+ when TA_ALLOC_ERR
714
+ "Memory allocation error, possibly insufficient memory"
715
+ when TA_GROUP_NOT_FOUND
716
+ "Function group not found"
717
+ when TA_FUNC_NOT_FOUND
718
+ "Function not found"
719
+ when TA_INVALID_HANDLE
720
+ "Invalid handle"
721
+ when TA_INVALID_PARAM_HOLDER
722
+ "Invalid parameter holder"
723
+ when TA_INVALID_PARAM_HOLDER_TYPE
724
+ "Invalid parameter holder type"
725
+ when TA_INVALID_PARAM_FUNCTION
726
+ "Invalid parameter function"
727
+ when TA_INPUT_NOT_ALL_INITIALIZE
728
+ "Input parameters not fully initialized"
729
+ when TA_OUTPUT_NOT_ALL_INITIALIZE
730
+ "Output parameters not fully initialized"
731
+ when TA_OUT_OF_RANGE_START_INDEX
732
+ "Start index out of range"
733
+ when TA_OUT_OF_RANGE_END_INDEX
734
+ "End index out of range"
735
+ when TA_INVALID_LIST_TYPE
736
+ "Invalid list type"
737
+ when TA_BAD_OBJECT
738
+ "Invalid object"
739
+ when TA_NOT_SUPPORTED
740
+ "Operation not supported"
741
+ when TA_INTERNAL_ERROR
742
+ "TA-Lib internal error"
743
+ when TA_UNKNOWN_ERR
744
+ "Unknown error"
745
+ else
746
+ "Undefined TA-Lib error (Error code: #{code})"
747
+ end
748
+
749
+ raise TALibError, error_message
750
+ end
751
+
752
+ # Initializes the TA-Lib library
753
+ def initialize_ta_lib
754
+ return if @initialized
755
+
756
+ ret_code = TA_Initialize()
757
+ check_ta_return_code(ret_code)
758
+ at_exit { TA_Shutdown() }
759
+ @initialized = true
760
+ end
761
+
762
+ # Defines a TA-Lib function as a Ruby method with documentation
763
+ #
764
+ # @param method_name [String] Name of the Ruby method to define
765
+ # @param func_name [String] Name of the TA-Lib function
766
+ def define_ta_function(method_name, func_name)
767
+ define_singleton_method(method_name) do |*args|
768
+ call_func(func_name, args)
769
+ end
770
+ end
771
+
772
+ # Sets up price inputs for functions that take price data
773
+ #
774
+ # @param params_ptr [Fiddle::Pointer] Parameter holder pointer
775
+ # @param index [Integer] Parameter index
776
+ # @param price_data [Array] Price data array
777
+ # @param flags [Integer] Input flags
778
+ def setup_price_inputs(params_ptr, index, price_data, flags)
779
+ required_flags = extract_flags(flags, :TA_InputFlags)
780
+ data_pointers = Array.new(6) { Fiddle::Pointer.malloc(0) }
781
+ required_flags.each_with_index do |flag, i|
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)
787
+ end
788
+
789
+ initialize_ta_lib
790
+ generate_ta_functions
791
+
792
+ # Placeholder for generated TA-Lib function documentation.
793
+ # Generated using YARD.
794
+ # Run: rake yard
795
+ class << self
796
+ ### GENERATED DOCUMENTATION START ###
797
+ # @!method accbands(price_hlc, time_period: 20.0)
798
+ # Acceleration Bands
799
+ #
800
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
801
+ # @param time_period [Integer] Number of period (default: 20.0)
802
+ # @return [Hash] Hash containing the following arrays:
803
+ # @option result [Array<Float>] :upper_band Output values
804
+ # @option result [Array<Float>] :middle_band Output values
805
+ # @option result [Array<Float>] :lower_band Output values
806
+ # @raise [TALibError] If there is an error in function execution
807
+
808
+ # @!method acos(real)
809
+ # Vector Trigonometric ACos
810
+ #
811
+ # @param real [Array<Float>] Input values
812
+ # @return [Array<Float>]
813
+ # @raise [TALibError] If there is an error in function execution
814
+
815
+ # @!method ad(price_hlcv)
816
+ # Chaikin A/D Line
817
+ #
818
+ # @param price_hlcv [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close, volume
819
+ # @return [Array<Float>]
820
+ # @raise [TALibError] If there is an error in function execution
821
+
822
+ # @!method add(real0, real1)
823
+ # Vector Arithmetic Add
824
+ #
825
+ # @param real0 [Array<Float>] Input values
826
+ # @param real1 [Array<Float>] Input values
827
+ # @return [Array<Float>]
828
+ # @raise [TALibError] If there is an error in function execution
829
+
830
+ # @!method adosc(price_hlcv, fast_period: 3.0, slow_period: 10.0)
831
+ # Chaikin A/D Oscillator
832
+ #
833
+ # @param price_hlcv [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close, volume
834
+ # @param fast_period [Integer] Number of period for the fast MA (default: 3.0)
835
+ # @param slow_period [Integer] Number of period for the slow MA (default: 10.0)
836
+ # @return [Array<Float>]
837
+ # @raise [TALibError] If there is an error in function execution
838
+
839
+ # @!method adx(price_hlc, time_period: 14.0)
840
+ # Average Directional Movement Index
841
+ #
842
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
843
+ # @param time_period [Integer] Number of period (default: 14.0)
844
+ # @return [Array<Float>]
845
+ # @raise [TALibError] If there is an error in function execution
846
+
847
+ # @!method adxr(price_hlc, time_period: 14.0)
848
+ # Average Directional Movement Index Rating
849
+ #
850
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
851
+ # @param time_period [Integer] Number of period (default: 14.0)
852
+ # @return [Array<Float>]
853
+ # @raise [TALibError] If there is an error in function execution
854
+
855
+ # @!method apo(real, fast_period: 12.0, slow_period: 26.0, ma_type: 0.0)
856
+ # Absolute Price Oscillator
857
+ #
858
+ # @param real [Array<Float>] Input values
859
+ # @param fast_period [Integer] Number of period for the fast MA (default: 12.0)
860
+ # @param slow_period [Integer] Number of period for the slow MA (default: 26.0)
861
+ # @param ma_type [Integer] Type of Moving Average (default: 0.0)
862
+ # @return [Array<Float>]
863
+ # @raise [TALibError] If there is an error in function execution
864
+
865
+ # @!method aroon(price_hl, time_period: 14.0)
866
+ # Aroon
867
+ #
868
+ # @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
869
+ # @param time_period [Integer] Number of period (default: 14.0)
870
+ # @return [Hash] Hash containing the following arrays:
871
+ # @option result [Array<Float>] :aroon_down Output values
872
+ # @option result [Array<Float>] :aroon_up Output values
873
+ # @raise [TALibError] If there is an error in function execution
874
+
875
+ # @!method aroonosc(price_hl, time_period: 14.0)
876
+ # Aroon Oscillator
877
+ #
878
+ # @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
879
+ # @param time_period [Integer] Number of period (default: 14.0)
880
+ # @return [Array<Float>]
881
+ # @raise [TALibError] If there is an error in function execution
882
+
883
+ # @!method asin(real)
884
+ # Vector Trigonometric ASin
885
+ #
886
+ # @param real [Array<Float>] Input values
887
+ # @return [Array<Float>]
888
+ # @raise [TALibError] If there is an error in function execution
889
+
890
+ # @!method atan(real)
891
+ # Vector Trigonometric ATan
892
+ #
893
+ # @param real [Array<Float>] Input values
894
+ # @return [Array<Float>]
895
+ # @raise [TALibError] If there is an error in function execution
896
+
897
+ # @!method atr(price_hlc, time_period: 14.0)
898
+ # Average True Range
899
+ #
900
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
901
+ # @param time_period [Integer] Number of period (default: 14.0)
902
+ # @return [Array<Float>]
903
+ # @raise [TALibError] If there is an error in function execution
904
+
905
+ # @!method avgprice(price_ohlc)
906
+ # Average Price
907
+ #
908
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
909
+ # @return [Array<Float>]
910
+ # @raise [TALibError] If there is an error in function execution
911
+
912
+ # @!method avgdev(real, time_period: 14.0)
913
+ # Average Deviation
914
+ #
915
+ # @param real [Array<Float>] Input values
916
+ # @param time_period [Integer] Number of period (default: 14.0)
917
+ # @return [Array<Float>]
918
+ # @raise [TALibError] If there is an error in function execution
919
+
920
+ # @!method bbands(real, time_period: 5.0, nb_dev_up: 2.0, nb_dev_dn: 2.0, ma_type: 0.0)
921
+ # Bollinger Bands
922
+ #
923
+ # @param real [Array<Float>] Input values
924
+ # @param time_period [Integer] Number of period (default: 5.0)
925
+ # @param nb_dev_up [Float] Deviation multiplier for upper band (default: 2.0)
926
+ # @param nb_dev_dn [Float] Deviation multiplier for lower band (default: 2.0)
927
+ # @param ma_type [Integer] Type of Moving Average (default: 0.0)
928
+ # @return [Hash] Hash containing the following arrays:
929
+ # @option result [Array<Float>] :upper_band Output values
930
+ # @option result [Array<Float>] :middle_band Output values
931
+ # @option result [Array<Float>] :lower_band Output values
932
+ # @raise [TALibError] If there is an error in function execution
933
+
934
+ # @!method beta(real0, real1, time_period: 5.0)
935
+ # Beta
936
+ #
937
+ # @param real0 [Array<Float>] Input values
938
+ # @param real1 [Array<Float>] Input values
939
+ # @param time_period [Integer] Number of period (default: 5.0)
940
+ # @return [Array<Float>]
941
+ # @raise [TALibError] If there is an error in function execution
942
+
943
+ # @!method bop(price_ohlc)
944
+ # Balance Of Power
945
+ #
946
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
947
+ # @return [Array<Float>]
948
+ # @raise [TALibError] If there is an error in function execution
949
+
950
+ # @!method cci(price_hlc, time_period: 14.0)
951
+ # Commodity Channel Index
952
+ #
953
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
954
+ # @param time_period [Integer] Number of period (default: 14.0)
955
+ # @return [Array<Float>]
956
+ # @raise [TALibError] If there is an error in function execution
957
+
958
+ # @!method cdl2crows(price_ohlc)
959
+ # Two Crows
960
+ #
961
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
962
+ # @return [Array<Integer>]
963
+ # @raise [TALibError] If there is an error in function execution
964
+
965
+ # @!method cdl3blackcrows(price_ohlc)
966
+ # Three Black Crows
967
+ #
968
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
969
+ # @return [Array<Integer>]
970
+ # @raise [TALibError] If there is an error in function execution
971
+
972
+ # @!method cdl3inside(price_ohlc)
973
+ # Three Inside Up/Down
974
+ #
975
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
976
+ # @return [Array<Integer>]
977
+ # @raise [TALibError] If there is an error in function execution
978
+
979
+ # @!method cdl3linestrike(price_ohlc)
980
+ # Three-Line Strike
981
+ #
982
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
983
+ # @return [Array<Integer>]
984
+ # @raise [TALibError] If there is an error in function execution
985
+
986
+ # @!method cdl3outside(price_ohlc)
987
+ # Three Outside Up/Down
988
+ #
989
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
990
+ # @return [Array<Integer>]
991
+ # @raise [TALibError] If there is an error in function execution
992
+
993
+ # @!method cdl3starsinsouth(price_ohlc)
994
+ # Three Stars In The South
995
+ #
996
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
997
+ # @return [Array<Integer>]
998
+ # @raise [TALibError] If there is an error in function execution
999
+
1000
+ # @!method cdl3whitesoldiers(price_ohlc)
1001
+ # Three Advancing White Soldiers
1002
+ #
1003
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1004
+ # @return [Array<Integer>]
1005
+ # @raise [TALibError] If there is an error in function execution
1006
+
1007
+ # @!method cdlabandonedbaby(price_ohlc, penetration: 0.3)
1008
+ # Abandoned Baby
1009
+ #
1010
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1011
+ # @param penetration [Float] Percentage of penetration of a candle within another candle (default: 0.3)
1012
+ # @return [Array<Integer>]
1013
+ # @raise [TALibError] If there is an error in function execution
1014
+
1015
+ # @!method cdladvanceblock(price_ohlc)
1016
+ # Advance Block
1017
+ #
1018
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1019
+ # @return [Array<Integer>]
1020
+ # @raise [TALibError] If there is an error in function execution
1021
+
1022
+ # @!method cdlbelthold(price_ohlc)
1023
+ # Belt-hold
1024
+ #
1025
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1026
+ # @return [Array<Integer>]
1027
+ # @raise [TALibError] If there is an error in function execution
1028
+
1029
+ # @!method cdlbreakaway(price_ohlc)
1030
+ # Breakaway
1031
+ #
1032
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1033
+ # @return [Array<Integer>]
1034
+ # @raise [TALibError] If there is an error in function execution
1035
+
1036
+ # @!method cdlclosingmarubozu(price_ohlc)
1037
+ # Closing Marubozu
1038
+ #
1039
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1040
+ # @return [Array<Integer>]
1041
+ # @raise [TALibError] If there is an error in function execution
1042
+
1043
+ # @!method cdlconcealbabyswall(price_ohlc)
1044
+ # Concealing Baby Swallow
1045
+ #
1046
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1047
+ # @return [Array<Integer>]
1048
+ # @raise [TALibError] If there is an error in function execution
1049
+
1050
+ # @!method cdlcounterattack(price_ohlc)
1051
+ # Counterattack
1052
+ #
1053
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1054
+ # @return [Array<Integer>]
1055
+ # @raise [TALibError] If there is an error in function execution
1056
+
1057
+ # @!method cdldarkcloudcover(price_ohlc, penetration: 0.5)
1058
+ # Dark Cloud Cover
1059
+ #
1060
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1061
+ # @param penetration [Float] Percentage of penetration of a candle within another candle (default: 0.5)
1062
+ # @return [Array<Integer>]
1063
+ # @raise [TALibError] If there is an error in function execution
1064
+
1065
+ # @!method cdldoji(price_ohlc)
1066
+ # Doji
1067
+ #
1068
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1069
+ # @return [Array<Integer>]
1070
+ # @raise [TALibError] If there is an error in function execution
1071
+
1072
+ # @!method cdldojistar(price_ohlc)
1073
+ # Doji Star
1074
+ #
1075
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1076
+ # @return [Array<Integer>]
1077
+ # @raise [TALibError] If there is an error in function execution
1078
+
1079
+ # @!method cdldragonflydoji(price_ohlc)
1080
+ # Dragonfly Doji
1081
+ #
1082
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1083
+ # @return [Array<Integer>]
1084
+ # @raise [TALibError] If there is an error in function execution
1085
+
1086
+ # @!method cdlengulfing(price_ohlc)
1087
+ # Engulfing Pattern
1088
+ #
1089
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1090
+ # @return [Array<Integer>]
1091
+ # @raise [TALibError] If there is an error in function execution
1092
+
1093
+ # @!method cdleveningdojistar(price_ohlc, penetration: 0.3)
1094
+ # Evening Doji Star
1095
+ #
1096
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1097
+ # @param penetration [Float] Percentage of penetration of a candle within another candle (default: 0.3)
1098
+ # @return [Array<Integer>]
1099
+ # @raise [TALibError] If there is an error in function execution
1100
+
1101
+ # @!method cdleveningstar(price_ohlc, penetration: 0.3)
1102
+ # Evening Star
1103
+ #
1104
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1105
+ # @param penetration [Float] Percentage of penetration of a candle within another candle (default: 0.3)
1106
+ # @return [Array<Integer>]
1107
+ # @raise [TALibError] If there is an error in function execution
1108
+
1109
+ # @!method cdlgapsidesidewhite(price_ohlc)
1110
+ # Up/Down-gap side-by-side white lines
1111
+ #
1112
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1113
+ # @return [Array<Integer>]
1114
+ # @raise [TALibError] If there is an error in function execution
1115
+
1116
+ # @!method cdlgravestonedoji(price_ohlc)
1117
+ # Gravestone Doji
1118
+ #
1119
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1120
+ # @return [Array<Integer>]
1121
+ # @raise [TALibError] If there is an error in function execution
1122
+
1123
+ # @!method cdlhammer(price_ohlc)
1124
+ # Hammer
1125
+ #
1126
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1127
+ # @return [Array<Integer>]
1128
+ # @raise [TALibError] If there is an error in function execution
1129
+
1130
+ # @!method cdlhangingman(price_ohlc)
1131
+ # Hanging Man
1132
+ #
1133
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1134
+ # @return [Array<Integer>]
1135
+ # @raise [TALibError] If there is an error in function execution
1136
+
1137
+ # @!method cdlharami(price_ohlc)
1138
+ # Harami Pattern
1139
+ #
1140
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1141
+ # @return [Array<Integer>]
1142
+ # @raise [TALibError] If there is an error in function execution
1143
+
1144
+ # @!method cdlharamicross(price_ohlc)
1145
+ # Harami Cross Pattern
1146
+ #
1147
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1148
+ # @return [Array<Integer>]
1149
+ # @raise [TALibError] If there is an error in function execution
1150
+
1151
+ # @!method cdlhighwave(price_ohlc)
1152
+ # High-Wave Candle
1153
+ #
1154
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1155
+ # @return [Array<Integer>]
1156
+ # @raise [TALibError] If there is an error in function execution
1157
+
1158
+ # @!method cdlhikkake(price_ohlc)
1159
+ # Hikkake Pattern
1160
+ #
1161
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1162
+ # @return [Array<Integer>]
1163
+ # @raise [TALibError] If there is an error in function execution
1164
+
1165
+ # @!method cdlhikkakemod(price_ohlc)
1166
+ # Modified Hikkake Pattern
1167
+ #
1168
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1169
+ # @return [Array<Integer>]
1170
+ # @raise [TALibError] If there is an error in function execution
1171
+
1172
+ # @!method cdlhomingpigeon(price_ohlc)
1173
+ # Homing Pigeon
1174
+ #
1175
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1176
+ # @return [Array<Integer>]
1177
+ # @raise [TALibError] If there is an error in function execution
1178
+
1179
+ # @!method cdlidentical3crows(price_ohlc)
1180
+ # Identical Three Crows
1181
+ #
1182
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1183
+ # @return [Array<Integer>]
1184
+ # @raise [TALibError] If there is an error in function execution
1185
+
1186
+ # @!method cdlinneck(price_ohlc)
1187
+ # In-Neck Pattern
1188
+ #
1189
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1190
+ # @return [Array<Integer>]
1191
+ # @raise [TALibError] If there is an error in function execution
1192
+
1193
+ # @!method cdlinvertedhammer(price_ohlc)
1194
+ # Inverted Hammer
1195
+ #
1196
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1197
+ # @return [Array<Integer>]
1198
+ # @raise [TALibError] If there is an error in function execution
1199
+
1200
+ # @!method cdlkicking(price_ohlc)
1201
+ # Kicking
1202
+ #
1203
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1204
+ # @return [Array<Integer>]
1205
+ # @raise [TALibError] If there is an error in function execution
1206
+
1207
+ # @!method cdlkickingbylength(price_ohlc)
1208
+ # Kicking - bull/bear determined by the longer marubozu
1209
+ #
1210
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1211
+ # @return [Array<Integer>]
1212
+ # @raise [TALibError] If there is an error in function execution
1213
+
1214
+ # @!method cdlladderbottom(price_ohlc)
1215
+ # Ladder Bottom
1216
+ #
1217
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1218
+ # @return [Array<Integer>]
1219
+ # @raise [TALibError] If there is an error in function execution
1220
+
1221
+ # @!method cdllongleggeddoji(price_ohlc)
1222
+ # Long Legged Doji
1223
+ #
1224
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1225
+ # @return [Array<Integer>]
1226
+ # @raise [TALibError] If there is an error in function execution
1227
+
1228
+ # @!method cdllongline(price_ohlc)
1229
+ # Long Line Candle
1230
+ #
1231
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1232
+ # @return [Array<Integer>]
1233
+ # @raise [TALibError] If there is an error in function execution
1234
+
1235
+ # @!method cdlmarubozu(price_ohlc)
1236
+ # Marubozu
1237
+ #
1238
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1239
+ # @return [Array<Integer>]
1240
+ # @raise [TALibError] If there is an error in function execution
1241
+
1242
+ # @!method cdlmatchinglow(price_ohlc)
1243
+ # Matching Low
1244
+ #
1245
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1246
+ # @return [Array<Integer>]
1247
+ # @raise [TALibError] If there is an error in function execution
1248
+
1249
+ # @!method cdlmathold(price_ohlc, penetration: 0.5)
1250
+ # Mat Hold
1251
+ #
1252
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1253
+ # @param penetration [Float] Percentage of penetration of a candle within another candle (default: 0.5)
1254
+ # @return [Array<Integer>]
1255
+ # @raise [TALibError] If there is an error in function execution
1256
+
1257
+ # @!method cdlmorningdojistar(price_ohlc, penetration: 0.3)
1258
+ # Morning Doji Star
1259
+ #
1260
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1261
+ # @param penetration [Float] Percentage of penetration of a candle within another candle (default: 0.3)
1262
+ # @return [Array<Integer>]
1263
+ # @raise [TALibError] If there is an error in function execution
1264
+
1265
+ # @!method cdlmorningstar(price_ohlc, penetration: 0.3)
1266
+ # Morning Star
1267
+ #
1268
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1269
+ # @param penetration [Float] Percentage of penetration of a candle within another candle (default: 0.3)
1270
+ # @return [Array<Integer>]
1271
+ # @raise [TALibError] If there is an error in function execution
1272
+
1273
+ # @!method cdlonneck(price_ohlc)
1274
+ # On-Neck Pattern
1275
+ #
1276
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1277
+ # @return [Array<Integer>]
1278
+ # @raise [TALibError] If there is an error in function execution
1279
+
1280
+ # @!method cdlpiercing(price_ohlc)
1281
+ # Piercing Pattern
1282
+ #
1283
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1284
+ # @return [Array<Integer>]
1285
+ # @raise [TALibError] If there is an error in function execution
1286
+
1287
+ # @!method cdlrickshawman(price_ohlc)
1288
+ # Rickshaw Man
1289
+ #
1290
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1291
+ # @return [Array<Integer>]
1292
+ # @raise [TALibError] If there is an error in function execution
1293
+
1294
+ # @!method cdlrisefall3methods(price_ohlc)
1295
+ # Rising/Falling Three Methods
1296
+ #
1297
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1298
+ # @return [Array<Integer>]
1299
+ # @raise [TALibError] If there is an error in function execution
1300
+
1301
+ # @!method cdlseparatinglines(price_ohlc)
1302
+ # Separating Lines
1303
+ #
1304
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1305
+ # @return [Array<Integer>]
1306
+ # @raise [TALibError] If there is an error in function execution
1307
+
1308
+ # @!method cdlshootingstar(price_ohlc)
1309
+ # Shooting Star
1310
+ #
1311
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1312
+ # @return [Array<Integer>]
1313
+ # @raise [TALibError] If there is an error in function execution
1314
+
1315
+ # @!method cdlshortline(price_ohlc)
1316
+ # Short Line Candle
1317
+ #
1318
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1319
+ # @return [Array<Integer>]
1320
+ # @raise [TALibError] If there is an error in function execution
1321
+
1322
+ # @!method cdlspinningtop(price_ohlc)
1323
+ # Spinning Top
1324
+ #
1325
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1326
+ # @return [Array<Integer>]
1327
+ # @raise [TALibError] If there is an error in function execution
1328
+
1329
+ # @!method cdlstalledpattern(price_ohlc)
1330
+ # Stalled Pattern
1331
+ #
1332
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1333
+ # @return [Array<Integer>]
1334
+ # @raise [TALibError] If there is an error in function execution
1335
+
1336
+ # @!method cdlsticksandwich(price_ohlc)
1337
+ # Stick Sandwich
1338
+ #
1339
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1340
+ # @return [Array<Integer>]
1341
+ # @raise [TALibError] If there is an error in function execution
1342
+
1343
+ # @!method cdltakuri(price_ohlc)
1344
+ # Takuri (Dragonfly Doji with very long lower shadow)
1345
+ #
1346
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1347
+ # @return [Array<Integer>]
1348
+ # @raise [TALibError] If there is an error in function execution
1349
+
1350
+ # @!method cdltasukigap(price_ohlc)
1351
+ # Tasuki Gap
1352
+ #
1353
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1354
+ # @return [Array<Integer>]
1355
+ # @raise [TALibError] If there is an error in function execution
1356
+
1357
+ # @!method cdlthrusting(price_ohlc)
1358
+ # Thrusting Pattern
1359
+ #
1360
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1361
+ # @return [Array<Integer>]
1362
+ # @raise [TALibError] If there is an error in function execution
1363
+
1364
+ # @!method cdltristar(price_ohlc)
1365
+ # Tristar Pattern
1366
+ #
1367
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1368
+ # @return [Array<Integer>]
1369
+ # @raise [TALibError] If there is an error in function execution
1370
+
1371
+ # @!method cdlunique3river(price_ohlc)
1372
+ # Unique 3 River
1373
+ #
1374
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1375
+ # @return [Array<Integer>]
1376
+ # @raise [TALibError] If there is an error in function execution
1377
+
1378
+ # @!method cdlupsidegap2crows(price_ohlc)
1379
+ # Upside Gap Two Crows
1380
+ #
1381
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1382
+ # @return [Array<Integer>]
1383
+ # @raise [TALibError] If there is an error in function execution
1384
+
1385
+ # @!method cdlxsidegap3methods(price_ohlc)
1386
+ # Upside/Downside Gap Three Methods
1387
+ #
1388
+ # @param price_ohlc [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: open, high, low, close
1389
+ # @return [Array<Integer>]
1390
+ # @raise [TALibError] If there is an error in function execution
1391
+
1392
+ # @!method ceil(real)
1393
+ # Vector Ceil
1394
+ #
1395
+ # @param real [Array<Float>] Input values
1396
+ # @return [Array<Float>]
1397
+ # @raise [TALibError] If there is an error in function execution
1398
+
1399
+ # @!method cmo(real, time_period: 14.0)
1400
+ # Chande Momentum Oscillator
1401
+ #
1402
+ # @param real [Array<Float>] Input values
1403
+ # @param time_period [Integer] Number of period (default: 14.0)
1404
+ # @return [Array<Float>]
1405
+ # @raise [TALibError] If there is an error in function execution
1406
+
1407
+ # @!method correl(real0, real1, time_period: 30.0)
1408
+ # Pearson's Correlation Coefficient (r)
1409
+ #
1410
+ # @param real0 [Array<Float>] Input values
1411
+ # @param real1 [Array<Float>] Input values
1412
+ # @param time_period [Integer] Number of period (default: 30.0)
1413
+ # @return [Array<Float>]
1414
+ # @raise [TALibError] If there is an error in function execution
1415
+
1416
+ # @!method cos(real)
1417
+ # Vector Trigonometric Cos
1418
+ #
1419
+ # @param real [Array<Float>] Input values
1420
+ # @return [Array<Float>]
1421
+ # @raise [TALibError] If there is an error in function execution
1422
+
1423
+ # @!method cosh(real)
1424
+ # Vector Trigonometric Cosh
1425
+ #
1426
+ # @param real [Array<Float>] Input values
1427
+ # @return [Array<Float>]
1428
+ # @raise [TALibError] If there is an error in function execution
1429
+
1430
+ # @!method dema(real, time_period: 30.0)
1431
+ # Double Exponential Moving Average
1432
+ #
1433
+ # @param real [Array<Float>] Input values
1434
+ # @param time_period [Integer] Number of period (default: 30.0)
1435
+ # @return [Array<Float>]
1436
+ # @raise [TALibError] If there is an error in function execution
1437
+
1438
+ # @!method div(real0, real1)
1439
+ # Vector Arithmetic Div
1440
+ #
1441
+ # @param real0 [Array<Float>] Input values
1442
+ # @param real1 [Array<Float>] Input values
1443
+ # @return [Array<Float>]
1444
+ # @raise [TALibError] If there is an error in function execution
1445
+
1446
+ # @!method dx(price_hlc, time_period: 14.0)
1447
+ # Directional Movement Index
1448
+ #
1449
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
1450
+ # @param time_period [Integer] Number of period (default: 14.0)
1451
+ # @return [Array<Float>]
1452
+ # @raise [TALibError] If there is an error in function execution
1453
+
1454
+ # @!method ema(real, time_period: 30.0)
1455
+ # Exponential Moving Average
1456
+ #
1457
+ # @param real [Array<Float>] Input values
1458
+ # @param time_period [Integer] Number of period (default: 30.0)
1459
+ # @return [Array<Float>]
1460
+ # @raise [TALibError] If there is an error in function execution
1461
+
1462
+ # @!method exp(real)
1463
+ # Vector Arithmetic Exp
1464
+ #
1465
+ # @param real [Array<Float>] Input values
1466
+ # @return [Array<Float>]
1467
+ # @raise [TALibError] If there is an error in function execution
1468
+
1469
+ # @!method floor(real)
1470
+ # Vector Floor
1471
+ #
1472
+ # @param real [Array<Float>] Input values
1473
+ # @return [Array<Float>]
1474
+ # @raise [TALibError] If there is an error in function execution
1475
+
1476
+ # @!method ht_dcperiod(real)
1477
+ # Hilbert Transform - Dominant Cycle Period
1478
+ #
1479
+ # @param real [Array<Float>] Input values
1480
+ # @return [Array<Float>]
1481
+ # @raise [TALibError] If there is an error in function execution
1482
+
1483
+ # @!method ht_dcphase(real)
1484
+ # Hilbert Transform - Dominant Cycle Phase
1485
+ #
1486
+ # @param real [Array<Float>] Input values
1487
+ # @return [Array<Float>]
1488
+ # @raise [TALibError] If there is an error in function execution
1489
+
1490
+ # @!method ht_phasor(real)
1491
+ # Hilbert Transform - Phasor Components
1492
+ #
1493
+ # @param real [Array<Float>] Input values
1494
+ # @return [Hash] Hash containing the following arrays:
1495
+ # @option result [Array<Float>] :in_phase Output values
1496
+ # @option result [Array<Float>] :quadrature Output values
1497
+ # @raise [TALibError] If there is an error in function execution
1498
+
1499
+ # @!method ht_sine(real)
1500
+ # Hilbert Transform - SineWave
1501
+ #
1502
+ # @param real [Array<Float>] Input values
1503
+ # @return [Hash] Hash containing the following arrays:
1504
+ # @option result [Array<Float>] :sine Output values
1505
+ # @option result [Array<Float>] :lead_sine Output values
1506
+ # @raise [TALibError] If there is an error in function execution
1507
+
1508
+ # @!method ht_trendline(real)
1509
+ # Hilbert Transform - Instantaneous Trendline
1510
+ #
1511
+ # @param real [Array<Float>] Input values
1512
+ # @return [Array<Float>]
1513
+ # @raise [TALibError] If there is an error in function execution
1514
+
1515
+ # @!method ht_trendmode(real)
1516
+ # Hilbert Transform - Trend vs Cycle Mode
1517
+ #
1518
+ # @param real [Array<Float>] Input values
1519
+ # @return [Array<Integer>]
1520
+ # @raise [TALibError] If there is an error in function execution
1521
+
1522
+ # @!method imi(price_oc, time_period: 14.0)
1523
+ # Intraday Momentum Index
1524
+ #
1525
+ # @param price_oc [Array(Array<Float>, Array<Float>)] Required price arrays: open, close
1526
+ # @param time_period [Integer] Number of period (default: 14.0)
1527
+ # @return [Array<Float>]
1528
+ # @raise [TALibError] If there is an error in function execution
1529
+
1530
+ # @!method kama(real, time_period: 30.0)
1531
+ # Kaufman Adaptive Moving Average
1532
+ #
1533
+ # @param real [Array<Float>] Input values
1534
+ # @param time_period [Integer] Number of period (default: 30.0)
1535
+ # @return [Array<Float>]
1536
+ # @raise [TALibError] If there is an error in function execution
1537
+
1538
+ # @!method linearreg(real, time_period: 14.0)
1539
+ # Linear Regression
1540
+ #
1541
+ # @param real [Array<Float>] Input values
1542
+ # @param time_period [Integer] Number of period (default: 14.0)
1543
+ # @return [Array<Float>]
1544
+ # @raise [TALibError] If there is an error in function execution
1545
+
1546
+ # @!method linearreg_angle(real, time_period: 14.0)
1547
+ # Linear Regression Angle
1548
+ #
1549
+ # @param real [Array<Float>] Input values
1550
+ # @param time_period [Integer] Number of period (default: 14.0)
1551
+ # @return [Array<Float>]
1552
+ # @raise [TALibError] If there is an error in function execution
1553
+
1554
+ # @!method linearreg_intercept(real, time_period: 14.0)
1555
+ # Linear Regression Intercept
1556
+ #
1557
+ # @param real [Array<Float>] Input values
1558
+ # @param time_period [Integer] Number of period (default: 14.0)
1559
+ # @return [Array<Float>]
1560
+ # @raise [TALibError] If there is an error in function execution
1561
+
1562
+ # @!method linearreg_slope(real, time_period: 14.0)
1563
+ # Linear Regression Slope
1564
+ #
1565
+ # @param real [Array<Float>] Input values
1566
+ # @param time_period [Integer] Number of period (default: 14.0)
1567
+ # @return [Array<Float>]
1568
+ # @raise [TALibError] If there is an error in function execution
1569
+
1570
+ # @!method ln(real)
1571
+ # Vector Log Natural
1572
+ #
1573
+ # @param real [Array<Float>] Input values
1574
+ # @return [Array<Float>]
1575
+ # @raise [TALibError] If there is an error in function execution
1576
+
1577
+ # @!method log10(real)
1578
+ # Vector Log10
1579
+ #
1580
+ # @param real [Array<Float>] Input values
1581
+ # @return [Array<Float>]
1582
+ # @raise [TALibError] If there is an error in function execution
1583
+
1584
+ # @!method ma(real, time_period: 30.0, ma_type: 0.0)
1585
+ # Moving average
1586
+ #
1587
+ # @param real [Array<Float>] Input values
1588
+ # @param time_period [Integer] Number of period (default: 30.0)
1589
+ # @param ma_type [Integer] Type of Moving Average (default: 0.0)
1590
+ # @return [Array<Float>]
1591
+ # @raise [TALibError] If there is an error in function execution
1592
+
1593
+ # @!method macd(real, fast_period: 12.0, slow_period: 26.0, signal_period: 9.0)
1594
+ # Moving Average Convergence/Divergence
1595
+ #
1596
+ # @param real [Array<Float>] Input values
1597
+ # @param fast_period [Integer] Number of period for the fast MA (default: 12.0)
1598
+ # @param slow_period [Integer] Number of period for the slow MA (default: 26.0)
1599
+ # @param signal_period [Integer] Smoothing for the signal line (nb of period) (default: 9.0)
1600
+ # @return [Hash] Hash containing the following arrays:
1601
+ # @option result [Array<Float>] :macd Output values
1602
+ # @option result [Array<Float>] :macd_signal Output values
1603
+ # @option result [Array<Float>] :macd_hist Output values
1604
+ # @raise [TALibError] If there is an error in function execution
1605
+
1606
+ # @!method macdext(real, fast_period: 12.0, fast_ma_type: 0.0, slow_period: 26.0, slow_ma_type: 0.0, signal_period: 9.0, signal_ma_type: 0.0)
1607
+ # MACD with controllable MA type
1608
+ #
1609
+ # @param real [Array<Float>] Input values
1610
+ # @param fast_period [Integer] Number of period for the fast MA (default: 12.0)
1611
+ # @param fast_ma_type [Integer] Type of Moving Average for fast MA (default: 0.0)
1612
+ # @param slow_period [Integer] Number of period for the slow MA (default: 26.0)
1613
+ # @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 (nb of period) (default: 9.0)
1615
+ # @param signal_ma_type [Integer] Type of Moving Average for signal line (default: 0.0)
1616
+ # @return [Hash] Hash containing the following arrays:
1617
+ # @option result [Array<Float>] :macd Output values
1618
+ # @option result [Array<Float>] :macd_signal Output values
1619
+ # @option result [Array<Float>] :macd_hist Output values
1620
+ # @raise [TALibError] If there is an error in function execution
1621
+
1622
+ # @!method macdfix(real, signal_period: 9.0)
1623
+ # Moving Average Convergence/Divergence Fix 12/26
1624
+ #
1625
+ # @param real [Array<Float>] Input values
1626
+ # @param signal_period [Integer] Smoothing for the signal line (nb of period) (default: 9.0)
1627
+ # @return [Hash] Hash containing the following arrays:
1628
+ # @option result [Array<Float>] :macd Output values
1629
+ # @option result [Array<Float>] :macd_signal Output values
1630
+ # @option result [Array<Float>] :macd_hist Output values
1631
+ # @raise [TALibError] If there is an error in function execution
1632
+
1633
+ # @!method mama(real, fast_limit: 0.5, slow_limit: 0.05)
1634
+ # MESA Adaptive Moving Average
1635
+ #
1636
+ # @param real [Array<Float>] Input values
1637
+ # @param fast_limit [Float] Upper limit use in the adaptive algorithm (default: 0.5)
1638
+ # @param slow_limit [Float] Lower limit use in the adaptive algorithm (default: 0.05)
1639
+ # @return [Hash] Hash containing the following arrays:
1640
+ # @option result [Array<Float>] :mama Output values
1641
+ # @option result [Array<Float>] :fama Output values
1642
+ # @raise [TALibError] If there is an error in function execution
1643
+
1644
+ # @!method mavp(real, periods, min_period: 2.0, max_period: 30.0, ma_type: 0.0)
1645
+ # Moving average with variable period
1646
+ #
1647
+ # @param real [Array<Float>] Input values
1648
+ # @param periods [Array<Float>] Input values
1649
+ # @param min_period [Integer] Value less than minimum will be changed to Minimum period (default: 2.0)
1650
+ # @param max_period [Integer] Value higher than maximum will be changed to Maximum period (default: 30.0)
1651
+ # @param ma_type [Integer] Type of Moving Average (default: 0.0)
1652
+ # @return [Array<Float>]
1653
+ # @raise [TALibError] If there is an error in function execution
1654
+
1655
+ # @!method max(real, time_period: 30.0)
1656
+ # Highest value over a specified period
1657
+ #
1658
+ # @param real [Array<Float>] Input values
1659
+ # @param time_period [Integer] Number of period (default: 30.0)
1660
+ # @return [Array<Float>]
1661
+ # @raise [TALibError] If there is an error in function execution
1662
+
1663
+ # @!method maxindex(real, time_period: 30.0)
1664
+ # Index of highest value over a specified period
1665
+ #
1666
+ # @param real [Array<Float>] Input values
1667
+ # @param time_period [Integer] Number of period (default: 30.0)
1668
+ # @return [Array<Integer>]
1669
+ # @raise [TALibError] If there is an error in function execution
1670
+
1671
+ # @!method medprice(price_hl)
1672
+ # Median Price
1673
+ #
1674
+ # @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
1675
+ # @return [Array<Float>]
1676
+ # @raise [TALibError] If there is an error in function execution
1677
+
1678
+ # @!method mfi(price_hlcv, time_period: 14.0)
1679
+ # Money Flow Index
1680
+ #
1681
+ # @param price_hlcv [Array(Array<Float>, Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close, volume
1682
+ # @param time_period [Integer] Number of period (default: 14.0)
1683
+ # @return [Array<Float>]
1684
+ # @raise [TALibError] If there is an error in function execution
1685
+
1686
+ # @!method midpoint(real, time_period: 14.0)
1687
+ # MidPoint over period
1688
+ #
1689
+ # @param real [Array<Float>] Input values
1690
+ # @param time_period [Integer] Number of period (default: 14.0)
1691
+ # @return [Array<Float>]
1692
+ # @raise [TALibError] If there is an error in function execution
1693
+
1694
+ # @!method midprice(price_hl, time_period: 14.0)
1695
+ # Midpoint Price over period
1696
+ #
1697
+ # @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
1698
+ # @param time_period [Integer] Number of period (default: 14.0)
1699
+ # @return [Array<Float>]
1700
+ # @raise [TALibError] If there is an error in function execution
1701
+
1702
+ # @!method min(real, time_period: 30.0)
1703
+ # Lowest value over a specified period
1704
+ #
1705
+ # @param real [Array<Float>] Input values
1706
+ # @param time_period [Integer] Number of period (default: 30.0)
1707
+ # @return [Array<Float>]
1708
+ # @raise [TALibError] If there is an error in function execution
1709
+
1710
+ # @!method minindex(real, time_period: 30.0)
1711
+ # Index of lowest value over a specified period
1712
+ #
1713
+ # @param real [Array<Float>] Input values
1714
+ # @param time_period [Integer] Number of period (default: 30.0)
1715
+ # @return [Array<Integer>]
1716
+ # @raise [TALibError] If there is an error in function execution
1717
+
1718
+ # @!method minmax(real, time_period: 30.0)
1719
+ # Lowest and highest values over a specified period
1720
+ #
1721
+ # @param real [Array<Float>] Input values
1722
+ # @param time_period [Integer] Number of period (default: 30.0)
1723
+ # @return [Hash] Hash containing the following arrays:
1724
+ # @option result [Array<Float>] :min Output values
1725
+ # @option result [Array<Float>] :max Output values
1726
+ # @raise [TALibError] If there is an error in function execution
1727
+
1728
+ # @!method minmaxindex(real, time_period: 30.0)
1729
+ # Indexes of lowest and highest values over a specified period
1730
+ #
1731
+ # @param real [Array<Float>] Input values
1732
+ # @param time_period [Integer] Number of period (default: 30.0)
1733
+ # @return [Hash] Hash containing the following arrays:
1734
+ # @option result [Array<Integer>] :min_idx Output values
1735
+ # @option result [Array<Integer>] :max_idx Output values
1736
+ # @raise [TALibError] If there is an error in function execution
1737
+
1738
+ # @!method minus_di(price_hlc, time_period: 14.0)
1739
+ # Minus Directional Indicator
1740
+ #
1741
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
1742
+ # @param time_period [Integer] Number of period (default: 14.0)
1743
+ # @return [Array<Float>]
1744
+ # @raise [TALibError] If there is an error in function execution
1745
+
1746
+ # @!method minus_dm(price_hl, time_period: 14.0)
1747
+ # Minus Directional Movement
1748
+ #
1749
+ # @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
1750
+ # @param time_period [Integer] Number of period (default: 14.0)
1751
+ # @return [Array<Float>]
1752
+ # @raise [TALibError] If there is an error in function execution
1753
+
1754
+ # @!method mom(real, time_period: 10.0)
1755
+ # Momentum
1756
+ #
1757
+ # @param real [Array<Float>] Input values
1758
+ # @param time_period [Integer] Number of period (default: 10.0)
1759
+ # @return [Array<Float>]
1760
+ # @raise [TALibError] If there is an error in function execution
1761
+
1762
+ # @!method mult(real0, real1)
1763
+ # Vector Arithmetic Mult
1764
+ #
1765
+ # @param real0 [Array<Float>] Input values
1766
+ # @param real1 [Array<Float>] Input values
1767
+ # @return [Array<Float>]
1768
+ # @raise [TALibError] If there is an error in function execution
1769
+
1770
+ # @!method natr(price_hlc, time_period: 14.0)
1771
+ # Normalized Average True Range
1772
+ #
1773
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
1774
+ # @param time_period [Integer] Number of period (default: 14.0)
1775
+ # @return [Array<Float>]
1776
+ # @raise [TALibError] If there is an error in function execution
1777
+
1778
+ # @!method obv(real, price_v)
1779
+ # On Balance Volume
1780
+ #
1781
+ # @param real [Array<Float>] Input values
1782
+ # @param price_v [Array(Array<Float>)] Required price arrays: volume
1783
+ # @return [Array<Float>]
1784
+ # @raise [TALibError] If there is an error in function execution
1785
+
1786
+ # @!method plus_di(price_hlc, time_period: 14.0)
1787
+ # Plus Directional Indicator
1788
+ #
1789
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
1790
+ # @param time_period [Integer] Number of period (default: 14.0)
1791
+ # @return [Array<Float>]
1792
+ # @raise [TALibError] If there is an error in function execution
1793
+
1794
+ # @!method plus_dm(price_hl, time_period: 14.0)
1795
+ # Plus Directional Movement
1796
+ #
1797
+ # @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
1798
+ # @param time_period [Integer] Number of period (default: 14.0)
1799
+ # @return [Array<Float>]
1800
+ # @raise [TALibError] If there is an error in function execution
1801
+
1802
+ # @!method ppo(real, fast_period: 12.0, slow_period: 26.0, ma_type: 0.0)
1803
+ # Percentage Price Oscillator
1804
+ #
1805
+ # @param real [Array<Float>] Input values
1806
+ # @param fast_period [Integer] Number of period for the fast MA (default: 12.0)
1807
+ # @param slow_period [Integer] Number of period for the slow MA (default: 26.0)
1808
+ # @param ma_type [Integer] Type of Moving Average (default: 0.0)
1809
+ # @return [Array<Float>]
1810
+ # @raise [TALibError] If there is an error in function execution
1811
+
1812
+ # @!method roc(real, time_period: 10.0)
1813
+ # Rate of change : ((price/prevPrice)-1)*100
1814
+ #
1815
+ # @param real [Array<Float>] Input values
1816
+ # @param time_period [Integer] Number of period (default: 10.0)
1817
+ # @return [Array<Float>]
1818
+ # @raise [TALibError] If there is an error in function execution
1819
+
1820
+ # @!method rocp(real, time_period: 10.0)
1821
+ # Rate of change Percentage: (price-prevPrice)/prevPrice
1822
+ #
1823
+ # @param real [Array<Float>] Input values
1824
+ # @param time_period [Integer] Number of period (default: 10.0)
1825
+ # @return [Array<Float>]
1826
+ # @raise [TALibError] If there is an error in function execution
1827
+
1828
+ # @!method rocr(real, time_period: 10.0)
1829
+ # Rate of change ratio: (price/prevPrice)
1830
+ #
1831
+ # @param real [Array<Float>] Input values
1832
+ # @param time_period [Integer] Number of period (default: 10.0)
1833
+ # @return [Array<Float>]
1834
+ # @raise [TALibError] If there is an error in function execution
1835
+
1836
+ # @!method rocr100(real, time_period: 10.0)
1837
+ # Rate of change ratio 100 scale: (price/prevPrice)*100
1838
+ #
1839
+ # @param real [Array<Float>] Input values
1840
+ # @param time_period [Integer] Number of period (default: 10.0)
1841
+ # @return [Array<Float>]
1842
+ # @raise [TALibError] If there is an error in function execution
1843
+
1844
+ # @!method rsi(real, time_period: 14.0)
1845
+ # Relative Strength Index
1846
+ #
1847
+ # @param real [Array<Float>] Input values
1848
+ # @param time_period [Integer] Number of period (default: 14.0)
1849
+ # @return [Array<Float>]
1850
+ # @raise [TALibError] If there is an error in function execution
1851
+
1852
+ # @!method sar(price_hl, acceleration: 0.02, maximum: 0.2)
1853
+ # Parabolic SAR
1854
+ #
1855
+ # @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
1856
+ # @param acceleration [Float] Acceleration Factor used up to the Maximum value (default: 0.02)
1857
+ # @param maximum [Float] Acceleration Factor Maximum value (default: 0.2)
1858
+ # @return [Array<Float>]
1859
+ # @raise [TALibError] If there is an error in function execution
1860
+
1861
+ # @!method sarext(price_hl, start_value: 0.0, offset_on_reverse: 0.0, acceleration_init_long: 0.02, acceleration_long: 0.02, acceleration_max_long: 0.2, acceleration_init_short: 0.02, acceleration_short: 0.02, acceleration_max_short: 0.2)
1862
+ # Parabolic SAR - Extended
1863
+ #
1864
+ # @param price_hl [Array(Array<Float>, Array<Float>)] Required price arrays: high, low
1865
+ # @param start_value [Float] Start value and direction. 0 for Auto, >0 for Long, <0 for Short (default: 0.0)
1866
+ # @param offset_on_reverse [Float] Percent offset added/removed to initial stop on short/long reversal (default: 0.0)
1867
+ # @param acceleration_init_long [Float] Acceleration Factor initial value for the Long direction (default: 0.02)
1868
+ # @param acceleration_long [Float] Acceleration Factor for the Long direction (default: 0.02)
1869
+ # @param acceleration_max_long [Float] Acceleration Factor maximum value for the Long direction (default: 0.2)
1870
+ # @param acceleration_init_short [Float] Acceleration Factor initial value for the Short direction (default: 0.02)
1871
+ # @param acceleration_short [Float] Acceleration Factor for the Short direction (default: 0.02)
1872
+ # @param acceleration_max_short [Float] Acceleration Factor maximum value for the Short direction (default: 0.2)
1873
+ # @return [Array<Float>]
1874
+ # @raise [TALibError] If there is an error in function execution
1875
+
1876
+ # @!method sin(real)
1877
+ # Vector Trigonometric Sin
1878
+ #
1879
+ # @param real [Array<Float>] Input values
1880
+ # @return [Array<Float>]
1881
+ # @raise [TALibError] If there is an error in function execution
1882
+
1883
+ # @!method sinh(real)
1884
+ # Vector Trigonometric Sinh
1885
+ #
1886
+ # @param real [Array<Float>] Input values
1887
+ # @return [Array<Float>]
1888
+ # @raise [TALibError] If there is an error in function execution
1889
+
1890
+ # @!method sma(real, time_period: 30.0)
1891
+ # Simple Moving Average
1892
+ #
1893
+ # @param real [Array<Float>] Input values
1894
+ # @param time_period [Integer] Number of period (default: 30.0)
1895
+ # @return [Array<Float>]
1896
+ # @raise [TALibError] If there is an error in function execution
1897
+
1898
+ # @!method sqrt(real)
1899
+ # Vector Square Root
1900
+ #
1901
+ # @param real [Array<Float>] Input values
1902
+ # @return [Array<Float>]
1903
+ # @raise [TALibError] If there is an error in function execution
1904
+
1905
+ # @!method stddev(real, time_period: 5.0, nb_dev: 1.0)
1906
+ # Standard Deviation
1907
+ #
1908
+ # @param real [Array<Float>] Input values
1909
+ # @param time_period [Integer] Number of period (default: 5.0)
1910
+ # @param nb_dev [Float] Nb of deviations (default: 1.0)
1911
+ # @return [Array<Float>]
1912
+ # @raise [TALibError] If there is an error in function execution
1913
+
1914
+ # @!method stoch(price_hlc, fast_k_period: 5.0, slow_k_period: 3.0, slow_k_ma_type: 0.0, slow_d_period: 3.0, slow_d_ma_type: 0.0)
1915
+ # Stochastic
1916
+ #
1917
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
1918
+ # @param fast_k_period [Integer] Time period for building the Fast-K line (default: 5.0)
1919
+ # @param slow_k_period [Integer] Smoothing for making the Slow-K line. Usually set to 3 (default: 3.0)
1920
+ # @param slow_k_ma_type [Integer] Type of Moving Average for Slow-K (default: 0.0)
1921
+ # @param slow_d_period [Integer] Smoothing for making the Slow-D line (default: 3.0)
1922
+ # @param slow_d_ma_type [Integer] Type of Moving Average for Slow-D (default: 0.0)
1923
+ # @return [Hash] Hash containing the following arrays:
1924
+ # @option result [Array<Float>] :slow_k Output values
1925
+ # @option result [Array<Float>] :slow_d Output values
1926
+ # @raise [TALibError] If there is an error in function execution
1927
+
1928
+ # @!method stochf(price_hlc, fast_k_period: 5.0, fast_d_period: 3.0, fast_d_ma_type: 0.0)
1929
+ # Stochastic Fast
1930
+ #
1931
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
1932
+ # @param fast_k_period [Integer] Time period for building the Fast-K line (default: 5.0)
1933
+ # @param fast_d_period [Integer] Smoothing for making the Fast-D line. Usually set to 3 (default: 3.0)
1934
+ # @param fast_d_ma_type [Integer] Type of Moving Average for Fast-D (default: 0.0)
1935
+ # @return [Hash] Hash containing the following arrays:
1936
+ # @option result [Array<Float>] :fast_k Output values
1937
+ # @option result [Array<Float>] :fast_d Output values
1938
+ # @raise [TALibError] If there is an error in function execution
1939
+
1940
+ # @!method stochrsi(real, time_period: 14.0, fast_k_period: 5.0, fast_d_period: 3.0, fast_d_ma_type: 0.0)
1941
+ # Stochastic Relative Strength Index
1942
+ #
1943
+ # @param real [Array<Float>] Input values
1944
+ # @param time_period [Integer] Number of period (default: 14.0)
1945
+ # @param fast_k_period [Integer] Time period for building the Fast-K line (default: 5.0)
1946
+ # @param fast_d_period [Integer] Smoothing for making the Fast-D line. Usually set to 3 (default: 3.0)
1947
+ # @param fast_d_ma_type [Integer] Type of Moving Average for Fast-D (default: 0.0)
1948
+ # @return [Hash] Hash containing the following arrays:
1949
+ # @option result [Array<Float>] :fast_k Output values
1950
+ # @option result [Array<Float>] :fast_d Output values
1951
+ # @raise [TALibError] If there is an error in function execution
1952
+
1953
+ # @!method sub(real0, real1)
1954
+ # Vector Arithmetic Subtraction
1955
+ #
1956
+ # @param real0 [Array<Float>] Input values
1957
+ # @param real1 [Array<Float>] Input values
1958
+ # @return [Array<Float>]
1959
+ # @raise [TALibError] If there is an error in function execution
1960
+
1961
+ # @!method sum(real, time_period: 30.0)
1962
+ # Summation
1963
+ #
1964
+ # @param real [Array<Float>] Input values
1965
+ # @param time_period [Integer] Number of period (default: 30.0)
1966
+ # @return [Array<Float>]
1967
+ # @raise [TALibError] If there is an error in function execution
1968
+
1969
+ # @!method t3(real, time_period: 5.0, v_factor: 0.7)
1970
+ # Triple Exponential Moving Average (T3)
1971
+ #
1972
+ # @param real [Array<Float>] Input values
1973
+ # @param time_period [Integer] Number of period (default: 5.0)
1974
+ # @param v_factor [Float] Volume Factor (default: 0.7)
1975
+ # @return [Array<Float>]
1976
+ # @raise [TALibError] If there is an error in function execution
1977
+
1978
+ # @!method tan(real)
1979
+ # Vector Trigonometric Tan
1980
+ #
1981
+ # @param real [Array<Float>] Input values
1982
+ # @return [Array<Float>]
1983
+ # @raise [TALibError] If there is an error in function execution
1984
+
1985
+ # @!method tanh(real)
1986
+ # Vector Trigonometric Tanh
1987
+ #
1988
+ # @param real [Array<Float>] Input values
1989
+ # @return [Array<Float>]
1990
+ # @raise [TALibError] If there is an error in function execution
1991
+
1992
+ # @!method tema(real, time_period: 30.0)
1993
+ # Triple Exponential Moving Average
1994
+ #
1995
+ # @param real [Array<Float>] Input values
1996
+ # @param time_period [Integer] Number of period (default: 30.0)
1997
+ # @return [Array<Float>]
1998
+ # @raise [TALibError] If there is an error in function execution
1999
+
2000
+ # @!method trange(price_hlc)
2001
+ # True Range
2002
+ #
2003
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
2004
+ # @return [Array<Float>]
2005
+ # @raise [TALibError] If there is an error in function execution
2006
+
2007
+ # @!method trima(real, time_period: 30.0)
2008
+ # Triangular Moving Average
2009
+ #
2010
+ # @param real [Array<Float>] Input values
2011
+ # @param time_period [Integer] Number of period (default: 30.0)
2012
+ # @return [Array<Float>]
2013
+ # @raise [TALibError] If there is an error in function execution
2014
+
2015
+ # @!method trix(real, time_period: 30.0)
2016
+ # 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA
2017
+ #
2018
+ # @param real [Array<Float>] Input values
2019
+ # @param time_period [Integer] Number of period (default: 30.0)
2020
+ # @return [Array<Float>]
2021
+ # @raise [TALibError] If there is an error in function execution
2022
+
2023
+ # @!method tsf(real, time_period: 14.0)
2024
+ # Time Series Forecast
2025
+ #
2026
+ # @param real [Array<Float>] Input values
2027
+ # @param time_period [Integer] Number of period (default: 14.0)
2028
+ # @return [Array<Float>]
2029
+ # @raise [TALibError] If there is an error in function execution
2030
+
2031
+ # @!method typprice(price_hlc)
2032
+ # Typical Price
2033
+ #
2034
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
2035
+ # @return [Array<Float>]
2036
+ # @raise [TALibError] If there is an error in function execution
2037
+
2038
+ # @!method ultosc(price_hlc, time_period1: 7.0, time_period2: 14.0, time_period3: 28.0)
2039
+ # Ultimate Oscillator
2040
+ #
2041
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
2042
+ # @param time_period1 [Integer] Number of bars for 1st period. (default: 7.0)
2043
+ # @param time_period2 [Integer] Number of bars fro 2nd period (default: 14.0)
2044
+ # @param time_period3 [Integer] Number of bars for 3rd period (default: 28.0)
2045
+ # @return [Array<Float>]
2046
+ # @raise [TALibError] If there is an error in function execution
2047
+
2048
+ # @!method var(real, time_period: 5.0, nb_dev: 1.0)
2049
+ # Variance
2050
+ #
2051
+ # @param real [Array<Float>] Input values
2052
+ # @param time_period [Integer] Number of period (default: 5.0)
2053
+ # @param nb_dev [Float] Nb of deviations (default: 1.0)
2054
+ # @return [Array<Float>]
2055
+ # @raise [TALibError] If there is an error in function execution
2056
+
2057
+ # @!method wclprice(price_hlc)
2058
+ # Weighted Close Price
2059
+ #
2060
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
2061
+ # @return [Array<Float>]
2062
+ # @raise [TALibError] If there is an error in function execution
2063
+
2064
+ # @!method willr(price_hlc, time_period: 14.0)
2065
+ # Williams' %R
2066
+ #
2067
+ # @param price_hlc [Array(Array<Float>, Array<Float>, Array<Float>)] Required price arrays: high, low, close
2068
+ # @param time_period [Integer] Number of period (default: 14.0)
2069
+ # @return [Array<Float>]
2070
+ # @raise [TALibError] If there is an error in function execution
2071
+
2072
+ # @!method wma(real, time_period: 30.0)
2073
+ # Weighted Moving Average
2074
+ #
2075
+ # @param real [Array<Float>] Input values
2076
+ # @param time_period [Integer] Number of period (default: 30.0)
2077
+ # @return [Array<Float>]
2078
+ # @raise [TALibError] If there is an error in function execution
2079
+
2080
+ ### GENERATED DOCUMENTATION END ###
2081
+ end
2082
+ end