
    E#i                    T   S SK Jr  S SKJr  S SK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JrJrJrJrJrJr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K!J$r$  S S	K!J%r%  S S
K!J&r&  S SK!J'r'  S SK!J(r(  S SK!J)r)  S SK!J*r*  S SK!J+r+  S SK!J,r,  S SK-J.r.  S SK/J0r0   " S S\\5      r1g)    )Exchange)ImplicitAPIN)AccountAnyBalances
Conversion
CurrenciesCurrencyDepositAddressIntLedgerEntryMarketNumOrder	OrderBook	OrderSide	OrderTypePositionStrStringsTickerTickersTradeTradingFeesTransactionMarketInterface)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)RateLimitExceeded)InvalidNonce)	TICK_SIZE)Precisec                     ^  \ rS rSrS\4U 4S jjr0 4S\4S jjr0 4S\\	   4S jjr
0 4S\\	   4S jjr0 4S\\	   4S jjr0 4S\\	   4S jjrS	 r0 4S
\S\4S jjrSSS0 4S\S\S\4S jjrSSS0 4S\S\S\4S jjrSSS0 4S
\S\S\4S jjrSSS0 4S
\S\S\S\\   4S jjrSSS0 4S
\S\S\S\\   4S jjrSSS0 4S
\S\S\S\\   4S jjrS\4S jrSS\S\S\4S jjrSS\S\S\4S jjr 0 4S\\   4S jjr!0 4S\\   4S jjr"0 4S\\   4S  jjr#S\$4S! jr%S\$4S" jr&0 4S# jr'0 4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0 4S%\*S\+4S( jjr.0 4S\S\/4S) jjr00 4S\4S* jjr10 4S\4S+ jjr2SS,\S\S\/4S- jjr30 4S. jr40 4S\54S/ jjr6SSS0 4S
\S\S\S\\7   4S0 jjr8S1 r9S2 r:SS3\S\S\74S4 jjr;0 4S5 jr<S0 4S\4S6 jjr=SS0 4S
\S\4S7 jjr>0 4S\S8\?4S9 jjr@S0 4S\S:\AS;\BS<\?S=\C4
S> jjrDSS?\S\S\E4S@ jjrFS\4SA jrGS:\4SB jrHSC\4SD jrIS0 4SE\S\4SF jjrJS0 4SG\\   S\4SH jjrKSS0 4SE\S\S:\AS;\BS<\CS=\C4SI jjrLS0 4SE\S\4SJ jjrMSSSK0 4S\S\S\S\\E   4SL jjrNSSS0 4S\S\S\4SM jjrOSSS0 4S\S\S\S\\E   4SN jjrPSSS0 4S\S\S\S\\E   4SO jjrQSSS0 4S\S\S\4SP jjrRSQSS0 4S\SR\S\S\S\\S   4
SS jjrTSS\S\S4ST jjrUSS0 4S\S\S\S\\   4SU jjrVSSS0 4S\S\S\4SV jjrWS0 4S\S\S\X4SW jjrYS0 4S%\*4SX jjrZS0 4S
\S<\?SY\SZ\S\4
S[ jjr[0 4S
\S\\   4S\ jjr\SS\S\4S] jjr]0 4S
\S<\?SE\4S^ jjr^S0 4SE\S
\4S_ jjr_0 4S` jr`0 4SE\4Sa jjra0 4Sb jrbSc rcS0 4Sd\Se\S<\CS\d4Sf jjreS0 4SE\Sd\Se\S<\CS\d4
Sg jjrfS0 4SE\S
\S\d4Sh jjrgSSi\Sj\Sk\S\d4Sl jjrhS0 4S\S;\BS\E4Sm jjriS0 4S%\*S\\j   4Sn jjrk0 4S\4So jjrlSSp\S\4Sq jjrm0 4S\n4Sr jjro0 4Ss\S\\   4St jjrpSu\4Sv jrqSSw\Sx\Sy\4Sz jjrrS{ rs/ S|0 SS4S} jrtS
\uS~\Sy\Sx\S\S\4S jrvSrwU =rx$ )coinbase   returnc                   > U R                  [        [        U ]  5       0 SS_SS_SS/_SS_S	S
_SS_SS_SU R                  S   _SSS0_S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_0 S&S_S'S_S(S_S)S
_S*S_S+S
_S,S_S-S
_S.S
_S/S_S0S
_S1S_S2S
_S3S_S4S_S5S_S6S_E0 S7S_S8S_S9S
_S:S
_S;S
_S<S
_S=S
_S>S
_S?S_S@S_SAS_SBS_SCS
_SDS
_SES
_SFS_SGS_E0 SHSI_SJS
_SKS_SLS_SMS_SNS_SOS_SPS
_SQS
_SRS
_SSS
_STS
_SUS
_SVS
_SWS
_SXS
_SYS
_E0 SZS
_S[S
_S\S_S]S
_S^S
_S_S
_S`S
_SaS
_SbS
_ScS
_SdS
_SeS
_SfS
_SgS_ShS
_SiS
_SjS_E0 SkS
_SlS_SmS
_SnS_SoS_SpS
_SqS
_SrS
_SsS_StS
_SuS
_SvS_SwS_SxS_SyS_SzS
_S{S
_E0 S|S_S}S
_S~S
_SS
_SS
_SS
_SS_SS_SS_SS_SSI_SS_SS
_SS_SS
_SS
_SS
_ES
S
S
S
S
SS.E_SSSS0SSS/SS/SS._SSSS._SSSSSSSSSSS.00 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSS.ESSSSSSSSSSSSSSS.SSS.SSS.S.S.SSSSSSSS.00 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSS.ESSSSSSSSSSSSS.SS0SSS.S.S.S._SSU R                  S5      U R                  S5      SSU R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      //	U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      //	S.S.0_S[        _S0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _[        [        [        [        [        [        [        S.E[        [        [        S.S._GS GSGSGSGSGSGSGSGSGS	._GS
GS00 GSS
_GSGS_GS/ GSQ_SFGSGS0_SGSGS/_GSGSGS/_GSGSGSGS._GSS_GSS_SgGS_GSGS _GS!S
_SGS"_SGS#_S6GS$_S7GS%_SGS&_GS'GS(0ES
SSS SSSS SSSSGS).S
S
SSSS
S
GS*.S S
GS+S GS,S
GS-.S
S
S
S
GS..S
S S
S
S
GS/.S
S S GS,S
S
S
GS0.S
S S S GS,S
S
S
GS1.GS2GS30GS4.	GS5GS60GS5GS60S GS7.GS5GS60S GS7.GS8.GS9.E5      $ (:  Nidr,   namezCoinbase Advanced	countriesUSproT	certifiedF	rateLimit"   versionv2	userAgentchromeheadersz
CB-VERSIONz
2018-05-30hasCORSspotmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelOrdercancelOrderscloseAllPositionsclosePositioncreateConvertTradecreateDepositAddresscreateLimitBuyOrdercreateLimitSellOrdercreateMarketBuyOrdercreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrdercreateMarketSellOrderWithCostcreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderdeposit	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCanceledOrdersfetchClosedOrdersfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressemulatedfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositMethodIdfetchDepositMethodIdsfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchL2OrderBookfetchLedgerfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyBuysfetchMyLiquidationsfetchMySellsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMargin)repayMarginsetLeverage	setMarginsetMarginModesetPositionModewithdrawurlszchttps://user-images.githubusercontent.com/1294454/40811661-b6eceae2-653a-11e8-829e-10bfadb078cf.jpgrestzhttps://api.coinbase.comzhttps://www.coinbase.comz&https://developers.coinbase.com/api/v2z;https://docs.cloud.coinbase.com/advanced-trade/docs/welcomezYhttps://support.coinbase.com/customer/portal/articles/2109597-buy-sell-bank-transfer-feesz&https://www.coinbase.com/advanced-feesz6https://www.coinbase.com/join/58cbe25a355148797479dbd2)logoapiwwwdocfeesreferralrequiredCredentials)apiKeysecretr   getg333333%@)
currencieszcurrencies/cryptotimezexchange-rateszusers/{user_id}zprices/{symbol}/buyzprices/{symbol}/sellzprices/{symbol}/spotaccountsaccounts/{account_id}accounts/{account_id}/addressesz,accounts/{account_id}/addresses/{address_id}z9accounts/{account_id}/addresses/{address_id}/transactions"accounts/{account_id}/transactions3accounts/{account_id}/transactions/{transaction_id}accounts/{account_id}/buysz#accounts/{account_id}/buys/{buy_id}accounts/{account_id}/sellsz%accounts/{account_id}/sells/{sell_id}accounts/{account_id}/depositsz+accounts/{account_id}/deposits/{deposit_id}!accounts/{account_id}/withdrawalsz1accounts/{account_id}/withdrawals/{withdrawal_id}zpayment-methodsz#payment-methods/{payment_method_id})userz	user/auth)r   zaccounts/{account_id}/primaryr   r   z<accounts/{account_id}/transactions/{transaction_id}/completez:accounts/{account_id}/transactions/{transaction_id}/resendr   z*accounts/{account_id}/buys/{buy_id}/commitr   z,accounts/{account_id}/sells/{sell_id}/commitr   z2accounts/{account_id}/deposits/{deposit_id}/commitr   z8accounts/{account_id}/withdrawals/{withdrawal_id}/commit)r   r   )zaccounts/{id}r   )r   postputdelete)publicprivate   )zbrokerage/timezbrokerage/market/product_bookzbrokerage/market/productsz&brokerage/market/products/{product_id}z.brokerage/market/products/{product_id}/candlesz-brokerage/market/products/{product_id}/tickerzbrokerage/accounts   z!brokerage/accounts/{account_uuid}z!brokerage/orders/historical/batchz!brokerage/orders/historical/fillsz&brokerage/orders/historical/{order_id}zbrokerage/productszbrokerage/products/{product_id}z'brokerage/products/{product_id}/candlesz&brokerage/products/{product_id}/tickerzbrokerage/best_bid_askzbrokerage/product_bookzbrokerage/transaction_summarybrokerage/portfolios%brokerage/portfolios/{portfolio_uuid}"brokerage/convert/trade/{trade_id}zbrokerage/cfm/balance_summaryzbrokerage/cfm/positions)z$brokerage/cfm/positions/{product_id}brokerage/cfm/sweepsz)brokerage/intx/portfolio/{portfolio_uuid}z)brokerage/intx/positions/{portfolio_uuid}z2brokerage/intx/positions/{portfolio_uuid}/{symbol}zbrokerage/payment_methodsz-brokerage/payment_methods/{payment_method_id}zbrokerage/key_permissions)zbrokerage/orderszbrokerage/orders/batch_cancelzbrokerage/orders/editzbrokerage/orders/edit_previewzbrokerage/orders/previewr   zbrokerage/portfolios/move_fundszbrokerage/convert/quoter   zbrokerage/cfm/sweeps/schedulezbrokerage/intx/allocatezbrokerage/orders/close_position)r   r   )r9   v3r   tradingz0.012z0.006010000z0.00450000z0.0025100000z0.0021000000z0.001815000000z0.001675000000z0.0012	250000000z0.0008	400000000z0.0005z0.0015z0.001z0.0006z0.0003z0.0)takermaker)r   r   	tierBased
percentagetiersprecisionMode
exceptionstwo_factor_requiredparam_requiredvalidation_errorinvalid_requestpersonal_details_requiredidentity_verification_requiredjumio_verification_required&jumio_face_match_verification_requiredunverified_emailauthentication_errorinvalid_authentication_methodinvalid_tokenrevoked_tokenexpired_tokeninvalid_scope	not_foundrate_limit_exceeded)internal_server_errorUNSUPPORTED_ORDER_CONFIGURATIONINSUFFICIENT_FUNDPERMISSION_DENIEDINVALID_ARGUMENT)PREVIEW_STOP_PRICE_ABOVE_LAST_TRADE_PRICEPREVIEW_INSUFFICIENT_FUND)z&Insufficient balance in source accountzrequest timestamp expiredz%order with self orderID was not found)exactbroad
timeframes
ONE_MINUTEFIVE_MINUTEFIFTEEN_MINUTETHIRTY_MINUTEONE_HOURTWO_HOURSIX_HOURONE_DAY)1m5m15m30m1h2h6h1dCGLDCELO
usePrivatebrokerIdccxtstablePairs)zBUSD-USDz	CBETH-ETHzDAI-USDzGUSD-USDzGYEN-USDzPAX-USDzPAX-USDTzUSDC-EURzUSDC-GBPzUSDT-EURzUSDT-GBPzUSDT-USDz	USDT-USDCzWBTC-BTCexpiresi  walletfiat
v3AccountsACCOUNT_TYPE_CRYPTOACCOUNT_TYPE_FIATnetworksethereumstellar)ERC20XLM!createMarketBuyOrderRequiresPriceadvancedfetchMarketsV3timeDifferencer   adjustForTimeDifferencefetchTickerV3fetchTickersV3fetchAccountsV3v2PrivateGetAccountsv2PublicGetTimeuser_native_currencyUSD)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergi  i'  )r=  limitdaysBack	untilDayssymbolRequired)r=  triggerrF  rO  )r=  rL  rP  rF  rO  )r=  rL  rM  rN  rP  rF  rO  )r=  rL  rM  daysBackCanceledrN  rP  rF  rO  rL  ,  )	sandboxrU   createOrdersr   r   r   r   ri   r   extendsdefault)linearinverse)rV  r?   rA   rB   )commonCurrenciesoptionsfeatures)deep_extendsuperr,   describe
userAgentsparse_numberr)   r   r   r'   r"   r#   r    r$   r(   r%   )self	__class__s    U/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/coinbase.pyr^  coinbase.describe   s   h > @ fC
*fC
'fC
 $fC
 4	fC

 fC
 fC
 tfC
 2fC
 lfC
"  ~~~ %~ 	~
 %~ %~ U~ $U~ '~ ~ t~ ~ $U~  ~ %d~  '!~" &t#~$ '%~& ''~( /)~* ,U+~, (-~. 0/~0 t1~2 73~4 9%5~6 &t7~8 (9~: ';~< (=~> "4?~@ 4A~B TC~D  E~F G~H  I~J &uK~L "5M~N +EO~P )%Q~R #ES~T ,UU~V &tW~X $TY~Z $T[~\ $T]~^ +E_~` 'a~b (c~d "4e~f g~h &zi~j (k~l 1$m~n 'o~p (q~r  s~t +Du~v &uw~x 'y~z ({~| #E}~~ *5~@ $UA~B uC~D "5E~F *5G~H +EI~J )%K~L #EM~N tO~P  Q~R !%S~T %eU~V $UW~X &uY~Z -e[~\ /]~^ "5_~` #Ea~b +Ec~d e~f !%g~h "5i~j tk~l &um~n o~p +Eq~r  s~t du~v $Uw~x +Ey~z %e{~| "4}~~ u~@ #EA~B dC~D !$E~F tG~H  I~J 'K~L $UM~N !$O~P *5Q~R (S~T %eU~V )%W~X )%Y~Z t[~\ ]~^ T_~` ta~b ":c~d #De~f )%g~h #Di~j k~l #Em~n &uo~p  %$"!&#( {~#fC
` }6 2<Q
 p< UafC
