
    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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 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StringsTickerTickersTrade)Client)List)ExchangeError)AuthenticationError)
BadRequest)NotSupported)ExchangeNotAvailable)RequestTimeout)Precisec            
           e Zd Z fdZd ZdefdZd#dZi fdefdZ	defd	Z
defd
Zd#dZdefdZi fdedefdZdi fdedefdZddi fdedededee         fdZdi fdede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 Z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#dZ$d Z%defdZ&defd Z'defd!Z(i fd"Z) xZ*S )$coinexc                 0   |                      t          t          |                                           ddddddddddd
dddddiidd	d
dddddddddddddg ddg ddddi dt          t
          t          t          t          t          did           S )!NTF)
wswatchBalancewatchTickerwatchTickerswatchTradeswatchMyTradeswatchOrderswatchOrderBook
watchOHLCVfetchOHLCVWsapir   zwss://socket.coinex.com/zwss://perpetual.coinex.com/)spotswap<      i,  i  i  i  i   i@8  i`T  i  iQ i i:	 )1m3m5m15m30m1h2h4h6h12h1d3d1wr&   )   
      2   r:   )1010z0.1z0.01r=   )limitsdefaultLimitaggregationsdefaultAggregation)watchOHLCVWarning
timeframesaccountr"   codes)r<   23456)hasurlsoptions	streaming
exceptions)
deep_extendsuperr   describer   r   r   r   r   r   )self	__class__s    U/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/pro/coinex.pyrR   zcoinex.describe   s   fd 3 3 < < > > $# $#!&#"&" $   : =  &*     "-oo$&$C$C$C*-	# #% 2 #&-%', 	a:A
 :A
 : : :	    c                 z    |                      |                     | j        dd          d          }|| j        d<   |S )N	requestIdr      )sumsafe_integerrM   )rS   rX   s     rU   
request_idzcoinex.request_idS   s;    HHT..t|[!LLaPP	$-[!rV   clientc                    |                      | j        d          }|                     |dg           }|                     |di           }t          |                                          }g }t          dt          |                    D ]w}||         }	||	         }
|                     |	d d |          }|                     |	d d |          }| 	                    |
|          }|| j
        |<   |                    |           x|                     |d          }t          dt          |                    D ]}||         }|                    d          }|d         }|                    d          }|                     |d|          }t          |                                          }t          |          }|dk    r|                    ||           |                    |d	           d S )
