
    ":h                         d dl Zd dl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 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j4                  j6                        Zy)    N)
ArrayCacheArrayCacheBySymbolById)	AnyIntOrder	OrderBookStrStringsTickerTickersTrade)Client)List)ExchangeError)AuthenticationError)ArgumentsRequired)
BadRequest)	BadSymbolc            
       4    e Zd Zdef fdZd Zddi fdZg di 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di fd	ee   dededee   fdZdddi fdedededee   fdZdddi fd	edededee   fdZdddi fd	edededee   fdZdddi fdedededee   fdZdi fd	ee   dedefdZdi fdededefdZdefdZdefdZd$ fd	Zd Z defdZ!d$dZ"defdZ#d$de	f fdZ$d Z%d Z&defd Z'defd!Z(defd"Z)defd#Z* xZ+S )%coinbaseexchangereturnc                     | j                  t        t        |          dddddddddddddddddiddiddddd	d
      S )NTF)ws
watchOHLCVwatchOrderBookwatchOrderBookForSymbolswatchTickerwatchTickerswatchTradeswatchTradesForSymbolswatchMyTradesForSymbolswatchBalancewatchStatuswatchOrderswatchOrdersForSymbolswatchMyTradesr   z#wss://ws-feed.exchange.coinbase.comz2wss://ws-feed-public.sandbox.exchange.coinbase.com)apitest  )tradesLimitordersLimitmyTradesLimit)hasurlsoptions)deep_extendsuperr   describe)self	__class__s    S/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/pro/coinbaseexchange.pyr2   zcoinbaseexchange.describe   s    &6 F H#"&,0# $#)-+/ %$#)-!%$ ? N	  $#!%3K
  	    c                 2   | j                          d}| j                         }t        |      dz   |z   }| j                  | j	                  |      | j                  | j                        t        j                  d      }|| j                  || j                  dS )Nz/users/self/verifyGETbase64)	timestampkey	signature
passphrase)check_required_credentialsnoncestrhmacencodebase64_to_binarysecrethashlibsha256apiKeypassword)r3   pathr?   payloadr<   s        r5   authenticatezcoinbaseexchange.authenticate6   s    '')#

e*u$t+IIdkk'2D4I4I$++4VX_XfXfhpq	;;"--	
 	
r6   Nc                 R  K   | j                          d {    d }|}g }|0| j                  |      }|d|d   z   z  }|j                  |d          | j                  d   d   }d|v r|dz   }d||gd}	| j	                  |	|      }
| j                  |||
|       d {   S 7 7 w)	N:idr'   r   r<   ?	subscribetypeproduct_idschannels)load_marketsmarketappendr.   extendwatch)r3   namesymbolmessageHashStartparamsrV   messageHash
productIdsurlrP   requests              r5   rP   zcoinbaseexchange.subscribeC   s     !!!&
[[(F3--KfTl+iit$& )C%
	 ++i0ZZ[';GGG) 	"( Hs"   B'B#BB'B%B'%B'c                   K   | j                          d {    d }| j                  |      }g }g }t        dt        |            D ]F  }||   }	| j	                  |	      }|j                  |d          |j                  |dz   |d   z          H | j                  d   d   }
d|v r|
dz   }
d	||gd
}| j                  ||      }| j                  |
|||       d {   S 7 7 w)Nr   rN   rM   r[   r'   r   r<   rO   rP   rQ   )	rU   market_symbolsrangelenrV   rW   r.   rX   watch_multiple)r3   rZ   symbolsr\   r]   rV   messageHashesr_   ir[   r`   rP   ra   s                r5   subscribe_multiplez#coinbaseexchange.subscribe_multipleZ   s    !!!%%g.
q#g,' 	LAQZF[[(FfTl+  !1C!7&:J!JK		L
 iit$& )C%
	 ++i0((mWmTTT- 	", Us"   C$C CC$C"C$"C$r[   c                 J   K   d}| j                  ||||       d{   S 7 w)a  
        watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        tickerN)rP   )r3   r[   r]   rZ   s       r5   watch_tickerzcoinbaseexchange.watch_tickers   s(      ^^D&$????s   #!#rg   c                 <  K   | j                          d{    t        |      }|dk(  rt        | j                  dz         d}d}| j	                  ||||       d{   }| j
                  ri }|||d   <   |S | j                  | j                  d|      S 7 7 ;w)a3  
        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
        :param str [params.channel]: the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   z0 watchTickers requires a non-empty symbols arrayrl   r[   )rU   re   r   rN   rj   
