Sha256: d79fde4fc79faaa12917c324b754000e1a01048e62f5e58693fe07171458163e

Contents?: true

Size: 702 Bytes

Versions: 8

Compression:

Stored size: 702 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

        data = make_request(url_path(underlying), params(expiry))
        Oj.load(data)
      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

8 entries across 8 versions & 1 rubygems

Version Path
sensei_eod_utils-0.0.7 lib/eod_facade/options.rb
sensei_eod_utils-0.0.6 lib/eod_facade/options.rb
sensei_eod_utils-0.0.5 lib/eod_facade/options.rb
sensei_eod_utils-0.0.4 lib/eod_facade/options.rb
sensei_eod_utils-0.0.3 lib/eod_facade/options.rb
sensei_eod_utils-0.0.2 lib/eod_facade/options.rb
sensei_eod_utils-0.0.1 lib/eod_facade/options.rb
sensei_eod_utils-0.0.0 lib/eod_facade/options.rb