Class: IB::Bag

Inherits:
Object
  • Object
show all
Defined in:
lib/ib/models/bag.rb

Instance Method Summary collapse

Instance Method Details

#included_in?(account) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
# File 'lib/ib/models/bag.rb', line 3

def included_in? 
  # iterate over combo-legs 
  # and return the bag if all con_id's are present in the account.contracts-map
  self if combo_legs.map do |c_l|
    .locate_contract c_l.con_id
  end.count == combo_legs.count
end

#portfolio_value(account) ⇒ Object

returns an array of portfolio-values



13
14
15
16
17
# File 'lib/ib/models/bag.rb', line 13

def portfolio_value 
  combo_legs.map do | c_l |
    .portfolio_values.detect{|x| x.contract.con_id ==  c_l.con_id}
  end
end