
    ei                         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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)
AnyBoolIntOrder	OrderBookStrStringsTickerTickersTrade)Client)List)ExchangeError)AuthenticationError)ArgumentsRequired)
BadRequest)	BadSymbol)Precisec            
       |    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i fd	e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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de)fd"Z*defd#Z+ xZ,S )%coinbaseexchangereturnc                     |                      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    W/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/pro/coinbaseexchange.pyr4   zcoinbaseexchange.describe   s    &6 = = F F H H#"&,0# $#)-+/ %$#)-!% $ ? N	   $#!% 3K
 K
   	    c                 <   |                                   d}|                                 }t          |          dz   |z   }|                     |                     |          |                     | 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)r5   pathrA   payloadr>   s        r7   authenticatezcoinbaseexchange.authenticate7   s    '')))#

e**u$t+IIdkk'22D4I4I$+4V4VX_Xfhpqq	;"-	
 
 	
r8   Nc                 t  K   |                                   d {V  d }|}g }|>|                     |          }|d|d         z   z  }|                    |d                    | j        d         d         }d|v r|dz   }d||gd}	|                     |	|          }
|                     |||
|           d {V S )	N:idr)   r   r>   ?	subscribetypeproduct_idschannels)load_marketsmarketappendr0   extendwatch)r5   namesymbolmessageHashStartparamsrX   messageHash
productIdsurlrR   requests              r7   rR   zcoinbaseexchange.subscribeD   s      !!!!!!!!!&
[[((F3--KfTl+++it$&  )C%
 
	 ++i00ZZ[';GGGGGGGGGr8   c                   K   |                                   d {V  d }|                     |          }g }g }t          dt          |                    D ][}||         }	|                     |	          }|                    |d                    |                    |dz   |d         z              \| j        d         d         }
d|v r|
dz   }
d	||gd
}|                     ||          }|                     |
|||           d {V S )Nr   rP   rO   r]   r)   r   r>   rQ   rR   rS   )	rW   market_symbolsrangelenrX   rY   r0   rZ   watch_multiple)r5   r\   symbolsr^   r_   rX   messageHashesra   ir]   rb   rR   rc   s                r7   subscribe_multiplez#coinbaseexchange.subscribe_multiple[   sF     !!!!!!!!!%%g..
q#g,,'' 	L 	LAQZF[[((FfTl+++  !1C!7&:J!JKKKKit$&  )C%
 
	 ++i00((mWmTTTTTTTTTr8   r]   c                 F   K   d}|                      ||||           d{V S )a  
        watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :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)rR   )r5   r]   r_   r\   s       r7   watch_tickerzcoinbaseexchange.watch_tickert   s7       ^^D&$?????????r8   ri   c                 :  K   |                                   d{V  t          |          }|dk    rt          | j        dz             d}d}|                     ||||           d{V }| j        ri }|||d         <   |S |                     | j        d|          S )a1  
        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 arrayrn   r]   )rW   rg   r   rP   rl   
