Class: IB::Messages::Incoming::TickByTick

Inherits:
Object
  • Object
show all
Defined in:
lib/ib/messages/incoming/ticks.rb

Overview

error messages: (10189) “Failed to request tick-by-tick data:Historical data request pacing violation”

Instance Method Summary collapse

Instance Method Details

#loadObject



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/ib/messages/incoming/ticks.rb', line 171

def load
	super
	case @data[:tick_type ] 
							when 0
								# do nothing
							when 1, 2 # Last, AllLast
			load_map	[ :price, :decimal ]	,
								[ :size, :int ] ,
								[ :mask, :int ]	,  		
								[ :exchange, :string ], 
								[ :special_conditions, :string ]
							when 3  # bid/ask
			load_map  [ :bid_price, :decimal ],
								[ :ask_price, :decimal],
								[ :bid_size, :int ],
								[ :ask_size, :int] ,
								[ :mask, :int  ]	
							when 4
			load_map	[ :mid_point, :decimal ]
							end

	@out_labels = case @data[ :tick_tpye ]
							when 1, 2
								[ "PastLimit", "Unreported" ]
								when 3 
								[ "BitPastLow", "BidPastHigh" ]
								else
									[]
								end	
end

#resolve_maskObject



167
168
169
# File 'lib/ib/messages/incoming/ticks.rb', line 167

def resolve_mask
	@data[:mask].present? ? [ @data[:mask] & 1 , @data[:mask] & 2  ] : [] 
end

#to_humanObject



201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/ib/messages/incoming/ticks.rb', line 201

def to_human
	"< TickByTick:" + 	case @data[ :tick_type ]
	when 1,2
		"(Last) #{size} @ #{price} [#{exchange}] "
	when 3
		"(Bid/Ask) #{bid_size} @ #{bid_price} / #{ask_size } @ #{ask_price} "
	when 4
		"(Midpoint)  #{mid_point } "
	else
		""
	end +  @out_labels.zip(resolve_mask).join( "/" )
end