
    i\                        d dl Zd dlmZmZmZmZ d dlZd dlm	Z	m
Z
mZ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ArrayCacheBySymbolBySideArrayCacheByTimestamp)
BalancesIntOrder	OrderBookPositionStrStringsTickerTickersTrade)Client)List)ExchangeError)AuthenticationError)RateLimitExceededc            
       ^    e Zd Z fdZi fdedefdZdi fdedefdZ	de
fd	Zi fdefd
Zde
fdZde
fdZddi fdedededee         fdZi 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 Zdddi fdededede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e
fdZdi fdededefdZ di fdee         dedefdZ!ddi fde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e
fdZ%i fdZ&de
fdZ'de
fd Z(de
fd!Z)de
fd"Z*de
fd#Z+ xZ,S )$bitmexc                     |                      t          t          |                                           dddddddddddddddiddiddddd	di d
t          idid          S )NT)wswatchBalancewatchMyTrades
watchOHLCVwatchOrderBookwatchOrderBookForSymbolswatchOrderswatchPostionswatchTickerwatchTickerswatchTradeswatchTradesForSymbolsr   z$wss://ws.testnet.bitmex.com/realtimezwss://ws.bitmex.com/realtime)testapiorderBookL2  )watchOrderBookLeveltradesLimit
OHLCVLimitzRate limit exceeded)exactbroad)hasurlsoptions
exceptions)deep_extendsuperr   describer   )self	__class__s    U/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/pro/bitmex.pyr4   zbitmex.describe   s    fd 3 3 < < > > $!%""&,0#!%# $#)-   @ 8	  (5#"   ./@ ?(A
 (A
 ( ( (	    symbolreturnc                    K   |                                   d{V  |                     |          }|                     |g|           d{V }||         S )a  
        watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :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>`
        N)load_marketsr9   watch_tickers)r5   r9   paramstickerss       r7   watch_tickerzbitmex.watch_ticker>   sp       !!!!!!!!!V$$**F8V<<<<<<<<vr8   Nsymbolsc                   K   |                                   d{V  |                     |dd          }d}| j        d         d         }g }g }|{t          dt	          |                    D ]\}||         }|                     |          }	|dz   |	d         z   }
|                    |
           d	|z   }|                    |           ]n*|                    |           |                    d
           d|d}|                     |||                     ||          |           d{V }| j	        ri }|||d         <   |S | 
                    | j        d|          S )a  
        watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
        :param str[] symbols: 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>`
        NT
instrumentr&   r   r   :idticker:
alltickers	subscribeopargsr9   )r<   market_symbolsr/   rangelenmarketappendwatch_multipleextend
newUpdatesfilter_by_arrayr?   )r5   rA   r>   nameurlmessageHashesrawSubscriptionsir9   rO   subscriptionmessageHashrequesttickerresults                  r7   r=   zbitmex.watch_tickersJ   s      !!!!!!!!!%%gtT::it$1c'll++ 2 2 V,,#czF4L8 ''555'&0$$[11112 ##D)))  ...$
 
 **3t{{7TZ?[?[]mnnnnnnnn? 	F'-F6(#$M##DL(GDDDr8   clientc                    |                      |dg           }i }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|| j        vr|                     i           | j        |<   |                     |          }	|                     | j        |         |	          }
|
||<   |
| j        |<   d|z   }|                    |
|           |                    |
d           |S )Ndatar   r9   rF   rG   )		safe_listrM   rN   safe_stringsafe_symbolr?   parse_tickerr2   resolve)r5   r_   messagera   r?   rY   updatemarketIdr9   updatedTickerfullParsedTickerr[   s               r7   handle_tickerzbitmex.handle_tickerm   s   F ~~gvr22q#d))$$ 	; 	;A!WF''99H%%h//Fdl**'+'8'8'<'<V$ --f55M#//V0DmTT.GFO#3DL #f,KNN+[999NN+\::::r8   c                   K   |                                   d{V  |                                  d{V  d}| j        d         d         }d|gd}|                     |||                     ||          |           d{V S )a  
        watch 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>`
        Nmarginr&   r   rH   rI   )r<   authenticater/   watchrR   )r5   r>   r[   rV   r\   s        r7   watch_balancezbitmex.watch_balancea  s       !!!!!!!!!!!!!!!!!!it$
 
 ZZ[$++gv2N2NP[\\\\\\\\\r8   c                     |                      |d          }|                     |          }|                     | j        |          | _        |                     |d          }|                    | j        |           d S )Nra   table)
safe_valueparse_balancerR   balancerc   rf   )r5   r_   rg   ra   rv   r[   s         r7   handle_balancezbitmex.handle_balances  ss    F w//$$T**{{4<99&&w88t|[11111r8   c                    d}|                      |dg           }|                     |d          }t          |                                          }t	          dt          |                    D ]}||         }|                     |          }	|	d         }
|dz   |
z   }|                     ||         |	          }|                      | j        |
          }|5| 	                    | j
        dd          }t          |          }|| j        |
<   t	          dt          |                    D ]}|                    ||                    |                    ||           d S )Ntradera   r9   r   rD   r*   r(   )rt   group_bylistkeysrM   rN   safe_marketparse_tradestradessafe_integerr0   r   rP   rf   )r5   r_   rg   rs   ra   dataByMarketIds	marketIdsrY   ri   rO   r9   r[   r   storedlimitjs                   r7   handle_tradeszbitmex.handle_trades  s]   x w33--h77--//00	q#i..)) 	0 	0A |H%%h//FH%F#+.K&&x'@&IIF__T[&99F~))$,tLL#E**&,F#1c&kk** ) )fQi((((NN6;////	0 	0r8   sincer   c                 D   K   |                      |g|||           d{V S )a  
        get the list of most recent trades for a particular symbol
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        N)watch_trades_for_symbols)r5   r9   r   r   r>   s        r7   watch_tradeszbitmex.watch_trades+  s6       22F8UE6RRRRRRRRRr8   c                 P  K   | j         d         d         }|                     |          }d}|                    |          }|                     |j        |          }||                                  |                                 }dt          |          z   }|                     | 	                    |          | 	                    | j
                  t          j                  }	d| j        ||	gd}
|                     |
|          }|                     ||||           | d {V S )Nr&   r   authenticatedzGET/realtimeauthKeyExpiresrI   )r/   r_   futurert   subscriptionscheck_required_credentialsmillisecondsstrhmacencodesecrethashlibsha256apiKeyrR   rp   )r5   r>   rV   r_   r[   r   r   	timestamppayload	signaturer\   rg   s               r7   ro   zbitmex.authenticate6  s     it$S!!%{++(<kJJ ++---))++I)C	NN:G		$++g"6"6DK8P8PRYR`aaI&K G kk'622GJJsK+>>>||||||r8   c                 6   |                      |dd          }d}|r2|                     |j        |          }|                    d           d S t	          |                     |                    }|                    ||           ||j        v r
|j        |= d S d S )NsuccessFr   T)	safe_boolrt   futuresrf   r   jsonrejectr   )r5   r_   rg   r   r[   r   errors          r7   handle_authentication_messagez$bitmex.handle_authentication_messageM  s    w	5AA% 	6__V^[AAFNN4     '		'(:(:;;EMM%---f222(555 32r8   c                   K   |                                   d{V  |                                  d{V  d}d}|                     |          sdd                    |          z   }| j        d         d         }d|gd	}|                     ||||           d{V }	| j        r|	S |                     | j        |||d
          S )ag  
        :see: https://www.bitmex.com/app/wsAPI
        watch all open positions
        :param str[]|None symbols: list of unified market symbols
        :param dict params: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/en/latest/manual.html#position-structure>`
        Nposition	positions::,r&   r   rH   rI   T)	r<   ro   is_emptyjoinr/   rp   rS   filter_by_symbols_since_limitr   )
