Sha256: 5bea6c0a5bd09b1c5e5a9a8fec65389d837d26953cbdc03176ab82c20bb1e64b

Contents?: true

Size: 826 Bytes

Versions: 2

Compression:

Stored size: 826 Bytes

Contents

module IB

  # Calculated characteristics of underlying Contract (volatile)
  class Underlying < IB::Model
    include BaseProperties

    attr_accessible :created_at, :updated_at
    attr_protected :id

    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
      super.merge :con_id => 0
    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 Underlying
  UnderComp = Underlying

end # module IB

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ib-ruby-0.8.4 lib/models/ib/underlying.rb
ib-ruby-0.8.3 lib/models/ib/underlying.rb