Class: Quant::IndicatorsProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/quant/indicators_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(series:, source:) ⇒ IndicatorsProxy

Returns a new instance of IndicatorsProxy.



7
8
9
10
11
# File 'lib/quant/indicators_proxy.rb', line 7

def initialize(series:, source:)
  @series = series
  @source = source
  @indicators = {}
end

Instance Attribute Details

#indicatorsObject (readonly)

Returns the value of attribute indicators.



5
6
7
# File 'lib/quant/indicators_proxy.rb', line 5

def indicators
  @indicators
end

#seriesObject (readonly)

Returns the value of attribute series.



5
6
7
# File 'lib/quant/indicators_proxy.rb', line 5

def series
  @series
end

#sourceObject (readonly)

Returns the value of attribute source.



5
6
7
# File 'lib/quant/indicators_proxy.rb', line 5

def source
  @source
end

Instance Method Details

#<<(tick) ⇒ Object



17
18
19
# File 'lib/quant/indicators_proxy.rb', line 17

def <<(tick)
  indicators.each_value { |indicator| indicator << tick }
end

#indicator(indicator_class) ⇒ Object



13
14
15
# File 'lib/quant/indicators_proxy.rb', line 13

def indicator(indicator_class)
  indicators[indicator_class] ||= indicator_class.new(series: series, source: source)
end

#maObject



21
# File 'lib/quant/indicators_proxy.rb', line 21

def ma; indicator(Indicators::Ma) end