Skip to content

Commit

Permalink
Book ticker sockets added
Browse files Browse the repository at this point in the history
  • Loading branch information
nardew committed Sep 14, 2019
1 parent d09d4bb commit 51f5058
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions binance/websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,55 @@ def start_ticker_socket(self, callback):
"""
return self._start_socket('!ticker@arr', callback)

def start_symbol_book_ticker_socket(self, symbol, callback):
"""Start a websocket for the best bid or ask's price or quantity for a specified symbol.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#individual-symbol-book-ticker-streams
:param symbol: required
:type symbol: str
:param callback: callback function to handle messages
:type callback: function
:returns: connection key string if successful, False otherwise
Message Format
.. code-block:: python
{
"u":400900217, // order book updateId
"s":"BNBUSDT", // symbol
"b":"25.35190000", // best bid price
"B":"31.21000000", // best bid qty
"a":"25.36520000", // best ask price
"A":"40.66000000" // best ask qty
}
"""
return self._start_socket(symbol.lower() + '@bookTicker', callback)

def start_book_ticker_socket(self, callback):
"""Start a websocket for the best bid or ask's price or quantity for all symbols.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#all-book-tickers-stream
:param callback: callback function to handle messages
:type callback: function
:returns: connection key string if successful, False otherwise
Message Format
.. code-block:: python
{
// Same as <symbol>@bookTicker payload
}
"""
return self._start_socket('!bookTicker', callback)

def start_multiplex_socket(self, streams, callback):
"""Start a multiplexed socket using a list of socket names.
User stream sockets can not be included.
Expand Down

0 comments on commit 51f5058

Please sign in to comment.