Sha256: c3ebeb39e20ecdd8f187f15e5ec63b3aeddca46820837a8a2adc6476c3a05cf9
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
require 'fin/models/model' module Fin class Order < Model # Properties as per P2ClientGate API prop_accessor [:repl_id, :id], [:repl_rev, :rev], [:isin_id, :isin], :price, # d16.5 Цена котировки :volume, # i8 Объём агрегированной котировки [:dir, :buysell], # i1 Направление котировки: покупка (1) /продажа (2) :moment # t Время последнего обновления котировки attr_accessor :book def self.from_record rec new :isin_id => rec.GetValAsLong('isin_id'), :repl_id => rec.GetValAsString('replID').to_i, :repl_rev => rec.GetValAsString('replRev').to_i, :price => rec.GetValAsString('price').to_f, :volume => rec.GetValAsString('volume').to_f, :moment => rec.GetValAsString('moment'), :dir => rec.GetValAsLong('dir') end def self.index_for rec rec.GetValAsLong('replID') end def index @repl_id end def price= val val = val.to_f @price = val.round == val ? val.to_i : val end def inspect "#{repl_id}:#{price}>#{volume}#{dir == 1 ? '+' : '-'}" end alias to_s inspect end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fin-0.1.0 | lib/fin/models/order.rb |