
    ei                         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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!  G d
 dej"        j#                  Z#dS )    N)
ArrayCacheArrayCacheBySymbolByIdArrayCacheBySymbolBySideArrayCacheByTimestamp)AnyBalancesBoolIntMarketNumOrder	OrderBook	OrderSide	OrderTypePositionStrStringsTickerTickersTrade)Client)List)ExchangeError)AuthenticationError)NetworkError)ChecksumErrorc                       e Zd Zdef fdZd Zdi fdededefdZ	i fdedefdZ
di fd	ee         dedefd
Zi fd	ee         defdZd Z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edee         fdZddi fd	ee         dededee         fdZi fd	ee         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i fde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i fd	edefdZ defdZ!dJde"de#defdZ$di fd	edefdZ%defd Z&dJd!Z'd"ddi fde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efd&Z+dddi fdedededee,         fd'Z-dJdefd(Z.dddi fd	edededee/         fd)Z0dJded	efd*Z1d+ Z2d, Z3i fde4fd-Z5defd.Z6di fded/e7d0e8d1e9d2e:de,fd3Z;ddi fd4eded/e7d0e8d1e:d2e:de,fd5Z<defd6Z=di fd4edede,fd7Z>di fdefd8Z?defd9Z@i fd:ZAi fd;ZBi i fd<ed	ee         d=ee         d>ee         d?ee         f
d@ZCi fdAZDi fdBZEdedeFfdCZGdefdDZHdefdEZIi fdFZJdefdGZKdefdHZLdefdIZM xZNS )K	cryptocomreturnc                    |                      t          t          |                                           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idddddddddidi d          S )NwsTwatchBalancewatchTickerwatchTickerswatchBidsAskswatchMyTradeswatchTradeswatchTradesForSymbolswatchOrderBookwatchOrderBookForSymbolswatchOrders
watchOHLCVwatchPositionscreateOrderWscancelOrderWscancelAllOrderseditOrderWsz*wss://stream.crypto.com/exchange/v1/marketz(wss://stream.crypto.com/exchange/v1/user)publicprivatez+wss://uat-stream.3ona.co/exchange/v1/marketz)wss://uat-stream.3ona.co/exchange/v1/user)apitest)fetchPositionsSnapshotawaitPositionsSnapshotchecksum)r-   r)   )hasurlsoptions	streaming)deep_extendsuperr   describe)self	__class__s    P/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/pro/cryptocom.pyr?   zcryptocom.describe   sq   i 6 6 ? ? A Ad t 	
     t ( !$ +D t d !$      "4!" t#* "N#M  LJ   /3.2# #
 # S+D
 +D
 + + +	    c                 $  K   	 |                     |                     |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idzpublic/respond-heartbeat)rE   methodz pong failed with error )sendsafe_integer	Exceptionr   rE   exception_messagereset)r@   clientmessageeerrors        rB   pongzcryptocom.pongB   s      	 ++T%6%6w%E%EQkllmmmmmmmmmmm 	  	  	  +E!EH^H^_`HaHa!abbELL	 s   28 
BAB

BNsymbollimitc                 B   K   |                      |g||           d{V S )a  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#book-instrument_name

        :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
        :param str [params.bookSubscriptionType]: The subscription type. Allowed values: SNAPSHOT full snapshot. This is the default if not specified. SNAPSHOT_AND_UPDATE delta updates
        :param int [params.bookUpdateFrequency]: Book update interval in ms. Allowed values: 100 for snapshot subscription 10 for delta subscription
        :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)r@   rQ   rR   paramss       rB   watch_order_bookzcryptocom.watch_order_bookN   s4       66xOOOOOOOOOrC   c                 @   K   |                      |g|           d{V S )aQ  
        unWatches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#book-instrument_name

        :param str symbol: unified symbol of the market to fetch the order book for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.bookSubscriptionType]: The subscription type. Allowed values: SNAPSHOT full snapshot. This is the default if not specified. SNAPSHOT_AND_UPDATE delta updates
        :param int [params.bookUpdateFrequency]: Book update interval in ms. Allowed values: 100 for snapshot subscription 10 for delta subscription
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        N)un_watch_order_book_for_symbolsr@   rQ   rU   s      rB   un_watch_order_bookzcryptocom.un_watch_order_book]   s2       996(FKKKKKKKKKrC   symbolsc                 F  K   |                                   d{V  |                     |          }g }g }|sd}|                     |d          }|i |d<   d}d}|                     |ddd          \  }}|                     |dd|          \  }}||d         d<   d}	d}
|                     |dd          \  }	}|                     |dd|	          \  }
}|
|
|d         d<   t	          d	t          |                    D ]r}||         }|                     |          }d
|d         z   dz   t          |          z   }d|d         z   }|                    |           |                    |           s| 	                    |||           d{V }|
                                S )a  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#book-instrument_name

        :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
        :param str [params.bookSubscriptionType]: The subscription type. Allowed values: SNAPSHOT full snapshot. This is the default if not specified. SNAPSHOT_AND_UPDATE delta updates
        :param int [params.bookUpdateFrequency]: Book update interval in ms. Allowed values: 100 for snapshot subscription 10 for delta subscription
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        N2   rU   r)   bookSubscriptionTypeSNAPSHOT_AND_UPDATEr*   bookUpdateFrequencyr   book.rE   .
orderbook:rQ   )load_marketsmarket_symbols
safe_valuehandle_option_and_paramsrangelenmarketstrappendwatch_public_multiplerR   )r@   r[   rR   rU   topicsmessageHashestopicParamsr^   bookSubscriptionType2r`   bookUpdateFrequency2irQ   rj   currentTopicmessageHash	orderbooks                    rB   rT   z&cryptocom.watch_order_book_for_symbolsk   s&      !!!!!!!!!%%g.. 	Eoofh77!F8# $'+'D'DVM]_u  xM  (N  (N$f(,(E(EfNh  kA  CW  )X  )X%v3Hx/0"#&*&C&CFL\^s&t&t#V'+'D'DVMgi~  AT  (U  (U$f+7KF834q#g,,'' 	( 	(AQZF[[((F'&,6<s5zzIL&)99K  ---MM,''''44]FFSSSSSSSS	   rC   c                 ~  K   |                                   d{V  |                     |          }g }g }g }|                     |dd          }|                     |d          }|i |d<   d}d}	|                     |ddd          \  }}|                     |dd|          \  }	}|	|d         d<   d}
d}|                     |dd	          \  }
}|                     |dd	|
          \  }}|||d         d<   t          d