NdefaultTypeparamsr   	tickers::z::rY   ,symboltickers)safe_stringrM   
safe_valuelistkeysrangelensafe_symbolsafe_marketparse_ws_tickerrd   appendfind_message_hashessplitfilter_by_arrayresolve)rS   r]   messager_   r`   
rawTickersrh   
newTickersimarketId	rawTickerrc   marketparsedTickermessageHashesmessageHashpartssymbolsStringsymbolsrd   tickersSymbols
numTickerss                         rU   handle_tickerzcoinex.handle_tickerX   s   d &&t|]CC(B77__VQ33
JOO%%&&
q#d))$$ 	, 	,AAwH"8,I%%hdKHHF%%hdKHHF//	6BBL#/DL l++++00EEq#m,,-- 		5 		5A'*K%%d++E!!HM#))#..G**:xIIG!',,..11N^,,JA~~w444z9-----rV   Nc           
      j   |                      | j        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 dd |                      |d          |                      |d          |d|          S )Nr_   rc   	timestampdatetimehighlowbid	bidVolume	buy_totalask	askVolume
sell_totalvwapopencloselastpreviousClosechange
percentageaveragevolumedeal)
baseVolumequoteVolumeinfo)re   rM   safe_tickerrk   )rS   tickerry   r_   s       rU   rm   zcoinex.parse_ws_ticker   s   P &&t|]CC !
d&&tVT;GG!
!
 !
 D$$VV44	!

 4##FE22!
 4!
 ))&+>>!
 4!
 ))&,??!
 D!
 D$$VV44!
 T%%fg66!
 D$$VV44!
 T!
 d!
  $!!
" t#!
$ **68<<++FF;;)!
 !
 !
* +  	rV   returnc                   K   |                                   d{V  |                     |           d{V  d}d}|                     dd|          \  }}| j        d         d         |         }t	          | j                                                  }d||                                 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balancer   r%   r   zasset.subscribemethodr`   id)
load_marketsauthenticatehandle_market_type_and_paramsrL   rg   currencies_by_idrh   r\   rP   watch)rS   r`   r|   typeurl
currencies	subscriberequests           rU   watch_balancezcoinex.watch_balance   s
      !!!!!!!!!'''''''''99.$PVWWfit$T*$/446677
' //##
 
	
 ""9f55ZZ[';GGGGGGGGGrV   c                 j   |                      |dg           }|                      |di           }|| j        d<   t          |                                          }t	          dt          |                    D ]}||         }|                     |          }|                     ||         d          }	|                     ||         d          }
|                                 }|	|d<   |
|d<   || j        |<   | 	                    | j                  | _        d}|
                    | j        |           d S )	Nr`   r   r   	availablefrozenfreeusedr   )rf   r   rg   rh   ri   rj   safe_currency_codere   rD   safe_balancerr   )rS   r]   rs   r`   firstr   rv   
currencyIdcoder   r   rD   r|   s                rU   handle_balancezcoinex.handle_balance   s#    (B772..$V%**,,''
q#j//** 		; 		;A#AJ**:66D((z):KHHI%%eJ&7BBFllnnG'GFO$GFO!(DL,,T\::DLLt|[11111rV   c                    |                      |dg           }|                     |d          }|                      |dg           }|                     | j        d          }|                     |d d |          }|d         }d|z   }	|                      | j        |          }
|
5|                     | j        dd          }t          |          }
|
| j        |<   t          dt          |                    D ]5}||         }| 	                    ||          }|

                    |           6|
| j        |<   |                    | j        |         |	           d S )	Nr`   r   rY   r_   rc   trades:tradesLimit  )rf   re   rM   rl   tradesr[   r   ri   rj   parse_ws_tradern   rr   )rS   r]   rs   r`   rw   r   r_   ry   rc   r|   storedlimitrv   tradeparseds                  rU   handle_tradeszcoinex.handle_trades  sR   " (B77##FA..B//&&t|]CC!!(D$DD!&(f55>%%dlM4HHE&&F"(DKq#f++&& 	" 	"A1IE((77FMM&!!!!$Ft{6*K88888rV   c                    |                      |d          }|                     | j        d          }|                     |                     |d          |||                     |          |                     d |d |          d d |                     |d          d |                     |d          |                     |d          d d d|          S )Ntimer_   r   r   priceamount)r   r   r   r   rc   orderr   sidetakerOrMakerr   r   costfee)safe_timestampre   rM   
safe_tradeiso8601rk   )rS   r   ry   r   r_   s        rU   r   zcoinex.parse_ws_trade=  s     ''v66	&&t|]CC""5$//"Y//&&tVT;GG$$UF33 %%eW55&&uh77 
  
   	rV   c                    |                      |ddg           }d}|                     |d          }|                     |          }||                    ||           d S t	          | j                                                  }t          |          }|dk    rEi | j        d<   |                     | j	        dd          }	t          |	          }
|
| j        d         d<   | j        d         d         }t          dt          |                    D ]}||         }|                    |            |                    ||           d S )	Nr`   resultohlcvr   r   unknown
OHLCVLimitr   )safe_value_2re   parse_ohlcvsrr   rg   ohlcvsrh   rj   r[   rM   r   ri   rn   )rS   r]   rs   candlesr|   r   r   rh   
keysLengthr   r   r   rv   candles                 rU   handle_ohlcvzcoinex.handle_ohlcvY  sC   F ##GXxDDgt,,""7++>NN6;///FDK$$&&''YY
??%'DK	"%%dlL$GGE*511F06DK	"9-I&y1q#f++&& 	! 	!AAYFLL    uk*****rV   rc   c                 l   K   |                      |g|           d{V }|                     ||          S )a  
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot004_websocket007_state_subscribe
        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)watch_tickersrf   )rS   rc   r`   rd   s       rU   watch_tickerzcoinex.watch_ticker  sE       **F8V<<<<<<<<w///rV   r   c                   K   |                                   d{V  |                     |          }d}|                     dd|          \  }}| j        d         d         |         }d}|dd                    |          z   }d|                                 g d	}|                     ||          }|                     ||||           d{V }| j        r|S | 	                    | j
        d
|          S )a  
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot004_websocket007_state_subscribe
        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 dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   r%   r   rd   ra   rb   zstate.subscriber   r   r`   rc   )r   market_symbolsr   rL   joinr\   rP   r   
