ta-indicator 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. data/LICENSE +10 -0
  2. data/LICENSE-ta-lib +32 -0
  3. data/README.rdoc +196 -0
  4. data/Rakefile +13 -0
  5. data/examples/mapping.rb +43 -0
  6. data/lib/indicator.rb +56 -0
  7. data/lib/indicator/auto_gen.rb +163 -0
  8. data/lib/indicator/auto_gen/acos.rb +44 -0
  9. data/lib/indicator/auto_gen/ad.rb +44 -0
  10. data/lib/indicator/auto_gen/ad_osc.rb +58 -0
  11. data/lib/indicator/auto_gen/add.rb +45 -0
  12. data/lib/indicator/auto_gen/adx.rb +53 -0
  13. data/lib/indicator/auto_gen/adxr.rb +53 -0
  14. data/lib/indicator/auto_gen/apo.rb +63 -0
  15. data/lib/indicator/auto_gen/aroon.rb +56 -0
  16. data/lib/indicator/auto_gen/aroon_osc.rb +53 -0
  17. data/lib/indicator/auto_gen/asin.rb +44 -0
  18. data/lib/indicator/auto_gen/atan.rb +44 -0
  19. data/lib/indicator/auto_gen/atr.rb +53 -0
  20. data/lib/indicator/auto_gen/avg_price.rb +44 -0
  21. data/lib/indicator/auto_gen/bbands.rb +74 -0
  22. data/lib/indicator/auto_gen/beta.rb +54 -0
  23. data/lib/indicator/auto_gen/bop.rb +44 -0
  24. data/lib/indicator/auto_gen/cci.rb +53 -0
  25. data/lib/indicator/auto_gen/cdl2_crows.rb +44 -0
  26. data/lib/indicator/auto_gen/cdl3_black_crows.rb +44 -0
  27. data/lib/indicator/auto_gen/cdl3_inside.rb +44 -0
  28. data/lib/indicator/auto_gen/cdl3_line_strike.rb +44 -0
  29. data/lib/indicator/auto_gen/cdl3_outside.rb +44 -0
  30. data/lib/indicator/auto_gen/cdl3_stars_in_south.rb +44 -0
  31. data/lib/indicator/auto_gen/cdl3_white_soldiers.rb +44 -0
  32. data/lib/indicator/auto_gen/cdl_abandoned_baby.rb +53 -0
  33. data/lib/indicator/auto_gen/cdl_advance_block.rb +44 -0
  34. data/lib/indicator/auto_gen/cdl_belt_hold.rb +44 -0
  35. data/lib/indicator/auto_gen/cdl_breakaway.rb +44 -0
  36. data/lib/indicator/auto_gen/cdl_closing_marubozu.rb +44 -0
  37. data/lib/indicator/auto_gen/cdl_conceal_babys_wall.rb +44 -0
  38. data/lib/indicator/auto_gen/cdl_counter_attack.rb +44 -0
  39. data/lib/indicator/auto_gen/cdl_dark_cloud_cover.rb +53 -0
  40. data/lib/indicator/auto_gen/cdl_doji.rb +44 -0
  41. data/lib/indicator/auto_gen/cdl_doji_star.rb +44 -0
  42. data/lib/indicator/auto_gen/cdl_dragonfly_doji.rb +44 -0
  43. data/lib/indicator/auto_gen/cdl_engulfing.rb +44 -0
  44. data/lib/indicator/auto_gen/cdl_evening_doji_star.rb +53 -0
  45. data/lib/indicator/auto_gen/cdl_evening_star.rb +53 -0
  46. data/lib/indicator/auto_gen/cdl_gap_side_side_white.rb +44 -0
  47. data/lib/indicator/auto_gen/cdl_gravestone_doji.rb +44 -0
  48. data/lib/indicator/auto_gen/cdl_hammer.rb +44 -0
  49. data/lib/indicator/auto_gen/cdl_hanging_man.rb +44 -0
  50. data/lib/indicator/auto_gen/cdl_harami.rb +44 -0
  51. data/lib/indicator/auto_gen/cdl_harami_cross.rb +44 -0
  52. data/lib/indicator/auto_gen/cdl_hign_wave.rb +44 -0
  53. data/lib/indicator/auto_gen/cdl_hikkake.rb +44 -0
  54. data/lib/indicator/auto_gen/cdl_hikkake_mod.rb +44 -0
  55. data/lib/indicator/auto_gen/cdl_homing_pigeon.rb +44 -0
  56. data/lib/indicator/auto_gen/cdl_identical3_crows.rb +44 -0
  57. data/lib/indicator/auto_gen/cdl_in_neck.rb +44 -0
  58. data/lib/indicator/auto_gen/cdl_inverted_hammer.rb +44 -0
  59. data/lib/indicator/auto_gen/cdl_kicking.rb +44 -0
  60. data/lib/indicator/auto_gen/cdl_kicking_by_length.rb +44 -0
  61. data/lib/indicator/auto_gen/cdl_ladder_bottom.rb +44 -0
  62. data/lib/indicator/auto_gen/cdl_long_legged_doji.rb +44 -0
  63. data/lib/indicator/auto_gen/cdl_long_line.rb +44 -0
  64. data/lib/indicator/auto_gen/cdl_marubozu.rb +44 -0
  65. data/lib/indicator/auto_gen/cdl_mat_hold.rb +53 -0
  66. data/lib/indicator/auto_gen/cdl_matching_low.rb +44 -0
  67. data/lib/indicator/auto_gen/cdl_morning_doji_star.rb +53 -0
  68. data/lib/indicator/auto_gen/cdl_morning_star.rb +53 -0
  69. data/lib/indicator/auto_gen/cdl_on_neck.rb +44 -0
  70. data/lib/indicator/auto_gen/cdl_piercing.rb +44 -0
  71. data/lib/indicator/auto_gen/cdl_rickshaw_man.rb +44 -0
  72. data/lib/indicator/auto_gen/cdl_rise_fall3_methods.rb +44 -0
  73. data/lib/indicator/auto_gen/cdl_seperating_lines.rb +44 -0
  74. data/lib/indicator/auto_gen/cdl_shooting_star.rb +44 -0
  75. data/lib/indicator/auto_gen/cdl_short_line.rb +44 -0
  76. data/lib/indicator/auto_gen/cdl_spinning_top.rb +44 -0
  77. data/lib/indicator/auto_gen/cdl_stalled_pattern.rb +44 -0
  78. data/lib/indicator/auto_gen/cdl_stick_sandwhich.rb +44 -0
  79. data/lib/indicator/auto_gen/cdl_takuri.rb +44 -0
  80. data/lib/indicator/auto_gen/cdl_tasuki_gap.rb +44 -0
  81. data/lib/indicator/auto_gen/cdl_thrusting.rb +44 -0
  82. data/lib/indicator/auto_gen/cdl_tristar.rb +44 -0
  83. data/lib/indicator/auto_gen/cdl_unique3_river.rb +44 -0
  84. data/lib/indicator/auto_gen/cdl_upside_gap2_crows.rb +44 -0
  85. data/lib/indicator/auto_gen/cdl_x_side_gap3_methods.rb +44 -0
  86. data/lib/indicator/auto_gen/ceil.rb +44 -0
  87. data/lib/indicator/auto_gen/cmo.rb +53 -0
  88. data/lib/indicator/auto_gen/correl.rb +54 -0
  89. data/lib/indicator/auto_gen/cos.rb +44 -0
  90. data/lib/indicator/auto_gen/cosh.rb +44 -0
  91. data/lib/indicator/auto_gen/dema.rb +53 -0
  92. data/lib/indicator/auto_gen/div.rb +45 -0
  93. data/lib/indicator/auto_gen/dx.rb +53 -0
  94. data/lib/indicator/auto_gen/ema.rb +53 -0
  95. data/lib/indicator/auto_gen/exp.rb +44 -0
  96. data/lib/indicator/auto_gen/floor.rb +44 -0
  97. data/lib/indicator/auto_gen/ht_dc_period.rb +44 -0
  98. data/lib/indicator/auto_gen/ht_dc_phase.rb +44 -0
  99. data/lib/indicator/auto_gen/ht_phasor.rb +47 -0
  100. data/lib/indicator/auto_gen/ht_sine.rb +47 -0
  101. data/lib/indicator/auto_gen/ht_trend_mode.rb +44 -0
  102. data/lib/indicator/auto_gen/ht_trendline.rb +44 -0
  103. data/lib/indicator/auto_gen/kama.rb +53 -0
  104. data/lib/indicator/auto_gen/linear_reg.rb +53 -0
  105. data/lib/indicator/auto_gen/linear_reg_angle.rb +53 -0
  106. data/lib/indicator/auto_gen/linear_reg_intercept.rb +53 -0
  107. data/lib/indicator/auto_gen/linear_reg_slope.rb +53 -0
  108. data/lib/indicator/auto_gen/ln.rb +44 -0
  109. data/lib/indicator/auto_gen/log10.rb +44 -0
  110. data/lib/indicator/auto_gen/macd.rb +69 -0
  111. data/lib/indicator/auto_gen/macd_ext.rb +84 -0
  112. data/lib/indicator/auto_gen/macd_fix.rb +59 -0
  113. data/lib/indicator/auto_gen/mama.rb +61 -0
  114. data/lib/indicator/auto_gen/max.rb +53 -0
  115. data/lib/indicator/auto_gen/max_index.rb +53 -0
  116. data/lib/indicator/auto_gen/med_price.rb +44 -0
  117. data/lib/indicator/auto_gen/mfi.rb +53 -0
  118. data/lib/indicator/auto_gen/mid_point.rb +53 -0
  119. data/lib/indicator/auto_gen/mid_price.rb +53 -0
  120. data/lib/indicator/auto_gen/min.rb +53 -0
  121. data/lib/indicator/auto_gen/min_index.rb +53 -0
  122. data/lib/indicator/auto_gen/min_max.rb +56 -0
  123. data/lib/indicator/auto_gen/min_max_index.rb +56 -0
  124. data/lib/indicator/auto_gen/minus_di.rb +53 -0
  125. data/lib/indicator/auto_gen/minus_dm.rb +53 -0
  126. data/lib/indicator/auto_gen/mom.rb +53 -0
  127. data/lib/indicator/auto_gen/moving_average.rb +58 -0
  128. data/lib/indicator/auto_gen/moving_average_variable_period.rb +64 -0
  129. data/lib/indicator/auto_gen/mult.rb +45 -0
  130. data/lib/indicator/auto_gen/natr.rb +53 -0
  131. data/lib/indicator/auto_gen/obv.rb +44 -0
  132. data/lib/indicator/auto_gen/plus_di.rb +53 -0
  133. data/lib/indicator/auto_gen/plus_dm.rb +53 -0
  134. data/lib/indicator/auto_gen/ppo.rb +63 -0
  135. data/lib/indicator/auto_gen/roc.rb +53 -0
  136. data/lib/indicator/auto_gen/roc_p.rb +53 -0
  137. data/lib/indicator/auto_gen/roc_r.rb +53 -0
  138. data/lib/indicator/auto_gen/roc_r100.rb +53 -0
  139. data/lib/indicator/auto_gen/rsi.rb +53 -0
  140. data/lib/indicator/auto_gen/sar.rb +58 -0
  141. data/lib/indicator/auto_gen/sar_ext.rb +88 -0
  142. data/lib/indicator/auto_gen/sin.rb +44 -0
  143. data/lib/indicator/auto_gen/sinh.rb +44 -0
  144. data/lib/indicator/auto_gen/sma.rb +53 -0
  145. data/lib/indicator/auto_gen/sqrt.rb +44 -0
  146. data/lib/indicator/auto_gen/std_dev.rb +58 -0
  147. data/lib/indicator/auto_gen/stoch.rb +76 -0
  148. data/lib/indicator/auto_gen/stoch_f.rb +66 -0
  149. data/lib/indicator/auto_gen/stoch_rsi.rb +71 -0
  150. data/lib/indicator/auto_gen/sub.rb +45 -0
  151. data/lib/indicator/auto_gen/sum.rb +53 -0
  152. data/lib/indicator/auto_gen/t3.rb +58 -0
  153. data/lib/indicator/auto_gen/tan.rb +44 -0
  154. data/lib/indicator/auto_gen/tanh.rb +44 -0
  155. data/lib/indicator/auto_gen/tema.rb +53 -0
  156. data/lib/indicator/auto_gen/trima.rb +53 -0
  157. data/lib/indicator/auto_gen/trix.rb +53 -0
  158. data/lib/indicator/auto_gen/true_range.rb +44 -0
  159. data/lib/indicator/auto_gen/tsf.rb +53 -0
  160. data/lib/indicator/auto_gen/typ_price.rb +44 -0
  161. data/lib/indicator/auto_gen/ult_osc.rb +63 -0
  162. data/lib/indicator/auto_gen/variance.rb +58 -0
  163. data/lib/indicator/auto_gen/wcl_price.rb +44 -0
  164. data/lib/indicator/auto_gen/will_r.rb +53 -0
  165. data/lib/indicator/auto_gen/wma.rb +53 -0
  166. data/lib/indicator/base.rb +19 -0
  167. data/lib/indicator/data_mapper.rb +93 -0
  168. data/lib/indicator/mixin.rb +15 -0
  169. data/lib/indicator/version.rb +3 -0
  170. data/test/data_mapper_test.rb +76 -0
  171. metadata +226 -0