@ "$AfC
H  *.15$(.2/3374848	  & 3T  >t  KD	 
 XY]  A$  RSW  9$  B4  :4  DT  =d  J4  @  PQU   .t! " B4# $ %))-' , )-=A?CBF\`Z^:>JN;?LP>BRVAEX\!" 6:$( 
 .2SW#U. <~ ./=>9:FGNOMN 	 0! ?  @  @	 
 Ea  1!  >q  Fq  Ea  5a  5a  <Q  3A  DQ  A!   <Q! " 6q# $ EF45IJIJRS9:MN9:3 8 12=>56=>8945?@78BC=>78?@!  DQ  FG45#]2 >}}IfC
D	 !..w7!..w7!%"& "..s3T5F5Fw5OP!..w79J9J79ST!..w79J9J89TU!..x8$:K:KG:TU!..y94;L;LX;VW!..z:D<M<Mh<WX!..z:D<M<Mh<WX!..{;T=N=Nx=XY!..{;T=N=Nx=XY
" "..s3T5F5Fw5OP!..w79J9J89TU!..w79J9J89TU!..x8$:K:KG:TU!..y94;L;LX;VW!..z:D<M<Mh<WX!..z:D<M<Mh<WX!..{;T=N=Nu=UV!..{;T=N=Nu=UV
"E	fC
D
 YE
fC
F
 )+>$m ' &}	
 01D 56I 23F =>Q '(; +,? 45H $%8 $%8 $%8 $%8   !" *+<#$ .;7A):)9(2AM1B16 ?P1==J7 G
fC
H "#'&   	IfC
^ !eF    H "t$	  )'  '$!( 4T)* D+,  0-. !!/0 *512 34  056  !278  69: .;< '=D  %&*(,,0,0)-+/6:#'#'"&#'	( #($)$(+/26/4#()$, %)&+!%$(%**/& ',#($)*/	# ',!%#($)*/( ',!%$(%*#($)*/$ ',!%$(,0%*#($)*/	*  #ACJ y
 "9  $	 "9  $	]TcfC
 f f	    c                 X  #    U R                  U R                  SS5      nU R                  USU5      nU R                  US5      nSnUS:X  a-  U R                  U5      I Sh  vN nU R	                  US0 5      nOU R                  U5      I Sh  vN nU R                  USS5      $  ND N7f)a  
fetches the current integer timestamp in milliseconds from the exchange server

https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-time#http-request

:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.method]: 'v2PublicGetTime' or 'v3PublicGetBrokerageTime' default is 'v2PublicGetTime'
:returns int: the current integer timestamp in milliseconds from the exchange server
r   r6  methodNdataepochepochSeconds)safe_stringrZ  omitr6  	safe_dictv3PublicGetBrokerageTimesafe_timestamp_2)ra  paramsdefaultMethodrg  responses        rc  
fetch_timecoinbase.fetch_time  s      (({DUV!!&(MB68,&&!11&99H ~~h;H!::6BBH $$XwGG' : Cs$   AB*!B&",B*B(B*(B*c                    #    U R                  U R                  SS5      nUS:X  a  U R                  U5      I Sh  vN $ U R                  U5      I Sh  vN $  N N7f)a  
fetch all the accounts associated with a profile

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getaccounts
https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-accounts#list-accounts

:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
r_   r4  N)rk  rZ  fetch_accounts_v3fetch_accounts_v2ra  rp  rg  s      rc  fetch_accountscoinbase.fetch_accounts*  sY      !!$,,ARS&&//777++F333 83!   8AAAAAAc                 8  #    U R                  5       I S h  vN   SnU R                  USS5      u  p!U(       a!  U R                  SS S S USSS S5	      I S h  vN $ SS0nU R                  U R	                  X15      5      I S h  vN nU R                  US/ 5      nU R                  US	0 5      nU R                  US5      nU R                  US/ 5      n[        U5      n	U	S
-
  n
U R                  X5      nUb  US:w  a  X{S'   XU
'   U R                  XQ5      $  N N N7f)NFr_   paginatenext_starting_afterstarting_afterd   rL  rh  
paginationr    )
load_marketshandle_option_and_paramsfetch_paginated_call_cursorr5  extend	safe_listrm  rk  lenparse_accounts)ra  rp  r}  requestrr  rh  r  cursorr   length	lastIndexlasts               rc  rw  coinbase.fetch_accounts_v2:  sM    !!!88R\]99/4QUW[]cez  }M  OS  UX  Y  Y  YS
 224;;w3OPPZ ~~h3^^HlB?
!!*.CD>>(FB7XQJ	~~h2Vr\*0&'"&Y""400 	" Y Qs4   DD>DD+DDBDDDc                   #    U R                  5       I S h  vN   SnU R                  USS5      u  p!U(       a!  U R                  SS S S USSS S5	      I S h  vN $ SS0nU R                  U R	                  X15      5      I S h  vN nU R                  US/ 5      n[        U5      nUS-
  nU R                  XW5      nU R                  US5      n	U	b  U	S	:w  a  XS'   XU'   U R                  XQ5      $  N N Np7f)
NFr_   r}  r     rL  r   r   r  )
r  r  r  v3PrivateGetBrokerageAccountsr  r  r  rm  rk  r  )
ra  rp  r}  r  rr  r   r  r  r  r  s
             rc  rv  coinbase.fetch_accounts_v3|  s    !!!88R\]99/4QUW[]cemowy}  @C  D  D  DS
 ;;DKK<XYY> >>(J;XQJ	~~h2!!(H5Vr\#N"&Y""844_ 	" D Zs4   C4C.>C4C0+C4C2A-C40C42C4c                   #    U R                  U5      I Sh  vN nU R                  US/ 5      n/ n[        S[        U5      5       H=  nX5   nUR	                  U R                  US5      U R                  US5      SUS.5        M?     U$  Nq7f)aC  
fetch all the portfolios

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getportfolios

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
N
portfoliosr   uuidtyper0   r  codeinfo)v3PrivateGetBrokeragePortfoliosr  ranger  appendrk  )ra  rp  rr  r  resulti	portfolios          rc  fetch_portfolioscoinbase.fetch_portfolios  s      ==fEE^^HlB?
q#j/*A"IMM&&y&9((F;!	  +  Fs   BB	A2Bc                 x   U R                  US5      nU R                  US5      nU R                  US0 5      nU R                  USU5      nU R                  US5      nU R                  US5      nUR                  S5      nU R	                  USS5      Ub  U R                  US	5      OUU R                  U5      US
.$ )Nactivecurrencyr  r1   r   r0   r  r   r  )	safe_boolrk  rm  splitsafe_string_2safe_string_lowersafe_currency_code)	ra  accountr  currencyIdV3r  
currencyIdtypeV3typeV2partss	            rc  parse_accountcoinbase.parse_account  s    p 2''<>>':r:%%hE
!!'62!!'62S!$$WdF;9?9KD**5!4RX++J7	
 	
re  r  c                 H  #    U R                  US5      nU R                  US5      nUch  U R                  5       I Sh  vN   [        S[	        U R
                  5      5       H-  nU R
                  U   nUS   U:X  d  M  US   S:X  d  M(  US   n  O   Uc  [        U R                  S-   U-   S	-   5      eSU0nU R                  U R                  Xb5      5      I Sh  vN nU R                  US
0 5      nU R                  US5      n	U R                  US5      n
UU	U
SUS.$  N NE7f)ao  
create a currency deposit address

https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-addresses#create-address

:param str code: unified currency code of the currency for the deposit address
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`

account_idNr   r  r  r#  r0   zO createDepositAddress() could not find the account with matching currency code z?, specify an `account_id` extra param to target specific walletrh  destination_tagaddress)r  tagr  networkr  )rk  rl  load_accountsr  r  r   r   r0   'v2PrivatePostAccountsAccountIdAddressesr  rm  )ra  r  rp  	accountIdr  r  r  rr  rh  r  r  s              rc  create_deposit_addresscoinbase.create_deposit_address
  sS     $$V\:	6<0$$&&&1c$--01--*6?d*wv(/J 'I	 2
 *{ {  C  !C  FG  !G  H  H)
 EEdkkRYFbccJ ~~h3t%67""43
 	
g ' ds/   ;D"D<D">D"	AD"D AD" D"NsymbolsincerL  c                   #    U R                  X45      nU R                  5       I Sh  vN   U R                  USS/5      nU R                  U R	                  XV5      5      I Sh  vN nU R                  US   SX#5      $  NV N7f)a
  
@ignore
       fetch sells

       https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-sells#list-sells

       :param str symbol: not used by coinbase fetchMySells()
       :param int [since]: timestamp in ms of the earliest sell, default is None
       :param int [limit]: max number of sells to return, default is None
       :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  rh  )prepare_account_requestr  rl  "v2PrivateGetAccountsAccountIdSellsr  parse_trades)ra  r  r  rL  rp  r  querysellss           rc  fetch_my_sellscoinbase.fetch_my_sellsR  s{      ..u=!!!		&<"=>==dkk'>YZZ  veCC 	"Z!   %BA>;B#B $B Bc                   #    U R                  X45      nU R                  5       I Sh  vN   U R                  USS/5      nU R                  U R	                  XV5      5      I Sh  vN nU R                  US   SX#5      $  NV N7f)a  
@ignore
       fetch buys

       https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-buys#list-buys

       :param str symbol: not used by coinbase fetchMyBuys()
       :param int [since]: timestamp in ms of the earliest buy, default is None
       :param int [limit]: max number of buys to return, default is None
       :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  rh  )r  r  rl  !v2PrivateGetAccountsAccountIdBuysr  r  )ra  r  r  rL  rp  r  r  buyss           rc  fetch_my_buyscoinbase.fetch_my_buysf  s{      ..u=!!!		&<"=>;;DKK<WXX  ftUBB 	"Xr  c                    #    S nU R                  X$U5      I S h  vN u  peU R                  5       I S h  vN   [        X5      " U R                  Xe5      5      I S h  vN nU R	                  US   S X45      $  N\ ND N7f)Nrh  )*prepare_account_request_with_currency_coder  getattrr  parse_transactions)ra  rg  r  r  rL  rp  r  rr  s           rc  fetch_transactions_with_method'coinbase.fetch_transactions_with_methodz  sv      $ O OPT]c dd!!! .t{{7/KLL&&x'7uLL e!Ls1   A=A7A=A9'A=A;A=9A=;A=c                    #    SnU R                  USS5      u  pTUS:X  a/  U R                  SXX45      I Sh  vN nU R                  USSS5      $ U R                  S	XX45      I Sh  vN $  N3 N7f)
a_  
Fetch all withdrawals made from an account. Won't return crypto withdrawals. Use fetchLedger for those.

https://docs.cdp.coinbase.com/coinbase-app/docs/api-withdrawals#list-withdrawals

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch withdrawals for
:param int [limit]: the maximum number of withdrawals structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.currencyType]: "fiat" or "crypto"
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr   currencyTypecrypto)v2PrivateGetAccountsAccountIdTransactionsr  
withdrawalF(v2PrivateGetAccountsAccountIdWithdrawalsr  r  filter_by_arrayra  r  r  rL  rp  r  resultss          rc  fetch_withdrawalscoinbase.fetch_withdrawals  s      #<<VEWYgh8# ??@kmqz  I  IG''uMM889ceirw  A  A  	A I A!   4A.A*.A.%A,&A.,A.c                    #    SnU R                  USS5      u  pTUS:X  a/  U R                  SXX45      I Sh  vN nU R                  USSS5      $ U R                  S	XX45      I Sh  vN $  N3 N7f)
ac  
Fetch all fiat deposits made to an account. Won't return crypto deposits or staking rewards. Use fetchLedger for those.

https://docs.cdp.coinbase.com/coinbase-app/docs/api-deposits#list-deposits

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch deposits for
:param int [limit]: the maximum number of deposits structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.currencyType]: "fiat" or "crypto"
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr   r  r  r  r  r]   F%v2PrivateGetAccountsAccountIdDepositsr  r  s          rc  fetch_depositscoinbase.fetch_deposits  s      #<<VEWYgh8# ??@kmqz  I  IG''EJJ889`bfot}}} I}r  c                    #    U R                  5       I Sh  vN   U R                  SXX45      I Sh  vN nU R                  USSS/S5      $  N5 N7f)a>  
fetch history of deposits and withdrawals

https://docs.cdp.coinbase.com/coinbase-app/docs/api-transactions