newUpdatesrq   rd   )	rS   r   r`   r   r   r|   r   r   ru   s	            rU   r   zcoinex.watch_tickers  s       !!!!!!!!!%%g..99.$PVWWfit$T*%(9(99K'//##
 
	
 ""9f55::c;MMMMMMMM
? 	##DL(GDDDrV   sincer   c                 (  K   |                                   d{V  |                     |          }d}|                     d||          \  }}| j        d         d         |         }d|z   }d}	|                     | j        dg           }
|
                    |d                    d	|
|                                 d
}|
| j        d<   |                     ||          }| 	                    ||||	           d{V }| 
                    |||dd          S )a  
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot004_websocket012_deal_subcribe
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures002_websocket019_deal_subcribe
        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>`
        Nr   r%   r   r   r   watchTradesSubscriptionsr   zdeals.subscriber   r   T)r   ry   r   rL   rf   rM   rn   r\   rP   r   filter_by_since_limit)rS   rc   r   r   r`   ry   r   r   r|   subscriptionHashsubscribedSymbolsrs   r   r   s                 rU   watch_tradeszcoinex.watch_trades  s@      !!!!!!!!!V$$99-QWXXfit$T*&(# OODL:TVXYY  ...''//##
 

 4E/0""7F33zz#{G=MNNNNNNNN))&%TRRRrV   c                 .  K   |                                   d{V  |                     |          }|d         }d}|                     d||          \  }}| j        d         d         |         }d}|dz   |z   }|                     | j        di           }	|                     |	dg           }
||                     |	d	d
          }|                     ||
          s-t          | j        dz   d	                    |
          z             | 
                    |	dd          }|                     |	dg           }| 
                    |d|          }|                     ||          s-t          | j        dz   d	                    |          z             |                     |d          }|                     | j        di           }|d         ||dg||<   d|                                 t          |                                          d}|| j        d<   |                     |                     |                     |                    d          }|                     ||          }|                     |||||           d{V }|                                S )a  
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot004_websocket017_depth_subscribe_multi
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures002_websocket011_depth_subscribe_multi
        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
        Nrc   r"   r%   r   	orderbook:r>   r?   r:   z' watchOrderBook() limit must be one of z, rA   r=   r@   aggregationz- watchOrderBook() aggregation must be one of watchOrderBookSubscriptionsr   Tzdepth.subscribe_multir   sha256)r   ry   r   rL   rf   rM   in_arrayr   r   r   re   omitr\   rg   valueshashencodejsonrP   r   r   )rS   rc   r   r`   ry   r   r   namer|   rM   r>   rA   r@   r   r   r   r   r   r   s                      rU   watch_order_bookzcoinex.watch_order_book  s      !!!!!!!!!V$$!99:JFTZ[[fit$T*Sj6)//$,0@"EE(B77=OOG^R@@E}}UF++ 	htw)RRUYU^U^_eUfUffggg!--g7KSQQwCC&&v}>PQQ}}[,77 	ttw)XX[_[d[deq[r[rrsss6=11&*oodlDace&f&f#/5d|UKQU.V#F+-//##6==??@@
 
	
 7R2399T[[;V1W1W%X%XZbcc""9f55**S+w@PRYZZZZZZZZ	   rV   r*   c                 
  K   |                                   d{V  |                     |          }|d         }d}|                     d||          \  }}|dk    rt          | j        dz             | j        d         d         |         }d}	|                     | j        d	d
          }
|                     | j	        |i           }|                     |di           }|                     ||	          }| 
                    |d          }| 
                    |d          }|