newUpdatesfilter_by_arraytickers)r3   rg   r]   symbolsLengthchannelr^   rl   results           r5   watch_tickerszcoinbaseexchange.watch_tickers}   s      !!!GADGG&XXYY..wfUU??F'-F6(#$M##DLL(GDD 	" Vs"   BBABB:BBsincelimitc                   K   | j                          d{    | j                  |      }d}| j                  ||||       d{   }| j                  r|j	                  ||      }| j                  |||dd      S 7 f7 9w)a  
        get the list of most recent trades for a particular symbol
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        Nmatchesr:   T)rU   r[   rP   ro   getLimitfilter_by_since_limit)r3   r[   rv   rw   r]   rZ   tradess          r5   watch_tradeszcoinbaseexchange.watch_trades   s      !!!V$~~dFD&AA??OOFE2E))&%TRR 	" Bs!   BA=.BA?8B?Bc                   K   t        |      }|dk(  rt        | j                  dz         | j                          d{    | j	                  |      }d}| j                  ||||       d{   }| j                  r6| j                  |d      }| j                  |d      }	|j                  |	|      }| j                  |||dd      S 7 7 ]w)a  
        get the list of most recent trades for a particular symbol
        :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>`
        r   z> watchTradesForSymbols() requires a non-empty array of symbolsNry   r[   r:   T)re   r   rN   rU   rc   rj   ro   
safe_valuesafe_stringrz   r{   )
r3   rg   rv   rw   r]   rr   rZ   r|   firsttradeSymbols
             r5   watch_trades_for_symbolsz)coinbaseexchange.watch_trades_for_symbols   s      GATWW'gghh!!!%%g...tWdFKK??OOFA.E**5(;KOOK7E))&%TRR 	" Ls"   <CC	.C-C.ACCc           	      ~  K   |t        | j                  dz         | j                          d{    | j                  |      }d}d}| j	                         }| j                  |||| j                  ||             d{   }| j                  r|j                  ||      }| j                  |||dd      S 7 7 9w)a  
        watches information on multiple trades made by the user
        :param str symbol: unified market symbol of the market trades were made in
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trade structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nz+ watchMyTrades() requires a symbol argumentusermyTradesr:   T)
r   rN   rU   r[   rK   rP   rX   ro   rz   r{   )	r3   r[   rv   rw   r]   rZ   r^   authenticationr|   s	            r5   watch_my_tradesz coinbaseexchange.watch_my_trades   s      >#DGG.[$[\\!!!V$ **,~~dFKVUcAdee??OOFE2E))&%TRR 	"
 f"   .B=B9AB=B;8B=;B=c           	        K   | j                  |dd      }| j                          d{    d}d}| j                         }| j                  |||| j	                  ||             d{   }| j
                  r6| j                  |d      }	| j                  |	d      }
|j                  |
|      }| j                  |||dd      S 7 7 ]w)	a  
        watches information on multiple trades made by the user
        :param str[] symbols: unified symbol of the market to fetch trades for
        :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>`
        NFr   r   r   r[   r:   T)
rc   rU   rK   rj   rX   ro   r   r   rz   r{   )r3   rg   rv   rw   r]   rZ   r^   r   r|   r   r   s              r5   watch_my_trades_for_symbolsz,coinbaseexchange.watch_my_trades_for_symbols   s      %%gtU;!!! **,..tWk4;;W]_mKnoo??OOFA.E**5(;KOOK7E))&%TRR 	" ps"   'C	C?C	)C*AC	C	c           	        K   | j                          d{    | j                  |dd      }d}d}| j                         }| j                  |||| j	                  ||             d{   }| j
                  r6| j                  |d      }	| j                  |	d      }
