
    i~                         d dl Zd dlmZmZmZ d dlmZmZm	Z	m
Z
mZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ  G d	 d
ej        j                  ZdS )    N)
ArrayCacheArrayCacheBySymbolByIdArrayCacheByTimestamp)BalancesIntOrder	OrderBookStrTickerTrade)Client)List)
BadRequest)NetworkError)Precisec            
           e Zd Z fdZi fdedefdZdefdZd!dZ	ddi fded	e
d
e
dee         fdZdefdZdi fded
e
defdZd ZdefdZd!defdZdefdZdddi fded	e
d
e
dee         fdZdddi fded	e
d
e
dee         fdZdddi fded	e
d
e
dee         fdZi fdefdZdefdZd Zd Zi fdZ i fdZ!d Z"d Z#defdZ$defdZ%defd Z& xZ'S )"bingxc                     |                      t          t          |                                           dddddddddd	dddddiid	d
diddddddddddddddddiddddddd d!iddd"d#d$d%id&          S )'NTF)	wswatchTradeswatchOrderBook
watchOHLCVwatchOrderswatchMyTradeswatchTickerwatchTickerswatchBalanceapir   z"wss://open-api-ws.bingx.com/marketz)wss://open-api-swap.bingx.com/swap-market)spotswapi 6 gunzip
timeframes1m3m5m15m30m1h2h4h6h12h1d3d1w1M)r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   1min5min15min30min60min1day)r#   r%   r&   r'   r(   r-   )fetchBalanceSnapshotawaitBalanceSnapshot)listenKeyRefreshRater   r    r   r   	keepAlivei@w )hasurlsoptions	streaming)deep_extendsuperr   describe)self	__class__s    T/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/pro/bingx.pyrA   zbingx.describe   s$   eT 2 2 ; ; = =#"&"#!%# % $
 
  D K  )0d !"""$$""""$""""# #& !$$&&%$# #	 -1,1! !C% %N Wu=@
 =@
 = = =	    symbolreturnc                   K   |                                   d{V  |                     |          }|                     d||          \  }}|                     | j        d         d         |          }|t          | j        dz   |z   dz             |d         dz   }|                                 }||d	}	|d
k    rd|	d<   |                     ||| 	                    |	|          |           d{V S )a  
        watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://bingx-api.github.io/docs/#/en-us/swapV2/socket/market.html#Subscribe%20to%2024-hour%20price%20changes
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   r   r   " watchTrades is not supported for 	 markets.id@tickerrK   dataTyper    subreqType)
load_marketsmarkethandle_market_type_and_params
safe_valuer<   r   rK   uuidwatchextend)
rB   rF   paramsrR   
marketTypequeryurlmessageHashrU   requests
             rD   watch_tickerzbingx.watch_tickerR   s      !!!!!!!!!V$$ >>}fV\]]
Eoodi.t4jAA;TW'KKjX[ffgggTlY.yy{{#
 
 !&GIZZ[$++gu2M2M{[[[[[[[[[rE   clientc                 j   |                      |di           }|                     |d          }|j                            d          dk    }|rdnd}|                     |d d |          }|d         }|                     ||          }	|	| j        |<   |d         dz   }
|                    |	|
           d S )	Ndatasr    r   r   rF   rK   rL   )rT   safe_stringr[   findsafe_marketparse_ws_tickertickersresolve)rB   r_   messagera   marketIdisSwaprY   rR   rF   tickerr\   s              rD   handle_tickerzbingx.handle_tickerj   s    n w33##D#..((A-%1VV6
!!(D$
CC!%%dF33%VTlY.v{+++++rE   Nc                    |                      |d          }|                     |d          }|                     ||          }|                     |d          }|                     i d|d         d|d|                     |          d|                     |d          d	|                     |d
          d|                     |d          d|                     |d          d|                     |d          d|                     |d          dd d|                     |d          d|d|dd d|                     |d          dd dd |                     |d          |                     |d          |d|          S ) Ntsrb   crF   	timestampdatetimehighhlowlbidB	bidVolumebaskA	askVolumeavwapopenocloselastpreviousClosechangep
percentageaveragevq)
baseVolumequoteVolumeinfo)safe_integerrc   re   safe_tickeriso8601)rB   ri   rR   rq   rj   r   s         rD   rf   zbingx.parse_ws_ticker   s   . %%gt44	##GS11!!(F33  #.. !
fX&!
!
 Y//!
 D$$Wc22	!

 4##GS11!
 4##GS11!
 ))'377!
 4##GS11!
 ))'377!
 D!
 D$$Wc22!
 U!
 E!
 T!
 d&&w44!
  $!!
" t#!
$ **7C88++GS99)!
 !
 !
* +  	rE   sincelimitc                 R  K   |                                   d{V  |                     |          }|                     d||          \  }}|                     | j        d         d         |          }|t          | j        dz   |z   dz             |d         dz   }	|                                 }
|
|	d	}|d
k    rd|d<   |                     ||	| 	                    ||          |	           d{V }| j
        r|                    ||          }|                     |||dd          S )a  
        watches information on multiple trades made in a market
        :see: https://bingx-api.github.io/docs/#/spot/socket/market.html#Subscribe%20to%20tick-by-tick
        :see: https://bingx-api.github.io/docs/#/swapV2/socket/market.html#Subscribe%20the%20Latest%20Trade%20Detail
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
        Nr   r   r   rI   rJ   rK   @traderM   r    rO   rP   rq   T)rQ   rR   rS   rT   r<   r   rK   rU   rV   rW   
newUpdatesgetLimitfilter_by_since_limit)rB   rF   r   r   rX   rR   rY   rZ   r[   r\   rU   r]   tradess                rD   watch_tradeszbingx.watch_trades   sT      !!!!!!!!!V$$ >>}fV\]]
Eoodi.t4jAA;TW'KKjX[ffgggTlX-yy{{#
 
 !&GIzz#{DKK4O4OQ\]]]]]]]]? 	3OOFE22E))&%TRRRrE   c                    |                      |dg           }|                     |d          }|                    d          d         }|j                            d          dk    }|rdnd}|                     |d d |          }|d         }	d }
t          |t                    r|                     ||          }
n| 	                    ||          g}
|                      | j
        |	          }|5|                     | j        dd	          }t          |          }|| j
        |	<   t          dt          |
                    D ]}|                    |
|                    |                    ||           d S )
Nra   rN   @r   r    r   rF   tradesLimit  )rT   rc   splitr[   rd   re   
isinstancelistparse_tradesparse_trader   r   r=   r   rangelenappendrh   )rB   r_   ri   ra   r\   rj   rk   rY   rR   rF   r   storedr   js                 rD   handle_tradeszbingx.handle_trades   st   x w33&&w
;;$$S))!,((A-%1VV6
!!(D$
CC!dD!! 	6&&tV44FF&&tV445Ff55>%%dlM4HHE&&F"(DKq#f++&& 	% 	%AMM&)$$$$v{+++++rE   c                   K   |                                   d{V  |                     |          }|                     d||          \  }}|d}ne|dk    r6|dk    r/|dk    r)|dk    r#|dk    r|dk    rt          | j        d	z             n)|d
k    r#|dk    r|dk    rt          | j        dz             |                     | j        d         d         |          }|t          | j        dz   |z   dz             |d         dz   t          |          z   }|                                 }	|	|d}
|dk    rd|
d<   | 	                    ||| 
                    |
|          |           d{V }|                                S )a  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: https://bingx-api.github.io/docs/#/spot/socket/market.html#Subscribe%20Market%20Depth%20Data
        :see: https://bingx-api.github.io/docs/#/swapV2/socket/market.html#Subscribe%20Market%20Depth%20Data
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        Nr   d   r       
      2   zB watchOrderBook()(swap) only supports limit 5, 10, 20, 50, and 100r   z7 watchOrderBook()(spot) only supports limit 20, and 100r   r   z% watchOrderBook is not supported for rJ   rK   @depthrM   rO   rP   )rQ   rR   rS   r   rK   rT   r<   strrU   rV   r?   r   )rB   rF   r   rX   rR   rY   rZ   r[   r\   rU   r]   	orderbooks               rD   watch_order_bookzbingx.watch_order_bookN  s      !!!!!!!!!V$$ >>?OQWY_``
E=EEV##QJJUb[[u{{RT[`dg[g[g$TW/s%stttv%%RKKesll$TW/h%hiiioodi.t4jAA;TW'NNQ[[^iijjjTlX-E

:yy{{#
 
 !&GI**S+t7G7GQV7W7WYdeeeeeeee	   rE   c                     |                      |d          }|                      |d          }|                    ||           d S )Nr      )
safe_floatstore)rB   booksidedeltapriceamounts        rD   handle_deltazbingx.handle_deltar  sB    q))**uf%%%%%rE   c           	          |                      |dg           }|                     |d          }|                    d          d         }|j                            d          dk    }|rdnd}|                     |d d |          }|d         }	|                      | j        |	          }
|
|                                 }
|                     ||	d dd	dd
          }|
	                    |           |
| j        |	<   |
                    |
|           d S )Nra   rN   r   r   r    r   rF   bidsasksr   )rT   rc   r   r[   rd   re   
orderbooks
order_bookparse_order_bookresetrh   )rB   r_   ri   ra   r\   rj   rk   rY   rR   rF   r   snapshots               rD   handle_order_bookzbingx.handle_order_bookw  s   P w33&&w
;;$$S))!,((A-%1VV6
!!(D$
CC!OODOV<<	))I((vtVVQPQRR!!!"+y+.....rE   c           	         |d         rdnd}|                      ||          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )	Nr   tTr   rt   rv   rp   r   )r   safe_number)rB   ohlcvrR   rq   s       rD   parse_ws_ohlcvzbingx.parse_ws_ohlcv  s     #6N4CC	eY//UC((UC((UC((UC((UC((
 	
rE   c                    |                      |dg           }d }t          |t                    r|}n|                      |dg           g}|                     |d          }|                    d          d         }|                    d          d         }|j                            d          dk    }|rdnd	}	|                     |d d |	          }
|
d
         }|                      | j        |i           | j        |<   |                      | j        |         |          }|;| 	                    | j
        dd          }t          |          }|| j        |         |<   t          dt          |                    D ]5}||         }|                     ||
          }|                    |           6|                    ||           d S )Nra   KrN   _r   r   r   r    r   rF   
OHLCVLimitr   )rT   r   r   rc   r   r[   rd   re   ohlcvsr   r=   r   r   r   r   r   rh   )rB   r_   ri   ra   candlesr\   timeframeIdrj   rk   rY   rR   rF   r   r   icandleparseds                    rD   handle_ohlcvzbingx.handle_ohlcv  s   Z w33dD!! 	7GGtS"556G&&w
;;!'',,Q/$$S))!,((A-%1VV6
!!(D$
CC!"oodk62FFFV!4kBB>%%dlL$GGE*511F/5DK,q#g,,'' 	" 	"AQZF((88FMM&!!!!v{+++++rE   r#   c                   K   |                                   d{V  |                     |          }|                     d||          \  }}|                     | j        d         d         |          }	|	t          | j        dz   |z   dz             |                     | j        |i           }
|                     |
di           }|                     |||          }|d         d	z   |z   }| 	                                }||d
}|dk    rd|d<   | 
                    |	||                     ||          |           d{V }| j        r|                    ||          }|                     |||dd          S )a  
        watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: https://bingx-api.github.io/docs/#/spot/socket/market.html#K%E7%BA%BF%20Streams
        :see: https://bingx-api.github.io/docs/#/swapV2/socket/market.html#Subscribe%20K-Line%20Data
        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        Nr   r   r   z! watchOHLCV is not supported for rJ   r"   rK   z@kline_rM   r    rO   rP   r   T)rQ   rR   rS   rT   r<   r   rK   r=   rc   rU   rV   rW   r   r   r   )rB   rF   	timeframer   r   rX   rR   rY   rZ   r[   r=   r"   intervalr\   rU   r]   r   s                    rD   watch_ohlcvzbingx.watch_ohlcv  s      !!!!!!!!!V$$ >>|VU[\\
Eoodi.t4jAA;TW'JJZWZeefff//$,
B??__WlB??
##J	9EETlY.9yy{{#
 
 !&GIjjk4;;w3N3NP[\\\\\\\\? 	2NN6511E))%q$GGGrE   c                 f  K   |                                   d{V  |                                  d{V  d}d}||                     |          }|d         }|                     d||          \  }}|dk    }d}d}	|r|n|	}
d}d}|r|n|}||d	|z   z  }| j        d
         d         |         dz   | j        d         z   }d}|                                 }|r|dd}|                     ||||
           d{V }| j        r|	                    ||          }| 
                    ||||d          S )a  
        :see: https://bingx-api.github.io/docs/#/spot/socket/account.html#Subscription%20order%20update%20data
        :see: https://bingx-api.github.io/docs/#/swapV2/socket/account.html#Account%20balance%20and%20position%20update%20push
        watches information on multiple orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        NrF   r   r   spot:privateswap:private
spot:order
swap:order:r   r   ?listenKey=	listenKeyspot.executionReportrM   TrQ   authenticaterR   rS   r<   r=   rU   rV   r   r   filter_by_symbol_since_limit)rB   rF   r   r   rX   typerR   isSpotspotHashswapHashsubscriptionHashspotMessageHashswapMessageHashr\   r[   r]   rU   orderss                     rD   watch_orderszbingx.watch_orders.  s      !!!!!!!!!!!!!!!!!![[((FH%F99-QWXXf&.!!'-;888&&)/Doo_3<'Kit$T*]:T\+=VVyy{{ 	2 G zz#{G=MNNNNNNNN? 	3OOFE22E00tTTTrE   c                 f  K   |                                   d{V  |                                  d{V  d}d}||                     |          }|d         }|                     d||          \  }}|dk    }d}d}	|r|n|	}
d}d}|r|n|}||d	|z   z  }| j        d
         d         |         dz   | j        d         z   }d}|                                 }|r|dd}|                     ||||
           d{V }| j        r|	                    ||          }| 
                    ||||d          S )a  
        :see: https://bingx-api.github.io/docs/#/spot/socket/account.html#Subscription%20order%20update%20data
        :see: https://bingx-api.github.io/docs/#/swapV2/socket/account.html#Account%20balance%20and%20position%20update%20push
        watches information on multiple trades made by the user
        :param str symbol: unified market symbol of the market trades were made in
        :param int [since]: the earliest time in ms to trades orders for
        :param int [limit]: the maximum number of trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
        NrF   r   r   r   r   spot:mytradesswap:mytradesr   r   r   r   r   r   rM   Tr   )rB   rF   r   r   rX   r   rR   r   spotSubHashswapSubHashr   r   r   r\   r[   r]   rU   r   s                     rD   watch_my_tradeszbingx.watch_my_tradesW  s      !!!!!!!!!!!!!!!!!![[((FH%F99-QWXXf&.$$*0A;;k)))/Doo_3<'Kit$T*]:T\+=VVyy{{ 	2 G zz#{G=MNNNNNNNN? 	3OOFE22E00tTTTrE   c                   K   |                                   d{V  |                                  d{V  d}|                     dd|          \  }}|dk    }d}d}d}d}|r|n|}|r|n|}	| j        d         d         |         d	z   | j        d
         z   }
d}|                                 }|dk    r|dd}|                     |
          }|                     |||	|           d}d}|                     |ddd          \  }}|                     |ddd          \  }}|r |r|	                    |dz              d{V  | 
                    |
|||	           d{V S )a  
        :see: https://bingx-api.github.io/docs/#/spot/socket/account.html#Subscription%20order%20update%20data
        :see: https://bingx-api.github.io/docs/#/swapV2/socket/account.html#Account%20balance%20and%20position%20update%20push
        query for balance and get the amount of funds available for trading or funds locked in orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        Nr   r   zspot:balancer   zswap:balancer   r   r   r   ACCOUNT_UPDATErM   r7   Tr8   F:fetchBalanceSnapshot)rQ   r   rS   r<   r=   rU   r_   set_balance_cachehandle_option_and_paramsfuturerV   )rB   rX   r   r   r   r   r   r   r\   r   r[   r]   rU   r_   r7   r8   s                   rD   watch_balancezbingx.watch_balance  s      !!!!!!!!!!!!!!!!!!99.$PVWWf&.$$(()/Doo_*0A;;kit$T*]:T\+=VVyy{{6>>, G S!!vt-=vFFF##'+'D'DV^]suy'z'z$f'+'D'DV^]suz'{'{$f 	@$8 	@--'> >?????????ZZ[';KLLLLLLLLLrE   c                     ||j         v rd S |                     |ddd          }|rD|dz   }||j        vr4|                    |           |                     | j        |||           d S d S i | j        |<   d S )Nr   r7   Tr   )subscriptionsr   futuresr   spawnload_balance_snapshotbalance)rB   r_   r   r   rX   r7   r\   s          rD   r   zbingx.set_balance_cache  s    v333F#<<V^Ukmqrr 	$!88K6>11k***

45v{DQQQQQ 21 "$DLrE   c                 >  K   |                      d|i           d {V }|                     ||                     | j        |i                     | j        |<   |j        |         }|                                 |                    | j        |         |dz              d S )Nr   :balance)fetch_balancerW   rT   r  r   rh   )rB   r_   r\   r   responser   s         rD   r   zbingx.load_balance_snapshot  s      ++VTN;;;;;;;;![[4??4<QUWY3Z3Z[[T,t|D)4*+<=====rE   c                    |                      |d          }	 |B| j        dz   |                     |          z   }|                     | j        d         ||           n,# t
          $ r}|                    |           Y d }~nd }~ww xY wdS )Ncode exactT)rc   rK   jsonthrow_exactly_matched_exception
exceptions	Exceptionreject)rB   r_   ri   r  feedbackes         rD   handle_error_messagezbingx.handle_error_message  s     00	7S=499W+=+==44T_W5MtU]^^^ 	 	 	MM!	ts   AA 
B'BBc                   K   |                      | j        d          }|d S 	 |                     d|i           d {V  n# t          $ r}ddg}t	          dt          |                    D ]}||         }| j        d         d         |         dz   |z   }|                     |          }t          |j	        
                                          }	t	          dt          |	                    D ] }
|	|
         }|                    ||           !d | j        d<   d| j        d<   Y d }~d S d }~ww xY w|                     | j        d	d
          }|                     || j        |           d S )Nr   r   r    r   r   r   r   lastAuthenticatedTimer9   6 )rc   r=    userAuthPrivatePutUserDataStreamr  r   r   r<   r_   r   r   keysr  r   delaykeep_alive_listen_key)rB   rX   r   errortypesr   r   r[   r_   messageHashesr   r\   r9   s                rD   r  zbingx.keep_alive_listen_key  s     $$T\;??	F	77i8PQQQQQQQQQQ 	 	 	V$E1c%jj)) 6 6Qxi&t,T2]BYNS)) $V^%8%8%:%: ; ;q#m"4"455 6 6A"/"2KMM%55556 )-DL%45DL01FFFFF	  $00?UW^__

')CVLLLLLs   A 
D.CD))D.c                 t  K   |                                  }|                     | j        dd          }|                     | j        dd          }||z
  |k    r`|                                  d {V }|                     |d          | j        d<   || j        d<   |                     || j        |           d S d S )Nr  r   r9   r  r   )millisecondsr   r=   !userAuthPrivatePostUserDataStreamrc   r  r  )rB   rX   timer  r9   r  s         rD   r   zbingx.authenticate  s        "" $ 1 1$,@WYZ [ [#00?UW^__''*>>>!CCEEEEEEEEH(,(8(8;(O(ODL%48DL01JJ+T-GPPPPP	 ?>rE   c                   K   	 |dk    r|                     d           d {V  d S |                     |d          }|                     |d          }|                     ||d           d {V  d S # t          $ rM}t          | j        dz   |                     |          z             }|                    |           Y d }~d S d }~ww xY w)NPingPongpingr  )pongr  z pong failed with error )sendrc   r  r   rK   r
  r   )rB   r_   ri   r#  r  r  r  s          rD   r$  z
bingx.pong  s"     	 &  kk&)))))))))))''88''88kk  # #             	  	  	  +E!E		RS!TUUELL	 s   !A3 A
A3 3
C
=ACC
c                    d|v }|                      |ddi           }| j        0|                     | j        dd          }t	          |          | _        | j        }|                     |          }|                    |           |d         }d}	d}
|r|	n|
}|                    ||           |                    ||d	z   |z              d S )
NrN   ra   r   ordersLimitr   rF   r   r   r   )safe_value_2r   r   r=   r   parse_orderr   rh   )rB   r_   ri   r   ra   r   r   parsedOrderrF   r   r   r\   s               rD   handle_orderzbingx.handle_order  s    h '  &#r::;%%dlM4HHE077DK&&t,,k"""X&#)8hhv{+++v{S069:::::rE   c                    d|v }|                      |ddi           }| j        }|2|                     | j        dd          }t	          |          }|| _        |                     |          }|d         }d}	d}
|r|	n|
}|                    |           |                    ||           |                    ||d	z   |z              d S )
NrN   ra   r   r   r   rF   r   r   r   )r(  myTradesr   r=   r   r   r   rh   )rB   r_   ri   r   resultcachedTradesr   r   rF   r   r   r\   s               rD   handle_my_tradeszbingx.handle_my_tradesi  s    r '""7FC<<}%%dlM4HHE1%88L(DM!!&))!"""(6hhhF###|[111|[3%6%?@@@@@rE   c                    |                      |di           }|                      |dg           }|                     |dd          }d|v rdnd}|| j        |         d<   || j        |         d	<   |                     |          | j        |         d
<   t	          dt          |                    D ]}||         }|                     |d          }	|                     |	          }
|
| j        |         v r| j        |         |
         n|                                 }|                     |d          |d<   |                     |d          }|d         ,t          j
        |                     |d          |          |d<   || j        |         |