r%|#||k    s||k    rt          | j        dz             |                     | j        di           }d|                                 |d         |                     ||          gd}||d}|                     ||          }|                     ||	||	|           d{V }| j        r|                    ||          }|                     |||d          S )a  
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures002_websocket023_kline_subscribe
        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
        Nrc   r#   r'   zP watchOHLCV() is only supported for swap markets. Try using fetchOHLCV() insteadr%   r   r   rB   Tsubscriptions	timeframez watchOHLCV() can only watch one symbol and timeframe at a time. To supress self warning set watchOHLCVWarning to False in optionsrC   zkline.subscriber   r   )rc   r   r   )r   ry   r   r   r   rL   	safe_boolrM   rf   clientsre   r   r\   r[   rP   r   r   getLimitr   )rS   rc   r   r   r   r`   ry   r   r   r|   rB   r]   	clientSubexistingSubscription	subSymbolsubTimeframerC   r   subscriptionr   r   s                        rU   watch_ohlcvzcoinex.watch_ohlcv   sQ      !!!!!!!!!V$$!99,PVWWf6>>tw){{|||it$T* NN4<9LdSSsB77OOFOR@@	#y+FF$$%98DD	''(<kJJ 	p!5!AyTZGZGZ^jnw^w^w  +o  !o  p  p  p__T\<DD
'//##t!!*i88
 
	 "
 
 ""9f55zz#{G[,WWWWWWWW? 	3OOFE22E))&%BBBrV   c           	        K   |                                   d{V  |                     |          }|                     d||          \  }}| j        d         d         |         }	|d         }d}
|                     | j        di           }|                     |||          }|d}|                                 }d	|d
         |                     |dz            | 	                    |d| 
                                          |                     |          g|d}||
