Class: IB::VolumeCondition

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, volume) ⇒ Object

dsl: VolumeCondition.fabricate some_contract, “>=”, 50000



187
188
189
190
191
192
# File 'lib/models/ib/condition.rb', line 187

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

.make(buffer) ⇒ Object



171
172
173
174
175
176
177
178
179
# File 'lib/models/ib/condition.rb', line 171

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

	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



167
168
169
# File 'lib/models/ib/condition.rb', line 167

def condition_type 
6
end

#serializeObject



181
182
183
184
# File 'lib/models/ib/condition.rb', line 181

def serialize

	super << self[:operator] << volume <<  serialize_contract_by.con_id 
end