Sha256: 5dc424e4fb9ad796ba29dcf86589830cb4679dcdb79318b9fc2482e42a220abc

Contents?: true

Size: 673 Bytes

Versions: 3

Compression:

Stored size: 673 Bytes

Contents

# frozen_string_literal: true

require 'oj'

module EodFacade
  class Options < ::EodFacade::Base
    class << self
      def call(symbol)
        underlying = EodServices::Contract.underlying_symbol(symbol)
        expiry = EodServices::Contract.contract_expiry(symbol)

        unless expiry
          raise ArgumentError, "Invalid expiration date for option #{symbol}"
        end

        make_request(url_path(underlying), params(expiry))
      end

      private

      def params(expiry)
        {
          from: expiry.to_s,
          to: expiry.to_s
        }
      end

      def url_path(underlying)
        "/options/#{underlying}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sensei_eod_utils-0.0.10 lib/eod_facade/options.rb
sensei_eod_utils-0.0.9 lib/eod_facade/options.rb
sensei_eod_utils-0.0.8 lib/eod_facade/options.rb