Class: IB::IncomingMessages::HistoricalData

Inherits:
AbstractMessage show all
Defined in:
lib/ib-ruby/messages.rb

Overview

ReceiveFa

Instance Attribute Summary

Attributes inherited from AbstractMessage

#data

Attributes inherited from ExtremelyAbstractMessage

#created_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractMessage

inherited, #initialize

Constructor Details

This class inherits a constructor from IB::IncomingMessages::AbstractMessage

Class Method Details

.message_idObject



1335
1336
1337
# File 'lib/ib-ruby/messages.rb', line 1335

def self.message_id
  17
end

Instance Method Details

#loadObject



1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
# File 'lib/ib-ruby/messages.rb', line 1339

def load
  autoload([:version, :int], [:req_id, :int])
  version_load(2, [:start_date_str, :string], [:end_date_str, :string])
  @data[:completed_indicator] = "finished-" + @data[:start_date_str] + "-" + @data[:end_date_str] if @data[:version] >= 2

  autoload([:item_count, :int])
  @data[:history] = Array.new(@data[:item_count]) {|index|
    attrs = {
      :date => @socket.read_string,
      :open => @socket.read_decimal,
      :high => @socket.read_decimal,
      :low => @socket.read_decimal,
      :close => @socket.read_decimal,
      :volume => @socket.read_int,
      :wap => @socket.read_decimal,
      :has_gaps => @socket.read_string
    }

    Datatypes::Bar.new(attrs)
  }

end

#to_humanObject



1362
1363
1364
# File 'lib/ib-ruby/messages.rb', line 1362

def to_human
  "<HistoricalData: req id #{@data[:req_id]}, #{@data[:item_count]} items, from #{@data[:start_date_str]} to #{@data[:end_date_str]}>"
end