class Cryptoexchange::Exchanges::Ccex::Services::Market
Public Class Methods
supports_individual_ticker_query?()
click to toggle source
# File lib/cryptoexchange/exchanges/ccex/services/market.rb, line 6 def supports_individual_ticker_query? true end
Public Instance Methods
adapt(ticker_output, volumes_output, market_pair)
click to toggle source
# File lib/cryptoexchange/exchanges/ccex/services/market.rb, line 27 def adapt(ticker_output, volumes_output, market_pair) market = ticker_output['ticker'] volume = HashHelper.dig(volumes_output, 'ticker', market_pair.base.downcase, 'vol') ticker = Cryptoexchange::Models::Ticker.new ticker.base = market_pair.base ticker.target = market_pair.target ticker.market = Ccex::Market::NAME ticker.last = NumericHelper.to_d(market['lastprice']) ticker.bid = NumericHelper.to_d(market['lastbuy']) ticker.ask = NumericHelper.to_d(market['lastsell']) ticker.high = NumericHelper.to_d(market['high']) ticker.low = NumericHelper.to_d(market['low']) ticker.volume = volume ? NumericHelper.to_d(volume)/ticker.last : 0 ticker.timestamp = NumericHelper.to_d(market['updated']) ticker.payload = market ticker end
fetch(market_pair)
click to toggle source
Calls superclass method
Cryptoexchange::Services::Market#fetch
# File lib/cryptoexchange/exchanges/ccex/services/market.rb, line 11 def fetch(market_pair) ticker_output = super(ticker_url(market_pair)) volume_output = super(volume_url(market_pair)) adapt(ticker_output, volume_output, market_pair) end
ticker_url(market_pair)
click to toggle source
# File lib/cryptoexchange/exchanges/ccex/services/market.rb, line 17 def ticker_url(market_pair) name = "#{market_pair.base}-#{market_pair.target}".downcase "#{Cryptoexchange::Exchanges::Ccex::Market::API_URL}/#{name}.json" end
volume_url(market_pair)
click to toggle source
# File lib/cryptoexchange/exchanges/ccex/services/market.rb, line 22 def volume_url(market_pair) target = market_pair.target.downcase "#{Cryptoexchange::Exchanges::Ccex::Market::API_URL}/volume_#{target}.json" end