Class: IB::PortfolioValue
- Includes:
- BaseProperties
- Defined in:
- lib/models/ib/portfolio_value.rb
Instance Method Summary collapse
-
#==(other) ⇒ Object
Order comparison.
- #to_human ⇒ Object (also: #to_s)
Methods included from BaseProperties
#content_attributes, #default_attributes, #invariant_attributes, #set_attribute_defaults, #update_missing
Instance Method Details
#==(other) ⇒ Object
Order comparison
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/models/ib/portfolio_value.rb', line 19 def == other super(other) || other.is_a?(self.class) && market_price == other.market_price && average_cost == other.average_cost && position == other.position && unrealized_pnl == other.unrealized_pnl && realized_pnl == other.realized_pnl && contract == other.contract end |
#to_human ⇒ Object Also known as: to_s
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/models/ib/portfolio_value.rb', line 29 def to_human the_account = if account.present? if account.is_a?(String) account + " " else account.account+" " end else "" end "<PortfolioValue: "+ the_account + "Pos=#{ position.to_i } @ #{market_price.to_f.round(3)};" + "Value=#{market_value.to_f.round(2)};PNL=" + ( unrealized_pnl.to_i.zero? ? "": "#{unrealized_pnl} unrealized;") + ( realized_pnl.to_i.zero? ? "" : "#{realized_pnl} realized;>" ) + contract.to_human end |