Class: Cryptoexchange::Exchanges::Bitfinex::Services::MarketStream
- Inherits:
-
Services::MarketStream
- Object
- Services::MarketStream
- Cryptoexchange::Exchanges::Bitfinex::Services::MarketStream
- Defined in:
- lib/cryptoexchange/exchanges/bitfinex/services/market_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 41 42 43 44 45 46 47 48 |
# File 'lib/cryptoexchange/exchanges/bitfinex/services/market_stream.rb', line 21 def (, market_pair) # [67452,6614.9,36.37426215,6615,71.7470363,42.2,0.0064,6614.9,9981.07371415,6741.4366438,6570] # # CHANNEL_ID integer Channel ID # BID float Price of last highest bid # BID_SIZE float Size of the last highest bid # ASK float Price of last lowest ask # ASK_SIZE float Size of the last lowest ask # DAILY_CHANGE float Amount that the last price has changed since yesterday # DAILY_CHANGE_PERC float Amount that the price has changed expressed in percentage terms # LAST_PRICE float Price of the last trade. # VOLUME float Daily volume # HIGH float Daily high # LOW float Daily low ticker = Cryptoexchange::Models::Ticker.new ticker.base = market_pair.base ticker.target = market_pair.target ticker.market = Bitfinex::Market::NAME ticker.ask = NumericHelper.to_d([3]) ticker.bid = NumericHelper.to_d([1]) ticker.last = NumericHelper.to_d([7]) ticker.high = NumericHelper.to_d([9]) ticker.low = NumericHelper.to_d([10]) ticker.volume = NumericHelper.to_d([6]) ticker. = Time.now.to_i ticker.payload = ticker end |
#subscribe_event(market_pair) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/cryptoexchange/exchanges/bitfinex/services/market_stream.rb', line 9 def subscribe_event(market_pair) { event: "subscribe", channel: "ticker", pair: "#{market_pair.base}#{market_pair.target}" }.to_json end |
#url ⇒ Object
5 6 7 |
# File 'lib/cryptoexchange/exchanges/bitfinex/services/market_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/market_stream.rb', line 17 def () .is_a?(Array) && .length == 11 end |