:param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
:param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
:param int [limit]: max number of deposit/withdrawals to return, default = 50, Min: 1, Max: 100
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr  r  r]   r  F)r  r  r  )ra  r  r  rL  rp  r  s         rc  fetch_deposits_withdrawals#coinbase.fetch_deposits_withdrawals  sa      !!!;;<gimv{  E  E##GVi5NPUVV 	" Es   AAAAAAstatusc                 2    SSSS.nU R                  X!U5      $ )Npendingokcanceled)created	completedr  rk  ra  r  statusess      rc  parse_transaction_status!coinbase.parse_transaction_status  s'     "

 &99re  transactionr  c                 P   U R                  US5      nS nS nU R                  US0 5      nUS:X  a&  U R                  US5      nU R                  US0 5      nO%U R                  US5      nU R                  US0 5      nUc  U R                  US5      nU R                  US5      n[        R                  " U5      nU R	                  U R                  US	5      5      n	U	c  U R                  US
5      n
U
(       a  SOS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S5      nUnU R                  USS/5      (       d=  [        R                  " US5      (       a  SnO[        R                  " US5      (       a  SnU R                  US5      nU R                  US5      nU R                  US5      n0 SU_SU_SU R                  USU5      _SU R                  U5      _SU_SU R                  U5      _SU_SU_SS _SS _SS _S S _SU_SU R                  U5      _SU R                  X5      _S	U	_S!U R                  U R                  US"5      5      _SU R                  US5      U R                  U5      S#.0E$ )$Nr  r  sendtransaction_amounttransaction_feesubtotalfeeamountr  	committedr  r  r0   r  
created_atresourcer]   r  r   tor  network_namer  txidhash	timestampdatetime	addressToaddressFromr  tagTotagFromupdated
updated_atcostr  )rk  rm  r*   
string_absr  r  in_array	string_gt	string_lt	parse8601network_id_to_coder`  r  safe_number)ra  r  r  transactionTypeamountAndCurrencyObject	feeObjectr  amountStringamountStringAbsr  r  r0   r  feeCurrencyIdr  r  r  toObjectr  	networkIds                       rc  parse_transactioncoinbase.parse_transaction  s!   t **;?"&	..i<f$&*nnW>R&S#w0A2FI&*nn[*&M#{E2>I"*&*nn[(&K#''(?J!,,\:..t/?/?X/VW>{K@I&TIFk40%%&=zJ
((J?##K>##K<}}TI|#<==  s33 ""<55#>>+t4$$Xy9	$$Wn=	
K
"
 D$$Wfb9
 1	

 
 t..y9
 y
 
 4
 4
 T
 t
 D
 d''8
 //
E
  f!
" t~~d&6&6{L&QR#
$ ((H= 33MB%
 	
re  trademarketc                     S nU R                  US0 5      nU R                  US0 5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nU R                  XS5      nUb  US   nOTU R                  US5      n	U R                  US5      n
U	b-  U
b*  U R                  U	5      nU R                  U
5      nUS	-   U-   nU R	                  US
5      nU R                  US5      nS nU R                  US5      nU(       a  Un[
        R                  " UU5      nU R                  US5      nU R                  USU5      nU R                  USU5      nS nS nUb  Ub  [
        R                  " UU5      nOUnUb  Ub  [
        R                  " UU5      nOUnU R                  US5      nU R                  USU R                  U5      5      nUc  Ub  Ub  US   nU R                  U/ SQ5      nU R                  USS5      nU R                  US5      nU R                  UU R                  USS5      U R                  US5      U R                  U5      UUS US:X  a  S OUUS:X  a  S OUUUUUU R                  U5      S.S.5      $ )Ntotalr  r  r  
product_id-r  r  /size_in_quotepricesize
commissionquote)r  
trade_timer   r  sideliquidity_indicatorr0   trade_idorder_idunknown_order_sideunknown_liquidity_indicatorr  )r  r0   orderr  r  r  r  r,  takerOrMakerr'  r  r  r  )rm  rk  safe_marketr  r  r*   
string_div
string_mulr  r`  safe_string_nsafe_string_lower_2r  
safe_trader  r  )ra  r  r   r  totalObjectamountObjectsubtotalObjectr  marketIdbaseIdquoteIdbaser*  sizeInQuotev3Pricev3Costv3Amount	v3FeeCostr  
costStringpriceStringr  r  feeCostr  r,  r3  s                              rc  parse_tradecoinbase.parse_trade  s   | nnUGR8~~eXr:z2>NN5%4	##E<8!!(C8H%F%%lJ?F&&{J?G")<..v6//8e+nnUO<""5'2##E62F))(G<H$$UL9	''hI%%nhG
")A!,,ZFK!K#,*B%%k<@DD((J?""9h8I8I)8TU!(:AT"7OM%%e-QR''z6B--e5JK$$UD*=%%eZ81 !%99D%15R%RDYe " 33MB 
  	re  c                   #    U R                   S   (       a  U R                  5       I Sh  vN   U R                  U R                   SS5      nUS:X  a  U R                  U5      I Sh  vN $ U R	                  U5      I Sh  vN $  NY N N7f)a$  

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpublicproducts
https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-currencies#get-fiat-currencies
https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates#get-exchange-rates

retrieves data on all markets for coinbase
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.usePrivate]: use private endpoint for fetching markets
:returns dict[]: an array of objects representing market data
r1  Nr   r/  )rZ  load_time_differencerk  fetch_markets_v3fetch_markets_v2rx  s      rc  fetch_marketscoinbase.fetch_markets  s}      <<12++---!!$,,@PQ%%..v666**6222	 . 72s3   (B
B;B
&B'B
?B B
B
B
c                   #    U R                  U5      I S h  vN nU R                  US0 5      nU R                  US0 5      nU R                  US/ 5      nU R                  US5      nU R                  U R                  US0 5      S0 5      n[	        UR                  5       5      n/ n	[        S[        U5      5       H  n
X   nU R                  U5      nX;   a  SOSnUS:X  d  M)  [        S[        U5      5       H  nX^   nU R                  US5      nU R                  U5      nU	R                  U R                  0 SUS	-   U-   _S
US-   U-   _SU_SU_SS _SU_SU_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.U R                  US5      S S.S .US!.	E5      5        M     M     U	$  GN7f)"Nr   exchangeRatesrh  r0   ratesr   r$  r  r$  r  r%  r@  r*  settler>  r?  settleIdr  r?   Tr@   FrA   rB   rC   r  contractrW  r  r'  minmaxmin_sizerG  r  r'  r  )	rX  contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitsr  )fetch_currencies_from_cacherm  r  index_bylistkeysr  r  r  rk  r  safe_market_structurer  )ra  rp  rr  r   rR  rh  dataByIdrS  baseIdsr  r  r>  r@  r  jquoteCurrencyr?  r*  s                     rc  rN  coinbase.fetch_markets_v2#  s    99&AA^^HlB?
x"E~~j&"5==t,t~~mVRH'SUVuzz|$q#g,'AZF**62D$06xDxq#d),A$(GM"..}dCG 33G<EMM$"<"< />fslW4/> $*u"4/> />  	/>
 !$/> !&/> "7/> #D/> /> /> !%/> /> !%/> !%/> !$/>  #E!/>" !$#/>$ $((,"&*."&&*&*%)& (,'+)
 (,'+'
 (,'+&
 (,'7'7z'R'+%#$ !.]/> /# /	 - (t E Bs   F?F<CF?$CF?c           	        #    SnU R                  USSS5      u  p!/ nU(       a!  UR                  U R                  U5      5        O UR                  U R                  U5      5        U R	                  S5      (       a   UR                  U R                  U5      5        / n U R                  U R                  USS05      5      U R                  U R                  USSS.5      5      /n[        R                  " U6 I S h  vN nS n [        R                  " U6 I S h  vN nU R                  US0 5      nU R                  US	0 5      n	U R                  US0 5      n
U R                  US	0 5      nU R                  US0 5      nU R                  US	0 5      nU R                  U	S
0 5      nU R                  US
0 5      nU R                  US
0 5      nU R                  US/ 5      n/ n[        S[        U5      5       H'  nUR                  U R                  UU   U5      5        M)     U R                  U
S/ 5      n[        S[        U5      5       H'  nUR                  U R                  UU   U5      5        M)     U R                  US/ 5      n[        S[        U5      5       H'  nUR                  U R                  UU   U5      5        M)     / n[        S[        U5      5       H^  nUU   nU R!                  US0 5      nU R                  US/ 5      n[        U5      nUS:  a	  US   US'   OS US'   UR                  U5        M`     U$ ! [         a  n/ n S nAGNlS nAff = f GN^ GNC! [         a  n/ n S nAGNSS nAff = f7f)NFr   r  product_typeFUTURE	PERPETUAL)ro  contract_expiry_typer   r   fee_tierproductsr  alias_toalias)r  r  v3PrivateGetBrokerageProducts"v3PublicGetBrokerageMarketProductscheck_required_credentials'v3PrivateGetBrokerageTransactionSummaryr  	Exceptionasynciogatherrm  r  r  r  parse_spot_marketparse_contract_market
safe_value)ra  rp  r  spotUnresolvedPromisesunresolvedContractPromisesepromisescontractPromisesr?   r   expiringFuturesperpetualFuturesexpiringFeesperpetualFeesfeeTierexpiringFeeTierperpetualFeeTierrh  r  r  
futureDataperpetualData
newMarketsr   r  realMarketIdsr  s                              rc  rM  coinbase.fetch_markets_v3h  s`    
!::6>S_afg
!#"))$*L*LV*TU"))$*Q*QRX*YZ\ **511"))$*V*VW]*^_0 &("	,77F^]eLf8gh77F]e  @K  ML  9M  N*& !)?@@	"%,^^5O%PP ~~h2.~~h2...)91bA>>*:ArB~~&62>'7B?( ..z26..z2F>>-RH~~dJ3q#d)$AMM$00a'BC %^^OZD
q#j/*AMM$44Z]OTU +'7RHq#m,-AMM$44]15EGWXY .
q#f+&AAYF??6626D NN4R@M'Fz"/"2w"&wf% ' s  	,)+&	,@  Q 	"!	"sz   BM9AL? %M9;M<M9M MM H!M9?
M	MM9MM9M 
M6)M1+M91M66M9c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      nU R                  US5      nU R                  US5      n	U R	                  U R
                  S/ 5      n
U R                  U R                  S   S5      nU R                  U R                  S   S	5      nU R                  X:5      (       a  S
OU R                  USU5      nU R                  X:5      (       a  SOU R                  USU5      nU R                  0 SU_SUS-   U-   _SU_SU_SS _SU_SU_SS _SU_SUS:H  _SS _SS_SS_SS_SU	(       + _SS_S S _S UUS S S S S U R                  US!5      U R                  US"S#5      S$.S S S%.U R                  US&5      U R                  US'5      S%.S S S%.U R                  US(5      U R                  US)5      S%.S*.S US+.E5      $ ),Nr#  base_currency_idquote_currency_idro  trading_disabledr!  r   r   r   gh㈵>taker_fee_rateg        maker_fee_rater0   r  r%  r@  r*  rT  r>  r?  rU  r  r?   r@   rA   FrB   rC   r  rV  rW  base_incrementprice_incrementquote_incrementrW  rX  base_min_sizebase_max_sizequote_min_sizequote_max_sizer\  rX  r   r   r]  r^  r_  r`  ra  rb  rc  r  r  )rk  r  r  r  r  rZ  r  r   r  rh  safe_number_2)ra  r   r  r0   r>  r?  r@  r*  
marketTypetradingDisabledr!  defaultTakerFeedefaultMakerFeetakerFeemakerFees                  rc  r~  coinbase.parse_spot_market  s   @ fl3!!&*<=""6+>?&&v.''0++FNC
..1CDnnT\\="E**499Y+?I**499Y+?I"mmB<<7$BRBRSZ\ln}B~--883d>N>NwXhjy>z)) 2+
"2+
dSj5(2+
 D2+
 U	2+

 d2+
 f2+
 w2+
 2+
 J2+
 Z6)2+
 d2+
 E2+
 e2+
 e2+
 /)2+
  !2+
" d#2+
$  "**63CD++F4EGXY  
  ++FOD++FOD
  
  ++F4DE++F4DE$ c2+
 2 2	re  c                    U R                  US5      nU R                  US0 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U R	                  U5      n	US:H  n
U R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      nU R                  US	5      nUS
-   U-   nS nU
(       a  SnUS-   U-   nOSnUS-   U-   S-   U R                  U5      -   nU R                  US5      nU R                  US5      nU(       a  UOU R                  S5      nU(       a  UOU R                  S5      nU R                  0 SU_SU_SU_SU_SU_SU_SU_SU_SU_SS_SS_SU
_SU
(       + _SS_S U(       + _S!S"_S#S"_SUUUUU	S S U R                  US$5      U R                  US%S&5      S'.S S S(.U R                  US)5      U R                  US*5      S(.S S S(.U R                  US+5      U R                  US,5      S(.S-.S US..E5      $ )/Nr#  future_product_detailsrr  contract_sizecontract_expiryrq  contract_root_unitr  is_disabledr%  rA   :rB   r$  r  r  z0.06z0.04r0   r  r@  r*  rT  r>  r?  rU  r  r?   Fr@   rC   r  rV  TrW  r  r  r  rW  rX  r  r  r  r  r\  r  )rk  rm  r  r  iso8601r  r  yymmddr`  rh  r  )ra  r   r  r0   futureProductDetailscontractExpiryTyper]  contractExpireexpireTimestampexpireDateTimeisSwapr>  r?  r@  r*  r  r  r  takerFeeRatemakerFeeRater   r   s                         rc  r  coinbase.parse_contract_marketW  s(   l fl3#~~f6NPRS!--.BDZ[''(<oN))*>@QR..8o6$3!!"68LM""6+>?&&v.''0..?e#Dc\E)FDc\E)C/$++o2NNF''1AB''1AB ,$2C2CF2K ,$2C2CF2K)) 2+
"2+
f2+
 D2+
 U	2+

 e2+
 f2+
 w2+
 2+
 D2+
 E2+
 e2+
 F2+
 &j2+
 e2+
 /)2+
  !2+
" d#2+
$ (%,**63CD++F4EGXY  
  ++FOD++FOD
  
  ++F4DE++F4DE$ c2+
 2 2	re  c                   #    U R                  U R                  S0 5      nU R                  US5      nU R                  USS5      nU R                  5       nUb  XS-
  U:  a  U R	                  U5      U R                  U5      /n[        R                  " U6 I S h  vN nU R                  US0 5      nU R                  US0 5      n	U R                  US/ 5      n
U R                  U	S/ 5      nU R                  U5      I S h  vN nU R                  UU R                  X5      UUS.5      U R                  S'   U R                  U R                  S0 5      $  N NU7f)	Nro   r  r"    r   r   rh  )r   rR  r  )rm  rZ  safe_integermillisecondsv2PublicGetCurrenciesv2PublicGetCurrenciesCryptor|  r}  r  v2PublicGetExchangeRatesr  array_concat)ra  rp  rZ  r  r"  nowr  promisesResultfiatResponsecryptoResponsefiatData
cryptoDatarR  s                rc  rd  $coinbase.fetch_currencies_from_cache  sN    ../@"E%%g{;	##GY=!COw#>**62008H $+>>8#<<N>>.!R@L "^^NArBN ~~lFB?HCJ"&"?"?"GGM.2kk'"//E!. D /DLL*+
 ~~dll,=rBBC =6 Hs&   BEEA$E=E>AEEc                 ~  #    U R                  U5      U R                  U5      U R                  U5      /n[        R                  " U6 I Sh  vN nU R                  US0 5      nU R                  US0 5      nU R                  US0 5      nU R                  US/ 5      nU R                  US/ 5      nU R                  US0 5      n	U R                  U	S0 5      n
[        U
R                  5       5      nU R                  Xx5      n0 n0 n0 n[        S[        U5      5       H  nUU   nU R                  US5      nU R                  USS	5      nU R                  U5      nU R                  US
5      nUR                  5       U R                   S   U'   UR                  5       U R                   S   U'   Ub  SOSnU R#                  UUUUUSSSSS0 U R%                  US5      SS.SSS.S.S.5      UU'   Uc  M  UR                  5       nUUU'   UUU'   M     [        S[        U5      5       H;  nUU   nU R                  U5      nUU;  d  M!  U R#                  0 UUS0 S.5      UU'   M=     U R'                  XR                   S   5      U R                   S'   U R'                  XR                   S   5      U R                   S'   U$  GNo7f)av  
fetches all available currencies on an exchange

https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-currencies#get-fiat-currencies
https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates#get-exchange-rates

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
Nr   r      rh  rS  asset_idr0   r  r1   r(  networksByIdr  r$  Tr[  rX  )r  r   )r  r0   r  r  r1   r  r]   r   r  rb  r(  rc  )r  r0   r  r  r(  )r  r  r  r|  r}  rm  r  rf  rg  r  r  r  rk  r  r  lowerrZ  safe_currency_structurer  r  )ra  rp  r  r  r  r  ratesResponser  r  	ratesDatarS  ratesIdsr   r  r(  r  r  r  assetIdr0   r  r1   r  lowerCaseNamer  s                            rc  fetch_currenciescoinbase.fetch_currenciesG  s     &&v.,,V4))&1

  '~~x88~~na< 2>  ~q"=>>,;^^NFB?
NN=&"=	y'26

%&&x<
q#j/*A!!}H&&x<G##HdF;B**2.D##Hf5D-1ZZ\DLL$T*15DLL(. ' 38&D77  !  $//*E#
  $#!	9 F4L. " $

!..2]+G +J q#h-(A!!J**:6DFN#;;$ $ "=  t	 ) $(;;xj9Q#RZ '+{{<nA]'^^$q 9s!   A	J=J:F J=0AJ=A7J=symbolsc                    #    U R                  U R                  SS5      nUS:X  a  U R                  X5      I Sh  vN $ U R                  X5      I Sh  vN $  N N7f)a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getproducts
https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates#get-exchange-rates

:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.usePrivate]: use private endpoint for fetching tickers
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
r   r3  N)rk  rZ  fetch_tickers_v3fetch_tickers_v2)ra  r  rp  rg  s       rc  fetch_tickerscoinbase.fetch_tickers  sZ      !!$,,@PQ%%..w???**7;;; @;r{  c                 2  #    U R                  5       I S h  vN   U R                  U5      n0 nU R                  U R                  X25      5      I S h  vN nU R	                  US0 5      nU R	                  US0 5      nU R                  US5      n0 n[        UR                  5       5      n	Sn
[        S[        U	5      5       H<  nX   nX-   U-   nU R                  US U
5      nUS   nU R                  Xl   U5      X'   M>     U R                  USU5      $  N N7f)Nrh  rS  r  r$  r   r  )r  market_symbolsr  r  rm  rk  rf  rg  r  r  r4  parse_tickerfilter_by_array_tickers)ra  r  rp  r  rr  rh  rS  r?  r  rj  	delimiterr  r>  r=  r   r  s                   rc  r  coinbase.fetch_tickers_v2  s    !!!%%g.
 66t{{77STT ~~h3tWb1""44uzz|$	q#g,'AZF)G3H%%hi@FH%F!..u}fEFN ( ++FHgFF= 	"
 Us"   DD:DDCDDc                   #    U R                  5       I S h  vN   U R                  U5      n0 nUb  U R                  U5      US'   S nU R                  SU R	                  U5      US5      u  pBUb  US:w  a  US:X  a  SOSUS'   S nSnU R                  USS	S5      u  pbU(       a)  U R                  U R                  X25      5      I S h  vN nO(U R                  U R                  X25      5      I S h  vN nU R                  US
/ 5      n0 n[        S[        U5      5       HD  n	Xy   n
U R                  U
S5      nU R                  US S5      nUS   nU R                  X5      X'   MF     U R                  USU5      $  GNc N N7f)Nproduct_idsr   rV  rA   rp  SPOTro  Fr  rt  r   r#  r$  r  )r  r  
market_idshandle_market_type_and_paramsget_market_from_symbolsr  rw  r  rx  r  r  r  rk  r4  r  r  )ra  r  rp  r  r  rr  r  rh  r  r  entryr=  r   r  s                 rc  r  coinbase.fetch_tickers_v3  s    !!!%%g.%)__W%=GM"
!??PTPlPlmtPuw}  @I  J
!jI&=3=3GhfGN#
!::6>S_afg
!??G@\]]H!DDT[[QXEabbHL ~~h
B7q#d)$AGE''|<H%%hc:FH%F!..u=FN % ++FHgFF{ 	" ^bs5   F E9B/F E<(F /E>0B
F <F >F c                    #    U R                  U R                  SS5      nUS:X  a  U R                  X5      I Sh  vN $ U R                  X5      I Sh  vN $  N N7f)a$  
fetches 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/reference/retailbrokerageapi_getmarkettrades
https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices#get-spot-price
https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices#get-buy-price
https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices#get-sell-price

:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.usePrivate]: whether to use the private endpoint for fetching the ticker
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
r   r2  N)rk  rZ  fetch_ticker_v3fetch_ticker_v2)ra  r  rp  rg  s       rc  fetch_tickercoinbase.fetch_ticker"  sW      !!$,,O_$--f===))&999 >9r{  c                 0  #    U R                  5       I S h  vN   U R                  U5      nU R                  SUS   0U5      nU R                  U5      I S h  vN nU R	                  U5      I S h  vN nU R                  U5      I S h  vN nU R                  US0 5      nU R                  US0 5      n	U R                  US0 5      n
U R                  U
S5      U R                  U	S5      U R                  US5      S.nU R                  X5      $  N N N N7f)Nr  r0   rh  r  )bidaskr'  )	r  r   r  v2PublicGetPricesSymbolSpotv2PublicGetPricesSymbolBuyv2PublicGetPricesSymbolSellrm  r  r  )ra  r  rp  r   r  r?   r  r  spotDataaskDatabidData
bidAskLasts               rc  r  coinbase.fetch_ticker_v25  s    !!!V$++fTl
 55g>> 33G<< 44W== >>$3..fb1..fb1##GX6##GX6%%h9


   443 	"
 ? = >sG   DDA DDD0D1D	D
BDDDDc                   #    U R                  5       I S h  vN   U R                  U5      nUS   SS.nSnU R                  USSS5      u  pRS nU(       a)  U R                  U R	                  XB5      5      I S h  vN nO(U R                  U R	                  XB5      5      I S h  vN nU R                  US/ 5      nU R                  US   U5      nU R                  US	5      US
'   U R                  US5      US'   U$  N N N\7f)Nr0   r   )r#  rL  Fr   r  tradesr   best_bidr  best_askr  )	r  r   r  ,v3PrivateGetBrokerageProductsProductIdTickerr  1v3PublicGetBrokerageMarketProductsProductIdTickerr  r  r  )	ra  r  rp  r   r  r  rr  rh  tickers	            rc  r  coinbase.fetch_ticker_v3Q  s    !!!V$ ,
 
!::6=R^`ef
!NNt{{[bOkllH!SSTXT_T_`gTpqqH& ~~h"5""47F3((:>u((:>uG 	" mqs5   D C:A!D 8C<9(D !C>"AD <D >D r   c                 .   U R                  US5      nU R                  US5      nS nS nSU;   a  U R                  US/ 5      nU R                  US/ 5      nU R                  US0 5      n	U R                  US0 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S5      nU R	                  X5      nU R                  US5      nU R                  US	5      nU R                  0 S
US
   _SU R                  U5      _SU_SU_SU_SU_SS _SS _SU_SU_SS _SS _SU_SS _SS _SU R                  US5      _SS _U R                  US5      U R                  US5      US.EU5      $ )Nr  r  bidsasksr   r'  r(  r#  r   r  r  r  r  highlow	bidVolume	askVolumevwapopenclosepreviousClosechanger   price_percentage_change_24haverage
volume_24happroximate_quote_24h_volume)
baseVolumequoteVolumer  )r  r  rm  rk  r4  safe_tickerr  )ra  r   r   r  r  r  r  r  r  firstBidfirstAskr=  r  r  s                 rc  r  coinbase.parse_tickerw  s=   v vu-vu-		f>>&&"5D>>&&"5D~~dAr2H~~dAr2H""8W5C((6:I""8W5C((6:I##FL9!!(30##FF3 !
fX&!
1!
 !
 3	!

 3!
 D!
 D!
 4!
 !
 !
 D!
 D!
 T!
 T!
 d!
  $**63PQ!!
" t#!
$ **6<@++F4RS)!
* + 	re  c                 F   U R                  USS/ 5      nU R                  USU R                  S   5      nU R                  USU R                  S   5      nSU0n[        S[	        U5      5       GH  nX7   nU R                  US5      n	U R                  X5      (       a  U R                  US5      n
U
b  U R                  U
S5      nU R                  U5      nU R                  U
S	5      nUnU R                  Xl5      nUc  U R                  5       nXS
'   XS'   O:[        R                  " US
   U5      US
'   [        R                  " US   U5      US'   XU'   M  M  U R                  X5      (       d  GM  U R                  US5      nU R                  US5      nUc  GM.  Uc  GM4  U R                  US5      nU R                  U5      nU R                  US5      nU R                  US5      n[        R                  " UU5      nU R                  Xl5      nUc  U R                  5       nXS
'   UUS'   XS'   OW[        R                  " US
   U5      US
'   [        R                  " US   U5      US'   [        R                  " US   U5      US'   XU'   GM"     U R                  U5      $ )Nrh  r   r  r%  r  r   balancer  r  freer"  available_balanceholdvalueused)safe_list_2r  rZ  r  r  rk  r  rm  r  r  r*   
string_addsafe_balance)ra  rr  rp  balancesr   r%  r  br  r  r  r  r  r"  r  r  	availabler  r  s                      rc  parse_custom_balancecoinbase.parse_custom_balance  s   ##Hfj"E>>&&$,,z2JK^^FFDLL4NO
)q#h-(AkG##GV4D}}T,,w	:$!%!1!1%!DJ22:>D ,,UH=E D"nnV:G"&,,.*.+0(*1*<*<WV_e*T+2+=+=gg>NPU+V(#*4L % t00 NN74GH	~~gv6(T-=!%!1!1)Z!HJ22:>D++D':D++Iw?D#..tT:E"nnV:G"&,,.*.*.+0(*1*<*<WV_d*S*1*<*<WV_d*S+2+=+=gg>NPU+V(#*4LM )N   ((re  c                 `  #    U R                  5       I Sh  vN   0 nSnU R                  USS5      nU R                  US/5      nSnU R                  SSU5      u  pQU R	                  U R
                  SS5      nUS:X  a)  U R                  U R                  X!5      5      I Sh  vN nOhU(       d  US:X  a.  SUS'   U R                  U R                  X!5      5      I Sh  vN nO-SUS'   U R                  U R                  X!5      5      I Sh  vN nXQS	'   U R                  X15      $  GN N NL N 7f)
a  
query for balance and get the amount of funds available for trading or funds locked in orders

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getaccounts
https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-accounts#list-accounts
https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getfcmbalancesummary

:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.v3]: default False, set True to use v3 api endpoint
:param str [params.type]: "spot"(default) or "swap" or "future"
:param int [params.limit]: default 250, maximum number of accounts to return
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
Nr   Fr`   r  rB   r  rL  r  )r  r  rl  r  rk  rZ  &v3PrivateGetBrokerageCfmBalanceSummaryr  r  r5  r%  )ra  rp  r  rr  isV3r  rg  s          rc  fetch_balancecoinbase.fetch_balance(	  s-     !!!~~fdE26D6*
!??PTV\]
!!$,,@_`!!HHU\IeffH"AA"GG!??G@\]]H"GG!66t{{77STTHP $v((::q 	" g ^ UsF   D.D%BD."D(#:D.D*-D.D,D.(D.*D.,D.c                 r  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ SnUb  U R                  U5      nSnU R	                  XU5      I Sh  vN u  ptU R                  U R                  Xt5      5      I Sh  vN nU R                  US   XbU5      n	[        U	5      n
U
S	:X  a  U	$ U
S
-
  nU R                  X5      nU R                  US0 5      nU R                  US5      nUb  US:w  a  XS   S'   XU'   U	$  GN N N N7f)aT  
Fetch the history of changes, i.e. actions done by the user or operations that altered the balance. Will return staking rewards, and crypto deposits or withdrawals.

https://docs.cdp.coinbase.com/coinbase-app/docs/api-transactions#list-transactions

:param str [code]: unified currency code, default is None
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
:param int [limit]: max number of ledger entries to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
NFr   r}  r~  r  r  rh  r   r   r  r  r  )r  r  r  r  r  r  r  parse_ledgerr  rm  rk  )ra  r  r  rL  rp  r}  r  r  rr  ledgerr  r  r  r  r  s                  rc  fetch_ledgercoinbase.fetch_ledger	  sp     !!!88PZ[99-V[ez  }M  OS  UX  Y  Y  Y}}T*H $ O OPT]c dd GGT[Hdee""8F#3XeLVQ;MQJ	~~f0^^HlB?
!!*.CDVr\28L./ $93 	" Y
 e fsF   D7D.<D7D11D7D3)D7/D50A?D71D73D75D7c                 .    SS0nU R                  X!U5      $ )Nr  r  r  )ra  r  typess      rc  parse_ledger_entry_status"coinbase.parse_ledger_entry_status	  s#    
 v66re  c           
      >    SSSSSSSSSS.	nU R                  X!U5      $ )Nr  r  )	buysellfiat_depositfiat_withdrawalexchange_depositexchange_withdrawalr  pro_depositpro_withdrawalr  ra  r  r2  s      rc  parse_ledger_entry_type coinbase.parse_ledger_entry_type	  s9    ), -#0!(+

 T22re  itemc                    U R                  US0 5      nU R                  US5      nS n[        R                  " US5      (       a  Sn[        R                  " U5      nOSnU R                  US5      nU R                  Xb5      nU R                  Xb5      nS nU R                  US0 5      n	U R                  U	S5      n
U
b:  U R                  U
S5      nU R                  X5      nU R                  U
S5      nUUS.nU R                  U R                  US	5      5      nU R                  US
5      nU R                  U R                  US5      5      nU R                  U R                  US5      5      nU R                  US5      nS nUb'  UR                  S5      n[        U5      nUS:  a  US   nU R                  UUUU R                  U5      UUS S UUU R                  U5      S S UUS.U5      $ )Nr  r   outinr  r  r  r  r  r0   r  r  resource_pathr%  r   )r  r0   r  r  	directionr  referenceIdreferenceAccountr  r  r  beforeafterr  r  )rm  rk  r*   r  
string_negr  safe_currencyr  r  r?  r3  r  r  safe_ledger_entryr  r`  )ra  rA  r  
amountInfor  rF  r  r  r  networkInfofeeInfor  feeCurrencyCode	feeAmountr  r0   r  r  pathr  r  numPartss                         rc  parse_ledger_entrycoinbase.parse_ledger_entry	  s   h ^^D(B7
!!*h7	VS))I''/FI%%j*=
&&z<%%j; nnT9b9...?@ ,,WjAM"55mNO(((;I!+C NN4#3#3D,#GH	dD)++D,<,<T6,JK//0@0@x0PQo6	JJsOE5zH!|!!H	%%"Y/"  $''/'
  ! 	re  c                   #    U R                  5       I S h  vN   U R                  SU5      I S h  vN   [        S[        U R                  5      5       H"  nU R                  U   nUS   U:X  d  M  US   s  $    g  Nd NL7f)NFr   r  r0   )r  r  r  r  r   )ra  r  rp  r  r  s        rc  find_account_idcoinbase.find_account_id
  sx     !!!  ///q#dmm,-AmmA&Gv$&t}$ .  	"/s%   A?A;A?A=<A?1A?=A?c                 x    U R                  USS5      nUc  [        U R                  S-   5      eSU0nUb  XS'   U$ )Nr  r  zN prepareAccountRequest() method requires an account_id(or accountId) parameterrL  )r  r!   r0   )ra  rL  rp  r  r  s        rc  r   coinbase.prepare_account_request  sR    &&v|[I	#DGG.~$~)
 $Gre  c                 (  #    U R                  USS5      nU R                  USS/5      nUcU  Uc  [        U R                  S-   5      eU R	                  X5      I S h  vN nUc  [        U R                  S-   U-   S-   5      eSU0nUb  X%S'   XS/$  N37f)Nr  r  zz prepareAccountRequestWithCurrencyCode() method requires an account_id(or accountId) parameter OR a currency code argumentzG prepareAccountRequestWithCurrencyCode() could not find account id for zS. You might try to generate the deposit address in the website for that coin first.rL  )r  rl  r!   r0   rX  r   )ra  r  rL  rp  r  r  s         rc  r  3coinbase.prepare_account_request_with_currency_code  s     &&v|[I	6L+#>?|'  3o  )o  p  p"224@@I #DGG.w$wz~$~  BW  %W  X  X)
 $G   As   ABB4Br  c                    #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSUS'   U R	                  USSUSU5      I Sh  vN $  NZ N7f)a  
create a market buy order by providing the symbol and cost

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_postorder

:param str symbol: unified symbol of the market to create an order in
:param float cost: how much you want to trade in units of the quote currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr?   z9 createMarketBuyOrderWithCost() supports spot orders onlyFr-  r   r6  )r  r   r&   r0   create_order)ra  r  r  rp  r   s        rc  !create_market_buy_order_with_cost*coinbase.create_market_buy_order_with_cost!  sw      !!!V$f~tww)ddee6;23&&vxdFSSS 	"
 Ts"   A5A1AA5,A3-A53A5r  r,  r  r'  c                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  U R                  SS5      nUS-   U R	                  5       -   US   UR                  5       S.n	U R                  U/ SQ5      n
U R                  US5      nU R                  US	5      nU
SLnUSLnUSLnU R                  US
5      nUS:X  a  SOU R                  USSS5      nU R                  US5      nU R                  US5      nUS:X  Ga
  U(       a  Uc
  US:X  a  SOSnUS:X  d  UbW  Uc  [        U R                  S-   5      eSU R                  X5      U R                  X5      U R                  X5      UUS.0U	S'   GOSU R                  X5      U R                  X5      U R                  X5      US.0U	S'   GOU(       d  U(       ar  SnU(       a  Uc
  US:X  a  SOSnU R                  X5      nOUc
  US:X  a  SOSnU R                  X5      nSU R                  X5      U R                  X5      UUS.0U	S'   GOUS:X  d  UbG  Uc  [        U R                  S-   5      eSU R                  X5      U R                  X5      UUS.0U	S'   GOUS:X  a*  S U R                  X5      U R                  X5      S!.0U	S'   GOUS":X  a*  S#U R                  X5      U R                  X5      S!.0U	S'   GO^S$U R                  X5      U R                  X5      US%.0U	S'   GO3U(       d  U(       d  U(       a  [        U R                  S&-   5      eUS'   (       a  US:X  a  SnSnU R                  US(S)S5      u  nnU R                  US*5      nU R                  US*5      nUb  U R!                  UU5      nOU(       ag  Uc  [#        U R                  S+-   5      eU R%                  U5      nU R%                  U5      n[&        R(                  " UU5      nU R!                  UU5      nOU R!                  X5      nS,S-U00U	S'   OS,S.U R                  X5      00U	S'   U R                  US/5      nUb  US0:X  a  S1U	S2'   OUS3:X  a  S4U	S2'   U R                  U/ S5Q5      nU R                  US6S7S5      nSnU(       aO  U R                  US6S7/5      nU R                  U	S85      n	U R+                  U R-                  X5      5      I Sh  vN nO(U R/                  U R-                  X5      5      I Sh  vN nU R1                  US95      nUSLa  U R3                  US:5      nU R                  US;5      n U R                  US<5      n!UbK  U R5                  U R6                  S=   U U!5        U R9                  U R6                  S>   U U!5        [        U!5      eU R3                  US?0 5      n"U R;                  U"U5      $  GN N N7f)@aI  
create a trade order

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_postorder

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much you want to trade in units of the base currency, quote currency for 'market' 'buy' orders
:param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param float [params.stopPrice]: price to trigger stop orders
:param float [params.triggerPrice]: price to trigger stop orders
:param float [params.stopLossPrice]: price to trigger stop-loss orders
:param float [params.takeProfitPrice]: price to trigger take-profit orders
:param bool [params.postOnly]: True or False
:param str [params.timeInForce]: 'GTC', 'IOC', 'GTD' or 'PO', 'FOK'
:param str [params.stop_direction]: 'UNKNOWN_STOP_DIRECTION', 'STOP_DIRECTION_STOP_UP', 'STOP_DIRECTION_STOP_DOWN' the direction the stopPrice is triggered from
:param str [params.end_time]: '2023-05-25T17:01:05.092Z' for 'GTD' orders
:param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
:param boolean [params.preview]: default to False, wether to use the test/preview endpoint or not
:param float [params.leverage]: default to 1, the leverage to use for the order
:param str [params.marginMode]: 'cross' or 'isolated'
:param str [params.retail_portfolio_id]: portfolio uid
:param boolean [params.is_max]: Used in conjunction with tradable_balance to indicate the user wants to use their entire tradable balance
:param str [params.tradable_balance]: amount of tradable balance
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r   r$  r0   )client_order_idr#  r,  )	stopPrice
stop_pricer>  rA  rB  rD  r;  TpostOnly	post_onlyFend_timestop_directionrL  r6  STOP_DIRECTION_STOP_DOWNSTOP_DIRECTION_STOP_UPr<  z= createOrder() requires an end_time parameter for a GTD orderstop_limit_stop_limit_gtd)	base_sizelimit_pricere  ri  rh  order_configurationstop_limit_stop_limit_gtc)rm  rn  re  ri  limit_limit_gtd)rm  rn  rh  rg  r9  sor_limit_ioc)rm  rn  r:  limit_limit_foklimit_limit_gtc)rm  rn  rg  z3 createOrder() only stop limit orders are supportedr?   rU   r-  r  a	   createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argumentmarket_market_ioc
quote_sizerm  r=  isolatedISOLATEDmargin_typecrossCROSS)rD  r>  rA  rB  rd  re  stopDirectionri  clientOrderIdrf  rg  rh  r=  previewtestrc  successerror_responseerrormessager	  r
  success_response)r  r   rk  rZ  r  uppersafe_number_nr  safe_bool_2r   r0   amount_to_precisionprice_to_precisionr&   r  rl  cost_to_precisionr$   number_to_stringr*   r6  #v3PrivatePostBrokerageOrdersPreviewr  v3PrivatePostBrokerageOrdersr  rm  throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionparse_order)#ra  r  r  r,  r  r'  rp  r   r0   r  r>  rA  rB  isStop
isStopLossisTakeProfitrD  rf  endTimer|  	tpslPricer"  r-  r  r  rG  costRequestr=  r~  rr  r  errorResponse
errorTitleerrorMessagerh  s#                                      rc  r_  coinbase.create_order3  s}    : !!!V$dllJ?!Cx$))+5 ,JJL

 ))&2]^((A**63DET)"$.
&d2&&v}='4/4d6F6Fvz[fhm6n""6:6((1AB7? (CG5=$>WoM5(g.A+DGG6u,uvv3)-)A)A&)Q+/+B+B6+Q*.*A*A&*W.;(/66G12 4)-)A)A&)Q+/+B+B6+Q*.*A*A&*W.;	66G12 | 	$,EIU](@Ys $ 7 7 NI$,GKu}(B[s $ 7 7 PI/%)%=%=f%M'+'>'>v'M&/*7	22-.  5(g.A+DGG6u,uvv))-)A)A&)Q+/+B+B6+Q(/)1	,6G12 !E)')-)A)A&)Q+/+B+B6+Q*6G12 !E)))-)A)A&)Q+/+B+B6+Q,6G12 *)-)A)A&)Q+/+B+B6+Q)1,6G12 |"477-b#bccf~45=481<@<Y<YZ`bo  rU  W[  =\916''7662# 2264@E6}*477  6A  ,A  B  B'+'<'<V'D&*&;&;E&B&-&8&8{&S $ 6 6v{ K 226BE'$e*2-. (#T%=%=f%M*2-.
 %%fl;
!Z')3&w&)0&6  $i  j""69feDYYv	6':;Fii):;G!EEdkkRYFbccH!>>t{{7?[\\HL ..95$ NN85EFM))-AJ++M9EL(44T__W5Mz[gh44T__W5Mz[gh#L11~~h(:B?f--{ 	"V d\s5   W)W"SW)4W%5(W)W'CW)%W)'W)r2  c           
         U R                  US5      nU R                  X2S5      nUb  U R                  XB5      nU R                  US0 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S5      n
U R                  US	5      nUS L=(       d    US L=(       d    US LnU	S L=(       d    U
S LnS nS nS nS nU(       aG  S nUb  UnOUb  UnOUnU R                  US
5      nU R                  US5      nU R	                  US5      nOiU(       aP  U	b  U	OU
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OU R                  US5      nU R                  US5      nU R                  US5      nS nUb  Ub  US   nU R                  0 SU_SU R                  US5      _SU R                  US5      _SU R                  U5      _SU_SS _SU_SU R                  U R                  US5      5      _SU R                  U R                  US5      5      _SU_SU R                  US5      _S U_S!U_S"U_S#U R                  US$5      _S%S _S&S _U R                  US'5      U R                  U R                  US(5      5      U R                  US5      US).S S*.EU5      $ )+Nr#  r$  ro  rt  rq  rr  rp  rl  ru  rn  rm  rg  re  created_time
total_feesr*  r  r0   r/  r}  rc  r  r  lastTradeTimestampr  r  
order_typerD  time_in_forcerf  r,  r'  r>  r  filledfilled_size	remainingr  average_filled_pricer  r  )r  r  r  r  )rk  safe_symbolr4  rm  r  
safe_orderr  parse_order_typeparse_time_in_forcer  parse_order_status)ra  r2  r   r=  r  orderConfigurationlimitGTClimitGTDlimitIOCstopLimitGTCstopLimitGTD	marketIOCisLimitr  r'  r  rf  r>  target
stopTargetr  	totalFeescurrencyFees                          rc  r  coinbase.parse_order  s   ~ ##E<8!!(C8%%f5F!^^E3H"M>>"46GH>>"46GH>>"4oF~~&8:UV~~&8:UVNN#57JK	D(]hd.B]X\H\t+JT1IF#!%!!$$V];E%%fk:F~~fk:H*6*BJ$$Z?E%%j+>F~~j+>H++JEL%%i=F##E>:$$UL9	!(: /K  
E 
$""5*5 
 T--e5FG 
 1	 

  
 !$ 
 f 
 D))$*:*:5,*OP 
 433D4D4DUO4\] 
  
 D**5&9 
 U 
 L 
 f 
 d&&um< 
  ! 
" D# 
$ ''/EF--d.>.>uh.OP((=' 1 
2 3 	re  c                 8    SSSSSS S.nU R                  X!U5      $ )Nr
  closedr  )OPENFILLED	CANCELLEDEXPIREDFAILEDUNKNOWN_ORDER_STATUSr  r  s      rc  r  coinbase.parse_order_status  s0    #! $(
 &99re  c                 B    US:X  a  g SSSSS.nU R                  X!U5      $ )NUNKNOWN_ORDER_TYPEr   rL  )MARKETLIMITSTOP
STOP_LIMITr  r>  s      rc  r  coinbase.parse_order_type  s6    ''!	
 T22re  rD  c                 6    SSSSS S.nU R                  X!U5      $ )NGTCr<  r9  r:  )GOOD_UNTIL_CANCELLEDGOOD_UNTIL_DATE_TIMEIMMEDIATE_OR_CANCELFILL_OR_KILLUNKNOWN_TIME_IN_FORCEr  )ra  rD  timeInForcess      rc  r  coinbase.parse_time_in_force  s-    $)$)#(!%)
 ;GGre  r0   c                    #    U R                  5       I Sh  vN   U R                  U/X#5      I Sh  vN nU R                  US0 5      $  N2 N7f)a_  
