Class: Cryptoexchange::Exchanges::Bitkub::Services::OrderBook
- Inherits:
-
Services::Market
- Object
- Services::Market
- Cryptoexchange::Exchanges::Bitkub::Services::OrderBook
- Defined in:
- lib/cryptoexchange/exchanges/bitkub/services/order_book.rb
Constant Summary collapse
- ORDER_LIMIT =
20
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
7 8 9 |
# File 'lib/cryptoexchange/exchanges/bitkub/services/order_book.rb', line 7 def supports_individual_ticker_query? true end |
Instance Method Details
#adapt(asks, bids, market_pair) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cryptoexchange/exchanges/bitkub/services/order_book.rb', line 30 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 = Bitkub::Market::NAME order_book.asks = adapt_orders(asks['result']) order_book.bids = adapt_orders(bids['result']) order_book. = Time.now.to_i order_book.payload = [asks, bids] order_book end |
#adapt_orders(orders) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/cryptoexchange/exchanges/bitkub/services/order_book.rb', line 43 def adapt_orders(orders) orders.collect do |order_entry| Cryptoexchange::Models::Order.new( price: order_entry[3], amount: order_entry[-1], timestamp: order_entry[1] ) end end |
#asks_url(market_pair) ⇒ Object
18 19 20 21 22 |
# File 'lib/cryptoexchange/exchanges/bitkub/services/order_book.rb', line 18 def asks_url(market_pair) base = market_pair.base target = market_pair.target "#{Cryptoexchange::Exchanges::Bitkub::Market::API_URL}/market/asks?sym=#{target}_#{base}&lmt=#{ORDER_LIMIT}" end |
#bids_url(market_pair) ⇒ Object
24 25 26 27 28 |
# File 'lib/cryptoexchange/exchanges/bitkub/services/order_book.rb', line 24 def bids_url(market_pair) base = market_pair.base target = market_pair.target "#{Cryptoexchange::Exchanges::Bitkub::Market::API_URL}/market/bids?sym=#{target}_#{base}&lmt=#{ORDER_LIMIT}" end |
#fetch(market_pair) ⇒ Object
12 13 14 15 16 |
# File 'lib/cryptoexchange/exchanges/bitkub/services/order_book.rb', line 12 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 |