newUpdatesfilter_by_arraytickers)r5   ri   r_   symbolsLengthchannelr`   rn   results           r7   watch_tickerszcoinbaseexchange.watch_tickers~   s       !!!!!!!!!GADG&XXYYY..wfUUUUUUUU? 	F'-F6(#$M##DL(GDDDr8   sincelimitc                   K   |                                   d{V  |                     |          }d}|                     ||||           d{V }| j        r|                    ||          }|                     |||dd          S )a  
        get the list of most recent trades for a particular symbol
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        Nmatchesr<   T)rW   r]   rR   rq   getLimitfilter_by_since_limit)r5   r]   rx   ry   r_   r\   tradess          r7   watch_tradeszcoinbaseexchange.watch_trades   s       !!!!!!!!!V$$~~dFD&AAAAAAAA? 	3OOFE22E))&%TRRRr8   c                   K   t          |          }|dk    rt          | j        dz             |                                  d{V  |                     |          }d}|                     ||||           d{V }| j        rB|                     |d          }|                     |d          }	|	                    |	|          }| 
                    |||dd          S )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 symbolsNr{   r]   r<   T)rg   r   rP   rW   re   rl   rq   
safe_valuesafe_stringr|   r}   )
r5   ri   rx   ry   r_   rt   r\   r~   firsttradeSymbols
             r7   watch_trades_for_symbolsz)coinbaseexchange.watch_trades_for_symbols   s       GATW'gghhh!!!!!!!!!%%g....tWdFKKKKKKKK? 	8OOFA..E**5(;;KOOK77E))&%TRRRr8   c           	        K   |t          | j        dz             |                                  d{V  |                     |          }d}d}|                                 }|                     ||||                     ||                     d{V }| j        r|                    ||          }| 	                    |||dd          S )a  
        watches information on multiple trades made by the user
        :param str symbol: unified market symbol of the market trades were made in
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trade structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
        Nz+ watchMyTrades() requires a symbol argumentusermyTradesr<   T)
r   rP   rW   r]   rM   rR   rZ   rq   r|   r}   )	r5   r]   rx   ry   r_   r\   r`   authenticationr~   s	            r7   watch_my_tradesz coinbaseexchange.watch_my_trades   s       >#DG.[$[\\\!!!!!!!!!V$$ **,,~~dFKVUcAdAdeeeeeeee? 	3OOFE22E))&%TRRRr8   c           	        K   |                      |dd          }|                                  d{V  d}d}|                                 }|                     ||||                     ||                     d{V }| j        rB|                     |d          }	|                     |	d          }
|                    |
|          }| 	                    |||dd          S )	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)
re   rW   rM   rl   rZ   rq   r   r   r|   r}   )r5   ri   rx   ry   r_   r\   r`   r   r~   r   r   s              r7   watch_my_trades_for_symbolsz,coinbaseexchange.watch_my_trades_for_symbols   s       %%gtU;;!!!!!!!!! **,,..tWk4;;W]_mKnKnoooooooo? 	8OOFA..E**5(;;KOOK77E))&%TRRRr8   c           	        K   |                                   d{V  |                     |dd          }d}d}|                                 }|                     ||||                     ||                     d{V }| j        rB|                     |d          }	|                     |	d          }
|                    |
|          }| 	                    |||dd          S )	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)
rW   re   rM   rl   rZ   rq   r   r   r|   r}   )r5   ri   rx   ry   r_   r\   r`   r   r   r   r   s              r7   watch_orders_for_symbolsz)coinbaseexchange.watch_orders_for_symbols   s       !!!!!!!!!%%gtU;;**,,..tWk4;;W]_mKnKnoooooooo? 	8OOFA..E**5(;;KOOK77E))&%TRRRr8   c           	        K   |t          | j        dz             |                                  d{V  |                     |          }d}d}|                                 }|                     ||||                     ||                     d{V }| j        r|                    ||          }| 	                    |||dd          S )a  
        watches information on multiple orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nz  watchMyTrades requires a symbolr   r   r<   T)
r   rP   rW   r]   rM   rR   rZ   rq   r|   r}   )	r5   r]   rx   ry   r_   r\   r`   r   r   s	            r7   watch_orderszcoinbaseexchange.watch_orders   s       >DG&HHIII!!!!!!!!!V$$**,,~~dFKVUcAdAdeeeeeeee? 	3OOFE22E))&%TRRRr8   c                 ~  K   t          |          }|dk    rt          | j        dz             d}|                                  d{V  |                     |          }|                     |          }g }t          d|          D ]%}||         }	|                    |dz   |	z              &| j        d         d         }
d||gd	}| 	                    ||          }||||d
}| 
                                }|                     |
|| 	                    ||          ||           d{V }|                                S )a  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str[] symbols: unified array of symbols
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        r   zA watchOrderBookForSymbols() requires a non-empty array of symbolslevel2NrO   r)   r   rR   rS   )r`   ri   	marketIdsry   )rg   r   rP   rW   re   
market_idsrf   rY   r0   rZ   rM   rh   ry   )r5   ri   ry   r_   rt   r\   r   rj   rk   marketIdrb   rR   rc   subscriptionr   	orderbooks                   r7   watch_order_book_for_symbolsz-coinbaseexchange.watch_order_book_for_symbols  s      GATW'jjkkk!!!!!!!!!%%g..OOG,,	q-(( 	8 	8A |H  h!67777it$$
 
	 ++i00"	
 
 **,,--c=$++gWeBfBfhu  xD  E  E  E  E  E  E  E  E	   r8   c                   K   d}|                                   d{V  |                     |          }|d         }|dz   |d         z   }| j        d         d         }d|d         g|gd	}|                     ||          }	|||d         |d
}
|                                 }|                     |||                     |	|          ||
           d{V }|                                S )a  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str 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]   rO   rP   r)   r   rR   rS   )r`   r]   r   ry   )rW   rX   r0   rZ   rM   r[   ry   )r5   r]   ry   r_   r\   rX   r`   rb   rR   rc   r   r   r   s                r7   watch_order_bookz!coinbaseexchange.watch_order_book4  s#      !!!!!!!!!V$$!Sj6$</it$t 
 
	 ++i00&t	
 
 **,,**S+t{{7N7[7[]hjvwwwwwwww	   r8   clientc                 ~   |                      |d          }||                     |          }|d         }d}|dz   |z   }|                     | j        |          }|5|                     | j        dd          }	t          |	          }|| j        |<   |                    |           |                    ||           |S )N
