Class: Vaultoro::BasicAPI::MarketData

Inherits:
Vaultoro::Base show all
Defined in:
lib/vaultoro/basic_api/market_data.rb

Instance Method Summary collapse

Methods inherited from Vaultoro::Base

#inspect

Instance Method Details

#fetchObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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