r5   rA   r   r   r>   subscriptionHashr[   rV   r\   newPositionss
             r7   watch_positionszbitmex.watch_positionsZ  s	      !!!!!!!!!!!!!!!!!!%!}}W%% 	3'!2!22Kit$ 
 
 "ZZ['CSTTTTTTTT? 	 11$.'5RWY]^^^r8   c                    | j         t                      | _         | j         }|                     |dg           }g }t          dt	          |                    D ]I}||         }|                     |          }|                    |           |                    |           J|                     |d          }	t          dt	          |	                    D ]}|	|         }
|
                    d          }|d         }|                    d          }| 	                    |d|d          }| 
                    |          s|                    ||
           |                    |d	           d S )
Nra   r   zpositions::r      r   r9   Fr   )r   r   rt   rM   rN   parse_positionrP   find_message_hashessplitrT   r   rf   )r5   r_   rg   cacherawPositionsr   rY   rawPositionr   rW   r[   partssymbolsStringrA   r   s                  r7   handle_positionszbitmex.handle_positionst  sl   j >!577DNw;;q#l++,, 	# 	#A&q/K**;77H)))LL""""00GGq#m,,-- 	7 	7A'*K%%d++E!!HM#))#..G,,\8WeTTI==++ 7y+666|[11111r8   c                   K   |                                   d{V  |                                  d{V  d}|}|}||                     |          }|d|z   z  }| j        d         d         }d|gd}	|                     |||	|           d{V }
| j        r|
                    ||          }|                     |
