Class: Indicator::AutoGen::MovingAverageVariablePeriod

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

Overview

Ta-Lib function mapping class Function: ‘MAVP’ Description: ‘Moving average with variable period’ 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) ⇒ MovingAverageVariablePeriod

Returns a new instance of MovingAverageVariablePeriod.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/indicator/auto_gen/moving_average_variable_period.rb', line 13

def initialize(*args)
  if args.first.is_a? Hash
    h = args.first
    @minimum_period = h[:minimum_period] || 2
    @maximum_period = h[:maximum_period] || 30
    @ma_type = h[:ma_type] || 0
  else
    @minimum_period = args[0] || 2 
    @maximum_period = args[1] || 30 
    @ma_type = args[2] || 0 
  end
  
  @func = TaLib::Function.new("MAVP")
end

Instance Attribute Details

#ma_typeObject

MA Type <MA Type>



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

def ma_type
  @ma_type
end

#maximum_periodObject

Maximum Period <Integer>



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

def maximum_period
  @maximum_period
end

#minimum_periodObject

Minimum Period <Integer>



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

def minimum_period
  @minimum_period
end

Class Method Details

.argumentsObject

The list of arguments



34
35
36
# File 'lib/indicator/auto_gen/moving_average_variable_period.rb', line 34

def self.arguments
  [ :minimum_period, :maximum_period, :ma_type ]
end

.inputsObject

The minimum set of inputs required



39
40
41
# File 'lib/indicator/auto_gen/moving_average_variable_period.rb', line 39

def self.inputs
  [ :in_real, :in_periods ]
end

.outputsObject

The outputs generated by this function



44
45
46
# File 'lib/indicator/auto_gen/moving_average_variable_period.rb', line 44

def self.outputs
  [ :out_real ]
end

.price_input?Boolean

Is price data required as an input

Returns:

  • (Boolean)


29
30
31
# File 'lib/indicator/auto_gen/moving_average_variable_period.rb', line 29

def self.price_input?
  false
end

Instance Method Details

#run(in_real, in_periods) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/indicator/auto_gen/moving_average_variable_period.rb', line 48

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

  @func.opt_int(0, @minimum_period)
  @func.opt_int(1, @maximum_period)
  @func.opt_int(2, @ma_type)

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

  @func.call(0, len - 1)

  out_real
end