
    E#i-                         S SK rS SKJr  S SKrS SKJrJrJrJ	r	J
r
JrJrJrJr  S SKJr  S SKJr  S SKJr   " S S\R(                  R*                  5      rg)	    N)ArrayCacheBySymbolById)	AnyIntOrder	OrderBookStrStringsTickerTickersTrade)List)ExchangeError)ArgumentsRequiredc            
         ^  \ rS rSrS\4U 4S jjrS0 4S\S\4S jjrS+S\S\S\4S	 jjr	S0 4S\S\S
\
4S jjrS0 4S\S\S\S
\
4S jjrS\S\\   4S jr0 4S\S\4S jjr0 4S\S\4S jjrS0 4S
\
S\4S jjrS0 4S
\
S\4S jjrS rS+S jrSS0 4S\S\S\S\\   4S jjr0 4S\S\4S jjrSS0 4S
\\   S\S\S\\   4S jjr0 4S
\\   S\4S jjrSSS0 4S\S\S\S\\   4S jjrS0 4S\S\4S jjr S0 4S\S\S\!4S jjr"0 4S\S\4S jjr#S0 4S
\\   S\S\!4S  jjr$S! r%S" r&S+S# jr'S$ r(S% r)S& r*S' r+S( r,S) r-S*r.U =r/$ ),coinbase   returnc                    > U R                  [        [        U ]  5       0 SS_SS_SS_SS_SS_SS_S	S_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSS.ESSS00SSSSSS.S.S.5      $ )NwsTcancelAllOrdersWsFcancelOrdersWscancelOrderWscreateOrderWseditOrderWsfetchBalanceWsfetchOpenOrdersWsfetchOrderWsfetchTradesWswatchBalancewatchMyTrades
watchOHLCVwatchOrderBookwatchOrderBookForSymbolswatchOrderswatchTicker)watchTickerswatchTradeswatchTradesForSymbolsunWatchTickerunWatchTickersunWatchTradesunWatchOrdersunWatchTradesForSymbolsapiz$wss://advanced-trade-ws.coinbase.com  bidsasks)bidoffer)tradesLimitordersLimitmyTradesLimitsides)hasurlsoptions)deep_extendsuperr   describe)self	__class__s    K/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/pro/coinbase.pyr=   coinbase.describe   sE   h > @d#U !%  	
   u !% $U       e !$ +D  t!" t#$ !%#)-!%"&!%!%+/38 @  $#!%!#	C*C
 * *	    Nname	isPrivatec                   #    U R                  5       I Sh  vN   SnUn/ n[        U[        5      (       a<  U R                  U5      nU R	                  U5      n	U	nUS-   SR                  U5      -   nO"Ub  U R                  U5      nUS-   U-   nUS   /nU R                  S   S   n
SUUS.nU(       a   U R                  XR                  X5      5      nU R                  XX5      I Sh  vN $  N N7f)	a  
@ignore
       subscribes to a websocket channel

       https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-overview#subscribe

       :param str name: the name of the channel
       :param boolean isPrivate: whether the channel is private or not
       :param str [symbol]: unified market symbol
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :returns dict: subscription to a websocket channel
       N::,idr.   r   	subscribetypeproduct_idschannel)load_markets
isinstancelistmarket_symbols
market_idsjoinmarketr9   extendcreate_ws_authwatch)r>   rC   rD   symbolparamsrT   messageHash
productIdssymbols	marketIdsurlrI   s               r@   rI   coinbase.subscribe>   s      !!!
fd##))&1G0I"J%,sxx/??K[[(F+.K ,Jiit$%
	 I/B/B4/TUIZZ)III1 	"0 Js"   C1C-CC1(C/)C1/C1topicc                 6  #    U R                  5       I Sh  vN   U R                  U R                  SS5      (       a  [        U R                  S-   5      eSU R                  S'   SnUnSU-   n/ n[        U[        5      (       aS  U R                  U5      n	U R                  U	5      n