t          |                    D ]}||         }|                     |          }d|d         z   dz   t          |          z   }d|d         z   }|	                    |           |	                    d|z              |	                    |           | 
                    d|||||           d{V S )av  
        unWatches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#book-instrument_name

        :param str[] symbols: unified array of symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.limit]: orderbook limit, default is 50
        :param str [params.bookSubscriptionType]: The subscription type. Allowed values: SNAPSHOT full snapshot. This is the default if not specified. SNAPSHOT_AND_UPDATE delta updates
        :param int [params.bookUpdateFrequency]: Book update interval in ms. Allowed values: 100 for snapshot subscription 10 for delta subscription
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        NrR   r]   rU   r)   r^   r_   r*   r`   r   ra   rE   rb   rc   rQ   zunsubscribe:rv   )rd   re   rH   rf   rg   rh   ri   rj   rk   rl   un_watch_public_multiple)r@   r[   rU   rn   subMessageHashesro   rR   rp   r^   rq   r`   rr   rs   rQ   rj   rt   ru   s                    rB   rX   z)cryptocom.un_watch_order_book_for_symbols   sI      !!!!!!!!!%%g..!!&'266oofh77!F8# $'+'D'DVM]_u  xM  (N  (N$f(,(E(EfNh  kA  CW  )X  )X%v3Hx/0"#&*&C&CFL\^s&t&t#V'+'D'DVMgi~  AT  (U  (U$f+7KF834q#g,,'' 	( 	(AQZF[[((F'&,6<s5zzIL&)99K##K000  +!=>>>MM,''''22;XhjprxyyyyyyyyyrC   c                     |                      |d          }|                      |d          }|                     |d          }|                    |||g           d S )Nr         )
safe_floatrH   
storeArray)r@   booksidedeltapriceamountcounts         rB   handle_deltazcryptocom.handle_delta   s^    q))**!!%++UFE233333rC   c                 ~    t          dt          |                    D ]}|                     |||                    d S )Nr   )rh   ri   r   )r@   r   deltasrs   s       rB   handle_deltaszcryptocom.handle_deltas   sH    q#f++&& 	3 	3Ahq	2222	3 	3rC   rL   c                    |                      |d          }|                     |          }|d         }|                     |d          }|                     |d          }|                     |d          }|| j        vr4|                     |d          }|                     i |          | j        |<   | j        |         }	|                      |d          }
|                     |dd	          }|}|
d
k    r=|	                    i            ||	d<   ||	d<   |                     |          |	d<   ||	d<   n|                     |di           }|                     |d          }|	d         }||k    rF| 	                    ddd          }|r-t          | j        dz   |                     |          z             |                     |	d         |                     |dg                      |                     |	d         |                     |dg                      ||	d<   |	| j        |<   d|z   }|                    |	|           d S )Ninstrument_namerQ   datar   tdepthchannelusbook	timestampdatetimenonceupdatepur)   r8   T asksbidsrc   )safe_stringsafe_marketrf   rH   
orderbookscounted_order_booksafe_integer_2rK   iso8601handle_optionr   rE   orderbook_checksum_messager   resolve)r@   rL   rM   marketIdrj   rQ   r   r   rR   rv   r   r   bookspreviousNoncecurrentNoncer8   ru   s                    rB   handle_order_bookzcryptocom.handle_order_book   sZ   p ##G->??!!(++!w//tQ''%%dC00	$/))%%gw77E&*&=&=b%&H&HDOF#OF+	""7I66##D#s33fOOB"(Ih%.Ik"$(LL$;$;Ij!!&IgOOD(B77E --dD99M$W-L},,--.>
DQQ a'#8W8WX^8_8_(_```9V,dooeVR.P.PQQQ9V,dooeVR.P.PQQQ"	'"+"V+y+.....rC   sincec                 D   K   |                      |g|||           d{V S )a:  
        get the list of most recent trades for a particular symbol

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#trade-instrument_name

        :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)r@   rQ   r   rR   rU   s        rB   watch_tradeszcryptocom.watch_trades%  s6       22F8UE6RRRRRRRRRrC   c                 @   K   |                      |g|           d{V S )a  
        get the list of most recent trades for a particular symbol

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#trade-instrument_name

        :param str symbol: unified symbol of the market to fetch trades for
        :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)un_watch_trades_for_symbolsrY   s      rB   un_watch_tradeszcryptocom.un_watch_trades3  s2       55vhGGGGGGGGGrC   c                    K   |                                   d{V  |                     |          }g }t          dt          |                    D ]?}||         }|                     |          }d|d         z   }	|                    |	           @|                     |||           d{V }
