Class: IB::Messages::Outgoing::RequestHistoricalData

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

Instance Method Summary collapse

Instance Method Details

#encodeObject



172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/ib/messages/outgoing/bar_requests.rb', line 172

def encode
  data_type, bar_size, contract = parse @data

  [super,
   contract.serialize_long(:include_expired),
   @data[:end_date_time],
   bar_size,
   @data[:duration],
   @data[:use_rth],
   data_type.to_s.upcase,
   @data[:format_date],
   contract.serialize_legs]
end

#parse(data) ⇒ Object



161
162
163
164
165
166
167
168
169
170
# File 'lib/ib/messages/outgoing/bar_requests.rb', line 161

def parse data
  data_type, bar_size, contract = super data

  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
  [data_type, bar_size, contract]
end