product_idr]   r{   rO   r,   r+   )	r   parse_ws_trader   r~   safe_integerr1   r   rY   resolve)
r5   r   messager   trader]   rT   r`   tradesArrayr,   s
             r7   handle_tradezcoinbaseexchange.handle_tradeV  s     ##G\::''00E8_F D*x/K//$+v>>K""//mTRR(55&1F#u%%%NN;444r8   c                 @   |                      |d          }||                     |          }d}|dz   |z   }| j        }|2|                     | j        dd          }t          |          }|| _        |                    |           |                    ||           |S )Nr   r   rO   r.   r+   )r   r   r   r   r1   r   rY   r   )	r5   r   r   r   r   rT   r`   r   ry   s	            r7   handle_my_tradez coinbaseexchange.handle_my_tradew  s    ##G\::''00ED*x/K-K"))$,NN4U;; +u%%%NN;444r8   c                 t   t          t          |                               |          }d }d}d|v rd}d|d<   |                     |d          }n@d|d<   |                     |d          }|d         }|                     d	d
d||          |d<   |rdnd}|                     ||          |d<   |                     |d                   }|d         }d }	|d         -|+|                     |d          }
t          j        |
|          }	|                     |          |                     |	          |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)r3   r   parse_trader   rX   r   
string_mulparse_number)r5   r   rX   parsedfeeRateisMakercurrentSideidKeyfeeCurrencyfeeCostr   r6   s              r7   r   zcoinbaseexchange.parse_ws_trade  s}   f '..::5AAu$$G%,F>"&&u.>??GG%,F>"&&u.>??G !.K!--/ / K) )F6N %,A  1A**5%88wVH-..Wo6N&W-@##FF33D(w77G%%g..%%g..#
 
u
 r8   c                 :    ddd}|                      ||d          S )Nclosedcanceled)filledr   open)r   )r5   statusstatusess      r7   parse_ws_order_statusz&coinbaseexchange.parse_ws_order_status  s.    "
 
 &&999r8   c           	      
   | j         }|2|                     | j        dd          }t          |          }|| _         |                     |d          }|                     |d          }|d|z   }|                     |          }|                     |d          }	|                     |d          }
|                     |d          }| j         }|                     |j        |i           }|                     ||	          }||                     ||
|          }|B| 	                    |          }|
                    |           |                    ||           d S |                     |d	          }|                     |d
i           }|                     |d	          }|||k    r|dk    r|                     |          }|d         g |d<   |d         
                    |           |d         |d<   d}d}|d         }t          dt          |                    D ]8}||         }|                     |dd          }|                     |dd          }9t          j        |d          s+|                     t          j        ||                    |d<   |                     |          |d<   |                     |d          }||                     t          j        ||                     |d                              |d<   |d         S|                     t          j        |                     |d          |                     |d                              |d<   |d         d|d         d         d|d<   |d         d         |d         d         |                     |d         d         |d         d                   |d         d<   |                     |d          }|                     |d          }|                     t          j        |                     |d          |                     |d                              |d         d<   |
                    |           |                    ||           d S |dk    s|dk    r|                     |d
         |          }| 	                    |          }t1          |                                          }t          dt          |                    D ]}||         }||         ||         ||<   |
                    |           |                    ||           d S d S d S d S )Nr-   r+   rT   r   zorders:order_idr   r   sequenceinfomatchr~   r<   lastTradeTimestamp0r   r   amountaverager   	remainingr   r   )r   r   receiveddone)r   r   r1   r   r   safe_symbolr   hashmapsafe_value_2parse_ws_orderrY   r   r   rf   rg   r   	string_eqr   
