class Binance::Spot::WebSocket
Spot Websocket
def agg_trade(symbol:, callbacks:)
- See: https://binance-docs.github.io/apidocs/spot/en/#aggregate-trade-streams -
Parameters:
-
symbol
(String
) --
def agg_trade(symbol:, callbacks:) url = "#{@base_url}/ws/#{symbol.downcase}@aggTrade" create_connection(url, callbacks) end
def book_ticker(callbacks:, symbol: nil)
- See: https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-book-ticker-streams -
Options Hash:
(**symbol)
-
(
String
) --
def book_ticker(callbacks:, symbol: nil) url = if symbol.nil? "#{@base_url}/ws/!bookTicker" else "#{@base_url}/ws/#{symbol.downcase}@bookTicker" end create_connection(url, callbacks) end
def diff_book_depth(symbol:, speed:, callbacks:)
- See: https://binance-docs.github.io/apidocs/spot/en/#diff-depth-stream -
Parameters:
-
speed
(String
) -- 1000ms or 100ms -
symbol
(String
) --
def diff_book_depth(symbol:, speed:, callbacks:) url = "#{@base_url}/ws/#{symbol.downcase}@depth@#{speed}" create_connection(url, callbacks) end
def initialize(options = {})
def initialize(options = {}) @base_url = options[:base_url] || BASE_URL options[:base_url] = @base_url super(options) end
def kline(symbol:, interval:, callbacks:)
- See: https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-streams -
Parameters:
-
interval
(String
) -- 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M -
symbol
(String
) --
def kline(symbol:, interval:, callbacks:) url = "#{@base_url}/ws/#{symbol.downcase}@kline_#{interval}" create_connection(url, callbacks) end
def mini_ticker(callbacks:, symbol: nil)
- See: https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-mini-ticker-stream -
Options Hash:
(**symbol)
-
(
String
) --
def mini_ticker(callbacks:, symbol: nil) url = if symbol.nil? "#{@base_url}/ws/!miniTicker@arr" else "#{@base_url}/ws/#{symbol.downcase}@miniTicker" end create_connection(url, callbacks) end
def partial_book_depth(symbol:, levels:, speed:, callbacks:)
- See: https://binance-docs.github.io/apidocs/spot/en/#partial-book-depth-streams -
Parameters:
-
speed
(String
) -- 1000ms or 100ms -
levels
(Integer
) -- 5, 10, or 20. -
symbol
(String
) --
def partial_book_depth(symbol:, levels:, speed:, callbacks:) url = "#{@base_url}/ws/#{symbol.downcase}@depth#{levels}@#{speed}" create_connection(url, callbacks) end
def rolling_window_ticker(symbol:, windowSize:, callbacks:)
- See: https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-rolling-window-statistics-streams -
def rolling_window_ticker(symbol:, windowSize:, callbacks:) url = "#{@base_url}/ws/#{symbol.downcase}@ticker_#{windowSize}" create_connection(url, callbacks) end
def rolling_window_ticker_all_symbols(windowSize:, callbacks:)
- See: https://binance-docs.github.io/apidocs/spot/en/#all-market-rolling-window-statistics-streams -
def rolling_window_ticker_all_symbols(windowSize:, callbacks:) url = "#{@base_url}/ws/!ticker_#{windowSize}@arr" create_connection(url, callbacks) end
def subscribe(stream:, callbacks:)
-
stream
(String|Array
) --
def subscribe(stream:, callbacks:) url = if stream.is_a?(Array) "#{@base_url}/stream?streams=#{stream.join('/')}" else "#{@base_url}/ws/#{stream}" end subscribe_to(url, callbacks) end
def symbol_ticker(callbacks:, symbol: nil)
- See: https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-ticker-streams -
Options Hash:
(**symbol)
-
(
String
) --
def symbol_ticker(callbacks:, symbol: nil) url = if symbol.nil? "#{@base_url}/ws/!ticker@arr" else "#{@base_url}/ws/#{symbol.downcase}@ticker" end create_connection(url, callbacks) end
def trade(symbol:, callbacks:)
- See: https://binance-docs.github.io/apidocs/spot/en/#trade-streams -
Parameters:
-
symbol
(String
) --
def trade(symbol:, callbacks:) url = "#{@base_url}/ws/#{symbol.downcase}@trade" create_connection(url, callbacks) end