Sha256: d714e702bc3d6f78ef59ba501251a11f4a742b906130452505445f0cd7907c26
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
module Alphavantage class Forex include Validations FUNCTIONS = { exchange_rates: 'CURRENCY_EXCHANGE_RATE', intraday: 'FX_INTRADAY', daily: 'FX_DAILY', weekly: 'FX_WEEKLY', monthly: 'FX_MONTHLY' } def initialize(from_symbol:,to_symbol:) @from_symbol = from_symbol @to_symbol = to_symbol end def exchange_rates Client.get(params: { function: FUNCTIONS[__method__], from_currency: @from_symbol, to_currency: @to_symbol }).realtime_currency_exchange_rate end def intraday(interval: '5min', outputsize: 'compact') Client.get(params: { function: FUNCTIONS[__method__], from_symbol: @from_symbol, to_symbol: @to_symbol, interval: validate_interval(interval), outputsize: validate_outputsize(outputsize) }) end def daily(outputsize: 'compact') Client.get(params: { function: FUNCTIONS[__method__], from_symbol: @from_symbol, to_symbol: @to_symbol, outputsize: validate_outputsize(outputsize) }) end def weekly Client.get(params: { function: FUNCTIONS[__callee__], from_symbol: @from_symbol, to_symbol: @to_symbol }) end alias :monthly :weekly end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
alphavantage-1.1.0 | lib/alphavantage/forex.rb |
alphavantage-1.0.2 | lib/alphavantage/forex.rb |
alphavantage-1.0.1 | lib/alphavantage/forex.rb |