Class: Cryptoexchange::Exchanges::Bitfinex::Services::TradeStream
- Inherits:
-
Services::TradeStream
- Object
- Services::TradeStream
- Cryptoexchange::Exchanges::Bitfinex::Services::TradeStream
- Defined in:
- lib/cryptoexchange/exchanges/bitfinex/services/trade_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 |
# File 'lib/cryptoexchange/exchanges/bitfinex/services/trade_stream.rb', line 21 def (, market_pair) # [ 5, 'te', '1234-BTCUSD', 1443659698, 236.42, 0.49064538 ] # [ 5, 'tu', '1234-BTCUSD', 15254529, 1443659698, 236.42, 0.49064538 ] # [67452,6614.9,36.37426215,6615,71.7470363,42.2,0.0064,6614.9,9981.07371415,6741.4366438,6570] # # CHANNEL_ID integer Channel ID # SEQ string Trade sequence id # ID int Trade database id # TIMESTAMP int Unix timestamp of the trade. # PRICE float Price at which the trade was executed # ±AMOUNT float How much was bought (positive) or sold (negative) trade = Cryptoexchange::Models::Trade.new trade.base = market_pair.base trade.target = market_pair.target trade.market = Bitfinex::Market::NAME trade.trade_id = [3] trade.type = [6] > 0 ? 'buy' : 'sell' # The order that causes the trade determines if it is a buy or a sell. trade.price = [5] trade.amount = [6] trade. = [4] trade.payload = trade end |
#subscribe_event(market_pair) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/cryptoexchange/exchanges/bitfinex/services/trade_stream.rb', line 9 def subscribe_event(market_pair) { event: "subscribe", channel: "trades", pair: "#{market_pair.base}#{market_pair.target}" }.to_json end |
#url ⇒ Object
5 6 7 |
# File 'lib/cryptoexchange/exchanges/bitfinex/services/trade_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/trade_stream.rb', line 17 def () .is_a?(Array) && .length == 7 end |