# class YahooFinance::HistoricalQuote

'Historical' quote retrieval.

'Historical' quote retrieval.

'Historical' quote retrieval.

### Attributes

adjClose[RW]
close[RW]
date[RW]
high[RW]
low[RW]
open[RW]
recno[RW]
symbol[RW]
volume[RW]

### Public Class Methods

new( sym, valarray=nil, &block ) click to toggle source

    # File lib/assets/yfinadaptor/yfinadaptor.rb, line 373
    def initialize( sym, valarray=nil, &block )
      @symbol = sym.upcase
      if valarray

        @date = HistoricalQuote.parse_date( valarray[0] )
        @open = valarray[1].to_f
        @high = valarray[2].to_f
        @low = valarray[3].to_f
        @close = valarray[4].to_f
        @volume = valarray[5].to_i
        @adjClose = valarray[6].to_f
        @recno = valarray[7].to_i if valarray.size >= 8
      end
      if block_given?
        instance_eval( &block )
      end
    end

parse_date( date ) click to toggle source

This method is obsolete since the Yahoo format change. However, I am leaving it here for API stability.

    # File lib/assets/yfinadaptor/yfinadaptor.rb, line 398
        def HistoricalQuote.parse_date( date )
          # Yahoo changed the format of the date column. It is now in the
          # same format as this method returned, so this method just
          # returns the same date.
          return date
    #       md = @@date_re.match( date )
    #       if md
    #         if md[3].to_i > 30
    #           year = "19#{md[3]}"
    #         else
    #           year = "20#{md[3]}"
    #         end
    #         return "#{year}-%02d-%02d" % [(@@months.index(md[2]) + 1), md[1].to_i]
    #       else
    #         return date
    #       end
        end

parse_date_to_Date( date ) click to toggle source

    # File lib/assets/yfinadaptor/yfinadaptor.rb, line 416
    def HistoricalQuote.parse_date_to_Date( date )
      return Date.parse( parse_date( date ) )
    end

### Public Instance Methods

date_to_Date() click to toggle source

    # File lib/assets/yfinadaptor/yfinadaptor.rb, line 429
    def date_to_Date
      return Date.parse( @date )
    end

to_a() click to toggle source

    # File lib/assets/yfinadaptor/yfinadaptor.rb, line 424
    def to_a
      return [] << symbol << date << open << high <<
        low << close << volume << adjClose
    end

to_s() click to toggle source

    # File lib/assets/yfinadaptor/yfinadaptor.rb, line 420
    def to_s
      return "#{symbol},#{date},#{open},#{high},#{low},#{close},#{volume},#{adjClose}"
    end