Sha256: ec645d85c87455f4e0fe19154ad4553e8c1fd0267782c900415db6dbe656e83b

Contents?: true

Size: 811 Bytes

Versions: 3

Compression:

Stored size: 811 Bytes

Contents

module Alphavantage
  class Fundamental
    FUNCTIONS = { 
      overview: 'OVERVIEW',
      earnings: 'EARNINGS',
      income_statement: 'INCOME_STATEMENT',
      balance_sheet: 'BALANCE_SHEET',
      cash_flow: 'CASH_FLOW'
    }

    def initialize(symbol:)
      @symbol = symbol
    end

    def overview
      response(FUNCTIONS[__method__])
    end

    def earnings
      response(FUNCTIONS[__method__]).annual_earnings
    end

    def income_statement
      response(FUNCTIONS[__method__]).annual_reports
    end

    def balance_sheet
      response(FUNCTIONS[__method__]).annual_reports
    end

    def cash_flow
      response(FUNCTIONS[__method__]).annual_reports
    end

    private

    def response(function)
      Client.get(params: { function: function, symbol: @symbol })
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alphavantage-1.1.0 lib/alphavantage/fundamental.rb
alphavantage-1.0.2 lib/alphavantage/fundamental.rb
alphavantage-1.0.1 lib/alphavantage/fundamental.rb