Class: String

Inherits:
Object show all
Defined in:
lib/models/ib/contract.rb,
lib/extensions/class-extensions.rb

Overview

module IB

Instance Method Summary collapse

Instance Method Details

#to_boolObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/extensions/class-extensions.rb', line 44

def to_bool
  case self.chomp.upcase
    when 'TRUE', 'T', '1'
      true
    when 'FALSE', 'F', '0', ''
      false
    else
      error "Unable to convert #{self} to bool"
  end
end

#to_contractObject



425
426
427
428
429
430
431
432
# File 'lib/models/ib/contract.rb', line 425

def to_contract
     keys = [:con_id, :symbol, :sec_type, :expiry, :strike, :right, :multiplier,
             :exchange, :primary_exchange, :currency, :local_symbol]
     props = Hash[keys.zip(split(":"))]
     props.delete_if { |k, v| v.nil? || v.empty? }
     IB::Contract.build props

end