Sha256: 083a9f10003e93b754c2551d4c69a33891e895d6bcb4785b7a9b4d0eb52bf27b

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

# frozen_string_literal: true

module EodServices
  class InstrumentType
    class <<self
      def etf?(symbol)
        call(symbol) == EodModels::InstrumentType::ETF
      end

      def stock?(symbol)
        call(symbol) == EodModels::InstrumentType::STOCK
      end

      def option?(symbol)
        call(symbol) == EodModels::InstrumentType::OPTION
      end

      private

      def call(symbol)
        fundamentals = EodFacade::Fundamentals.call(symbol)

        if fundamentals['General']['Type'] == 'ETF'
          EodModels::InstrumentType::ETF
        elsif fundamentals['General']['Type'] == 'Common Stock'
          EodModels::InstrumentType::Stock
        elsif EodFacade::Options.call(symbol)
          EodModels::InstrumentType::Option
        else
          raise ArgumentError, "Invalid intrument type for #{symbol}"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sensei_eod_utils-0.0.23 lib/eod_services/instrument_type.rb