Sha256: 5b5b8aae51e155a26d3bad46a8efcc6e5737131a929ff52f4304d081cfe6219c

Contents?: true

Size: 1.44 KB

Versions: 13

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe IEX::Resources::OHLC do
  include_context 'client'

  context 'known symbol', vcr: { cassette_name: 'ohlc/msft' } do
    subject do
      client.ohlc('MSFT')
    end
    it 'retrieves a close price' do
      expect(subject.close.price).to eq 119.36
    end
    it 'retrieves a open price' do
      expect(subject.open.price).to eq 120
    end
    it 'retrieves a high price' do
      expect(subject.high).to eq 120.23
    end
    it 'retrieves a low price' do
      expect(subject.low).to eq 118.38
    end
    it 'retrieves a close price date/time' do
      expect(subject.close.time.to_f).to eq 1_554_408_000.193
    end
    it 'retrieves a open price date/time' do
      expect(subject.open.time.to_f).to eq 1_554_384_600.42
    end
  end

  context 'market', vcr: { cassette_name: 'ohlc/market' } do
    subject do
      client.market
    end
    it 'retrieves a right number of stocks' do
      expect(subject.size).to eq 8890
    end
    it 'retrieves a close price for known symbol' do
      expect(subject['MSFT'].close.price).to eq 119.36
    end
    it 'retrieves a close price time for known symbol' do
      expect(subject['MSFT'].close.time.to_f).to eq 1_554_408_000.193
    end
    it 'retrieves a open price for known symbol' do
      expect(subject['MSFT'].open.price).to eq 120
    end
    it 'retrieves a open price time for known symbol' do
      expect(subject['MSFT'].open.time.to_f).to eq 1_554_384_600.42
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
iex-ruby-client-2.1.0 spec/iex/endpoints/ohlc_spec.rb
iex-ruby-client-2.0.0 spec/iex/endpoints/ohlc_spec.rb
iex-ruby-client-1.6.0 spec/iex/endpoints/ohlc_spec.rb
iex-ruby-client-1.5.0 spec/iex/endpoints/ohlc_spec.rb
iex-ruby-client-1.4.1 spec/iex/endpoints/ohlc_spec.rb
iex-ruby-client-1.4.0 spec/iex/endpoints/ohlc_spec.rb
iex-ruby-client-1.3.0 spec/iex/endpoints/ohlc_spec.rb
iex-ruby-client-1.2.0 spec/iex/endpoints/ohlc_spec.rb
iex-ruby-client-1.1.2 spec/iex/endpoints/ohlc_spec.rb
iex-ruby-client-1.1.1 spec/iex/endpoints/ohlc_spec.rb
iex-ruby-client-1.1.0 spec/iex/endpoints/ohlc_spec.rb
iex-ruby-client-1.0.1 spec/iex/endpoints/ohlc_spec.rb
iex-ruby-client-1.0.0 spec/iex/endpoints/ohlc_spec.rb