| j        rB|                     |
d          }| 	                    |d          }|

                    ||          }|                     |
||dd          S )a=  
        get the list of most recent trades for a particular symbol

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#trade-instrument_name

        :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>`
        Nr   trade.rE   rQ   r   T)rd   re   rh   ri   rj   rl   rm   
newUpdatesrf   r   getLimitfilter_by_since_limit)r@   r[   r   rR   rU   rn   rs   rQ   rj   rt   tradesfirsttradeSymbols                rB   r   z"cryptocom.watch_trades_for_symbols?  s*      !!!!!!!!!%%g..q#g,,'' 	( 	(AQZF[[((F(6$<7LMM,''''11&&&IIIIIIII? 	8OOFA..E**5(;;KOOK77E))&%TRRRrC   c                   K   |                                   d{V  |                     |          }g }g }t          dt          |                    D ]]}||         }|                     |          }d|d         z   }|                    d|d         z              |                    |           ^|                     d|||||           d{V S )a  
        get the list of most recent trades for a particular symbol

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#trade-instrument_name

        :param str[] [symbols]: list of unified market symbols to unwatch trades for
        :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   rE   zunsubscribe:trades:rQ   r   )rd   re   rh   ri   rj   rl   rx   )	r@   r[   rU   rn   ro   rs   rQ   rj   rt   s	            rB   r   z%cryptocom.un_watch_trades_for_symbolsZ  s       !!!!!!!!!%%g..q#g,,'' 	( 	(AQZF[[((F(6$<7L  !69I!IJJJMM,''''228WmU[]ceklllllllllrC   c                    |                      |d          }|                      |d          }|                      |d          }|                     |          }|d         }|                     | j        |          }|5|                     | j        dd          }	t          |	          }|| j        |<   |                     |dg           }
t          |
          }|dk    rd S |                     |
|          }t          dt          |                    D ]}|
                    ||                    |                    d	|z   d
          }|                    ||           |                    ||           d S )Nr   r   subscriptionrQ   tradesLimit  r   r   rb    )r   r   rf   r   rH   r;   r   ri   parse_tradesrh   rl   replacer   )r@   rL   rM   r   r   symbolSpecificMessageHashrj   rQ   storedrR   r   
dataLengthparsedTradesjchannelReplaceds                  rB   handle_tradeszcryptocom.handle_tradesp  sq   . ""7I66##G->??$($4$4Wn$M$M!!!(++!f55>%%dlM4HHE&&F"(DKw33YY
??F((v66q#l++,, 	+ 	+AMM,q/****!//#."==v8999v/////rC   c                 H  K   |                                   d{V  d}||                     |          }|d         }d}||dz   |d         z   n|}|                     ||           d{V }| j        r|                    ||          }|                     ||||d          S )aO  
        watches information on multiple trades made by the user

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#user-trade-instrument_name

        :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 <https://docs.ccxt.com/?id=trade-structure>`
        NrQ   