|j                  |
|      }| j                  |||dd      S 7 7 ]w)	a  
        watches information on multiple orders made by the user
        :param str[] symbols: unified symbol of the market to fetch orders for
        :param int [since]: the earliest time in ms to fetch orders 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 `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        NFr   ordersr   r[   r:   T)
rU   rc   rK   rj   rX   ro   r   r   rz   r{   )r3   rg   rv   rw   r]   rZ   r^   r   r   r   r   s              r5   watch_orders_for_symbolsz)coinbaseexchange.watch_orders_for_symbols   s      !!!%%gtU;**,..tWk4;;W]_mKnoo??OOFA.E**5(;KOOK7E))&%TRR 	"
 ps#   C	CAC	)C*AC	C	c           	      ~  K   |t        | j                  dz         | j                          d{    | j                  |      }d}d}| j	                         }| j                  |||| j                  ||             d{   }| j                  r|j                  ||      }| j                  |||dd      S 7 7 9w)a  
        watches information on multiple orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz  watchMyTrades requires a symbolr   r   r:   T)
r   rN   rU   r[   rK   rP   rX   ro   rz   r{   )	r3   r[   rv   rw   r]   rZ   r^   r   r   s	            r5   watch_orderszcoinbaseexchange.watch_orders   s      >DGG&HHII!!!V$**,~~dFKVUcAdee??OOFE2E))&%TRR 	"
 fr   c                 6  K   t        |      }|dk(  rt        | j                  dz         d}| j                          d{    | j	                  |      }| j                  |      }g }t        d|      D ]  }||   }	|j                  |dz   |	z            | j                  d   d   }
d||gd	}| j                  ||      }||||d
}| j                         }| j                  |
|| j                  ||      ||       d{   }|j                         S 7 7 w)a  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str[] symbols: unified array of symbols
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        r   zA watchOrderBookForSymbols() requires a non-empty array of symbolslevel2NrM   r'   r   rP   rQ   )r^   rg   	marketIdsrw   )re   r   rN   rU   rc   
market_idsrd   rW   r.   rX   rK   rf   rw   )r3   rg   rw   r]   rr   rZ   r   rh   ri   marketIdr`   rP   ra   subscriptionr   	orderbooks                   r5   watch_order_book_for_symbolsz-coinbaseexchange.watch_order_book_for_symbols  sI     GATWW'jjkk!!!%%g.OOG,	q-( 	8A |H  h!67	8 iit$$
	 ++i0"	
 **,--c=$++gWeBfhu  xD  E  E	  1 	". Es$   >D DB?D DDDc                   K   d}| j                          d{    | j                  |      }|d   }|dz   |d   z   }| j                  d   d   }d|d   g|gd	}| j                  ||      }	|||d   |d
}
| j	                         }| j                  ||| j                  |	|      ||
       d{   }|j                         S 7 7 w)a  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        r   Nr[   rM   rN   r'   r   rP   rQ   )r^   r[   r   rw   )rU   rV   r.   rX   rK   rY   rw   )r3   r[   rw   r]   rZ   rV   r^   r`   rP   ra   r   r   r   s                r5   watch_order_bookz!coinbaseexchange.watch_order_book3  s      !!!V$!Sj6$</iit$t 
	 ++i0&t	
 **,**S+t{{7N7[]hjvww	  / 	", xs"   CCBC/C0CCclientc                 ^   | j                  |d      }|| j                  |      }|d   }d}|dz   |z   }| j                  | j                  |      }|7| j	                  | j
                  dd      }	t        |	      }|| j                  |<   |j                  |       |j                  ||       |S )N
