Class: Indicator::AutoGen::SarExt

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

Overview

Ta-Lib function mapping class Function: ‘SAREXT’ Description: ‘Parabolic SAR - Extended’ 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

Methods included from DataMapper

#default_getter, #default_getter=, #map, #map_ohlcv

Constructor Details

#initialize(*args) ⇒ SarExt

Returns a new instance of SarExt.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/indicator/auto_gen/sar_ext.rb', line 23

def initialize(*args)
  if args.first.is_a? Hash
    h = args.first
    @start_value = h[:start_value] || 0.000000e+0
    @offset_on_reverse = h[:offset_on_reverse] || 0.000000e+0
    @af_init_long = h[:af_init_long] || 2.000000e-2
    @af_long = h[:af_long] || 2.000000e-2
    @af_max_long = h[:af_max_long] || 2.000000e-1
    @af_init_short = h[:af_init_short] || 2.000000e-2
    @af_short = h[:af_short] || 2.000000e-2
    @af_max_short = h[:af_max_short] || 2.000000e-1
  else
    @start_value = args[0] || 0.000000e+0 
    @offset_on_reverse = args[1] || 0.000000e+0 
    @af_init_long = args[2] || 2.000000e-2 
    @af_long = args[3] || 2.000000e-2 
    @af_max_long = args[4] || 2.000000e-1 
    @af_init_short = args[5] || 2.000000e-2 
    @af_short = args[6] || 2.000000e-2 
    @af_max_short = args[7] || 2.000000e-1 
  end
  
  @func = TaLib::Function.new("SAREXT")
end

Instance Attribute Details

#af_init_longObject

AF Init Long <Double>



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

def af_init_long
  @af_init_long
end

#af_init_shortObject

AF Init Short <Double>



17
18
19
# File 'lib/indicator/auto_gen/sar_ext.rb', line 17

def af_init_short
  @af_init_short
end

#af_longObject

AF Long <Double>



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

def af_long
  @af_long
end

#af_max_longObject

AF Max Long <Double>



15
16
17
# File 'lib/indicator/auto_gen/sar_ext.rb', line 15

def af_max_long
  @af_max_long
end

#af_max_shortObject

AF Max Short <Double>



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

def af_max_short
  @af_max_short
end

#af_shortObject

AF Short <Double>



19
20
21
# File 'lib/indicator/auto_gen/sar_ext.rb', line 19

def af_short
  @af_short
end

#offset_on_reverseObject

Offset on Reverse <Double>



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

def offset_on_reverse
  @offset_on_reverse
end

#start_valueObject

Start Value <Double>



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

def start_value
  @start_value
end

Class Method Details

.argumentsObject

The list of arguments



54
55
56
# File 'lib/indicator/auto_gen/sar_ext.rb', line 54

def self.arguments
  [ :start_value, :offset_on_reverse, :af_init_long, :af_long, :af_max_long, :af_init_short, :af_short, :af_max_short ]
end

.inputsObject

The minimum set of inputs required



59
60
61
# File 'lib/indicator/auto_gen/sar_ext.rb', line 59

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

.outputsObject

The outputs generated by this function



64
65
66
# File 'lib/indicator/auto_gen/sar_ext.rb', line 64

def self.outputs
  [ :out_real ]
end

.price_input?Boolean

Is price data required as an input

Returns:

  • (Boolean)


49
50
51
# File 'lib/indicator/auto_gen/sar_ext.rb', line 49

def self.price_input?
  true
end

Instance Method Details

#run(*args) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/indicator/auto_gen/sar_ext.rb', line 68

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

  @func.opt_real(0, @start_value)
  @func.opt_real(1, @offset_on_reverse)
  @func.opt_real(2, @af_init_long)
  @func.opt_real(3, @af_long)
  @func.opt_real(4, @af_max_long)
  @func.opt_real(5, @af_init_short)
  @func.opt_real(6, @af_short)
  @func.opt_real(7, @af_max_short)

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

  @func.call(0, len - 1)

  out_real
end