class Vaultoro::BasicAPI::MarketData

Public Instance Methods

fetch() click to toggle source
# File lib/vaultoro/basic_api/market_data.rb, line 18
def fetch
  @errors.clear

  response = Client.get('/markets', {})
  code = response.code rescue ""

  case code
  when '200'
    hash = JSON.parse(response.body)
    @status = hash['status'].upcase

    if @status == 'SUCCESS'
      @market_currency = hash['data']['MarketCurrency']
      @base_currency = hash['data']['BaseCurrency']
      @market_currency_name = hash['data']['MarketCurrencyLong']
      @base_currency_name = hash['data']['BaseCurrencyLong']
      @min_trade_size = ("%f" % "#{hash['data']['MinTradeSize']}").to_f
      @market_name = hash['data']['MarketName']
      @is_active = hash['data']['IsActive']
      @min_unit_qty = hash['data']['MinUnitQty'].to_f
      @min_price = hash['data']['MinPrice'].to_f
      @last_price = hash['data']['LastPrice'].to_f
      @daily_low = hash['data']['24hLow'].to_f
      @daily_high = hash['data']['24hHigh'].to_f
      @daily_volume = hash['data']['24HVolume'].to_f
    else
      set_errors(response)
      return false
    end

    return true
  else
    set_errors(response)
    return false
  end
end