Sha256: 7a2b5fd596b34aafa1255936874e7db2c66e273450a015cf72ae1c23dbc3abaf

Contents?: true

Size: 968 Bytes

Versions: 3

Compression:

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

3 entries across 3 versions & 1 rubygems

Version Path
alphavantage-1.1.0 lib/alphavantage/crypto.rb
alphavantage-1.0.2 lib/alphavantage/crypto.rb
alphavantage-1.0.1 lib/alphavantage/crypto.rb