product_idr[   ry   rM   r*   r)   )	r   parse_ws_trader   r|   safe_integerr/   r   rW   resolve)
r3   r   messager   trader[   rR   r^   tradesArrayr*   s
             r5   handle_tradezcoinbaseexchange.handle_tradeU  s     ##G\:''0E8_F D*x/K//$++v>K""//mTR(5&1F#u%NN;4r6   c                 $   | j                  |d      }|{| j                  |      }d}|dz   |z   }| j                  }|/| j                  | j                  dd      }t        |      }|| _        |j                  |       |j                  ||       |S )Nr   r   rM   r,   r)   )r   r   r   r   r/   r   rW   r   )	r3   r   r   r   r   rR   r^   r   rw   s	            r5   handle_my_tradez coinbaseexchange.handle_my_tradev  s    ##G\:''0ED*x/K--K"))$,,N4U; +u%NN;4r6   c                    t         t        |   |      }d }d}d|v rd}d|d<   | j                  |d      }n5d|d<   | j                  |d      }|d   }| j	                  d	d
d||      |d<   |rdnd}| j	                  ||      |d<   | j                  |d         }|d   }d }	|d   || j                  |d      }
|
|z  }	||	|d|d<   |S )NFmaker_fee_rateTmakertakerOrMakertakertaker_fee_ratesidesellbuy)r   r   maker_order_idtaker_order_idorderr[   quotecost)rater   currencyfee)r1   r   parse_tradesafe_numberr   rV   )r3   r   rV   parsedfeeRateisMakercurrentSideidKeyfeeCurrencyfeeCostr   r4   s              r5   r   zcoinbaseexchange.parse_ws_trade  s#   f ':5Au$G%,F>"&&u.>?G%,F>"&&u.>?G !.K!--/ K)F6N %, 1A**5%8wVH-.Wo6N&W-@##FF3DWnG#
u
 r6   c                 2    ddd}| j                  ||d      S )Nclosedcanceled)filledr   open)r   )r3   statusstatusess      r5   parse_ws_order_statusz&coinbaseexchange.parse_ws_order_status  s&    "
 &&99r6   c                    | j                   }|/| j                  | j                  dd      }t        |      }|| _         | j	                  |d      }| j	                  |d      }|d|z   }| j                  |      }| j	                  |d      }	| j	                  |d      }
| j	                  |d      }| j                   }| j                  |j                  |i       }| j                  ||	      }|| j                  ||
|      }|5| j                  |      }|j                  |       |j                  ||       y | j                  |d	      }| j                  |d
i       }| j                  |d	      }|||kD  r|dk(  r.| j                  |      }|d   g |d<   |d   j                  |       |d   |d<   d}d}|d   }t        dt        |            D ]1  }||   }| j                  ||d         }| j                  ||d         }3 |dkD  r||z  |d<   ||d<   |d   #|dxx   |d   z  cc<   |d   |d   |d   z
  |d<   |d   d|d   d   d|d<   |d   d   ,|d   d   $| j                  |d   d   |d   d         |d   d<   |j                  |       |j                  ||       y |dk(  s|dk(  r| j!                  |d
   |      }| j                  |      }t#        |j%                               }t        dt        |            D ]  }||   }||   ||   ||<    |j                  |       |j                  ||       y y y y )Nr+   r)   rR   r   zorders:order_idr   r   sequenceinfomatchr|   r:   lastTradeTimestampr   r   amountaverager   	remainingr   r   )r   r   receiveddone)r   r   r/   r   r   safe_symbolr   hashmapsafe_value_2parse_ws_orderrW   r   r   rd   re   sumrX   listkeys)r3   r   r   currentOrdersrw   rR   r   r^   r[   orderIdmakerOrderIdtakerOrderIdr   previousOrderspreviousOrderr   r   previousInfopreviousSequencer   	totalCosttotalAmountr|   ri   