|||d          S )	a  
        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>`
        NorderrD   r&   r   rH   rI   Tr<   ro   r9   r/   rp   rS   getLimitfilter_by_symbol_since_limit)r5   r9   r   r   r>   rU   r   r[   rV   r\   orderss              r7   watch_orderszbitmex.watch_orders  s      !!!!!!!!!!!!!!!!!![[((F3<'Kit$ 
 
 zz#{G=MNNNNNNNN? 	3OOFE22E00tTTTr8   c                 8   |                      |dg           }d}t          |          }|dk    rh| j        0|                     | j        dd          }t          |          | _        | j        }i }t          d|          D ]}	||	         }
|                     |
d          }|                      |j        |          }|
}|| 	                    |d         |
          }| 
                    |          }|                    |           |d         }d	||<   |                    | j        |           t          |                                          }t          dt          |                    D ]-}	||	         }|                    | j        |d
z   |z              ,d S d S )Nra   r   r   ordersLimitr(   orderIDinfor9   TrD   )rt   rN   r   r   r0   r   rM   rc   hashmaprR   parse_orderrP   rf   r{   r|   )r5   r_   rg   ra   r[   
dataLengthr   r   rA   rY   currentOrderorderIdpreviousOrderrawOrderr   r9   r|   s                    r7   handle_orderszbitmex.handle_orders;  s   l w33YY
>>{"))$,tLL4U;;[FG1j)) 
' 
'#Aw**<CC $ H H' ,#{{=+@,OOH((22e$$$x"&NN4;444''D1c$ii(( H Hat{K#,=,FGGGG+ >&H Hr8   c                   K   |                                   d{V  |                                  d{V  d}|}|}||                     |          }|d|z   z  }| j        d         d         }d|gd}	|                     |||	|           d{V }
| j        r|
                    ||          }|                     |
|||d          S )	a  
        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 fetch trades for
        :param int [limit]: the maximum number of trade 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
        N	executionrD   r&   r   rH   rI   Tr   )r5   r9   r   r   r>   rU   r   r[   rV   r\   r   s              r7   watch_my_tradeszbitmex.watch_my_trades  s      !!!!!!!!!!!!!!!!!![[((F3<'Kit$ 
 
 zz#{G=MNNNNNNNN? 	3OOFE22E00tTTTr8   c                    |                      |d          }|                     |dg           }|                     |d          }|                     |dg           }|                     |          }| j        0|                     | j        dd          }t          |          | _        | j        }	i }
t          dt          |                    D ],}||         }|d         }|	
                    |           ||
|<   -t          |          }|dk    r|                    |	|           t          |
                                          }t          dt          |                    D ]$}|                    |	|d	z   ||         z              %d S )
Nrs   ra   execTyper   r*   r(   r   r9   rD   )rc   rt   rz   r~   myTradesr   r0   r   rM   rN   rP   rf   r{   r|   )r5   r_   rg   r[   ra   dataByExecType	rawTradesr   r   r   rA   r   ry   r9   	numTradesr|   rY   s                    r7   handle_my_tradeszbitmex.handle_my_trades	  s   t &&w88w33tZ88OONGR@@	""9--= %%dlM4HHE2599DMq#f++&& 	$ 	$A1IE8_FMM%   #GFOOKK	q==NN6;///GLLNN##q#d))$$ 	@ 	@ANN6;#4tAw#>????	@ 	@r8   c                 B   K   |                      |g||           d{V S )a  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :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
        N)watch_order_book_for_symbols)r5   r9   r   r>   s       r7   watch_order_bookzbitmex.watch_order_bookY  s4       66xOOOOOOOOOr8   c                   K   d}||                      | j        dd          }n)|dk    rd}n |dk    rd}nt          | j        dz             |                                  d{V  |                     |          }g }g }t          d	t          |                    D ]_}||         }|                     |          }	|d
z   |	d         z   }
|	                    |
           |d
z   |z   }|	                    |           `| j
        d         d         }d|d}|                     |||                     ||          |           d{V }|                                S )a  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str[] symbols: unified array of symbols
        :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)   r'      orderBookL2_25
   orderBookL10zK watchOrderBookForSymbols limit argument must be None(L2), 25(L2) or 10(L3)r   rD   rE   r&   r   rH   rI   )rc   r0   r   rE   r<   rL   rM   rN   rO   rP   r/   rQ   r2   r   )r5   rA   r   r>   rs   topicsrW   rY   r9   rO   topicr[   rV   r\   	orderbooks                  r7   r   z#bitmex.watch_order_book_for_symbolsc  s      =$$T\3H-XXEEb[[$EEb[["EE*w wxxx!!!!!!!!!%%g..q#g,,'' 	. 	.AQZF[[((FCK&,.EMM%   #+.K  ----it$
 
 --c=$BRBRSZ\bBcBcekllllllll	   r8   c                   K   |                                   d{V  |                     |dd          }d}g }g }t          dt          |                    D ]_}||         }	|                     |	          }
