Class: TechnicalAnalysis::Indicator
- Inherits:
-
Object
- Object
- TechnicalAnalysis::Indicator
- Defined in:
- lib/technical_analysis/indicators/indicator.rb
Direct Known Subclasses
Adi, Adtv, Adx, Ao, Atr, Bb, Cci, Cmf, Cr, Dc, Dlr, Dpo, Dr, Ema, Eom, Fi, Ichimoku, Kc, Kst, Macd, Mfi, Mi, Nvi, Obv, ObvMean, Rsi, Sma, Sr, Trix, Tsi, Uo, Vi, Vpt, Vwap, Wma, Wr
Class Method Summary collapse
-
.calculate(indicator_symbol, data, calculation, options = {}) ⇒ Object
Find the applicable indicator and looks up the value.
-
.find(indicator_symbol) ⇒ Object
Finds the applicable indicator and returns an instance.
-
.indicator_name ⇒ String
Returns the name of the technical indicator.
-
.indicator_symbol ⇒ String
Returns the symbol of the technical indicator.
-
.min_data_size(indicator_symbol, options) ⇒ Integer
Calculates the minimum number of observations needed to calculate the technical indicator.
-
.roster ⇒ Array
Returns an array of TechnicalAnalysis modules.
-
.valid_options ⇒ Array
Returns an array of valid keys for options for this technical indicator.
-
.validate_options(options) ⇒ Boolean
Validates the provided options for this technical indicator.
Class Method Details
.calculate(indicator_symbol, data, calculation, options = {}) ⇒ Object
Find the applicable indicator and looks up the value
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/technical_analysis/indicators/indicator.rb', line 78 def self.calculate(indicator_symbol, data, calculation, ={}) return nil unless CALCULATIONS.include? calculation indicator = find(indicator_symbol) raise "Indicator not found!" if indicator.nil? case calculation when :indicator_name; indicator.indicator_name when :indicator_symbol; indicator.indicator_symbol when :technicals; indicator.calculate(data, ) when :min_data_size; indicator.min_data_size() when :valid_options; indicator. when :validate_options; indicator.() else nil end end |
.find(indicator_symbol) ⇒ Object
Finds the applicable indicator and returns an instance
62 63 64 65 66 67 68 |
# File 'lib/technical_analysis/indicators/indicator.rb', line 62 def self.find(indicator_symbol) roster.each do |indicator| return indicator if indicator.indicator_symbol == indicator_symbol end nil end |
.indicator_name ⇒ String
Returns the name of the technical indicator
134 135 136 |
# File 'lib/technical_analysis/indicators/indicator.rb', line 134 def self.indicator_name raise "#{self.name} did not implement indicator_name" end |
.indicator_symbol ⇒ String
Returns the symbol of the technical indicator
127 128 129 |
# File 'lib/technical_analysis/indicators/indicator.rb', line 127 def self.indicator_symbol raise "#{self.name} did not implement indicator_symbol" end |
.min_data_size(indicator_symbol, options) ⇒ Integer
Calculates the minimum number of observations needed to calculate the technical indicator
101 102 103 104 |
# File 'lib/technical_analysis/indicators/indicator.rb', line 101 def self.min_data_size(indicator_symbol, ) raise "#{self.name} did not implement min_data_size" nil end |
.roster ⇒ Array
Returns an array of TechnicalAnalysis modules
.valid_options ⇒ Array
Returns an array of valid keys for options for this technical indicator
119 120 121 122 |
# File 'lib/technical_analysis/indicators/indicator.rb', line 119 def self. raise "#{self.name} did not implement valid_options" [] end |
.validate_options(options) ⇒ Boolean
Validates the provided options for this technical indicator
111 112 113 114 |
# File 'lib/technical_analysis/indicators/indicator.rb', line 111 def self.() raise "#{self.name} did not implement validate_options" false end |