Sha256: 59c627e77bc2627ae8380d089b929f16a8f3ba01470e58a038f9e1c55fecf5a2

Contents?: true

Size: 879 Bytes

Versions: 4

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

4 entries across 4 versions & 1 rubygems

Version Path
sensei_eod_utils-0.0.27 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.26 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.25 lib/eod_services/instrument_type.rb
sensei_eod_utils-0.0.24 lib/eod_services/instrument_type.rb