<   |                     | j        |                   | j        |<   |                    | j        |         |dz              d S )Nr~   rx   r   EPr    r   r   rq   rr   r   wbfreebcusedr  )rT   safe_integer_2r  r   r   r   rc   safe_currency_codeaccountr   
string_subsafe_balancerh   )rB   r_   ri   r~   ra   rq   r   r   r  
currencyIdr  r:  balanceChanges                rD   handle_balancezbingx.handle_balance  s   J OOGS"--q#r**''c::	((vv%)T6"*3T;')-i)@)@T:&q#d))$$ 		/ 		/A1gG))'377J**:66D374<;M3M3Mdl4(..TXT`T`TbTbG"..w==GFO ,,Wd;;Mv*")"4T5E5Egv5V5VXe"f"f'.DLt$$!..t|D/ABBTt|D)4*+<=====rE   c                 *   |                      ||          sd S |dk    sd|v r|                     | j        ||           d S |                     |dd          }|                    d          dk    r|                     ||           d S |                    d          dk    r|                     ||           d S |                    d          dk    r|                     ||           d S |                    d	          dk    r|                     ||           d S |                    d
          dk    ra| 	                    |di           }|                     |d          }|dk    r| 
                    ||           |                     ||           d S |                     |d          }|dk    r|                     ||           |dk    r{|                     ||           | 	                    |di           }|                     |d          }|                     |d          }|dk    r|dk    r| 
                    ||           | 	                    |d          }|                     |d          }	|	dk    r|                     ||           d S d S )Nr!  r#  rN    r   r   rL   r   z@klineexecutionReportra   xTRADEr  r   ORDER_TRADE_UPDATEr   XFILLED	24hTicker)r  r   r$  rc   rd   r   rm   r   r   rT   r0  r+  r?  )
