class Cryptoexchange::Exchanges::Dragonex::Services::OrderBook

Public Class Methods

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

Public Instance Methods

adapt(asks, bids, market_pair) click to toggle source
# File lib/cryptoexchange/exchanges/dragonex/services/order_book.rb, line 27
def adapt(asks, bids, market_pair)
  order_book = Cryptoexchange::Models::OrderBook.new

  order_book.base      = market_pair.base
  order_book.target    = market_pair.target
  order_book.market    = Dragonex::Market::NAME
  order_book.asks      = adapt_orders(asks['data'])
  order_book.bids      = adapt_orders(bids['data'])
  order_book.payload   = [asks, bids]
  order_book
end
adapt_orders(orders) click to toggle source
# File lib/cryptoexchange/exchanges/dragonex/services/order_book.rb, line 39
def adapt_orders(orders)
  orders.collect do |order_entry|
    price  = order_entry['price']
    amount = order_entry['volume']
    Cryptoexchange::Models::Order.new(price:  price,
                                      amount: amount)
  end
end
asks_url(market_pair) click to toggle source
# File lib/cryptoexchange/exchanges/dragonex/services/order_book.rb, line 17
def asks_url(market_pair)
  id = market_pair.inst_id
  "#{Cryptoexchange::Exchanges::Dragonex::Market::API_URL}/api/v1/market/sell/?symbol_id=#{id}"
end
bids_url(market_pair) click to toggle source
# File lib/cryptoexchange/exchanges/dragonex/services/order_book.rb, line 22
def bids_url(market_pair)
  id = market_pair.inst_id
  "#{Cryptoexchange::Exchanges::Dragonex::Market::API_URL}/api/v1/market/buy/?symbol_id=#{id}"
end
fetch(market_pair) click to toggle source
Calls superclass method Cryptoexchange::Services::Market#fetch
# File lib/cryptoexchange/exchanges/dragonex/services/order_book.rb, line 11
def fetch(market_pair)
  asks_output = super(asks_url(market_pair))
  bids_output = super(bids_url(market_pair))
  adapt(asks_output, bids_output, market_pair)
end