lib/utils.rb in SimBot-0.1.32 vs lib/utils.rb in SimBot-0.1.33

- old
+ new

@@ -4,10 +4,14 @@ # accept market paramter and return the coinmarket cap quote for said market # @param [String] market # @return [FalseClass and Float] def self.quote(market) case market + when 'btceth' + btceth_price + when 'tusdbtc' + 1 / btcusd_price when 'bchxrp' bchxrp_price when 'bchbtc' bchbtc_price when 'btcxrp' @@ -76,10 +80,16 @@ def self.btcltc_price response = RestClient.get('https://api.coinmarketcap.com/v2/ticker/1/?convert=LTC') hash = JSON.parse(response.body) hash['data']['quotes']['LTC']['price'].to_f.round(4) end - + # fetch btc/eth price from coin market cap + # @return [float] rate + def self.btceth_price + response = RestClient.get('https://api.coinmarketcap.com/v2/ticker/1/?convert=ETH') + hash = JSON.parse(response.body) + hash['data']['quotes']['ETH']['price'].to_f.round(4) + end # fetch bch/xrp price from coin market cap # @return [float] rate def self.bchxrp_price response = RestClient.get('https://api.coinmarketcap.com/v2/ticker/1831/?convert=XRP') hash = JSON.parse(response.body)