rB   r_   ri   rN   ra   r   r  statusmsgDatamsgEvents
             rD   handle_messagezbingx.handle_message  s   ((99 	Fv6W#4#4JJty&'222F##GZ<<==""a''""67333F==##q((vw///F==""a''vw///F==""a''fg...F==*++q00??7FB77D##D#..Dw%%fg666fg...FWc**   000$$$fg...??7C44D##D#..D%%dC00Ff&8&8%%fg666//'622##GS11{""vw///// #"rE   )N)(__name__
__module____qualname__rA   r   r   r^   r   rm   rf   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+  r0  r?  rL  __classcell__)rC   s   @rD   r   r      s       > > > > >@ 68 \ \ \F \ \ \ \0A,F A, A, A, A,F0 0 0 0d <@d[] S S SS S Sbfglbm S S S S<O,F O, O, O, O,b @DB "! "!S "! "!S\ "! "! "! "!H& & &
5/ 5/ 5/ 5/ 5/n
 
D 
 
 
 
0D,6 D, D, D, D,L 8<$]ajl  H  H  HC  HWZ  Hquvzq{  H  H  H  HD 04$UYbd 'U 'U 'UC 'Us 'Uimnsit 'U 'U 'U 'UR 37TX\eg 'U 'UC 'Us 'URU 'Ulpqvlw 'U 'U 'U 'UR *, #M #M #M #M #M #MJ
$ 
$ 
$ 
$ 
$> > >  & 24 M M M M0 )+ Q Q Q Q     0a; a; a;FGAv GA GA GA GAR7>V 7> 7> 7> 7>r(0V (0 (0 (0 (0 (0 (0 (0 (0rE   r   )ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   r   ccxt.base.typesr   r   r   r	   r
   r   r   !ccxt.async_support.base.ws.clientr   typingr   ccxt.base.errorsr   r   ccxt.base.preciser   async_supportr    rE   rD   <module>r[     s       f f f f f f f f f f O O O O O O O O O O O O O O O O O O 4 4 4 4 4 4       ' ' ' ' ' ' ) ) ) ) ) ) % % % % % %C0 C0 C0 C0 C0D$ C0 C0 C0 C0 C0rE   