Class: Indicator::AutoGen::StochRsi

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

Overview

Ta-Lib function mapping class Function: ‘STOCHRSI’ Description: ‘Stochastic Relative Strength 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) ⇒ StochRsi

Returns a new instance of StochRsi.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/indicator/auto_gen/stoch_rsi.rb', line 15

def initialize(*args)
  if args.first.is_a? Hash
    h = args.first
    @time_period = h[:time_period] || 14
    @fast_k_period = h[:fast_k_period] || 5
    @fast_d_period = h[:fast_d_period] || 3
    @fast_d_ma = h[:fast_d_ma] || 0
  else
    @time_period = args[0] || 14 
    @fast_k_period = args[1] || 5 
    @fast_d_period = args[2] || 3 
    @fast_d_ma = args[3] || 0 
  end
  
  @func = TaLib::Function.new("STOCHRSI")
end

Instance Attribute Details

#fast_d_maObject

Fast-D MA <MA Type>



13
14
15
# File 'lib/indicator/auto_gen/stoch_rsi.rb', line 13

def fast_d_ma
  @fast_d_ma
end

#fast_d_periodObject

Fast-D Period <Integer>



11
12
13
# File 'lib/indicator/auto_gen/stoch_rsi.rb', line 11

def fast_d_period
  @fast_d_period
end

#fast_k_periodObject

Fast-K Period <Integer>



9
10
11
# File 'lib/indicator/auto_gen/stoch_rsi.rb', line 9

def fast_k_period
  @fast_k_period
end

#time_periodObject

Time Period <Integer>



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

def time_period
  @time_period
end

Class Method Details

.argumentsObject

The list of arguments



38
39
40
# File 'lib/indicator/auto_gen/stoch_rsi.rb', line 38

def self.arguments
  [ :time_period, :fast_k_period, :fast_d_period, :fast_d_ma ]
end

.inputsObject

The minimum set of inputs required



43
44
45
# File 'lib/indicator/auto_gen/stoch_rsi.rb', line 43

def self.inputs
  [ :in_real ]
end

.outputsObject

The outputs generated by this function



48
49
50
# File 'lib/indicator/auto_gen/stoch_rsi.rb', line 48

def self.outputs
  [ :out_fast_k, :out_fast_d ]
end

.price_input?Boolean

Is price data required as an input

Returns:

  • (Boolean)


33
34
35
# File 'lib/indicator/auto_gen/stoch_rsi.rb', line 33

def self.price_input?
  false
end

Instance Method Details

#run(in_real) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/indicator/auto_gen/stoch_rsi.rb', line 52

def run(in_real)
  len = in_real.length
  @func.in_real(0, map(in_real))

  @func.opt_int(0, @time_period)
  @func.opt_int(1, @fast_k_period)
  @func.opt_int(2, @fast_d_period)
  @func.opt_int(3, @fast_d_ma)

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

  @func.call(0, len - 1)

{:out_fast_k => out_fast_k,
  :out_fast_d => out_fast_d}
end