string_div
string_add
string_subsum	safe_dictrZ   listkeys) r5   r   r   currentOrdersry   rT   r   r`   r]   orderIdmakerOrderIdtakerOrderIdr   previousOrderspreviousOrderr   r   previousInfopreviousSequencer   	totalCosttotalAmountr~   rk   
tradeEntrypreviousOrderFilledpreviousOrderFeetradeFeer   r   r   r=   s                                    r7   handle_orderzcoinbaseexchange.handle_order  s   ^  %%dlM4HHE2599M'DK00##G\::#h.K%%h//F&&w
;;G++G5EFFL++G5EFFL[F!__V^VRHHN OONGDDM$ $ 1 1.,P\ ] ]$,,W55f%%%v{33333,,WjAA#}fbII#'#4#4\:#N#N $,(=M2M2Mw $ 3 3G < <(2:68M(3%h/66u===>CK>P&:;$'	&)!.x!8!&q#f++!6!6 V VA)/J(,(8(8VS(Q(QI*.*:*::xQT*U*UKK&0cBB u7;7H7HI[\egrIsIs7t7tM)4040A0A)0L0Lf-.2.>.>}h.W.W+.:6:6G6GHZ[npt  qA  qA  BG  IQ  qR  qR  IS  IS  7T  7TM(3,X6B=A=N=NwOabfbrbr  tA  CK  cL  cL  NR  N^  N^  _l  nv  Nw  Nw  Px  Px  >y  >yk :(/7(),1%L,D4 4M%0 *%08D5QV<X^K_Kk;?88MRWDXY_D`bghmbnoubv;w;wM%08/3~~mU/S/S,'+~~eU'C'CH;?;L;LWM_`d`p`p  rB  DJ  aK  aK  MQ  M]  M]  ^f  hn  Mo  Mo  Np  Np  <q  <qM%08m444v{;;;;;*,,$&..#{{=+@'JJ $ 3 3D 9 9#EJJLL11!&q#d))!4!4 @ @A"&q'C$Sz55:3Zc 2m444v{;;;;;C  & 3N2MF 3A.r8   c           	         |                      |d          }|                      |d          }|                      |d          }|                     |          }|                      |d          }|                     |d          }|                     |dd          }	|                      |d          }
|                     |
          }|                      |d	          }|                     |          }|                      |d
          }|                      |d          }|                      |d          }d }|	|t          j        |	|          }n|dk    rd}|	t          j        |	|          }|                     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          S )Nr   
client_oidr   r   pricesizefundstimereason
order_typeremaining_sizerT   r   r   r   r]   rP   clientOrderIdr<   datetimer   timeInForcepostOnly	stopPricetriggerPricer   r   r   )r   r   r   r   r~   )r   r   safe_numbersafe_string_2	parse8601r   r   r   
safe_orderiso8601r   )r5   r   rX   rP   r   r   r]   r   r   r   r   r<   r   r   	orderTyper   rT   r   s                     r7   r   zcoinbaseexchange.parse_ws_ordery  s   eZ00((==##E<88!!(++v..  00##E67;;v..NN4((	!!%22++F33$$UL99	$$U,<==	v..Y%:'	::FFZF!#.vv>>	  
E 
f 
 " 
 ]	 

  
 Y// 
 !$ 
 I 
 4 
  
 D 
 U 
  
 D 
 d''// 
  D! 
" t# 
$ ''//**955- 
  
  
   	r8   c                     |                      |d          }|]|                     |          }|d         }|| j        |<   d|z   }d|z   }|                    ||           |                    ||           |S )Nr   r]   zticker:)r   parse_tickerrs   r   )r5   r   r   r   rn   r]   r`   idMessageHashs           r7   handle_tickerzcoinbaseexchange.handle_ticker  s    ( ##G\::&&w//FH%F#)DL #f,K%0MNN6;///NN6=111r8   c                 `   |                      |d          }|)t          t          |                               ||          S |                      |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          S ) NrT   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   r3   r   r  r   r  safe_tickerr  )	r5   rn   rX   rT   r   r]   r<   r  r6   s	           r7   r  zcoinbaseexchange.parse_ticker  s-   , //<)400==ffMMM##FL99!!(FC88NN4#3#3FF#C#CDD	00 !
f!
!
 Y//!
 D$$VZ88	!

 4##FI66!
 4##FJ77!
 ))&/BB!
 4##FJ77!
 ))&/BB!
 D!
 D$$VZ88!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **6<@@)!
 !
 !
   	r8   c                     |                      |d          }|                      |d          }|                    ||           d S )Nr      )r  store)r5   booksidedeltar   r   s        r7   handle_deltazcoinbaseexchange.handle_delta  sF      **!!%++uf%%%%%r8   c                 ~    t          dt          |                    D ]}|                     |||                    d S )Nr   )rf   rg   r)  )r5   r'  deltasrk   s       r7   handle_deltaszcoinbaseexchange.handle_deltas   sH    q#f++&& 	3 	3Ahq	2222	3 	3r8   c                    |                      |d          }|                      |d          }|                     |d d          }|d         }d}|dz   |z   }|                     |j        |i           }	|                     |	d          }
