Class: Cryptoexchange::Exchanges::Dragonex::Services::OrderBook
- Inherits:
-
Services::Market
- Object
- Services::Market
- Cryptoexchange::Exchanges::Dragonex::Services::OrderBook
- Defined in:
- lib/cryptoexchange/exchanges/dragonex/services/order_book.rb
Class Method Summary collapse
Instance Method Summary collapse
- #adapt(asks, bids, market_pair) ⇒ Object
- #adapt_orders(orders) ⇒ Object
- #asks_url(market_pair) ⇒ Object
- #bids_url(market_pair) ⇒ Object
- #fetch(market_pair) ⇒ Object
Methods inherited from Services::Market
Class Method Details
.supports_individual_ticker_query? ⇒ Boolean
6 7 8 |
# File 'lib/cryptoexchange/exchanges/dragonex/services/order_book.rb', line 6 def supports_individual_ticker_query? true end |
Instance Method Details
#adapt(asks, bids, market_pair) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# 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) ⇒ Object
39 40 41 42 43 44 45 46 |
# 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) ⇒ Object
17 18 19 20 |
# 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) ⇒ Object
22 23 24 25 |
# 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) ⇒ Object
11 12 13 14 15 |
# 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 |