Sha256: 8e55440817749879fc00bac64713b1346d68c29227654b047d76b0b6cda29ffb

Contents?: true

Size: 897 Bytes

Versions: 2

Compression:

Stored size: 897 Bytes

Contents

require 'ib-ruby/models/contract_detail'

module IB
  module Models

    # Calculated characteristics of underlying Contract (volatile)
    class Underlying < Model.for(:underlying)
      include ModelProperties

      has_one :contract

      prop :con_id, # Id of the Underlying Contract
           :delta, # double: The underlying stock or future delta.
           :price #  double: The price of the underlying.

      validates_numericality_of :con_id, :delta, :price #, :allow_nil => true

      def default_attributes
        {:con_id => 0}.merge super
      end

      # Serialize under_comp parameters
      def serialize
        [true, con_id, delta, price]
      end

      # Comparison
      def == other
        con_id == other.con_id && delta == other.delta && price == other.price
      end

    end # class Contract
    UnderComp = Underlying

  end # module Models
end # module IB

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ib-ruby-0.7.9 lib/ib-ruby/models/underlying.rb
ib-ruby-0.7.8 lib/ib-ruby/models/underlying.rb