|dk    r|                     i |
          | j        |<   | j        |         }|                     |d	         |                     |d	g                      |                     |d
         |                     |d
g                      d |d<   d |d<   ||d<   |                    ||           d S |dk    r%| j        |         }| 	                    |                      |d                    }|                     |dg           }d	d
d}t          dt          |                    D ]}||         }|                      |d          }|                      ||          }|                     |d          }|                     |d          }||         }|                    ||           ||d<   |                     |          |d<   |                    ||           d S d S )NrT   r   r  r]   r   rO   ry   snapshotasksbidsr<   r   l2updater   changes)r   r   r   r%     )r   safe_marketr   subscriptionsr   
order_book
orderbooksr,  r   r  rf   rg   r  r&  r  )r5   r   r   rT   r   rX   r]   r\   r`   r   ry   r   r<   r2  sidesrk   r  r=   r   r   r   r'  s                         r7   handle_order_bookz"coinbaseexchange.handle_order_book  s   4 00##G\::!!(D#66!Sj8+v';["MM!!,88:&*oob%&@&@DOF#/Iy0$//'6SU2V2VWWWy0$//'6SU2V2VWWW%)Ik"$(Ij!"(IhNN9k22222Z/It'7'7'H'HIIIoogy"==G E 1c'll++ . . &&vq11''s33((33))&!44$T?uf----%.Ik"$(LL$;$;Ij!NN9k22222%  r8   c                     |S N )r5   r   r   s      r7   handle_subscription_statusz+coinbaseexchange.handle_subscription_statusC  s	     r8   c                    |                      |d          }|                      |d          }	 |dk    rt          d|z             t          | j        dz   |z             # t          $ r }|                    |           Y d }~dS d }~ww xY w)Nr   r   zAuthentication FailedzAuthentication failed:  T)r   r   r   rP   	Exceptionreject)r5   r   r   errMsgr   errors         r7   handle_error_messagez%coinbaseexchange.handle_error_messageQ  s      !!'955!!'844	000)*Cf*LMMM#DGcMF$:;;; 	 	 	MM%   44444	s   2A   
B
*BB
c           
         |                      |d          }| j        | j        | j        | j        | j        | j        | j        | j        | j        d	}t          |j                  dz
  }|j        |dz
           dk    }|                     ||          }|P|dk    rH|r.| 	                    ||           |                     ||           d S | 
                    ||           d S d S  |||           d S )NrT   )	r.  r1  rR   rn   r   r   r  r   rC  r   r%  rQ   r   )r   r9  r=  r
  r   rD  rg   rb   r   r   r   )r5   r   r   rT   methodslengthauthenticatedmethods           r7   handle_messagezcoinbaseexchange.handle_messagel  s   00..8()%'%.

 

 VZ1$
6A:.#5$//>w  7((999%%fg66666%%fg66666  F67#####r8   r;  )-__name__
__module____qualname__r   r4   rM   rR   rl   rB   r   ro   r   r   rw   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,  r9  r=  r   rD  rJ  __classcell__)r6   s   @r7   r   r      s       #      B
 
 
 ,0$r H H H H. 68$WY U U U U2 68 @ @ @F @ @ @ @ 6:" E E7 E E E E E* <@d[] S S SS S Sbfglbm S S S S" OSaenp S Sd3i S S[^ Suyz  vA S S S S, 37TX\eg S SC Ss SRU Slpqvlw S S S S* RVdhqs S Sc S3 S^a Sx|  ~C  yD S S S S* OSaenp S Sd3i S S[^ Suyz  vA S S S S* 04$UYbd S S SC Ss Simnsit S S S S* SW_a $! $!$s) $!C $!fo $! $! $! $!L @DB  !  !S  !  !S\  !  !  !  !D6    Bf    Q Q Q Q Q Qf: : :W<6 W< W< W< W<r- - - -^F    >2 26 2 2 2 2 2 2h& & &
3 3 3=3 =3 =3 =3 =3~    6 t    6$V $ $ $ $ $ $ $ $r8   r   )ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   rG   ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   !ccxt.async_support.base.ws.clientr   typingr   ccxt.base.errorsr   r   r   r   r   ccxt.base.preciser   async_supportr   r<  r8   r7   <module>rX     sP       O O O O O O O O  b b b b b b b b b b b b b b b b b b b b b b b b 4 4 4 4 4 4       * * * * * * 0 0 0 0 0 0 . . . . . . ' ' ' ' ' ' & & & & & & % % % % % %p$ p$ p$ p$ p$t): p$ p$ p$ p$ p$r8   