user.traderb   rE   Trd   rj   watch_private_subscriber   r   filter_by_symbol_since_limit)r@   rQ   r   rR   rU   rj   ru   r   s           rB   watch_my_tradeszcryptocom.watch_my_trades         !!!!!!!!![[((FH%F"=C=O{S(6$<77Va33KHHHHHHHH? 	3OOFE22E00tTTTrC   c                    K   |                                   d{V  |                     |          }d|d         z   }|                     ||           d{V S )a  
        watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#ticker-instrument_name

        :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ticker.rE   )rd   rj   watch_public)r@   rQ   rU   rj   ru   s        rB   watch_tickerzcryptocom.watch_ticker  ss       !!!!!!!!!V$$$vd|3&&{F;;;;;;;;;rC   c                    K   |                                   d{V  |                     |          }d|d         z   }d|d         z   }|                     d|d         g|g|g|g|           d{V S )a  
        unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#ticker-instrument_name

        :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   rE   unsubscribe:ticker:rQ   ticker)rd   rj   rx   )r@   rQ   rU   rj   subMessageHashru   s         rB   un_watch_tickerzcryptocom.un_watch_ticker  s       !!!!!!!!!V$$'&,6+fX.>>228fX>N=OR]Q^ao`p  tB  sC  EK  L  L  L  L  L  L  L  L  	LrC   c                 H  K   |                                   d{V  |                     |dd          }g }|                     |          }t          dt	          |                    D ]"}||         }|                    d|z              #| j        d         d         d         }|                                 }dd	|i|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

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#ticker-instrument_name

        :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>`
        NFr   r   r4   r!   r2   	subscribechannelsrF   rU   r   rQ   )rd   re   
market_idsrh   ri   rl   r:   r   watch_multipleextendr   filter_by_arraytickers)r@   r[   rU   ro   	marketIdsrs   r   urlrE   requestr   results               rB   watch_tickerszcryptocom.watch_tickers  sX      !!!!!!!!!%%gtU;;OOG,,	q#i..)) 	7 	7A |H  X!56666it$X.ZZ\\!M 
 
 **3t{{7TZ?[?[]jkkkkkkkk? 	F'-F6(#$M##DL(GDDDrC   c                   K   |                                   d{V  |                     |dd          }g }g }|                     |          }t          dt	          |                    D ]B}||         }||         }|                    d|z              |                    d|z              C|                     d|||||           d{V S )a  
        unWatches a price ticker

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#ticker-instrument_name

        :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>`
        NFr   r   r   r   )rd   re   r   rh   ri   rl   rx   )	r@   r[   rU   ro   ry   r   rs   r   rQ   s	            rB   un_watch_tickerszcryptocom.un_watch_tickers  s      !!!!!!!!!%%gtU;;OOG,,	q#i..)) 	A 	AA |HQZF##I$8999  !6!?@@@@228WmUegwy  A  A  A  A  A  A  A  A  	ArC   c                    |                      ||           |                     |d          }|                     |d          }|                     |          }|                     |dg           }t	          dt          |                    D ]H}||         }|                     ||          }	|	d         }
|	| j        |
<   |                    |	|           Id S )Nr   r   r   r   rQ   )	handle_bid_askr   r   rf   rh   ri   parse_ws_tickerr   r   )r@   rL   rM   ru   r   rj   r   rs   r   parsedrQ   s              rB   handle_tickerzcryptocom.handle_ticker
  s    2 	FG,,,&&w??##G->??!!(++w33q#d))$$ 	0 	0A!WF))&&99FH%F#)DL NN6;////	0 	0rC   r   rj   c                 (   |                      |d          }|                     |d          }|                     ||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k    r|                     |d           nd |d!|          S )"Nr   rs   _quotearQ   r   r   highhlowlbidb	bidVolumebsaskk	askVolumeksvwapopencloselastpreviousClosechange
percentagecaveragevUSDvv)
baseVolumequoteVolumeinfo)rH   r   r   safe_tickerr   safe_number)r@   r   rj   r   r   r   r   s          rB   r   zcryptocom.parse_ws_ticker/  s"   $ %%fc22	##FC00!!(FC88  11,, !
fX&!
!
 Y//!
 D$$VS11	!

 4##FC00!
 4##FC00!
 ))&$77!
 4##FC00!
 ))&$77!
 D!
 D!
 T!
 D!
 T!
 d!
  $**6377!!
" t#!
$ **6377>Cunn4++FD999SW)!
 !
 !
* +  	rC   c                   K   |                                   d{V  |                     |dd          }g }g }|                     |          }t          dt	          |                    D ]@}||         }|                    d||         z              |                    d|z              A| j        d         d         d         }|                                 }	d	d
|i|	d}
|                     ||| 	                    |
|          |           d{V }| j
        ri }|||d         <   |S |                     | j        d|          S )a  

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#ticker-instrument_name

        watches best bid & ask for symbols
        :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>`
        NFr   bidask.r   r4   r!   r2   r   r   r   rQ   )rd   re   r   rh   ri   rl   r:   r   r   r   r   r   bidsasks)r@   r[   rU   ro   rn   r   rs   r   r   rE   r   
newTickersr   s                rB   watch_bids_askszcryptocom.watch_bids_asks]  sx      !!!!!!!!!%%gtU;;OOG,,	q#i..)) 	0 	0A |H  WQZ!7888MM)h.////it$X.ZZ\\!F 
 
  ..sM4;;wX^C_C_anoooooooo
? 	G,6GJx()N##DM8WEEErC   c                     |                      |dg           }|                     |di           }|                     |          }|d         }|| j        |<   d|z   }|                    ||           d S )Nr   r   rQ   r  )	safe_list	safe_dictparse_ws_bid_askr  r   )r@   rL   rM   r   r   parsedTickerrQ   ru   s           rB   r   zcryptocom.handle_bid_ask  sy    ~~gvr22a,,,,V44h' ,f&(|[11111rC   c                    |                      |d          }|                     ||          }|                      |d          }|                     |d          }|                     |||                     |          |                      |d          |                      |d          |                      |d          |                      |d          |d|          S )	Nrs   rQ   r   r   r   r   r   )rQ   r   r   r   r   r   r   r  )r   r   rH   r	  r   )r@   r   rj   r   rQ   r   s         rB   r  zcryptocom.parse_ws_bid_ask  s    ##FC00!!(F33!!&(33%%fc22	"Y//##FC00))&$77##FC00))&$77	!
 	!
 	 	 		rC   1m	timeframec                 r  K   |                                   d{V  |                     |          }|d         }|                     | j        ||          }d|z   dz   |d         z   }|                     ||           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

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#candlestick-time_frame-instrument_name

        :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
        NrQ   candlestick.rb   rE   r   T)rd   rj   r   
timeframesr   r   r   r   )
r@   rQ   r  r   rR   rU   rj   intervalru   ohlcvs
             rB   watch_ohlcvzcryptocom.watch_ohlcv  s       !!!!!!!!!V$$!##DOY	JJ)H4s:VD\I''V<<<<<<<<? 	2NN6511E))%q$GGGrC   c           	      `  K   |                                   d{V  |                     |          }|d         }|                     | j        ||          }d|z   dz   |d         z   }d|d         z   dz   |z   }d|d         |ggi}|                     d	|d         g|g|g|g||           d{V S )
