class Cryptoexchange::Exchanges::C2cx::Services::Market

Public Class Methods

supports_individual_ticker_query?() click to toggle source
# File lib/cryptoexchange/exchanges/c2cx/services/market.rb, line 6
def supports_individual_ticker_query?
  true
end

Public Instance Methods

adapt(response, market_pair) click to toggle source
# File lib/cryptoexchange/exchanges/c2cx/services/market.rb, line 22
def adapt(response, market_pair)
  data             = response['data']
  ticker           = Cryptoexchange::Models::Ticker.new
  ticker.base      = market_pair.base
  ticker.target    = market_pair.target
  ticker.market    = C2cx::Market::NAME
  ticker.low       = NumericHelper.to_d(data['low'])
  ticker.high      = NumericHelper.to_d(data['high'])
  ticker.last      = NumericHelper.to_d(data['last'])
  ticker.bid       = NumericHelper.to_d(data['buy'])
  ticker.ask       = NumericHelper.to_d(data['sell'])         
  ticker.volume    = NumericHelper.to_d(data['volume'])
  ticker.timestamp = data['timestamp'].to_i
  ticker.payload   = data
  ticker
end
fetch(market_pair) click to toggle source
Calls superclass method Cryptoexchange::Services::Market#fetch
# File lib/cryptoexchange/exchanges/c2cx/services/market.rb, line 11
def fetch(market_pair)
  response = super(ticker_url(market_pair))
  adapt(response, market_pair)
end
ticker_url(market_pair) click to toggle source
# File lib/cryptoexchange/exchanges/c2cx/services/market.rb, line 16
def ticker_url(market_pair)
  base   = market_pair.base.upcase
  target = market_pair.target.upcase
  "#{Cryptoexchange::Exchanges::C2cx::Market::API_URL}/ticker/?symbol=#{target}_#{base}"
end