ta-indicator 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/README.rdoc +200 -196
  2. data/examples/mapping.rb +15 -0
  3. data/lib/indicator/auto_gen.rb +158 -158
  4. data/lib/indicator/auto_gen/ad.rb +2 -2
  5. data/lib/indicator/auto_gen/ad_osc.rb +2 -2
  6. data/lib/indicator/auto_gen/adx.rb +2 -2
  7. data/lib/indicator/auto_gen/adxr.rb +2 -2
  8. data/lib/indicator/auto_gen/aroon.rb +2 -2
  9. data/lib/indicator/auto_gen/aroon_osc.rb +2 -2
  10. data/lib/indicator/auto_gen/atr.rb +2 -2
  11. data/lib/indicator/auto_gen/avg_price.rb +1 -1
  12. data/lib/indicator/auto_gen/bop.rb +1 -1
  13. data/lib/indicator/auto_gen/cci.rb +2 -2
  14. data/lib/indicator/auto_gen/cdl2_crows.rb +1 -1
  15. data/lib/indicator/auto_gen/cdl3_black_crows.rb +1 -1
  16. data/lib/indicator/auto_gen/cdl3_inside.rb +1 -1
  17. data/lib/indicator/auto_gen/cdl3_line_strike.rb +1 -1
  18. data/lib/indicator/auto_gen/cdl3_outside.rb +1 -1
  19. data/lib/indicator/auto_gen/cdl3_stars_in_south.rb +1 -1
  20. data/lib/indicator/auto_gen/cdl3_white_soldiers.rb +1 -1
  21. data/lib/indicator/auto_gen/cdl_abandoned_baby.rb +1 -1
  22. data/lib/indicator/auto_gen/cdl_advance_block.rb +1 -1
  23. data/lib/indicator/auto_gen/cdl_belt_hold.rb +1 -1
  24. data/lib/indicator/auto_gen/cdl_breakaway.rb +1 -1
  25. data/lib/indicator/auto_gen/cdl_closing_marubozu.rb +1 -1
  26. data/lib/indicator/auto_gen/cdl_conceal_babys_wall.rb +1 -1
  27. data/lib/indicator/auto_gen/cdl_counter_attack.rb +1 -1
  28. data/lib/indicator/auto_gen/cdl_dark_cloud_cover.rb +1 -1
  29. data/lib/indicator/auto_gen/cdl_doji.rb +1 -1
  30. data/lib/indicator/auto_gen/cdl_doji_star.rb +1 -1
  31. data/lib/indicator/auto_gen/cdl_dragonfly_doji.rb +1 -1
  32. data/lib/indicator/auto_gen/cdl_engulfing.rb +1 -1
  33. data/lib/indicator/auto_gen/cdl_evening_doji_star.rb +1 -1
  34. data/lib/indicator/auto_gen/cdl_evening_star.rb +1 -1
  35. data/lib/indicator/auto_gen/cdl_gap_side_side_white.rb +1 -1
  36. data/lib/indicator/auto_gen/cdl_gravestone_doji.rb +1 -1
  37. data/lib/indicator/auto_gen/cdl_hammer.rb +1 -1
  38. data/lib/indicator/auto_gen/cdl_hanging_man.rb +1 -1
  39. data/lib/indicator/auto_gen/cdl_harami.rb +1 -1
  40. data/lib/indicator/auto_gen/cdl_harami_cross.rb +1 -1
  41. data/lib/indicator/auto_gen/cdl_hign_wave.rb +1 -1
  42. data/lib/indicator/auto_gen/cdl_hikkake.rb +1 -1
  43. data/lib/indicator/auto_gen/cdl_hikkake_mod.rb +1 -1
  44. data/lib/indicator/auto_gen/cdl_homing_pigeon.rb +1 -1
  45. data/lib/indicator/auto_gen/cdl_identical3_crows.rb +1 -1
  46. data/lib/indicator/auto_gen/cdl_in_neck.rb +1 -1
  47. data/lib/indicator/auto_gen/cdl_inverted_hammer.rb +1 -1
  48. data/lib/indicator/auto_gen/cdl_kicking.rb +1 -1
  49. data/lib/indicator/auto_gen/cdl_kicking_by_length.rb +1 -1
  50. data/lib/indicator/auto_gen/cdl_ladder_bottom.rb +1 -1
  51. data/lib/indicator/auto_gen/cdl_long_legged_doji.rb +1 -1
  52. data/lib/indicator/auto_gen/cdl_long_line.rb +1 -1
  53. data/lib/indicator/auto_gen/cdl_marubozu.rb +1 -1
  54. data/lib/indicator/auto_gen/cdl_mat_hold.rb +1 -1
  55. data/lib/indicator/auto_gen/cdl_matching_low.rb +1 -1
  56. data/lib/indicator/auto_gen/cdl_morning_doji_star.rb +1 -1
  57. data/lib/indicator/auto_gen/cdl_morning_star.rb +1 -1
  58. data/lib/indicator/auto_gen/cdl_on_neck.rb +1 -1
  59. data/lib/indicator/auto_gen/cdl_piercing.rb +1 -1
  60. data/lib/indicator/auto_gen/cdl_rickshaw_man.rb +1 -1
  61. data/lib/indicator/auto_gen/cdl_rise_fall3_methods.rb +1 -1
  62. data/lib/indicator/auto_gen/cdl_seperating_lines.rb +1 -1
  63. data/lib/indicator/auto_gen/cdl_shooting_star.rb +1 -1
  64. data/lib/indicator/auto_gen/cdl_short_line.rb +1 -1
  65. data/lib/indicator/auto_gen/cdl_spinning_top.rb +1 -1
  66. data/lib/indicator/auto_gen/cdl_stalled_pattern.rb +1 -1
  67. data/lib/indicator/auto_gen/cdl_stick_sandwhich.rb +1 -1
  68. data/lib/indicator/auto_gen/cdl_takuri.rb +1 -1
  69. data/lib/indicator/auto_gen/cdl_tasuki_gap.rb +1 -1
  70. data/lib/indicator/auto_gen/cdl_thrusting.rb +1 -1
  71. data/lib/indicator/auto_gen/cdl_tristar.rb +1 -1
  72. data/lib/indicator/auto_gen/cdl_unique3_river.rb +1 -1
  73. data/lib/indicator/auto_gen/cdl_upside_gap2_crows.rb +1 -1
  74. data/lib/indicator/auto_gen/cdl_x_side_gap3_methods.rb +1 -1
  75. data/lib/indicator/auto_gen/dx.rb +2 -2
  76. data/lib/indicator/auto_gen/med_price.rb +2 -2
  77. data/lib/indicator/auto_gen/mfi.rb +2 -2
  78. data/lib/indicator/auto_gen/mid_price.rb +2 -2
  79. data/lib/indicator/auto_gen/minus_di.rb +2 -2
  80. data/lib/indicator/auto_gen/minus_dm.rb +2 -2
  81. data/lib/indicator/auto_gen/natr.rb +2 -2
  82. data/lib/indicator/auto_gen/obv.rb +6 -5
  83. data/lib/indicator/auto_gen/plus_di.rb +2 -2
  84. data/lib/indicator/auto_gen/plus_dm.rb +2 -2
  85. data/lib/indicator/auto_gen/sar.rb +2 -2
  86. data/lib/indicator/auto_gen/sar_ext.rb +2 -2
  87. data/lib/indicator/auto_gen/stoch.rb +2 -2
  88. data/lib/indicator/auto_gen/stoch_f.rb +2 -2
  89. data/lib/indicator/auto_gen/true_range.rb +2 -2
  90. data/lib/indicator/auto_gen/typ_price.rb +2 -2
  91. data/lib/indicator/auto_gen/ult_osc.rb +2 -2
  92. data/lib/indicator/auto_gen/wcl_price.rb +2 -2
  93. data/lib/indicator/auto_gen/will_r.rb +2 -2
  94. data/lib/indicator/base.rb +18 -0
  95. data/lib/indicator/data_mapper.rb +0 -20
  96. data/lib/indicator/version.rb +1 -1
  97. metadata +4 -4
