Sha256: 4895f627f68b6907b4438e88b1fe5373f6d4a063ae1b2d44e224602fd09d8a52

Contents?: true

Size: 857 Bytes

Versions: 1

Compression:

Stored size: 857 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['type'] == 'ETF'
          EodModels::InstrumentType::ETF
        elsif fundamentals['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.22 lib/eod_services/instrument_type.rb