Module: CoingeckoRuby::Client::Prices
- Included in:
- CoingeckoRuby::Client
- Defined in:
- lib/coingecko_ruby/client/prices.rb
Instance Method Summary collapse
-
#daily_historical_price(id, currency: 'usd', days: 7, **options) ⇒ Hash
Fetches a coin’s historical price data in daily ranges.
-
#exchange_rate(from:, to: 'usd') ⇒ Hash
Fetches the exchange rate for a coin or currency in the given coin or currency.
-
#get_daily_historical_prices(id:, days:, currency: 'usd') ⇒ Object
deprecated
Deprecated.
Use #daily_historical_price instead
-
#get_exchange_rate(from:, to: 'usd') ⇒ Object
deprecated
Deprecated.
Use #exchange_rate instead
-
#get_historical_price_on_date(id:, date:) ⇒ Object
deprecated
Deprecated.
Use #historical_price instead
-
#get_hourly_historical_prices(id:, days:, currency: 'usd') ⇒ Object
deprecated
Deprecated.
Use #hourly_historical_price instead
-
#get_minutely_historical_prices(id:, currency: 'usd') ⇒ Object
deprecated
Deprecated.
Use #minutely_historical_price instead
-
#get_ohlc(id:, days:, currency: 'usd') ⇒ Object
deprecated
Deprecated.
Use #ohlc instead
- #get_price(id:, currency: 'usd', options: {}) ⇒ Object deprecated Deprecated.
-
#historical_price(id, date:, **options) ⇒ Hash
Fetches historical price data for a coin at a given date.
-
#hourly_historical_price(id, currency: 'usd', days: 7, **options) ⇒ Hash
Fetches a coin’s historical price data in 1 hour ranges.
-
#minutely_historical_price(id, currency: 'usd', **options) ⇒ Hash
Fetches a coin’s historical price data in 5 - 10 minutes ranges.
-
#ohlc(id, currency: 'usd', days: 7, **options) ⇒ Array<Array<String, Float>>
Fetches a coin’s open, high, low, and close (OHLC) data within the number of days given.
-
#price(ids, currency: 'usd', **options) ⇒ Hash
Fetches the current price for a coin in the given coin or currency.
- #prices(ids, currency: 'usd', **options) ⇒ Object
-
#supported_currencies ⇒ Array<String>
Fetches the list of currencies currently supported by CoinGecko’s API.
Instance Method Details
#daily_historical_price(id, currency: 'usd', days: 7, **options) ⇒ Hash
Fetches a coin’s historical price data in daily ranges.
231 232 233 |
# File 'lib/coingecko_ruby/client/prices.rb', line 231 def daily_historical_price(id, currency: 'usd', days: 7, **) get "coins/#{id}/market_chart", vs_currency: currency, days: days, interval: 'daily', ** end |
#exchange_rate(from:, to: 'usd') ⇒ Hash
Fetches the exchange rate for a coin or currency in the given coin or currency.
309 310 311 |
# File 'lib/coingecko_ruby/client/prices.rb', line 309 def exchange_rate(from:, to: 'usd') price(from, currency: to) end |
#get_daily_historical_prices(id:, days:, currency: 'usd') ⇒ Object
Use #daily_historical_price instead
236 237 238 |
# File 'lib/coingecko_ruby/client/prices.rb', line 236 def get_daily_historical_prices(id:, days:, currency: 'usd') daily_historical_price(id, currency: currency, days: days) end |
#get_exchange_rate(from:, to: 'usd') ⇒ Object
Use #exchange_rate instead
314 315 316 |
# File 'lib/coingecko_ruby/client/prices.rb', line 314 def get_exchange_rate(from:, to: 'usd') exchange_rate(from: from, to: to) end |
#get_historical_price_on_date(id:, date:) ⇒ Object
Use #historical_price instead
129 130 131 |
# File 'lib/coingecko_ruby/client/prices.rb', line 129 def get_historical_price_on_date(id:, date:) historical_price(id, date: date) end |
#get_hourly_historical_prices(id:, days:, currency: 'usd') ⇒ Object
Use #hourly_historical_price instead
202 203 204 |
# File 'lib/coingecko_ruby/client/prices.rb', line 202 def get_hourly_historical_prices(id:, days:, currency: 'usd') hourly_historical_price(id, currency: currency, days: days) end |
#get_minutely_historical_prices(id:, currency: 'usd') ⇒ Object
Use #minutely_historical_price instead
165 166 167 |
# File 'lib/coingecko_ruby/client/prices.rb', line 165 def get_minutely_historical_prices(id:, currency: 'usd') minutely_historical_price(id, currency: currency) end |
#get_ohlc(id:, days:, currency: 'usd') ⇒ Object
Use #ohlc instead
263 264 265 |
# File 'lib/coingecko_ruby/client/prices.rb', line 263 def get_ohlc(id:, days:, currency: 'usd') ohlc(id, currency: currency, days: days) end |
#get_price(id:, currency: 'usd', options: {}) ⇒ Object
46 47 48 |
# File 'lib/coingecko_ruby/client/prices.rb', line 46 def get_price(id:, currency: 'usd', options: {}) price(id, currency, **) end |
#historical_price(id, date:, **options) ⇒ Hash
Fetches historical price data for a coin at a given date.
122 123 124 125 126 |
# File 'lib/coingecko_ruby/client/prices.rb', line 122 def historical_price(id, date:, **) date = Time.now.strftime('%d-%m-%Y') if date.nil? get "coins/#{id}/history", date: date, ** end |
#hourly_historical_price(id, currency: 'usd', days: 7, **options) ⇒ Hash
Hourly historical data is only available within the last 90 days.
Fetches a coin’s historical price data in 1 hour ranges.
195 196 197 198 199 |
# File 'lib/coingecko_ruby/client/prices.rb', line 195 def hourly_historical_price(id, currency: 'usd', days: 7, **) return daily_historical_price(id, currrency: currency, days: days) if days > 90 get "coins/#{id}/market_chart", vs_currency: currency, days: days, ** end |
#minutely_historical_price(id, currency: 'usd', **options) ⇒ Hash
Minutely historical data is only available within the last 24 hours.
Fetches a coin’s historical price data in 5 - 10 minutes ranges.
160 161 162 |
# File 'lib/coingecko_ruby/client/prices.rb', line 160 def minutely_historical_price(id, currency: 'usd', **) get "coins/#{id}/market_chart", vs_currency: currency, days: 1, ** end |
#ohlc(id, currency: 'usd', days: 7, **options) ⇒ Array<Array<String, Float>>
Fetches a coin’s open, high, low, and close (OHLC) data within the number of days given.
258 259 260 |
# File 'lib/coingecko_ruby/client/prices.rb', line 258 def ohlc(id, currency: 'usd', days: 7, **) get "coins/#{id}/ohlc", vs_currency: currency, days: days, ** end |
#price(ids, currency: 'usd', **options) ⇒ Hash
Fetches the current price for a coin in the given coin or currency.
34 35 36 37 38 |
# File 'lib/coingecko_ruby/client/prices.rb', line 34 def price(ids, currency: 'usd', **) ids = ids.join(',') if ids.is_a? Array currency = currency.join(',') if currency.is_a? Array get 'simple/price', ids: ids, vs_currencies: currency, ** end |
#prices(ids, currency: 'usd', **options) ⇒ Object
41 42 43 |
# File 'lib/coingecko_ruby/client/prices.rb', line 41 def prices(ids, currency: 'usd', **) price(ids, currency: currency, **) end |
#supported_currencies ⇒ Array<String>
Fetches the list of currencies currently supported by CoinGecko’s API.
283 284 285 |
# File 'lib/coingecko_ruby/client/prices.rb', line 283 def supported_currencies get 'simple/supported_vs_currencies' end |