@@ -29,7 +29,7 @@ class Indicator::AutoGen::PlusDI < Indicator::Base
29
29
 
30
30
  # The minimum set of inputs required
31
31
  def self.inputs
32
- [ :open, :high, :low, :close ]
32
+ [ :high, :low, :close ]
33
33
  end
34
34
 
35
35
  # The outputs generated by this function
@@ -38,7 +38,7 @@ class Indicator::AutoGen::PlusDI < Indicator::Base
38
38
  end
39
39
 
40
40
  def run(*args)
41
- o, h, l, c, v, len = map_ohlcv(false, *args)
41
+ o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
42
42
  @func.in_price(0, o, h, l, c, v, nil)
43
43
 
44
44
  @func.opt_int(0, @time_period)
@@ -29,7 +29,7 @@ class Indicator::AutoGen::PlusDM < Indicator::Base
29
29
 
30
30
  # The minimum set of inputs required
31
31
  def self.inputs
32
- [ :open, :high, :low, :close ]
32
+ [ :high, :low ]
33
33
  end
34
34
 
35
35
  # The outputs generated by this function
@@ -38,7 +38,7 @@ class Indicator::AutoGen::PlusDM < Indicator::Base
38
38
  end
39
39
 
40
40
  def run(*args)
41
- o, h, l, c, v, len = map_ohlcv(false, *args)
41
+ o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
42
42
  @func.in_price(0, o, h, l, c, v, nil)
