├── .gitignore ├── lib ├── indicator │ ├── version.rb │ ├── mixin.rb │ ├── base.rb │ ├── auto_gen │ │ ├── ceil.rb │ │ ├── ln.rb │ │ ├── exp.rb │ │ ├── floor.rb │ │ ├── log10.rb │ │ ├── sqrt.rb │ │ ├── cos.rb │ │ ├── sin.rb │ │ ├── tan.rb │ │ ├── acos.rb │ │ ├── asin.rb │ │ ├── atan.rb │ │ ├── cosh.rb │ │ ├── sinh.rb │ │ ├── tanh.rb │ │ ├── ht_dc_phase.rb │ │ ├── ad.rb │ │ ├── ht_dc_period.rb │ │ ├── bop.rb │ │ ├── ht_trendline.rb │ │ ├── med_price.rb │ │ ├── obv.rb │ │ ├── true_range.rb │ │ ├── add.rb │ │ ├── div.rb │ │ ├── ht_trend_mode.rb │ │ ├── typ_price.rb │ │ ├── avg_price.rb │ │ ├── cdl_doji.rb │ │ ├── mult.rb │ │ ├── wcl_price.rb │ │ ├── sub.rb │ │ ├── cdl2_crows.rb │ │ ├── cdl_hammer.rb │ │ ├── cdl_harami.rb │ │ ├── cdl_kicking.rb │ │ ├── cdl_belt_hold.rb │ │ ├── cdl_doji_star.rb │ │ ├── cdl_hikkake.rb │ │ ├── cdl_in_neck.rb │ │ ├── cdl_marubozu.rb │ │ ├── cdl_on_neck.rb │ │ ├── cdl_tristar.rb │ │ ├── cdl3_inside.rb │ │ ├── cdl_breakaway.rb │ │ ├── cdl_piercing.rb │ │ ├── cdl_tasuki_gap.rb │ │ ├── cdl3_outside.rb │ │ ├── cdl_engulfing.rb │ │ ├── cdl_hanging_man.rb │ │ ├── cdl_hign_wave.rb │ │ ├── cdl_long_line.rb │ │ ├── cdl_thrusting.rb │ │ ├── cdl_matching_low.rb │ │ ├── cdl_rickshaw_man.rb │ │ ├── cdl_short_line.rb │ │ ├── cdl_spinning_top.rb │ │ ├── cdl3_black_crows.rb │ │ ├── cdl3_line_strike.rb │ │ ├── cdl_advance_block.rb │ │ ├── cdl_homing_pigeon.rb │ │ ├── cdl_ladder_bottom.rb │ │ ├── cdl_shooting_star.rb │ │ ├── cdl_unique3_river.rb │ │ ├── cdl_counter_attack.rb │ │ ├── cdl_dragonfly_doji.rb │ │ ├── cdl_harami_cross.rb │ │ ├── cdl_hikkake_mod.rb │ │ ├── cdl_gravestone_doji.rb │ │ ├── cdl_inverted_hammer.rb │ │ ├── cdl_stalled_pattern.rb │ │ ├── cdl_stick_sandwhich.rb │ │ ├── cdl3_stars_in_south.rb │ │ ├── cdl_closing_marubozu.rb │ │ ├── cdl_long_legged_doji.rb │ │ ├── cdl_seperating_lines.rb │ │ ├── cdl_takuri.rb │ │ ├── cdl_identical3_crows.rb │ │ ├── cdl_upside_gap2_crows.rb │ │ ├── cdl3_white_soldiers.rb │ │ ├── cdl_conceal_babys_wall.rb │ │ ├── cdl_rise_fall3_methods.rb │ │ ├── cdl_gap_side_side_white.rb │ │ ├── cdl_x_side_gap3_methods.rb │ │ ├── cdl_kicking_by_length.rb │ │ ├── ht_sine.rb │ │ ├── ht_phasor.rb │ │ ├── mom.rb │ │ ├── sum.rb │ │ ├── sma.rb │ │ ├── tsf.rb │ │ ├── cmo.rb │ │ ├── ema.rb │ │ ├── rsi.rb │ │ ├── wma.rb │ │ ├── kama.rb │ │ ├── min.rb │ │ ├── trima.rb │ │ ├── dema.rb │ │ ├── max.rb │ │ ├── mid_point.rb │ │ ├── tema.rb │ │ ├── linear_reg.rb │ │ ├── roc.rb │ │ ├── roc_r.rb │ │ ├── trix.rb │ │ ├── roc_p.rb │ │ ├── atr.rb │ │ ├── linear_reg_angle.rb │ │ ├── linear_reg_slope.rb │ │ ├── roc_r100.rb │ │ ├── beta.rb │ │ ├── cci.rb │ │ ├── dx.rb │ │ ├── mfi.rb │ │ ├── will_r.rb │ │ ├── aroon_osc.rb │ │ ├── max_index.rb │ │ ├── min_index.rb │ │ ├── adx.rb │ │ ├── natr.rb │ │ ├── plus_dm.rb │ │ ├── linear_reg_intercept.rb │ │ ├── mid_price.rb │ │ ├── minus_dm.rb │ │ ├── adxr.rb │ │ ├── plus_di.rb │ │ ├── minus_di.rb │ │ ├── correl.rb │ │ ├── cdl_mat_hold.rb │ │ ├── cdl_evening_star.rb │ │ ├── cdl_morning_star.rb │ │ ├── cdl_abandoned_baby.rb │ │ ├── cdl_dark_cloud_cover.rb │ │ ├── cdl_evening_doji_star.rb │ │ ├── cdl_morning_doji_star.rb │ │ ├── min_max.rb │ │ ├── moving_average.rb │ │ ├── aroon.rb │ │ ├── variance.rb │ │ ├── min_max_index.rb │ │ ├── std_dev.rb │ │ ├── t3.rb │ │ ├── ad_osc.rb │ │ ├── sar.rb │ │ ├── macd_fix.rb │ │ ├── mama.rb │ │ ├── apo.rb │ │ ├── ppo.rb │ │ ├── ult_osc.rb │ │ ├── moving_average_variable_period.rb │ │ ├── stoch_f.rb │ │ ├── macd.rb │ │ ├── stoch_rsi.rb │ │ └── stoch.rb │ └── data_mapper.rb └── indicator.rb ├── tools └── list_template.erb ├── Rakefile ├── ta-indicator.gemspec ├── LICENSE ├── examples ├── atr_example.rb └── mapping.rb ├── LICENSE-ta-lib └── test └── data_mapper_test.rb /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.gem 3 | -------------------------------------------------------------------------------- /lib/indicator/version.rb: -------------------------------------------------------------------------------- 1 | module Indicator 2 | VERSION = '0.1.1' 3 | end 4 | -------------------------------------------------------------------------------- /tools/list_template.erb: -------------------------------------------------------------------------------- 1 | module Indicator 2 | module AutoGen 3 | end 4 | end 5 | 6 | <% functions.each do |f| %> 7 | require 'indicator/auto_gen/<%=f.camel_name.underscore%>' 8 | <%end%> 9 | -------------------------------------------------------------------------------- /lib/indicator/mixin.rb: -------------------------------------------------------------------------------- 1 | require 'indicator' 2 | 3 | module Indicator 4 | module Mixin 5 | def indicator type, *args 6 | i = Indicator.create_named type, *args 7 | i.run self 8 | end 9 | end 10 | end 11 | 12 | # Extend the array class with the mixin 13 | class Array 14 | include Indicator::Mixin 15 | end 16 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # 2 | # To change this template, choose Tools | Templates 3 | # and open the template in the editor. 4 | 5 | require 'rake' 6 | require 'rake/clean' 7 | require 'rake/testtask' 8 | 9 | Rake::TestTask.new do |t| 10 | t.libs << 'lib' << 'test' << 'examples' 11 | t.test_files = FileList['test/**/*.rb'] 12 | t.verbose = false 13 | end 14 | -------------------------------------------------------------------------------- /ta-indicator.gemspec: -------------------------------------------------------------------------------- 1 | lib = File.expand_path('../lib/', __FILE__) 2 | $:.unshift lib unless $:.include?(lib) 3 | 4 | require 'indicator/version' 5 | 6 | Gem::Specification.new do |s| 7 | s.name = 'ta-indicator' 8 | s.version = Indicator::VERSION 9 | 10 | s.summary = 'Technical Analysis library' 11 | s.description = 'Higher level wrapper around the talib_ruby project' 12 | s.author = 'Michael Lamb' 13 | s.email = 'mr.lamby@gmail.com' 14 | s.platform = Gem::Platform::RUBY 15 | s.homepage = 'https://github.com/mlamby/indicator' 16 | s.files = %w(LICENSE LICENSE-ta-lib README.rdoc Rakefile) + Dir["{lib,examples}/**/*"] 17 | s.test_files = Dir["test/**/*"] 18 | 19 | s.add_runtime_dependency 'talib_ruby' 20 | 21 | end 22 | -------------------------------------------------------------------------------- /lib/indicator/base.rb: -------------------------------------------------------------------------------- 1 | module Indicator 2 | 3 | # Base Indicator 4 | class Base 5 | include Indicator::DataMapper 6 | 7 | attr_accessor :name 8 | 9 | class << self 10 | attr_reader :indicators 11 | end 12 | 13 | @indicators = [] 14 | 15 | def self.inherited(subclass) 16 | Base.indicators << subclass 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 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ceil.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CEIL' 3 | # Description: 'Vector Ceil' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Ceil < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CEIL") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ln.rb: -------------------------------------------------------------------------------- 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/exp.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'EXP' 3 | # Description: 'Vector Arithmetic Exp' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Exp < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("EXP") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/floor.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'FLOOR' 3 | # Description: 'Vector Floor' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Floor < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("FLOOR") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/log10.rb: -------------------------------------------------------------------------------- 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/sqrt.rb: -------------------------------------------------------------------------------- 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cos.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'COS' 3 | # Description: 'Vector Trigonometric Cos' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Cos < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("COS") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/sin.rb: -------------------------------------------------------------------------------- 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/tan.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'TAN' 3 | # Description: 'Vector Trigonometric Tan' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Tan < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("TAN") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/acos.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ACOS' 3 | # Description: 'Vector Trigonometric ACos' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Acos < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("ACOS") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/asin.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ASIN' 3 | # Description: 'Vector Trigonometric ASin' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Asin < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("ASIN") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/atan.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ATAN' 3 | # Description: 'Vector Trigonometric ATan' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Atan < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("ATAN") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cosh.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'COSH' 3 | # Description: 'Vector Trigonometric Cosh' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Cosh < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("COSH") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/sinh.rb: -------------------------------------------------------------------------------- 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/tanh.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'TANH' 3 | # Description: 'Vector Trigonometric Tanh' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Tanh < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("TANH") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ht_dc_phase.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'HT_DCPHASE' 3 | # Description: 'Hilbert Transform - Dominant Cycle Phase' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::HtDcPhase < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("HT_DCPHASE") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ad.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'AD' 3 | # Description: 'Chaikin A/D Line' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Ad < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("AD") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :high, :low, :close, :volume ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_real ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ht_dc_period.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'HT_DCPERIOD' 3 | # Description: 'Hilbert Transform - Dominant Cycle Period' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::HtDcPeriod < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("HT_DCPERIOD") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/bop.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'BOP' 3 | # Description: 'Balance Of Power' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Bop < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("BOP") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_real ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ht_trendline.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'HT_TRENDLINE' 3 | # Description: 'Hilbert Transform - Instantaneous Trendline' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::HtTrendline < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("HT_TRENDLINE") 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/med_price.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MEDPRICE' 3 | # Description: 'Median Price' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::MedPrice < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("MEDPRICE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :high, :low ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_real ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/obv.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'OBV' 3 | # Description: 'On Balance Volume' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Obv < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("OBV") 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, :volume ] 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, volume) 33 | len = in_real.length 34 | @func.in_real(0, map(in_real)) 35 | @func.in_real(1, map(volume)) 36 | 37 | 38 | out_real = Array.new(len) 39 | @func.out_real(0, out_real) 40 | 41 | @func.call(0, len - 1) 42 | 43 | out_real 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright 2012 Michael Lamb 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/true_range.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'TRANGE' 3 | # Description: 'True Range' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::TrueRange < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("TRANGE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_real ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/add.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ADD' 3 | # Description: 'Vector Arithmetic Add' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Add < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("ADD") 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_real0, :in_real1 ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_real ] 30 | end 31 | 32 | def run(in_real0, in_real1) 33 | len = in_real0.length 34 | @func.in_real(0, map(in_real0)) 35 | @func.in_real(1, map(in_real1)) 36 | 37 | 38 | out_real = Array.new(len) 39 | @func.out_real(0, out_real) 40 | 41 | @func.call(0, len - 1) 42 | 43 | out_real 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/div.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'DIV' 3 | # Description: 'Vector Arithmetic Div' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Div < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("DIV") 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_real0, :in_real1 ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_real ] 30 | end 31 | 32 | def run(in_real0, in_real1) 33 | len = in_real0.length 34 | @func.in_real(0, map(in_real0)) 35 | @func.in_real(1, map(in_real1)) 36 | 37 | 38 | out_real = Array.new(len) 39 | @func.out_real(0, out_real) 40 | 41 | @func.call(0, len - 1) 42 | 43 | out_real 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ht_trend_mode.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'HT_TRENDMODE' 3 | # Description: 'Hilbert Transform - Trend vs Cycle Mode' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::HtTrendMode < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("HT_TRENDMODE") 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_integer ] 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_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/typ_price.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'TYPPRICE' 3 | # Description: 'Typical Price' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::TypPrice < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("TYPPRICE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_real ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/avg_price.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'AVGPRICE' 3 | # Description: 'Average Price' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::AvgPrice < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("AVGPRICE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_real ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_doji.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLDOJI' 3 | # Description: 'Doji' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlDoji < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLDOJI") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/mult.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MULT' 3 | # Description: 'Vector Arithmetic Mult' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Mult < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("MULT") 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_real0, :in_real1 ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_real ] 30 | end 31 | 32 | def run(in_real0, in_real1) 33 | len = in_real0.length 34 | @func.in_real(0, map(in_real0)) 35 | @func.in_real(1, map(in_real1)) 36 | 37 | 38 | out_real = Array.new(len) 39 | @func.out_real(0, out_real) 40 | 41 | @func.call(0, len - 1) 42 | 43 | out_real 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/wcl_price.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'WCLPRICE' 3 | # Description: 'Weighted Close Price' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::WclPrice < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("WCLPRICE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_real ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 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 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/sub.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'SUB' 3 | # Description: 'Vector Arithmetic Substraction' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Sub < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("SUB") 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_real0, :in_real1 ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_real ] 30 | end 31 | 32 | def run(in_real0, in_real1) 33 | len = in_real0.length 34 | @func.in_real(0, map(in_real0)) 35 | @func.in_real(1, map(in_real1)) 36 | 37 | 38 | out_real = Array.new(len) 39 | @func.out_real(0, out_real) 40 | 41 | @func.call(0, len - 1) 42 | 43 | out_real 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl2_crows.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDL2CROWS' 3 | # Description: 'Two Crows' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Cdl2Crows < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDL2CROWS") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_hammer.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLHAMMER' 3 | # Description: 'Hammer' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlHammer < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLHAMMER") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_harami.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLHARAMI' 3 | # Description: 'Harami Pattern' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlHarami < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLHARAMI") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_kicking.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLKICKING' 3 | # Description: 'Kicking' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlKicking < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLKICKING") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_belt_hold.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLBELTHOLD' 3 | # Description: 'Belt-hold' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlBeltHold < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLBELTHOLD") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_doji_star.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLDOJISTAR' 3 | # Description: 'Doji Star' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlDojiStar < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLDOJISTAR") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_hikkake.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLHIKKAKE' 3 | # Description: 'Hikkake Pattern' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlHikkake < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLHIKKAKE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_in_neck.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLINNECK' 3 | # Description: 'In-Neck Pattern' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlInNeck < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLINNECK") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_marubozu.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLMARUBOZU' 3 | # Description: 'Marubozu' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlMarubozu < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLMARUBOZU") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_on_neck.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLONNECK' 3 | # Description: 'On-Neck Pattern' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlOnNeck < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLONNECK") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_tristar.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLTRISTAR' 3 | # Description: 'Tristar Pattern' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlTristar < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLTRISTAR") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl3_inside.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDL3INSIDE' 3 | # Description: 'Three Inside Up/Down' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Cdl3Inside < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDL3INSIDE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_breakaway.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLBREAKAWAY' 3 | # Description: 'Breakaway' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlBreakaway < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLBREAKAWAY") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_piercing.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLPIERCING' 3 | # Description: 'Piercing Pattern' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlPiercing < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLPIERCING") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_tasuki_gap.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLTASUKIGAP' 3 | # Description: 'Tasuki Gap' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlTasukiGap < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLTASUKIGAP") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl3_outside.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDL3OUTSIDE' 3 | # Description: 'Three Outside Up/Down' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Cdl3Outside < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDL3OUTSIDE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_engulfing.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLENGULFING' 3 | # Description: 'Engulfing Pattern' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlEngulfing < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLENGULFING") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_hanging_man.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLHANGINGMAN' 3 | # Description: 'Hanging Man' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlHangingMan < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLHANGINGMAN") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_hign_wave.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLHIGHWAVE' 3 | # Description: 'High-Wave Candle' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlHignWave < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLHIGHWAVE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_long_line.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLLONGLINE' 3 | # Description: 'Long Line Candle' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlLongLine < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLLONGLINE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_thrusting.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLTHRUSTING' 3 | # Description: 'Thrusting Pattern' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlThrusting < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLTHRUSTING") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_matching_low.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLMATCHINGLOW' 3 | # Description: 'Matching Low' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlMatchingLow < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLMATCHINGLOW") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_rickshaw_man.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLRICKSHAWMAN' 3 | # Description: 'Rickshaw Man' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlRickshawMan < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLRICKSHAWMAN") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_short_line.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLSHORTLINE' 3 | # Description: 'Short Line Candle' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlShortLine < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLSHORTLINE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_spinning_top.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLSPINNINGTOP' 3 | # Description: 'Spinning Top' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlSpinningTop < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLSPINNINGTOP") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl3_black_crows.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDL3BLACKCROWS' 3 | # Description: 'Three Black Crows' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Cdl3BlackCrows < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDL3BLACKCROWS") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl3_line_strike.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDL3LINESTRIKE' 3 | # Description: 'Three-Line Strike ' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Cdl3LineStrike < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDL3LINESTRIKE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_advance_block.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLADVANCEBLOCK' 3 | # Description: 'Advance Block' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlAdvanceBlock < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLADVANCEBLOCK") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_homing_pigeon.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLHOMINGPIGEON' 3 | # Description: 'Homing Pigeon' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlHomingPigeon < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLHOMINGPIGEON") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_ladder_bottom.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLLADDERBOTTOM' 3 | # Description: 'Ladder Bottom' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlLadderBottom < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLLADDERBOTTOM") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_shooting_star.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLSHOOTINGSTAR' 3 | # Description: 'Shooting Star' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlShootingStar < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLSHOOTINGSTAR") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_unique3_river.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLUNIQUE3RIVER' 3 | # Description: 'Unique 3 River' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlUnique3River < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLUNIQUE3RIVER") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_counter_attack.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLCOUNTERATTACK' 3 | # Description: 'Counterattack' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlCounterAttack < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLCOUNTERATTACK") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_dragonfly_doji.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLDRAGONFLYDOJI' 3 | # Description: 'Dragonfly Doji' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlDragonflyDoji < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLDRAGONFLYDOJI") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_harami_cross.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLHARAMICROSS' 3 | # Description: 'Harami Cross Pattern' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlHaramiCross < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLHARAMICROSS") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_hikkake_mod.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLHIKKAKEMOD' 3 | # Description: 'Modified Hikkake Pattern' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlHikkakeMod < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLHIKKAKEMOD") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_gravestone_doji.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLGRAVESTONEDOJI' 3 | # Description: 'Gravestone Doji' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlGravestoneDoji < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLGRAVESTONEDOJI") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_inverted_hammer.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLINVERTEDHAMMER' 3 | # Description: 'Inverted Hammer' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlInvertedHammer < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLINVERTEDHAMMER") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_stalled_pattern.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLSTALLEDPATTERN' 3 | # Description: 'Stalled Pattern' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlStalledPattern < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLSTALLEDPATTERN") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_stick_sandwhich.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLSTICKSANDWICH' 3 | # Description: 'Stick Sandwich' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlStickSandwhich < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLSTICKSANDWICH") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl3_stars_in_south.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDL3STARSINSOUTH' 3 | # Description: 'Three Stars In The South' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Cdl3StarsInSouth < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDL3STARSINSOUTH") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_closing_marubozu.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLCLOSINGMARUBOZU' 3 | # Description: 'Closing Marubozu' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlClosingMarubozu < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLCLOSINGMARUBOZU") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_long_legged_doji.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLLONGLEGGEDDOJI' 3 | # Description: 'Long Legged Doji' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlLongLeggedDoji < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLLONGLEGGEDDOJI") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_seperating_lines.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLSEPARATINGLINES' 3 | # Description: 'Separating Lines' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlSeperatingLines < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLSEPARATINGLINES") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_takuri.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLTAKURI' 3 | # Description: 'Takuri (Dragonfly Doji with very long lower shadow)' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlTakuri < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLTAKURI") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_identical3_crows.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLIDENTICAL3CROWS' 3 | # Description: 'Identical Three Crows' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlIdentical3Crows < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLIDENTICAL3CROWS") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_upside_gap2_crows.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLUPSIDEGAP2CROWS' 3 | # Description: 'Upside Gap Two Crows' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlUpsideGap2Crows < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLUPSIDEGAP2CROWS") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl3_white_soldiers.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDL3WHITESOLDIERS' 3 | # Description: 'Three Advancing White Soldiers' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Cdl3WhiteSoldiers < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDL3WHITESOLDIERS") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_conceal_babys_wall.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLCONCEALBABYSWALL' 3 | # Description: 'Concealing Baby Swallow' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlConcealBabysWall < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLCONCEALBABYSWALL") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_rise_fall3_methods.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLRISEFALL3METHODS' 3 | # Description: 'Rising/Falling Three Methods' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlRiseFall3Methods < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLRISEFALL3METHODS") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_gap_side_side_white.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLGAPSIDESIDEWHITE' 3 | # Description: 'Up/Down-gap side-by-side white lines' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlGapSideSideWhite < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLGAPSIDESIDEWHITE") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_x_side_gap3_methods.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLXSIDEGAP3METHODS' 3 | # Description: 'Upside/Downside Gap Three Methods' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlXSideGap3Methods < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLXSIDEGAP3METHODS") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_kicking_by_length.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLKICKINGBYLENGTH' 3 | # Description: 'Kicking - bull/bear determined by the longer marubozu' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlKickingByLength < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("CDLKICKINGBYLENGTH") 10 | end 11 | 12 | # Is price data required as an input 13 | def self.price_input? 14 | true 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 | [ :open, :high, :low, :close ] 25 | end 26 | 27 | # The outputs generated by this function 28 | def self.outputs 29 | [ :out_integer ] 30 | end 31 | 32 | def run(*args) 33 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 34 | @func.in_price(0, o, h, l, c, v, nil) 35 | 36 | 37 | out_integer = Array.new(len) 38 | @func.out_int(0, out_integer) 39 | 40 | @func.call(0, len - 1) 41 | 42 | out_integer 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ht_sine.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'HT_SINE' 3 | # Description: 'Hilbert Transform - SineWave' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::HtSine < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("HT_SINE") 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_sine, :out_lead_sine ] 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_sine = Array.new(len) 38 | @func.out_real(0, out_sine) 39 | out_lead_sine = Array.new(len) 40 | @func.out_real(1, out_lead_sine) 41 | 42 | @func.call(0, len - 1) 43 | 44 | {:out_sine => out_sine, 45 | :out_lead_sine => out_lead_sine} 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ht_phasor.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'HT_PHASOR' 3 | # Description: 'Hilbert Transform - Phasor Components' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::HtPhasor < Indicator::Base 6 | 7 | def initialize(*args) 8 | 9 | @func = TaLib::Function.new("HT_PHASOR") 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_in_phase, :out_quadrature ] 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_in_phase = Array.new(len) 38 | @func.out_real(0, out_in_phase) 39 | out_quadrature = Array.new(len) 40 | @func.out_real(1, out_quadrature) 41 | 42 | @func.call(0, len - 1) 43 | 44 | {:out_in_phase => out_in_phase, 45 | :out_quadrature => out_quadrature} 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/mom.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MOM' 3 | # Description: 'Momentum' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Mom < Indicator::Base 6 | # Time Period 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] || 10 13 | else 14 | @time_period = args[0] || 10 15 | end 16 | 17 | @func = TaLib::Function.new("MOM") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/sum.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'SUM' 3 | # Description: 'Summation' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Sum < Indicator::Base 6 | # Time Period 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("SUM") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/sma.rb: -------------------------------------------------------------------------------- 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 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/tsf.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'TSF' 3 | # Description: 'Time Series Forecast' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Tsf < Indicator::Base 6 | # Time Period 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("TSF") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cmo.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CMO' 3 | # Description: 'Chande Momentum Oscillator' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Cmo < Indicator::Base 6 | # Time Period 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("CMO") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ema.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'EMA' 3 | # Description: 'Exponential Moving Average' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Ema < Indicator::Base 6 | # Time Period 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("EMA") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/rsi.rb: -------------------------------------------------------------------------------- 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 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/wma.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'WMA' 3 | # Description: 'Weighted Moving Average' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Wma < Indicator::Base 6 | # Time Period 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("WMA") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/kama.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'KAMA' 3 | # Description: 'Kaufman Adaptive Moving Average' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Kama < Indicator::Base 6 | # Time Period 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("KAMA") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/min.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MIN' 3 | # Description: 'Lowest value over a specified period' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Min < Indicator::Base 6 | # Time Period 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("MIN") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/trima.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'TRIMA' 3 | # Description: 'Triangular Moving Average' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Trima < Indicator::Base 6 | # Time Period 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("TRIMA") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/dema.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'DEMA' 3 | # Description: 'Double Exponential Moving Average' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Dema < Indicator::Base 6 | # Time Period 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("DEMA") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/max.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MAX' 3 | # Description: 'Highest value over a specified period' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Max < Indicator::Base 6 | # Time Period 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("MAX") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/mid_point.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MIDPOINT' 3 | # Description: 'MidPoint over period' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::MidPoint < Indicator::Base 6 | # Time Period 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("MIDPOINT") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/tema.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'TEMA' 3 | # Description: 'Triple Exponential Moving Average' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Tema < Indicator::Base 6 | # Time Period 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("TEMA") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/linear_reg.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'LINEARREG' 3 | # Description: 'Linear Regression' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::LinearReg < Indicator::Base 6 | # Time Period 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") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/roc.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ROC' 3 | # Description: 'Rate of change : ((price/prevPrice)-1)*100' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Roc < Indicator::Base 6 | # Time Period 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] || 10 13 | else 14 | @time_period = args[0] || 10 15 | end 16 | 17 | @func = TaLib::Function.new("ROC") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/roc_r.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ROCR' 3 | # Description: 'Rate of change ratio: (price/prevPrice)' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::RocR < Indicator::Base 6 | # Time Period 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] || 10 13 | else 14 | @time_period = args[0] || 10 15 | end 16 | 17 | @func = TaLib::Function.new("ROCR") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/trix.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'TRIX' 3 | # Description: '1-day Rate-Of-Change (ROC) of a Triple Smooth EMA' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Trix < Indicator::Base 6 | # Time Period 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("TRIX") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/roc_p.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ROCP' 3 | # Description: 'Rate of change Percentage: (price-prevPrice)/prevPrice' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::RocP < Indicator::Base 6 | # Time Period 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] || 10 13 | else 14 | @time_period = args[0] || 10 15 | end 16 | 17 | @func = TaLib::Function.new("ROCP") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/atr.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ATR' 3 | # Description: 'Average True Range' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Atr < Indicator::Base 6 | # Time Period 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("ATR") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/linear_reg_angle.rb: -------------------------------------------------------------------------------- 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 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/linear_reg_slope.rb: -------------------------------------------------------------------------------- 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 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/roc_r100.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ROCR100' 3 | # Description: 'Rate of change ratio 100 scale: (price/prevPrice)*100' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::RocR100 < Indicator::Base 6 | # Time Period 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] || 10 13 | else 14 | @time_period = args[0] || 10 15 | end 16 | 17 | @func = TaLib::Function.new("ROCR100") 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/beta.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'BETA' 3 | # Description: 'Beta' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Beta < Indicator::Base 6 | # Time Period 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] || 5 13 | else 14 | @time_period = args[0] || 5 15 | end 16 | 17 | @func = TaLib::Function.new("BETA") 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_real0, :in_real1 ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(in_real0, in_real1) 41 | len = in_real0.length 42 | @func.in_real(0, map(in_real0)) 43 | @func.in_real(1, map(in_real1)) 44 | 45 | @func.opt_int(0, @time_period) 46 | 47 | out_real = Array.new(len) 48 | @func.out_real(0, out_real) 49 | 50 | @func.call(0, len - 1) 51 | 52 | out_real 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cci.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CCI' 3 | # Description: 'Commodity Channel Index' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Cci < Indicator::Base 6 | # Time Period 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("CCI") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/dx.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'DX' 3 | # Description: 'Directional Movement Index' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Dx < Indicator::Base 6 | # Time Period 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("DX") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/mfi.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MFI' 3 | # Description: 'Money Flow Index' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Mfi < Indicator::Base 6 | # Time Period 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("MFI") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low, :close, :volume ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/will_r.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'WILLR' 3 | # Description: 'Williams' %R' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::WillR < Indicator::Base 6 | # Time Period 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("WILLR") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/aroon_osc.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'AROONOSC' 3 | # Description: 'Aroon Oscillator' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::AroonOsc < Indicator::Base 6 | # Time Period 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("AROONOSC") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/max_index.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MAXINDEX' 3 | # Description: 'Index of highest value over a specified period' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::MaxIndex < Indicator::Base 6 | # Time Period 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("MAXINDEX") 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_integer ] 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_integer = Array.new(len) 47 | @func.out_int(0, out_integer) 48 | 49 | @func.call(0, len - 1) 50 | 51 | out_integer 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/min_index.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MININDEX' 3 | # Description: 'Index of lowest value over a specified period' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::MinIndex < Indicator::Base 6 | # Time Period 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("MININDEX") 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_integer ] 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_integer = Array.new(len) 47 | @func.out_int(0, out_integer) 48 | 49 | @func.call(0, len - 1) 50 | 51 | out_integer 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/adx.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ADX' 3 | # Description: 'Average Directional Movement Index' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Adx < Indicator::Base 6 | # Time Period 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("ADX") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/natr.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'NATR' 3 | # Description: 'Normalized Average True Range' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Natr < Indicator::Base 6 | # Time Period 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("NATR") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/plus_dm.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'PLUS_DM' 3 | # Description: 'Plus Directional Movement' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::PlusDM < Indicator::Base 6 | # Time Period 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("PLUS_DM") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/linear_reg_intercept.rb: -------------------------------------------------------------------------------- 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 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/mid_price.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MIDPRICE' 3 | # Description: 'Midpoint Price over period' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::MidPrice < Indicator::Base 6 | # Time Period 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("MIDPRICE") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/minus_dm.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MINUS_DM' 3 | # Description: 'Minus Directional Movement' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::MinusDM < Indicator::Base 6 | # Time Period 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("MINUS_DM") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/adxr.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ADXR' 3 | # Description: 'Average Directional Movement Index Rating' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Adxr < Indicator::Base 6 | # Time Period 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("ADXR") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/plus_di.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'PLUS_DI' 3 | # Description: 'Plus Directional Indicator' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::PlusDI < Indicator::Base 6 | # Time Period 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("PLUS_DI") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/minus_di.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MINUS_DI' 3 | # Description: 'Minus Directional Indicator' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::MinusDI < Indicator::Base 6 | # Time Period 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("MINUS_DI") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 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 54 | -------------------------------------------------------------------------------- /lib/indicator.rb: -------------------------------------------------------------------------------- 1 | require 'talib_ruby' 2 | require 'indicator/data_mapper' 3 | require 'indicator/base' 4 | require 'indicator/auto_gen' 5 | 6 | module Indicator 7 | 8 | class UnknownIndicator < StandardError 9 | end 10 | 11 | def self.contains? name 12 | not Indicator.get(name).nil? 13 | end 14 | 15 | def self.get name 16 | name = name.to_s 17 | Base.indicators.find do |klass| 18 | klass_name = klass.name.split('::')[-1] 19 | klass_name.casecmp(name) == 0 20 | end 21 | end 22 | 23 | def self.create type, *args 24 | klass = Indicator.get type 25 | raise UnknownIndicator,type if klass.nil? 26 | 27 | klass.send(:new, *args) 28 | end 29 | 30 | def self.create_named name, *args 31 | sp = name.to_s.split "_" 32 | 33 | type = sp.first.to_sym 34 | 35 | args = sp.drop(1).collect { |a| a.to_i } if args.empty? 36 | 37 | obj = Indicator.create type, *args 38 | obj.name = name 39 | obj 40 | end 41 | 42 | def self.list 43 | Indicator::Base.indicators 44 | end 45 | 46 | def self.info type 47 | klass = Indicator.get type 48 | raise UnknownIndicator,type if klass.nil? 49 | """Indicator: #{klass.name} 50 | Arguments: #{klass.arguments} 51 | Input Count: #{klass.inputs.count} 52 | Inputs: #{klass.inputs} 53 | Output Count: #{klass.outputs.count} 54 | Outputs: #{klass.outputs}""" 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/correl.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CORREL' 3 | # Description: 'Pearson's Correlation Coefficient (r)' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Correl < Indicator::Base 6 | # Time Period 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("CORREL") 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_real0, :in_real1 ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_real ] 38 | end 39 | 40 | def run(in_real0, in_real1) 41 | len = in_real0.length 42 | @func.in_real(0, map(in_real0)) 43 | @func.in_real(1, map(in_real1)) 44 | 45 | @func.opt_int(0, @time_period) 46 | 47 | out_real = Array.new(len) 48 | @func.out_real(0, out_real) 49 | 50 | @func.call(0, len - 1) 51 | 52 | out_real 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_mat_hold.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLMATHOLD' 3 | # Description: 'Mat Hold' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlMatHold < Indicator::Base 6 | # Penetration 7 | attr_accessor :penetration 8 | 9 | def initialize(*args) 10 | if args.first.is_a? Hash 11 | h = args.first 12 | @penetration = h[:penetration] || 5.000000e-1 13 | else 14 | @penetration = args[0] || 5.000000e-1 15 | end 16 | 17 | @func = TaLib::Function.new("CDLMATHOLD") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 23 | end 24 | 25 | # The list of arguments 26 | def self.arguments 27 | [ :penetration ] 28 | end 29 | 30 | # The minimum set of inputs required 31 | def self.inputs 32 | [ :open, :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_integer ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 43 | 44 | @func.opt_real(0, @penetration) 45 | 46 | out_integer = Array.new(len) 47 | @func.out_int(0, out_integer) 48 | 49 | @func.call(0, len - 1) 50 | 51 | out_integer 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_evening_star.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLEVENINGSTAR' 3 | # Description: 'Evening Star' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlEveningStar < Indicator::Base 6 | # Penetration 7 | attr_accessor :penetration 8 | 9 | def initialize(*args) 10 | if args.first.is_a? Hash 11 | h = args.first 12 | @penetration = h[:penetration] || 3.000000e-1 13 | else 14 | @penetration = args[0] || 3.000000e-1 15 | end 16 | 17 | @func = TaLib::Function.new("CDLEVENINGSTAR") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 23 | end 24 | 25 | # The list of arguments 26 | def self.arguments 27 | [ :penetration ] 28 | end 29 | 30 | # The minimum set of inputs required 31 | def self.inputs 32 | [ :open, :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_integer ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 43 | 44 | @func.opt_real(0, @penetration) 45 | 46 | out_integer = Array.new(len) 47 | @func.out_int(0, out_integer) 48 | 49 | @func.call(0, len - 1) 50 | 51 | out_integer 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_morning_star.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLMORNINGSTAR' 3 | # Description: 'Morning Star' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlMorningStar < Indicator::Base 6 | # Penetration 7 | attr_accessor :penetration 8 | 9 | def initialize(*args) 10 | if args.first.is_a? Hash 11 | h = args.first 12 | @penetration = h[:penetration] || 3.000000e-1 13 | else 14 | @penetration = args[0] || 3.000000e-1 15 | end 16 | 17 | @func = TaLib::Function.new("CDLMORNINGSTAR") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 23 | end 24 | 25 | # The list of arguments 26 | def self.arguments 27 | [ :penetration ] 28 | end 29 | 30 | # The minimum set of inputs required 31 | def self.inputs 32 | [ :open, :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_integer ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 43 | 44 | @func.opt_real(0, @penetration) 45 | 46 | out_integer = Array.new(len) 47 | @func.out_int(0, out_integer) 48 | 49 | @func.call(0, len - 1) 50 | 51 | out_integer 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /examples/atr_example.rb: -------------------------------------------------------------------------------- 1 | # This sample requires the yahoo finance gem 2 | require 'yahoofinance' 3 | require 'indicator' 4 | 5 | def bar_to_hash r 6 | h = {} 7 | h[:date] = Date.parse(r[0]) 8 | h[:open] = r[1].to_f 9 | h[:high] = r[2].to_f 10 | h[:low] = r[3].to_f 11 | h[:close] = r[4].to_f 12 | h[:volume] = r[5].to_f 13 | h 14 | end 15 | 16 | yahoo_cba = YahooFinance::get_historical_quotes_days("CBA.AX", 30) 17 | yahoo_nab = YahooFinance::get_historical_quotes_days("NAB.AX", 30) 18 | 19 | puts "Downloading Data" 20 | cba = yahoo_cba.inject([]) { |lst, q| lst << bar_to_hash(q) } 21 | nab = yahoo_nab.inject([]) { |lst, q| lst << bar_to_hash(q) } 22 | 23 | # First way to use ATR - Use the factory 24 | # Create an ATR indicator with the time_period argument set to 14 25 | atr = Indicator.create_named :atr_14 26 | # Run the ATR using the stock prices for CBA and NAB 27 | result = atr.run(cba) 28 | puts "14 Day ATR For CBA.AX" 29 | puts result.join(',') 30 | 31 | result = atr.run(nab) 32 | puts "14 Day ATR For NAB.AX" 33 | puts result.join(',') 34 | 35 | # Second way to use ATR - Manually create the indicator class 36 | atr = Indicator::AutoGen::Atr.new() 37 | # Configure Arguments 38 | atr.time_period = 7 39 | 40 | # Run the ATR using the stock prices for CBA and NAB 41 | result = atr.run(cba) 42 | puts "7 Day ATR For CBA.AX" 43 | puts result.join(',') 44 | 45 | result = atr.run(nab) 46 | puts "7 Day ATR For NAB.AX" 47 | puts result.join(',') 48 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_abandoned_baby.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLABANDONEDBABY' 3 | # Description: 'Abandoned Baby' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlAbandonedBaby < Indicator::Base 6 | # Penetration 7 | attr_accessor :penetration 8 | 9 | def initialize(*args) 10 | if args.first.is_a? Hash 11 | h = args.first 12 | @penetration = h[:penetration] || 3.000000e-1 13 | else 14 | @penetration = args[0] || 3.000000e-1 15 | end 16 | 17 | @func = TaLib::Function.new("CDLABANDONEDBABY") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 23 | end 24 | 25 | # The list of arguments 26 | def self.arguments 27 | [ :penetration ] 28 | end 29 | 30 | # The minimum set of inputs required 31 | def self.inputs 32 | [ :open, :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_integer ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 43 | 44 | @func.opt_real(0, @penetration) 45 | 46 | out_integer = Array.new(len) 47 | @func.out_int(0, out_integer) 48 | 49 | @func.call(0, len - 1) 50 | 51 | out_integer 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_dark_cloud_cover.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLDARKCLOUDCOVER' 3 | # Description: 'Dark Cloud Cover' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlDarkCloudCover < Indicator::Base 6 | # Penetration 7 | attr_accessor :penetration 8 | 9 | def initialize(*args) 10 | if args.first.is_a? Hash 11 | h = args.first 12 | @penetration = h[:penetration] || 5.000000e-1 13 | else 14 | @penetration = args[0] || 5.000000e-1 15 | end 16 | 17 | @func = TaLib::Function.new("CDLDARKCLOUDCOVER") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 23 | end 24 | 25 | # The list of arguments 26 | def self.arguments 27 | [ :penetration ] 28 | end 29 | 30 | # The minimum set of inputs required 31 | def self.inputs 32 | [ :open, :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_integer ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 43 | 44 | @func.opt_real(0, @penetration) 45 | 46 | out_integer = Array.new(len) 47 | @func.out_int(0, out_integer) 48 | 49 | @func.call(0, len - 1) 50 | 51 | out_integer 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_evening_doji_star.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLEVENINGDOJISTAR' 3 | # Description: 'Evening Doji Star' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlEveningDojiStar < Indicator::Base 6 | # Penetration 7 | attr_accessor :penetration 8 | 9 | def initialize(*args) 10 | if args.first.is_a? Hash 11 | h = args.first 12 | @penetration = h[:penetration] || 3.000000e-1 13 | else 14 | @penetration = args[0] || 3.000000e-1 15 | end 16 | 17 | @func = TaLib::Function.new("CDLEVENINGDOJISTAR") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 23 | end 24 | 25 | # The list of arguments 26 | def self.arguments 27 | [ :penetration ] 28 | end 29 | 30 | # The minimum set of inputs required 31 | def self.inputs 32 | [ :open, :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_integer ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 43 | 44 | @func.opt_real(0, @penetration) 45 | 46 | out_integer = Array.new(len) 47 | @func.out_int(0, out_integer) 48 | 49 | @func.call(0, len - 1) 50 | 51 | out_integer 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/cdl_morning_doji_star.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'CDLMORNINGDOJISTAR' 3 | # Description: 'Morning Doji Star' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::CdlMorningDojiStar < Indicator::Base 6 | # Penetration 7 | attr_accessor :penetration 8 | 9 | def initialize(*args) 10 | if args.first.is_a? Hash 11 | h = args.first 12 | @penetration = h[:penetration] || 3.000000e-1 13 | else 14 | @penetration = args[0] || 3.000000e-1 15 | end 16 | 17 | @func = TaLib::Function.new("CDLMORNINGDOJISTAR") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 23 | end 24 | 25 | # The list of arguments 26 | def self.arguments 27 | [ :penetration ] 28 | end 29 | 30 | # The minimum set of inputs required 31 | def self.inputs 32 | [ :open, :high, :low, :close ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_integer ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 43 | 44 | @func.opt_real(0, @penetration) 45 | 46 | out_integer = Array.new(len) 47 | @func.out_int(0, out_integer) 48 | 49 | @func.call(0, len - 1) 50 | 51 | out_integer 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/min_max.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MINMAX' 3 | # Description: 'Lowest and highest values over a specified period' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::MinMax < Indicator::Base 6 | # Time Period 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("MINMAX") 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_min, :out_max ] 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_min = Array.new(len) 47 | @func.out_real(0, out_min) 48 | out_max = Array.new(len) 49 | @func.out_real(1, out_max) 50 | 51 | @func.call(0, len - 1) 52 | 53 | {:out_min => out_min, 54 | :out_max => out_max} 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/moving_average.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MA' 3 | # Description: 'Moving average' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::MovingAverage < Indicator::Base 6 | # Time Period 7 | attr_accessor :time_period 8 | # MA Type 9 | attr_accessor :ma_type 10 | 11 | def initialize(*args) 12 | if args.first.is_a? Hash 13 | h = args.first 14 | @time_period = h[:time_period] || 30 15 | @ma_type = h[:ma_type] || 0 16 | else 17 | @time_period = args[0] || 30 18 | @ma_type = args[1] || 0 19 | end 20 | 21 | @func = TaLib::Function.new("MA") 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, :ma_type ] 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_int(1, @ma_type) 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 59 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/aroon.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'AROON' 3 | # Description: 'Aroon' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Aroon < Indicator::Base 6 | # Time Period 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("AROON") 18 | end 19 | 20 | # Is price data required as an input 21 | def self.price_input? 22 | true 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 | [ :high, :low ] 33 | end 34 | 35 | # The outputs generated by this function 36 | def self.outputs 37 | [ :out_aroon_down, :out_aroon_up ] 38 | end 39 | 40 | def run(*args) 41 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 42 | @func.in_price(0, o, h, l, c, v, nil) 43 | 44 | @func.opt_int(0, @time_period) 45 | 46 | out_aroon_down = Array.new(len) 47 | @func.out_real(0, out_aroon_down) 48 | out_aroon_up = Array.new(len) 49 | @func.out_real(1, out_aroon_up) 50 | 51 | @func.call(0, len - 1) 52 | 53 | {:out_aroon_down => out_aroon_down, 54 | :out_aroon_up => out_aroon_up} 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/variance.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'VAR' 3 | # Description: 'Variance' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Variance < Indicator::Base 6 | # Time Period 7 | attr_accessor :time_period 8 | # Deviations 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("VAR") 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 59 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/min_max_index.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MINMAXINDEX' 3 | # Description: 'Indexes of lowest and highest values over a specified period' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::MinMaxIndex < Indicator::Base 6 | # Time Period 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("MINMAXINDEX") 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_min_idx, :out_max_idx ] 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_min_idx = Array.new(len) 47 | @func.out_int(0, out_min_idx) 48 | out_max_idx = Array.new(len) 49 | @func.out_int(1, out_max_idx) 50 | 51 | @func.call(0, len - 1) 52 | 53 | {:out_min_idx => out_min_idx, 54 | :out_max_idx => out_max_idx} 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/std_dev.rb: -------------------------------------------------------------------------------- 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 7 | attr_accessor :time_period 8 | # Deviations 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 59 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/t3.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'T3' 3 | # Description: 'Triple Exponential Moving Average (T3)' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::T3 < Indicator::Base 6 | # Time Period 7 | attr_accessor :time_period 8 | # Volume Factor 9 | attr_accessor :volume_factor 10 | 11 | def initialize(*args) 12 | if args.first.is_a? Hash 13 | h = args.first 14 | @time_period = h[:time_period] || 5 15 | @volume_factor = h[:volume_factor] || 7.000000e-1 16 | else 17 | @time_period = args[0] || 5 18 | @volume_factor = args[1] || 7.000000e-1 19 | end 20 | 21 | @func = TaLib::Function.new("T3") 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, :volume_factor ] 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, @volume_factor) 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 59 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ad_osc.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ADOSC' 3 | # Description: 'Chaikin A/D Oscillator' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::AdOsc < Indicator::Base 6 | # Fast Period 7 | attr_accessor :fast_period 8 | # Slow Period 9 | attr_accessor :slow_period 10 | 11 | def initialize(*args) 12 | if args.first.is_a? Hash 13 | h = args.first 14 | @fast_period = h[:fast_period] || 3 15 | @slow_period = h[:slow_period] || 10 16 | else 17 | @fast_period = args[0] || 3 18 | @slow_period = args[1] || 10 19 | end 20 | 21 | @func = TaLib::Function.new("ADOSC") 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 | [ :fast_period, :slow_period ] 32 | end 33 | 34 | # The minimum set of inputs required 35 | def self.inputs 36 | [ :high, :low, :close, :volume ] 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(self.class.inputs, *args) 46 | @func.in_price(0, o, h, l, c, v, nil) 47 | 48 | @func.opt_int(0, @fast_period) 49 | @func.opt_int(1, @slow_period) 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 59 | -------------------------------------------------------------------------------- /LICENSE-ta-lib: -------------------------------------------------------------------------------- 1 | TA-Lib Copyright (c) 1999-2008, Mario Fortier 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or 5 | without modification, are permitted provided that the following 6 | conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the 14 | distribution. 15 | 16 | - Neither name of author nor the names of its contributors 17 | may be used to endorse or promote products derived from this 18 | software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | -------------------------------------------------------------------------------- /examples/mapping.rb: -------------------------------------------------------------------------------- 1 | # This sample requires the yahoo finance gem 2 | require 'yahoofinance' 3 | require 'indicator' 4 | 5 | def bar_to_hash r 6 | h = {} 7 | h[:date] = Date.parse(r[0]) 8 | h[:open] = r[1].to_f 9 | h[:high] = r[2].to_f 10 | h[:low] = r[3].to_f 11 | h[:close] = r[4].to_f 12 | h[:volume] = r[5].to_f 13 | h 14 | end 15 | 16 | def short_hash r 17 | h = {} 18 | h[:date] = r[:date] 19 | h[:high] = r[:high] 20 | h[:low] = r[:low] 21 | h[:close] = r[:close] 22 | h[:volume] = r[:volume] 23 | h 24 | end 25 | 26 | def get_data_100 ticker 27 | YahooFinance::get_historical_quotes_days(ticker, 100) 28 | end 29 | 30 | puts 'Retrieving historical data' 31 | cba = get_data_100("CBA.AX").inject([]) { |lst, q| lst << bar_to_hash(q) } 32 | nab = get_data_100("NAB.AX").inject([]) { |lst, q| lst << bar_to_hash(q) } 33 | nab_no_open = nab.inject([]) { |lst, q| lst << short_hash(q) } 34 | 35 | sma = Indicator.create_named :sma_13 36 | sma_results = sma.run(Indicator::DataMapper::Map.new(cba, :open)) 37 | 38 | ema = Indicator.create_named :ema_25 39 | ema.default_getter = :high 40 | ema_results = sma.run cba 41 | 42 | sub = Indicator.create :sub 43 | sub.default_getter = :low 44 | sub_results = sub.run cba, nab 45 | 46 | stoch = Indicator.create :stoch 47 | stoch_results = stoch.run nab 48 | stoch_results = stoch.run nab_no_open 49 | 50 | adx = Indicator.create :adx 51 | adx_results = adx.run( 52 | new_map(nab, :open), 53 | new_map(nab, :high), 54 | new_map(nab, :low), 55 | new_map(nab, :close)) 56 | 57 | # Or the default mapping 58 | adx_results = adx.run nab 59 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/sar.rb: -------------------------------------------------------------------------------- 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 7 | attr_accessor :acceleration_factor 8 | # AF Maximum 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 | [ :high, :low ] 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(self.class.inputs, *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 59 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/macd_fix.rb: -------------------------------------------------------------------------------- 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 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 60 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/mama.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MAMA' 3 | # Description: 'MESA Adaptive Moving Average' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Mama < Indicator::Base 6 | # Fast Limit 7 | attr_accessor :fast_limit 8 | # Slow Limit 9 | attr_accessor :slow_limit 10 | 11 | def initialize(*args) 12 | if args.first.is_a? Hash 13 | h = args.first 14 | @fast_limit = h[:fast_limit] || 5.000000e-1 15 | @slow_limit = h[:slow_limit] || 5.000000e-2 16 | else 17 | @fast_limit = args[0] || 5.000000e-1 18 | @slow_limit = args[1] || 5.000000e-2 19 | end 20 | 21 | @func = TaLib::Function.new("MAMA") 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 | [ :fast_limit, :slow_limit ] 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_mama, :out_fama ] 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_real(0, @fast_limit) 49 | @func.opt_real(1, @slow_limit) 50 | 51 | out_mama = Array.new(len) 52 | @func.out_real(0, out_mama) 53 | out_fama = Array.new(len) 54 | @func.out_real(1, out_fama) 55 | 56 | @func.call(0, len - 1) 57 | 58 | {:out_mama => out_mama, 59 | :out_fama => out_fama} 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/apo.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'APO' 3 | # Description: 'Absolute Price Oscillator' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Apo < Indicator::Base 6 | # Fast Period 7 | attr_accessor :fast_period 8 | # Slow Period 9 | attr_accessor :slow_period 10 | # MA Type 11 | attr_accessor :ma_type 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 | @ma_type = h[:ma_type] || 0 19 | else 20 | @fast_period = args[0] || 12 21 | @slow_period = args[1] || 26 22 | @ma_type = args[2] || 0 23 | end 24 | 25 | @func = TaLib::Function.new("APO") 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, :ma_type ] 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_real ] 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, @ma_type) 55 | 56 | out_real = Array.new(len) 57 | @func.out_real(0, out_real) 58 | 59 | @func.call(0, len - 1) 60 | 61 | out_real 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ppo.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'PPO' 3 | # Description: 'Percentage Price Oscillator' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Ppo < Indicator::Base 6 | # Fast Period 7 | attr_accessor :fast_period 8 | # Slow Period 9 | attr_accessor :slow_period 10 | # MA Type 11 | attr_accessor :ma_type 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 | @ma_type = h[:ma_type] || 0 19 | else 20 | @fast_period = args[0] || 12 21 | @slow_period = args[1] || 26 22 | @ma_type = args[2] || 0 23 | end 24 | 25 | @func = TaLib::Function.new("PPO") 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, :ma_type ] 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_real ] 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, @ma_type) 55 | 56 | out_real = Array.new(len) 57 | @func.out_real(0, out_real) 58 | 59 | @func.call(0, len - 1) 60 | 61 | out_real 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/ult_osc.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'ULTOSC' 3 | # Description: 'Ultimate Oscillator' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::UltOsc < Indicator::Base 6 | # First Period 7 | attr_accessor :first_period 8 | # Second Period 9 | attr_accessor :second_period 10 | # Third Period 11 | attr_accessor :third_period 12 | 13 | def initialize(*args) 14 | if args.first.is_a? Hash 15 | h = args.first 16 | @first_period = h[:first_period] || 7 17 | @second_period = h[:second_period] || 14 18 | @third_period = h[:third_period] || 28 19 | else 20 | @first_period = args[0] || 7 21 | @second_period = args[1] || 14 22 | @third_period = args[2] || 28 23 | end 24 | 25 | @func = TaLib::Function.new("ULTOSC") 26 | end 27 | 28 | # Is price data required as an input 29 | def self.price_input? 30 | true 31 | end 32 | 33 | # The list of arguments 34 | def self.arguments 35 | [ :first_period, :second_period, :third_period ] 36 | end 37 | 38 | # The minimum set of inputs required 39 | def self.inputs 40 | [ :high, :low, :close ] 41 | end 42 | 43 | # The outputs generated by this function 44 | def self.outputs 45 | [ :out_real ] 46 | end 47 | 48 | def run(*args) 49 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 50 | @func.in_price(0, o, h, l, c, v, nil) 51 | 52 | @func.opt_int(0, @first_period) 53 | @func.opt_int(1, @second_period) 54 | @func.opt_int(2, @third_period) 55 | 56 | out_real = Array.new(len) 57 | @func.out_real(0, out_real) 58 | 59 | @func.call(0, len - 1) 60 | 61 | out_real 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/moving_average_variable_period.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'MAVP' 3 | # Description: 'Moving average with variable period' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::MovingAverageVariablePeriod < Indicator::Base 6 | # Minimum Period 7 | attr_accessor :minimum_period 8 | # Maximum Period 9 | attr_accessor :maximum_period 10 | # MA Type 11 | attr_accessor :ma_type 12 | 13 | def initialize(*args) 14 | if args.first.is_a? Hash 15 | h = args.first 16 | @minimum_period = h[:minimum_period] || 2 17 | @maximum_period = h[:maximum_period] || 30 18 | @ma_type = h[:ma_type] || 0 19 | else 20 | @minimum_period = args[0] || 2 21 | @maximum_period = args[1] || 30 22 | @ma_type = args[2] || 0 23 | end 24 | 25 | @func = TaLib::Function.new("MAVP") 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 | [ :minimum_period, :maximum_period, :ma_type ] 36 | end 37 | 38 | # The minimum set of inputs required 39 | def self.inputs 40 | [ :in_real, :in_periods ] 41 | end 42 | 43 | # The outputs generated by this function 44 | def self.outputs 45 | [ :out_real ] 46 | end 47 | 48 | def run(in_real, in_periods) 49 | len = in_real.length 50 | @func.in_real(0, map(in_real)) 51 | @func.in_real(1, map(in_periods)) 52 | 53 | @func.opt_int(0, @minimum_period) 54 | @func.opt_int(1, @maximum_period) 55 | @func.opt_int(2, @ma_type) 56 | 57 | out_real = Array.new(len) 58 | @func.out_real(0, out_real) 59 | 60 | @func.call(0, len - 1) 61 | 62 | out_real 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/stoch_f.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'STOCHF' 3 | # Description: 'Stochastic Fast' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::StochF < Indicator::Base 6 | # Fast-K Period 7 | attr_accessor :fast_k_period 8 | # Fast-D Period 9 | attr_accessor :fast_d_period 10 | # Fast-D MA 11 | attr_accessor :fast_d_ma 12 | 13 | def initialize(*args) 14 | if args.first.is_a? Hash 15 | h = args.first 16 | @fast_k_period = h[:fast_k_period] || 5 17 | @fast_d_period = h[:fast_d_period] || 3 18 | @fast_d_ma = h[:fast_d_ma] || 0 19 | else 20 | @fast_k_period = args[0] || 5 21 | @fast_d_period = args[1] || 3 22 | @fast_d_ma = args[2] || 0 23 | end 24 | 25 | @func = TaLib::Function.new("STOCHF") 26 | end 27 | 28 | # Is price data required as an input 29 | def self.price_input? 30 | true 31 | end 32 | 33 | # The list of arguments 34 | def self.arguments 35 | [ :fast_k_period, :fast_d_period, :fast_d_ma ] 36 | end 37 | 38 | # The minimum set of inputs required 39 | def self.inputs 40 | [ :high, :low, :close ] 41 | end 42 | 43 | # The outputs generated by this function 44 | def self.outputs 45 | [ :out_fast_k, :out_fast_d ] 46 | end 47 | 48 | def run(*args) 49 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 50 | @func.in_price(0, o, h, l, c, v, nil) 51 | 52 | @func.opt_int(0, @fast_k_period) 53 | @func.opt_int(1, @fast_d_period) 54 | @func.opt_int(2, @fast_d_ma) 55 | 56 | out_fast_k = Array.new(len) 57 | @func.out_real(0, out_fast_k) 58 | out_fast_d = Array.new(len) 59 | @func.out_real(1, out_fast_d) 60 | 61 | @func.call(0, len - 1) 62 | 63 | {:out_fast_k => out_fast_k, 64 | :out_fast_d => out_fast_d} 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /test/data_mapper_test.rb: -------------------------------------------------------------------------------- 1 | require 'minitest/autorun' 2 | require 'indicator' 3 | 4 | include Indicator 5 | 6 | class DataMapperTest < MiniTest::Unit::TestCase 7 | class Bar 8 | attr_accessor :open, :high, :low, :close, :volume 9 | 10 | def initialize seed 11 | @open = seed 12 | @high = seed + 1 13 | @low = seed + 2 14 | @close = seed + 3 15 | @volume = seed + 4 16 | end 17 | 18 | def [] index 19 | if index == :mid 20 | return (@open + @close) / 2.0 21 | elsif index == :offset 22 | return @open + 100 23 | end 24 | end 25 | 26 | def to_s 27 | "#{@open},#{@high},#{@low},#{@close},#{@volume}" 28 | end 29 | end 30 | 31 | class MapTest 32 | include DataMapper 33 | end 34 | 35 | def setup 36 | @mapper = MapTest.new 37 | @default_getter = :open 38 | @simple_ds = [1,2,3,4,5,6,7,8,9,10] 39 | @simple_ds2 = [11,12,13,14,15,16,17,18,19,20] 40 | 41 | @bars = (1..10).inject([]) { |list, i| list << Bar.new(i) } 42 | end 43 | 44 | def test_simple 45 | r = @mapper.map @simple_ds, @default_getter 46 | 47 | assert_equal @simple_ds, r 48 | end 49 | 50 | def ensure_default_is_not_used 51 | r = @mapper.map @simple_ds, lambda { |i| i * 10 } 52 | assert_equal @simple_ds, r 53 | end 54 | 55 | def test_with_lamda 56 | m = DataMapper::Map.new @simple_ds, lambda { |i| i * 10 } 57 | r = @mapper.map m, @default_getter 58 | 59 | ds2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] 60 | assert_equal ds2, r 61 | end 62 | 63 | def test_double_with_symbol_map 64 | m = DataMapper::Map.new @bars, :open 65 | r = @mapper.map m, @default_getter 66 | 67 | assert_equal [1,2,3,4,5,6,7,8,9,10], r 68 | end 69 | 70 | def test_double_with_hash_map 71 | m = DataMapper::Map.new @bars, :mid 72 | r = @mapper.map m, @default_getter 73 | 74 | assert_equal [2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5], r 75 | end 76 | end 77 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/macd.rb: -------------------------------------------------------------------------------- 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 7 | attr_accessor :fast_period 8 | # Slow Period 9 | attr_accessor :slow_period 10 | # Signal Period 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 70 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/stoch_rsi.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'STOCHRSI' 3 | # Description: 'Stochastic Relative Strength Index' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::StochRsi < Indicator::Base 6 | # Time Period 7 | attr_accessor :time_period 8 | # Fast-K Period 9 | attr_accessor :fast_k_period 10 | # Fast-D Period 11 | attr_accessor :fast_d_period 12 | # Fast-D MA 13 | attr_accessor :fast_d_ma 14 | 15 | def initialize(*args) 16 | if args.first.is_a? Hash 17 | h = args.first 18 | @time_period = h[:time_period] || 14 19 | @fast_k_period = h[:fast_k_period] || 5 20 | @fast_d_period = h[:fast_d_period] || 3 21 | @fast_d_ma = h[:fast_d_ma] || 0 22 | else 23 | @time_period = args[0] || 14 24 | @fast_k_period = args[1] || 5 25 | @fast_d_period = args[2] || 3 26 | @fast_d_ma = args[3] || 0 27 | end 28 | 29 | @func = TaLib::Function.new("STOCHRSI") 30 | end 31 | 32 | # Is price data required as an input 33 | def self.price_input? 34 | false 35 | end 36 | 37 | # The list of arguments 38 | def self.arguments 39 | [ :time_period, :fast_k_period, :fast_d_period, :fast_d_ma ] 40 | end 41 | 42 | # The minimum set of inputs required 43 | def self.inputs 44 | [ :in_real ] 45 | end 46 | 47 | # The outputs generated by this function 48 | def self.outputs 49 | [ :out_fast_k, :out_fast_d ] 50 | end 51 | 52 | def run(in_real) 53 | len = in_real.length 54 | @func.in_real(0, map(in_real)) 55 | 56 | @func.opt_int(0, @time_period) 57 | @func.opt_int(1, @fast_k_period) 58 | @func.opt_int(2, @fast_d_period) 59 | @func.opt_int(3, @fast_d_ma) 60 | 61 | out_fast_k = Array.new(len) 62 | @func.out_real(0, out_fast_k) 63 | out_fast_d = Array.new(len) 64 | @func.out_real(1, out_fast_d) 65 | 66 | @func.call(0, len - 1) 67 | 68 | {:out_fast_k => out_fast_k, 69 | :out_fast_d => out_fast_d} 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /lib/indicator/data_mapper.rb: -------------------------------------------------------------------------------- 1 | module Indicator 2 | module DataMapper 3 | 4 | class SourceMustBeEnumerable < StandardError 5 | end 6 | 7 | class InvalidMapping < StandardError 8 | end 9 | 10 | Map = Struct.new(:source, :getter) 11 | 12 | def default_getter 13 | @default_getter || :close 14 | end 15 | 16 | def default_getter= v 17 | @default_getter = v 18 | end 19 | 20 | def map ds, getter=default_getter 21 | 22 | return nil unless ds 23 | 24 | # ds can be supplied as an array of [source, mapping] or simply 25 | # the source 26 | if ds.is_a? Map 27 | source = ds.source 28 | mapping = ds.getter 29 | else 30 | source = ds 31 | end 32 | 33 | raise SourceMustBeEnumerable unless source.is_a? Enumerable 34 | raise ArgumentError unless getter 35 | 36 | # Return nil straight away if the data source is empty. The 37 | # downstream ta-lib functions can handle a nil argument. 38 | return nil unless source.length > 0 39 | 40 | # No need to go any further if no mapping was specified and 41 | # the specified data source responds to 'to_f'. 42 | element = source.first 43 | return source if element.respond_to?(:to_f) and mapping.nil? 44 | 45 | mapping ||= getter 46 | mapping_sym = mapping.to_sym rescue nil 47 | 48 | # Figure out how to use the mapping value. 49 | # It can either be a directly callable mapping, a function name 50 | # or a hash index. 51 | map_proc = 52 | if mapping.respond_to? :call 53 | mapping 54 | else 55 | if not mapping_sym.nil? and element.respond_to?(mapping_sym) 56 | mapping_sym.to_proc 57 | elsif element.respond_to?(:[]) 58 | ->(e) { e[mapping] } 59 | end 60 | end 61 | 62 | raise InvalidMapping unless map_proc 63 | 64 | # Returned the mapped data 65 | source.collect { |e| map_proc.call(e) } 66 | end 67 | 68 | end 69 | end 70 | 71 | def new_map(ds, map) 72 | Indicator::DataMapper::Map.new(ds, map) 73 | end 74 | -------------------------------------------------------------------------------- /lib/indicator/auto_gen/stoch.rb: -------------------------------------------------------------------------------- 1 | # Ta-Lib function mapping class 2 | # Function: 'STOCH' 3 | # Description: 'Stochastic' 4 | # This file has been autogenerated - Do Not Edit. 5 | class Indicator::AutoGen::Stoch < Indicator::Base 6 | # Fast-K Period 7 | attr_accessor :fast_k_period 8 | # Slow-K Period 9 | attr_accessor :slow_k_period 10 | # Slow-K MA 11 | attr_accessor :slow_k_ma 12 | # Slow-D Period 13 | attr_accessor :slow_d_period 14 | # Slow-D MA 15 | attr_accessor :slow_d_ma 16 | 17 | def initialize(*args) 18 | if args.first.is_a? Hash 19 | h = args.first 20 | @fast_k_period = h[:fast_k_period] || 5 21 | @slow_k_period = h[:slow_k_period] || 3 22 | @slow_k_ma = h[:slow_k_ma] || 0 23 | @slow_d_period = h[:slow_d_period] || 3 24 | @slow_d_ma = h[:slow_d_ma] || 0 25 | else 26 | @fast_k_period = args[0] || 5 27 | @slow_k_period = args[1] || 3 28 | @slow_k_ma = args[2] || 0 29 | @slow_d_period = args[3] || 3 30 | @slow_d_ma = args[4] || 0 31 | end 32 | 33 | @func = TaLib::Function.new("STOCH") 34 | end 35 | 36 | # Is price data required as an input 37 | def self.price_input? 38 | true 39 | end 40 | 41 | # The list of arguments 42 | def self.arguments 43 | [ :fast_k_period, :slow_k_period, :slow_k_ma, :slow_d_period, :slow_d_ma ] 44 | end 45 | 46 | # The minimum set of inputs required 47 | def self.inputs 48 | [ :high, :low, :close ] 49 | end 50 | 51 | # The outputs generated by this function 52 | def self.outputs 53 | [ :out_slow_k, :out_slow_d ] 54 | end 55 | 56 | def run(*args) 57 | o, h, l, c, v, len = map_ohlcv(self.class.inputs, *args) 58 | @func.in_price(0, o, h, l, c, v, nil) 59 | 60 | @func.opt_int(0, @fast_k_period) 61 | @func.opt_int(1, @slow_k_period) 62 | @func.opt_int(2, @slow_k_ma) 63 | @func.opt_int(3, @slow_d_period) 64 | @func.opt_int(4, @slow_d_ma) 65 | 66 | out_slow_k = Array.new(len) 67 | @func.out_real(0, out_slow_k) 68 | out_slow_d = Array.new(len) 69 | @func.out_real(1, out_slow_d) 70 | 71 | @func.call(0, len - 1) 72 | 73 | {:out_slow_k => out_slow_k, 74 | :out_slow_d => out_slow_d} 75 | end 76 | end 77 | --------------------------------------------------------------------------------