
    5if                         S SK r S SKrS SKJr  S SKJrJrJrJrJ	r	  S SK
Jr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr   " S S\\5      r " S S5      r " S S\5      rg)    N)Enum)OptionalListDictCallableAny)KEEPALIVE_TIMEOUT)KeepAliveWebsocket)ReconnectingWebsocket)ThreadedApiManager)AsyncClient)FuturesType)ContractType)get_loopc                   (    \ rS rSrSrSrSrSrSrSr	g)	BinanceSocketType   SpotUSD_M_FuturesCoin_M_FuturesVanilla_OptionsAccount N)
__name__
__module____qualname____firstlineno__SPOTUSD_M_FUTURESCOIN_M_FUTURESOPTIONSACCOUNT__static_attributes__r       `/var/www/html/BTCUSD/btcusdt_trading_app/venv/lib/python3.13/site-packages/binance/ws/streams.pyr   r      s    D#M%NGGr$   r   c                      \ rS rSrSrSrSrSrSrSr	Sr
S	rS	rS
rSrSrSr\S4S\S\4S jjrSXS\\   4S jjrSSS\R2                  4S\S\\   S\S\S\S\4S jjr   SYS\S\\   S\S\S\4
S jjr SZS\S\S\4S jjr S[S\S\4S  jjr!S\4S! jr" S\S"\S#\\   S$\\   4S% jjr#\RH                  4S"\4S& jjr%\RH                  \RL                  \'RP                  4S"\S\S'\'4S( jjr)S]S)\4S* jjr*S"\4S+ jr+S"\4S, jr,\RL                  4S"\S\4S- jjr-S"\4S. jr.S"\4S/ jr/S0 r0S1 r1S2 r2S^S"\S4\4S5 jjr3S3\RL                  4S"\S4\S\4S6 jjr4S3\RL                  4S4\S\4S7 jjr5\RL                  4S"\S\4S8 jjr6\RL                  4S"\S\4S9 jjr7S:\RL                  4S;\S\4S< jjr8S"\4S= jr9S> r:S?\;\   4S@ jr<S?\;\   4SA jr=\RL                  4S?\;\   S\4SB jjr>SC r?SD r@SE rASF rBSG rCSH rDSI rES"\4SJ jrFS"\4SK jrGS"\SL\4SM jrHS"\4SN jrI\RH                  4S"\4SO jjrJS_S"\S#\4SP jjrKS\RL                  4S"\S#\4SQ jjrLSR rMS"\SL\4SS jrNS"\4ST jrOS"\4SU jrPSV rQSWrRg)`BinanceSocketManager   zwss://stream.binance.{}:9443/z$wss://stream.testnet.binance.vision/zwss://demo-stream.binance.com/zwss://fstream.binance.{}/zwss://stream.binancefuture.com/z wss://fstream.binancefuture.com/zwss://dstream.binance.{}/z wss://dstream.binancefuture.com/z#wss://nbstream.binance.{}/eoptions/51020d   clientmax_queue_sizec                    U R                   R                  UR                  5      U l         U R                  R                  UR                  5      U l        U R                  R                  UR                  5      U l        U R
                  R                  UR                  5      U l        0 U l        [        5       U l        Xl	        X l
        U R                  R                  U l        U R                  R                  U l        X0l        0 U l        g)a  Initialise the BinanceSocketManager