d}|}|                     ||          }|                     |	|
|||           d{V }|                     |||d          S )a  
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot004_websocket005_kline_query
        query 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 query OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int|None since: timestamp in ms of the earliest candle to fetch
        :param int|None limit: the maximum amount of candles to fetch
        :param dict params: extra parameters specific to the exchange API endpoint
        :param int|None params['end']: the end time for spot markets, self.seconds() is set
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        N
fetchOHLCVr%   r   rc   r   rC   iazkline.queryr   r   endr   r   futurer   )r   ry   r   rL   rf   rM   re   r\   parse_to_intr[   secondsrP   r   r   )rS   rc   r   r   r   r`   ry   r   queryr   r|   rC   r   r   r  r   r   r   s                     rU   fetch_ohlcv_wszcoinex.fetch_ohlcv_ws0  s      !!!!!!!!!V$$88vvVVeit$T*!__T\<DD
$$ZIFF	=E__#t!!%$,//!!&%@@!!),,	 	
 	
	 !
 
 ""9e44zz#{G=M|\\\\\\\\))&%BBBrV   c                 ^    |                      |dd          }|                    |           d S )Nr   rY   )parse_bid_ask
storeArray)rS   booksidedeltabidAsks       rU   handle_deltazcoinex.handle_deltaZ  s3    ##E1a00F#####rV   c                 ~    t          dt          |                    D ]}|                     |||                    d S )Nr   )ri   rj   r  )rS   r  deltasrv   s       rU   handle_deltaszcoinex.handle_deltas^  sH    q#f++&& 	3 	3Ahq	2222	3 	3rV   c                    |                      |dg           }|                      |d          }|                      |d          }|                     |d          }|                     | j        d          }|                     |d d |          }|d         }	d}
|
dz   |	z   }|                     |d	          }|                      | j        |	          }|r\|                     ||	|          }| |                     |          }|| j        |	<   n| j        |	         }|                    |           n|                      |d
g           }|                      |dg           }| 	                    |d
         |           | 	                    |d         |           ||d<   ||d<   | 
                    |          |d<   || j        |	<   |                    | j        |	         |           d S )Nr`   r   rY      r_   rc   r   r   r   asksbidsnoncer   r   )rf   re   rM   rl   r[   
orderbooksparse_order_book
order_bookresetr  r   rr   )rS   r]   rs   r`   fullOrderBookr   rw   r_   ry   rc   r   r|   r   currentOrderBooksnapshotr  r  s                    rU   handle_order_bookzcoinex.handle_order_bookb  s   0 (B7722OOFA..	##FA..&&t|]CC!!(D$DD!Sj6)%%i88	??4?FCC 	7,,Y	JJH' OOH55	*3'' OF3	))))??9fb99D??9fb99D/7>>>/7>>>(1W%,5[)+/<<	+B+BZ(&6DOF#tv.<<<<<rV   c                 T  K   |                                   d {V  |                     |           d {V  d}d }|                     d||          \  }}d|                                 d}	|2|                     |          }|d         }|d         g|	d<   |d|z   z  }ng |	d<   | j        d	         d
         |         }
|                     |	|          }|                     |
||||           d {V }| j        r|	                    ||          }| 
                    ||||d          S )Nordersr!   zorder.subscribe)r   r   rc   r   r`   r   r%   r   T)r   r   r   r\   ry   rL   rP   r   r   r   filter_by_symbol_since_limit)rS   rc   r   r   r`   r|   ry   r   r  rs   r   r   r&  s                rU   watch_orderszcoinex.watch_orders  sn     !!!!!!!!!'''''''''88PVWWe'//##
 
 [[((FH%F!'GH3<'KK "GHit$T*""7E22zz#{G['RRRRRRRR? 	3OOFE22E00tTTTrV   c                    |                      |dg           }|                      |di           }|                     |          }| j        0|                     | j        dd          }t          |          | _        | j        }|                    |           d}|                    | j        |           |d|d         z   z  }|                    | j        |           d S )Nr`   rY   ordersLimitr   r&  r   rc   )rf   parse_ws_orderr&  r[   rM   r   rn   rr   )	rS   r]   rs   r`   r   parsedOrderr   r&  r|   s	            rU   handle_orderszcoinex.handle_orders  s    n (B772..))%00;%%dlM4HHE077DKk"""t{K000s[222t{K00000rV   c           	         |                      |dd          }|                     |d          }|                     |d          }|                     ddd|          }|                     |d          }|                     dd	d|          }|                     |d
          }	|                     |d          }
|                     |d          }|                     | j        d          }|                     ||d |          }|                     |d          }|                     |d          }d }|d         rB|                     |d          }t	          j        ||          }t	          j        ||
          }d }d }|                     |                     |d                    }|5|                     |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(|          S ))Nupdate_timemtimery   r   r   )r<   rF   r   sellbuyleftr   statusr_   
deal_money
deal_stockr'   leverage	money_fee	fee_assetquote)currencyr   r   r   order_idclientOrderId	client_idr   r   lastTradeTimestamplast_deal_timerc   timeInForcepostOnlyr   	stopPrice
stop_pricetriggerPricefilled	remaining)r   r   r4  r   r   )safe_timestamp_2re   rM   rl   r   
string_div	omit_zeror   
safe_ordersafe_string_2r   r   parse_ws_order_status)rS   r   ry   r   rw   typeCoder   sideCoder   rG  r   r4  r_   r   rF  r   r7  r   feeCostfeeCurrencyIds                       rU   r+  zcoinex.parse_ws_order  s   D ))%HH	##E844##E622!
 !
   ##E622!
 !
   $$UF33	!!%22!!%22&&t|]CC!!(FD+FF|44!!%66&> 	''z::H%fh77D(88GF..!1!1%!E!EFF ,,UKQQM 33MBB C   
E 
$$$UJ== 
 T--e[AA 
 Y//	 

  
 !$"5"5e=M"N"N 
 fX& 
 D 
 4 
  
 D 
 T%%eW55 
 ))%>> 
 D,,ULAA 
 f 
  f! 
" # 
$ 0088- 
  
  
. /  	rV   c                 :    ddd}|                      |||          S )Npendingok)r=   r<   )re   )rS   r4  statusess      rU   rM  zcoinex.parse_ws_order_status  s.    
 
 &&999rV   c                    |                      |d          }|-t          | j        dz   |                     |          z             |                     |d          }| j        | j        | j        | j        | j	        | j
        | j	        d}|                      ||          }| |||           d S |                     ||           d S )Nerror r   )zstate.updatezasset.updatezdeals.updatezdepth.updatezorder.updatezkline.updatezorder.update_stop)rf   r   r   r   re   r   r   r   r$  r-  r   handle_subscription_status)rS   r]   rs   rW  r   handlershandlers          rU   handle_messagezcoinex.handle_message  s    11#		%0@0@ @AAA!!'844 . / . 2 . -!%!3
 
 //(F33GFG$$$F''88888rV   c                     d}d}|                      |j        |          }|                    d           |                      |j        |          }|                    d           |S )Nauthenticated:spotauthenticated:swapT)rf   futuresrr   )rS   r]   rs   messageHashSpotmessageHashSwap
spotFutureswapFuturess          rU   handle_authentication_messagez$coinex.handle_authentication_message  sg     /. __V^_EE
4   oofnoFFD!!!rV   c                 L   |                      |d          }|                     |j        |          }|p|                     |d          }|dk    r|                     ||           d S |                     |j        |          }||                    d           |j        |= d S d S )Nr   r	  r   T)r[   rf   r   re   r   r`  rr   )rS   r]   rs   r   r  futureIndexr	  s          rU   rY  z!coinex.handle_subscription_status  s    w--v';R@@#**<BBKg%%!!&'222__V^[AAF!t$$$$R((( $#rV   c                 d  K   d }|                      dd |          \  }}| j        d         d         |         }|                     |          }|                                 }|dk    }d}d}|r|n|}	|                    |	          }
|                     |j        |	          }|dk    r||
 d {V S |                                 }||d}d| j        z   d	z   | 	                    |          z   d
z   | j
        z   }|                     |                     |          d          }d| j        |                                |g|d}|                     ||	|||           d|j        |	<   |
 d {V S ||
 d {V S |                                 }||d}d| j        z   dz   | 	                    |          z   d
