Class: MyTradeWizard::Stock

Inherits:
Object
  • Object
show all
Defined in:
lib/mytradewizard/stock.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contractObject (readonly)

Returns the value of attribute contract.



7
8
9
# File 'lib/mytradewizard/stock.rb', line 7

def contract
  @contract
end

#symbolObject (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

#priceObject



18
19
20
# File 'lib/mytradewizard/stock.rb', line 18

def price
  MyTradeWizard::Yahoo.OHLC(symbol, 1).most_recent.close
end