Skip to content

Commit 7d19a88

Browse files
author
Sam McHardy
authored
Merge pull request sammchardy#114 from sujitnair/miniticker_socket
Add support for miniticker websocket
2 parents 745ca91 + fc4c86f commit 7d19a88

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

binance/websockets.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,38 @@ def start_kline_socket(self, symbol, callback, interval=Client.KLINE_INTERVAL_1M
212212
socket_name = '{}@kline_{}'.format(symbol.lower(), interval)
213213
return self._start_socket(socket_name, callback)
214214

215+
def start_miniticker_socket(self, callback):
216+
"""Start a miniticker websocket for all trades
217+
218+
This is not in the official Binance api docs, but this is what
219+
feeds the right column on a ticker page on Binance.
220+
221+
:param callback: callback function to handle messages
222+
:type callback: function
223+
224+
:returns: connection key string if successful, False otherwise
225+
226+
Message Format
227+
228+
.. code-block:: python
229+
230+
[
231+
{
232+
'e': '24hrMiniTicker', # Event type
233+
'E': 1515906156273, # Event time
234+
's': 'QTUMETH', # Symbol
235+
'c': '0.03836900', # close
236+
'o': '0.03953500', # open
237+
'h': '0.04400000', # high
238+
'l': '0.03756000', # low
239+
'v': '147435.80000000', # volume
240+
'q': '5903.84338533' # quote volume
241+
}
242+
]
243+
"""
244+
245+
return self._start_socket('!miniTicker@arr@3000ms', callback)
246+
215247
def start_trade_socket(self, symbol, callback):
216248
"""Start a websocket for symbol trade data
217249

0 commit comments

Comments
 (0)