Method: IB::SpreadPrototype#initialize_spread

Defined in:
lib/ib/spread-prototypes.rb

#initialize_spread(ref_contract = nil, **attributes) {|the_spread| ... } ⇒ Object

Yields:

  • (the_spread)


25
26
27
28
29
30
31
32
33
34
# File 'lib/ib/spread-prototypes.rb', line 25

def initialize_spread ref_contract = nil, **attributes
	error "Initializing of Spread failed – contract is missing" unless ref_contract.is_a?(IB::Contract)
    # make sure that :exchange, :symbol and :currency are present
	the_contract =  ref_contract.merge( **attributes ).verify.first
	error "Underlying for Spread is not valid: #{ref_contract.to_human}" if the_contract.nil?
	the_spread= IB::Spread.new  the_contract.attributes.slice( :exchange, :symbol, :currency )
	error "Initializing of Spread failed – Underling is no Contract" if the_spread.nil?
	yield the_spread if block_given?  # yield outside mutex controlled verify-environment
	the_spread  # return_value
end