Class: StockPivot::EodQuote

Inherits:
Object
  • Object
show all
Defined in:
lib/stock_pivot/eod_quote.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ EodQuote

Returns a new instance of EodQuote.



6
7
8
9
10
11
12
13
14
# File 'lib/stock_pivot/eod_quote.rb', line 6

def initialize(args)
  @symbol = args.fetch(:symbol).upcase
  @trade_date = args.fetch(:trade_date)
  @open = args.fetch(:open, 0.0).to_d
  @high = args.fetch(:high, 0.0).to_d
  @low = args.fetch(:low, 0.0).to_d
  @close = args.fetch(:close, 0.0).to_d
  @volume = args.fetch(:volume, 0).to_i
end

Instance Attribute Details

#closeObject (readonly)

Returns the value of attribute close.



4
5
6
# File 'lib/stock_pivot/eod_quote.rb', line 4

def close
  @close
end

#highObject (readonly)

Returns the value of attribute high.



4
5
6
# File 'lib/stock_pivot/eod_quote.rb', line 4

def high
  @high
end

#lowObject (readonly)

Returns the value of attribute low.



4
5
6
# File 'lib/stock_pivot/eod_quote.rb', line 4

def low
  @low
end

#openObject (readonly)

Returns the value of attribute open.



4
5
6
# File 'lib/stock_pivot/eod_quote.rb', line 4

def open
  @open
end

#symbolObject (readonly)

Returns the value of attribute symbol.



4
5
6
# File 'lib/stock_pivot/eod_quote.rb', line 4

def symbol
  @symbol
end

#trade_dateObject (readonly)

Returns the value of attribute trade_date.



4
5
6
# File 'lib/stock_pivot/eod_quote.rb', line 4

def trade_date
  @trade_date
end

#volumeObject (readonly)

Returns the value of attribute volume.



4
5
6
# File 'lib/stock_pivot/eod_quote.rb', line 4

def volume
  @volume
end

Instance Method Details

#rangeObject



16
17
18
# File 'lib/stock_pivot/eod_quote.rb', line 16

def range
  @range ||= (@high - @low).round(2)
end