U
nUS-   SR                  U5      -   nUS-   SR                  U5      -   nO*Ub'  U R                  U5      nUS-   U-   nUS-   U-   nUS	   /nU R                  S
   S   nSUUS.nU/U/USU/S.nU(       a   U R                  XR                  X(5      5      nXR                  S'   U R                  XXU5      I Sh  vN nSU R                  S'   SU R                  S'   U$  GN~ N'7f)a  
@ignore
       unSubscribes to a websocket channel

       https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-overview#subscribe

       :param str topic: unified topic
       :param str name: the name of the channel
       :param boolean isPrivate: whether the channel is private or not
       :param str [symbol]: unified market symbol
       :returns dict: subscription to a websocket channel
       NunSubscriptionPendingFX another unSubscription is pending, coinbase does not support concurrent unSubscriptionsTunsubscribe:rF   rG   rH   r.   r   unsubscriberJ   messageHashessubMessageHashesr`   re   r\   unSubscription)rN   	safe_boolr:   r   rH   rO   rP   rQ   rR   rS   rT   r9   rU   rV   rW   )r>   r`   rC   rD   rX   rT   watchMessageHashunWatchMessageHashr[   r\   r]   r^   messagesubscriptionress                  r@   un_subscribecoinbase.un_subscribee   s     !!!>>$,,(?GG  +E  !E  F  F04,-+d2
fd##))&1G0I"J/$6&9II!3d!:SXXf=M!M[[(F#d{V3!3d!:V!C ,Jiit$ "%
 11!1 2x
 kk'+>+>t+PQG)5%&JJsUabb05,-)-%&
O 	"H cs"   FFEF/F0%FFr\   c                   #    U R                  5       I Sh  vN   / n/ nU R                  USS5      n[        S[        U5      5       HE  nX7   nU R	                  U5      n	U	S   n
UR                  U
5        UR                  US-   U-   5        MG     U R                  S   S   nSUUS	.nU(       a   U R                  XR                  X5      5      nU R                  XX5      I Sh  vN $  N N7f)
a  
@ignore
       subscribes to a websocket channel

       https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-overview#subscribe

       :param str name: the name of the channel
       :param boolean isPrivate: whether the channel is private or not
       :param str[] [symbols]: unified market symbol
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :returns dict: subscription to a websocket channel
       NFr   rH   rF   r.   r   rI   rJ   )
rN   rQ   rangelenrT   appendr9   rU   rV   watch_multiple)r>   rC   rD   r\   rY   r[   rg   irX   rT   marketIdr^   rI   s                r@   subscribe_multiplecoinbase.subscribe_multiple   s      !!!
%%gtU;q#g,'AZF[[(Fd|Hh'  v!56 ( iit$%
	
 I/B/B4/TUI((YVVV% 	"$ Ws"   C-C)CC-$C+%C-+C-c                   #    U R                  U R                  SS5      (       a  [        U R                  S-   5      eSU R                  S'   U R	                  5       I Sh  vN   / n/ n/ nU R                  USS5      n[        S[        U5      5       H_  n	XI   n
U R                  U
5      nUS   nUR                  U5        UR                  US-   U
-   5        UR                  S	U-   S-   U
-   5        Ma     U R                  S
   S   nSUUS.nU(       a   U R                  XR                  X&5      5      nUUUSUS.nXR                  S'   U R                  XXU5      I Sh  vN nSU R                  S'   SU R                  S'   U$  GN& N'7f)a  
@ignore
       unsubscribes to a websocket channel

       https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-overview#subscribe

       :param str topic: unified topic
       :param str name: the name of the channel
       :param boolean isPrivate: whether the channel is private or not
       :param str[] [symbols]: unified market symbol
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :returns dict: subscription to a websocket channel
       rb   Frc   TNr   rH   rF   rd   r.   r   re   rJ   rf   ri   )rj   r:   r   rH   rN   rQ   rs   rt   rT   ru   r9   rU   rV   rv   )r>   r`   rC   rD   r\   rY   r[   watchMessageHashesunWatchMessageHashesrw   rX   rT   rx   r^   rm   rn   ro   s                    r@   un_subscribe_multiplecoinbase.un_subscribe_multiple   s     >>$,,(?GG  +E  !E  F  F04,-!!!
!%%gtU;q#g,'AZF[[(Fd|Hh'%%dTkF&:; ''(=(Dv(MN ( iit$!%

 kk'+>+>t+PQG1 2
 *6%&''7bnoo05,-)-%&
? 	"8 ps%   AF
F D F
 F!%F
F
r[   c                    0 nU R                  U R                  5       5      nU R                  5         U R                  R	                  S5      S:  =(       d    U R
                  R                  S5      nXA-   SR                  U5      -   nU(       da  U R                  US'   XCS'   U R                  U R                  U5      U R                  U R
                  5      [        R                  5      US'   U$ U R                  R                  S5      (       a  [        U R                  S-   5      eU R                  U R                  S	5      nU R!                  U R                  S
S5      nU R                  5       n	Ub	  US-   U	:  a-  U R#                  U	5      n
XR                  S	'   XR                  S
'   U R                  U R                  S	5      US'   U$ )Nzorganizations/r   z
-----BEGINrG   api_key	timestamp	signaturezV apiKey should contain the name(eg: organizations/3b910e93....) and not the public keywsTokenwsTokenTimestampx   jwt)number_to_stringsecondscheck_required_credentialsapiKeyfindsecret
startswithrS   hmacencodehashlibsha256r   rH   safe_stringr:   safe_integercreate_auth_token)r>   rC   r[   rI   r   isCloudAPiKeyauthcurrentTokentokenTimestampr   tokens              r@   rV   coinbase.create_ws_auth   s   	))$,,.9	'')))*:;q@kdkkF\F\]iFj#((:"66#';;Ii %.k"%)YYt{{4/@$++dkkBZ\c\j\j%kIk"  {{%%l33'  3K  )K  L  L++DLL)DL!..t||=OQRSNllnG#~';g'E..w7*/Y'3:/0#//iHIerB   rX   c                 |   #    U R                  5       I Sh  vN   SnU R                  USX5      I Sh  vN $  N! N7f)a  
watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#ticker-channel

: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tickerF)rN   rI   r>   rX   rY   rC   s       r@   watch_tickercoinbase.watch_ticker  s<      !!!^^D%@@@ 	"@s   <8<:<<c                 ~   #    U R                  5       I Sh  vN   SnU R                  SUSU5      I Sh  vN $  N" N7f)a^  
stops watching a price ticker

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#ticker-channel

: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   FrN   rp   r   s       r@   un_watch_tickercoinbase.un_watch_ticker  s@      !!!&&xufEEE 	"E   =9=;==c                    #    U R                  5       I Sh  vN   Uc  U R                  nSnU R                  USX5      I Sh  vN nU R                  (       a  0 nUS   nXEU'   U$ U R                  $  NZ N07f)a  
watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#ticker-batch-channel

: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>`
Nticker_batchFrX   )rN   r\   ry   
newUpdatestickers)r>   r\   rY   rC   r   r   rX   s          r@   watch_tickerscoinbase.watch_tickers"  sz      !!!?llG..tUGLL??GH%F$FON|| 	" Ms!   A5A1+A5A3/A53A5c                    #    U R                  5       I Sh  vN   Uc  U R                  nU R                  SSSU5      I Sh  vN $  N/ N7f)aW  
stop watching

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#ticker-batch-channel