:param client: Binance API client
:type client: binance.AsyncClient
:param user_timeout: Timeout for user socket in seconds
:param max_queue_size: Max size of the websocket queue, defaults to 100
:type max_queue_size: int
N)
STREAM_URLformattldFSTREAM_URLDSTREAM_URLOPTIONS_URL_connsr   _loop_client_user_timeouttestnetdemo_max_queue_size	ws_kwargs)selfr-   user_timeoutr.   s       r%   __init__BinanceSocketManager.__init__*   s     //00<++226::>++226::>++226::>Z
)||++LL%%	-r$   N
stream_urlc                     U(       a  U$ U R                   nU R                  (       a  U R                  nU$ U R                  (       a  U R                  nU$ N)r0   r:   STREAM_TESTNET_URLr;   STREAM_DEMO_URLr>   rB   s     r%   _get_stream_url$BinanceSocketManager._get_stream_urlF   sH    __
<<00J  YY--Jr$   ws/Fpathprefix	is_binarysocket_typereturnc                 T  ^ ^ T SU 3n[        T R                  SS 5      nU(       a  U SU 3nUT R                  ;  a\  [        SUT R	                  U5      UU U4S jUT R                  R
                  T R                  S.T R                  D6T R                  U'   T R                  U   $ )N_	TIME_UNITz
?timeUnit=c                 0   > TR                  T SU  35      $ )NrQ   _exit_socket)pr>   rN   s    r%   <lambda>2BinanceSocketManager._get_socket.<locals>.<lambda>a   s    D$5$5Qqc6J$Kr$   )rK   urlrL   	exit_cororM   https_proxyr.   r   )getattrr8   r6   r   rH   r[   r<   r=   )r>   rK   rB   rL   rM   rN   conn_id	time_units   `    `  r%   _get_socket BinanceSocketManager._get_socketP   s     !M4&)DLL+t<	V:i[1D$++%#8 	$((4K# LL44#33	$ ..	$DKK  {{7##r$   c                 <  ^ ^ [         R                   SU 3mTT R                  ;  ag  [        ST R                  T R                  U5      UUUU 4S jUT R                  T R                  R                  S.T R                  D6T R                  T'   T R                  T   $ )NrQ   c                 &   > TR                  T5      $ rD   rT   )rV   r]   r>   s    r%   rW   :BinanceSocketManager._get_account_socket.<locals>.<lambda>x   s    D$5$5g$>r$   )r-   rY   keepalive_typerL   rZ   rM   r?   r[   r   )	r   r"   r6   r
   r8   rH   r9   r[   r=   )r>   rK   rB   rL   rM   r]   s   `    @r%   _get_account_socket(BinanceSocketManager._get_account_socketj   s     '../q7$++%#5 
$||((4#>#!// LL44
$ ..
$DKK  {{7##r$   futures_typec                    [         R                  nU[        R                  :X  aH  U R                  nU R
                  (       a  U R                  nOeU R                  (       a  U R                  nOGU R                  nU R
                  (       a  U R                  nOU R                  (       a  U R                  nU R                  XX4S9$ )N)rN   )r   r   r   USD_Mr3   r:   FSTREAM_TESTNET_URLr;   FSTREAM_DEMO_URLr4   DSTREAM_TESTNET_URLDSTREAM_DEMO_URLr_   )r>   rK   rg   rL   rN   rB   s         r%   _get_futures_socket(BinanceSocketManager._get_futures_socket   s     *;)H)H;,,,))J||!55
!22
))J||!55
!22
&RRr$   c                 \    U R                   nU R                  UUUS[        R                  S9$ )NF)rM   rN   )r5   r_   r   r!   )r>   rK   rL   rB   s       r%   _get_options_socket(BinanceSocketManager._get_options_socket   s:    %%
)11   
 	
r$   c                 B   #    U R                  U5      I S h  vN   g  N7frD   )_stop_socket)r>   rK   s     r%   rU   !BinanceSocketManager._exit_socket   s     %%%s   symboldepthintervalc                     UR                  5       S-   nU(       a  US:w  a  U U 3nU(       a  US;   a	  U SU S3nO[        S5      eU R                  U5      $ )aq  Start a websocket for symbol market depth returning either a diff or a partial book

https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#partial-book-depth-streams

:param symbol: required
:type symbol: str
:param depth: optional Number of depth entries to return, default None. If passed returns a partial book instead of a diff
:type depth: str
:param interval: optional interval for updates, default None. If not set, updates happen every second. Must be 0, None (1s) or 100 (100ms)
:type interval: int

:returns: connection key string if successful, False otherwise

Partial Message Format

.. code-block:: python

    {
        "lastUpdateId": 160,  # Last update ID
        "bids": [             # Bids to be updated
            [
                "0.0024",     # price level to be updated
                "10",         # quantity
                []            # ignore
            ]
        ],
        "asks": [             # Asks to be updated
            [
                "0.0026",     # price level to be updated
                "100",        # quantity
                []            # ignore
            ]
        ]
    }


Diff Message Format

.. code-block:: python

    {
        "e": "depthUpdate", # Event type
        "E": 123456789,     # Event time
        "s": "BNBBTC",      # Symbol
        "U": 157,           # First update ID in event
        "u": 160,           # Final update ID in event
        "b": [              # Bids to be updated
            [
                "0.0024",   # price level to be updated
                "10",       # quantity
                []          # ignore
            ]
        ],
        "a": [              # Asks to be updated
            [
                "0.0026",   # price level to be updated
                "100",      # quantity
                []          # ignore
            ]
        ]
    }

@depth1)r   r,   @mszAWebsocket interval value not allowed. Allowed values are [0, 100])lower
ValueErrorr_   )r>   rv   rw   rx   socket_names        r%   depth_socket!BinanceSocketManager.depth_socket   sl    D llnx/Uc\(M%1K8#!,Qxj; W  ,,r$   c                 N    UR                  5        SU 3nU R                  U5      $ )a  Start a websocket for symbol kline data

https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#klinecandlestick-streams

:param symbol: required
:type symbol: str
:param interval: Kline interval, default KLINE_INTERVAL_1MINUTE
:type interval: str

:returns: connection key string if successful, False otherwise

Message Format

.. code-block:: python

    {
        "e": "kline",                                   # event type
        "E": 1499404907056,                             # event time
        "s": "ETHBTC",                                  # symbol
        "k": {
            "t": 1499404860000,                 # start time of this bar
            "T": 1499404919999,                 # end time of this bar
            "s": "ETHBTC",                              # symbol
            "i": "1m",                                  # interval
            "f": 77462,                                 # first trade id
            "L": 77465,                                 # last trade id
            "o": "0.10278577",                  # open
            "c": "0.10278645",                  # close
            "h": "0.10278712",                  # high
            "l": "0.10278518",                  # low
            "v": "17.47929838",                 # volume
            "n": 4,                                             # number of trades
            "x": false,                                 # whether this bar is final
            "q": "1.79662878",                  # quote volume
            "V": "2.34879839",                  # volume of active buy
            "Q": "0.24142166",                  # quote volume of active buy
            "B": "13279784.01349473"    # can be ignored
            }
    }
@kline_)r~   r_   )r>   rv   rx   rK   s       r%   kline_socket!BinanceSocketManager.kline_socket   s-    R ,,.!
3%%r$   contract_typec                 h    UR                  5        SUR                   SU 3nU R                  USUS9$ )a  Start a websocket for symbol kline data for the perpeual futures stream

https://binance-docs.github.io/apidocs/futures/en/#continuous-contract-kline-candlestick-streams

:param symbol: required
:type symbol: str
:param interval: Kline interval, default KLINE_INTERVAL_1MINUTE
:type interval: str
:param futures_type: use USD-M or COIN-M futures default USD-M
:param contract_type: use PERPETUAL or CURRENT_QUARTER or NEXT_QUARTER default PERPETUAL

:returns: connection key string if successful, False otherwise

Message Format

.. code-block:: python

        {
        "e":"continuous_kline",   // Event type
        "E":1607443058651,        // Event time
        "ps":"BTCUSDT",           // Pair
        "ct":"PERPETUAL"          // Contract type
        "k":{
            "t":1607443020000,      // Kline start time
            "T":1607443079999,      // Kline close time
            "i":"1m",               // Interval
            "f":116467658886,       // First trade ID
            "L":116468012423,       // Last trade ID
            "o":"18787.00",         // Open price
            "c":"18804.04",         // Close price
            "h":"18804.04",         // High price
            "l":"18786.54",         // Low price
            "v":"197.664",          // volume
            "n": 543,               // Number of trades
            "x":false,              // Is this kline closed?
            "q":"3715253.19494",    // Quote asset volume
            "V":"184.769",          // Taker buy volume
            "Q":"3472925.84746",    //Taker buy quote asset volume
            "B":"0"                 // Ignore
        }
    }
    <pair>_<contractType>@continuousKline_<interval>
rQ   z@continuousKline_rJ   rL   rg   )r~   valuern   )r>   rv   rx   rg   r   rK   s         r%   kline_futures_socket)BinanceSocketManager.kline_futures_socket  sB    f ,,.!=#6#6"77H
S''U'VVr$   update_timec                 ,    U R                  SU S35      $ )a0  Start a miniticker websocket for all trades

This is not in the official Binance api docs, but this is what
feeds the right column on a ticker page on Binance.

:param update_time: time between callbacks in milliseconds, must be 1000 or greater
:type update_time: int

:returns: connection key string if successful, False otherwise

Message Format

.. code-block:: python

    [
        {
            'e': '24hrMiniTicker',  # Event type
            'E': 1515906156273,     # Event time
            's': 'QTUMETH',         # Symbol
            'c': '0.03836900',      # close
            'o': '0.03953500',      # open
            'h': '0.04400000',      # high
            'l': '0.03756000',      # low
            'v': '147435.80000000', # volume
            'q': '5903.84338533'    # quote volume
        }
    ]
z!miniTicker@arr@r}   r_   )r>   r   s     r%   miniticker_socket&BinanceSocketManager.miniticker_socketP  s    < "2;-r BCCr$   c                 F    U R                  UR                  5       S-   5      $ )a  Start a websocket for symbol trade data

https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#trade-streams

:param symbol: required
:type symbol: str

:returns: connection key string if successful, False otherwise

Message Format

.. code-block:: python

    {
        "e": "trade",     # Event type
        "E": 123456789,   # Event time
        "s": "BNBBTC",    # Symbol
        "t": 12345,       # Trade ID
        "p": "0.001",     # Price
        "q": "100",       # Quantity
        "b": 88,          # Buyer order Id
        "a": 50,          # Seller order Id
        "T": 123456785,   # Trade time
        "m": true,        # Is the buyer the market maker?
        "M": true         # Ignore.
    }

@trader_   r~   r>   rv   s     r%   trade_socket!BinanceSocketManager.trade_socketp  s     <  9::r$   c                 F    U R                  UR                  5       S-   5      $ )a  Start a websocket for symbol trade data

https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#aggregate-trade-streams

:param symbol: required
:type symbol: str

:returns: connection key string if successful, False otherwise

Message Format

.. code-block:: python

    {
        "e": "aggTrade",                # event type
        "E": 1499405254326,             # event time
        "s": "ETHBTC",                  # symbol
        "a": 70232,                             # aggregated tradeid
        "p": "0.10281118",              # price
        "q": "8.15632997",              # quantity
        "f": 77489,                             # first breakdown trade id
        "l": 77489,                             # last breakdown trade id
        "T": 1499405254324,             # trade time
        "m": false,                             # whether buyer is a maker
        "M": true                               # can be ignored
    }

	@aggTrader   r   s     r%   aggtrade_socket$BinanceSocketManager.aggtrade_socket  s     :  <==r$   c                 D    U R                  UR                  5       S-   US9$ )a  Start a websocket for aggregate symbol trade data for the futures stream

:param symbol: required
:param futures_type: use USD-M or COIN-M futures default USD-M

:returns: connection key string if successful, False otherwise

Message Format

.. code-block:: python

    {
        "e": "aggTrade",  // Event type
        "E": 123456789,   // Event time
        "s": "BTCUSDT",    // Symbol
        "a": 5933014,     // Aggregate trade ID
        "p": "0.001",     // Price
        "q": "100",       // Quantity
        "f": 100,         // First trade ID
        "l": 105,         // Last trade ID
        "T": 123456785,   // Trade time
        "m": true,        // Is the buyer the market maker?
    }

r   rg   rn   r~   r>   rv   rg   s      r%   aggtrade_futures_socket,BinanceSocketManager.aggtrade_futures_socket  s,    8 ''LLN[(| ( 
 	
r$   c                 F    U R                  UR                  5       S-   5      $ )a  Start a websocket for a symbol's miniTicker data

https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-mini-ticker-stream

:param symbol: required
:type symbol: str

:returns: connection key string if successful, False otherwise

Message Format

.. code-block:: python

    {
        "e": "24hrMiniTicker",  // Event type
        "E": 123456789,         // Event time
        "s": "BNBBTC",          // Symbol
        "c": "0.0025",          // Close price
        "o": "0.0010",          // Open price
        "h": "0.0025",          // High price
        "l": "0.0010",          // Low price
        "v": "10000",           // Total traded base asset volume
        "q": "18"               // Total traded quote asset volume
    }

z@miniTickerr   r   s     r%   symbol_miniticker_socket-BinanceSocketManager.symbol_miniticker_socket  s     6  >??r$   c                 F    U R                  UR                  5       S-   5      $ )a  Start a websocket for a symbol's ticker data

https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#individual-symbol-ticker-streams

:param symbol: required
:type symbol: str

:returns: connection key string if successful, False otherwise

Message Format

.. code-block:: python

    {
        "e": "24hrTicker",  # Event type
        "E": 123456789,     # Event time
        "s": "BNBBTC",      # Symbol
        "p": "0.0015",      # Price change
        "P": "250.00",      # Price change percent
        "w": "0.0018",      # Weighted average price
        "x": "0.0009",      # Previous day's close price
        "c": "0.0025",      # Current day's close price
        "Q": "10",          # Close trade's quantity
        "b": "0.0024",      # Best bid price
        "B": "10",          # Bid bid quantity
        "a": "0.0026",      # Best ask price
        "A": "100",         # Best ask quantity
        "o": "0.0010",      # Open price
        "h": "0.0025",      # High price
        "l": "0.0010",      # Low price
        "v": "10000",       # Total traded base asset volume
        "q": "18",          # Total traded quote asset volume
        "O": 0,             # Statistics open time
        "C": 86400000,      # Statistics close time
        "F": 0,             # First trade ID
        "L": 18150,         # Last trade Id
        "n": 18151          # Total number of trades
    }

@tickerr   r   s     r%   symbol_ticker_socket)BinanceSocketManager.symbol_ticker_socket  s!    R  :;;r$   c                 $    U R                  S5      $ )a  Start a websocket for all ticker data

By default all markets are included in an array.

https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#all-market-tickers-stream

:param coro: callback function to handle messages
:type coro: function

:returns: connection key string if successful, False otherwise

Message Format

.. code-block:: python

    [
        {
            'F': 278610,
            'o': '0.07393000',
            's': 'BCCBTC',
            'C': 1509622420916,
            'b': '0.07800800',
            'l': '0.07160300',
            'h': '0.08199900',
            'L': 287722,
            'P': '6.694',
            'Q': '0.10000000',
            'q': '1202.67106335',
            'p': '0.00494900',
            'O': 1509536020916,
            'a': '0.07887800',
            'n': 9113,
            'B': '1.00000000',
            'c': '0.07887900',
            'x': '0.07399600',
            'w': '0.07639068',
            'A': '2.41900000',
            'v': '15743.68900000'
        }
    ]
!ticker@arrr   r>   s    r%   ticker_socket"BinanceSocketManager.ticker_socket  s    T ..r$   c                 B    U R                  S[        R                  5      $ )a  Start a websocket for all ticker data

By default all markets are included in an array.

https://binance-docs.github.io/apidocs/futures/en/#all-market-tickers-streams

:returns: connection key string if successful, False otherwise

Message Format

.. code-block:: python

    [
        {
            "e": "24hrTicker",  // Event type
            "E": 123456789,     // Event time
            "s": "BTCUSDT",     // Symbol
            "p": "0.0015",      // Price change
            "P": "250.00",      // Price change percent
            "w": "0.0018",      // Weighted average price
            "c": "0.0025",      // Last price
            "Q": "10",          // Last quantity
            "o": "0.0010",      // Open price
            "h": "0.0025",      // High price
            "l": "0.0010",      // Low price
            "v": "10000",       // Total traded base asset volume
            "q": "18",          // Total traded quote asset volume
            "O": 0,             // Statistics open time
            "C": 86400000,      // Statistics close time
            "F": 0,             // First trade ID
            "L": 18150,         // Last trade Id
            "n": 18151          // Total number of trades
        }
    ]
r   )rn   r   ri   r   s    r%   futures_ticker_socket*BinanceSocketManager.futures_ticker_socketC  s    H ''{7H7HIIr$   c                 B    U R                  S[        R                  5      $ )a  Start a websocket for all ticker data

By default all markets are included in an array.

https://binance-docs.github.io/apidocs/delivery/en/#all-market-tickers-streams

:returns: connection key string if successful, False otherwise

Message Format

.. code-block:: python

    [
        {
            "e": "24hrTicker",  // Event type
            "E": 123456789,     // Event time
            "s": "BTCUSDT",     // Symbol
            "p": "0.0015",      // Price change
            "P": "250.00",      // Price change percent
            "w": "0.0018",      // Weighted average price
            "c": "0.0025",      // Last price
            "Q": "10",          // Last quantity
            "o": "0.0010",      // Open price
            "h": "0.0025",      // High price
            "l": "0.0010",      // Low price
            "v": "10000",       // Total traded base asset volume
            "q": "18",          // Total traded quote asset volume
            "O": 0,             // Statistics open time
            "C": 86400000,      // Statistics close time
            "F": 0,             // First trade ID
            "L": 18150,         // Last trade Id
            "n": 18151          // Total number of trades
        }
    ]
r   )rn   r   COIN_Mr   s    r%   futures_coin_ticker_socket/BinanceSocketManager.futures_coin_ticker_socketi  s    H ''{7I7IJJr$   Tfastc                 v    U(       a  SOSnU R                  UR                  5       U-   [        R                  S9$ )a  Start a websocket for a symbol's futures mark price
https://binance-docs.github.io/apidocs/delivery/en/#index-price-stream
:param symbol: required
:param fast: use faster or 1s default
:returns: connection key string if successful, False otherwise

Message Format
.. code-block:: python
    {
        "e": "indexPriceUpdate",  // Event type
        "E": 1591261236000,       // Event time
        "i": "BTCUSD",            // Pair
        "p": "9636.57860000",     // Index Price
      }
z@indexPrice@1sz@indexPricer   )rn   r~   r   r   )r>   rv   r   stream_names       r%   index_price_socket'BinanceSocketManager.index_price_socket  s<      +/&M''LLN[({7I7I ( 
 	
r$   c                 Z    U(       a  SOSnU R                  UR                  5       U-   US9$ )a  Start a websocket for a symbol's futures mark price
https://binance-docs.github.io/apidocs/futures/en/#mark-price-stream
:param symbol: required
:param fast: use faster or 1s default
:param futures_type: use USD-M or COIN-M futures default USD-M
:returns: connection key string if successful, False otherwise
Message Format
.. code-block:: python
    {
        "e": "markPriceUpdate",  // Event type
        "E": 1562305380000,      // Event time
        "s": "BTCUSDT",          // Symbol
        "p": "11185.87786614",   // Mark price
        "r": "0.00030000",       // Funding rate
        "T": 1562306400000       // Next funding time
    }
z@markPrice@1s
@markPricer   r   )r>   rv   r   rg   r   s        r%   symbol_mark_price_socket-BinanceSocketManager.symbol_mark_price_socket  s5    . *.o<''LLN[(| ( 
 	
r$   c                 6    U(       a  SOSnU R                  X2S9$ )a  Start a websocket for all futures mark price data
By default all symbols are included in an array.
https://binance-docs.github.io/apidocs/futures/en/#mark-price-stream-for-all-market
:param fast: use faster or 1s default
:param futures_type: use USD-M or COIN-M futures default USD-M
:returns: connection key string if successful, False otherwise
Message Format
.. code-block:: python

    [
        {
            "e": "markPriceUpdate",  // Event type
            "E": 1562305380000,      // Event time
            "s": "BTCUSDT",          // Symbol
            "p": "11185.87786614",   // Mark price
            "r": "0.00030000",       // Funding rate
            "T": 1562306400000       // Next funding time
        }
    ]
z!markPrice@arr@1sz!markPrice@arrr   rn   )r>   r   rg   r   s       r%   all_mark_price_socket*BinanceSocketManager.all_mark_price_socket  s#    . .2)7G'''OOr$   c                 D    U R                  UR                  5       S-   US9$ )a  Start a websocket for a symbol's ticker data
By default all markets are included in an array.
https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-book-ticker-streams
:param symbol: required
:param futures_type: use USD-M or COIN-M futures default USD-M
:returns: connection key string if successful, False otherwise
.. 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
        }
    ]
@bookTickerr   r   r   s      r%   symbol_ticker_futures_socket1BinanceSocketManager.symbol_ticker_futures_socket  s,    * ''LLN]* ( 
 	
r$   c                 D    U R                  UR                  5       S-   US9$ )a  Start a futures websocket for a single symbol's ticker data
https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-ticker-streams
:param symbol: required
:type symbol: str
:param futures_type: use USD-M or COIN-M futures default USD-M
:returns: connection key string if successful, False otherwise
.. code-block:: python
    {
        "e": "24hrTicker",  // Event type
        "E": 123456789,     // Event time
        "s": "BTCUSDT",     // Symbol
        "p": "0.0015",      // Price change
    }
r   r   r   r   s      r%   'individual_symbol_ticker_futures_socket<BinanceSocketManager.individual_symbol_ticker_futures_socket  s,    " ''LLNY&\ ( 
 	
r$   !bookTickerchannelc                      U R                  XS9$ )a-  Start a websocket for all ticker data
By default all markets are included in an array.

https://binance-docs.github.io/apidocs/futures/en/#all-book-tickers-stream

https://binance-docs.github.io/apidocs/futures/en/#all-market-tickers-streams

:param channel: optional channel type, default '!bookTicker', but '!ticker@arr' is also available
:param: futures_type: use USD-M or COIN-M futures default USD-M
: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
        }
    ]
r   r   )r>   r   rg   s      r%   all_ticker_futures_socket.BinanceSocketManager.all_ticker_futures_socket  s    : '''KKr$   c                 F    U R                  UR                  5       S-   5      $ )a  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

: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
    }

r   r   r   s     r%   symbol_book_ticker_socket.BinanceSocketManager.symbol_book_ticker_socket'  s     0  >??r$   c                 $    U R                  S5      $ )am  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

:returns: connection key string if successful, False otherwise

Message Format

.. code-block:: python

    {
        // Same as <symbol>@bookTicker payload
    }

r   r   r   s    r%   book_ticker_socket'BinanceSocketManager.book_ticker_socketA  s      ..r$   streamsc                 J    SSR                  U5       3nU R                  USS9$ )a,  Start a multiplexed socket using a list of socket names.
User stream sockets can not be included.

Symbols in socket name must be lowercase i.e bnbbtc@aggTrade, neobtc@ticker

Combined stream events are wrapped as follows: {"stream":"<streamName>","data":<rawPayload>}

https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md

:param streams: list of stream names in lower case
:type streams: list

:returns: connection key string if successful, False otherwise

Message Format - see Binance API docs for all types

streams=/stream?rL   )joinr_   )r>   r   rK   s      r%   multiplex_socket%BinanceSocketManager.multiplex_socketS  s0    $ #((7+,-Y77r$   c                 x    SR                  U Vs/ s H  o"PM     sn5      nSU 3nU R                  USS9$ s  snf )zStart a multiplexed socket using a list of socket names.

https://developers.binance.com/docs/derivatives/option/websocket-market-streams

r   r   r   r   )r   rq   )r>   r   sr   stream_paths        r%   options_multiplex_socket-BinanceSocketManager.options_multiplex_socketh  sH     hh737a734 .''I'FF  4s   7c                 L    SSR                  U5       3nU R                  USUS9$ )aW  Start a multiplexed socket using a list of socket names.
User stream sockets can not be included.

Symbols in socket name must be lowercase i.e bnbbtc@aggTrade, neobtc@ticker

Combined stream events are wrapped as follows: {"stream":"<streamName>","data":<rawPayload>}

https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md

:param streams: list of stream names in lower case
:param futures_type: use USD-M or COIN-M futures default USD-M

:returns: connection key string if successful, False otherwise

Message Format - see Binance API docs for all types

r   r   r   r   )r   rn   )r>   r   rg   rK   s       r%   futures_multiplex_socket-BinanceSocketManager.futures_multiplex_socketr  s9    ( #((7+,-'' ( 
 	
r$   c                     U R                   nU R                  (       a  U R                  nOU R                  (       a  U R                  nU R                  SUS9$ )a4  Start a websocket for user data

https://github.com/binance-exchange/binance-official-api-docs/blob/master/user-data-stream.md
https://binance-docs.github.io/apidocs/spot/en/#listen-key-spot

:returns: connection key string if successful, False otherwise

Message Format - see Binance API docs for all types
userrB   r0   r:   rE   r;   rF   re   rG   s     r%   user_socket BinanceSocketManager.user_socket  sG     __
<<00JYY--J'':'FFr$   c                     U R                   nU R                  (       a  U R                  nOU R                  (       a  U R                  nU R                  SUS9$ )zStart a websocket for futures user data

https://binance-docs.github.io/apidocs/futures/en/#user-data-streams

:returns: connection key string if successful, False otherwise

Message Format - see Binanace API docs for all types
futuresr   r3   r:   rj   r;   rk   re   rG   s     r%   futures_user_socket(BinanceSocketManager.futures_user_socket  sI     %%
<<11JYY..J''	j'IIr$   c                 6    U R                  SU R                  S9$ )zStart a websocket for coin futures user data

https://binance-docs.github.io/apidocs/delivery/en/#user-data-streams

:returns: connection key string if successful, False otherwise

Message Format - see Binanace API docs for all types
coin_futuresr   )re   r4   r   s    r%   coin_futures_user_socket-BinanceSocketManager.coin_futures_user_socket  s      ''4CSCS'TTr$   c                     U R                   nU R                  (       a  U R                  nOU R                  (       a  U R                  nU R                  SUS9$ )zStart a websocket for cross-margin data

https://binance-docs.github.io/apidocs/spot/en/#listen-key-margin

:returns: connection key string if successful, False otherwise

Message Format - see Binance API docs for all types
marginr   r   rG   s     r%   margin_socket"BinanceSocketManager.margin_socket  sG     __
<<00JYY--J''Z'HHr$   c                     U R                   nU R                  (       a  U R                  nOU R                  (       a  U R                  nU R                  SUS9$ )zStart a websocket for futures data

    https://binance-docs.github.io/apidocs/futures/en/#websocket-market-streams

:returns: connection key string if successful, False otherwise

Message Format - see Binance API docs for all types
r   r   r   rG   s     r%   futures_socket#BinanceSocketManager.futures_socket  sI     %%
<<11JYY..J''	j'IIr$   c                     U R                   nU R                  (       a  U R                  nOU R                  (       a  U R                  nU R                  SUS9$ )zStart a websocket for coin futures data

    https://binance-docs.github.io/apidocs/delivery/en/#websocket-market-streams

:returns: connection key string if successful, False otherwise

Message Format - see Binance API docs for all types
r   r   )r4   r:   rl   r;   rm   re   rG   s     r%   coin_futures_socket(BinanceSocketManager.coin_futures_socket  sI     %%
<<11JYY..J'':'NNr$   c                     U R                   nU R                  (       a  U R                  nOU R                  (       a  U R                  nUS-  nU R                  SUS9$ )zStart a websocket for portfolio margin user data

    https://developers.binance.com/docs/derivatives/portfolio-margin/user-data-streams

:returns: connection key string if successful, False otherwise

Message Format - see Binance API docs for all types
zpm/portfolio_marginr   r   rG   s     r%   portfolio_margin_socket,BinanceSocketManager.portfolio_margin_socket  sT     %%
<<11JYY..Je
''(:z'RRr$   c                     U R                   nU R                  (       a  U R                  nOU R                  (       a  U R                  nU R                  XS9$ )a@  Start a websocket for isolated margin data

https://binance-docs.github.io/apidocs/spot/en/#listen-key-isolated-margin

:param symbol: required - symbol for the isolated margin account
:type symbol: str

:returns: connection key string if successful, False otherwise

Message Format - see Binance API docs for all types
r   r   )r>   rv   rB   s      r%   isolated_margin_socket+BinanceSocketManager.isolated_margin_socket  sE     __
<<00JYY--J'''FFr$   c                 F    U R                  UR                  5       S-   5      $ )a  Subscribe to a 24-hour ticker info stream for options trading.

API Reference: https://developers.binance.com/docs/derivatives/option/websocket-market-streams/24-hour-TICKER

Stream provides real-time 24hr ticker information for all symbols. Only symbols whose ticker info 
changed will be sent. Updates every 1000ms.

:param symbol: The option symbol to subscribe to (e.g. "BTC-220930-18000-C")
:type symbol: str
r   rq   upperr   s     r%   options_ticker_socket*BinanceSocketManager.options_ticker_socket  s      ''(BCCr$   expiration_datec                 L    U R                  UR                  5       S-   U-   5      $ )a  Subscribe to a 24-hour ticker info stream by underlying asset and expiration date.

API Reference: https://developers.binance.com/docs/derivatives/option/websocket-market-streams/24-hour-TICKER-by-underlying-asset-and-expiration-data

Stream provides real-time 24hr ticker information grouped by underlying asset and expiration date.
Updates every 1000ms.

:param symbol: The underlying asset (e.g., "ETH")
:type symbol: str
:param expiration_date: The expiration date (e.g., "220930" for Sept 30, 2022)
:type expiration_date: str
z@ticker@r  r>   rv   r
  s      r%   #options_ticker_by_expiration_socket8BinanceSocketManager.options_ticker_by_expiration_socket  s%     ''(Co(UVVr$   c                 F    U R                  UR                  5       S-   5      $ )ar  Subscribe to a real-time trade information stream.

API Reference: https://developers.binance.com/docs/derivatives/option/websocket-market-streams/Trade-Streams

Stream pushes raw trade information for a specific symbol or underlying asset.
Updates every 50ms.

:param symbol: The option symbol or underlying asset (e.g., "BTC-200630-9000-P" or "BTC")
:type symbol: str
r   r  r   s     r%   options_recent_trades_socket1BinanceSocketManager.options_recent_trades_socket*  s      ''(ABBr$   c                 L    U R                  UR                  5       S-   U-   5      $ )a)  Subscribe to a Kline/Candlestick data stream.

API Reference: https://developers.binance.com/docs/derivatives/option/websocket-market-streams/Kline-Candlestick-Streams

Stream pushes updates to the current klines/candlestick every 1000ms (if existing).

Available intervals:
- Minutes: "1m", "3m", "5m", "15m", "30m"
- Hours: "1h", "2h", "4h", "6h", "12h"
- Days: "1d", "3d"
- Weeks: "1w"

:param symbol: The option symbol (e.g., "BTC-200630-9000-P")
:type symbol: str
:param interval: Kline interval, default KLINE_INTERVAL_1MINUTE
:type interval: str
r   r  )r>   rv   rx   s      r%   options_kline_socket)BinanceSocketManager.options_kline_socket7  s%    ( ''(BX(MNNr$   c                 ^    U R                  UR                  5       S-   [        U5      -   5      $ )a  Subscribe to partial book depth stream for options trading.

API Reference: https://developers.binance.com/docs/derivatives/option/websocket-market-streams/Partial-Book-Depth-Streams

Stream provides top N bids and asks from the order book.
Default update speed is 500ms if not specified in the stream name.

:param symbol: The option symbol (e.g., "BTC-200630-9000-P")
:type symbol: str
:param depth: Number of price levels. Valid values: "10", "20", "50", "100"
:type depth: str
rz   )rq   r  str)r>   rv   rw   s      r%   options_depth_socket)BinanceSocketManager.options_depth_socketM  s)     ''(ACJ(NOOr$   c                 \    U R                  UR                  5       S-   [        U5      -   US9$ )a9  Subscribe to a futures depth data stream

https://binance-docs.github.io/apidocs/futures/en/#partial-book-depth-streams

:param symbol: required
:type symbol: str
:param depth: optional Number of depth entries to return, default 10.
:type depth: str
:param futures_type: use USD-M or COIN-M futures default USD-M
rz   r   )rn   r~   r  )r>   rv   rw   rg   s       r%   futures_depth_socket)BinanceSocketManager.futures_depth_socket\  s5     ''LLNX%E
2 ( 
 	
r$   c                 $    U R                  S5      $ )a6  Subscribe to a new symbol listing information stream.

Stream provides real-time notifications when new option symbols are listed.
Updates every 50ms.

Stream name: option_pair

API Reference: https://developers.binance.com/docs/derivatives/option/websocket-market-streams/New-Symbol-Info

Response fields include:
- Event type and timestamps
- Underlying index (e.g., 'BTCUSDT')
- Quotation asset (e.g., 'USDT')
- Trading pair name (e.g., 'BTC-221116-21000-C')
- Conversion ratio and minimum trade volume
- Option type (CALL/PUT)
- Strike price and expiration time
option_pair)rq   r   s    r%   options_new_symbol_socket.BinanceSocketManager.options_new_symbol_socketk  s    & ''66r$   c                 L    U R                  UR                  5       S-   U-   5      $ )a  Subscribe to an options open interest stream.

Stream provides open interest information for specific underlying asset on specific expiration date.
Updates every 60 seconds.

Stream name format: <underlyingAsset>@openInterest@<expirationDate>

API Reference: https://developers.binance.com/docs/derivatives/option/websocket-market-streams/Open-Interest

Response fields include:
- Event type and timestamps
- Option symbol (e.g., 'ETH-221125-2700-C')
- Open interest in contracts
- Open interest in USDT

:param symbol: The underlying asset (e.g., "ETH")
:type symbol: str
:param expiration_date: The expiration date (e.g., "221125" for Nov 25, 2022)
:type expiration_date: str
z@openInterest@r  r  s      r%   options_open_interest_socket1BinanceSocketManager.options_open_interest_socket  s&    * ''9I(IO([\\r$   c                 F    U R                  UR                  5       S-   5      $ )a  Subscribe to an options mark price stream.

Stream provides mark price information for all option symbols on specific underlying asset.
Updates every 1000ms.

Stream name format: <underlyingAsset>@markPrice

API Reference: https://developers.binance.com/docs/derivatives/option/websocket-market-streams/Mark-Price

Response fields include:
- Event type and timestamps
- Option symbol (e.g., 'ETH-220930-1500-C')
- Option mark price

:param symbol: The underlying asset (e.g., "ETH")
:type symbol: str
r   r  r   s     r%   options_mark_price_socket.BinanceSocketManager.options_mark_price_socket  s     $ ''(EFFr$   c                 F    U R                  UR                  5       S-   5      $ )a  Subscribe to an options index price stream.

API Reference: https://developers.binance.com/docs/derivatives/option/websocket-market-streams/Index-Price-Streams

Stream provides index price information for underlying assets (e.g., ETHUSDT).
Updates every 1000ms.

Response fields include:
- Event type and timestamps
- Underlying symbol (e.g., 'ETHUSDT')
- Index price

:param symbol: The underlying symbol (e.g., "ETHUSDT")
:type symbol: str
z@indexr  r   s     r%   options_index_price_socket/BinanceSocketManager.options_index_price_socket  s       ''(ABBr$   c                 F   #    XR                   ;  a  gU R                   U	 g7f)zyStop a websocket given the connection key

:param conn_key: Socket connection key
:type conn_key: string

:returns: None
N)r6   )r>   conn_keys     r%   rt   !BinanceSocketManager._stop_socket  s       ;;&KK!s   !)r4   r3   r5   r0   r8   r6   r7   r<   r9   r;   r:   r=   rD   )NrJ   F)zstream?streams=)rJ   NNi  Tr*   )Sr   r   r   r   r0   rE   rF   r3   rj   rk   r4   rl   rm   r5   WEBSOCKET_DEPTH_5WEBSOCKET_DEPTH_10WEBSOCKET_DEPTH_20r	   r   intr@   r   r  rH   r   r   boolr   r_   r
   re   r   rn   rq   rU   r   KLINE_INTERVAL_1MINUTEr   ri   r   	PERPETUALr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r!  r$  r'  rt   r#   r   r$   r%   r'   r'      s   0J?6O-K;9-K<97K
 '!	 	8(3-  %)):)?)?$$ SM$ 	$
 $ '$ 
$: %)$$ SM$ 	$
 $ 
$0 CTSS'2S<?S$
 
S 
&s & SWL-L-"*3-L-BJ3-L-\ 2=1S1S *&3 *&^ 33$/$5$5&2&<&<4W4W "	4W
 $4WlDS D@;3 ;@>c >@ 8C7H7H

)4
@@s @:)<3 )<V*/X$JL$KL
 
D 
0 $/$5$5	

 
 "	
:  [=N=NPP/:P6 8C7H7H

)4
4 8C7H7H

)4
. %$/$5$5LL "L>@ @4/$8S	 8*GS	 G ?J>O>O
Cy
0;
2G"J"
UI"J O S"GS G&DC DW# WPS WC3 C %0$F$FOO,P3 Ps P >BP[PaPa 
3 
s 
7*]3 ] ].G G(C C$"r$   r'   c                   |  ^  \ rS rSr         SAS\\   S\\   S\\\\4      S\S\S\\\\4      S\\   S	\\	R                     S
\4U 4S jjjrS r SBS\S\S\\\4   S\\   S\4
S jjr  SCS\S\S\\   S\\   S\4
S jjr\R$                  4S\S\S\4S jjr\R$                  \R*                  \R.                  4S\S\S\S\S\4
S jjr SDS\S\S\4S jjrS\S\S\4S jrS\S\S\4S jr\R*                  4S\S\S\S\4S jjrS\S\S\4S  jrS\S\S\4S! jrS\S\4S" jr SES\S\S$\S\4S% jjr S#\R*                  4S\S\S$\S\S\4
S& jjr!S#\R*                  4S\S$\S\S\4S' jjr"\R*                  4S\S\S\S\4S( jjr#\R*                  4S\S\S\S\4S) jjr$\R*                  4S\S\S\4S* jjr%S\S\S\4S+ jr&S\S\4S, jr'S\S-\(\   S\4S. jr)S\S-\(\   S\4S/ jr*\R*                  4S\S-\(\   S\S\4S0 jjr+S\S\4S1 jr,S\S\4S2 jr-S\S\4S3 jr.S\S\4S4 jr/S\S\4S5 jr0S\S\4S6 jr1S\S\S\4S7 jr2S\S\S\4S8 jr3S\S\S9\S\4S: jr4S\S\S\4S; jr5\R$                  4S\S\S\4S< jjr6 SFS\S\S\S\4S> jjr7S=\R*                  4S\S\S\S\4S? jjr8S@r9U =r:$ )GThreadedWebsocketManageri  api_key
api_secretrequests_paramsr2   r:   session_paramsr[   loopr.   c
           
      L   > [         T
U ]  UUUUUUUU5        S U l        Xl        g rD   )superr@   _bsmr<   )r>   r9  r:  r;  r2   r:   r<  r[   r=  r.   	__class__s             r%   r@   !ThreadedWebsocketManager.__init__  s9     			
 59	-r$   c                 x   #    U R                   (       d   e[        U R                   U R                  S9U l        g 7f)N)r-   r.   )r8   r'   r<   r@  r   s    r%   _before_socket_listener_start6ThreadedWebsocketManager._before_socket_listener_start  s-     |||(<<//
	s   8:callbackr   paramsrK   rO   c                    [         R                   " 5       nU R                  (       dP  [         R                   " 5       U-
  S:  a  [        S5      e[         R                  " S5        U R                  (       d  MP  [	        U R                  U5      " S0 UD6nU=(       d    UR
                  nSU R                  U'   U R                  R                  [        R                  U R                  XgU5      5        U$ )N   z;Binance Socket Manager failed to initialize after 5 secondsg?Tr   )timer@  RuntimeErrorsleepr\   _path_socket_runningr7   call_soon_threadsafeasynciocreate_taskstart_listener)r>   rF  r   rG  rK   
start_timesocketsocket_paths           r%   _start_async_socket,ThreadedWebsocketManager._start_async_socket  s     YY[
))yy{Z'!+"#`aaJJsO ))) K0:6:/6<<,0[)

