Class: Indicator::AutoGen::Bbands
- Defined in:
- lib/indicator/auto_gen/bbands.rb
Overview
Ta-Lib function mapping class Function: ‘BBANDS’ Description: ‘Bollinger Bands’ This file has been autogenerated - Do Not Edit.
Instance Attribute Summary collapse
-
#deviations_down ⇒ Object
Deviations down <Double>.
-
#deviations_up ⇒ Object
Deviations up <Double>.
-
#ma_type ⇒ Object
MA Type <MA Type>.
-
#time_period ⇒ Object
Time Period <Integer>.
Attributes inherited from Base
Class Method Summary collapse
-
.arguments ⇒ Object
The list of arguments.
-
.inputs ⇒ Object
The minimum set of inputs required.
-
.outputs ⇒ Object
The outputs generated by this function.
-
.price_input? ⇒ Boolean
Is price data required as an input.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Bbands
constructor
A new instance of Bbands.
- #run(in_real) ⇒ Object
Methods inherited from Base
Methods included from DataMapper
#default_getter, #default_getter=, #map
Constructor Details
#initialize(*args) ⇒ Bbands
Returns a new instance of Bbands.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/indicator/auto_gen/bbands.rb', line 15 def initialize(*args) if args.first.is_a? Hash h = args.first @time_period = h[:time_period] || 5 @deviations_up = h[:deviations_up] || 2.000000e+0 @deviations_down = h[:deviations_down] || 2.000000e+0 @ma_type = h[:ma_type] || 0 else @time_period = args[0] || 5 @deviations_up = args[1] || 2.000000e+0 @deviations_down = args[2] || 2.000000e+0 @ma_type = args[3] || 0 end @func = TaLib::Function.new("BBANDS") end |
Instance Attribute Details
#deviations_down ⇒ Object
Deviations down <Double>
11 12 13 |
# File 'lib/indicator/auto_gen/bbands.rb', line 11 def deviations_down @deviations_down end |
#deviations_up ⇒ Object
Deviations up <Double>
9 10 11 |
# File 'lib/indicator/auto_gen/bbands.rb', line 9 def deviations_up @deviations_up end |
#ma_type ⇒ Object
MA Type <MA Type>
13 14 15 |
# File 'lib/indicator/auto_gen/bbands.rb', line 13 def ma_type @ma_type end |
#time_period ⇒ Object
Time Period <Integer>
7 8 9 |
# File 'lib/indicator/auto_gen/bbands.rb', line 7 def time_period @time_period end |
Class Method Details
.arguments ⇒ Object
The list of arguments
38 39 40 |
# File 'lib/indicator/auto_gen/bbands.rb', line 38 def self.arguments [ :time_period, :deviations_up, :deviations_down, :ma_type ] end |
.inputs ⇒ Object
The minimum set of inputs required
43 44 45 |
# File 'lib/indicator/auto_gen/bbands.rb', line 43 def self.inputs [ :in_real ] end |
.outputs ⇒ Object
The outputs generated by this function
48 49 50 |
# File 'lib/indicator/auto_gen/bbands.rb', line 48 def self.outputs [ :out_real_upper_band, :out_real_middle_band, :out_real_lower_band ] end |
.price_input? ⇒ Boolean
Is price data required as an input
33 34 35 |
# File 'lib/indicator/auto_gen/bbands.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 71 72 73 |
# File 'lib/indicator/auto_gen/bbands.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_real(1, @deviations_up) @func.opt_real(2, @deviations_down) @func.opt_int(3, @ma_type) out_real_upper_band = Array.new(len) @func.out_real(0, out_real_upper_band) out_real_middle_band = Array.new(len) @func.out_real(1, out_real_middle_band) out_real_lower_band = Array.new(len) @func.out_real(2, out_real_lower_band) @func.call(0, len - 1) {:out_real_upper_band => out_real_upper_band, :out_real_middle_band => out_real_middle_band, :out_real_lower_band => out_real_lower_band} end |