: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>`
Nr   r   F)rN   r\   r~   )r>   r\   rY   s      r@   un_watch_tickerscoinbase.un_watch_tickers8  sM      !!!?llG//.%QXYYY 	" Zs!   A
A*A
AA
A
c                 @   U R                  US5      nU R                  US/ 5      nU R                  US5      nU R                  U5      n/ n[        S[	        U5      5       H  nXH   n	U R                  U	S/ 5      n
[        S[	        U
5      5       H  nX   nU R                  US5      nUc  M  U R                  U5      nXnS'   X^S'   US   nXR                  U'   UR                  U5        US	-   U-   nUR                  UU5        U R                  UUU5        M     M     g )
NrM   eventsr   r   r   
product_iddatetimerX   rF   )
r   	safe_list	parse8601rs   rt   parse_ws_tickerr   ru   resolvetry_resolve_usdc)r>   clientrm   rM   r   r   r   
newTickersrw   
tickersObjr   jr   
wsMarketIdresultrX   rZ   s                    r@   handle_tickerscoinbase.handle_tickersG  s%   t ""7I626##G[9NN8,	
q#f+&AJnnZB?G1c'l+ !--flC
%--f5&/{#%-z")'-V$!!&)%nv5v{3%%fk6B , 'rB   c           	          U R                  US5      nS nU R                  US5      nU R                  0 SU_SU R                  X2S5      _SU_SU R	                  U5      _SU R                  US	5      _S
U R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SS _SS _SU_SU_SS _SS _SU R                  US5      _S U R                  US5      S S.E5      $ )Nr   priceinforX   -r   r   high	high_24_hlowlow_24_hr2   best_bid	bidVolumebest_bid_quantityaskbest_ask	askVolumebest_ask_quantityvwapopencloselastpreviousClosechange
percentageprice_percent_chg_24_hvolume_24_h)average
baseVolumequoteVolume)r   safe_numbersafe_tickersafe_symboliso8601)r>   r   rT   rx   r   r   s         r@   r   coinbase.parse_ws_ticker  s   & ##FL9	0 !
F!
d&&x=!
 !
 Y/	!

 D$$V[9!
 4##FJ7!
 4##FJ7!
 ))&2EF!
 4##FJ7!
 ))&2EF!
 D!
 D!
 T!
 D!
 T!
  d!!
" $**63KL#!
$ **6=A)!
  	rB   sincelimitc                 
  #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  USX5      I Sh  vN nU R                  (       a  UR	                  X5      nU R                  XbUSS5      $  Nh N<7f)a   
get the list of most recent trades for a particular symbol

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#market-trades-channel

: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market_tradesFr   T)rN   rX   rI   r   getLimitfilter_by_since_limit)r>   rX   r   r   rY   rC   tradess          r@   watch_tradescoinbase.watch_trades  sx      !!!V$~~dE6BB??OOF2E))&TRR 	" Cs!   BA?-BB;BBc                 ~   #    U R                  5       I Sh  vN   SnU R                  SUSU5      I Sh  vN $  N" N7f)a  
stops watching the list of most recent trades for a particular symbol

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#market-trades-channel

: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>`
Nr   r   Fr   r   s       r@   un_watch_tradescoinbase.un_watch_trades  s@      !!!&&xufEEE 	"Er   c                 0  #    U R                  5       I Sh  vN   SnU R                  USX5      I Sh  vN nU R                  (       a5  U R                  US5      nU R	                  US5      nUR                  X5      nU R                  XbUSS5      $  N{ N`7f)a  
get the list of most recent trades for a particular symbol

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#market-trades-channel

