Class: Alphavantage::Crypto

Inherits:
Object
  • Object
show all
Includes:
Validations
Defined in:
lib/alphavantage/crypto.rb

Constant Summary collapse

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

Constants included from Validations

Validations::VALID_DATATYPES, Validations::VALID_INDICATOR_INTERVALS, Validations::VALID_INTERVALS, Validations::VALID_OUTPUTSIZES, Validations::VALID_SERIES_TYPES, Validations::VALID_SLICES

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol:, market:) ⇒ Crypto

Returns a new instance of Crypto.



20
21
22
23
# File 'lib/alphavantage/crypto.rb', line 20

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

Class Method Details

.health_index(symbol:) ⇒ Object



13
14
15
16
17
18
# File 'lib/alphavantage/crypto.rb', line 13

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

Instance Method Details

#dailyObject Also known as: weekly, monthly



34
35
36
37
38
39
40
# File 'lib/alphavantage/crypto.rb', line 34

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

#intraday(interval: '5min') ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/alphavantage/crypto.rb', line 25

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