Sha256: 9fef9b4b31b4fe61a6513ac757a5cec31d9ab8f48642670da694f71de3ee3113

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

require 'integration_helper'

describe 'Request Fundamental Data',
         :connected => true, :integration => true, :reuters => true do

  before(:all) do
    verify_account
    @ib = IB::Connection.new OPTS[:connection].merge(:logger => mock_logger)

    @contract = IB::Contract.new :symbol => 'IBM',
                                 :exchange => 'NYSE',
                                 :currency => 'USD',
                                 :sec_type => 'STK'

    @ib.send_message :RequestFundamentalData,
                     :id => 456,
                     :contract => @contract,
                     :report_type => 'snapshot' # 'estimates', 'finstat'

    @ib.wait_for :FundamentalData, 10 # sec
  end

  after(:all) do
    close_connection
  end

  subject { @ib.received[:FundamentalData].first }

  it { @ib.received[:FundamentalData].should have_at_least(1).data_message }

  it { should be_an IB::Messages::Incoming::FundamentalData }
  its(:request_id) { should == 456 }
  its(:xml) { should be_a String }

  it 'responds with XML with relevant data' do
    require 'xmlsimple'
    data_xml = XmlSimple.xml_in(subject.xml, 'ForceArray' => false) #, 'ContentKey' => 'content')
    name = data_xml["CoIDs"]["CoID"].find {|tag| tag['Type'] == 'CompanyName'}['content']
    name.should =~ /International Business Machines/
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ib-ruby-0.9.2 spec/integration/fundamental_data_spec.rb
ib-ruby-0.9.1 spec/integration/fundamental_data_spec.rb
ib-ruby-0.9.0 spec/integration/fundamental_data_spec.rb