class Cryptoexchange::Exchanges::Lykke::Services::Market

Public Class Methods

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

Public Instance Methods

adapt(ticker_output, market_pair) click to toggle source
# File lib/cryptoexchange/exchanges/lykke/services/market.rb, line 41
def adapt(ticker_output, market_pair)
ticker           = Cryptoexchange::Models::Ticker.new
ticker.base      = market_pair.base
ticker.target    = market_pair.target
ticker.market    = Lykke::Market::NAME
ticker.bid       = NumericHelper.to_d(ticker_output['bid'])
ticker.ask       = NumericHelper.to_d(ticker_output['ask'])
ticker.last      = NumericHelper.to_d(ticker_output['lastPrice'])
ticker.volume    = NumericHelper.divide(NumericHelper.to_d(ticker_output['volume24H']), ticker.last)
ticker.timestamp = nil
ticker.payload   = ticker_output
ticker
end
adapt_all(output, pairs_dictionary) click to toggle source
# File lib/cryptoexchange/exchanges/lykke/services/market.rb, line 26
def adapt_all(output, pairs_dictionary)
  output.map do |ticker|
    next unless pairs_dictionary.any?{|match| match["id"] == ticker["assetPair"]}
    pair_object = pairs_dictionary.select{|pair| pair["id"] == ticker["assetPair"]}
    base = pair_object[0]["baseAssetId"]
    target = pair_object[0]["quotingAssetId"]
    market_pair = Cryptoexchange::Models::MarketPair.new(
                    base: base,
                    target: target,
                    market: Lykke::Market::NAME
                  )
    adapt(ticker, market_pair)
  end.compact
end
dictionary_url() click to toggle source
# File lib/cryptoexchange/exchanges/lykke/services/market.rb, line 22
def dictionary_url
  "#{Cryptoexchange::Exchanges::Lykke::Market::API_URL}/AssetPairs/dictionary"
end
fetch() click to toggle source
Calls superclass method Cryptoexchange::Services::Market#fetch
# File lib/cryptoexchange/exchanges/lykke/services/market.rb, line 11
def fetch
  output = super(ticker_url)
  pairs_output = HTTP.get(dictionary_url)
  pairs_dictionary = JSON.parse(pairs_output.to_s)
  adapt_all(output, pairs_dictionary)
end
ticker_url() click to toggle source
# File lib/cryptoexchange/exchanges/lykke/services/market.rb, line 18
def ticker_url
  "#{Cryptoexchange::Exchanges::Lykke::Market::API_URL}/Market"
end