|dz   |
d         z   }|                    |           |dz   |	z   }|                    |           `| j        d         d         }d	|d
}|                     |||                     ||          |           d{V }| j	        rB| 
                    |d          }|                     |d          }|                    ||          }|                     |||dd          S )a  
        get the list of most recent trades for a list of symbols
        :param str[] symbols: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        NFry   r   rD   rE   r&   r   rH   rI   r9   r   T)r<   rL   rM   rN   rO   rP   r/   rQ   r2   rS   rt   rc   r   filter_by_since_limit)r5   rA   r   r   r>   rs   r   rW   rY   r9   rO   r   r[   rV   r\   r   firsttradeSymbols                     r7   r   zbitmex.watch_trades_for_symbols  s      !!!!!!!!!%%gtU;;q#g,,'' 	. 	.AQZF[[((FCK&,.EMM%   #+.K  ----it$
 
 **3t?O?OPWY_?`?`bhiiiiiiii? 	8OOFA..E**5(;;KOOK77E))&%TRRRr8   1mc                   K   |                                   d{V  |                     |          }|d         }d|                     | j        ||          z   }|dz   |d         z   }| j        d         d         }	d|gd	}
|                     |	||                     |
|          |           d{V }| j        r|                    ||          }| 	                    |||d
d          S )aQ  
        watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :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
        Nr9   tradeBinrD   rE   r&   r   rH   rI   r   T)
r<   rO   rc   
timeframesr/   rp   rR   rS   r   r   )r5   r9   	timeframer   r   r>   rO   rs   r[   rV   r\   ohlcvs               r7   watch_ohlcvzbitmex.watch_ohlcv  s      !!!!!!!!!V$$!T--doy)TTTckF4L0it$
 
 jjk4;;w3O3OQ\]]]]]]]]? 	2NN6511E))%q$GGGr8   c           
         |                      |d          }|                    dd          }|                     |          }|                     |          }|                     |dg           }i }t          dt          |                    D ]m}	||	         }
|                      |
d          }|                     |          }|d         }|dz   |d         z   }|                     |                      |
d	                    |d
z  z
  d | 	                    |
d          | 	                    |
d          | 	                    |
d          | 	                    |
d          g}|                     | j
        |i           | j
        |<   |                     | j
        |         |          }|;|                     | j        dd
          }t          |          }|| j
        |         |<   |                    |           |||<   ot          |                                          }t          dt          |                    D ]&}	||	         }|                    ||         |           'd S )Nrs   r    ra   r   r9   rD   rE   r   r(   highlowclosevolumer+   )rc   replacefind_timeframeparse_timeframert   rM   rN   r}   	parse8601
safe_floatohlcvsr   r0   r   rP   r{   r|   rf   )r5   r_   rg   rs   intervalr   durationcandlesresultsrY   candleri   rO   r9   r[   r^   r   r   rW   s                      r7   handle_ohlcvzbitmex.handle_ohlcv  sK   D   '22==R00''11	''	22//'6266q#g,,'' 	* 	*AQZF''99H%%h//FH%F#+t4Kt//DDEESWW//..0011F #'//$+vr"J"JDK__T[%8)DDF~))$,dKK.u5517F#I.MM&!!!#)GK  W\\^^,,q#m,,-- 	> 	>A'*KNN7;/====	> 	>r8   c                    K   |                                   d {V  d}| j        d         d         }|                     ||           d {V S )N	heartbeatr&   r   )r<   r/   rp   )r5   r>   eventrV   s       r7   watch_heartbeatzbitmex.watch_heartbeat&  sf      !!!!!!!!!it$ZZU+++++++++r8   c           	         |                      |d          }|                      |d          }|                     |dg           }|dk    r|                     |di           }|                     |d          }|                     |          }|d         }	|dk    r|                                 | j        |	<   nI|dk    r|                     i d	          | j        |	<   n$|d
k    r|                     i d          | j        |	<   | j        |	         }
|	|
d<   t          dt          |                    D ]}|                     ||         d          }|                     |	|                      ||         d                    }|                      ||         d          }|                      ||         d          }|dk    rdnd}|
|         }|	                    |||           |                      ||         d          }| 
                    |          |
d<   ||
d<   |dz   |	z   }|                    |
|           d S i }t          dt          |                    D ]Z}|                     ||         d          }||vrd||<   |                     |d          ||<   |                     |          }|d         }	| j        |	         }
|                     ||         d          }|dk    rdn0|                     |	|                      ||         dd                    }|                      ||         d          }|                      ||         d          }|dk    rdnd}|
|         }|	                    |||           |                      ||         d          }| 
                    |          |
d<   ||
d<   \t          |                                          }t          dt          |                    D ]R}||         }|                     |          }|d         }	|dz   |	z   }| j        |	         }
|                    |
|           Sd S )Nactionrs   ra   partialfilterr9   r'   r   r   orderBook10r   r   pricesizerE   sideBuybidsasksr   datetimerD   r   delete0)rc   rt   r}   indexed_order_book
orderbooksrM   rN   r   convertFromRawQuantitystorer   rf   sumsafe_numberr{   r|   )r5   r_   rg   r  rs   ra   r  ri   rO   r9   r   rY   r  r	  rE   r
  booksider  r[   numUpdatesByMarketIdr   s                        r7   handle_order_bookzbitmex.handle_order_book,  s   d !!'844  '22w33Y__Wh;;Fvx88H%%h//FH%F%%*.*A*A*C*C''****.*A*A"b*I*I''-''*.*A*A"b*I*I'/I"(Ih1c$ii(( 
1 
1Q992264;K;KDQRGU[;\;\]]%%d1gt44''Q88"&%--vvf$T?udB///++DG[AA)-)A)A	+&(0	*%%#+.KNN9k22222#% 1c$ii(( 1 1??47H== $88856(215:NPQ1R1R$X.))(33) OF3	((a'::#x//qqd6Q6QRXZ^ZjZjkopqkrtz|  [A  [A  7B  7B%%d1gt44''Q88"&%--vvf$T?udB///++DG[AA)-)A)A	+&(0	*%%1668899I1c)nn-- 7 7$Q<))(33)#ckF2 OF3	y+66667 7r8   c                     |S N r5   r_   rg   s      r7   handle_system_statuszbitmex.handle_system_status  s	     r8   c                     |S r  r  r  s      r7   handle_subscription_statusz!bitmex.handle_subscription_status  s	     r8   c                    |                      |d          }||                     |di           }|                     |dg           }t          |          }|dk    rn|d         }| j        d         d         }|                     ||          }	d }
|	t          |          }
n ||	         |          }
|                    |
|           dS dS )	Nr   r\   rK   r   r   r-   FT)rc   rt   rN   r1   find_broadly_matched_keyr   r   )r5   r_   rg   r   r\   rK   numArgsr[   r-   broadKey	exceptions              r7   handle_error_messagezbitmex.handle_error_message  s    "   '22oogy"==G??7FB77D$iiG{{"1g-g688FF 	# -e 4 4II /h 6 6Ii555utr8   c                    |                      ||          r|                     |d          }| j        | j        | j        | j        | j        | j        | j        | j        | j        | j        | j        | j        | j	        d}| 
                    ||          }|M| 
                    |di           }| 
                    |d          }|dk    r|                     ||           d S d S  |||           d S d S )Nrs   )r'   r   r  rC   ry   
tradeBin1m
tradeBin5m
tradeBin1h
tradeBin1dr   r   rn   r   r\   rJ   r   )r&  rc   r  rl   r   r   r   r   rw   r   rt   r   )r5   r_   rg   rs   methodsmethodr\   rJ   s           r7   handle_messagezbitmex.handle_message  s"   F $$VW55 	($$Wg66E#5"&"8#5"0+"/"/"/"/+!2- 1 G __We44F~//'9bAA__Wd33)))66vwGGGGG *) vw'''''1	( 	(r8   )-__name__
__module____qualname__r4   r   r   r@   r   r   r=   r   rl   r   rq   rw   r   r   r   r   r   ro   r   r   r   r   r   r	   r   r   r   r   r
   r   r   r   r{   r   r   r  r  r  r   r&  r.  __classcell__)r6   s   @r7   r   r      s       ) ) ) ) )V 68 
 
 
F 
 
 
 
 6:" !E !E7 !E !E !E !E !EFrF r r r rh *, ] ] ] ] ] ]$g2V g2 g2 g2 g2RM0F M0 M0 M0 M0^ <@d[] 	S 	S 	SS 	S 	Sbfglbm 	S 	S 	S 	S )+    .6F 6 6 6 6 8<$]ajl _ _W _C _WZ _quv~q _ _ _ _4h2 h2 h2T 04$UYbd U U UC Us Uimnsit U U U U:oHF oH oH oH oHb 37TX\eg U UC Us URU Ulpqvlw U U U U:N@v N@ N@ N@ N@` @DB P PS P PS\ P P P P SW_a "! "!$s) "!C "!fo "! "! "! "!H OSaenp S Sd3i S S[^ Suyz  vA S S S SB 8<$]ajl H H HC HWZ Hquvzq{ H H H H6a>6 a> a> a> a>F ,. , , , ,k7 k7 k7 k7 k7Z6         !6 ! ! ! !F;(V ;( ;( ;( ;( ;( ;( ;( ;(r8   r   )ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   r   r   r   ccxt.base.typesr   r   r	   r
   r   r   r   r   r   r   !ccxt.async_support.base.ws.clientr   typingr   ccxt.base.errorsr   r   r   async_supportr   r  r8   r7   <module>r;     sJ       A  A  A  A  A  A  A  A  A  A  A  A  k k k k k k k k k k k k k k k k k k k k k k k k 4 4 4 4 4 4       * * * * * * 0 0 0 0 0 0 . . . . . .@( @( @( @( @(T& @( @( @( @( @(r8   