Class: IB::OrderCondition

Inherits:
Model show all
Includes:
BaseProperties
Defined in:
lib/models/ib/condition.rb,
lib/models/ib/condition.rb

Constant Summary collapse

Subclasses =

subclasses representing specialized condition types.

Hash.new(OrderCondition)

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BaseProperties

#==, #as_table, #content_attributes, #invariant_attributes, #set_attribute_defaults, #table_header, #table_row, #to_human, #update_missing

Class Method Details

.make_from(buffer) ⇒ Object

This builds an appropriate subclass based on its type



240
241
242
243
# File 'lib/models/ib/condition.rb', line 240

def self.make_from  buffer
	condition_type = buffer.read_int
	OrderCondition::Subclasses[condition_type].make( buffer )
end

.verify_contract_if_necessary(c) ⇒ Object



10
11
12
# File 'lib/models/ib/condition.rb', line 10

def self.verify_contract_if_necessary c
	 c.con_id.to_i.zero? ||( c.primary_exchange.blank? && c.exchange.blank?) ? c.verify! : c 
end

Instance Method Details

#condition_typeObject



13
14
15
# File 'lib/models/ib/condition.rb', line 13

def condition_type
	error "condition_type method is abstract"
end

#default_attributesObject



16
17
18
# File 'lib/models/ib/condition.rb', line 16

def  default_attributes
	 super.merge(  operator: ">=" , conjunction_connection: :and )
end

#serializeObject



24
25
26
# File 'lib/models/ib/condition.rb', line 24

def serialize
	[ condition_type,  self[:conjunction_connection] ]
end

#serialize_contract_by_con_idObject



20
21
22
# File 'lib/models/ib/condition.rb', line 20

def serialize_contract_by_con_id
	[ contract.con_id , contract.primary_exchange.presence || contract.exchange ]
end