Module: IB::SpreadPrototype
- Defined in:
- lib/ib/spread-prototypes.rb
Instance Method Summary collapse
- #build(from:, **fields) ⇒ Object
- #defaults ⇒ Object
- #initialize_spread(ref_contract = nil, **attributes) {|the_spread| ... } ⇒ Object
- #optional ⇒ Object
- #parameters ⇒ Object
- #requirements ⇒ Object
Instance Method Details
#build(from:, **fields) ⇒ Object
20 21 22 |
# File 'lib/ib/spread-prototypes.rb', line 20 def build from: , **fields end |
#defaults ⇒ Object
40 41 42 |
# File 'lib/ib/spread-prototypes.rb', line 40 def defaults {} end |
#initialize_spread(ref_contract = nil, **attributes) {|the_spread| ... } ⇒ Object
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 |
#optional ⇒ Object
44 45 46 |
# File 'lib/ib/spread-prototypes.rb', line 44 def optional { } end |
#parameters ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/ib/spread-prototypes.rb', line 48 def parameters the_output = ->(var){ var.empty? ? "none" : var.map{|x| x.join(" --> ") }.join("\n\t: ")} "Required : " + the_output[requirements] + "\n --------------- \n" + "Optional : " + the_output[optional] + "\n --------------- \n" end |
#requirements ⇒ Object
36 37 38 |
# File 'lib/ib/spread-prototypes.rb', line 36 def requirements {} end |