Class: TechnicalAnalysis::MacdValue

Inherits:
Object
  • Object
show all
Defined in:
lib/technical_analysis/indicators/macd.rb

Overview

The value class to be returned by calculations

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date_time: nil, macd_line: nil, macd_histogram: nil, signal_line: nil) ⇒ MacdValue

Returns a new instance of MacdValue.



126
127
128
129
130
131
# File 'lib/technical_analysis/indicators/macd.rb', line 126

def initialize(date_time: nil, macd_line: nil, macd_histogram: nil, signal_line: nil)
  @date_time = date_time
  @macd_line = macd_line
  @macd_histogram = macd_histogram
  @signal_line = signal_line
end

Instance Attribute Details

#date_timeString

Returns the date_time of the obversation as it was provided.

Returns:

  • (String)

    the date_time of the obversation as it was provided



115
116
117
# File 'lib/technical_analysis/indicators/macd.rb', line 115

def date_time
  @date_time
end

#macd_histogramFloat

Returns the macd_histogram calculation value.

Returns:

  • (Float)

    the macd_histogram calculation value



121
122
123
# File 'lib/technical_analysis/indicators/macd.rb', line 121

def macd_histogram
  @macd_histogram
end

#macd_lineFloat

Returns the macd_line calculation value.

Returns:

  • (Float)

    the macd_line calculation value



118
119
120
# File 'lib/technical_analysis/indicators/macd.rb', line 118

def macd_line
  @macd_line
end

#signal_lineFloat

Returns the signal_line calculation value.

Returns:

  • (Float)

    the signal_line calculation value



124
125
126
# File 'lib/technical_analysis/indicators/macd.rb', line 124

def signal_line
  @signal_line
end

Instance Method Details

#to_hashHash

Returns the attributes as a hash.

Returns:

  • (Hash)

    the attributes as a hash



134
135
136
137
138
139
140
141
# File 'lib/technical_analysis/indicators/macd.rb', line 134

def to_hash
  {
    date_time: @date_time,
    macd_line: @macd_line,
    macd_histogram: @macd_histogram,
    signal_line: @signal_line
  }
end