z   | j
        z   }|                     |                     |          dd          }d| j        |                                |g|d}|                     ||	|||           d|j        |	<   |
 d {V S )Nr   r%   r   r&   r^  r_  r  z
access_id=z&tonce=z&secret_key=md5zserver.signr   Tz&timestamp=r   hex)r   rL   r]   millisecondsr	  rf   r   r\   apiKeynumber_to_stringsecretr   r   upperr   lower)rS   r`   r   r   r]   r   isSpotspotMessageHashswapMessageHashr|   r	  authenticatedrX   r   signDatar   r   s                    rU   r   zcoinex.authenticate  s     99.$PVWWfit$T*S!!  ""&...)/Doo_{++(<kJJ6>>(#||||||#))I) I $dk1I=@U@UVZ@[@[[^llosozzH99T[[22E::D'KJJLL
   G JJsK)YGGG04F -<<<<<<(#||||||#))I) I $dk1MADDYDYZ^D_D__bppsws~~H99T[[22HeDDD'KJJLL
   G JJsK)YGGG04F -<<<<<<rV   )N)+__name__
__module____qualname__rR   r\   r   r   rm   r   r   r   r   r   r   strr   r   r   r   r   r   r   r   r   r	   r   rg   r  r  r  r  r$  r
   r   r(  r-  r+  rM  r\  re  rY  r   __classcell__)rT   s   @rU   r   r      s       ; ; ; ; ;z  
J.F J. J. J. J.X> > > >@ *, H H H H H H*2V 2 2 2 2@"9F "9 "9 "9 "9H   86+6 6+ 6+ 6+ 6+p 68 	0 	0 	0F 	0 	0 	0 	0 6:" E E7 E E E E E6 <@d[] S S SS S Sbfglbm S S S S< @DB )! )!S )! )!S\ )! )! )! )!V 8<$]ajl .C .C .CC .CWZ .Cquvzq{ .C .C .C .C` ;?T`dmo (C (C3 (Cs (CZ] (Ctxy}t~ (C (C (C (CT$ $ $3 3 35= 5= 5= 5= 5=n 04$UYbd U U UC Us Uimnsit U U U U0b1F b1 b1 b1 b1HZ Z Z Zx: : :9V 9 9 9 9(F    () ) ) ) ) )+ 7  7  7  7  7  7  7  7 rV   r   )ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   r   ccxt.base.typesr   r   r   r	   r
   r   r   r   r   !ccxt.async_support.base.ws.clientr   typingr   ccxt.base.errorsr   r   r   r   r   r   ccxt.base.preciser   async_supportr    rV   rU   <module>r     sY       f f f f f f f f f f a a a a a a a a a a a a a a a a a a a a a a 4 4 4 4 4 4       * * * * * * 0 0 0 0 0 0 ' ' ' ' ' ' ) ) ) ) ) ) 1 1 1 1 1 1 + + + + + + % % % % % %P  P  P  P  P T& P  P  P  P  P rV   