class Iqfeed::Level1Tick
Attributes
ask[RW]
bid[RW]
last_price[RW]
last_size[RW]
sym[RW]
time_stamp[RW]
total_volume[RW]
type[RW]
Public Class Methods
parse(line)
click to toggle source
# File lib/iqfeed/level1_client.rb, line 23 def self.parse(line) fields = line.split(',') tick = Level1Tick.new tick.type = fields[17] tick.sym = fields[1] tick.bid = fields[10] tick.ask = fields[11] tick.last_price = fields[3] tick.last_size = fields[7] tick.total_volume = fields[6] tick.time_stamp = fields[65] tick.type =~ /(t|a|b)/ ? tick : nil end
Public Instance Methods
to_s(bid, ask)
click to toggle source
# File lib/iqfeed/level1_client.rb, line 37 def to_s(bid, ask) if (@type =~ /t/) if @last_price == @bid operation = 'SELL' elsif @last_price == @ask operation = 'BUY' elsif @last_price == bid operation = 'SELL' elsif @last_price == ask operation = 'BUY' else operation = 'UNKNOWN' end "Symbol: #{@sym} TS:#{@time_stamp} Size:#{@last_size} Price:#{@last_price} Bid:#{@bid} Ask:#{@ask} #{operation}" # elsif (@type =~ /T/) # "extendedTrade" # elsif !@type.nil? # "other" # else # nil end end