Class: IB::Bag
- Inherits:
-
Object
- Object
- IB::Bag
- Defined in:
- lib/ib/models/bag.rb
Instance Method Summary collapse
- #included_in?(account) ⇒ Boolean
-
#portfolio_value(account) ⇒ Object
returns an array of portfolio-values.
Instance Method Details
#included_in?(account) ⇒ Boolean
3 4 5 6 7 8 9 |
# File 'lib/ib/models/bag.rb', line 3 def included_in? account # 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| account.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 account combo_legs.map do | c_l | account.portfolio_values.detect{|x| x.contract.con_id == c_l.con_id} end end |