Module: TALibFFI

Extended by:
Fiddle::Importer
Defined in:
lib/ta_lib_ffi.rb

Overview

Ruby FFI wrapper for TA-Lib (Technical Analysis Library)

This module provides a Ruby interface to the TA-Lib technical analysis library using FFI (Foreign Function Interface). It allows you to perform various technical analysis calculations on financial market data.

Examples:

Basic usage

require 'ta_lib_ffi'

# Calculate Simple Moving Average
prices = [10.0, 11.0, 12.0, 11.0, 10.0]
result = TALibFFI.sma(prices, time_period: 3)

See Also:

Defined Under Namespace

Classes: TALibError

Constant Summary collapse

VERSION =
"0.2.0"
TA_SUCCESS =
0
TA_LIB_NOT_INITIALIZE =
1
TA_BAD_PARAM =
2
TA_ALLOC_ERR =
3
TA_GROUP_NOT_FOUND =
4
TA_FUNC_NOT_FOUND =
5
TA_INVALID_HANDLE =
6
TA_INVALID_PARAM_HOLDER =
7
TA_INVALID_PARAM_HOLDER_TYPE =
8
TA_INVALID_PARAM_FUNCTION =
9
TA_INPUT_NOT_ALL_INITIALIZE =
10
TA_OUTPUT_NOT_ALL_INITIALIZE =
11
TA_OUT_OF_RANGE_START_INDEX =
12
TA_OUT_OF_RANGE_END_INDEX =
13
TA_INVALID_LIST_TYPE =
14
TA_BAD_OBJECT =
15
TA_NOT_SUPPORTED =
16
TA_INTERNAL_ERROR =
5000
TA_UNKNOWN_ERR =
0xFFFF
TA_StringTable =
struct [
  "unsigned int size",
  "const char **string",
  "void *hiddenData"
]
TA_FuncInfo =
struct [
  "const char *name",
  "const char *group",
  "const char *hint",
  "const char *camelCaseName",
  "TA_FuncFlags flags",
  "unsigned int nbInput",
  "unsigned int nbOptInput",
  "unsigned int nbOutput",
  "const TA_FuncHandle *handle"
]
TA_ParamHolder =
struct [
  "void *hiddenData"
]
TA_InputParameterInfo =
struct [
  "TA_InputParameterType type",
  "const char *paramName",
  "TA_InputFlags flags"
]
TA_OptInputParameterInfo =
struct [
  "TA_OptInputParameterType type",
  "const char *paramName",
  "TA_OptInputFlags flags",
  "const char *displayName",
  "const void *dataSet",
  "TA_Real defaultValue",
  "const char *hint",
  "const char *helpFile"
]
TA_OutputParameterInfo =
struct [
  "TA_OutputParameterType type",
  "const char *paramName",
  "TA_OutputFlags flags"
]
TA_PARAM_TYPE =
{
  TA_Input_Price: 0,
  TA_Input_Real: 1,
  TA_Input_Integer: 2,
  TA_OptInput_RealRange: 0,
  TA_OptInput_RealList: 1,
  TA_OptInput_IntegerRange: 2,
  TA_OptInput_IntegerList: 3,
  TA_Output_Real: 0,
  TA_Output_Integer: 1
}.freeze
TA_FLAGS =
{
  TA_InputFlags: {
    TA_IN_PRICE_OPEN: 0x00000001,
    TA_IN_PRICE_HIGH: 0x00000002,
    TA_IN_PRICE_LOW: 0x00000004,
    TA_IN_PRICE_CLOSE: 0x00000008,
    TA_IN_PRICE_VOLUME: 0x00000010,
    TA_IN_PRICE_OPENINTEREST: 0x00000020,
    TA_IN_PRICE_TIMESTAMP: 0x00000040
  },
  TA_OptInputFlags: {
    TA_OPTIN_IS_PERCENT: 0x00100000,
    TA_OPTIN_IS_DEGREE: 0x00200000,
    TA_OPTIN_IS_CURRENCY: 0x00400000,
    TA_OPTIN_ADVANCED: 0x01000000
  },
  TA_OutputFlags: {
    TA_OUT_LINE: 0x00000001,
    TA_OUT_DOT_LINE: 0x00000002,
    TA_OUT_DASH_LINE: 0x00000004,
    TA_OUT_DOT: 0x00000008,
    TA_OUT_HISTO: 0x00000010,
    TA_OUT_PATTERN_BOOL: 0x00000020,
    TA_OUT_PATTERN_BULL_BEAR: 0x00000040,
    TA_OUT_PATTERN_STRENGTH: 0x00000080,
    TA_OUT_POSITIVE: 0x00000100,
    TA_OUT_NEGATIVE: 0x00000200,
    TA_OUT_ZERO: 0x00000400,
    TA_OUT_UPPER_LIMIT: 0x00000800,
    TA_OUT_LOWER_LIMIT: 0x00001000
  }
}.freeze

Class Method Summary collapse

Class Method Details

.accbands(price_hlc, time_period: 20.0) ⇒ Hash

GENERATED DOCUMENTATION START ### Acceleration Bands

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • time_period (Integer) (defaults to: 20.0)

    Number of period (default: 20.0)

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 792

.acos(real) ⇒ Array<Float>

Vector Trigonometric ACos

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 804

.ad(price_hlcv) ⇒ Array<Float>

Chaikin A/D Line

