Sha256: 8cb379eae10f44ca85dc5897f1726644347c2363a36a8699a3460bf2a9fa46ce

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

require 'ib-ruby/models/contract'

module IB
  module Models
    class Contract

      # "BAG" is not really a contract, but a combination (combo) of securities.
      # AKA basket or bag of securities. Individual securities in combo are represented
      # by ComboLeg objects.
      class Bag < Contract
        # General Notes:
        # 1. :exchange for the leg definition must match that of the combination order.
        # The exception is for a STK legs, which must specify the SMART exchange.
        # 2. :symbol => "USD" For combo Contract, this is an arbitrary value (like “USD”)

        def initialize opts = {}
          super opts
          @sec_type = IB::SECURITY_TYPES[:bag]
        end

        def description
          @description || to_human
        end

        def to_human
          "<Bag: " + [symbol, exchange, currency].join(" ") + " legs: " +
              (@combo_legs_description ||
                  @combo_legs.map do |leg|
                    "#{leg.action} #{leg.ratio} * #{leg.con_id}"
                  end.join('|')) + ">"
        end

      end # class Bag

      TYPES[IB::SECURITY_TYPES[:bag]] = Bag

    end # class Contract
  end # module Models
end # module IB

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ib-ruby-0.5.14 lib/ib-ruby/models/contract/bag.rb
ib-ruby-0.5.13 lib/ib-ruby/models/contract/bag.rb
ib-ruby-0.5.12 lib/ib-ruby/models/contract/bag.rb
ib-ruby-0.5.11 lib/ib-ruby/models/contract/bag.rb