Class: Cryptoexchange::Exchanges::Gdac::Services::Market

Inherits:
Services::Market show all
Defined in:
lib/cryptoexchange/exchanges/gdac/services/market.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Services::Market

#fetch_using_post

Class Method Details

.supports_individual_ticker_query?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/cryptoexchange/exchanges/gdac/services/market.rb', line 6

def supports_individual_ticker_query?
  false
end

Instance Method Details

#adapt(market_data) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cryptoexchange/exchanges/gdac/services/market.rb', line 28

def adapt(market_data)
  target, base = market_data['marketName'].split('-')
  ticker = Cryptoexchange::Models::Ticker.new
  ticker.base = base
  ticker.target = target
  ticker.market = Gdac::Market::NAME
  ticker.ask = NumericHelper.to_d(market_data['ask'])
  ticker.bid = NumericHelper.to_d(market_data['bid'])
  ticker.last = NumericHelper.to_d(market_data['last'])
  ticker.high = NumericHelper.to_d(market_data['high'])
  ticker.low = NumericHelper.to_d(market_data['low'])
  ticker.volume = NumericHelper.to_d(market_data['volume'])
  ticker.timestamp = nil
  ticker.payload = market_data
  ticker
end

#adapt_all(output) ⇒ Object



24
25
26
# File 'lib/cryptoexchange/exchanges/gdac/services/market.rb', line 24

def adapt_all(output)
  output['result'].map { |market_data| adapt(market_data) }
end

#fetchObject



11
12
13
14
15
16
17
18
# File 'lib/cryptoexchange/exchanges/gdac/services/market.rb', line 11

def fetch
  ctx = OpenSSL::SSL::SSLContext.new
  ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
  result = HTTP.get(ticker_url, ssl_context: ctx)
  output = JSON.parse(result)

  adapt_all(output)
end

#ticker_urlObject



20
21
22
# File 'lib/cryptoexchange/exchanges/gdac/services/market.rb', line 20

def ticker_url
  "#{Cryptoexchange::Exchanges::Gdac::Market::API_URL}/public/marketsummaries"
end