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


38
39
40
41
# File 'lib/stock-markit/quote.rb', line 38

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


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

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


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

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


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

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


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

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


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

def high
  @high
end

#last_priceFloat (readonly)

The last price of the company's stock

Returns:

  • (Float)

    the current value of last_price


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

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


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

def low
  @low
end

#market_capInteger (readonly)

The company's market cap

Returns:

  • (Integer)

    the current value of market_cap


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

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


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

def ms_date
  @ms_date
end

#nameString (readonly)

The company name

Returns:

  • (String)

    the current value of name


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

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


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

def open
  @open
end

#statusString (readonly)

The status from the api call

Returns:

  • (String)

    the current value of status


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

def status
  @status
end

#symbolString, Symbol (readonly)

The ticker symbol of the company

Returns:

  • (String, Symbol)

    the current value of symbol


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

def symbol
  @symbol
end

#timestampTime (readonly)

The last time the company's stock was traded

Returns:

  • (Time)

    the current value of timestamp


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

def timestamp
  @timestamp
end

#volumeInteger (readonly)

The trade volume of the company's stock

Returns:

  • (Integer)

    the current value of volume


27
28
29
# File 'lib/stock-markit/quote.rb', line 27

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:


46
47
48
# File 'lib/stock-markit/quote.rb', line 46

def fetch
  update
end

#updateself, False

Returns:

  • (self)

    on successful api call

  • (False)

    on failed api call - check #message for failure message

See Also:


53
54
55
# File 'lib/stock-markit/quote.rb', line 53

def update
  lookup_with_api
end