a5  
        unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#candlestick-time_frame-instrument_name

        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        NrQ   r  rb   rE   zunsubscribe:ohlcv::symbolsAndTimeframesr  )rd   rj   r   r  rx   )	r@   rQ   r  rU   rj   r  r   ru   	subExtends	            rB   un_watch_ohlcvzcryptocom.un_watch_ohlcv  s      !!!!!!!!!V$$!##DOY	JJ,x7#=tL*VH-==CiO"fX&6	%B$C
	 227VH=M<NQ\P]`n_o  sA  rB  DJ  LU  V  V  V  V  V  V  V  V  	VrC   c                    |                      |d          }|                      |d          }|                     |          }|d         }|                      |d          }|                     |          }|                     | j        |i           | j        |<   |                     | j        |         |          }	|	;|                     | j        dd          }
t          |
          }	|	| j        |         |<   |                     |d          }t          dt          |                    D ]5}||         }| 
                    ||          }|	                    |           6|                    |	|           d S )	Nr   r   rQ   r  
OHLCVLimitr   r   r   )r   r   find_timeframerf   ohlcvsrH   r;   r   rh   ri   parse_ohlcvrl   r   )r@   rL   rM   ru   r   rj   rQ   r  r  r   rR   r   rs   tickr   s                  rB   handle_ohlcvzcryptocom.handle_ohlcv  sg    &&w??##G->??!!(++!##GZ88''11	"oodk62FFFV!4i@@>%%dlL$GGE*511F-3DK	*w//q#d))$$ 	" 	"A7D%%dF33FMM&!!!!v{+++++rC   c                 H  K   |                                   d{V  d}||                     |          }|d         }d}||dz   |d         z   n|}|                     ||           d{V }| j        r|                    ||          }|                     ||||d          S )aO  
        watches information on multiple orders made by the user

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#user-order-instrument_name

        :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>`
        NrQ   
user.orderrb   rE   Tr   )r@   rQ   r   rR   rU   rj   ru   orderss           rB   watch_orderszcryptocom.watch_orders  r   rC   c                 Z   |                      |d          }|                      |d          }|                     |dg           }t          |          }|dk    r| j        0|                     | j        dd          }t          |          | _        | j        }	|                     |          }
t          dt          |
                    D ]}|		                    |
|                    |
                    |	|           |
                    |	|           |
                    |	d           d S d S )Nr   r   r   r   ordersLimitr   r+  )r   rf   ri   r,  rH   r;   r   parse_ordersrh   rl   r   )r@   rL   rM   r   r   r   r,  ordersLengthrR   r   r   rs   s               rB   handle_orderszcryptocom.handle_orders  s'   > ""7I66$($4$4Wn$M$M!&"556{{!{"))$,tLL4U;;[F&&v..F1c&kk** ) )fQi((((NN6#<===NN67+++NN6<00000 rC   c                 B  K   |                                   d{V  |                                  d{V  | j        d         d         d         }|                                 }dddgi|d}d	}|                     |          }|                     |          sd
d                    |          z   }|                     |          }	|                     |	|           | 	                    ddd          }
| 	                    ddd          }|
r=|r;| j
        4|	                    d           d{V }|                     ||||d          S |                     |||                     ||                     d{V }| j        r|S |                     | j
        |||d          S )a?  
        watch all open positions

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#user-position_balance

        :param str[] [symbols]: list of unified market symbols to watch positions for
        :param int [since]: the earliest time in ms to fetch positions for
        :param int [limit]: the maximum number of positions to retrieve
        :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>`
        Nr4   r!   r3   r   r   user.position_balancer   	positions::,r-   r6   Tr7   )rd   authenticater:   r   re   is_emptyjoinrL   set_positions_cacher   r5  futurefilter_by_symbols_since_limitwatchr   r   )r@   r[   r   rR   rU   r   rE   r   ru   rL   r6   r7   snapshotnewPositionss                 rB   watch_positionszcryptocom.watch_positions,  s      !!!!!!!!!!!!!!!!!!it$Y/ZZ\\!45 
 
 "%%g..}}W%% 	3'!2!22KS!!  111!%!3!34DF^`d!e!e!%!3!34DF^`d!e!e! 	]&< 	]AW#]]+CDDDDDDDDH55hPUW[\\\!ZZ[$++gv:V:VWWWWWWWW? 	 11$.'5RWY]^^^rC   c                     |                      ddd          }|r@d}||j        vr3|                    |           |                     | j        ||           d S d S t                      | _        d S )Nr-   r6   F)r   futuresr<  spawnload_positions_snapshotr   r5  )r@   rL   typer[   r6   ru   s         rB   r;  zcryptocom.set_positions_cacheS  s    !%!3!34DF^`e!f!f! 	82K6>11k***

