Sha256: ec1a8d850e6e7e06877d42f05e3ddce4a53db4d19391fb5431216ac5e35f9985

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require './test/test_helper'

class TestMACD < Minitest::Test
  def setup
    ticker = "TESTING"
    @days = 90

    YahooFinance.stub(:get_historical_quotes, data_for_tests(@days)) do
      @data = SignalTools::Stock.new(ticker)
    end

    @data = @data.stock_data.close_prices
  end

  def test_calculate
    assert_equal "-0.034645", "%.6f" % SignalTools::Technicals::MACD.new(@data, 8, 17, 9).calculate[:signal_points][-1]
    assert_equal "-0.018762", "%.6f" % SignalTools::Technicals::MACD.new(@data, 8, 17, 9).calculate[:signal_points][-5]
    assert_equal "-0.195043", "%.6f" % SignalTools::Technicals::MACD.new(@data, 8, 17, 9).calculate[:divergences][-1]
    assert_equal "0.063532",  "%.6f" % SignalTools::Technicals::MACD.new(@data, 8, 17, 9).calculate[:divergences][-5]

    assert_equal "-0.022654", "%.6f" % SignalTools::Technicals::MACD.new(@data, 12, 26, 9).calculate[:signal_points][-1]
    assert_equal "-0.014099", "%.6f" % SignalTools::Technicals::MACD.new(@data, 12, 26, 9).calculate[:signal_points][-5]
    assert_equal "-0.136291", "%.6f" % SignalTools::Technicals::MACD.new(@data, 12, 26, 9).calculate[:divergences][-1]
    assert_equal "0.034219",  "%.6f" % SignalTools::Technicals::MACD.new(@data, 12, 26, 9).calculate[:divergences][-5]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
signal_tools-0.3.1 test/lib/signal_tools/technicals/test_macd.rb