Sha256: 63e23c62505802a02563917e7c0d815a77dc2df48fb45573bea07499cd9ceeb3

Contents?: true

Size: 964 Bytes

Versions: 25

Compression:

Stored size: 964 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
        !!EodFacade::Options.call(symbol)
      rescue ArgumentError
        false
      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

25 entries across 25 versions & 1 rubygems

Version Path
sensei_eod_utils-0.0.52 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.51 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.50 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.49 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.48 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.47 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.46 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.45 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.44 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.43 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.42 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.41 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.40 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.39 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.38 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.37 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.36 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.35 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.34 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.33 lib/eod_services/instrument_type.rb