''!4!4V(!S	
 r$   rv   rw   rx   c                 ,    U R                  USUUUS.S9$ )Nr   )rv   rw   rx   rF  r   rG  rV  )r>   rF  rv   rw   rx   s        r%   start_depth_socket+ThreadedWebsocketManager.start_depth_socket   s0     ''& $ ( 
 	
r$   c                 *    U R                  USUUS.S9$ )Nr   rv   rx   rY  rZ  r>   rF  rv   rx   s       r%   start_kline_socket+ThreadedWebsocketManager.start_kline_socket  s-     ''& $ ( 
 	
r$   rg   r   c           	      .    U R                  USUUUUS.S9$ )Nr   )rv   rx   rg   r   rY  rZ  )r>   rF  rv   rx   rg   r   s         r%   start_kline_futures_socket3ThreadedWebsocketManager.start_kline_futures_socket   s3     ''. $ ,!.	 ( 	
 		
r$   r   c                 (    U R                  USSU0S9$ )Nr   r   rY  rZ  )r>   rF  r   s      r%   start_miniticker_socket0ThreadedWebsocketManager.start_miniticker_socket3  s,     ''+{ ( 
 	
r$   c                 (    U R                  USSU0S9$ )Nr   rv   rY  rZ  r>   rF  rv   s      r%   start_trade_socket+ThreadedWebsocketManager.start_trade_socket>  s*    ''&& ( 
 	
r$   c                 (    U R                  USSU0S9$ )Nr   rv   rY  rZ  ri  s      r%   start_aggtrade_socket.ThreadedWebsocketManager.start_aggtrade_socketG  s*    '')& ( 
 	
r$   c                 *    U R                  USUUS.S9$ )Nr   rv   rg   rY  rZ  r>   rF  rv   rg   s       r%   start_aggtrade_futures_socket6ThreadedWebsocketManager.start_aggtrade_futures_socketP  s-     ''1  , ( 
 	
r$   c                 (    U R                  USSU0S9$ )Nr   rv   rY  rZ  ri  s      r%   start_symbol_miniticker_socket7ThreadedWebsocketManager.start_symbol_miniticker_socket_  s*    ''2& ( 
 	
r$   c                 (    U R                  USSU0S9$ )Nr   rv   rY  rZ  ri  s      r%   start_symbol_ticker_socket3ThreadedWebsocketManager.start_symbol_ticker_socketh  s*    ''.& ( 
 	
r$   c                 $    U R                  US0 S9$ )Nr   rY  rZ  r>   rF  s     r%   start_ticker_socket,ThreadedWebsocketManager.start_ticker_socketq  !    ''?2 ( 
 	
r$   Tr   c                 (    U R                  USX#S.S9$ )Nr   )rv   r   rY  rZ  )r>   rF  rv   r   s       r%   start_index_price_socket1ThreadedWebsocketManager.start_index_price_socketv  s(     '',$3 ( 
 	
r$   c                 *    U R                  USX#US.S9$ )Nr   )rv   r   rg   rY  rZ  )r>   rF  rv   r   rg   s        r%   start_symbol_mark_price_socket7ThreadedWebsocketManager.start_symbol_mark_price_socket  s*     ''2$LQ ( 
 	
r$   c                 (    U R                  USX#S.S9$ )Nr   )r   rg   rY  rZ  )r>   rF  r   rg   s       r%   start_all_mark_price_socket4ThreadedWebsocketManager.start_all_mark_price_socket  s(     ''/ ? ( 
 	
r$   c                 (    U R                  USX#S.S9$ )Nr   rp  rY  rZ  rq  s       r%   "start_symbol_ticker_futures_socket;ThreadedWebsocketManager.start_symbol_ticker_futures_socket  s(     ''6$C ( 
 	
r$   c                 (    U R                  USX#S.S9$ )Nr   rp  rY  rZ  rq  s       r%   -start_individual_symbol_ticker_futures_socketFThreadedWebsocketManager.start_individual_symbol_ticker_futures_socket  s(     ''A$C ( 
 	
r$   c                 (    U R                  USSU0S9$ )Nr   rg   rY  rZ  )r>   rF  rg   s      r%   start_all_ticker_futures_socket8ThreadedWebsocketManager.start_all_ticker_futures_socket  s*     ''3"L1 ( 
 	
r$   c                 (    U R                  USSU0S9$ )Nr   rv   rY  rZ  ri  s      r%   start_symbol_book_ticker_socket8ThreadedWebsocketManager.start_symbol_book_ticker_socket  s(    ''3f% ( 
 	
r$   c                 $    U R                  US0 S9$ )Nr   rY  rZ  r{  s     r%   start_book_ticker_socket1ThreadedWebsocketManager.start_book_ticker_socket  s"    ''+? ( 
 	
r$   r   c                 (    U R                  USSU0S9$ )Nr   r   rY  rZ  r>   rF  r   s      r%   start_multiplex_socket/ThreadedWebsocketManager.start_multiplex_socket  s(    ''*w' ( 
 	
r$   c                 (    U R                  USSU0S9$ )Nr   r   rY  rZ  r  s      r%   start_options_multiplex_socket7ThreadedWebsocketManager.start_options_multiplex_socket  s*     ''2w' ( 
 	
r$   c                 (    U R                  USX#S.S9$ )Nr   )r   rg   rY  rZ  )r>   rF  r   rg   s       r%   start_futures_multiplex_socket7ThreadedWebsocketManager.start_futures_multiplex_socket  s(     ''2&E ( 
 	
r$   c                 $    U R                  US0 S9$ )Nr   rY  rZ  r{  s     r%   start_user_socket*ThreadedWebsocketManager.start_user_socket  s!    ''= ( 
 	
r$   c                 $    U R                  US0 S9$ )Nr   rY  rZ  r{  s     r%   start_futures_user_socket2ThreadedWebsocketManager.start_futures_user_socket  "    ''+@ ( 
 	
r$   c                 $    U R                  US0 S9$ )Nr   rY  rZ  r{  s     r%   start_coin_futures_user_socket7ThreadedWebsocketManager.start_coin_futures_user_socket  s"    ''+Eb ( 
 	
r$   c                 $    U R                  US0 S9$ )Nr   rY  rZ  r{  s     r%   start_margin_socket,ThreadedWebsocketManager.start_margin_socket  r~  r$   c                 $    U R                  US0 S9$ )Nr   rY  rZ  r{  s     r%   start_futures_socket-ThreadedWebsocketManager.start_futures_socket  s"    ''+;B ( 
 	
r$   c                 $    U R                  US0 S9$ )Nr   rY  rZ  r{  s     r%   start_coin_futures_socket2ThreadedWebsocketManager.start_coin_futures_socket  r  r$   c                 (    U R                  USSU0S9$ )Nr  rv   rY  rZ  ri  s      r%   start_isolated_margin_socket5ThreadedWebsocketManager.start_isolated_margin_socket  s(    ''0f% ( 
 	
r$   c                 (    U R                  USSU0S9$ )Nr  rv   rY  rZ  ri  s      r%   start_options_ticker_socket4ThreadedWebsocketManager.start_options_ticker_socket  s(    ''/f% ( 
 	
r$   r
  c                 (    U R                  USX#S.S9$ )Nr  )rv   r
  rY  rZ  )r>   rF  rv   r
  s       r%   )start_options_ticker_by_expiration_socketBThreadedWebsocketManager.start_options_ticker_by_expiration_socket  s(     ''=$I ( 
 	
r$   c                 (    U R                  USSU0S9$ )Nr  rv   rY  rZ  ri  s      r%   "start_options_recent_trades_socket;ThreadedWebsocketManager.start_options_recent_trades_socket  s*     ''6f% ( 
 	
r$   c                 (    U R                  USX#S.S9$ )Nr  r^  rY  rZ  r_  s       r%   start_options_kline_socket3ThreadedWebsocketManager.start_options_kline_socket  s(     ''.$; ( 
 	
r$   r*   c                 (    U R                  USX#S.S9$ )Nr  )rv   rw   rY  rZ  )r>   rF  rv   rw   s       r%   start_options_depth_socket3ThreadedWebsocketManager.start_options_depth_socket+  s(     ''.$5 ( 
 	
r$   c                 *    U R                  USX#US.S9$ )Nr  )rv   rw   rg   rY  rZ  )r>   rF  rv   rw   rg   s        r%   start_futures_depth_socket3ThreadedWebsocketManager.start_futures_depth_socket4  s*     ''.$lS ( 
 	
r$   )r@  r<   )	NNNcomFNNNr,   rD   r,  r-  r.  r/  );r   r   r   r   r   r  r   r   r4  rP  AbstractEventLoopr3  r@   rD  r   rV  r[  r   r5  r`  r   ri   r   r6  rc  rf  rj  rm  rr  ru  rx  r|  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r#   __classcell__)rA  s   @r%   r8  r8    s    "&$(4837%)48!.#. SM. "$sCx.1	.
 . . !c3h0. c]. w001. . .2
 #  S#X	
 sm 
0  $"&

 
 }	

 3-
 

* 33	

 

 

& 33$/$5$5&2&<&<

 

 "
 $
 

( 6:	
 	
/2	
		

8 
S 
S 

h 
 
 
 %0$5$5	

 
 "	

 


x 
 
QT 

8 
S 
S 

H 
 
 =A
 
*-
59
	
 $/$5$5

 
 	

 "
 

  $/$5$5	



 

 "	


 


  %0$5$5	



 

 "	


 


  %0$5$5	



 

 "	


 


 ?J>O>O
 
0;
	

 
# 
RU 

 
c 


x 
$s) 
PS 

 
+/9
	
 %0$5$5	



 c

 "	


 



( 
s 


( 
s 


x 
C 


H 
 


X 
# 


( 
s 


X 
s 
s 

H 
c 
c 

 
*-
@C
	

 
*-
	
 33	



 


 


 =A
 
*-
69
	
  &&

 
 	
 

 
r$   r8  )rP  rJ  enumr   typingr   r   r   r   r   binance.ws.constantsr	   binance.ws.keepalive_websocketr
   !binance.ws.reconnecting_websocketr   binance.ws.threaded_streamr   binance.async_clientr   binance.enumsr   r   binance.helpersr   r  r   r'   r8  r   r$   r%   <module>r     sX       6 6 2 = C 9 - % & $T n" n"b%t
1 t
r$   