tradeEntryr   r   r   r;   s                                r5   handle_orderzcoinbaseexchange.handle_order  s   ^  %%dllM4HE259M'DK0##G\:#h.K%%h/F&&w
;G++G5EFL++G5EFL[[F!__V^^VRHN OONGDM$ $ 1 1.,P\ ]$,,W5f%v{3,,WjA#}fbI#'#4#4\:#N $,(=M2Mw $ 3 3G <(2:68M(3%h/66u=>CK>P&:;$%	&'!.x!8!&q#f+!6 VA)/J(,Jv<N(OI*.((;
8@T*UKV '?7@;7NM)409f-(2>)(3uXF3,X6B=J8=TWdemWn=nk :(/7(),1%L,D4M%0 *%08D5QV<X^K_Kk;?88MRWDXY_D`bghmbnoubv;wM%08m4v{;*,$&.#{{=+@'J $ 3 3D 9#EJJL1!&q#d)!4 @A"&q'C$Sz55:3Zc 2@
 m4v{; 3A? 3N'  r6   c           	         | j                  |d      }| j                  |d      }| j                  |d      }| j                  |      }| j                  |d      }| j                  |d      }| j                  |dd      }	| j                  |d      }
| j	                  |
      }| j                  |d	      }| j                  |      }| j                  |d
      }| j                  |d      }| j                  |d      }d }|	||	|z
  }n|dk(  r	d}|	|	|z
  }| j                  i d|d|d|d|d|d| j                  |      dd d|dd dd d|d|dd dd d|	dd dd |||d d d      S )Nr   
client_oidr   r   pricesizefundstimereason
order_typeremaining_sizerR   r   r   r   r[   rN   clientOrderIdr:   datetimer   timeInForcepostOnly	stopPricetriggerPricer   r   r   )r   r   r   r   r|   )r   r   r   safe_number_2	parse8601r   
safe_orderiso8601)r3   r   rV   rN   r   r   r[   r   r   r   r   r:   r   r   	orderTyper   rR   r   s                     r5   r   zcoinbaseexchange.parse_ws_ordert  s,   eZ0((=##E<8!!(+v.  0##E67;v.NN4(	!!%2++F3$$UL9	$$U,<=	v.Y%:i'FZF!"VO	  
E 
f 
 " 
 ]	 

  
 Y/ 
 !$ 
 I 
 4 
  
 D 
 U 
  
 D 
 f 
  D! 
" t# 
$ "- 
  	r6   c                     | j                  |d      }|S| j                  |      }|d   }|| j                  |<   d|z   }d|z   }|j                  ||       |j                  ||       |S )Nr   r[   zticker:)r   parse_tickerrq   r   )r3   r   r   r   rl   r[   r^   idMessageHashs           r5   handle_tickerzcoinbaseexchange.handle_ticker  sy    ( ##G\:&&w/FH%F#)DLL #f,K%0MNN6;/NN6=1r6   c                    | j                  |d      }|t        t        |   ||      S | j                  |d      }| j	                  ||d      }| j                  | j                  |d            }| j                  |d      }| j                  i d|d|d| j                  |      d	| j                  |d
      d| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      dd d| j                  |d      d|d|dd dd dd dd | j                  |d      d |d      S ) NrR   r   -r   r   r[   r:   r   highhigh_24hlowlow_24hbidbest_bid	bidVolumebest_bid_sizeaskbest_ask	askVolumebest_ask_sizevwapr   open_24hcloselastpreviousClosechange
percentager   
volume_24h)
baseVolumequoteVolumer   )r   r1   r   r   r   r   safe_tickerr   )	r3   rl   rV   rR   r   r[   r:   r  r4   s	           r5   r   zcoinbaseexchange.parse_ticker  s   , /<)4=ffMM##FL9!!(FC8NN4#3#3FF#CD	0 !
f!
!
 Y/!
 D$$VZ8	!

 4##FI6!
 4##FJ7!
 ))&/B!
 4##FJ7!
 ))&/B!
 D!
 D$$VZ8!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **6<@)!
  	r6   c                 p    | j                  |d      }| j                  |d      }|j                  ||       y )Nr      )r   store)r3   booksidedeltar   r   s        r5   handle_deltazcoinbaseexchange.handle_delta  s4      *!!%+uf%r6   c                 b    t        dt        |            D ]  }| j                  |||           y )Nr   )rd   re   r  )r3   r  deltasri   s       r5   handle_deltaszcoinbaseexchange.handle_deltas  s0    q#f+& 	3Ahq	2	3r6   c                    | j                  |d      }| j                  |d      }| j                  |d d      }|d   }d}|dz   |z   }| j                  |j                  |i       }	| j	                  |	d      }