47MMMMM 21 677DNNNrC   c                   K   |                                   d {V }t                      | _        | j        }t          dt	          |                    D ]<}||         }|                     |dd          }|dk    r|                    |           =||j        v r:|j        |         }|                    |           |                    |d           d S d S )Nr   	contractsr5  )	fetch_positionsr   r5  rh   ri   r
  rl   rC  r   )	r@   rL   ru   r5  cachers   positionrH  r<  s	            rB   rE  z!cryptocom.load_positions_snapshot]  s      ..00000000	133q#i..)) 	' 	'A |H((;BBI1}}X&&&&.((^K0FNN5!!!NN5+..... )(rC   c                 6   |                      |dg           }|                      |di           }|                      |dg           }| j        t                      | _        | j        }g }t          dt	          |                    D ]I}||         }	|                     |	          }
|                    |
           |                    |
           J|                     |d          }t          dt	          |                    D ]}||         }|                    d          }|d         }|                    d          }| 	                    |d|d	          }| 
                    |          s|                    ||           |                    |d           d S )
Nr   r   r5  zpositions::r6  r{   r7  rQ   F)rf   r5  r   rh   ri   parse_positionrl   find_message_hashessplitr   r9  r   )r@   rL   rM   r   	firstDatarawPositionsrJ  r@  rs   rawPositionrK  ro   ru   partssymbolsStringr[   r5  s                    rB   handle_positionszcryptocom.handle_positionsl  s   6 w33OOD!R00	y+rBB>!577DN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1rC   c                 B   K   d}|                      ||           d{V S )ar  
        watch balance and get the amount of funds available for trading or funds locked in orders

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#user-balance

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        user.balanceN)r   )r@   rU   ru   s      rB   watch_balancezcryptocom.watch_balance  s5       %11+vFFFFFFFFFrC   c                    |                      |d          }|                     |dg           }|                     |d         dg           }|| j        d<   t          dt	          |                    D ]}||         }|                      |d          }|                     |          }	|                                 }
|                      |d          |
d<   |                      |d	          |
d
<   |
| j        |	<   |                     | j                  | _        |                    | j        |           |                      |d          }|                    | j        |           d S )Nr   r   r   position_balancesr  r   quantitytotalreserved_qtyusedrE   )	r   rf   balancerh   ri   safe_currency_codeaccountsafe_balancer   )r@   rL   rM   ru   r   positionBalancesrs   r_  
currencyIdcodera  messageHashRequests               rB   handle_balancezcryptocom.handle_balance  sY   \ &&w??w33??474GLL#Vq#.//00 	; 	;A&q)G))'3DEEJ**:66DllnnG#//DDGG"..wGGGFO!(DL,,T\::DLLt|[111!--gt<<t|%788888rC   rF  sider   r   c                    K   |                                   d{V  |                     ||||||          }d|d}|                                 }|                     ||           d{V S )a  

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order

        create a trade order
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nprivate/create-orderrF   rU   )rd   create_order_requestr   watch_private_request)	r@   rQ   rF  rh  r   r   rU   r   ru   s	            rB   create_order_wszcryptocom.create_order_ws  s       !!!!!!!!!**64vufUU,
 
 jjll//WEEEEEEEEErC   rE   c                    K   |                                   d{V  |                     |||||          }d|d}|                                 }	|                     |	|           d{V S )ar  
        edit a trade order

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-amend-order

        :param str id: order id
        :param str symbol: unified market symbol of the order to edit
        :param str [type]: not used by cryptocom editOrder
        :param str [side]: not used by cryptocom editOrder
        :param float amount:(mandatory) how much of the currency you want to trade in units of the base currency
        :param float price:(mandatory) the price for the order, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.clientOrderId]: the original client order id of the order to edit, required if id is not provided
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nprivate/amend-orderrk  )rd   edit_order_requestr   rm  )
r@   rE   rQ   rF  rh  r   r   rU   r   ru   s
             rB   edit_order_wszcryptocom.edit_order_ws   s        !!!!!!!!!((VVUFKK+
 
 jjll//WEEEEEEEEErC   c                     |                      |d          }|                     |di           }|                     |          }|                    ||           d S )NrE   r   )r   rf   parse_orderr   )r@   rL   rM   ru   rawOrderorders         rB   handle_orderzcryptocom.handle_order  s[     &&w55??7Hb99  **uk*****rC   c                    K   |                                   d{V  |                     d|i|          }d|d}|                                 }|                     ||           d{V S )a  
        cancels an open order

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-order

        :param str id: the order id of the order to cancel
        :param str [symbol]: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Norder_idprivate/cancel-orderrk  )rd   r   r   rm  )r@   rE   rQ   rU   r   ru   s         rB   cancel_order_wszcryptocom.cancel_order_ws*  s       !!!!!!!!!
  -
 
 jjll//WEEEEEEEEErC   c                    K   |                                   d{V  d}d|                     i |          d}|&|                     |          }|d         |d         d<   |                                 }|                     ||           d{V S )a  
        cancel all open orders

        https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-all-orders

        :param str symbol: unified market symbol of the orders to cancel
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict} Returns exchange raw message {@link https://docs.ccxt.com/?id=order-structure:
        Nprivate/cancel-all-ordersrk  rE   rU   r   )rd   r   rj   r   rm  )r@   rQ   rU   rj   r   ru   s         rB   cancel_all_orders_wszcryptocom.cancel_all_orders_ws@  s       !!!!!!!!!1kk"f--
 
 [[((F39$<GH/0jjll//WEEEEEEEEErC   c                 ^    |                      |d          }|                    ||           d S )NrE   )r   r   )r@   rL   rM   ru   s       rB   handle_cancel_all_ordersz"cryptocom.handle_cancel_all_ordersV  s3     &&w55w,,,,,rC   c                    K   | j         d         d         d         }|                                 }dd|gi|d}|                     ||          }|                     ||||           d {V S Nr4   r!   r2   r   r   r   )r:   r   r   r>  r@   ru   rU   r   rE   r   rM   s          rB   r   zcryptocom.watch_publica  s      it$X.ZZ\\![M 
 
 ++gv..ZZ[';GGGGGGGGGrC   c                    K   | j         d         d         d         }|                                 }dd|i|d}|                     ||          }|                     ||||           d {V S r  )r:   r   r=   r   )r@   ro   rn   rU   r   rE   r   rM   s           rB   rm   zcryptocom.watch_public_multiplen  s      it$X.ZZ\\!F 
 
 ""7F33((mWmTTTTTTTTTrC   topicro   ry   rn   c           
      H  K   | j         d         d         d         }|                                 }	dd|i|	t          |	          d}
t          |	          ||||d}|                     |
|          }|                     |||||                     ||                     d {V S )Nr4   r!   r2   unsubscriber   )rF   rU   r   rE   )rE   r  r[   ry   ro   )r:   r   rk   r=   r   r   )r@   r  r[   ro   ry   rn   rU   r!  r   rE   r   r   rM   s                rB   rx   z"cryptocom.un_watch_public_multiple{  s      it$X.ZZ\\#F b''
 
 b'' 0*
 
 ""7F33((mWmUYU`U`amoxUyUyzzzzzzzzzrC   c                    K   |                                   d {V  | j        d         d         d         }||d}|                     ||          }|                     |t	          |          |d           d {V S )Nr4   r!   r3   )rE   r   T)r8  r:   r   r>  rk   )r@   r   rU   r   r   rM   s         rB   rm  zcryptocom.watch_private_request  s      !!!!!!!!!it$Y/
 
 ++gv..ZZSZZ$?????????rC   c                   K   |                                   d {V  | j        d         d         d         }|                                 }dd|gi|d}|                     ||          }|                     ||||           d {V S )Nr4   r!   r3   r   r   r   )r8  r:   r   r   r>  r  s          rB   r   z!cryptocom.watch_private_subscribe  s      !!!!!!!!!it$Y/ZZ\\![M 
 
 ++gv..ZZ[';GGGGGGGGGrC   c                 `   |                      |d          }|                      |d          }	 |r|dk    r| j        dz   |                     |          z   }|                     | j        d         ||           |                     |d          }|"|                     | j        d         ||           t          |          dS # t          $ r`}t          |t                    r*d	}|                    ||           ||j        v r|j        |= n|                    ||           Y d }~d
S d }~ww xY w)NrE   re  0r   exactrM   broadFauthenticatedT)r   rE   jsonthrow_exactly_matched_exception
exceptionsrf   throw_broadly_matched_exceptionr   rI   
isinstancer   rejectsubscriptions)	r@   rL   rM   rE   	errorCodefeedbackmessageStringrN   ru   s	            rB   handle_error_messagezcryptocom.handle_error_message  sT    gt,,$$Wf55		 .Y#--7S=499W+=+==44T_W5MyZbccc $ C C ,889QS`bjkkk#H---5 	 	 	!011 %-a---&"666,[9a$$$44444	s   BC 
D-AD((D-c           
         | j         | j        | j        | j        | j        | j        | j        | j        | j        d	}|                     |dd          }|                     |d          }|/|	                    d          dk    r|                     ||           |+|
                    d          r|                     ||           |                     ||          }| |||           d S d S )N)	candlestickr   trader   zbook.updater+  r   rW  r4  r   r  r   r   r+  )r)  r   r   r   r2  rg  rU  safe_value_2r   find
