lib/utils.rb in SimBot-0.1.37 vs lib/utils.rb in SimBot-0.1.38

- old
+ new

@@ -6,16 +6,18 @@ # @return [FalseClass and Float] def self.quote(market) case market when 'bchxrp' bchxrp_price - when 'xrpzar' - xrpusd_price*14 when 'tusdzar' - bchxrp_price + tusdzar_price + when 'xrpzar' + xrpusd_price*tusdzar_price + when 'ethzar' + ethusd_price*tusdzar_price when 'btczar' - btcusd_price*14 + btcusd_price*tusdzar_price when 'bchbtc' bchbtc_price when 'btcxrp' btcxrp_price when 'eoseth' @@ -34,9 +36,18 @@ 1/bchbtc_price else false end end + + # fetch btc/usd price from coin market cap + # @return [float] rate + def self.tusdzar_price + response = RestClient.get('https://free.currencyconverterapi.com/api/v6/convert?q=USD_ZAR') + hash = JSON.parse(response.body) + hash['results']['USD_ZAR']['val'].to_f.round(4) + end + # fetch btc/usd price from coin market cap # @return [float] rate def self.xrpusd_price response = RestClient.get('https://api.coinmarketcap.com/v2/ticker/52/?convert=USD')