43
43
 
44
44
  @func.opt_int(0, @time_period)
@@ -33,7 +33,7 @@ class Indicator::AutoGen::Sar < Indicator::Base
33
33
 
34
34
  # The minimum set of inputs required
35
35
  def self.inputs
36
- [ :open, :high, :low, :close ]
36
+ [ :high, :low ]
37
37
  end
38
38
 
39
39
  # The outputs generated by this function
@@ -42,7 +42,7 @@ class Indicator::AutoGen::Sar < Indicator::Base
42
42
  end
43
43
 
44
44
  def run(*args)
45
- o, h, l, c, v, len = map_ohlcv(false, *args)
45
+ o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
46
46
  @func.in_price(0, o, h, l, c, v, nil)
47
47
 
48
48
  @func.opt_real(0, @acceleration_factor)
@@ -57,7 +57,7 @@ class Indicator::AutoGen::SarExt < Indicator::Base
57
57
 
58
58
  # The minimum set of inputs required
59
59
  def self.inputs
60
- [ :open, :high, :low, :close ]
60
+ [ :high, :low ]
61
61
  end
62
62
 
63
63
  # The outputs generated by this function
@@ -66,7 +66,7 @@ class Indicator::AutoGen::SarExt < Indicator::Base
66
66
  end
67
67
 
68
68
  def run(*args)
69
- o, h, l, c, v, len = map_ohlcv(false, *args)
69
+ o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
70
70
  @func.in_price(0, o, h, l, c, v, nil)
71
71
 
72
72
  @func.opt_real(0, @start_value)
@@ -45,7 +45,7 @@ class Indicator::AutoGen::Stoch < Indicator::Base
45
45
 
46
46
  # The minimum set of inputs required
47
47
  def self.inputs
48
- [ :open, :high, :low, :close ]
48
+ [ :high, :low, :close ]
49
49
  end
50
50
 
51
51
  # The outputs generated by this function
@@ -54,7 +54,7 @@ class Indicator::AutoGen::Stoch < Indicator::Base
54
54
  end
55
55
 
56
56
  def run(*args)
57
- o, h, l, c, v, len = map_ohlcv(false, *args)
57
+ o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
58
58
  @func.in_price(0, o, h, l, c, v, nil)
59
59
 
60
60
  @func.opt_int(0, @fast_k_period)
@@ -37,7 +37,7 @@ class Indicator::AutoGen::StochF < Indicator::Base
37
37
 
38
38
  # The minimum set of inputs required
39
39
  def self.inputs
40
- [ :open, :high, :low, :close ]
40
+ [ :high, :low, :close ]
41
41
  end
42
42
 
43
43
  # The outputs generated by this function
@@ -46,7 +46,7 @@ class Indicator::AutoGen::StochF < Indicator::Base
46
46
  end
47
47
 
48
48
  def run(*args)
49
- o, h, l, c, v, len = map_ohlcv(false, *args)
49
+ o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
50
50
  @func.in_price(0, o, h, l, c, v, nil)
51
51
 
52
52
  @func.opt_int(0, @fast_k_period)
@@ -21,7 +21,7 @@ class Indicator::AutoGen::TrueRange < Indicator::Base
21
21
 
22
22
  # The minimum set of inputs required
23
23
  def self.inputs
24
- [ :open, :high, :low, :close ]
24
+ [ :high, :low, :close ]
25
25
  end
26
26
 
27
27
  # The outputs generated by this function
@@ -30,7 +30,7 @@ class Indicator::AutoGen::TrueRange < Indicator::Base
30
30
  end
31
31
 
32
32
  def run(*args)
33
- o, h, l, c, v, len = map_ohlcv(false, *args)
33
+ o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
34
34
  @func.in_price(0, o, h, l, c, v, nil)
35
35
 
36
36
 
@@ -21,7 +21,7 @@ class Indicator::AutoGen::TypPrice < Indicator::Base
21
21
 
22
22
  # The minimum set of inputs required
23
23
  def self.inputs
24
- [ :open, :high, :low, :close ]
24
+ [ :high, :low, :close ]
25
25
  end
26
26
 
27
27
  # The outputs generated by this function
