Class: MyTradeWizard::Stock
- Inherits:
-
Object
- Object
- MyTradeWizard::Stock
- Defined in:
- lib/mytradewizard/stock.rb
Instance Attribute Summary collapse
-
#contract ⇒ Object
readonly
Returns the value of attribute contract.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(symbol) ⇒ Stock
constructor
A new instance of Stock.
- #price ⇒ Object
Constructor Details
#initialize(symbol) ⇒ Stock
Returns a new instance of Stock.
9 10 11 12 |
# File 'lib/mytradewizard/stock.rb', line 9 def initialize(symbol) @symbol = symbol @contract = IB::Contract.new(:sec_type => :stock, :symbol => symbol, :currency => "USD") end |
Instance Attribute Details
#contract ⇒ Object (readonly)
Returns the value of attribute contract.
7 8 9 |
# File 'lib/mytradewizard/stock.rb', line 7 def contract @contract end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
6 7 8 |
# File 'lib/mytradewizard/stock.rb', line 6 def symbol @symbol end |
Instance Method Details
#==(other) ⇒ Object
14 15 16 |
# File 'lib/mytradewizard/stock.rb', line 14 def ==(other) other.class == self.class && other.symbol == symbol end |
#price ⇒ Object
18 19 20 |
# File 'lib/mytradewizard/stock.rb', line 18 def price MyTradeWizard::Yahoo.OHLC(symbol, 1).most_recent.close end |