Class: Indicator::AutoGen::Sar

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

Overview

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

Returns a new instance of Sar.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/indicator/auto_gen/sar.rb', line 11

def initialize(*args)
  if args.first.is_a? Hash
    h = args.first
    @acceleration_factor = h[:acceleration_factor] || 2.000000e-2
    @af_maximum = h[:af_maximum] || 2.000000e-1
  else
    @acceleration_factor = args[0] || 2.000000e-2 
    @af_maximum = args[1] || 2.000000e-1 
  end
  
  @func = TaLib::Function.new("SAR")
end

Instance Attribute Details

#acceleration_factorObject

Acceleration Factor <Double>



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

def acceleration_factor
  @acceleration_factor
end

#af_maximumObject

AF Maximum <Double>



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

def af_maximum
  @af_maximum
end

Class Method Details

.argumentsObject

The list of arguments



30
31
32
# File 'lib/indicator/auto_gen/sar.rb', line 30

def self.arguments
  [ :acceleration_factor, :af_maximum ]
end

.inputsObject

The minimum set of inputs required



35
36
37
# File 'lib/indicator/auto_gen/sar.rb', line 35

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

.outputsObject

The outputs generated by this function



40
41
42
# File 'lib/indicator/auto_gen/sar.rb', line 40

def self.outputs
  [ :out_real ]
end

.price_input?Boolean

Is price data required as an input

Returns:

  • (Boolean)


25
26
27
# File 'lib/indicator/auto_gen/sar.rb', line 25

def self.price_input?
  true
end

Instance Method Details

#run(*args) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/indicator/auto_gen/sar.rb', line 44

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, @acceleration_factor)
  @func.opt_real(1, @af_maximum)

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

  @func.call(0, len - 1)

  out_real
end