1111from twisted .internet .protocol import ReconnectingClientFactory
1212from twisted .internet .error import ReactorAlreadyRunning
1313
14- from .enums import KLINE_INTERVAL_1MINUTE , WEBSOCKET_UPDATE_1SECOND , WEBSOCKET_DEPTH_1
14+ from .enums import KLINE_INTERVAL_1MINUTE , WEBSOCKET_DEPTH_1
1515
1616BINANCE_STREAM_URL = 'wss://stream.binance.com:9443/ws/'
1717
@@ -66,10 +66,7 @@ def __init__(self, client):
6666 self ._user_listen_key = None
6767 self ._client = client
6868
69- def _start_socket (self , path , callback , update_time = WEBSOCKET_UPDATE_1SECOND ):
70- if update_time != WEBSOCKET_UPDATE_1SECOND :
71- path = '{}@{}' .format (path , update_time )
72-
69+ def _start_socket (self , path , callback ):
7370 if path in self ._conns :
7471 return False
7572
@@ -81,7 +78,7 @@ def _start_socket(self, path, callback, update_time=WEBSOCKET_UPDATE_1SECOND):
8178 self ._conns [path ] = connectWS (factory , context_factory )
8279 return path
8380
84- def start_depth_socket (self , symbol , callback , depth = WEBSOCKET_DEPTH_1 , update_time = WEBSOCKET_UPDATE_1SECOND ):
81+ def start_depth_socket (self , symbol , callback , depth = WEBSOCKET_DEPTH_1 ):
8582 """Start a websocket for symbol market depth
8683
8784 https://www.binance.com/restapipub.html#depth-wss-endpoint
@@ -92,8 +89,6 @@ def start_depth_socket(self, symbol, callback, depth=WEBSOCKET_DEPTH_1, update_t
9289 :type callback: function
9390 :param depth: Number of depth entries to return, default WEBSOCKET_DEPTH_1
9491 :type depth: enum
95- :param update_time: Update time interval, default WEBSOCKET_UPDATE_1SECOND
96- :type update_time: enum
9792
9893 :returns: connection key string if successful, False otherwise
9994
@@ -135,9 +130,9 @@ def start_depth_socket(self, symbol, callback, depth=WEBSOCKET_DEPTH_1, update_t
135130 socket_name = symbol .lower () + '@depth'
136131 if depth != WEBSOCKET_DEPTH_1 :
137132 socket_name = '{}{}' .format (socket_name , depth )
138- return self ._start_socket (socket_name , callback , update_time = update_time )
133+ return self ._start_socket (socket_name , callback )
139134
140- def start_kline_socket (self , symbol , callback , interval = KLINE_INTERVAL_1MINUTE , update_time = WEBSOCKET_UPDATE_1SECOND ):
135+ def start_kline_socket (self , symbol , callback , interval = KLINE_INTERVAL_1MINUTE ):
141136 """Start a websocket for symbol kline data
142137
143138 https://www.binance.com/restapipub.html#kline-wss-endpoint
@@ -148,8 +143,6 @@ def start_kline_socket(self, symbol, callback, interval=KLINE_INTERVAL_1MINUTE,
148143 :type callback: function
149144 :param interval: Kline interval, default KLINE_INTERVAL_1MINUTE
150145 :type interval: enum
151- :param update_time: Update time interval, default WEBSOCKET_UPDATE_1SECOND
152- :type update_time: enum
153146
154147 :returns: connection key string if successful, False otherwise
155148
@@ -183,7 +176,7 @@ def start_kline_socket(self, symbol, callback, interval=KLINE_INTERVAL_1MINUTE,
183176 }
184177 """
185178 socket_name = '{}@kline_{}' .format (symbol .lower (), interval )
186- return self ._start_socket (socket_name , callback , update_time = update_time )
179+ return self ._start_socket (socket_name , callback )
187180
188181 def start_trade_socket (self , symbol , callback ):
189182 """Start a websocket for symbol trade data
@@ -216,17 +209,13 @@ def start_trade_socket(self, symbol, callback):
216209 """
217210 return self ._start_socket (symbol .lower () + '@trade' , callback )
218211
219- def start_ticker_socket (self , callback , update_time = WEBSOCKET_UPDATE_1SECOND ):
212+ def start_ticker_socket (self , callback ):
220213 """Start a websocket for ticker data
221214
222215 By default all markets are included in an array.
223216
224- Using a 0ms update time will split markets into separate messages.
225-
226217 :param callback: callback function to handle messages
227218 :type callback: function
228- :param update_time: Update time interval, default WEBSOCKET_UPDATE_1SECOND
229- :type update_time: enum
230219
231220 :returns: connection key string if successful, False otherwise
232221
@@ -260,17 +249,15 @@ def start_ticker_socket(self, callback, update_time=WEBSOCKET_UPDATE_1SECOND):
260249 }
261250 ]
262251 """
263- return self ._start_socket ('!ticker@arr' , callback , update_time = update_time )
252+ return self ._start_socket ('!ticker@arr' , callback )
264253
265- def start_user_socket (self , callback , update_time = WEBSOCKET_UPDATE_1SECOND ):
254+ def start_user_socket (self , callback ):
266255 """Start a websocket for user data
267256
268257 https://www.binance.com/restapipub.html#user-wss-endpoint
269258
270259 :param callback: callback function to handle messages
271260 :type callback: function
272- :param update_time: Update time interval, default WEBSOCKET_UPDATE_1SECOND
273- :type update_time: enum
274261
275262 :returns: connection key string if successful, False otherwise
276263
@@ -283,7 +270,7 @@ def start_user_socket(self, callback, update_time=WEBSOCKET_UPDATE_1SECOND):
283270 self .stop_socket (conn_key )
284271 break
285272 self ._user_listen_key = self ._client .stream_get_listen_key ()
286- conn_key = self ._start_socket (self ._user_listen_key , callback , update_time = update_time )
273+ conn_key = self ._start_socket (self ._user_listen_key , callback )
287274 if conn_key :
288275 # start timer to keep socket alive
289276 self ._start_user_timer ()
0 commit comments