|dk(  r| j                  i |
      | j                  |<   | j                  |   }| j                  |d	   | j                  |d	g              | j                  |d
   | j                  |d
g              d |d<   d |d<   ||d<   |j                  ||       y |dk(  r| j                  |   }| j                  | j                  |d            }| j                  |dg       }d	d
d}t        dt        |            D ]f  }||   }| j                  |d      }| j                  ||      }| j                  |d      }| j                  |d      }||   }|j                  ||       h ||d<   | j                  |      |d<   |j                  ||       y y )NrR   r   r   r[   r   rM   rw   snapshotasksbidsr:   r   l2updater   changes)r   r   r   r     )r   safe_marketr   subscriptionsr   
order_book
orderbooksr   r   r   rd   re   r   r  r   )r3   r   r   rR   r   rV   r[   rZ   r^   r   rw   r   r:   r&  sidesri   r  r;   r   r   r   r  s                         r5   handle_order_bookz"coinbaseexchange.handle_order_book  s*   4 0##G\:!!(D#6!Sj8+v';';["M!!,8:&*oob%&@DOOF#/Iy0$//'6SU2VWy0$//'6SU2VW%)Ik"$(Ij!"(IhNN9k2Z/It'7'7'HIIoogy"=GE 1c'l+ . &&vq1''s3((3))&!4$T?uf-. &/Ik"$(LL$;Ij!NN9k2%  r6   c                     |S N )r3   r   r   s      r5   handle_subscription_statusz+coinbaseexchange.handle_subscription_status>  s	     r6   c                     | j                  |d      }| j                  |d      }	 |dk(  rt        d|z         t        | j                  dz   |z         # t        $ r}|j                  |       Y d }~yd }~ww xY w)Nr   r   zAuthentication FailedzAuthentication failed:  T)r   r   r   rN   	Exceptionreject)r3   r   r   errMsgr   errors         r5   handle_error_messagez%coinbaseexchange.handle_error_messageL  s~      !!'95!!'84	00)*Cf*LMM#DGGcMF$:;; 	MM% 	s   .A 	A8A33A8c           
         | j                  |d      }| j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j
                  d	}t        |j                        dz
  }|j                  |dz
     dk(  }| j                  ||      }|@|dk(  r:|r%| j                  ||       | j	                  ||       y | j                  ||       y y  |||       y )NrR   )	r"  r%  rP   rl   r   r   r  r   r7  r   r  rO   r   )r   r-  r1  r   r   r8  re   r`   r   r   r   )r3   r   r   rR   methodslengthauthenticatedmethods           r5   handle_messagezcoinbaseexchange.handle_messageg  s    0....88(())%%''%%..

 VZZ1$

6A:.#5$/>w ((9%%fg6%%fg6  67#r6   r/  ),__name__
__module____qualname__r   r2   rK   rP   rj   r@   r   rm   r
   r   ru   r   r   r   r}   r   r	   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r-  r1  r8  r>  __classcell__)r4   s   @r5   r   r      s   # B
 ,0$r H. 68$WY U2 68 @ @F @ 6:" E7 E E* <@d[] S SS S Sbfglbm S" OSaenp Sd3i S S[^ Suyz  vA S, 37TX\eg SC Ss SRU Slpqvlw S* DHVZimvx S SPS Scf S  ~B  CH  ~I S* AESWfjsu Sg SS S`c Sz~  @E  {F S* 04$UYbd S SC Ss Simnsit S* SW_a $!$s) $!C $!fo $!L @DB  !S  !  !S\  !D6 Bf Qf:S<6 S<j-^F >26 2h&
3=3 =3~ 6 6$V $r6   r   )ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   rE   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   async_supportr   r0  r6   r5   <module>rK     sH     O  \ \ \ 4  * 0 . ' &l$t)):: l$r6   