Class: IB::PercentChangeCondition

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

#default_attributes, make_from, #serialize_contract_by_con_id, verify_contract_if_necessary

Methods included from BaseProperties

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

Class Method Details

.fabricate(contract, operator, change) ⇒ Object

dsl: PercentChangeCondition.fabricate some_contract, “>=”, “5%”



218
219
220
221
222
223
# File 'lib/models/ib/condition.rb', line 218

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

.make(buffer) ⇒ Object



203
204
205
206
207
208
209
210
211
# File 'lib/models/ib/condition.rb', line 203

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

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

Instance Method Details

#condition_typeObject



199
200
201
# File 'lib/models/ib/condition.rb', line 199

def condition_type 
7
end

#serializeObject



213
214
215
216
# File 'lib/models/ib/condition.rb', line 213

def serialize
	super << self[:operator] << percent_change  << serialize_contract_by_con_id 

end