Class: Cryptoexchange::Exchanges::Bitfinex::Services::OrderBookStream
- Inherits:
-
Services::OrderBookStream
- Object
- Services::OrderBookStream
- Cryptoexchange::Exchanges::Bitfinex::Services::OrderBookStream
- Defined in:
- lib/cryptoexchange/exchanges/bitfinex/services/order_book_stream.rb
Instance Method Summary collapse
- #parse_message(message, market_pair) ⇒ Object
- #subscribe_event(market_pair) ⇒ Object
- #url ⇒ Object
- #valid_message?(message) ⇒ Boolean
Instance Method Details
#parse_message(message, market_pair) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cryptoexchange/exchanges/bitfinex/services/order_book_stream.rb', line 21 def (, market_pair) # CHANNEL_ID integer Channel ID # PRICE float Price level # COUNT int Number of orders at that price level # ±AMOUNT float Total amount available at that price level. Positive values mean bid, negative values mean ask. order_book = Cryptoexchange::Models::OrderBook.new order_book.base = market_pair.base order_book.target = market_pair.target order_book.market = Bitfinex::Market::NAME if [3] > 0 order_book.bids = adapt_orders() else order_book.asks = adapt_orders() end order_book. = Time.now.to_i order_book.payload = order_book end |
#subscribe_event(market_pair) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/cryptoexchange/exchanges/bitfinex/services/order_book_stream.rb', line 9 def subscribe_event(market_pair) { event: "subscribe", channel: "book", pair: "#{market_pair.base}#{market_pair.target}" }.to_json end |
#url ⇒ Object
5 6 7 |
# File 'lib/cryptoexchange/exchanges/bitfinex/services/order_book_stream.rb', line 5 def url Cryptoexchange::Exchanges::Bitfinex::Market::WS_URL end |
#valid_message?(message) ⇒ Boolean
17 18 19 |
# File 'lib/cryptoexchange/exchanges/bitfinex/services/order_book_stream.rb', line 17 def () .is_a?(Array) && .length == 4 end |