Sha256: 0a553a0a0a8284ca2abb25e39033384e27641a1bb18c50b5ead866176ae760e5

Contents?: true

Size: 777 Bytes

Versions: 1

Compression:

Stored size: 777 Bytes

Contents

require './lib/signal_tools/technicals/stochastic'

module SignalTools::Technicals
  class SlowStochastic
    include Stochastic

    SMA_DEFAULT = 3

    def initialize(stock_data, k_period, d_period)
      @d_period = d_period
      @k_period = k_period
      @stock_data = stock_data
    end

    def calculate
      # trim_data_to_range!(slow_stochastic_points(k_period, d_period))
      slow_stochastic_points
    end

    def slow_stochastic_points
      fast_points = fast_stochastic_points
      k_points = slow_k_points(fast_points[:k])
      slow_d_points = calculate_d_points(k_points, d_period)
      k_d_points(k_points, slow_d_points)
    end

    def slow_k_points(fast_k_points)
      collection_for_array(fast_k_points, SMA_DEFAULT, :average)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
signal_tools-0.3.1 lib/signal_tools/technicals/slow_stochastic.rb