Sha256: fdc4086c8b4a61de9e86f32e5ee994d622530cf39e65c7e2bb08a963257289b5

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

require 'test_helper'
require 'signal_tools'

class TestStockData < Test::Unit::TestCase
  def setup
    ticker = "TESTING"
    @days = 90
    @total_days = @days + SignalTools::StockData::Extra_Days
    @from_date = Date.today - @days
    @to_date = Date.today
    flexmock(YahooFinance).should_receive(:get_historical_quotes).with_any_args.and_return(data_for_tests(@days))
    @stock_data = SignalTools::StockData.new(ticker, @from_date, @to_date)
  end

  def test_dates
    new_dates = []
    (0...@days).each { |i| new_dates.unshift(@to_date - i) }
    assert_equal new_dates, @stock_data.dates
  end

  def test_open_prices
    result = @stock_data.open_prices.delete_if { |e| !e.is_a?(Float) }
    assert_equal @total_days, result.size
  end

  def test_high_prices
    result = @stock_data.high_prices.delete_if { |e| !e.is_a?(Float) }
    assert_equal @total_days, result.size
  end

  def test_low_prices
    result = @stock_data.low_prices.delete_if { |e| !e.is_a?(Float) }
    assert_equal @total_days, result.size
  end

  def test_close_prices
    result = @stock_data.close_prices.delete_if { |e| !e.is_a?(Float) }
    assert_equal @total_days, result.size
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
signal_tools-0.2.2 test/test_stock_data.rb
signal_tools-0.2.1 test/test_stock_data.rb