cancels an open order

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_cancelorders

:param str id: order id
:param str symbol: not used by coinbase cancelOrder()
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   )r  cancel_ordersrm  )ra  r0   r  rp  orderss        rc  cancel_ordercoinbase.cancel_order  sK      !!!))2$??~~fa,, 	"?s   AA	AAAAidsc                   #    U R                  5       I Sh  vN   SnUb  U R                  U5      nSU0nU R                  U R                  XS5      5      I Sh  vN nU R	                  US/ 5      n[        S[        U5      5       H4  nU R                  Xx   S5      n	U	SLd  M  [        U R                  S-   5      e   U R                  Xt5      $  N Nw7f)am  
cancel multiple orders

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_cancelorders

:param str[] ids: order ids
:param str symbol: not used by coinbase cancelOrders()
: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	order_idsr  r   r  Tz? cancelOrders() has failed, check your arguments and parameters)r  r   'v3PrivatePostBrokerageOrdersBatchCancelr  r  r  r  r  r"   r0   parse_orders)
ra  r  r  rp  r   r  rr  r  r  r  s
             rc  r  coinbase.cancel_orders  s      !!![[(F
 EEdkkRYFbcc )R8q#f+&AnnVY	:Gd" +l!lmm '   001 	" ds)   CCACCAC#,CCc                   #    U R                  5       I Sh  vN   U R                  U5      nSU0n	Ub  U R                  X%5      U	S'   Ub  U R                  X&5      U	S'   U R	                  USSS5      n
SnU
(       a=  U R                  USS/5      nU R                  U R                  X5      5      I Sh  vN nO(U R                  U R                  X5      5      I Sh  vN nU R                  X5      $  N N@ N7f)a  
edit a trade order

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_editorder

:param str id: cancel order id
:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.preview]: default to False, wether to use the test/preview endpoint or not
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr/  r(  r'  r~  r  F)
r  r   r  r  r  rl  'v3PrivatePostBrokerageOrdersEditPreviewr   v3PrivatePostBrokerageOrdersEditr  )ra  r0   r  r  r,  r  r'  rp  r   r  r~  rr  s               rc  
edit_ordercoinbase.edit_order  s       !!!V$
 "66vFGFO#66vEGG""69feDYYv	6':;F!II$++V]JfggH!BB4;;wC_``H 113 	" h`s4   C7C1BC72C33(C7C5C73C75C7c                   #    U R                  5       I Sh  vN   SnUb  U R                  U5      nSU0nU R                  U R                  XS5      5      I Sh  vN nU R	                  US0 5      nU R                  Xt5      $  Nj N*7f)a  
fetches information on an order made by the user

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_gethistoricalorder

:param str id: the order id
:param str symbol: unified market symbol that the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr/  r2  )r  r   ,v3PrivateGetBrokerageOrdersHistoricalOrderIdr  rm  r  )ra  r0   r  rp  r   r  rr  r2  s           rc  fetch_ordercoinbase.fetch_order  s      !!![[(F
 JJ4;;W^KghhP x"5..a 	" is"   BBABB)BBr  c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ SnUb  U R                  U5      n0 nUb  US   US'   Ub  X7S	'   Ub  U R	                  U5      US
'   U R                  US/5      nUb'  U R                  US/5      nU R	                  U5      US'   U R                  U R                  Xt5      5      I Sh  vN n	U R                  U	S/ 5      n
U R                  U
S5      nU R                  U	S5      nUb  US:w  a  XS'   XS'   U R                  XX#5      $  GNB GN Nd7f)a=  
fetches information on multiple orders made by the user

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_gethistoricalorders

:param str symbol: unified market symbol that the orders were made in
:param int [since]: the earliest time in ms to fetch orders
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch trades for
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NFr   r}  r  r  r0   r#  rL  
start_dateuntilend_dater  r   r  )r  r  r  r   r  safe_integer_nrl  *v3PrivateGetBrokerageOrdersHistoricalBatchr  r  rm  rk  r  )ra  r  r  rL  rp  r}  r   r  r  rr  r  firstr  s                rc  fetch_orderscoinbase.fetch_ordersN  s     !!!88PZ[99-X]goqy{  BF  G  G  G[[(F$*4LGL!$G$(LL$7GL!##FWI6YYvy1F"&,,u"5GJHHU\IeffV (B7vq)!!(H5Vr\$(O1I  >>I 	" G g5   E E<E EB%E 9E:AE E E c                 L  #    U R                  5       I S h  vN   S nUb  U R                  U5      nSU0nUb  US   US'   Uc  SnXGS'   Ub  U R                  U5      US'   U R                  US/5      nUb'  U R	                  US/5      nU R                  U5      US'   U R                  U R                  Xu5      5      I S h  vN n	U R                  U	S	/ 5      n
U R                  U
S
5      nU R                  U	S5      nUb  US:w  a  XS'   XS
'   U R                  XX45      $  GN	 Na7f)Norder_statusr0   r#  r  rL  r  r  r  r  r   r  r  )r  r   r  r  rl  r  r  r  rm  rk  r  )ra  r  r  r  rL  rp  r   r  r  rr  r  r  r  s                rc  fetch_orders_by_statuscoinbase.fetch_orders_by_status  sI    !!![[(FF
 $*4LGL!=E $(LL$7GL!##FWI6YYvy1F"&,,u"5GJHHU\IeffV (B7vq)!!(H5Vr\$(O1I  >>G 	"$ gs#   D$DB)D$ D"AD$"D$c                    #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ U R                  SXX45      I Sh  vN $  N\ N! N7f)a;  
fetches information on all currently open orders

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_gethistoricalorders

:param str symbol: unified market symbol of the orders
:param int [since]: timestamp in ms of the earliest order, default is None
:param int [limit]: the maximum number of open order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:param int [params.until]: the latest time in ms to fetch trades for
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NFr   r}  r  r  r  r  r  r  r  ra  r  r  rL  rp  r}  s         rc  fetch_open_orderscoinbase.fetch_open_orders  s      !!!88ART^_99:KV\aksu}  @D  FI  J  J  J00VVV 	" JV3   A9A3<A9A5A9.A7/A95A97A9c                    #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ U R                  SXX45      I Sh  vN $  N\ N! N7f)aK  
fetches information on multiple closed orders made by the user

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_gethistoricalorders

:param str symbol: unified market symbol of the orders
:param int [since]: timestamp in ms of the earliest order, default is None
:param int [limit]: the maximum number of closed order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:param int [params.until]: the latest time in ms to fetch trades for
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NFri   r}  r  r  r  r  r  s         rc  fetch_closed_orderscoinbase.fetch_closed_orders  s      !!!88ATV`a99:Mv^cmuw  BF  HK  L  L  L006%XXX 	" LXr  c                 D   #    U R                  SXX45      I Sh  vN $  N7f)a  
fetches information on multiple canceled orders made by the user

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_gethistoricalorders

:param str symbol: unified market symbol of the orders
:param int [since]: timestamp in ms of the earliest order, default is None
:param int [limit]: the maximum number of canceled 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>`
r  N)r  )ra  r  r  rL  rp  s        rc  fetch_canceled_orderscoinbase.fetch_canceled_orders  s"      00fU[[[[s     r  	timeframec           
      d  #    U R                  5       I Sh  vN   SnUc  UO
[        XF5      nSnU R                  USSS5      u  puU(       a  U R                  SXXBXVS-
  5      I Sh  vN $ U R	                  U5      nUS   U R                  U R                  X"5      S.n	U R                  US	S
/5      n
U R                  US	/5      nU R                  U5      nXK-  nSnUb$  U R                  U R                  US-  5      5      nO9[        U R                  5       5      n[        R                  " U[        U5      5      nXS'   U
b'  U R                  U R                  U
S-  5      5      U	S
'   O#[        R                   " U[        U5      5      U	S
'   SnSnU R                  USSS5      u  nnU(       a)  U R#                  U R%                  X5      5      I Sh  vN nO(U R'                  U R%                  X5      5      I Sh  vN nU R)                  US/ 5      nU R+                  UXX45      $  GN GN NY N27f)a%  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpubliccandles

:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param int [since]: timestamp in ms of the earliest candle to fetch
:param int [limit]: the maximum amount of candles to fetch, not used by coinbase
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch trades for
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:param boolean [params.usePrivate]: default False, when True will use the private endpoint to fetch the candles
:returns int[][]: A list of candles ordered, open, high, low, close, volume
NrR  Fr   r}  r   r0   )r#  granularityr  endr  startr  candles)r  rY  r  "fetch_paginated_call_deterministicr   rk  r  r  rl  parse_timeframer  parse_to_intstrsecondsr*   
string_subr   -v3PrivateGetBrokerageProductsProductIdCandlesr  2v3PublicGetBrokerageMarketProductsProductIdCandlesr  parse_ohlcvs)ra  r  r  r  rL  rp  maxLimitr}  r   r  r  durationrequestedDurationsinceStringr  rr  r  r  s                     rc  fetch_ohlcvcoinbase.fetch_ohlcv   s@      !!!"]U1E88z[`a@@v^cpv  DE  yE  F  F  FV$ ,++DOOYR
 ##FWe,<=6G9-''	2!,//0A0A%$,0OPKdlln%C!,,S#6G2HIK&!2243D3DUT\3RSGEN %//SAR=STGEN
!::6<Q]_de
F!OOPTP[P[\cPlmmH!TTUYU`U`ahUqrrH ..9b9  &UJJe 	" F4 nrsG   H0H&AH0&H)'E+H0H,(H0;H.<+H0)H0,H0.H0c           	          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      /$ )Nr  r
  r  r  r  volume)safe_timestampr  )ra  ohlcvr   s      rc  parse_ohlcvcoinbase.parse_ohlcvd  sn     w/UF+UF+UE*UG,UH-
 	
re  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb&  U R                  U R                  US-  5      5      US'   Ub  [	        US5      US'   SnU R                  USS5      u  ptUb'  U R                  U R                  US-  5      5      US	'   OUb  [        U R                  S
-   5      eSnSn	U R                  USSS5      u  pU	(       a)  U R                  U R                  Xd5      5      I Sh  vN nO(U R                  U R                  Xd5      5      I Sh  vN nU R                  US/ 5      n
U R                  XX#5      $  GNK NU N.7f)ag  
get the list of most recent trades for a particular symbol

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpublicmarkettrades

:param str symbol: unified market symbol of the trades
:param int [since]: not used by coinbase fetchTrades
:param int [limit]: the maximum number of trade structures to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.usePrivate]: default False, when True will use the private endpoint to fetch the trades
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
Nr#  r0   r  r  rL  r   r  r  zI fetchTrades() requires a `until` parameter when you use `since` argumentFr  r  )r  r   r  r  rY  r  r!   r0   r  r  r  r  r  )ra  r  r  rL  rp  r   r  r  rr  r  r  s              rc  fetch_tradescoinbase.fetch_tradesz  st     !!!V$&,
 #44T5F5Fut|5TUGG"5$/GG55fmWU!2243D3DUT\3RSGEN#DGG.y$yzz
!::6=R^`ef
!NNt{{[bOkllH!SSTXT_T_`gTpqqH" (B7  >>O 	"& mqs4   E(E!C7E(E$(E(7E&8*E($E(&E(c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ SnUb  U R                  U5      n0 nUb  US   US'   Ub  X7S	'   Ub  U R	                  U5      US
'   U R                  US/5      nUb'  U R                  US/5      nU R	                  U5      US'   U R                  U R                  Xt5      5      I Sh  vN n	U R                  U	S/ 5      n
U R                  U
S5      nU R                  U	S5      nUb  US:w  a  XS'   XS'   U R                  XX#5      $  GNB GN Nd7f)a  
fetch all trades made by the user

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getfills

:param str symbol: unified market symbol of the trades
:param int [since]: timestamp in ms of the earliest order, default is None
:param int [limit]: the maximum number of trade structures to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch trades for
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
NFr   r}  r  r  r0   r#  rL  start_sequence_timestampr  end_sequence_timestampfillsr   r  )r  r  r  r   r  r  rl  *v3PrivateGetBrokerageOrdersHistoricalFillsr  r  rm  rk  r  )ra  r  r  rL  rp  r}  r   r  r  rr  r  r  r  s                rc  fetch_my_tradescoinbase.fetch_my_trades  s     !!!88R\]99/6Z_iqs{  ~B  DG  H  H  H[[(F$*4LGL!$G26,,u2EG./##FWI6YYvy1F04U0CG,-HHU\Ieff0 '26vq)!!(H5Vr\$(O1I  >>c 	" H gr  c           	         #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X%S'   SnSnU R                  USSS5      u  psU(       a)  U R                  U R	                  XS5      5      I Sh  vN nO(U R                  U R	                  XS5      5      I Sh  vN nU R                  US0 5      nU R                  US	5      n	U R                  U	5      n
U R                  XU
S
SSS5      $  N N{ NT7f)a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpublicproductbook

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.usePrivate]: default False, when True will use the private endpoint to fetch the order book
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nr#  r0   rL  Fr   r  	pricebookr   r  r  r'  r(  )
r  r   r   v3PrivateGetBrokerageProductBookr  %v3PublicGetBrokerageMarketProductBookrm  rk  r  parse_order_book)ra  r  rL  rp  r   r  rr  r  rh  r   r  s              rc  fetch_order_bookcoinbase.fetch_order_book  s     !!!V$&,
 $G
!::6CSUachi
!BB4;;wC_``H!GGT[HdeeH* ~~hR8f-NN4(	$$T9ffgW]^^K 	" aes5   C>C8A'C>>C:?(C>'C<(AC>:C><C>c                 .  #    U R                  5       I Sh  vN   U R                  U5      n0 nUb  U R                  U5      US'   U R                  U R	                  X25      5      I Sh  vN nU R                  US/ 5      nU R                  XQ5      $  Nz N*7f)a  
fetches the bid and ask price and volume for multiple markets

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getbestbidask

:param str[] [symbols]: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr  
pricebooks)r  r  r  v3PrivateGetBrokerageBestBidAskr  r  parse_tickers)ra  r  rp  r  rr  tickerss         rc  fetch_bids_askscoinbase.fetch_bids_asks$  s      !!!%%g.%)__W%=GM"==dkk'>Z[[. ..<<!!'33; 	"
 \s"   BBAB(B))BBr  r  c                 d  #    U R                  XE5      u  pEU R                  U5        U R                  5       I Sh  vN   U R                  U5      nU R	                  USS5      nU R                  USS/5      nUcR  Uc  [        U R                  S-   5      eU R                  X5      I Sh  vN nUc  [        U R                  S-   U-   5      eUSUUUS   S.nUb  XHS	'   U R                  U R                  X5      5      I Sh  vN n	U R                  U	S
0 5      n
U R                  X5      $  N N N,7f)a  
make a withdrawal

https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-transactions#send-money

:param str code: unified currency code
:param float amount: the amount to withdraw
:param str address: the address to withdraw to
:param str [tag]: an optional tag for the withdrawal
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr  r  zV withdraw() requires an account_id(or accountId) parameter OR a currency code argumentz* withdraw() could not find account id for r  r0   )r  r  r   r  r  r  rh  )handle_withdraw_tag_and_paramscheck_addressr  r  r  rl  r!   r0   rX  r   *v2PrivatePostAccountsAccountIdTransactionsr  rm  r  )ra  r  r  r  r  rp  r  r  r  rr  rh  s              rc  r   coinbase.withdrawM  sO     99#F7#!!!==&&&v|[I	6L+#>?|'  3K  )K  L  L"224@@I #DGG.Z$Z]a$abb# 
 ?),%&HHU\Ieffj ~~h3%%d55S 	" A gs5   8D0D*A.D0)D,*AD0D.)D0,D0.D0c                 l  #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  US   SU5      I Sh  vN u  pBU R                  U R	                  XB5      5      I Sh  vN nU R                  US/ 5      nU R                  USS5      nU R                  US5      $  N Nh N@7f)as  