: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   Fr   rX   r   T)rN   ry   r   	safe_dictr   r   r   )	r>   r\   r   r   rY   rC   r   firsttradeSymbols	            r@   watch_trades_for_symbols!coinbase.watch_trades_for_symbols  s      !!!..tUGLL??NN61-E**5(;KOOK7E))&TRR 	"Ls    BBBBABBc                 ~   #    U R                  5       I Sh  vN   SnU R                  SUSX5      I Sh  vN $  N" N7f)a  
get the list of most recent trades for a particular symbol

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#market-trades-channel

:param str[] symbols: 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>`
Nr   r   F)rN   r~   )r>   r\   rY   rC   s       r@   un_watch_trades_for_symbols$coinbase.un_watch_trades_for_symbols  s@      !!!//$wWWW 	"Wr   c                    #    U R                  5       I Sh  vN   SnU R                  USX5      I Sh  vN nU R                  (       a  UR                  X5      nU R	                  XbUSS5      $  NW N<7f)a	  
watches information on multiple orders made by the user

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#user-channel

:param str [symbol]: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NuserTr   )rN   rI   r   r   r   )r>   rX   r   r   rY   rC   orderss          r@   watch_orderscoinbase.watch_orders*  sg      !!!~~dD&AA??OOF2E))&TRR 	"As   A2A.A2A0;A20A2c                    #    U R                  5       I Sh  vN   SnU R                  SUSU R                  U5      5      I Sh  vN $  N1 N7f)a  
stops watching information on multiple orders made by the user

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#user-channel

:param str [symbol]: unified market symbol of the market orders were made in
: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>`
Nr   r   T)rN   rp   rX   r   s       r@   un_watch_orderscoinbase.un_watch_orders=  sI      !!!&&xtT[[=PQQQ 	"Qs!   AA,AA
A
Ac                    #    U R                  5       I Sh  vN   SnU R                  U5      nUS   nU R                  USX5      I Sh  vN nUR                  5       $  NG N7f)a  
watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#level2-channel

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nlevel2rX   F)rN   rT   rI   r   )r>   rX   r   rY   rC   rT   	orderbooks          r@   watch_order_bookcoinbase.watch_order_bookK  sc      !!!V$!..ufEE	   	" Fs!   A"A2A"	A 
A" A"c                    #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  SUSU5      I Sh  vN $  N3 N7f)a  
stops watching information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#level2-channel

