Sha256: 96275cca4330d091231bef037349498147bb81c512e3aff6019ceb7db8d1f24b

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 Bytes

Contents

module Alphavantage
  class Crypto
    include Validations

    FUNCTIONS = {
      health_index: 'CRYPTO_RATING',
      intraday: 'CRYPTO_INTRADAY',
      daily: 'DIGITAL_CURRENCY_DAILY',
      weekly: 'DIGITAL_CURRENCY_WEEKLY',
      monthly: 'DIGITAL_CURRENCY_MONTHLY'
    }

    def self.health_index(symbol:)
      Client.get(params: {
        function: self::FUNCTIONS[__method__],
        symbol: symbol
      }).crypto_rating_fcas
    end

    def initialize(symbol:,market:)
      @symbol = symbol
      @market = market
    end

    def intraday(interval: '5min')
      Client.get(params: {
        function: FUNCTIONS[__method__],
        symbol: @symbol,
        market: @market,
        interval: validate_interval(interval)
      })
    end

    def daily
      Client.get(params: {
        function: FUNCTIONS[__callee__],
        symbol: @symbol,
        market: @market
      })
    end
    alias :weekly :daily
    alias :monthly :daily

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alphavantage-1.2.0 lib/alphavantage/crypto.rb