Class: IB::Messages::Outgoing::BarRequestMessage

Inherits:
AbstractMessage show all
Defined in:
lib/ib/messages/outgoing/bar_requests.rb

Overview

Messages that request bar data have special processing of @data

Instance Attribute Summary

Attributes inherited from AbstractMessage

#created_at, #data

Instance Method Summary collapse

Methods inherited from AbstractMessage

data_map, message_id, #message_id, message_type, #message_type, properties?, #request_id, #to_human, version

Instance Method Details

#parse(data) ⇒ Object

Preprocessor for some data fields



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ib/messages/outgoing/bar_requests.rb', line 9

def parse data
  type = data[:data_type] || data[:what_to_show]
  data_type = DATA_TYPES.invert[type] || type
  unless  DATA_TYPES.keys.include?(data_type)
    error ":data_type must be one of #{DATA_TYPES.inspect}", :args
  end

  #size = data[:bar_size] || data[:size]
  #bar_size = BAR_SIZES.invert[size] || size
  # unless  BAR_SIZES.keys.include?(bar_size)
    # error ":bar_size must be one of #{BAR_SIZES.inspect}", :args
  # end
  unless data[:contract].is_a? IB::Contract
    error "contract must be a valid IB::Contract" , :args
  end
  [data_type, nil, data[:contract]]
end