Class: IB::PriceCondition

Inherits:
OrderCondition show all
Defined in:
lib/models/ib/condition.rb

Constant Summary

Constants inherited from OrderCondition

OrderCondition::Subclasses

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OrderCondition

make_from, #serialize_contract_by_con_id, verify_contract_if_necessary

Methods included from BaseProperties

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

Class Method Details

.fabricate(contract, operator, price) ⇒ Object

dsl: PriceCondition.fabricate some_contract, “>=”, 500



61
62
63
64
65
66
# File 'lib/models/ib/condition.rb', line 61

def self.fabricate contract, operator, price
	error "Condition Operator has to be \">=\" or \"<=\" " unless ["<=", ">="].include? operator 
	self.new	operator: operator,
						price: price.to_i,
						contract: verify_contract_if_necessary( contract )
end

.make(buffer) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/models/ib/condition.rb', line 44

def self.make  buffer
	 m= self.new  conjunction_connection:  buffer.read_string,
		operator: buffer.read_int,
		price: buffer.read_decimal

		the_contract = IB::Contract.new con_id: buffer.read_int, exchange: buffer.read_string
		m.contract = the_contract
		m.trigger_method = buffer.read_int
		m

end

Instance Method Details

#condition_typeObject



40
41
42
# File 'lib/models/ib/condition.rb', line 40

def condition_type 
1
end

#default_attributesObject



36
37
38
# File 'lib/models/ib/condition.rb', line 36

def default_attributes 
	super.merge( :trigger_method => :default  )
end

#serializeObject



56
57
58
# File 'lib/models/ib/condition.rb', line 56

def serialize
super << self[:operator] << price << serialize_contract_by_con_id <<  self[:trigger_method] 
end