fetch the deposit address for a currency associated with self account

https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postcoinbaseaccountaddresses

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
Nr  rh  Fr  )r  r  r  &v2PrivateGetAccountsAccountIdAddressesr  r  parse_deposit_addressesre  )ra  r  rp  r  r  rr  rh  addressStructuress           rc  "fetch_deposit_addresses_by_network+coinbase.fetch_deposit_addresses_by_network  s      !!!==& $ O OPXY_P`bfhn ooDDT[[QXEabbp ~~h3 88tUK}}.	::} 	" pbs3   B4B.0B4B0)B41B22=B40B42B4c                    U R                  US5      nU R                  U5        U R                  US5      nU R                  S U5      nU R                  US5      nS nUb#  UR                  S5      nU R                  US5      nU R	                  US5      n	UU R                  Xr5      U R                  XE5      UU R                  U	S5      S.$ )	Nr  r  address_labelr  r   address_infor  )r  r  r  r  r  )rk  r3  r  r  rm  r  )
ra  depositAddressr  r  r  r  addressLabelr  splitAddressLabeladdressInfos
             rc  parse_deposit_addresscoinbase.parse_deposit_address  s    X "">9=7#$$^Y?	&&tX6''H
# , 2 23 7))*;Q?Jnn^^D"//
E..y?##K1BC
 	