Parameters:

  • price_hlcv (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE, TA_IN_PRICE_VOLUME

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 811

.add(real0, real1) ⇒ Array<Float>

Vector Arithmetic Add

Parameters:

  • real0 (Array<Float>)

    Input values

  • real1 (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 818

.adosc(price_hlcv, fast_period: 3.0, slow_period: 10.0) ⇒ Array<Float>

Chaikin A/D Oscillator

Parameters:

  • price_hlcv (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE, TA_IN_PRICE_VOLUME

  • fast_period (Integer) (defaults to: 3.0)

    Number of period for the fast MA (default: 3.0)

  • slow_period (Integer) (defaults to: 10.0)

    Number of period for the slow MA (default: 10.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 826

.adx(price_hlc, time_period: 14.0) ⇒ Array<Float>

Average Directional Movement Index

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 835

.adxr(price_hlc, time_period: 14.0) ⇒ Array<Float>

Average Directional Movement Index Rating

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 843

.apo(real, fast_period: 12.0, slow_period: 26.0, ma_type: 0.0) ⇒ Array<Float>

Absolute Price Oscillator

Parameters:

  • real (Array<Float>)

    Input values

  • fast_period (Integer) (defaults to: 12.0)

    Number of period for the fast MA (default: 12.0)

  • slow_period (Integer) (defaults to: 26.0)

    Number of period for the slow MA (default: 26.0)

  • ma_type (Integer) (defaults to: 0.0)

    Type of Moving Average (default: 0.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 851

.aroon(price_hl, time_period: 14.0) ⇒ Hash

Aroon

Parameters:

  • price_hl (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 861

.aroonosc(price_hl, time_period: 14.0) ⇒ Array<Float>

Aroon Oscillator

Parameters:

  • price_hl (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 871

.asin(real) ⇒ Array<Float>

Vector Trigonometric ASin

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 879

.atan(real) ⇒ Array<Float>

Vector Trigonometric ATan

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 886

.atr(price_hlc, time_period: 14.0) ⇒ Array<Float>

Average True Range

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 893

.avgdev(real, time_period: 14.0) ⇒ Array<Float>

Average Deviation

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 908

.avgprice(price_ohlc) ⇒ Array<Float>

Average Price

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 901

.bbands(real, time_period: 5.0, nb_dev_up: 2.0, nb_dev_dn: 2.0, ma_type: 0.0) ⇒ Hash

Bollinger Bands

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 5.0)

    Number of period (default: 5.0)

  • nb_dev_up (Float) (defaults to: 2.0)

    Deviation multiplier for upper band (default: 2.0)

  • nb_dev_dn (Float) (defaults to: 2.0)

    Deviation multiplier for lower band (default: 2.0)

  • ma_type (Integer) (defaults to: 0.0)

    Type of Moving Average (default: 0.0)

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 916

.beta(real0, real1, time_period: 5.0) ⇒ Array<Float>

Beta

Parameters:

  • real0 (Array<Float>)

    Input values

  • real1 (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 5.0)

    Number of period (default: 5.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 930

.bop(price_ohlc) ⇒ Array<Float>

Balance Of Power

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 939

.build_function_info_mapHash

Builds a map of function information for all functions

Returns:

  • (Hash)

    Map of function information



622
623
624
625
626
627
628
629
630
631
632
633
# File 'lib/ta_lib_ffi.rb', line 622

def build_function_info_map
  info_map = {}
  each_function do |func_info|
    info_map[func_info["name"].to_s] = {
      info: func_info,
      inputs: collect_input_info(func_info),
      outputs: collect_output_info(func_info),
      opt_inputs: collect_opt_input_info(func_info)
    }
  end
  info_map
end

.calculate_lookback(params_ptr) ⇒ Integer

Calculates the lookback period for a function with given parameters

Parameters:

  • params_ptr (Fiddle::Pointer)

    Pointer to parameter holder

Returns:

  • (Integer)

    The lookback period



388
389
390
391
392
393
# File 'lib/ta_lib_ffi.rb', line 388

def calculate_lookback(params_ptr)
  lookback_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT)
  ret_code = TA_GetLookback(params_ptr, lookback_ptr)
  check_ta_return_code(ret_code)
  lookback_ptr[0, Fiddle::SIZEOF_INT].unpack1("l")
end

.calculate_results(params_ptr, input_size, func_name) ⇒ Array, Hash

Calculates function results

Parameters:

  • params_ptr (Fiddle::Pointer)

    Parameter holder pointer

  • input_size (Integer)

    Size of input data

  • func_name (String)

    Function name

Returns:

  • (Array, Hash)

    Function results



529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# File 'lib/ta_lib_ffi.rb', line 529

def calculate_results(params_ptr, input_size, func_name) # rubocop:disable Metrics/MethodLength
  out_begin = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT)
  out_size = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT)
  output_arrays = setup_output_buffers(params_ptr, input_size, func_name)

  begin
    ret_code = TA_CallFunc(params_ptr, 0, input_size - 1, out_begin, out_size)
    check_ta_return_code(ret_code)

    actual_size = out_size[0, Fiddle::SIZEOF_INT].unpack1("l")
    format_output_results(output_arrays, actual_size, func_name)
  ensure
    out_begin.free
    out_size.free
    output_arrays.each(&:free)
  end
end

.call_func(func_name, args) ⇒ Array, Hash

Calls a TA-Lib function with the given arguments

Parameters:

  • func_name (String)

    The name of the function to call

  • args (Array)

    Array of input arrays and optional parameters

Returns:

  • (Array, Hash)

    Function results (single array or hash of named outputs)

Raises:

  • (TALibError)

    If there is an error in function execution



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/ta_lib_ffi.rb', line 365

def call_func(func_name, args) # rubocop:disable Metrics/MethodLength
  options = args.last.is_a?(Hash) ? args.pop : {}
  input_arrays = args

  validate_inputs!(input_arrays)

  handle_ptr = get_function_handle(func_name)
  params_ptr = create_parameter_holder(handle_ptr)

  begin
    setup_input_parameters(params_ptr, input_arrays, func_name)
    setup_optional_parameters(params_ptr, options, func_name)
    _lookback = calculate_lookback(params_ptr)
    calculate_results(params_ptr, input_arrays.first.length, func_name)
  ensure
    TA_ParamHolderFree(params_ptr)
  end
end

.cci(price_hlc, time_period: 14.0) ⇒ Array<Float>

Commodity Channel Index

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 946

.cdl2crows(price_ohlc) ⇒ Array<Integer>

Two Crows

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 954

.cdl3blackcrows(price_ohlc) ⇒ Array<Integer>

Three Black Crows

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 961

.cdl3inside(price_ohlc) ⇒ Array<Integer>

Three Inside Up/Down

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 968

.cdl3linestrike(price_ohlc) ⇒ Array<Integer>

Three-Line Strike

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 975

.cdl3outside(price_ohlc) ⇒ Array<Integer>

Three Outside Up/Down

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 982

.cdl3starsinsouth(price_ohlc) ⇒ Array<Integer>

Three Stars In The South

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 989

.cdl3whitesoldiers(price_ohlc) ⇒ Array<Integer>

Three Advancing White Soldiers

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 996

.cdlabandonedbaby(price_ohlc, penetration: 0.3) ⇒ Array<Integer>

Abandoned Baby

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • penetration (Float) (defaults to: 0.3)

    Percentage of penetration of a candle within another candle (default: 0.3)

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1003

.cdladvanceblock(price_ohlc) ⇒ Array<Integer>

Advance Block

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1011

.cdlbelthold(price_ohlc) ⇒ Array<Integer>

Belt-hold

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1018

.cdlbreakaway(price_ohlc) ⇒ Array<Integer>

Breakaway

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1025

.cdlclosingmarubozu(price_ohlc) ⇒ Array<Integer>

Closing Marubozu

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1032

.cdlconcealbabyswall(price_ohlc) ⇒ Array<Integer>

Concealing Baby Swallow

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1039

.cdlcounterattack(price_ohlc) ⇒ Array<Integer>

Counterattack

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1046

.cdldarkcloudcover(price_ohlc, penetration: 0.5) ⇒ Array<Integer>

Dark Cloud Cover

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • penetration (Float) (defaults to: 0.5)

    Percentage of penetration of a candle within another candle (default: 0.5)

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1053

.cdldoji(price_ohlc) ⇒ Array<Integer>

Doji

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1061

.cdldojistar(price_ohlc) ⇒ Array<Integer>

Doji Star

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1068

.cdldragonflydoji(price_ohlc) ⇒ Array<Integer>

Dragonfly Doji

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1075

.cdlengulfing(price_ohlc) ⇒ Array<Integer>

Engulfing Pattern

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1082

.cdleveningdojistar(price_ohlc, penetration: 0.3) ⇒ Array<Integer>

Evening Doji Star

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • penetration (Float) (defaults to: 0.3)

    Percentage of penetration of a candle within another candle (default: 0.3)

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1089

.cdleveningstar(price_ohlc, penetration: 0.3) ⇒ Array<Integer>

Evening Star

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • penetration (Float) (defaults to: 0.3)

    Percentage of penetration of a candle within another candle (default: 0.3)

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1097

.cdlgapsidesidewhite(price_ohlc) ⇒ Array<Integer>

Up/Down-gap side-by-side white lines

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1105

.cdlgravestonedoji(price_ohlc) ⇒ Array<Integer>

Gravestone Doji

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1112

.cdlhammer(price_ohlc) ⇒ Array<Integer>

Hammer

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1119

.cdlhangingman(price_ohlc) ⇒ Array<Integer>

Hanging Man

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1126

.cdlharami(price_ohlc) ⇒ Array<Integer>

Harami Pattern

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1133

.cdlharamicross(price_ohlc) ⇒ Array<Integer>

Harami Cross Pattern

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1140

.cdlhighwave(price_ohlc) ⇒ Array<Integer>

High-Wave Candle

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1147

.cdlhikkake(price_ohlc) ⇒ Array<Integer>

Hikkake Pattern

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1154

.cdlhikkakemod(price_ohlc) ⇒ Array<Integer>

Modified Hikkake Pattern

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1161

.cdlhomingpigeon(price_ohlc) ⇒ Array<Integer>

Homing Pigeon

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1168

.cdlidentical3crows(price_ohlc) ⇒ Array<Integer>

Identical Three Crows

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1175

.cdlinneck(price_ohlc) ⇒ Array<Integer>

In-Neck Pattern

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1182

.cdlinvertedhammer(price_ohlc) ⇒ Array<Integer>

Inverted Hammer

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1189

.cdlkicking(price_ohlc) ⇒ Array<Integer>

Kicking

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1196

.cdlkickingbylength(price_ohlc) ⇒ Array<Integer>

Kicking - bull/bear determined by the longer marubozu

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1203

.cdlladderbottom(price_ohlc) ⇒ Array<Integer>

Ladder Bottom

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1210

.cdllongleggeddoji(price_ohlc) ⇒ Array<Integer>

Long Legged Doji

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1217

.cdllongline(price_ohlc) ⇒ Array<Integer>

Long Line Candle

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1224

.cdlmarubozu(price_ohlc) ⇒ Array<Integer>

Marubozu

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1231

.cdlmatchinglow(price_ohlc) ⇒ Array<Integer>

Matching Low

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1238

.cdlmathold(price_ohlc, penetration: 0.5) ⇒ Array<Integer>

Mat Hold

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • penetration (Float) (defaults to: 0.5)

    Percentage of penetration of a candle within another candle (default: 0.5)

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1245

.cdlmorningdojistar(price_ohlc, penetration: 0.3) ⇒ Array<Integer>

Morning Doji Star

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • penetration (Float) (defaults to: 0.3)

    Percentage of penetration of a candle within another candle (default: 0.3)

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1253

.cdlmorningstar(price_ohlc, penetration: 0.3) ⇒ Array<Integer>

Morning Star

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • penetration (Float) (defaults to: 0.3)

    Percentage of penetration of a candle within another candle (default: 0.3)

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1261

.cdlonneck(price_ohlc) ⇒ Array<Integer>

On-Neck Pattern

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1269

.cdlpiercing(price_ohlc) ⇒ Array<Integer>

Piercing Pattern

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1276

.cdlrickshawman(price_ohlc) ⇒ Array<Integer>

Rickshaw Man

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1283

.cdlrisefall3methods(price_ohlc) ⇒ Array<Integer>

Rising/Falling Three Methods

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1290

.cdlseparatinglines(price_ohlc) ⇒ Array<Integer>

Separating Lines

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1297

.cdlshootingstar(price_ohlc) ⇒ Array<Integer>

Shooting Star

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1304

.cdlshortline(price_ohlc) ⇒ Array<Integer>

Short Line Candle

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1311

.cdlspinningtop(price_ohlc) ⇒ Array<Integer>

Spinning Top

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1318

.cdlstalledpattern(price_ohlc) ⇒ Array<Integer>

Stalled Pattern

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1325

.cdlsticksandwich(price_ohlc) ⇒ Array<Integer>

Stick Sandwich

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1332

.cdltakuri(price_ohlc) ⇒ Array<Integer>

Takuri (Dragonfly Doji with very long lower shadow)

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1339

.cdltasukigap(price_ohlc) ⇒ Array<Integer>

Tasuki Gap

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1346

.cdlthrusting(price_ohlc) ⇒ Array<Integer>

Thrusting Pattern

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1353

.cdltristar(price_ohlc) ⇒ Array<Integer>

Tristar Pattern

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1360

.cdlunique3river(price_ohlc) ⇒ Array<Integer>

Unique 3 River

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1367

.cdlupsidegap2crows(price_ohlc) ⇒ Array<Integer>

Upside Gap Two Crows

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1374

.cdlxsidegap3methods(price_ohlc) ⇒ Array<Integer>

Upside/Downside Gap Three Methods

Parameters:

  • price_ohlc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1381

.ceil(real) ⇒ Array<Float>

Vector Ceil

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1388

.check_ta_return_code(code) ⇒ Object

Checks TA-Lib return codes and raises appropriate errors

Parameters:

  • code (Integer)

    TA-Lib return code

Raises:

  • (TALibError)

    If the return code indicates an error



698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
# File 'lib/ta_lib_ffi.rb', line 698

def check_ta_return_code(code) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
  return if code == TA_SUCCESS

  error_message = case code
                  when TA_LIB_NOT_INITIALIZE
                    "TA-Lib not initialized, please call TA_Initialize first"
                  when TA_BAD_PARAM
                    "Bad parameter, please check input parameters"
                  when TA_ALLOC_ERR
                    "Memory allocation error, possibly insufficient memory"
                  when TA_GROUP_NOT_FOUND
                    "Function group not found"
                  when TA_FUNC_NOT_FOUND
                    "Function not found"
                  when TA_INVALID_HANDLE
                    "Invalid handle"
                  when TA_INVALID_PARAM_HOLDER
                    "Invalid parameter holder"
                  when TA_INVALID_PARAM_HOLDER_TYPE
                    "Invalid parameter holder type"
                  when TA_INVALID_PARAM_FUNCTION
                    "Invalid parameter function"
                  when TA_INPUT_NOT_ALL_INITIALIZE
                    "Input parameters not fully initialized"
                  when TA_OUTPUT_NOT_ALL_INITIALIZE
                    "Output parameters not fully initialized"
                  when TA_OUT_OF_RANGE_START_INDEX
                    "Start index out of range"
                  when TA_OUT_OF_RANGE_END_INDEX
                    "End index out of range"
                  when TA_INVALID_LIST_TYPE
                    "Invalid list type"
                  when TA_BAD_OBJECT
                    "Invalid object"
                  when TA_NOT_SUPPORTED
                    "Operation not supported"
                  when TA_INTERNAL_ERROR
                    "TA-Lib internal error"
                  when TA_UNKNOWN_ERR
                    "Unknown error"
                  else
                    "Undefined TA-Lib error (Error code: #{code})"
                  end

  raise TALibError, error_message
end

.cmo(real, time_period: 14.0) ⇒ Array<Float>

Chande Momentum Oscillator

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1395

.collect_input_info(func_info) ⇒ Array<Fiddle::CStructEntity>

Collects input parameter information for a function

Parameters:

  • func_info (Fiddle::CStructEntity)

    Function information

Returns:

  • (Array<Fiddle::CStructEntity>)

    Array of input parameter information



639
640
641
642
643
644
645
# File 'lib/ta_lib_ffi.rb', line 639

def collect_input_info(func_info)
  func_info["nbInput"].times.map do |i|
    param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
    TA_GetInputParameterInfo(func_info["handle"], i, param_info_ptr.ref)
    TA_InputParameterInfo.new(param_info_ptr)
  end
end

.collect_opt_input_info(func_info) ⇒ Array<Fiddle::CStructEntity>

Collects optional input parameter information for a function

Parameters:

  • func_info (Fiddle::CStructEntity)

    Function information

Returns:

  • (Array<Fiddle::CStructEntity>)

    Array of optional input parameter information



651
652
653
654
655
656
657
# File 'lib/ta_lib_ffi.rb', line 651

def collect_opt_input_info(func_info)
  func_info["nbOptInput"].times.map do |i|
    param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
    TA_GetOptInputParameterInfo(func_info["handle"], i, param_info_ptr.ref)
    TA_OptInputParameterInfo.new(param_info_ptr)
  end
end

.collect_output_info(func_info) ⇒ Array<Fiddle::CStructEntity>

Collects output parameter information for a function

Parameters:

  • func_info (Fiddle::CStructEntity)

    Function information

Returns:

  • (Array<Fiddle::CStructEntity>)

    Array of output parameter information



663
664
665
666
667
668
669
# File 'lib/ta_lib_ffi.rb', line 663

def collect_output_info(func_info)
  func_info["nbOutput"].times.map do |i|
    param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
    TA_GetOutputParameterInfo(func_info["handle"], i, param_info_ptr.ref)
    TA_OutputParameterInfo.new(param_info_ptr)
  end
end

.correl(real0, real1, time_period: 30.0) ⇒ Array<Float>

Pearson’s Correlation Coefficient ®

Parameters:

  • real0 (Array<Float>)

    Input values

  • real1 (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1403

.cos(real) ⇒ Array<Float>

Vector Trigonometric Cos

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1412

.cosh(real) ⇒ Array<Float>

Vector Trigonometric Cosh

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1419

.create_parameter_holder(handle_ptr) ⇒ Fiddle::Pointer

Creates a parameter holder for a function

Parameters:

  • handle_ptr (Fiddle::Pointer)

    Function handle pointer

Returns:

  • (Fiddle::Pointer)

    Pointer to parameter holder



429
430
431
432
433
434
# File 'lib/ta_lib_ffi.rb', line 429

def create_parameter_holder(handle_ptr)
  params_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  ret_code = TA_ParamHolderAlloc(handle_ptr, params_ptr.ref)
  check_ta_return_code(ret_code)
  params_ptr
end

.define_ta_function(method_name, func_name) ⇒ Object

Defines a TA-Lib function as a Ruby method with documentation

Parameters:

  • method_name (String)

    Name of the Ruby method to define

  • func_name (String)

    Name of the TA-Lib function



759
760
761
762
763
# File 'lib/ta_lib_ffi.rb', line 759

def define_ta_function(method_name, func_name)
  define_singleton_method(method_name) do |*args|
    call_func(func_name, args)
  end
end

.dema(real, time_period: 30.0) ⇒ Array<Float>

Double Exponential Moving Average

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1426

.div(real0, real1) ⇒ Array<Float>

Vector Arithmetic Div

Parameters:

  • real0 (Array<Float>)

    Input values

  • real1 (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1434

.dx(price_hlc, time_period: 14.0) ⇒ Array<Float>

Directional Movement Index

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1442

.each_function {|func_info| ... } ⇒ Object

Iterates over all available TA-Lib functions

Yields:

  • (func_info)

    Yields function information for each function

Yield Parameters:

  • func_info (Fiddle::CStructEntity)

    Function information struct



292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/ta_lib_ffi.rb', line 292

def each_function(&block)
  callback = Fiddle::Closure::BlockCaller.new(
    Fiddle::TYPE_VOID,
    [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
    Fiddle::Function::DEFAULT
  ) do |func_info_ptr, _|
    block.call TA_FuncInfo.new(func_info_ptr)
  end

  ret_code = TA_ForEachFunc(callback, nil)
  check_ta_return_code(ret_code)
end

.ema(real, time_period: 30.0) ⇒ Array<Float>

Exponential Moving Average

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1450

.exp(real) ⇒ Array<Float>

Vector Arithmetic Exp

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1458

.extract_flags(value, type) ⇒ Array<Symbol>

Extracts flags from a bitmask value based on the flag type

Parameters:

  • value (Integer)

    The bitmask value to extract flags from

  • type (Symbol)

    The type of flags to extract (:TA_InputFlags, :TA_OptInputFlags, or :TA_OutputFlags)

Returns:

  • (Array<Symbol>)

    Array of flag names that are set in the bitmask



232
233
234
235
236
237
238
# File 'lib/ta_lib_ffi.rb', line 232

def extract_flags(value, type)
  flags_set = []
  TA_FLAGS[type].each do |k, v|
    flags_set << k if (value & v) != 0
  end
  flags_set
end

.floor(real) ⇒ Array<Float>

Vector Floor

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1465

.format_output_results(output_ptrs, size, func_name) ⇒ Array, Hash

Formats output results from TA-Lib function

Parameters:

  • output_ptrs (Array<Fiddle::Pointer>)

    Array of output buffer pointers

  • size (Integer)

    Size of output data

  • func_name (String)

    Function name

Returns:

  • (Array, Hash)

    Formatted results



586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
# File 'lib/ta_lib_ffi.rb', line 586

def format_output_results(output_ptrs, size, func_name) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
  func_info = function_info_map[func_name]
  results = output_ptrs.zip(func_info[:outputs]).map do |ptr, output|
    case output["type"]
    when TA_PARAM_TYPE[:TA_Output_Real]
      ptr[0, Fiddle::SIZEOF_DOUBLE * size].unpack("d#{size}")
    when TA_PARAM_TYPE[:TA_Output_Integer]
      ptr[0, Fiddle::SIZEOF_INT * size].unpack("l#{size}")
    end
  end

  return results.first if results.length == 1

  output_names = func_info[:outputs].map do |output|
    normalize_parameter_name(output["paramName"].to_s).to_sym
  end
  output_names.zip(results).to_h
end

.function_description_xmlString

Gets XML description of all TA-Lib functions

Returns:

  • (String)

    XML function descriptions



608
609
610
# File 'lib/ta_lib_ffi.rb', line 608

def function_description_xml
  TA_FunctionDescriptionXML().to_s
end

.function_info(name) ⇒ Fiddle::CStructEntity

Gets detailed information about a specific TA-Lib function

Parameters:

  • name (String)

    The name of the function to get information for

Returns:

  • (Fiddle::CStructEntity)

    Struct containing function information



276
277
278
279
280
281
282
283
284
285
286
# File 'lib/ta_lib_ffi.rb', line 276

def function_info(name)
  handle_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  ret_code = TA_GetFuncHandle(name, handle_ptr.ref)
  check_ta_return_code(ret_code)

  info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  ret_code = TA_GetFuncInfo(handle_ptr, info_ptr.ref)
  check_ta_return_code(ret_code)

  TA_FuncInfo.new(info_ptr)
end

.function_info_mapHash

Gets or builds the function information map

Returns:

  • (Hash)

    Map of function information



615
616
617
# File 'lib/ta_lib_ffi.rb', line 615

def function_info_map
  @function_info_map ||= build_function_info_map
end

.function_table(group) ⇒ Array<String>

Returns a list of all functions in a specific group

Parameters:

  • group (String)

    The name of the group to get functions for

Returns:

  • (Array<String>)

    Array of function names in the group



259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/ta_lib_ffi.rb', line 259

def function_table(group)
  string_table_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  ret_code = TA_FuncTableAlloc(group, string_table_ptr.ref)
  check_ta_return_code(ret_code)

  string_table = TA_StringTable.new(string_table_ptr)
  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 }

  TA_FuncTableFree(string_table)

  func_names
end

.generate_ta_functionsObject

Generates Ruby methods for all TA-Lib functions

This method iterates through all available TA-Lib functions and creates corresponding Ruby methods with proper documentation.



675
676
677
678
679
# File 'lib/ta_lib_ffi.rb', line 675

def generate_ta_functions
  each_function do |func_info|
    define_ta_function(func_info["name"].to_s.downcase, func_info["name"].to_s)
  end
end

.get_function_handle(func_name) ⇒ Fiddle::Pointer

Gets a function handle for a given function name

Parameters:

  • func_name (String)

    The name of the function

Returns:

  • (Fiddle::Pointer)

    Pointer to function handle



418
419
420
421
422
423
# File 'lib/ta_lib_ffi.rb', line 418

def get_function_handle(func_name)
  handle_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  ret_code = TA_GetFuncHandle(func_name, handle_ptr.ref)
  check_ta_return_code(ret_code)
  handle_ptr
end

.group_tableArray<String>

Returns a list of all available function groups in TA-Lib

Returns:

  • (Array<String>)

    Array of group names



243
244
245
246
247
248
249
250
251
252
253
# File 'lib/ta_lib_ffi.rb', line 243

def group_table
  string_table_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  ret_code = TA_GroupTableAlloc(string_table_ptr.ref)
  check_ta_return_code(ret_code)

  string_table = TA_StringTable.new(string_table_ptr)
  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 }
  TA_GroupTableFree(string_table_ptr)

  group_names
end

.ht_dcperiod(real) ⇒ Array<Float>

Hilbert Transform - Dominant Cycle Period

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1472

.ht_dcphase(real) ⇒ Array<Float>

Hilbert Transform - Dominant Cycle Phase

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1479

.ht_phasor(real) ⇒ Hash

Hilbert Transform - Phasor Components

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1486

.ht_sine(real) ⇒ Hash

Hilbert Transform - SineWave

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1495

.ht_trendline(real) ⇒ Array<Float>

Hilbert Transform - Instantaneous Trendline

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1504

.ht_trendmode(real) ⇒ Array<Integer>

Hilbert Transform - Trend vs Cycle Mode

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1511

.imi(price_oc, time_period: 14.0) ⇒ Array<Float>

Intraday Momentum Index

Parameters:

  • price_oc (Array<Float>)

    TA_IN_PRICE_OPEN, TA_IN_PRICE_CLOSE

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1518

.initialize_ta_libObject

Initializes the TA-Lib library



746
747
748
749
750
751
752
753
# File 'lib/ta_lib_ffi.rb', line 746

def initialize_ta_lib
  return if @initialized

  ret_code = TA_Initialize()
  check_ta_return_code(ret_code)
  at_exit { TA_Shutdown() }
  @initialized = true
end

.kama(real, time_period: 30.0) ⇒ Array<Float>

Kaufman Adaptive Moving Average

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1526

.linearreg(real, time_period: 14.0) ⇒ Array<Float>

Linear Regression

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1534

.linearreg_angle(real, time_period: 14.0) ⇒ Array<Float>

Linear Regression Angle

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1542

.linearreg_intercept(real, time_period: 14.0) ⇒ Array<Float>

Linear Regression Intercept

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1550

.linearreg_slope(real, time_period: 14.0) ⇒ Array<Float>

Linear Regression Slope

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1558

.ln(real) ⇒ Array<Float>

Vector Log Natural

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1566

.log10(real) ⇒ Array<Float>

Vector Log10

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1573

.ma(real, time_period: 30.0, ma_type: 0.0) ⇒ Array<Float>

Moving average

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

  • ma_type (Integer) (defaults to: 0.0)

    Type of Moving Average (default: 0.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1580

.macd(real, fast_period: 12.0, slow_period: 26.0, signal_period: 9.0) ⇒ Hash

Moving Average Convergence/Divergence

Parameters:

  • real (Array<Float>)

    Input values

  • fast_period (Integer) (defaults to: 12.0)

    Number of period for the fast MA (default: 12.0)

  • slow_period (Integer) (defaults to: 26.0)

    Number of period for the slow MA (default: 26.0)

  • signal_period (Integer) (defaults to: 9.0)

    Smoothing for the signal line (nb of period) (default: 9.0)

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1589

.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) ⇒ Hash

MACD with controllable MA type

Parameters:

  • real (Array<Float>)

    Input values

  • fast_period (Integer) (defaults to: 12.0)

    Number of period for the fast MA (default: 12.0)

  • fast_ma_type (Integer) (defaults to: 0.0)

    Type of Moving Average for fast MA (default: 0.0)

  • slow_period (Integer) (defaults to: 26.0)

    Number of period for the slow MA (default: 26.0)

  • slow_ma_type (Integer) (defaults to: 0.0)

    Type of Moving Average for slow MA (default: 0.0)

  • signal_period (Integer) (defaults to: 9.0)

    Smoothing for the signal line (nb of period) (default: 9.0)

  • signal_ma_type (Integer) (defaults to: 0.0)

    Type of Moving Average for signal line (default: 0.0)

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1602

.macdfix(real, signal_period: 9.0) ⇒ Hash

Moving Average Convergence/Divergence Fix 12/26

Parameters:

  • real (Array<Float>)

    Input values

  • signal_period (Integer) (defaults to: 9.0)

    Smoothing for the signal line (nb of period) (default: 9.0)

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1618

.mama(real, fast_limit: 0.5, slow_limit: 0.05) ⇒ Hash

MESA Adaptive Moving Average

Parameters:

  • real (Array<Float>)

    Input values

  • fast_limit (Float) (defaults to: 0.5)

    Upper limit use in the adaptive algorithm (default: 0.5)

  • slow_limit (Float) (defaults to: 0.05)

    Lower limit use in the adaptive algorithm (default: 0.05)

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1629

.mavp(real, periods, min_period: 2.0, max_period: 30.0, ma_type: 0.0) ⇒ Array<Float>

Moving average with variable period

Parameters:

  • real (Array<Float>)

    Input values

  • periods (Array<Float>)

    Input values

  • min_period (Integer) (defaults to: 2.0)

    Value less than minimum will be changed to Minimum period (default: 2.0)

  • max_period (Integer) (defaults to: 30.0)

    Value higher than maximum will be changed to Maximum period (default: 30.0)

  • ma_type (Integer) (defaults to: 0.0)

    Type of Moving Average (default: 0.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1640

.max(real, time_period: 30.0) ⇒ Array<Float>

Highest value over a specified period

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1651

.maxindex(real, time_period: 30.0) ⇒ Array<Integer>

Index of highest value over a specified period

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1659

.medprice(price_hl) ⇒ Array<Float>

Median Price

Parameters:

  • price_hl (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1667

.mfi(price_hlcv, time_period: 14.0) ⇒ Array<Float>

Money Flow Index

Parameters:

  • price_hlcv (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE, TA_IN_PRICE_VOLUME

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1674

.midpoint(real, time_period: 14.0) ⇒ Array<Float>

MidPoint over period

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1682

.midprice(price_hl, time_period: 14.0) ⇒ Array<Float>

Midpoint Price over period

Parameters:

  • price_hl (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1690

.min(real, time_period: 30.0) ⇒ Array<Float>

Lowest value over a specified period

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1698

.minindex(real, time_period: 30.0) ⇒ Array<Integer>

Index of lowest value over a specified period

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Integer>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1706

.minmax(real, time_period: 30.0) ⇒ Hash

Lowest and highest values over a specified period

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1714

.minmaxindex(real, time_period: 30.0) ⇒ Hash

Indexes of lowest and highest values over a specified period

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1724

.minus_di(price_hlc, time_period: 14.0) ⇒ Array<Float>

Minus Directional Indicator

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1734

.minus_dm(price_hl, time_period: 14.0) ⇒ Array<Float>

Minus Directional Movement

Parameters:

  • price_hl (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1742

.mom(real, time_period: 10.0) ⇒ Array<Float>

Momentum

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 10.0)

    Number of period (default: 10.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1750

.mult(real0, real1) ⇒ Array<Float>

Vector Arithmetic Mult

Parameters:

  • real0 (Array<Float>)

    Input values

  • real1 (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1758

.natr(price_hlc, time_period: 14.0) ⇒ Array<Float>

Normalized Average True Range

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1766

.normalize_parameter_name(name) ⇒ String

Normalizes parameter names to Ruby style

Parameters:

  • name (String)

    Parameter name to normalize

Returns:

  • (String)

    Normalized parameter name



685
686
687
688
689
690
691
692
# File 'lib/ta_lib_ffi.rb', line 685

def normalize_parameter_name(name)
  name.sub(/^(optIn|outReal|outInteger|out|in)/, "")
      .gsub(/::/, "/")
      .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
      .gsub(/([a-z\d])([A-Z])/, '\1_\2')
      .tr("-", "_")
      .downcase
end

.obv(real, price_v) ⇒ Array<Float>

On Balance Volume

Parameters:

  • real (Array<Float>)

    Input values

  • price_v (Array<Float>)

    TA_IN_PRICE_VOLUME

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1774

.plus_di(price_hlc, time_period: 14.0) ⇒ Array<Float>

Plus Directional Indicator

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1782

.plus_dm(price_hl, time_period: 14.0) ⇒ Array<Float>

Plus Directional Movement

Parameters:

  • price_hl (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1790

.ppo(real, fast_period: 12.0, slow_period: 26.0, ma_type: 0.0) ⇒ Array<Float>

Percentage Price Oscillator

Parameters:

  • real (Array<Float>)

    Input values

  • fast_period (Integer) (defaults to: 12.0)

    Number of period for the fast MA (default: 12.0)

  • slow_period (Integer) (defaults to: 26.0)

    Number of period for the slow MA (default: 26.0)

  • ma_type (Integer) (defaults to: 0.0)

    Type of Moving Average (default: 0.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1798

.prepare_double_array(array) ⇒ Fiddle::Pointer

Prepares a double array for TA-Lib input

Parameters:

  • array (Array<Numeric>)

    Array of numbers to prepare

Returns:

  • (Fiddle::Pointer)

    Pointer to prepared array



474
475
476
477
478
479
480
# File 'lib/ta_lib_ffi.rb', line 474

def prepare_double_array(array)
  array_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE * array.length)
  array.each_with_index do |value, i|
    array_ptr[i * Fiddle::SIZEOF_DOUBLE, Fiddle::SIZEOF_DOUBLE] = [value.to_f].pack("d")
  end
  array_ptr
end

.prepare_integer_array(array) ⇒ Fiddle::Pointer

Prepares an integer array for TA-Lib input

Parameters:

  • array (Array<Numeric>)

    Array of numbers to prepare

Returns:

  • (Fiddle::Pointer)

    Pointer to prepared array



486
487
488
489
490
491
492
# File 'lib/ta_lib_ffi.rb', line 486

def prepare_integer_array(array)
  array_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT * array.length)
  array.each_with_index do |value, i|
    array_ptr[i * Fiddle::SIZEOF_INT, Fiddle::SIZEOF_INT] = [value.to_i].pack("l")
  end
  array_ptr
end

Prints detailed information about a TA-Lib function

Parameters:

  • func_info (Fiddle::CStructEntity)

    Function information struct to print



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/ta_lib_ffi.rb', line 308

def print_function_info(func_info) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
  puts "Function Name: #{func_info["name"]}"
  puts "Function Group: #{func_info["group"]}"
  puts "Function Hint: #{func_info["hint"]}"
  puts "Camel Case Name: #{func_info["camelCaseName"]}"
  puts "Flags: #{func_info["flags"]}"
  puts "Number of Inputs: #{func_info["nbInput"]}"
  puts "Number of Optional Inputs: #{func_info["nbOptInput"]}"
  puts "Number of Outputs: #{func_info["nbOutput"]}"
  puts "Function Handle: #{func_info["handle"].to_i}"

  puts "\nInput Parameter Info:"
  func_info["nbInput"].times do |i|
    param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
    ret_code = TA_GetInputParameterInfo(func_info["handle"], i, param_info_ptr.ref)
    check_ta_return_code(ret_code)
    param_info = TA_InputParameterInfo.new(param_info_ptr)
    puts "  Parameter #{i + 1}:"
    puts "    Name: #{param_info["paramName"]}"
    puts "    Type: #{param_info["type"]}"
    puts "    Flags: #{extract_flags(param_info["flags"], :TA_InputFlags)}"
  end

  puts "\nOptional Input Parameter Info:"
  func_info["nbOptInput"].times do |i|
    param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
    ret_code = TA_GetOptInputParameterInfo(func_info["handle"], i, param_info_ptr.ref)
    check_ta_return_code(ret_code)
    param_info = TA_OptInputParameterInfo.new(param_info_ptr)
    puts "  Parameter #{i + 1}:"
    puts "    Name: #{param_info["paramName"]}"
    puts "    Type: #{param_info["type"]}"
    puts "    Flags: #{extract_flags(param_info["flags"], :TA_OptInputFlags)}"
    puts "    Display Name: #{param_info["displayName"]}"
    puts "    Default Value: #{param_info["defaultValue"]}"
    puts "    Hint: #{param_info["hint"]}"
  end

  puts "\nOutput Parameter Info:"
  func_info["nbOutput"].times do |i|
    param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
    ret_code = TA_GetOutputParameterInfo(func_info["handle"], i, param_info_ptr.ref)
    check_ta_return_code(ret_code)
    param_info = TA_OutputParameterInfo.new(param_info_ptr)
    puts "  Parameter #{i + 1}:"
    puts "    Name: #{param_info["paramName"]}"
    puts "    Type: #{param_info["type"]}"
    puts "    Flags: #{extract_flags(param_info["flags"], :TA_OutputFlags)}"
  end
end

.roc(real, time_period: 10.0) ⇒ Array<Float>

Rate of change : ((price/prevPrice)-1)*100

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 10.0)

    Number of period (default: 10.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1808

.rocp(real, time_period: 10.0) ⇒ Array<Float>

Rate of change Percentage: (price-prevPrice)/prevPrice

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 10.0)

    Number of period (default: 10.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1816

.rocr(real, time_period: 10.0) ⇒ Array<Float>

Rate of change ratio: (price/prevPrice)

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 10.0)

    Number of period (default: 10.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1824

.rocr100(real, time_period: 10.0) ⇒ Array<Float>

Rate of change ratio 100 scale: (price/prevPrice)*100

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 10.0)

    Number of period (default: 10.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1832

.rsi(real, time_period: 14.0) ⇒ Array<Float>

Relative Strength Index

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1840

.sar(price_hl, acceleration: 0.02, maximum: 0.2) ⇒ Array<Float>

Parabolic SAR

Parameters:

  • price_hl (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW

  • acceleration (Float) (defaults to: 0.02)

    Acceleration Factor used up to the Maximum value (default: 0.02)

  • maximum (Float) (defaults to: 0.2)

    Acceleration Factor Maximum value (default: 0.2)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1848

.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) ⇒ Array<Float>

Parabolic SAR - Extended

Parameters:

  • price_hl (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW

  • start_value (Float) (defaults to: 0.0)

    Start value and direction. 0 for Auto, >0 for Long, <0 for Short (default: 0.0)

  • offset_on_reverse (Float) (defaults to: 0.0)

    Percent offset added/removed to initial stop on short/long reversal (default: 0.0)

  • acceleration_init_long (Float) (defaults to: 0.02)

    Acceleration Factor initial value for the Long direction (default: 0.02)

  • acceleration_long (Float) (defaults to: 0.02)

    Acceleration Factor for the Long direction (default: 0.02)

  • acceleration_max_long (Float) (defaults to: 0.2)

    Acceleration Factor maximum value for the Long direction (default: 0.2)

  • acceleration_init_short (Float) (defaults to: 0.02)

    Acceleration Factor initial value for the Short direction (default: 0.02)

  • acceleration_short (Float) (defaults to: 0.02)

    Acceleration Factor for the Short direction (default: 0.02)

  • acceleration_max_short (Float) (defaults to: 0.2)

    Acceleration Factor maximum value for the Short direction (default: 0.2)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1857

.set_input_parameter(params_ptr, index, array, input_info) ⇒ Integer

Sets a single input parameter

Parameters:

  • params_ptr (Fiddle::Pointer)

    Parameter holder pointer

  • index (Integer)

    Parameter index

  • array (Array)

    Input data array

  • input_info (Hash)

    Input parameter information

Returns:

  • (Integer)

    TA-Lib return code



457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/ta_lib_ffi.rb', line 457

def set_input_parameter(params_ptr, index, array, input_info)
  case input_info["type"]
  when TA_PARAM_TYPE[:TA_Input_Real]
    input_ptr = prepare_double_array(array)
    TA_SetInputParamRealPtr(params_ptr, index, input_ptr)
  when TA_PARAM_TYPE[:TA_Input_Integer]
    input_ptr = prepare_integer_array(array)
    TA_SetInputParamIntegerPtr(params_ptr, index, input_ptr)
  when TA_PARAM_TYPE[:TA_Input_Price]
    setup_price_inputs(params_ptr, index, array, input_info["flags"])
  end
end

.set_optional_parameter(params_ptr, index, value, type) ⇒ Object

Sets a single optional parameter

Parameters:

  • params_ptr (Fiddle::Pointer)

    Parameter holder pointer

  • index (Integer)

    Parameter index

  • value (Numeric)

    Parameter value

  • type (Integer)

    Parameter type



513
514
515
516
517
518
519
520
521
# File 'lib/ta_lib_ffi.rb', line 513

def set_optional_parameter(params_ptr, index, value, type)
  case type
  when TA_PARAM_TYPE[:TA_OptInput_RealRange], TA_PARAM_TYPE[:TA_OptInput_RealList]
    ret_code = TA_SetOptInputParamReal(params_ptr, index, value)
  when TA_PARAM_TYPE[:TA_OptInput_IntegerRange], TA_PARAM_TYPE[:TA_OptInput_IntegerList]
    ret_code = TA_SetOptInputParamInteger(params_ptr, index, value)
  end
  check_ta_return_code(ret_code)
end

.setup_input_parameters(params_ptr, input_arrays, func_name) ⇒ Object

Sets up input parameters for a function call

Parameters:

  • params_ptr (Fiddle::Pointer)

    Parameter holder pointer

  • input_arrays (Array<Array>)

    Input data arrays

  • func_name (String)

    Function name



441
442
443
444
445
446
447
448
# File 'lib/ta_lib_ffi.rb', line 441

def setup_input_parameters(params_ptr, input_arrays, func_name)
  func_info = function_info_map[func_name]
  input_arrays.each_with_index do |array, index|
    input_info = func_info[:inputs][index]
    ret_code = set_input_parameter(params_ptr, index, array, input_info)
    check_ta_return_code(ret_code)
  end
end

.setup_optional_parameters(params_ptr, options, func_name) ⇒ Object

Sets up optional parameters for a function call

Parameters:

  • params_ptr (Fiddle::Pointer)

    Parameter holder pointer

  • options (Hash)

    Optional parameters

  • func_name (String)

    Function name



499
500
501
502
503
504
505
# File 'lib/ta_lib_ffi.rb', line 499

def setup_optional_parameters(params_ptr, options, func_name)
  func_info = function_info_map[func_name]
  func_info[:opt_inputs]&.each_with_index do |opt_input, index|
    param_name = normalize_parameter_name(opt_input["paramName"].to_s)
    set_optional_parameter(params_ptr, index, options[param_name.to_sym], opt_input["type"]) if options.key?(param_name.to_sym)
  end
end

.setup_output_buffers(params_ptr, size, func_name) ⇒ Array<Fiddle::Pointer>

Sets up output buffers for function results

Parameters:

  • params_ptr (Fiddle::Pointer)

    Parameter holder pointer

  • size (Integer)

    Size of output buffer

  • func_name (String)

    Function name

Returns:

  • (Array<Fiddle::Pointer>)

    Array of output buffer pointers



553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
# File 'lib/ta_lib_ffi.rb', line 553

def setup_output_buffers(params_ptr, size, func_name) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
  func_info = function_info_map[func_name]
  output_ptrs = []

  func_info[:outputs].each_with_index do |output, index|
    ptr = case output["type"]
          when TA_PARAM_TYPE[:TA_Output_Real]
            Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE * size)
          when TA_PARAM_TYPE[:TA_Output_Integer]
            Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT * size)
          end

    output_ptrs << ptr

    ret_code =  case output["type"]
                when TA_PARAM_TYPE[:TA_Output_Real]
                  TA_SetOutputParamRealPtr(params_ptr, index, ptr)
                when TA_PARAM_TYPE[:TA_Output_Integer]
                  TA_SetOutputParamIntegerPtr(params_ptr, index, ptr)
                end

    check_ta_return_code(ret_code)
  end

  output_ptrs
end

.setup_price_inputs(params_ptr, index, price_data, flags) ⇒ Object

Sets up price inputs for functions that take price data

Parameters:

  • params_ptr (Fiddle::Pointer)

    Parameter holder pointer

  • index (Integer)

    Parameter index

  • price_data (Array)

    Price data array

  • flags (Integer)

    Input flags



771
772
773
774
775
776
777
778
779
780
781
782
783
# File 'lib/ta_lib_ffi.rb', line 771

def setup_price_inputs(params_ptr, index, price_data, flags)
  required_flags = extract_flags(flags, :TA_InputFlags)
  data_pointers = Array.new(6) { nil }
  TA_FLAGS[:TA_InputFlags].keys[0..5].each_with_index do |flag, i|
    data_pointers[i] = if required_flags.include?(flag)
                         prepare_double_array(price_data[required_flags.index(flag)])
                       else
                         Fiddle::Pointer.malloc(0)
                       end
  end

  TA_SetInputParamPricePtr(params_ptr, index, *data_pointers)
end

.sin(real) ⇒ Array<Float>

Vector Trigonometric Sin

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1872

.sinh(real) ⇒ Array<Float>

Vector Trigonometric Sinh

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1879

.sma(real, time_period: 30.0) ⇒ Array<Float>

Simple Moving Average

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1886

.sqrt(real) ⇒ Array<Float>

Vector Square Root

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1894

.stddev(real, time_period: 5.0, nb_dev: 1.0) ⇒ Array<Float>

Standard Deviation

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 5.0)

    Number of period (default: 5.0)

  • nb_dev (Float) (defaults to: 1.0)

    Nb of deviations (default: 1.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1901

.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) ⇒ Hash

Stochastic

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • fast_k_period (Integer) (defaults to: 5.0)

    Time period for building the Fast-K line (default: 5.0)

  • slow_k_period (Integer) (defaults to: 3.0)

    Smoothing for making the Slow-K line. Usually set to 3 (default: 3.0)

  • slow_k_ma_type (Integer) (defaults to: 0.0)

    Type of Moving Average for Slow-K (default: 0.0)

  • slow_d_period (Integer) (defaults to: 3.0)

    Smoothing for making the Slow-D line (default: 3.0)

  • slow_d_ma_type (Integer) (defaults to: 0.0)

    Type of Moving Average for Slow-D (default: 0.0)

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1910

.stochf(price_hlc, fast_k_period: 5.0, fast_d_period: 3.0, fast_d_ma_type: 0.0) ⇒ Hash

Stochastic Fast

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • fast_k_period (Integer) (defaults to: 5.0)

    Time period for building the Fast-K line (default: 5.0)

  • fast_d_period (Integer) (defaults to: 3.0)

    Smoothing for making the Fast-D line. Usually set to 3 (default: 3.0)

  • fast_d_ma_type (Integer) (defaults to: 0.0)

    Type of Moving Average for Fast-D (default: 0.0)

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1924

.stochrsi(real, time_period: 14.0, fast_k_period: 5.0, fast_d_period: 3.0, fast_d_ma_type: 0.0) ⇒ Hash

Stochastic Relative Strength Index

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

  • fast_k_period (Integer) (defaults to: 5.0)

    Time period for building the Fast-K line (default: 5.0)

  • fast_d_period (Integer) (defaults to: 3.0)

    Smoothing for making the Fast-D line. Usually set to 3 (default: 3.0)

  • fast_d_ma_type (Integer) (defaults to: 0.0)

    Type of Moving Average for Fast-D (default: 0.0)

Returns:

  • (Hash)

    Hash containing the following arrays:

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1936

.sub(real0, real1) ⇒ Array<Float>

Vector Arithmetic Subtraction

Parameters:

  • real0 (Array<Float>)

    Input values

  • real1 (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1949

.sum(real, time_period: 30.0) ⇒ Array<Float>

Summation

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1957

.t3(real, time_period: 5.0, v_factor: 0.7) ⇒ Array<Float>

Triple Exponential Moving Average (T3)

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 5.0)

    Number of period (default: 5.0)

  • v_factor (Float) (defaults to: 0.7)

    Volume Factor (default: 0.7)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1965

.tan(real) ⇒ Array<Float>

Vector Trigonometric Tan

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1974

.tanh(real) ⇒ Array<Float>

Vector Trigonometric Tanh

Parameters:

  • real (Array<Float>)

    Input values

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1981

.tema(real, time_period: 30.0) ⇒ Array<Float>

Triple Exponential Moving Average

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1988

.trange(price_hlc) ⇒ Array<Float>

True Range

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 1996

.trima(real, time_period: 30.0) ⇒ Array<Float>

Triangular Moving Average

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 2003

.trix(real, time_period: 30.0) ⇒ Array<Float>

1-day Rate-Of-Change (ROC) of a Triple Smooth EMA

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 2011

.tsf(real, time_period: 14.0) ⇒ Array<Float>

Time Series Forecast

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 2019

.typprice(price_hlc) ⇒ Array<Float>

Typical Price

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 2027

.ultosc(price_hlc, time_period1: 7.0, time_period2: 14.0, time_period3: 28.0) ⇒ Array<Float>

Ultimate Oscillator

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • time_period1 (Integer) (defaults to: 7.0)

    Number of bars for 1st period. (default: 7.0)

  • time_period2 (Integer) (defaults to: 14.0)

    Number of bars fro 2nd period (default: 14.0)

  • time_period3 (Integer) (defaults to: 28.0)

    Number of bars for 3rd period (default: 28.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 2034

.validate_inputs!(arrays) ⇒ Object

Validates input arrays for TA-Lib functions

Parameters:

  • arrays (Array<Array>)

    Arrays to validate

Raises:



399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/ta_lib_ffi.rb', line 399

def validate_inputs!(arrays) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
  raise TALibError, "Input arrays cannot be empty" if arrays.empty?

  arrays.each do |arr|
    raise TALibError, "Input must be arrays" unless arr.is_a?(Array)
  end

  sizes = arrays.map(&:length)
  raise TALibError, "Input arrays cannot be empty" if sizes.any?(&:zero?)

  arrays.each do |arr|
    raise TALibError, "Input arrays must contain only numbers" unless arr.flatten.all? { |x| x.is_a?(Numeric) }
  end
end

.var(real, time_period: 5.0, nb_dev: 1.0) ⇒ Array<Float>

Variance

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 5.0)

    Number of period (default: 5.0)

  • nb_dev (Float) (defaults to: 1.0)

    Nb of deviations (default: 1.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 2044

.wclprice(price_hlc) ⇒ Array<Float>

Weighted Close Price

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 2053

.willr(price_hlc, time_period: 14.0) ⇒ Array<Float>

Williams’ %R

Parameters:

  • price_hlc (Array<Float>)

    TA_IN_PRICE_HIGH, TA_IN_PRICE_LOW, TA_IN_PRICE_CLOSE

  • time_period (Integer) (defaults to: 14.0)

    Number of period (default: 14.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 2060

.wma(real, time_period: 30.0) ⇒ Array<Float>

Weighted Moving Average

Parameters:

  • real (Array<Float>)

    Input values

  • time_period (Integer) (defaults to: 30.0)

    Number of period (default: 30.0)

Returns:

  • (Array<Float>)

Raises:

  • (TALibError)

    If there is an error in function execution



# File 'lib/ta_lib_ffi.rb', line 2068