Class: Indicator::AutoGen::Cci

Inherits:
Base
  • Object
show all
Defined in:
lib/indicator/auto_gen/cci.rb

Overview

Ta-Lib function mapping class Function: ‘CCI’ Description: ‘Commodity Channel Index’ This file has been autogenerated - Do Not Edit.

Instance Attribute Summary collapse

Attributes inherited from Base

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

inherited, #map_ohlcv

Methods included from DataMapper

#default_getter, #default_getter=, #map

Constructor Details

#initialize(*args) ⇒ Cci

Returns a new instance of Cci.



9
10
11
12
13
14
15
16
17
18
# File 'lib/indicator/auto_gen/cci.rb', line 9

def initialize(*args)
  if args.first.is_a? Hash
    h = args.first
    @time_period = h[:time_period] || 14
  else
    @time_period = args[0] || 14 
  end
  
  @func = TaLib::Function.new("CCI")
end

Instance Attribute Details

#time_periodObject

Time Period <Integer>



7
8
9
# File 'lib/indicator/auto_gen/cci.rb', line 7

def time_period
  @time_period
end

Class Method Details

.argumentsObject

The list of arguments



26
27
28
# File 'lib/indicator/auto_gen/cci.rb', line 26

def self.arguments
  [ :time_period ]
end

.inputsObject

The minimum set of inputs required



31
32
33
# File 'lib/indicator/auto_gen/cci.rb', line 31

def self.inputs
  [ :high, :low, :close ]
end

.outputsObject

The outputs generated by this function



36
37
38
# File 'lib/indicator/auto_gen/cci.rb', line 36

def self.outputs
  [ :out_real ]
end

.price_input?Boolean

Is price data required as an input

Returns:

  • (Boolean)


21
22
23
# File 'lib/indicator/auto_gen/cci.rb', line 21

def self.price_input?
  true
end

Instance Method Details

#run(*args) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/indicator/auto_gen/cci.rb', line 40

def run(*args)
  o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
  @func.in_price(0, o, h, l, c, v, nil)

  @func.opt_int(0, @time_period)

  out_real = Array.new(len)
  @func.out_real(0, out_real)

  @func.call(0, len - 1)

  out_real
end