re  c                 "  #    U R                  5       I Sh  vN   U R                  USS5      nU R                  USS/5      nUcR  Uc  [        U R                  S-   5      eU R                  X5      I Sh  vN nUc  [        U R                  S-   U-   5      eUU R                  U5      UR                  5       USS.nU R                  U R                  Xd5      5      I Sh  vN nU R                  USS	0 5      nU R                  U5      $  N N N-7f)
a  
make a deposit

https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-deposits#deposit-funds

:param str code: unified currency code
:param float amount: the amount to deposit
:param str id: the payment method id to be used for the deposit, can be retrieved from v2PrivateGetPaymentMethods
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.accountId]: the id of the account to deposit into
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr  r  zU deposit() requires an account_id(or accountId) parameter OR a currency code argumentz) deposit() could not find account id for T)r  r  r  payment_methodcommitrh  transfer)r  r  rl  r!   r0   rX  r   r  r  &v2PrivatePostAccountsAccountIdDepositsr  safe_dict_2r  )	ra  r  r  r0   rp  r  r  rr  rh  s	            rc  r]   coinbase.deposit/  s$     !!!&&v|[I	6L+#>?|'  3J  )J  K  K"224@@I #DGG.Y$Y\`$`aa#++F3

 
 DDT[[QXEabbL &*bA%%d++o 	" A cs5   DD	AD4D5A*DD *DDDc                   #    U R                  5       I Sh  vN   U R                  USS5      nU R                  USS/5      nUcR  Uc  [        U R                  S-   5      eU R                  X#5      I Sh  vN nUc  [        U R                  S-   U-   5      eUUS.nU R                  U R                  XS5      5      I Sh  vN nU R                  USS0 5      nU R                  U5      $  N Nv N-7f)	a  
fetch information on a deposit, fiat only, for crypto transactions use fetchLedger

https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-deposits#show-deposit

:param str id: deposit id
:param str [code]: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.accountId]: the id of the account that the funds were deposited into
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr  r  zZ fetchDeposit() requires an account_id(or accountId) parameter OR a currency code argumentz. fetchDeposit() could not find account id for )r  
deposit_idrh  rH  )r  r  rl  r!   r0   rX  r   .v2PrivateGetAccountsAccountIdDepositsDepositIdr  rJ  r  )ra  r0   r  rp  r  r  rr  rh  s           rc  fetch_depositcoinbase.fetch_depositu  s
     !!!&&v|[I	6L+#>?|'  3O  )O  P  P"224@@I #DGG.^$^ae$eff#
 LLT[[Y`MijjL &*bA%%d++i 	" A ks5   C/C)AC/4C+5A
C/?C- *C/+C/-C/c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US/ 5      nU R                  U5      $  NA N*7f)aX  
fetch the deposit id for a fiat currency associated with self account

https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpaymentmethods

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an array of `deposit id structures <https://docs.ccxt.com/#/?id=deposit-id-structure>`
Npayment_methods)r  #v3PrivateGetBrokeragePaymentMethodsr  parse_deposit_method_ids)ra  rp  rr  r  s       rc  fetch_deposit_method_ids!coinbase.fetch_deposit_method_ids  sZ      !!!AA&II( *;R@,,V44- 	"Is   AAAA)AAc                    #    U R                  5       I Sh  vN   SU0nU R                  U R                  X25      5      I Sh  vN nU R                  US0 5      nU R	                  U5      $  NT N*7f)ay  
fetch the deposit id for a fiat currency associated with self account

https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_getpaymentmethod

:param str id: the deposit payment method id
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `deposit id structure <https://docs.ccxt.com/#/?id=deposit-id-structure>`
Npayment_method_idrF  )r  2v3PrivateGetBrokeragePaymentMethodsPaymentMethodIdr  rm  parse_deposit_method_id)ra  r0   rp  r  rr  r  s         rc  fetch_deposit_method_id coinbase.fetch_deposit_method_id  sx      !!!
 PPQUQ\Q\]dQmnn$ *:B?++F33/ 	" os!   A/A++A/A-)A/-A/c                     / n[        S[        U5      5       H7  nU R                  U R                  X   5      U5      nUR	                  U5        M9     U$ )Nr   )r  r  r  rZ  r  )ra  r  rp  r  r  r0   s         rc  rT  !coinbase.parse_deposit_method_ids  sL    q#c(#AT99#&A6JBMM" $ re  c                     UU R                  US5      U R                  US5      U R                  US5      U R                  US5      S.$ )Nr0   r  verifiedr1   )r  r0   r  r`  r  )rk  r  )ra  	depositIds     rc  rZ   coinbase.parse_deposit_method_id  sM    ""9d3((J?y*=##Iv6
 	
re  fromCodetoCodec                   #    U R                  5       I Sh  vN   UUU R                  U5      S.nU R                  U R                  XT5      5      I Sh  vN nU R	                  US0 5      nU R                  U5      $  Ne N*7f)a*  
fetch a quote for converting from one currency to another

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_createconvertquote

:param str fromCode: the currency that you want to sell and convert from
:param str toCode: the currency that you want to buy and convert into
:param float [amount]: how much you want to trade in units of the from currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:param dict [params.trade_incentive_metadata]: an object to fill in user incentive data
:param str [params.trade_incentive_metadata.user_incentive_id]: the id of the incentive
:param str [params.trade_incentive_metadata.code_val]: the code value of the incentive
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
N)from_account
to_accountr  r  )r  r  "v3PrivatePostBrokerageConvertQuoter  rm  parse_conversion)ra  rc  rd  r  rp  r  rr  rh  s           rc  fetch_convert_quotecoinbase.fetch_convert_quote  s      !!!$ ++F3

 @@WA]^^~~h4$$T** 	" _s!   B A<<B A>)B >B c                    #    U R                  5       I Sh  vN   UUUS.nU R                  U R                  Xe5      5      I Sh  vN nU R                  US0 5      nU R	                  U5      $  NV N*7f)aG  
convert from one currency to another

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_commitconverttrade

:param str id: the id of the trade that you want to make
:param str fromCode: the currency that you want to sell and convert from
:param str toCode: the currency that you want to buy and convert into
:param float [amount]: how much you want to trade in units of the from currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
Nr.  rf  rg  r  )r  )v3PrivatePostBrokerageConvertTradeTradeIdr  rm  ri  )	ra  r0   rc  rd  r  rp  r  rr  rh  s	            rc  create_convert_tradecoinbase.create_convert_trade$  sv      !!!$ 

 GGT[Hdee~~h4$$T** 	" fs!   A1A--A1A/)A1/A1c                   #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eU R                  US5      nUc  [        U R                  S-   5      eU R	                  US5      nUUUS.nU R                  U R                  XS5      5      I Sh  vN nU R                  US0 5      nU R                  U5      $  N N*7f)a  
fetch the data for a conversion trade

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getconverttrade

:param str id: the id of the trade that you want to commit
:param str code: the unified currency code that was converted from
:param dict [params]: extra parameters specific to the exchange API endpoint
:param strng params['toCode']: the unified currency code that was converted into
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
Nz- fetchConvertTrade() requires a code argumentrd  z0 fetchConvertTrade() requires a toCode parameterrm  r  )	r  r!   r0   rk  rl  (v3PrivateGetBrokerageConvertTradeTradeIdr  rm  ri  )ra  r0   r  rp  rd  r  rr  rh  s           rc  fetch_convert_tradecoinbase.fetch_convert_trade;  s      !!!<#DGG.]$]^^!!&(3>#DGG.`$`aa68,  

 FFt{{SZGcdd~~h4$$T** 	" es"   CCBCC	)C	C
conversionfromCurrency
toCurrencyc                 t   U R                  US5      nU R                  XB5      nU R                  US5      nU R                  Xc5      nU R                  US5      nU R                  US5      n	U R                  U	S5      n
US S U R                  US5      UU R                  US5      US S U R                  U
S5      S.
$ )	Nsource_currencytarget_currencyuser_entered_amount	total_feer  r0   r  )
r  r  r  r0   rv  
fromAmountrw  toAmountr'  r  )rk  r  rm  r  )ra  ru  rv  rw  fromCoinrc  r   rd  fromAmountStructurefeeStructurefeeAmountStructures              rc  ri  coinbase.parse_conversionW  s    ##J0AB**8Bj*;<((8"nnZ9NO~~j+>!^^L(C"":t4$**+>H ##$6@
 	
re  c                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  USS5      nU R                  US5      nSUS   0nUc  [	        U R
                  S-   5      eXVS'   U R                  U R                  Xc5      5      I Sh  vN nU R                  US0 5      nU R                  U5      $  N N*7f)ab  
       *futures only* closes open positions for a market

       https://docs.cdp.coinbase.com/coinbase-app/trade/reference/retailbrokerageapi_closeposition

       :param str symbol: Unified CCXT market symbol
       :param str [side]: not used by coinbase
       :param dict [params]: extra parameters specific to the coinbase api endpoint
@param {str}  params.clientOrderId *mandatory* the client order id of the position to close
       :param float [params.size]: the size of the position to close, optional
       :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
       Nrc  r}  r#  r0   z3 closePosition() requires a clientOrderId parameterr  )
r  r   r  rl  r!   r0   )v3PrivatePostBrokerageOrdersClosePositionr  rm  r  )	ra  r  r,  rp  r   r}  r  rr  r2  s	            rc  close_positioncoinbase.close_positionl  s      !!!V$**63DoV6?3&,
  #DGG.c$cdd%2!"GGT[Hdeex);R@&& 	" fs"   CCBCC)CCc                   #    U R                  5       I Sh  vN   U R                  U5      nSnUb  U R                  US   5      nSnU R                  SX25      u  pBSnUS:X  a  U R	                  U5      I Sh  vN nO^SnU R                  USS5      u  pbUc  [        U R                  S-   5      eSU0nU R                  U R                  Xr5      5      I Sh  vN nU R                  US/ 5      nU R                  X5      $  N N N,7f)	a  
fetch all open positions

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getfcmpositions
https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getintxpositions

:param str[] [symbols]: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.portfolio]: the portfolio UUID to fetch positions for
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nr   r   rB   r  z fetchPositions() requires a "portfolio" value in params(eg: dbcb91e7-2bc9-515), or set.options["portfolio"]. You can get a list of portfolios with fetchPortfolios()portfolio_uuid	positions)r  r  r   r  !v3PrivateGetBrokerageCfmPositionsr  r!   r0   /v3PrivateGetBrokerageIntxPositionsPortfolioUuidr  r  parse_positions)	ra  r  rp  r   r  rr  r  r  r  s	            rc  fetch_positionscoinbase.fetch_positions  s'     !!!%%g.[[,F99:JF[8!CCFKKHI $ = =fFVXc dI '  3Z  )Z  [  [ )G "QQRVR]R]^eRnooHNN8["=	##I77) 	" L ps5   DC?A D7D8ADD)DDDc                 B  #    U R                  5       I Sh  vN   U R                  U5      nSnUS   (       aZ  U R                  US5      nUc  [        U R                  S-   5      eSU0nU R                  U R                  Xb5      5      I Sh  vN nObSnU R                  USS5      u  prUc  [        U R                  S-   5      eUS   US	.nU R                  U R                  X5      5      I Sh  vN nU R                  US
0 5      n	U R                  X5      $  GN N N-7f)a  
fetch data on a single open contract trade position

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getintxposition
https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getfcmposition

:param str symbol: unified market symbol of the market the position is held in, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.product_id]: *futures only* the product id of the position to fetch, required for futures markets only
:param str [params.portfolio]: *perpetual/swaps only* the portfolio UUID to fetch the position for, required for perpetual/swaps markets only
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
NrB   r#  z2 fetchPosition() requires a "product_id" in paramsr   r  z fetchPosition() requires a "portfolio" value in params(eg: dbcb91e7-2bc9-515), or set.options["portfolio"]. You can get a list of portfolios with fetchPortfolios()r0   )r  r  position)r  r   rk  r!   r0   *v3PrivateGetBrokerageCfmPositionsProductIdr  r  5v3PrivateGetBrokerageIntxPositionsPortfolioUuidSymbolrm  parse_position)
ra  r  rp  r   rr  	productIdfutureRequestr  r  r  s
             rc  fetch_positioncoinbase.fetch_position  s8     !!!V$(((>I '2f(fggi#M "LLT[[YfMoppHI $ = =fFVXc dI '  3Y  )Y  Z  Z ,"+G "WWX\XcXcdkXtuuH>>(J;""844- 	" q vs5   DDA5DDA"D/D0)DDDr  c                 N   U R                  USS5      nU R                  X25      nU R                  US5      nS nUb
  US:X  a  SOSnU R                  US0 5      nU R                  US5      nUS	:X  a  S
OSnU R                  US0 5      n	U R                  US0 5      n
U R                  U
S5      nU R                  US0 5      nU R                  US0 5      nU R	                  0 SU_SU R                  US5      _SU R                  X25      _SU R                  US5      _SU_SU_SU R                  US5      _SU R                  U	S5      _SS _SS _SU R                  US5      _SUS   _SS _SS _S U_S!S _S"S _S S S S U R                  US#5      S S U R                  US$5      S S S S%.E5      $ )&Nr  r  ry  MARGIN_TYPE_CROSSrz  rw  position_notionalposition_sidePOSITION_SIDE_LONGlongshortunrealized_pnlliquidation_pricer  r	  portfolio_summaryr  r0   r#  notionalr=  liquidationPrice
entryPriceunrealizedPnlrealizedPnlr   	contractsnet_sizer]  	markPrice	lastPricer,  rE  r  
collateralrG  )r  lastUpdateTimestampmaintenanceMarginmaintenanceMarginPercentager  initialMargininitialMarginPercentagerG  marginRatiorA  rB  )rk  r4  rm  r  safe_positionr  )ra  r  r   r=  	rawMarginr=  notionalObjectpositionSider,  unrealizedPNLObjectliquidationPriceObjectr  
vwapObjectsummaryObjects                 rc  r  coinbase.parse_position  s_   t ##Hh;!!(3$$X}=	
 %.2E%EJJ2ErJ''/B&*>>vW"nnX7GL!%:Mr!R++,BGL^^Hfb9
x1DbI!! #
H#
$""8\:#
 d&&x8#
 ((A	#

 *#
  0#
 $**:w?#
 T--.A7K#
 4#
 $#
 ))(J?#
 F>2#
 #
 #
 D#
  d!#
" ##
$ #'!%+/**=,G!'+((:>!#9#
  	re  c                 L  #    U R                  5       I Sh  vN   SnU R                  SSU5      u  p!US:H  nU(       a  SOSnSU0nU R                  U R                  XQ5      5      I Sh  vN nU R	                  US0 5      nU R                  US5      nU R                  US	5      n	0 n
[        S
[        U R                  5      5       HS  nU R                  U   nU R                  U5      nU(       a
  US   (       d  U(       a  M=  US   (       a  MI  UUUU	SS.X'   MU     U
$  GN	 N7f)a~  

https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_gettransactionsummary/

fetch the trading fees for multiple markets
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: 'spot' or 'swap'
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
Nr   r?   r  rp  ro  rs  r  r  r   T)r  r  r   r   r   )
r  r  rz  r  rm  r  r  r  r  r   )ra  rp  r  isSpotproductTyper  rr  rh  	taker_fee
marker_feer  r  r  r   s                 rc  fetch_trading_feescoinbase.fetch_trading_feesU  s'     !!!99:LdTZ[&. &fHK
 EEdkkRYFbcc0 ~~h
B7$$T+;<	%%d,<=
q#dll+,A\\!_F[[(F6&>66&..$$&'"&"	 - _ 	" ds/   D$DAD$)D"*BD$D$D$"D$portfolioUuidc                    #    U R                  5       I Sh  vN   SU0nU R                  U R                  X25      5      I Sh  vN nU R                  U5      nU$  NC N7f)ax  
Fetch details for a specific portfolio by UUID

https://docs.cloud.coinbase.com/advanced-trade/reference/retailbrokerageapi_getportfolios

:param str portfolioUuid: The unique identifier of the portfolio to fetch
:param Dict [params]: Extra parameters specific to the exchange API endpoint
:returns any[]: An account structure <https://docs.ccxt.com/#/?id=account-structure>
Nr  )r  ,v3PrivateGetBrokeragePortfoliosPortfolioUuidr  parse_portfolio_details)ra  r  rp  r  rr  r  s         rc  fetch_portfolio_details coinbase.fetch_portfolio_details  sd      !!!m
 JJ4;;W^Kghh--h7 	" is!   AA+AAAAportfolioDatac                    US   nU R                  US0 5      nU R                  USS5      nU R                  USS5      nU R                  US/ 5      n/ n[        S[	        U5      5       GHv  nXh   n	U R                  U	S	S5      n
U R                  U	S
S5      nU R                  U5      nU R                  U	SS5      nU R                  U5      nX-
  nU R                  U	S0 5      nU R                  USS5      nU R                  U	S0 5      nU R                  USS5      n0 SU
_SU_SS_SU_SU_SU R                  U	SS5      _SU_SU R                  U R                  U	SS5      5      _S
U R                  U R                  U	S
S5      5      _SU R                  U R                  U	SS5      5      _SU R                  U R                  U	SS5      5      _SU R                  U R                  U	SS5      5      _SU R                  U R                  U	SS5      5      _SU R                  U5      _SU R                  USS5      _SU R                  U	SS5      _SU R                  U5      _U R                  USS5      U R                  U	SS5      U R                  U R                  U	S S5      5      U R                  U	S!S5      U R                  U	S"S5      S#.EnUR                  U5        GMy     U$ )$N	breakdownr  r1   Unknownr  r  spot_positionsr   assetavailable_to_trade_fiatr   total_balance_fiat
cost_basisr  average_entry_pricer  r  hold_amountwallet_namer  account_uuidtotal_balance_cryptoavailable_to_trade_cryptoavailable_to_transfer_fiatavailable_to_transfer_crypto
allocationcost_basis_currencyr8  is_cashF
asset_uuidr  asset_coloraccount_type)average_entry_price_currencyr  r  r  r  )rm  rk  r  r  r  r`  r  r  )ra  r  r  portfolioInfoportfolioNamer  spotPositionsparsedPositionsr  r  currencyCodeavailableBalanceStravailableBalancetotalBalanceFiatStrtotalBalanceFiat
holdAmountcostBasisDictcostBasisStraverageEntryPriceDictaverageEntryPriceStrpositionDatas                        rc  r   coinbase.parse_portfolio_details  s   !+.	y+rB((	J((Cy2BBGq#m,-A*-H++HgyIL"&"2"28=VX["\#001DE"&"2"28=QSV"W#001DE)<J NN8\2FM++M7CHL$(NN8=RTV$W!#'#3#34I7TW#X "L"#%5" " }	"
 m"  0 0>2 N" %&6" '(9(9$:J:J8Ukmp:q(r" *4+<+<T=M=MhXqsv=w+x" ,T->->t?O?OPXZuwz?{-|" -d.?.?@P@PQY[wy|@}.~" /0A0A$BRBRS[]xz}B~0" d//0@0@<Y\0]^" d//=" &t'7'7zSX'Y"  4>>(IuE!"" &t'8'89M'N#"$ 150@0@AVXbdi0j"..xrJ"&"3"3D4D4DXO_ad4e"f#//-L $ 0 0>2 N-"L0 ""<0I .J re  r  rg  urlc           
      >   S nUb4  US-   UR                  SS5      -   nUR                  S5      nUS:  a  USU nU R                  S5      nU(       a  SOSnU(       a  S	OS
n	U/U	UUS-   U R                  US.n
Ub  U(       d  XZS'   OU/U
S'   U(       aP  U R	                  U R
                  5      nU R                  USS5      nU R                  XSSU R                  USS.5      $ U R                  XR                  U R
                  5      SSU R                  USS.5      $ )Nr  zhttps://r  ?r      cdp_serviceretail_rest_api_proxycdpzcoinbase-cloudx   )audissnbfexpsubiaturiuris    sha256FEdDSA)kidnoncealgES256)	replacefindrandom_bytesr   base64_to_binaryr   array_slicejwtencode)ra  r  rg  r  useEddsar  quesPosr  r  r  r  	byteArrayseeds                rc  create_auth_tokencoinbase.create_auth_token  s:    ?3,Z!<<ChhsmG {!Gn!!"%'m-De%55S=;;
 ?!$#&%--dkk:I##Iq"5D88G8UDKKZ_ho<pqq 88G[[%=xX\XcXcns  }D  QE  F  Fre  c                 B    U R                  5       U R                  S   -
  $ )Nr0  )r  rZ  )ra  s    rc  r  coinbase.nonce  s       "T\\2B%CCCre  GETc                 F   US   nUS   S:H  nUS:H  n	U	(       a  SOSn
SU
-   S-   U R                  X5      -   nU R                  X@R                  U5      5      nUnUS:X  a  U(       a  US	U R                  U5      -   -  nU R                  S
   S   U-   nU(       Ga  U R                  U R                  S5      nS nUb  UnGO8U R                  (       a'  U R                  S5      (       d  SU R                  -   nGO U R                  5         U R                  5       nSnUS:w  a  U(       a  U R                  U5      nUnO%U	(       d  U(       a  US	U R                  U5      -   -  nU R                  R                  S5      S:  =(       d    U R                  R                  S5      n[!        U R                  5      S:H  =(       d?    U R#                  U R$                  SS5      =(       d    U R                  R'                  S5      nU(       d  U(       aX  U(       a8  U R                  R                  S5      (       a  [)        U R*                  S-   5      eU R-                  UX>U5      nSU-   nOU R/                  5       nU R1                  US-  5      n[3        U5      nUU-   U-   U-   nU R5                  U R7                  U5      U R7                  U R                  5      [8        R:                  5      nU R                  UUSS.nUb#  USS.nUS:w  a  U(       a  U R                  U5      nXXeS.$ )Nr   r   r   r   zapi/v3r9   r%  r  r  r   r   AuthorizationFzBearer r  zorganizations/z
-----BEGINX   v2CloudAPiKey=zV apiKey should contain the name(eg: organizations/3b910e93....) and not the public keyr  zapplication/json)zCB-ACCESS-KEYzCB-ACCESS-SIGNzCB-ACCESS-TIMESTAMPContent-Type)r  r  )r  rg  bodyr<   )implode_paramsrl  extract_paramsurlencode_with_array_repeatr   rk  r<   tokenry  r  json	urlencoder   r	  r   
startswithr  r  rZ  endswithr!   r0   r  r  r  r  hmacr  hashlibr  )ra  rS  r   rg  rp  r<   r  r8   signedr)  pathPartfullPathr  	savedPathr  authorizationauthorizationStringr  payloadisCloudAPiKeyisV2CloudAPiKeyr"  r  r  timestampStringauth	signatures                              rc  signcoinbase.sign  s   a&Q9$$ $84>C'$*=*=d*KK		&"5"5d";<	U?C$"B"B5"IIIiiv&1 ,,T\\?KM"&(&3#D$C$CE$J$J&/$**&<#//1,,.U?#yy/"& #sT^^E-B'BBG
 "&!1!12B!Cq!H sdkkNdNdeqNr"%dkk"2b"8  #NDNN4<<Yhjo<p  #Ntxtt  uI  uI  JM  uN O$)?)?)M)M/  ;S  1S  T  T& !227FYE*3e*;' JJLE $ 1 1%$, ?I&))nO*V3i?'ID $		$++d*;T[[=UW^WeWe fI)-*3/>(:	G #.%8$6 U?#yy/dOOre  reasonr<   r  c
                    Uc  g U R                   S-   U-   n
U R                  US5      nUb\  U R                  USS5      nU R                  U R                  S   X5        U R                  U R                  S   X5        [        U
5      eU R                  US5      nUb\  U R                  USS5      nU R                  U R                  S   X5        U R                  U R                  S   X5        [        U
5      eU R                  US5      nUb  [        U[        5      (       a  [        U5      nUS	:  av  U R                  US	   S
5      nU R                  US	   S5      nUbI  U R                  U R                  S   X5        U R                  U R                  S   X5        [        U
5      eU R                  S   nSU;  a1  U(       d*  [        U R                   S-   U R                  U5      -   5      eg )Nr  r  error_descriptionr	  r
  r  preview_failure_reasonerrorsr   r0   r  r.  rh  z$ failed due to a malformed response )r0   rk  r  r  r   r  r   rm  r  
isinstancerf  r  rZ  r#  )ra  r  r7  r  rg  r<   r  rr  requestHeadersrequestBodyfeedback	errorCoder  r  errorMessageInnerr;  	numErrorsadvancedTrades                     rc  handle_errorscoinbase.handle_errorsK  s   77S=4'D $$Xw7	 --h8KWUL001I9_001I<b))x1AB$ $ 2 2=BZ\t u001IK\g001IK\g))(3&$''K	q= $ 0 0D AI#'#3#3F1Iy#IL ,<<T__W=UW`k<<T__W=UWcn+H55Z0("]*P PSWS\S\]eSf fggre   )N)NN)NNF)y__name__
__module____qualname____firstlineno__r   r^  r   rs  r   r   ry  rw  rv  r  r  r  r   r  r   r  r  r  r   r  r  r  r  dictr
   r  r   r   rI  rO  rN  rM  r   r~  r  rd  r	   r  r   r   r  r  r  r   r  r  r  r  r%  r   r*  r   r/  r3  r?  rU  rX  r  r  floatr`  r   r   r   r_  r   r  r  r  r  r  r  r  r  r  r  r  r  r  rf  r  r  r  r!  r   r(  r/  r   r:  rC  r]   rO  rU  r[  rT  rZ  r   rj  ro  rs  ri  r  r   r  r  r  r   r  r  r  r  r  r5  intrD  __static_attributes____classcell__)rb  s   @rc  r,   r,      s
   g# gR ') "HS "HH +- 4g 4  .0 @1DM @1D .0 05DM 05d -/ 4= ,D
L >@ F
 F
N F
P 26DW[df D3 Dc DQT D( 154VZce C# CS CPS C( HLZ^mqz| M MTW Mgj M 37TX\eg AC As ARU Alpq|l} A( 04$UYbd ~ ~C ~s ~imnyiz ~( <@daenp WS W W[^ Wuy  {F  vG W :s :P
T P
X P
Q\ P
d{ {v { {z *, 3V 3& -/ C4< CJ -/ M4< M^^O ^@A AF 8: +CZ -/ g: gR 6:" <7 < <" 9=R Gg GG GB 9=R >Gg >GG >G@ 68 : :F :& 9; 5C 58 9; $C $LA4 A A6 AF 57 ,)\ *, f; f;P .2SW`b &s &# &S &gklwgx &P73ot ox o; ob	 24  48 	S 	 LP^bkm !S !X[ !  XZ Tc T T$ mqy{ Z. Z.I Z.Y Z.X] Z.fi Z.xA Av A AF	: 	:	3S 	3Hs H 9=R -S -# - AER #1tCy #1# #1J fjx|  FH )23 )2 )29 )2I )2_b )2ru )2V 8<B ;/C ;/ ;/z 04$UXac R? R?C R?s R?hlmrhs R?h BFTXgktv D?3 D?c D?ad D?L 59tZ^gi Wc W WTW Wnrsxny W* 7;\`ik Y Y3 YVY Yptuzp{ Y* 9=4^bkm \# \S \X[ \ ?CQUdhqs BK BK BK3 BK^a BKx|  ~B  yC BKH
 
4 
, <@d[] 4? 4?S 4? 4?bfglbm 4?l 37TX\eg ??C ??s ??RU ??B @DB 1_S 1_ 1_S\ 1_f 8<B '4W '4R QU]_ X63 X6 X6 X6# X6do X6t JL H;S H;PTUcPd H;T<
h <
R` <
| GI D,# D,u D,# D,L 8<B @,c @, @,D 57 5B =? !4 !4F 46 
 SW_a +# +s +C +fp +2 ]aik +S +C + +VY +pz +. >B" +C +s +Q[ +8
4 
x 
\d 
pz 
* CGr '3 'i 'V[ '6 8<B  8W  84PX>  8D 8: #53 #5JEt EV EN /1 9[ 9v HJ 3 dSVi $,T ,\"F "Fc "Fs "FHD  b$T RPh?# ?s ? ?c ?TX ?`c ? ?re  r,   )2 ccxt.async_support.base.exchanger   ccxt.abstract.coinbaser   r|  r(  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r    r!   r"   r#   r$   r%   r&   r'   r(   ccxt.base.decimal_to_precisionr)   ccxt.base.preciser*   r,   rF  re  rc  <module>rW     sy    6 .   G  G  G  G  G  G  G  * 0 - . ' . ) * ) . ) 4 %oMx oMre  