: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
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nr   r   F)rN   rX   rp   r   s       r@   un_watch_order_bookcoinbase.un_watch_order_book]  sQ      !!!V$&&{D%HHH 	" Is!   AA
.AAAAc                    #    U R                  5       I Sh  vN   SnU R                  USX5      I Sh  vN nUR                  5       $  N1 N7f)a  
watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-channels#level2-channel

:param str[] symbols: unified array of symbols
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nr   F)rN   ry   r   )r>   r\   r   rY   rC   r   s         r@   watch_order_book_for_symbols%coinbase.watch_order_book_for_symbolsl  sJ      !!!11$wOO	   	"Os   AAAA
A
Ac                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  U5      nSU-   n	U R                  U R
                  U5      n
U
c6  U R                  U R                  SS5      n[        U5      n
XR
                  U'   [        S[        U5      5       HY  nX<   nU R                  US5      n[        S[        U5      5       H'  nX   nU
R                  U R                  U5      5        M)     M[     UR                  X5        U R                  XU
5        g )Nr   r   r   r   zmarket_trades::r4   r/   )r   
safe_valuer   r   r   r   r   r:   r   rs   rt   ru   parse_trader   r   )r>   r   rm   r   eventr   traderx   rX   rZ   tradesArrayr4   rw   currentEventcurrentTradesr   items                    r@   handle_tradecoinbase.handle_trade|  s9   0 2*x0vq)##E<8!!(+'&0oodkk6:++DLL-NK0=K"-KKq#f+&A!9L NN<BM1c-01$'""4#3#3D#9: 2 ' 	{0f;?rB   c                    U R                  US5      n/ nU R                  c-  U R                  U R                  SS5      n[	        U5      U l        [        S[        U5      5       H  nX6   nU R                  US5      n[        S[        U5      5       H]  n	X   n
U R                  U
5      nU R                  nU R                  U
S5      nX;  a  UR                  U5        UR                  U5        M_     M     [        S[        U5      5       HU  nXF   nU R                  U5      nSU-   nUR                  U R                  U5        U R                  XU R                  5        MW     UR                  U R                  S5        g )	Nr   r5   r/   r   r   r   zuser::r   )r   r   r   r:   r   rs   rt   parse_ws_orderr   ru   r   r   r   )r>   r   rm   r   r]   r   rw   r  responseOrdersr   responseOrderparsedcachedOrdersrx   rX   rZ   s                   r@   handle_ordercoinbase.handle_order  sP   : 2	;;%%dllM4HE07DKq#f+&AIE!^^E8<N1c.12 . 1,,];#{{++M<H -$$X.##F+ 3 ' q#i.)A |H%%h/F"V+KNN4;;4!!&t{{C * 	t{{F+rB   c                 6   U R                  US5      nU R                  US5      nU R                  US5      nU R                  USS5      nU R                  XR5      nU R                  US5      nU R                  0 SU_SU R                  US5      _S	U_S
U_SU R	                  U5      _SU_SS _SU R                  US5      _SS _SS _SU R                  USS5      _SU R                  US5      _SU_SU_SU R                  US5      _SU R                  U R                  US5      5      _SU R                  US5      _U R                  US5      U R                  US5      U R                  US5      U R                  US 5      U R                  US!5      S".S S#.E5      $ )$Norder_idclient_order_idr   timecreation_time
stop_pricer   rX   rH   clientOrderIdr   r   lastTradeTimestamprK   
order_typetimeInForcepostOnlyside
order_sider   limit_price	stopPricetriggerPriceamountcumulative_quantitycostfilled_valuer   	avg_priceleaves_quantitystatus
total_feesquote)r+  currency)filled	remainingr1  feer   )r   safe_string_2safe_market
safe_orderr   	omit_zerosafe_string_lower)r>   orderrT   rH   r!  rx   r   r)  s           r@   r  coinbase.parse_ws_order  s"     eZ0((0AB##E<8%%eV_E!!(3$$UL9	  
E 
d&&vx8 
 " 
 ]	 

 1 
  
 !$ 
 D$$UL9 
 4 
  
 D&&uflC 
 T%%e]; 
  
 I 
 d&&u.CD 
  DNN4#3#3E>#JK! 