startswithrf   )r@   rL   rM   methodsr   r   rF   s          rB   handle_subscribezcryptocom.handle_subscribe  s   ,('*1,, /%)%:

 

 ""7Hf==""6955W\\,%?%?"%D%Dvv...W%7%7%E%Evv...'22F66""""" rC   c                 ,   |                      ||          rd S |                     |d          }| j        | j        | j        | j        | j        | j        | j        | j        | j        | j        d
}|                     ||          }| |||           d S d S )NrF   )
r   zpublic/heartbeatpublic/authrj  rp  rz  r}  zprivate/close-positionr   r  )	r  r   handle_pinghandle_authenticaterw  r  r  handle_unsubscriberf   )r@   rL   rM   rF   r  
callMethods         rB   handle_messagezcryptocom.handle_message  s    D $$VW55 	F!!'844  $ 03$($5#'#4$($5)-)F&*&7.2
 
 __Wf55
!Jvw''''' "!rC   c                 v  K   |                                   | j        d         d         d         }|                     |          }d}|                    |          }|                     |j        |          }|d}t          |                                           }||z   | j        z   |z   }	| 	                    | 
                    |	          | 
                    | j                  t          j                  }
|||| j        |
d}|                     ||          }|                     ||||           | d {V S )Nr4   r!   r3   r  r  )rE   r   rF   api_keysig)check_required_credentialsr:   rL   reusableFuturerf   r  rk   r   apiKeyhmacencodesecrethashlibsha256r   r>  )r@   rU   r   rL   ru   r<  r  rF   r   auth	signaturer   rM   s                rB   r8  zcryptocom.authenticate  s/     '')))it$Y/S!!%&&{33(<kJJ "F

%%EE>DK/%7D		$++d"3"3T[[5M5Mw~^^I ;  G kk'622GJJsK+>>>||||||rC   c                 >    |                      | j        ||           d S N)rD  rP   )r@   rL   rM   s      rB   r  zcryptocom.handle_ping*  s     

49fg.....rC   c                 f    |                      |j        d          }|                    d           d S )Nr  T)rf   rC  r   )r@   rL   rM   r<  s       rB   r  zcryptocom.handle_authenticate-  s1     AAtrC   c                 t   |                      |d          }t          |j                                                  }t	          dt          |                    D ]}||         }||j        vr|                    d          r|j        |         }|                      |d          }||k    rS|                     |dg           }	|                     |dg           }
t	          dt          |	                    D ])}|	|         }|
|         }|                     |||           *| 	                    |           d S )NrE   r   r  ro   ry   )
r   listr  keysrh   ri   r  r  clean_unsubscriptionclean_cache)r@   rL   rM   rE   r  rs   ru   r   subIdro   ry   r   	unsubHashsubHashs                 rB   r  zcryptocom.handle_unsubscribe4  sN   gt,,F(--//00q#d))$$ 	/ 	/Aq'K6#777%%m44 /%3K@((t<<;; $|_b Q Q#'>>,@RTV#W#W q#m"4"455 J JA -a 0I.q1G--fgyIIII  ...!	/ 	/rC   r  )O__name__
__module____qualname__r   r?   rP   rk   r
   r   rV   rZ   r   rT   rX   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   dictr   r   r  r   r  r  r  r"  r)  r   r-  r2  r   rA  r;  rE  rU  r   rX  rg  r   r   floatr   rn  rr  rw  r{  r~  r  r   rm   rx   rm  r   r	   r  r  r  r8  r  r  r  __classcell__)rA   s   @rB   r   r      s	       ,# , , , , , ,\
  
  
  @DB P PS P PS\ P P P P =? L L L3 L L L L SW_a )! )!$s) )!C )!fo )! )! )! )!V PR )z )zT#Y )zV_ )z )z )z )zV4 4 43 3 3X/ X/ X/ X/ X/t <@d[] S S SS S Sbfglbm S S S S 9; 
H 
HC 
HtE{ 
H 
H 
H 
H OSaenp S Sd3i S S[^ Suyz  vA S S S S6 LN m mc mRU m m m m,*0F *0 *0 *0 *0X 37TX\eg U UC Us URU Ulpqvlw U U U U0 68 < < <F < < < < 9; L LC Ls L L L L  6:" E E7 E E E E EB 9=R A Ag AC A A A A,#0F #0 #0 #0 #0J, ,d ,F ,f , , , ,\ 8<B !F !FW !F7 !F !F !F !FF2V 2 2 2 2     ?CQUdhqs H H H H3 H^a Hx|  ~B  yC H H H H. BFb V V3 V3 VUX V V V V,,6 , , , ,< 04$UYbd U U UC Us Uimnsit U U U U0.1 .1F .1 .1 .1 .1` 8<$]ajl %_ %_W %_C %_WZ %_quv~q %_ %_ %_ %_N8 8& 8 8 8 8 8/ / /02 02 02d *, 
G 
G 
G 
G 
G 
G=9V =9 =9 =9 =9~ pt|~ F FC Fy F	 F[` Fil F  DI F F F F. im{  IK F Fc F3 Fi Fy Fbe Fux F  PU F F F F2+6 + + + +" <@ F F FS Fu F F F F, 8<B F F F F F F,	-v 	- 	- 	- 	- 68 H H H H IK U U U U _a  mo { {C {$s) {\`ad\e {y}  B  zC {  MQ  RU  MV { { { {* 9; @ @ @ @ AC H H H H6 t    <#v # # # #03(V 3( 3( 3( 3(j )+    ./& / / / /&    / / / / / / / / /rC   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   r   r   r   r   r   r   !ccxt.async_support.base.ws.clientr   typingr   ccxt.base.errorsr   r   r   r   async_supportr    rC   rB   <module>r     s       A  A  A  A  A  A  A  A  A  A  A  A  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z  Z 4 4 4 4 4 4       * * * * * * 0 0 0 0 0 0 ) ) ) ) ) ) * * * * * *u/ u/ u/ u/ u/", u/ u/ u/ u/ u/rC   