Sha256: 7add1f504569134faba619b3b7bdd577b1fcc830b1207f840baf03afb596d910

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 Bytes

Contents

require './test/test_helper'

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

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

    @close_prices = @stock.stock_data.close_prices
  end

  def test_calculate
    assert_equal "2.344948", "%.6f" % SignalTools::Technicals::EMA.new(@close_prices, 10, :default).calculate[-1]
    assert_equal "2.736776", "%.6f" % SignalTools::Technicals::EMA.new(@close_prices, 10, :default).calculate[-5]
    assert_equal "2.556322", "%.6f" % SignalTools::Technicals::EMA.new(@close_prices, 25, :default).calculate[-1]
    assert_equal "2.705835", "%.6f" % SignalTools::Technicals::EMA.new(@close_prices, 25, :default).calculate[-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_ema.rb