Sha256: c2a87af76d54529631743bed39244f300c6fc815cd975a22f1597883f0fb6617

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

require 'fin/models/model'

module Fin

  # Represents Depth-of-Market Aggregate Order for a given security and price level.
  # Source table: 	FORTS_OPTAGGR**_REPL::orders_aggr, where (**) is 5, 20, 50
  #
  class Quote < Model
    model_class_id 16

    # Properties as per P2ClientGate API
    property :isin_id => :i8, #         Уникальный числовой идентификатор инструмента
             :price => :'d16.5', #      Цена котировки
             :volume => :i8, # 	        Объём агрегированной котировки
             [:dir, :buysell] => :i1, #	Направление котировки: покупка (1) /продажа (2)
             :moment => :t #          	Время последнего обновления котировки

    attr_accessor :book

    def self.index_for rec
      rec.GetValAsLong('replID')
    end

    def index
      repl_id
    end

    def price_as_integer
      if price && price.round == price
        price.to_i
      else
        price
      end
    end

    def to_s
      "#{repl_id}:#{price_as_integer}>#{volume}#{dir == 1 ? '+' : '-'}"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fin-0.1.6 lib/fin/models/quote.rb
fin-0.1.5 lib/fin/models/quote.rb
fin-0.1.4 lib/fin/models/quote.rb
fin-0.1.3 lib/fin/models/quote.rb
fin-0.1.2 lib/fin/models/quote.rb