ta-indicator 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +200 -196
- data/examples/mapping.rb +15 -0
- data/lib/indicator/auto_gen.rb +158 -158
- data/lib/indicator/auto_gen/ad.rb +2 -2
- data/lib/indicator/auto_gen/ad_osc.rb +2 -2
- data/lib/indicator/auto_gen/adx.rb +2 -2
- data/lib/indicator/auto_gen/adxr.rb +2 -2
- data/lib/indicator/auto_gen/aroon.rb +2 -2
- data/lib/indicator/auto_gen/aroon_osc.rb +2 -2
- data/lib/indicator/auto_gen/atr.rb +2 -2
- data/lib/indicator/auto_gen/avg_price.rb +1 -1
- data/lib/indicator/auto_gen/bop.rb +1 -1
- data/lib/indicator/auto_gen/cci.rb +2 -2
- data/lib/indicator/auto_gen/cdl2_crows.rb +1 -1
- data/lib/indicator/auto_gen/cdl3_black_crows.rb +1 -1
- data/lib/indicator/auto_gen/cdl3_inside.rb +1 -1
- data/lib/indicator/auto_gen/cdl3_line_strike.rb +1 -1
- data/lib/indicator/auto_gen/cdl3_outside.rb +1 -1
- data/lib/indicator/auto_gen/cdl3_stars_in_south.rb +1 -1
- data/lib/indicator/auto_gen/cdl3_white_soldiers.rb +1 -1
- data/lib/indicator/auto_gen/cdl_abandoned_baby.rb +1 -1
- data/lib/indicator/auto_gen/cdl_advance_block.rb +1 -1
- data/lib/indicator/auto_gen/cdl_belt_hold.rb +1 -1
- data/lib/indicator/auto_gen/cdl_breakaway.rb +1 -1
- data/lib/indicator/auto_gen/cdl_closing_marubozu.rb +1 -1
- data/lib/indicator/auto_gen/cdl_conceal_babys_wall.rb +1 -1
- data/lib/indicator/auto_gen/cdl_counter_attack.rb +1 -1
- data/lib/indicator/auto_gen/cdl_dark_cloud_cover.rb +1 -1
- data/lib/indicator/auto_gen/cdl_doji.rb +1 -1
- data/lib/indicator/auto_gen/cdl_doji_star.rb +1 -1
- data/lib/indicator/auto_gen/cdl_dragonfly_doji.rb +1 -1
- data/lib/indicator/auto_gen/cdl_engulfing.rb +1 -1
- data/lib/indicator/auto_gen/cdl_evening_doji_star.rb +1 -1
- data/lib/indicator/auto_gen/cdl_evening_star.rb +1 -1
- data/lib/indicator/auto_gen/cdl_gap_side_side_white.rb +1 -1
- data/lib/indicator/auto_gen/cdl_gravestone_doji.rb +1 -1
- data/lib/indicator/auto_gen/cdl_hammer.rb +1 -1
- data/lib/indicator/auto_gen/cdl_hanging_man.rb +1 -1
- data/lib/indicator/auto_gen/cdl_harami.rb +1 -1
- data/lib/indicator/auto_gen/cdl_harami_cross.rb +1 -1
- data/lib/indicator/auto_gen/cdl_hign_wave.rb +1 -1
- data/lib/indicator/auto_gen/cdl_hikkake.rb +1 -1
- data/lib/indicator/auto_gen/cdl_hikkake_mod.rb +1 -1
- data/lib/indicator/auto_gen/cdl_homing_pigeon.rb +1 -1
- data/lib/indicator/auto_gen/cdl_identical3_crows.rb +1 -1
- data/lib/indicator/auto_gen/cdl_in_neck.rb +1 -1
- data/lib/indicator/auto_gen/cdl_inverted_hammer.rb +1 -1
- data/lib/indicator/auto_gen/cdl_kicking.rb +1 -1
- data/lib/indicator/auto_gen/cdl_kicking_by_length.rb +1 -1
- data/lib/indicator/auto_gen/cdl_ladder_bottom.rb +1 -1
- data/lib/indicator/auto_gen/cdl_long_legged_doji.rb +1 -1
- data/lib/indicator/auto_gen/cdl_long_line.rb +1 -1
- data/lib/indicator/auto_gen/cdl_marubozu.rb +1 -1
- data/lib/indicator/auto_gen/cdl_mat_hold.rb +1 -1
- data/lib/indicator/auto_gen/cdl_matching_low.rb +1 -1
- data/lib/indicator/auto_gen/cdl_morning_doji_star.rb +1 -1
- data/lib/indicator/auto_gen/cdl_morning_star.rb +1 -1
- data/lib/indicator/auto_gen/cdl_on_neck.rb +1 -1
- data/lib/indicator/auto_gen/cdl_piercing.rb +1 -1
- data/lib/indicator/auto_gen/cdl_rickshaw_man.rb +1 -1
- data/lib/indicator/auto_gen/cdl_rise_fall3_methods.rb +1 -1
- data/lib/indicator/auto_gen/cdl_seperating_lines.rb +1 -1
- data/lib/indicator/auto_gen/cdl_shooting_star.rb +1 -1
- data/lib/indicator/auto_gen/cdl_short_line.rb +1 -1
- data/lib/indicator/auto_gen/cdl_spinning_top.rb +1 -1
- data/lib/indicator/auto_gen/cdl_stalled_pattern.rb +1 -1
- data/lib/indicator/auto_gen/cdl_stick_sandwhich.rb +1 -1
- data/lib/indicator/auto_gen/cdl_takuri.rb +1 -1
- data/lib/indicator/auto_gen/cdl_tasuki_gap.rb +1 -1
- data/lib/indicator/auto_gen/cdl_thrusting.rb +1 -1
- data/lib/indicator/auto_gen/cdl_tristar.rb +1 -1
- data/lib/indicator/auto_gen/cdl_unique3_river.rb +1 -1
- data/lib/indicator/auto_gen/cdl_upside_gap2_crows.rb +1 -1
- data/lib/indicator/auto_gen/cdl_x_side_gap3_methods.rb +1 -1
- data/lib/indicator/auto_gen/dx.rb +2 -2
- data/lib/indicator/auto_gen/med_price.rb +2 -2
- data/lib/indicator/auto_gen/mfi.rb +2 -2
- data/lib/indicator/auto_gen/mid_price.rb +2 -2
- data/lib/indicator/auto_gen/minus_di.rb +2 -2
- data/lib/indicator/auto_gen/minus_dm.rb +2 -2
- data/lib/indicator/auto_gen/natr.rb +2 -2
- data/lib/indicator/auto_gen/obv.rb +6 -5
- data/lib/indicator/auto_gen/plus_di.rb +2 -2
- data/lib/indicator/auto_gen/plus_dm.rb +2 -2
- data/lib/indicator/auto_gen/sar.rb +2 -2
- data/lib/indicator/auto_gen/sar_ext.rb +2 -2
- data/lib/indicator/auto_gen/stoch.rb +2 -2
- data/lib/indicator/auto_gen/stoch_f.rb +2 -2
- data/lib/indicator/auto_gen/true_range.rb +2 -2
- data/lib/indicator/auto_gen/typ_price.rb +2 -2
- data/lib/indicator/auto_gen/ult_osc.rb +2 -2
- data/lib/indicator/auto_gen/wcl_price.rb +2 -2
- data/lib/indicator/auto_gen/will_r.rb +2 -2
- data/lib/indicator/base.rb +18 -0
- data/lib/indicator/data_mapper.rb +0 -20
- data/lib/indicator/version.rb +1 -1
- 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
|
-
[ :
|
|
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(
|
|
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
|
-
[ :
|
|
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(
|
|
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
|
-
[ :
|
|
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(
|
|
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
|
-
[ :
|
|
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(
|
|
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
|
-
[ :
|
|
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(
|
|
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
|
-
[ :
|
|
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(
|
|
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
|
-
[ :
|
|
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(
|
|
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
|
-
[ :
|
|
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(
|
|
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
|
-
[ :
|
|
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(
|
|
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
|
-
[ :
|
|
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(
|
|
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
|
-
[ :
|
|
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(
|
|
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)
|
data/lib/indicator/base.rb
CHANGED
|
@@ -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
|
|
data/lib/indicator/version.rb
CHANGED
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
|
+
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:
|
|
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: &
|
|
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: *
|
|
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: []
|