" t''{;# 
$ &&u.CD))%1BC,,UH=**5,? ,,VW= 3 
  	rB   c                    [        S[        U5      5       Hq  nX#   nU R                  US5      nU R                  U R                  S   U5      nU R	                  US5      nU R	                  US5      nX   n	U	R                  Xx5        Ms     g )Nr   r&  r7   price_levelnew_quantity)rs   rt   r   r:   r   store)
r>   r   updatesrw   r  sideIdr&  r   r+  orderbookSides
             r@   handle_order_book_helper!coinbase.handle_order_book_helper  s    q#g,'AJE%%eV4F##DLL$96BD$$UM:E%%e^<F%OM. (rB   c                    U R                  US5      nU R                  US5      n[        S[        U5      5       GH.  nX5   nU R                  US/ 5      nU R                  US5      nU R	                  U5      n	U	S   n
SU
-   nU R                  UR                  U0 5      nU R                  US5      nU R                  US	5      nUS
:X  a  U R                  0 U5      U R                  U
'   XR                  ;  a  U R                  U
   c  M  U R                  U
   nU R                  X5        U R                  U5      US'   XOS'   XS'   UR                  X5        U R                  XU5        GM1     g )Nr   r   r   rC  r   rX   zlevel2::r   rK   snapshotr   )r   r   rs   rt   r9  r	  subscriptionsr   
order_book
orderbooksrF  r   r   r   )r>   r   rm   r   r   rw   r  rC  rx   rT   rX   rZ   rn   r   rK   r   s                   r@   handle_order_bookcoinbase.handle_order_book  s]   : 2##G[9q#f+&AIEnnUIr:G''|<H%%h/FH%F$v-K??6+?+?bQL%%lG<E##E62Dz!*.//"e*D'oo-4??63J3R/I)))=%)^^H%=Ik"$,j!"(hNN92!!&yA- 'rB   c                     UR                  S5      (       d  UR                  S5      (       a  UR                  X2S-   5        g g )Nz/USDz-USDC)endswithr   )r>   r   rZ   r   s       r@   r   coinbase.try_resolve_usdcQ  s:    '';+?+?+G+GNN6#45 ,HrB   c                    U R                  US/ 5      nU R                  US0 5      nSU;   n[        US   R                  5       5      n[	        U5      nU(       a  US:X  a  U R                  U R                  S0 5      nU R                  US/ 5      n	U R                  US/ 5      n
[        S[	        U	5      5       H  nX   nX   nU R                  XU5        M     U R                  U5        U$ )Nr   r   rJ  ri   rg   rh   )
r   r	  rP   keysrt   r   r:   rs   clean_unsubscriptionclean_cache)r>   r   rm   r   
firstEventisUnsubsubKeyssubKeysLengthunSubObjectrg   rh   rw   rZ   subHashs                 r@   handle_subscription_status#coinbase.handle_subscription_statusU  s    * 26__VQ3
"j0z/2779:G})..7GLK NN;LM#~~k;MrR1c-01+.*-))&;G 2 [)rB   c                     U$ N )r>   r   rm   s      r@   handle_heartbeatscoinbase.handle_heartbeatsz  s	    " rB   c                 t   U R                  US5      nU R                  U R                  U R                  U R                  U R                  U R
                  U R                  S.nU R                  US5      nUS:X  a  U R                  US5      n[        U5      eU R                  XC5      nU(       a	  U" X5        g g )NrM   )rJ  r   r   r   r   l2_data
heartbeatsrK   errorrm   )	r   r]  r   r  r  rM  rb  r   r	  )r>   r   rm   rM   methodsrK   errorMessagemethods           r@   handle_messagecoinbase.handle_message  s    ""7I6!<<)) //!..%%--00
 07?++GY?L--26# rB   )r   r`  )0__name__
__module____qualname____firstlineno__r   r=   strboolrI   rp   r	   ry   r~   r   rV   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  rF  rM  r   r]  rb  rk  __static_attributes____classcell__)r?   s   @r@   r   r      s   +# +Z BFb %JC %JD %JN4 43 44 4l W[ce WS WT WG WB fjrt 0 0C 0D 0[b 0d3 DI 0 68 A AF A 9; FC Fv F 6:" 7  , 9=R Zg ZC ZoCb+Z <@d[] S SS S Sbfglbm S( 9; FC Fs F OSaenp Sd3i S S[^ Suyz  vA S* LN Xc XRU X 04$UYbd S SC Ss Simnsit S& 37r RC Rc R @DB !S ! !S\ !$ =? I I3 I SW_a !$s) !C !fo ! +@Z3,j0d/5Bn6#J&$ $rB   r   )ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   ccxt.base.typesr   r   r   r   r   r	   r
   r   r   typingr   ccxt.base.errorsr   r   async_supportr   ra  rB   r@   <module>r|     s<     C  \ \ \  * .O$t!!** O$rB   