Class: StockMarkit::Quote

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/stock-markit/quote.rb

Overview

Stock Quote

Copyright

Copyright © 2016 Michael Heijmans

License

MIT

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol) ⇒ Quote

Returns a new instance of Quote.

Parameters:

  • symbol (String, Symbol)

    The stock’s ticker symbol



41
42
43
44
# File 'lib/stock-markit/quote.rb', line 41

def initialize(symbol)
  @symbol   = symbol.to_sym.upcase
  @options  = { query: {symbol: @symbol} }
end

Instance Attribute Details

#changeFloat (readonly)

The change in price of the company’s stock since the previous trading day’s close

Returns:

  • (Float)

    the current value of change



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def change
  @change
end

#change_percentFloat (readonly)

The change percent in price of the company’s stock since the previous trading day’s close

Returns:

  • (Float)

    the current value of change_percent



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def change_percent
  @change_percent
end

#change_percent_ytdFloat (readonly)

The change percent in price of the company’s stock since the start of the year

Returns:

  • (Float)

    the current value of change_percent_ytd



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def change_percent_ytd
  @change_percent_ytd
end

#change_ytdFloat (readonly)

The change in price of the company’s stock since the start of the year

Returns:

  • (Float)

    the current value of change_ytd



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def change_ytd
  @change_ytd
end

#highFloat (readonly)

The high price of the company’s stock in the trading session

Returns:

  • (Float)

    the current value of high



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def high
  @high
end

#last_priceFloat (readonly)

The last price of the company’s stock

Returns:

  • (Float)

    the current value of last_price



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def last_price
  @last_price
end

#lowFloat (readonly)

The low price of the company’s stock in the trading session

Returns:

  • (Float)

    the current value of low



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def low
  @low
end

#market_capInteger (readonly)

The company’s market cap

Returns:

  • (Integer)

    the current value of market_cap



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def market_cap
  @market_cap
end

#ms_dateFloat (readonly)

The last time the company’s stock was traded in exchange-local timezone. Represented as an OLE Automation date.

Returns:

  • (Float)

    the current value of ms_date



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def ms_date
  @ms_date
end

#nameString (readonly)

The company name

Returns:

  • (String)

    the current value of name



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def name
  @name
end

#openFloat (readonly)

The opening price of the company’s stock at the start of the trading session

Returns:

  • (Float)

    the current value of open



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def open
  @open
end

#statusString (readonly)

The status from the api call

Returns:

  • (String)

    the current value of status



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def status
  @status
end

#symbolString, Symbol (readonly)

The ticker symbol of the company

Returns:

  • (String, Symbol)

    the current value of symbol



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def symbol
  @symbol
end

#timestampTime (readonly)

The last time the company’s stock was traded

Returns:

  • (Time)

    the current value of timestamp



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def timestamp
  @timestamp
end

#volumeInteger (readonly)

The trade volume of the company’s stock

Returns:

  • (Integer)

    the current value of volume



30
31
32
# File 'lib/stock-markit/quote.rb', line 30

def volume
  @volume
end

Instance Method Details

#fetchself, False

Returns:

  • (self)

    on successful api call

  • (False)

    on failed api call - check #message for failure message

See Also:



49
50
51
# File 'lib/stock-markit/quote.rb', line 49

def fetch
  update
end

#updateself, False

Returns:

  • (self)

    on successful api call

  • (False)

    on failed api call - check #message for failure message

See Also:



56
57
58
# File 'lib/stock-markit/quote.rb', line 56

def update
  lookup_with_api
end