@@ -0,0 +1,53 @@
1
+ # Ta-Lib function mapping class
2
+ # Function: 'LINEARREG_ANGLE'
3
+ # Description: 'Linear Regression Angle'
4
+ # This file has been autogenerated - Do Not Edit.
5
+ class Indicator::AutoGen::LinearRegAngle < Indicator::Base
6
+ # Time Period <Integer>
7
+ attr_accessor :time_period
8
+
9
+ def initialize(*args)
10
+ if args.first.is_a? Hash
11
+ h = args.first
12
+ @time_period = h[:time_period] || 14
13
+ else
14
+ @time_period = args[0] || 14
15
+ end
16
+
17
+ @func = TaLib::Function.new("LINEARREG_ANGLE")
18
+ end
19
+
20
+ # Is price data required as an input
21
+ def self.price_input?
22
+ false
23
+ end
24
+
25
+ # The list of arguments
26
+ def self.arguments
27
+ [ :time_period ]
28
+ end
29
+
30
+ # The minimum set of inputs required
31
+ def self.inputs
32
+ [ :in_real ]
33
+ end
34
+
35
+ # The outputs generated by this function
36
+ def self.outputs
37
+ [ :out_real ]
38
+ end
39
+
40
+ def run(in_real)
41
+ len = in_real.length
42
+ @func.in_real(0, map(in_real))
43
+
44
+ @func.opt_int(0, @time_period)
45
+
46
+ out_real = Array.new(len)
47
+ @func.out_real(0, out_real)
48
+
49
+ @func.call(0, len - 1)
50
+
51
+ out_real
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ # Ta-Lib function mapping class
2
+ # Function: 'LINEARREG_INTERCEPT'
3
+ # Description: 'Linear Regression Intercept'
4
+ # This file has been autogenerated - Do Not Edit.
5
+ class Indicator::AutoGen::LinearRegIntercept < Indicator::Base
6
+ # Time Period <Integer>
7
+ attr_accessor :time_period
8
+
9
+ def initialize(*args)
10
+ if args.first.is_a? Hash
11
+ h = args.first
12
+ @time_period = h[:time_period] || 14
13
+ else
14
+ @time_period = args[0] || 14
15
+ end
16
+
17
+ @func = TaLib::Function.new("LINEARREG_INTERCEPT")
18
+ end
19
+
20
+ # Is price data required as an input
21
+ def self.price_input?
22
+ false
23
+ end
24
+
25
+ # The list of arguments
26
+ def self.arguments
27
+ [ :time_period ]
28
+ end
29
+
30
+ # The minimum set of inputs required
31
+ def self.inputs
32
+ [ :in_real ]
33
+ end
34
+
35
+ # The outputs generated by this function
36
+ def self.outputs
37
+ [ :out_real ]
38
+ end
39
+
40
+ def run(in_real)
41
+ len = in_real.length
42
+ @func.in_real(0, map(in_real))
43
+
44
+ @func.opt_int(0, @time_period)
45
+
46
+ out_real = Array.new(len)
47
+ @func.out_real(0, out_real)
48
+
49
+ @func.call(0, len - 1)
50
+
51
+ out_real
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ # Ta-Lib function mapping class
2
+ # Function: 'LINEARREG_SLOPE'
3
+ # Description: 'Linear Regression Slope'
4
+ # This file has been autogenerated - Do Not Edit.
5
+ class Indicator::AutoGen::LinearRegSlope < Indicator::Base
6
+ # Time Period <Integer>
7
+ attr_accessor :time_period
8
+
9
+ def initialize(*args)
10
+ if args.first.is_a? Hash
11
+ h = args.first
12
+ @time_period = h[:time_period] || 14
13
+ else
14
+ @time_period = args[0] || 14
15
+ end
16
+
17
+ @func = TaLib::Function.new("LINEARREG_SLOPE")
18
+ end
19
+
20
+ # Is price data required as an input
21
+ def self.price_input?
22
+ false
23
+ end
24
+
25
+ # The list of arguments
26
+ def self.arguments
27
+ [ :time_period ]
28
+ end
29
+
30
+ # The minimum set of inputs required
31
+ def self.inputs
32
+ [ :in_real ]
33
+ end
34
+
35
+ # The outputs generated by this function
36
+ def self.outputs
37
+ [ :out_real ]
38
+ end
39
+
40
+ def run(in_real)
41
+ len = in_real.length
42
+ @func.in_real(0, map(in_real))
43
+
44
+ @func.opt_int(0, @time_period)
45
+
46
+ out_real = Array.new(len)
47
+ @func.out_real(0, out_real)
48
+
49
+ @func.call(0, len - 1)
50
+
51
+ out_real
52
+ end
53
+ end
@@ -0,0 +1,44 @@
1
+ # Ta-Lib function mapping class
2
+ # Function: 'LN'
3
+ # Description: 'Vector Log Natural'
4
+ # This file has been autogenerated - Do Not Edit.
5
+ class Indicator::AutoGen::Ln < Indicator::Base
6
+
7
+ def initialize(*args)
8
+
9
+ @func = TaLib::Function.new("LN")
10
+ end
11
+
12
+ # Is price data required as an input
13
+ def self.price_input?
14
+ false
15
+ end
16
+
17
+ # The list of arguments
18
+ def self.arguments
19
+ [ ]
20
+ end
21
+
22
+ # The minimum set of inputs required
23
+ def self.inputs
24
+ [ :in_real ]
25
+ end
26
+
27
+ # The outputs generated by this function
28
+ def self.outputs
29
+ [ :out_real ]
30
+ end
31
+
32
+ def run(in_real)
33
+ len = in_real.length
34
+ @func.in_real(0, map(in_real))
35
+
36
+
37
+ out_real = Array.new(len)
38
+ @func.out_real(0, out_real)
39
+
40
+ @func.call(0, len - 1)
41
+
42
+ out_real
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ # Ta-Lib function mapping class
2
+ # Function: 'LOG10'
3
+ # Description: 'Vector Log10'
4
+ # This file has been autogenerated - Do Not Edit.
5
+ class Indicator::AutoGen::Log10 < Indicator::Base
6
+
7
+ def initialize(*args)
8
+
9
+ @func = TaLib::Function.new("LOG10")
10
+ end
11
+
12
+ # Is price data required as an input
13
+ def self.price_input?
14
+ false
15
+ end
16
+
17
+ # The list of arguments
18
+ def self.arguments
19
+ [ ]
20
+ end
21
+
22
+ # The minimum set of inputs required
23
+ def self.inputs
24
+ [ :in_real ]
25
+ end
26
+
27
+ # The outputs generated by this function
28
+ def self.outputs
29
+ [ :out_real ]
30
+ end
31
+
32
+ def run(in_real)
33
+ len = in_real.length
34
+ @func.in_real(0, map(in_real))
35
+
36
+
37
+ out_real = Array.new(len)
38
+ @func.out_real(0, out_real)
39
+
40
+ @func.call(0, len - 1)
41
+
42
+ out_real
43
+ end
44
+ end
@@ -0,0 +1,69 @@
1
+ # Ta-Lib function mapping class
2
+ # Function: 'MACD'
3
+ # Description: 'Moving Average Convergence/Divergence'
4
+ # This file has been autogenerated - Do Not Edit.
5
+ class Indicator::AutoGen::Macd < Indicator::Base
6
+ # Fast Period <Integer>
7
+ attr_accessor :fast_period
8
+ # Slow Period <Integer>
9
+ attr_accessor :slow_period
10
+ # Signal Period <Integer>
11
+ attr_accessor :signal_period
12
+
13
+ def initialize(*args)
14
+ if args.first.is_a? Hash
15
+ h = args.first
16
+ @fast_period = h[:fast_period] || 12
17
+ @slow_period = h[:slow_period] || 26
18
+ @signal_period = h[:signal_period] || 9
19
+ else
20
+ @fast_period = args[0] || 12
21
+ @slow_period = args[1] || 26
22
+ @signal_period = args[2] || 9
23
+ end
24
+
25
+ @func = TaLib::Function.new("MACD")
26
+ end
27
+
28
+ # Is price data required as an input
29
+ def self.price_input?
30
+ false
31
+ end
32
+
33
+ # The list of arguments
34
+ def self.arguments
35
+ [ :fast_period, :slow_period, :signal_period ]
36
+ end
37
+
38
+ # The minimum set of inputs required
39
+ def self.inputs
40
+ [ :in_real ]
41
+ end
42
+
43
+ # The outputs generated by this function
44
+ def self.outputs
45
+ [ :out_macd, :out_macd_signal, :out_macd_hist ]
46
+ end
47
+
48
+ def run(in_real)
49
+ len = in_real.length
50
+ @func.in_real(0, map(in_real))
51
+
52
+ @func.opt_int(0, @fast_period)
53
+ @func.opt_int(1, @slow_period)
54
+ @func.opt_int(2, @signal_period)
55
+
56
+ out_macd = Array.new(len)
57
+ @func.out_real(0, out_macd)
58
+ out_macd_signal = Array.new(len)
59
+ @func.out_real(1, out_macd_signal)
60
+ out_macd_hist = Array.new(len)
61
+ @func.out_real(2, out_macd_hist)
62
+
63
+ @func.call(0, len - 1)
64
+
65
+ {:out_macd => out_macd,
66
+ :out_macd_signal => out_macd_signal,
67
+ :out_macd_hist => out_macd_hist}
68
+ end
69
+ end
@@ -0,0 +1,84 @@
1
+ # Ta-Lib function mapping class
2
+ # Function: 'MACDEXT'
3
+ # Description: 'MACD with controllable MA type'
4
+ # This file has been autogenerated - Do Not Edit.
5
+ class Indicator::AutoGen::MacdExt < Indicator::Base
6
+ # Fast Period <Integer>
7
+ attr_accessor :fast_period
8
+ # Fast MA <MA Type>
9
+ attr_accessor :fast_ma
10
+ # Slow Period <Integer>
11
+ attr_accessor :slow_period
12
+ # Slow MA <MA Type>
13
+ attr_accessor :slow_ma
14
+ # Signal Period <Integer>
15
+ attr_accessor :signal_period
16
+ # Signal MA <MA Type>
17
+ attr_accessor :signal_ma
18
+
19
+ def initialize(*args)
20
+ if args.first.is_a? Hash
21
+ h = args.first
22
+ @fast_period = h[:fast_period] || 12
23
+ @fast_ma = h[:fast_ma] || 0
24
+ @slow_period = h[:slow_period] || 26
25
+ @slow_ma = h[:slow_ma] || 0
26
+ @signal_period = h[:signal_period] || 9
27
+ @signal_ma = h[:signal_ma] || 0
28
+ else
29
+ @fast_period = args[0] || 12
30
+ @fast_ma = args[1] || 0
31
+ @slow_period = args[2] || 26
32
+ @slow_ma = args[3] || 0
33
+ @signal_period = args[4] || 9
34
+ @signal_ma = args[5] || 0
35
+ end
36
+
37
+ @func = TaLib::Function.new("MACDEXT")
38
+ end
39
+
40
+ # Is price data required as an input
41
+ def self.price_input?
42
+ false
43
+ end
44
+
45
+ # The list of arguments
46
+ def self.arguments
47
+ [ :fast_period, :fast_ma, :slow_period, :slow_ma, :signal_period, :signal_ma ]
48
+ end
49
+
50
+ # The minimum set of inputs required
51
+ def self.inputs
52
+ [ :in_real ]
53
+ end
54
+
55
+ # The outputs generated by this function
56
+ def self.outputs
57
+ [ :out_macd, :out_macd_signal, :out_macd_hist ]
58
+ end
59
+
60
+ def run(in_real)
61
+ len = in_real.length
62
+ @func.in_real(0, map(in_real))
63
+
64
+ @func.opt_int(0, @fast_period)
65
+ @func.opt_int(1, @fast_ma)
66
+ @func.opt_int(2, @slow_period)
67
+ @func.opt_int(3, @slow_ma)
68
+ @func.opt_int(4, @signal_period)
69
+ @func.opt_int(5, @signal_ma)
70
+
71
+ out_macd = Array.new(len)
72
+ @func.out_real(0, out_macd)
73
+ out_macd_signal = Array.new(len)
74
+ @func.out_real(1, out_macd_signal)
75
+ out_macd_hist = Array.new(len)
76
+ @func.out_real(2, out_macd_hist)
77
+
78
+ @func.call(0, len - 1)
79
+
80
+ {:out_macd => out_macd,
81
+ :out_macd_signal => out_macd_signal,
82
+ :out_macd_hist => out_macd_hist}
83
+ end
84
+ end
@@ -0,0 +1,59 @@
1
+ # Ta-Lib function mapping class
2
+ # Function: 'MACDFIX'
3
+ # Description: 'Moving Average Convergence/Divergence Fix 12/26'
4
+ # This file has been autogenerated - Do Not Edit.
5
+ class Indicator::AutoGen::MacdFix < Indicator::Base
6
+ # Signal Period <Integer>
7
+ attr_accessor :signal_period
8
+
9
+ def initialize(*args)
10
+ if args.first.is_a? Hash
11
+ h = args.first
12
+ @signal_period = h[:signal_period] || 9
13
+ else
14
+ @signal_period = args[0] || 9
15
+ end
16
+
17
+ @func = TaLib::Function.new("MACDFIX")
18
+ end
19
+
20
+ # Is price data required as an input
21
+ def self.price_input?
22
+ false
23
+ end
24
+
25
+ # The list of arguments
26
+ def self.arguments
27
+ [ :signal_period ]
28
+ end
29
+
30
+ # The minimum set of inputs required
31
+ def self.inputs
32
+ [ :in_real ]
33
+ end
34
+
35
+ # The outputs generated by this function
36
+ def self.outputs
37
+ [ :out_macd, :out_macd_signal, :out_macd_hist ]
38
+ end
39
+
40
+ def run(in_real)
41
+ len = in_real.length
42
+ @func.in_real(0, map(in_real))
43
+
44
+ @func.opt_int(0, @signal_period)
45
+
46
+ out_macd = Array.new(len)
47
+ @func.out_real(0, out_macd)
48
+ out_macd_signal = Array.new(len)
49
+ @func.out_real(1, out_macd_signal)
50
+ out_macd_hist = Array.new(len)
51
+ @func.out_real(2, out_macd_hist)
52
+
53
+ @func.call(0, len - 1)
54
+
55
+ {:out_macd => out_macd,
56
+ :out_macd_signal => out_macd_signal,
57
+ :out_macd_hist => out_macd_hist}
58
+ end
59
+ end