@@ -30,7 +30,7 @@ class Indicator::AutoGen::TypPrice < Indicator::Base
30
30
  end
31
31
 
32
32
  def run(*args)
33
- o, h, l, c, v, len = map_ohlcv(false, *args)
33
+ o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
34
34
  @func.in_price(0, o, h, l, c, v, nil)
35
35
 
36
36
 
@@ -37,7 +37,7 @@ class Indicator::AutoGen::UltOsc < Indicator::Base
37
37
 
38
38
  # The minimum set of inputs required
39
39
  def self.inputs
40
- [ :open, :high, :low, :close ]
40
+ [ :high, :low, :close ]
41
41
  end
42
42
 
43
43
  # The outputs generated by this function
@@ -46,7 +46,7 @@ class Indicator::AutoGen::UltOsc < Indicator::Base
46
46
  end
47
47
 
48
48
  def run(*args)
49
- o, h, l, c, v, len = map_ohlcv(false, *args)
49
+ o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
50
50
  @func.in_price(0, o, h, l, c, v, nil)
51
51
 
52
52
  @func.opt_int(0, @first_period)
@@ -21,7 +21,7 @@ class Indicator::AutoGen::WclPrice < Indicator::Base
21
21
 
22
22
  # The minimum set of inputs required
23
23
  def self.inputs
24
- [ :open, :high, :low, :close ]
24
+ [ :high, :low, :close ]
25
25
  end
26
26
 
27
27
  # The outputs generated by this function
@@ -30,7 +30,7 @@ class Indicator::AutoGen::WclPrice < Indicator::Base
30
30
  end
31
31
 
32
32
  def run(*args)
33
- o, h, l, c, v, len = map_ohlcv(false, *args)
33
+ o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
34
34
  @func.in_price(0, o, h, l, c, v, nil)
35
35
 
36
36
 
@@ -29,7 +29,7 @@ class Indicator::AutoGen::WillR < Indicator::Base
29
29
 
30
30
  # The minimum set of inputs required
31
31
  def self.inputs
32
- [ :open, :high, :low, :close ]
32
+ [ :high, :low, :close ]
33
33
  end
34
34
 
35
35
  # The outputs generated by this function
@@ -38,7 +38,7 @@ class Indicator::AutoGen::WillR < Indicator::Base
38
38
  end
39
39
 
40
40
  def run(*args)
41
- o, h, l, c, v, len = map_ohlcv(false, *args)
41
+ o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args)
42
42
  @func.in_price(0, o, h, l, c, v, nil)
43
43
 
44
44
  @func.opt_int(0, @time_period)
@@ -15,5 +15,23 @@ module Indicator
15
15
  def self.inherited(subclass)
16
16
  Base.indicators << subclass
17
17
  end
18
+
19
+ def map_ohlcv types, *args
20
+
21
+ raise ArgumentError unless args.length > 0
22
+ first = args.first
23
+
24
+ l = [:open, :high, :low, :close, :volume].inject([]) do |lst, t|
25
+ if types.include? t
26
+ a = args.shift
27
+ lst << (a ? map(a, t) : map(first, t))
28
+ else
29
+ lst << nil
30
+ end
31
+ end
32
+
33
+ # Push the length onto the end of the array
34
+ l << first.length
35
+ end
18
36
  end
19
37
  end
@@ -65,26 +65,6 @@ module Indicator
65
65
  source.collect { |e| map_proc.call(e) }
66
66
  end
67
67
 
68
- def map_ohlcv volume_required, *args
69
-
70
- raise ArgumentError unless args.length > 0
71
- first = args.first
72
-
73
- types = [:open, :high, :low, :close]
74
- types << :volume if volume_required
75
-
76
- l = types.inject([]) do |lst, t|
77
- a = args.shift
78
- lst << (a ? map(a, t) : map(first, t))
79
- end
80
-
81
- # Push a nil in the place of the volume data series
82
- # if it hasn't been requested
83
- l << nil unless volume_required
84
-
85
- # Push the length onto the end of the array
86
- l << first.length
87
- end
88
68
  end
89
69
  end
90
70
 
@@ -1,3 +1,3 @@
1
1
  module Indicator
2
- VERSION = '0.0.4'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ta-indicator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-29 00:00:00.000000000Z
12
+ date: 2013-01-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: talib_ruby
16
- requirement: &17147904 !ruby/object:Gem::Requirement
16
+ requirement: &18354552 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *17147904
24
+ version_requirements: *18354552
25
25
  description: Higher level wrapper around the talib_ruby project
26
26
  email: mr.lamby@gmail.com
27
27
  executables: []