ta-indicator 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +10 -0
- data/LICENSE-ta-lib +32 -0
- data/README.rdoc +196 -0
- data/Rakefile +13 -0
- data/examples/mapping.rb +43 -0
- data/lib/indicator.rb +56 -0
- data/lib/indicator/auto_gen.rb +163 -0
- data/lib/indicator/auto_gen/acos.rb +44 -0
- data/lib/indicator/auto_gen/ad.rb +44 -0
- data/lib/indicator/auto_gen/ad_osc.rb +58 -0
- data/lib/indicator/auto_gen/add.rb +45 -0
- data/lib/indicator/auto_gen/adx.rb +53 -0
- data/lib/indicator/auto_gen/adxr.rb +53 -0
- data/lib/indicator/auto_gen/apo.rb +63 -0
- data/lib/indicator/auto_gen/aroon.rb +56 -0
- data/lib/indicator/auto_gen/aroon_osc.rb +53 -0
- data/lib/indicator/auto_gen/asin.rb +44 -0
- data/lib/indicator/auto_gen/atan.rb +44 -0
- data/lib/indicator/auto_gen/atr.rb +53 -0
- data/lib/indicator/auto_gen/avg_price.rb +44 -0
- data/lib/indicator/auto_gen/bbands.rb +74 -0
- data/lib/indicator/auto_gen/beta.rb +54 -0
- data/lib/indicator/auto_gen/bop.rb +44 -0
- data/lib/indicator/auto_gen/cci.rb +53 -0
- data/lib/indicator/auto_gen/cdl2_crows.rb +44 -0
- data/lib/indicator/auto_gen/cdl3_black_crows.rb +44 -0
- data/lib/indicator/auto_gen/cdl3_inside.rb +44 -0
- data/lib/indicator/auto_gen/cdl3_line_strike.rb +44 -0
- data/lib/indicator/auto_gen/cdl3_outside.rb +44 -0
- data/lib/indicator/auto_gen/cdl3_stars_in_south.rb +44 -0
- data/lib/indicator/auto_gen/cdl3_white_soldiers.rb +44 -0
- data/lib/indicator/auto_gen/cdl_abandoned_baby.rb +53 -0
- data/lib/indicator/auto_gen/cdl_advance_block.rb +44 -0
- data/lib/indicator/auto_gen/cdl_belt_hold.rb +44 -0
- data/lib/indicator/auto_gen/cdl_breakaway.rb +44 -0
- data/lib/indicator/auto_gen/cdl_closing_marubozu.rb +44 -0
- data/lib/indicator/auto_gen/cdl_conceal_babys_wall.rb +44 -0
- data/lib/indicator/auto_gen/cdl_counter_attack.rb +44 -0
- data/lib/indicator/auto_gen/cdl_dark_cloud_cover.rb +53 -0
- data/lib/indicator/auto_gen/cdl_doji.rb +44 -0
- data/lib/indicator/auto_gen/cdl_doji_star.rb +44 -0
- data/lib/indicator/auto_gen/cdl_dragonfly_doji.rb +44 -0
- data/lib/indicator/auto_gen/cdl_engulfing.rb +44 -0
- data/lib/indicator/auto_gen/cdl_evening_doji_star.rb +53 -0
- data/lib/indicator/auto_gen/cdl_evening_star.rb +53 -0
- data/lib/indicator/auto_gen/cdl_gap_side_side_white.rb +44 -0
- data/lib/indicator/auto_gen/cdl_gravestone_doji.rb +44 -0
- data/lib/indicator/auto_gen/cdl_hammer.rb +44 -0
- data/lib/indicator/auto_gen/cdl_hanging_man.rb +44 -0
- data/lib/indicator/auto_gen/cdl_harami.rb +44 -0
- data/lib/indicator/auto_gen/cdl_harami_cross.rb +44 -0
- data/lib/indicator/auto_gen/cdl_hign_wave.rb +44 -0
- data/lib/indicator/auto_gen/cdl_hikkake.rb +44 -0
- data/lib/indicator/auto_gen/cdl_hikkake_mod.rb +44 -0
- data/lib/indicator/auto_gen/cdl_homing_pigeon.rb +44 -0
- data/lib/indicator/auto_gen/cdl_identical3_crows.rb +44 -0
- data/lib/indicator/auto_gen/cdl_in_neck.rb +44 -0
- data/lib/indicator/auto_gen/cdl_inverted_hammer.rb +44 -0
- data/lib/indicator/auto_gen/cdl_kicking.rb +44 -0
- data/lib/indicator/auto_gen/cdl_kicking_by_length.rb +44 -0
- data/lib/indicator/auto_gen/cdl_ladder_bottom.rb +44 -0
- data/lib/indicator/auto_gen/cdl_long_legged_doji.rb +44 -0
- data/lib/indicator/auto_gen/cdl_long_line.rb +44 -0
- data/lib/indicator/auto_gen/cdl_marubozu.rb +44 -0
- data/lib/indicator/auto_gen/cdl_mat_hold.rb +53 -0
- data/lib/indicator/auto_gen/cdl_matching_low.rb +44 -0
- data/lib/indicator/auto_gen/cdl_morning_doji_star.rb +53 -0
- data/lib/indicator/auto_gen/cdl_morning_star.rb +53 -0
- data/lib/indicator/auto_gen/cdl_on_neck.rb +44 -0
- data/lib/indicator/auto_gen/cdl_piercing.rb +44 -0
- data/lib/indicator/auto_gen/cdl_rickshaw_man.rb +44 -0
- data/lib/indicator/auto_gen/cdl_rise_fall3_methods.rb +44 -0
- data/lib/indicator/auto_gen/cdl_seperating_lines.rb +44 -0
- data/lib/indicator/auto_gen/cdl_shooting_star.rb +44 -0
- data/lib/indicator/auto_gen/cdl_short_line.rb +44 -0
- data/lib/indicator/auto_gen/cdl_spinning_top.rb +44 -0
- data/lib/indicator/auto_gen/cdl_stalled_pattern.rb +44 -0
- data/lib/indicator/auto_gen/cdl_stick_sandwhich.rb +44 -0
- data/lib/indicator/auto_gen/cdl_takuri.rb +44 -0
- data/lib/indicator/auto_gen/cdl_tasuki_gap.rb +44 -0
- data/lib/indicator/auto_gen/cdl_thrusting.rb +44 -0
- data/lib/indicator/auto_gen/cdl_tristar.rb +44 -0
- data/lib/indicator/auto_gen/cdl_unique3_river.rb +44 -0
- data/lib/indicator/auto_gen/cdl_upside_gap2_crows.rb +44 -0
- data/lib/indicator/auto_gen/cdl_x_side_gap3_methods.rb +44 -0
- data/lib/indicator/auto_gen/ceil.rb +44 -0
- data/lib/indicator/auto_gen/cmo.rb +53 -0
- data/lib/indicator/auto_gen/correl.rb +54 -0
- data/lib/indicator/auto_gen/cos.rb +44 -0
- data/lib/indicator/auto_gen/cosh.rb +44 -0
- data/lib/indicator/auto_gen/dema.rb +53 -0
- data/lib/indicator/auto_gen/div.rb +45 -0
- data/lib/indicator/auto_gen/dx.rb +53 -0
- data/lib/indicator/auto_gen/ema.rb +53 -0
- data/lib/indicator/auto_gen/exp.rb +44 -0
- data/lib/indicator/auto_gen/floor.rb +44 -0
- data/lib/indicator/auto_gen/ht_dc_period.rb +44 -0
- data/lib/indicator/auto_gen/ht_dc_phase.rb +44 -0
- data/lib/indicator/auto_gen/ht_phasor.rb +47 -0
- data/lib/indicator/auto_gen/ht_sine.rb +47 -0
- data/lib/indicator/auto_gen/ht_trend_mode.rb +44 -0
- data/lib/indicator/auto_gen/ht_trendline.rb +44 -0
- data/lib/indicator/auto_gen/kama.rb +53 -0
- data/lib/indicator/auto_gen/linear_reg.rb +53 -0
- data/lib/indicator/auto_gen/linear_reg_angle.rb +53 -0
- data/lib/indicator/auto_gen/linear_reg_intercept.rb +53 -0
- data/lib/indicator/auto_gen/linear_reg_slope.rb +53 -0
- data/lib/indicator/auto_gen/ln.rb +44 -0
- data/lib/indicator/auto_gen/log10.rb +44 -0
- data/lib/indicator/auto_gen/macd.rb +69 -0
- data/lib/indicator/auto_gen/macd_ext.rb +84 -0
- data/lib/indicator/auto_gen/macd_fix.rb +59 -0
- data/lib/indicator/auto_gen/mama.rb +61 -0
- data/lib/indicator/auto_gen/max.rb +53 -0
- data/lib/indicator/auto_gen/max_index.rb +53 -0
- data/lib/indicator/auto_gen/med_price.rb +44 -0
- data/lib/indicator/auto_gen/mfi.rb +53 -0
- data/lib/indicator/auto_gen/mid_point.rb +53 -0
- data/lib/indicator/auto_gen/mid_price.rb +53 -0
- data/lib/indicator/auto_gen/min.rb +53 -0
- data/lib/indicator/auto_gen/min_index.rb +53 -0
- data/lib/indicator/auto_gen/min_max.rb +56 -0
- data/lib/indicator/auto_gen/min_max_index.rb +56 -0
- data/lib/indicator/auto_gen/minus_di.rb +53 -0
- data/lib/indicator/auto_gen/minus_dm.rb +53 -0
- data/lib/indicator/auto_gen/mom.rb +53 -0
- data/lib/indicator/auto_gen/moving_average.rb +58 -0
- data/lib/indicator/auto_gen/moving_average_variable_period.rb +64 -0
- data/lib/indicator/auto_gen/mult.rb +45 -0
- data/lib/indicator/auto_gen/natr.rb +53 -0
- data/lib/indicator/auto_gen/obv.rb +44 -0
- data/lib/indicator/auto_gen/plus_di.rb +53 -0
- data/lib/indicator/auto_gen/plus_dm.rb +53 -0
- data/lib/indicator/auto_gen/ppo.rb +63 -0
- data/lib/indicator/auto_gen/roc.rb +53 -0
- data/lib/indicator/auto_gen/roc_p.rb +53 -0
- data/lib/indicator/auto_gen/roc_r.rb +53 -0
- data/lib/indicator/auto_gen/roc_r100.rb +53 -0
- data/lib/indicator/auto_gen/rsi.rb +53 -0
- data/lib/indicator/auto_gen/sar.rb +58 -0
- data/lib/indicator/auto_gen/sar_ext.rb +88 -0
- data/lib/indicator/auto_gen/sin.rb +44 -0
- data/lib/indicator/auto_gen/sinh.rb +44 -0
- data/lib/indicator/auto_gen/sma.rb +53 -0
- data/lib/indicator/auto_gen/sqrt.rb +44 -0
- data/lib/indicator/auto_gen/std_dev.rb +58 -0
- data/lib/indicator/auto_gen/stoch.rb +76 -0
- data/lib/indicator/auto_gen/stoch_f.rb +66 -0
- data/lib/indicator/auto_gen/stoch_rsi.rb +71 -0
- data/lib/indicator/auto_gen/sub.rb +45 -0
- data/lib/indicator/auto_gen/sum.rb +53 -0
- data/lib/indicator/auto_gen/t3.rb +58 -0
- data/lib/indicator/auto_gen/tan.rb +44 -0
- data/lib/indicator/auto_gen/tanh.rb +44 -0
- data/lib/indicator/auto_gen/tema.rb +53 -0
- data/lib/indicator/auto_gen/trima.rb +53 -0
- data/lib/indicator/auto_gen/trix.rb +53 -0
- data/lib/indicator/auto_gen/true_range.rb +44 -0
- data/lib/indicator/auto_gen/tsf.rb +53 -0
- data/lib/indicator/auto_gen/typ_price.rb +44 -0
- data/lib/indicator/auto_gen/ult_osc.rb +63 -0
- data/lib/indicator/auto_gen/variance.rb +58 -0
- data/lib/indicator/auto_gen/wcl_price.rb +44 -0
- data/lib/indicator/auto_gen/will_r.rb +53 -0
- data/lib/indicator/auto_gen/wma.rb +53 -0
- data/lib/indicator/base.rb +19 -0
- data/lib/indicator/data_mapper.rb +93 -0
- data/lib/indicator/mixin.rb +15 -0
- data/lib/indicator/version.rb +3 -0
- data/test/data_mapper_test.rb +76 -0
- metadata +226 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
# Ta-Lib function mapping class
|
2
|
+
# Function: 'RSI'
|
3
|
+
# Description: 'Relative Strength Index'
|
4
|
+
# This file has been autogenerated - Do Not Edit.
|
5
|
+
class Indicator::AutoGen::Rsi < 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("RSI")
|
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,58 @@
|
|
1
|
+
# Ta-Lib function mapping class
|
2
|
+
# Function: 'SAR'
|
3
|
+
# Description: 'Parabolic SAR'
|
4
|
+
# This file has been autogenerated - Do Not Edit.
|
5
|
+
class Indicator::AutoGen::Sar < Indicator::Base
|
6
|
+
# Acceleration Factor <Double>
|
7
|
+
attr_accessor :acceleration_factor
|
8
|
+
# AF Maximum <Double>
|
9
|
+
attr_accessor :af_maximum
|
10
|
+
|
11
|
+
def initialize(*args)
|
12
|
+
if args.first.is_a? Hash
|
13
|
+
h = args.first
|
14
|
+
@acceleration_factor = h[:acceleration_factor] || 2.000000e-2
|
15
|
+
@af_maximum = h[:af_maximum] || 2.000000e-1
|
16
|
+
else
|
17
|
+
@acceleration_factor = args[0] || 2.000000e-2
|
18
|
+
@af_maximum = args[1] || 2.000000e-1
|
19
|
+
end
|
20
|
+
|
21
|
+
@func = TaLib::Function.new("SAR")
|
22
|
+
end
|
23
|
+
|
24
|
+
# Is price data required as an input
|
25
|
+
def self.price_input?
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
# The list of arguments
|
30
|
+
def self.arguments
|
31
|
+
[ :acceleration_factor, :af_maximum ]
|
32
|
+
end
|
33
|
+
|
34
|
+
# The minimum set of inputs required
|
35
|
+
def self.inputs
|
36
|
+
[ :open, :high, :low, :close ]
|
37
|
+
end
|
38
|
+
|
39
|
+
# The outputs generated by this function
|
40
|
+
def self.outputs
|
41
|
+
[ :out_real ]
|
42
|
+
end
|
43
|
+
|
44
|
+
def run(*args)
|
45
|
+
o, h, l, c, v, len = map_ohlcv(false, *args)
|
46
|
+
@func.in_price(0, o, h, l, c, v, nil)
|
47
|
+
|
48
|
+
@func.opt_real(0, @acceleration_factor)
|
49
|
+
@func.opt_real(1, @af_maximum)
|
50
|
+
|
51
|
+
out_real = Array.new(len)
|
52
|
+
@func.out_real(0, out_real)
|
53
|
+
|
54
|
+
@func.call(0, len - 1)
|
55
|
+
|
56
|
+
out_real
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# Ta-Lib function mapping class
|
2
|
+
# Function: 'SAREXT'
|
3
|
+
# Description: 'Parabolic SAR - Extended'
|
4
|
+
# This file has been autogenerated - Do Not Edit.
|
5
|
+
class Indicator::AutoGen::SarExt < Indicator::Base
|
6
|
+
# Start Value <Double>
|
7
|
+
attr_accessor :start_value
|
8
|
+
# Offset on Reverse <Double>
|
9
|
+
attr_accessor :offset_on_reverse
|
10
|
+
# AF Init Long <Double>
|
11
|
+
attr_accessor :af_init_long
|
12
|
+
# AF Long <Double>
|
13
|
+
attr_accessor :af_long
|
14
|
+
# AF Max Long <Double>
|
15
|
+
attr_accessor :af_max_long
|
16
|
+
# AF Init Short <Double>
|
17
|
+
attr_accessor :af_init_short
|
18
|
+
# AF Short <Double>
|
19
|
+
attr_accessor :af_short
|
20
|
+
# AF Max Short <Double>
|
21
|
+
attr_accessor :af_max_short
|
22
|
+
|
23
|
+
def initialize(*args)
|
24
|
+
if args.first.is_a? Hash
|
25
|
+
h = args.first
|
26
|
+
@start_value = h[:start_value] || 0.000000e+0
|
27
|
+
@offset_on_reverse = h[:offset_on_reverse] || 0.000000e+0
|
28
|
+
@af_init_long = h[:af_init_long] || 2.000000e-2
|
29
|
+
@af_long = h[:af_long] || 2.000000e-2
|
30
|
+
@af_max_long = h[:af_max_long] || 2.000000e-1
|
31
|
+
@af_init_short = h[:af_init_short] || 2.000000e-2
|
32
|
+
@af_short = h[:af_short] || 2.000000e-2
|
33
|
+
@af_max_short = h[:af_max_short] || 2.000000e-1
|
34
|
+
else
|
35
|
+
@start_value = args[0] || 0.000000e+0
|
36
|
+
@offset_on_reverse = args[1] || 0.000000e+0
|
37
|
+
@af_init_long = args[2] || 2.000000e-2
|
38
|
+
@af_long = args[3] || 2.000000e-2
|
39
|
+
@af_max_long = args[4] || 2.000000e-1
|
40
|
+
@af_init_short = args[5] || 2.000000e-2
|
41
|
+
@af_short = args[6] || 2.000000e-2
|
42
|
+
@af_max_short = args[7] || 2.000000e-1
|
43
|
+
end
|
44
|
+
|
45
|
+
@func = TaLib::Function.new("SAREXT")
|
46
|
+
end
|
47
|
+
|
48
|
+
# Is price data required as an input
|
49
|
+
def self.price_input?
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
53
|
+
# The list of arguments
|
54
|
+
def self.arguments
|
55
|
+
[ :start_value, :offset_on_reverse, :af_init_long, :af_long, :af_max_long, :af_init_short, :af_short, :af_max_short ]
|
56
|
+
end
|
57
|
+
|
58
|
+
# The minimum set of inputs required
|
59
|
+
def self.inputs
|
60
|
+
[ :open, :high, :low, :close ]
|
61
|
+
end
|
62
|
+
|
63
|
+
# The outputs generated by this function
|
64
|
+
def self.outputs
|
65
|
+
[ :out_real ]
|
66
|
+
end
|
67
|
+
|
68
|
+
def run(*args)
|
69
|
+
o, h, l, c, v, len = map_ohlcv(false, *args)
|
70
|
+
@func.in_price(0, o, h, l, c, v, nil)
|
71
|
+
|
72
|
+
@func.opt_real(0, @start_value)
|
73
|
+
@func.opt_real(1, @offset_on_reverse)
|
74
|
+
@func.opt_real(2, @af_init_long)
|
75
|
+
@func.opt_real(3, @af_long)
|
76
|
+
@func.opt_real(4, @af_max_long)
|
77
|
+
@func.opt_real(5, @af_init_short)
|
78
|
+
@func.opt_real(6, @af_short)
|
79
|
+
@func.opt_real(7, @af_max_short)
|
80
|
+
|
81
|
+
out_real = Array.new(len)
|
82
|
+
@func.out_real(0, out_real)
|
83
|
+
|
84
|
+
@func.call(0, len - 1)
|
85
|
+
|
86
|
+
out_real
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Ta-Lib function mapping class
|
2
|
+
# Function: 'SIN'
|
3
|
+
# Description: 'Vector Trigonometric Sin'
|
4
|
+
# This file has been autogenerated - Do Not Edit.
|
5
|
+
class Indicator::AutoGen::Sin < Indicator::Base
|
6
|
+
|
7
|
+
def initialize(*args)
|
8
|
+
|
9
|
+
@func = TaLib::Function.new("SIN")
|
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: 'SINH'
|
3
|
+
# Description: 'Vector Trigonometric Sinh'
|
4
|
+
# This file has been autogenerated - Do Not Edit.
|
5
|
+
class Indicator::AutoGen::Sinh < Indicator::Base
|
6
|
+
|
7
|
+
def initialize(*args)
|
8
|
+
|
9
|
+
@func = TaLib::Function.new("SINH")
|
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,53 @@
|
|
1
|
+
# Ta-Lib function mapping class
|
2
|
+
# Function: 'SMA'
|
3
|
+
# Description: 'Simple Moving Average'
|
4
|
+
# This file has been autogenerated - Do Not Edit.
|
5
|
+
class Indicator::AutoGen::Sma < 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] || 30
|
13
|
+
else
|
14
|
+
@time_period = args[0] || 30
|
15
|
+
end
|
16
|
+
|
17
|
+
@func = TaLib::Function.new("SMA")
|
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: 'SQRT'
|
3
|
+
# Description: 'Vector Square Root'
|
4
|
+
# This file has been autogenerated - Do Not Edit.
|
5
|
+
class Indicator::AutoGen::Sqrt < Indicator::Base
|
6
|
+
|
7
|
+
def initialize(*args)
|
8
|
+
|
9
|
+
@func = TaLib::Function.new("SQRT")
|
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,58 @@
|
|
1
|
+
# Ta-Lib function mapping class
|
2
|
+
# Function: 'STDDEV'
|
3
|
+
# Description: 'Standard Deviation'
|
4
|
+
# This file has been autogenerated - Do Not Edit.
|
5
|
+
class Indicator::AutoGen::StdDev < Indicator::Base
|
6
|
+
# Time Period <Integer>
|
7
|
+
attr_accessor :time_period
|
8
|
+
# Deviations <Double>
|
9
|
+
attr_accessor :deviations
|
10
|
+
|
11
|
+
def initialize(*args)
|
12
|
+
if args.first.is_a? Hash
|
13
|
+
h = args.first
|
14
|
+
@time_period = h[:time_period] || 5
|
15
|
+
@deviations = h[:deviations] || 1.000000e+0
|
16
|
+
else
|
17
|
+
@time_period = args[0] || 5
|
18
|
+
@deviations = args[1] || 1.000000e+0
|
19
|
+
end
|
20
|
+
|
21
|
+
@func = TaLib::Function.new("STDDEV")
|
22
|
+
end
|
23
|
+
|
24
|
+
# Is price data required as an input
|
25
|
+
def self.price_input?
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
# The list of arguments
|
30
|
+
def self.arguments
|
31
|
+
[ :time_period, :deviations ]
|
32
|
+
end
|
33
|
+
|
34
|
+
# The minimum set of inputs required
|
35
|
+
def self.inputs
|
36
|
+
[ :in_real ]
|
37
|
+
end
|
38
|
+
|
39
|
+
# The outputs generated by this function
|
40
|
+
def self.outputs
|
41
|
+
[ :out_real ]
|
42
|
+
end
|
43
|
+
|
44
|
+
def run(in_real)
|
45
|
+
len = in_real.length
|
46
|
+
@func.in_real(0, map(in_real))
|
47
|
+
|
48
|
+
@func.opt_int(0, @time_period)
|
49
|
+
@func.opt_real(1, @deviations)
|
50
|
+
|
51
|
+
out_real = Array.new(len)
|
52
|
+
@func.out_real(0, out_real)
|
53
|
+
|
54
|
+
@func.call(0, len - 1)
|
55
|
+
|
56
|
+
out_real
|
57
|
+
end
|
58
|
+
end
|