
    eic                    <   d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlm Z  d d	lm!Z! d d
lm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dl(m)Z) d dl*m+Z+  G d dee          Z,dS )    )Exchange)ImplicitAPIN)AccountAnyBalances
CurrenciesCurrencyDepositAddressIntLedgerEntryMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeesTransaction)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)RateLimitExceeded)OnMaintenance)	TICK_SIZE)Precisec                   P    e Zd Zdef fdZi fdefdZi fdee         fdZ	i fdee
         fdZd ZdefdZi fdefdZd	i fd
ededefdZdJdededefdZd	i fdedefdZi fd
edefdZdJdededefdZd	d	d	i fd
ededefdZd	d	i fd
edededee         fdZi fde fdZ!dJdede"fdZ#dd	d	i fd
ededededee"         f
dZ$i fdefdZ%defdZ&dJd edede'fd!Z(d	i fd"ed
efd#Z)d	d	d	i fd"ed
ededefd$Z*d	d	d	i fd
edededee'         fd%Z+d	d	d	i fd
edededee'         fd&Z,d	d	d	i fd
edededee'         fd'Z-d	i fd
ed(e.d)e/d*e0d+e1f
d,Z2d	i fd"ed
efd-Z3d	i fd
efd.Z4i fd/Z5d	i fd0ed*e0d1ed2ede6f
d3Z7d4 Z8dJd5ed6e9de:fd7Z;d	d	d	i fd0edededee:         fd8Z<d	d	d	i fd0edededee6         fd9Z=d	d	d	i fd0edededee6         fd:Z>d	d	d	i fd0edededee6         fd;Z?d< Z@dJd=ed6e9de6fd>ZAi fd0edeBfd?ZCd@dAi d	d	fdBZDd0eEdCedDedEedFedGefdHZFd@dAi d	d	i fdIZG xZHS )Kcoinbaseexchangereturnc                 `   |                      t          t          |                                           i ddddddgddd	| j        d
         dddi ddddddddddddddddddddddddddddddddddi d dd!dd"dd#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0di d1dd2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAdi dBddCddDddEddFddGddHddIddJddKddLddMddNddOddPddQddRdi dSddTddUddVddWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcdi ddddeddfddgddhddiddjddkdldmddnddoddpddqddrddsddtdduddddvdwdxdydzd{d|d}d~ddddddddddddddgddddddddg dig dg dg ddddddidt
          ddd|                     d          |                     d          dddddddddddddddddddddddd dddd dddddddddddddd ddddddddddddddddddddddddddddddddddddyid	ddid d dd d ddddi ddddddddddddddddēddƓddȓddʓdd̓ddΓddГddғddԓdd֓ddddddddddddddddidt          t          t          t          t          t          t          t          t          d	t          t          t          t          t          t          t          ddi          S )Nidr(   namezCoinbase Exchange	countriesUS	rateLimitd   	userAgentchromeproThasCORSspotmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercloseAllPositionsclosePositioncreateDepositAddresscreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchAccountsfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLedgerfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsemulatedfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginrepayMarginsetLeverage	setMarginsetMarginMode)setPositionModewithdraw
timeframes<   ,  i  i  i`T  iQ )1m5m15m1h6h1dhostnamezexchange.coinbase.comurlsz0https://api-public.sandbox.exchange.coinbase.com)publicprivatezQhttps://github.com/ccxt/ccxt/assets/43336371/34a65553-88aa-4a38-a714-064bd228b97ezhttps://api.{hostname}zhttps://coinbase.com/z.https://docs.cloud.coinbase.com/exchange/docs/z#https://docs.pro.coinbase.com/#feeszIhttps://support.pro.coinbase.com/customer/en/portal/articles/2945310-fees)testlogoapiwwwdocfeesrequiredCredentials)apiKeysecretpasswordr   get)
currenciesproductszproducts/{id}zproducts/{id}/bookzproducts/{id}/candleszproducts/{id}/statszproducts/{id}/tickerzproducts/{id}/tradestimezproducts/spark-lineszproducts/volume-summary)0zaddress-bookaccountszaccounts/{id}zaccounts/{id}/holdszaccounts/{id}/ledgerzaccounts/{id}/transferszcoinbase-accountsfillsfundingr   zmargin/profile_informationzmargin/buying_powerzmargin/withdrawal_powerzmargin/withdrawal_power_allzmargin/exit_planzmargin/liquidation_historyzmargin/position_refresh_amountszmargin/statusoracleordersorders/{id}orders/client:{client_oid}z
otc/orderszpayment-methodspositionprofileszprofiles/{id}zreports/{report_id}	transfersztransfers/{transfer_id}zusers/self/exchange-limitszusers/self/hold-balanceszusers/self/trailing-volumezwithdrawals/fee-estimatezconversions/{conversion_id}conversionszconversions/feeszloans/lending-overviewzloans/lending-overview-xmzloans/loan-previewzloans/loan-preview-xmzloans/repayment-previewzloans/repayment-preview-xmzloans/interest/{loan_id}z loans/interest/history/{loan_id}zloans/interestzloans/assetsloans)r   zdeposits/coinbase-accountzdeposits/payment-methodz coinbase-accounts/{id}/addresseszfunding/repayr   zposition/closezprofiles/margin-transferzprofiles/transferreportszwithdrawals/coinbasezwithdrawals/coinbase-accountzwithdrawals/cryptozwithdrawals/payment-methodz
loans/openzloans/repay-interestzloans/repay-principal)r   r   r   )r   postdeletecommonCurrenciesCGLDCELOprecisionModer   z0.004z0.006)	tierBased
percentagemakertakerr   g333333?   )BCHBTCLTCETHEURUSD
   )r   r   r   deposit)tradingr   features)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergi )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   )r   r   r   r   r   r   r      )r   r   r   daysBackCanceledr   r   r   r   r   )	sandboxrD   createOrdersrv   r~   r{   r   rT   rw   extendsdefault)linearinverse)r   r6   r8   r9   optionsnetworksr   bitcoinr   ethereumSOLsolanaARBONEarbitrumAVAXC	avacchainMATICpolygonBASEbaseSUIsuiOPoptimismNEARnearAPTaptosKAVAkavaBLASTblastXLMstellarSEIseiADAcardanoCOREcoredaoalgorandosmosiscelohederazksyncstackstezoselrondlitecoincosmosfilecoinpolkadotdogecoinrippledash)ALGOOSMOr   HBARZKSYNCSTXXTZEGLDr   ATOMFILDOTDOGEXRPDASH
exceptions)	zInsufficient fundsNotFoundzInvalid API Keyzinvalid signaturezInvalid PassphrasezInvalid order idzPrivate rate limit exceededzTrading pair not availablezProduct not found)zOrder already donezorder not foundzprice too smallzprice too precisezunder maintenancezsize is too smallzCancel only mode)exactbroad)deep_extendsuperr(   describe
userAgentsr%   parse_numberr   r"   r   r!   r#   r   r$   )self	__class__s    a/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/coinbaseexchange.pyr?  zcoinbaseexchange.describe   s   &6 = = F F H H |K
$|K
'|K
 $|K
 	|K

 2|K
 4|K
  iii %i 	i
 %i %i Ui $Ui 'i i "4i ti $Ui  i 'i  t!i" 7#i i$ 9%%i& &u'i( ()i* '+i, (-i. "4/i0  1i2 3i4 &u5i6 "57i8 +E9i: )%;i< #E=i> ,U?i@ $TAiB 'CiD (Ei i iF "4GiH &uIiJ  KiL +DMiN &uOiP 'QiR (SiT #EUiV *5WiX $UYiZ u[i\ "5]i^ *5_i` +Eaib )%cid teif  gi i ih !%iij %ekil $Umin &uoip -eqir /sit "5uiv #Ewix +Eyiz {i| !%}i~ "5i@ &uAiB +ECiD  EiF dGiH $UIi i iJ +EKiL %eMiN "4OiP uQiR #ESiT dUiV !$WiX tYiZ #D[i\  ]i^ '_i` $Uaib !%cid *5eif (gih %eiij )%ki i il )%min toip qir Tsit tuiv "5wix #Dyiz $Z{i| )%}i~ #Di@ AiB #ECiD &uEiF uGiH uIiJ UKiL  Mi iN $) Qi i i|K
b  c|K
r /s|K
t PQ  l67  /G9_ u|K
V " $ $W|K
`     1 1 1d  &  MK K!\ \a|K
Z ![|K
` Ya|K
b !%"&!..w77!..w77	  "'"'    #!! !  !   #!     c|K
Z #&*(,,0,1).+06:#'#'"&#'	( ( #($)$)+027/4#')$ $, %)&+!$$*%+*.& & ',#($)*/	# # ',!$#($)*/( ( ',!$$*%+#($)*/$ $ ',!$$*,-%+#($)*/	* 	*  #AC CJ y ## 
 ## YP P[|K
|
  E9E :E
 8E jE [E YE FE 5E *E FE  7!E$ F%E, W-E. 9/E2 53E8 99E< I=E> '%"$ ' $" % & %%%&#"GE E EG}
|K
L *; -':)<*=(43D2B)5
 
 +8'4'3)5)6)5(5  M|K
 |K
 | | |	    c                 p  K   |                      |           d{V }i }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |          }|                     |di           }	i }
|                     |dg           }t          dt          |                    D ]}||         }|                     |d          }|                     |          }||                     |d          ||                     |d          dk    ddddd	|                     |d
          |                     |d          di|                     |d          |d|
|<   | 	                    ||||                     |	d          ||                     |d          dk    ddd|                     |d          |                     |	d          dd|                     |	d
          |                     |	d          dd|
d          ||<   |S )a0  
        fetches all available currencies on an exchange

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

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        Nr   r+   r,   detailssupported_networksstatusonliner   min_withdrawal_amountmax_withdrawal_amountminmaxcontract_address)r+   r,   networkactiver   r   fee	precisionlimitscontractinfotypemax_precisionmin_size)amountr   )r+   coderW  rX  r,   rR  r   r   rS  rT  rU  r   )
publicGetCurrenciesrangelensafe_stringsafe_currency_code	safe_dict	safe_listnetwork_id_to_codesafe_numbersafe_currency_structure)rB  paramsresponseresulticurrencyr+   r,   r\  rG  r   supportedNetworksjrQ  	networkIdnetworkCodes                   rD  fetch_currenciesz!coinbaseexchange.fetch_currencies  s      11&99999999T q#h--(( 4	 4	A{H!!(D11B##Hf55D**2..DnnXy"==GH $x9Mr R R1c"34455  +A. ,,Wd;;	"55i@@# ,,Wf==*"..wAAXM $#!%"#'#3#3G=T#U#U#'#3#3G=T#U#U% % !% 0 0:L M M#!) )%%$  77 ((&99**8X>>(J !--hHH  $//DD# 
  $//9PQQ#//9PQQ! !	 	 %+9 9  F4LL. rE  c                 8  K   |                      |           d{V }g }t          dt          |                    D ][}||         }|                     |d          }|                    d          \  }}|                     |          }	|                     |          }
|                     |d          }|                    |                     | j        d         i d|d|	dz   |
z   d	|	d
|
ddd|d|ddddddd| 	                    |d          ddddddd|dk    dddddddddd| 
                    |d          | 
                    |d          dddddddddd| 
                    |d           ddd!d|d"
                     ]|S )#a8  
        retrieves data on all markets for coinbaseexchange

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

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        Nr   r+   -rI  r   symbol/r  quotesettlebaseIdquoteIdsettleIdrX  r6   Tr7   margin_enabledr8   Fr9   r:   rR  rJ  rV  r   base_incrementquote_increment)r[  pricerM  min_market_funds)r   r[  r}  cost)
r   contractSizeexpiryexpiryDatetimestrike
optionTyperT  rU  createdrW  )publicGetProductsr^  r_  r`  splitra  appendextendr   
safe_valuere  )rB  rg  rh  ri  rj  marketr+   rw  rx  r  ru  rI  s               rD  fetch_marketszcoinbaseexchange.fetch_marketsE  s      //77777777b q#h--(( :	 :	Aa[F!!&$//B hhsmmOFG **622D++G44E%%fh77FMM$++di	&: 0=b0=$*u,0= 0= 	0=
 $0= &0= 70= D0= 0= 0= $//&2BCC0= 0= %0= %0= 6X-0=  E!0=" $#0=$   $"&""..v7GHH!--f6GHH   $#! !
  $# 
  $# 
  $//8JKK#  $  _0= 0= 0= 0 0 0 0 0 0b rE  c                    K   |                                   d{V  |                     |           d{V }|                     ||          S )av  
        fetch all the accounts associated with a profile

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

        :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)load_marketsprivateGetAccountsparse_accountsrB  rg  rh  s      rD  fetch_accountszcoinbaseexchange.fetch_accounts  si       !!!!!!!!!0088888888* ""8V444rE  c                     |                      |d          }|                      |d          d |                     |          |dS )Nrk  r+   )r+   rX  r\  rW  )r`  ra  )rB  account
currencyIds      rD  parse_accountzcoinbaseexchange.parse_account  sR     %%gz::
""7D11++J77	
 
 	
rE  c                    d|i}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d          |d	<   |||<   |                     |          S )
NrW  r   rk  	availablefreeholdusedbalancetotal)r^  r_  r`  ra  r  safe_balance)rB  rh  ri  rj  r  r  r\  r  s           rD  parse_balancezcoinbaseexchange.parse_balance  s    )q#h--(( 	# 	#AqkG))':>>J**:66DllnnG"..wDDGFO"..w??GFO#//CCGG"F4LL  (((rE  c                    K   |                                   d{V  |                     |           d{V }|                     |          S )ax  
        query for balance and get the amount of funds available for trading or funds locked in orders

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

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        N)r  r  r  r  s      rD  fetch_balancezcoinbaseexchange.fetch_balance  se       !!!!!!!!!0088888888!!(+++rE  Nrs  r   c                 *  K   |                                   d{V  |                     |          dd}|                     |                     ||                     d{V }|                     ||          }|                     |d          |d<   |S )aM  

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

        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        N   )r+   levelsequencenonce)r  	market_idpublicGetProductsIdBookr  parse_order_booksafe_integer)rB  rs  r   rg  requestrh  	orderbooks          rD  fetch_order_bookz!coinbaseexchange.fetch_order_book  s       !!!!!!!!!
 ..((
 
 55dkk'66R6RSSSSSSSS  ))(F;;	!..xDD	'rE  tickerr  c                    d }d }d }d }d }d }d }	d }
|d n|d         }t          |t                    r+|                     |d          }|                                 }n|                     |                     |d                    }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }	|                     |d	d
          }|                     |d          }
|                     i d|d|d|                     |          d|d|d|dd d|dd dd d|	d|d
|dd dd dd dd |
d |d|          S )Nrs     r   bidaskhighlowopenr}  lastvolume	timestampdatetime	bidVolume	askVolumevwapclosepreviousClosechanger   average)
baseVolumequoteVolumerW  )	
isinstancelistr`  milliseconds	parse8601r  safe_string_2safe_tickeriso8601)rB  r  r  r  r  r  r  r  r  r  r  rs  s               rD  parse_tickerzcoinbaseexchange.parse_ticker2  s=   F 	 .vh/?fd## 	8##FA..D))++IItvv'F'FGGI""6511C""6511C##FF33D""6511C##FF33D%%fgv>>D%%fh77F !
f!
!
 Y//!
 D	!

 3!
 3!
 !
 3!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ !)!
 !
 !
* +  	rE  symbolsc                 Z  K   |                                   d{V  |                     |          }i }|                     |                     ||                     d{V }i }t	          |                                          }d}t          dt          |                    D ]p}||         }	|                     ||	g           }
|                     |
dg           }| 	                    |	d|          }|d         }| 
                    ||          ||<   q|                     |d|          S )a'  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

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

        :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
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>`
        Nrr  r   rs  )r  market_symbolspublicGetProductsSparkLinesr  r  keysr^  r_  r  safe_marketr  filter_by_array_tickers)rB  r  rg  r  rh  ri  	marketIds	delimiterrj  marketIdentryfirstr  rs  s                 rD  fetch_tickerszcoinbaseexchange.fetch_tickers  s>      !!!!!!!!!%%g..99$++gv:V:VWWWWWWWW* ))		q#i..)) 	> 	>A |HOOHh;;EOOE1b11E%%hi@@FH%F!..uf==F6NN++FHgFFFrE  c                 B  K   |                                   d{V  |                     |          }d|d         i}|                     | j        dd          } t	          | |          |                     ||                     d{V }|                     ||          S )a  

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

        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/?id=ticker-structure>`
        Nr+   fetchTickerMethodpublicGetProductsIdTicker)r  r  r`  r   getattrr  r  )rB  rs  rg  r  r  methodrh  s          rD  fetch_tickerzcoinbaseexchange.fetch_ticker  s       !!!!!!!!!V$$&,
 !!$,0CE`aa.v..t{{7F/K/KLLLLLLLL.   6222rE  tradec                    |                      |                     |dd                    }|                     |d          }|                     ||d          }d }d }d }|                     |d          }|S|dz   }	|                     ||	          }|                     |d          }
|
 |
dk    rd	nd
}|                     ||          }|                     |dd          }||d         |d}|                     |d          }|d         dk    rdnd}|                     |d          }|                     |d          }|                     |d          }||||d         dk    rdnd}|                     |d          }|                     |d          }|                     |||||                     |          |d         d ||||||d|          S )Nr   
created_at
product_idrr  rx  _value	liquidityTr   r   	fill_feesrS  ru  r  rk  ratetrade_idsidebuysellorder_idmaker_order_idtaker_order_idr}  sizers  )r+   orderrW  r  r  rs  rX  takerOrMakerr  r}  r[  rS  r  )r  r  r`  r  safe_string_lower
safe_trader  )rB  r  r  r  r  feeRater  r  feeCurrencyId	costFieldr  feeCostrS  r+   r  orderIdmakerOrderIdtakerOrderIdr}  r[  s                       rD  parse_tradezcoinbaseexchange.parse_trade  s,   . NN4#5#5eV\#R#RSS	##E<88!!(FC88..vyAA$%0I##E955D((<<I$+4+;+;ww'**6<@@$$UK??w
 

 eZ00-500vvu""5*55''/?@@''/?@@l&>\E]"6]e3355&D  00!!%00"Y//X&( 
  
   	rE  sincec                   K   |t          | j        dz             d}|                     |dd          \  }}|r |                     d||||d           d{V S |                                  d{V  |                     |          }d|d         i}|||d	<   ||                     |          |d
<   |                     |dd          }|/|                     |dg          }|                     |          |d<   | 	                    | 
                    ||                     d{V }	|                     |	|||          S )aI  

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

        fetch all trades made by the user
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades 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 Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
        Nz+ fetchMyTrades() requires a symbol argumentFrv   paginater0   r  r+   r   
start_dateuntilend_date)r   r+   handle_option_and_paramsfetch_paginated_call_dynamicr  r  r  safe_value_2omitprivateGetFillsr  parse_trades)
rB  rs  r  r   rg  r  r  r  r   rh  s
             rD  fetch_my_tradesz coinbaseexchange.fetch_my_trades  s      >#DG.[$[\\\88R\]]& 	o::?FTY[`bhjmnnnnnnnnn!!!!!!!!!V$$&,
 $GG$(LL$7$7GL!!!&':>>YYvy11F"&,,u"5"5GJ--dkk'6.J.JKKKKKKKK  65%@@@rE  c                   K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     ||||          S )a9  

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

        get the list of most recent trades for a particular symbol
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        Nr+   r   )r  r  publicGetProductsIdTradesr  r  )rB  rs  r  r   rg  r  r  rh  s           rD  fetch_tradeszcoinbaseexchange.fetch_tradesB  s       !!!!!!!!!V$$&,
 $GG77GV8T8TUUUUUUUU   65%@@@rE  c                 L  K   |                                   d{V  |                     |           d{V }|                     |d          }|                     |d          }i }t          dt	          | j                            D ]}| j        |         }||||ddd||<   |S )ac  
        fetch the trading fees for multiple markets

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

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/?id=fee-structure>` indexed by market symbols
        Nmaker_fee_ratetaker_fee_rater   T)rW  rs  r   r   r   r   )r  privateGetFeesre  r^  r_  r  )rB  rg  rh  r   r   ri  rj  rs  s           rD  fetch_trading_feesz#coinbaseexchange.fetch_trading_feesc  s       !!!!!!!!!,,V44444444   +;<<  +;<<q#dl++,, 		 		A\!_F  "! F6NN rE  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr      r  r   r     )safe_timestampre  )rB  ohlcvr  s      rD  parse_ohlcvzcoinbaseexchange.parse_ohlcv  s     q))UA&&UA&&UA&&UA&&UA&&
 	
rE  r   	timeframec           	        K   |                                   d{V  d}|                     |ddd          \  }}|r!|                     d|||||d           d{V S |                     |          }|                     | j        |          }d|d         i}	|||	d<   n||	d<   |                     |dd	          }
|                     |dg          }||                     |          |	d
<   |d}nt          d|          }|
|dz  }| 
                    ||z            r3|                     |                     |dz
  |z  |                    |	d	<   nH|                     |                     ||z  |                    |	d	<   n|                     |
          |	d	<   |                     |                     |	|                     d{V }|                     |||||          S )a  

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

        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :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 int[][]: A list of candles ordered, open, high, low, close, volume
        NFrw   r  r   r+   granularityr   endstarti  r   )r  r  "fetch_paginated_call_deterministicr  r  r   r  r  r  rN  is_round_numbersumpublicGetProductsIdCandlesr  parse_ohlcvs)rB  rs  r  r  r   rg  r  r  parsedTimeframer  r   parsedTimeframeMillisecondsrh  s                rD  fetch_ohlcvzcoinbaseexchange.fetch_ohlcv  s7      !!!!!!!!!88z[`aa& 	}@@vW\^cenpvx{|||||||||V$$++DOYGG&,
 &%4GM""%.GM"!!&'5996G9--#||E22GG}C}.=.D+''0K(KLL h%)\\$((EAIId;dfk2l2l%m%mGENN%)\\$((5C^;^`e2f2f%g%gGENN!%e!4!488Wf9U9UVVVVVVVV   69eUKKKrE  c                 h   K   |                      |           d{V }|                     |d          S )a  
        fetches the current integer timestamp in milliseconds from the exchange server
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        Nepoch)publicGetTimer  r  s      rD  
fetch_timezcoinbaseexchange.fetch_time  sE       ++F33333333 ""8W555rE  rI  c                 B    ddddddd}|                      |||          S )Nr  closedcanceled)pendingrR  r  doner*  	cancelingr`  )rB  rI  statusess      rD  parse_order_statusz#coinbaseexchange.parse_order_status  s:    "
 
 &&999rE  r  c                 L   |                      |                     |d                    }|                     |d          }|                     ||d          }|                     |                     |d                    }|                     |d          }|dk    r|dk    rd}|                     |d          }|                     |d	          }|                     |d
|          }	|                     |d          }
|                     |d          }d }|||d         d d}|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     i d|d|d|d|d|                     |          dd d|d|d         d|d|d|d|d|d|d|
d |	d!|d |d d d"|          S )#Nr  r  rr  rI  done_reasonr)  r*  r}  filled_sizer  executed_valuer  ru  r  r+   rX  r  time_in_force	post_only
stop_price
client_oidclientOrderIdrW  r  r  lastTradeTimestamprs  r   postOnlyr   r  r[  filled)	remainingrS  r  trades)r  r`  r  r0  re  r  
safe_orderr  )rB  r  r  r  r  rI  
doneReasonr}  r<  r[  r  r  rS  r+   rX  r  r   r;  r   r9  s                       rD  parse_orderzcoinbaseexchange.parse_order  s   , NN4#3#3E<#H#HII	##E<88!!(FC88(()9)9%)J)JKK%%e];;
hZ:%=%=F  00!!%77!!%88'788""5+66"7O C
 eT**v..v..&&uo>>??5+66''|<<((==  
" 
] 
 E 
 	 

 Y// 
 !$ 
 f 
 fX& 
 D 
 ; 
  
 D 
 U 
 L 
 D 
  f! 
" f# 
$ + 
  
  
, -  	rE  r+   c                 R  K   |                                   d{V  i }|                     |dd          }d}|d}||d<   nd}||d<   |                     |ddg          } t          | |          |                     ||                     d{V }|                     |          S )a  

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

        fetches information on an order made by the user
        :param str id: the order id
        :param str symbol: not used by coinbaseexchange fetchOrder
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr9  r8  privateGetOrdersIdr+   privateGetOrdersClientClientOid)r  r  r  r  r  rA  )rB  r+   rs  rg  r  r9  r  rh  s           rD  fetch_orderzcoinbaseexchange.fetch_order2  s       !!!!!!!!!**6?LQQ )FGDMM6F$1GL!YYv'FGGF.v..t{{7F/K/KLLLLLLLL)))rE  c                   K   |                                   d{V  d}||                     |          }d|i}|                     |                     ||                     d{V }|                     ||||          S )a  
        fetch all the trades made from a single order
        :param str id: order id
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
        Nr  )r  r  r  r  r  )	rB  r+   rs  r  r   rg  r  r  rh  s	            rD  fetch_order_tradesz#coinbaseexchange.fetch_order_tradesK  s       !!!!!!!!![[((F
 --dkk'6.J.JKKKKKKKK  65%@@@rE  c           	      r   K   ddi}|                      ||||                     ||                     d{V S )a  

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

        fetches information on multiple orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch open orders for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        rI  allNfetch_open_ordersr  rB  rs  r  r   rg  r  s         rD  fetch_orderszcoinbaseexchange.fetch_orders_  sQ       e
 ++FE5$++gW]B^B^_________rE  c                 b  K   |                                   d{V  d}|                     |dd          \  }}|r |                     d||||d           d{V S i }d}| |                     |          }|d         |d<   |||d<   ||                     |          |d	<   |                     |d
d          }|/|                     |d
g          }|                     |          |d<   |                     |                     ||                     d{V }	| 	                    |	|||          S )aa  

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

        fetch all unfilled currently open orders
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open orders 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 open orders 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  r0   r+   r  r   r  r   r  )
r  r  r  r  r  r  r  privateGetOrdersr  parse_orders)
rB  rs  r  r   rg  r  r  r  r   rh  s
             rD  rK  z"coinbaseexchange.fetch_open_ordersq  s}      !!!!!!!!!88ART^__& 	q::;LfV[]bdjloppppppppp[[((F$*4LGL!$GG$(LL$7$7GL!!!&':>>YYvy11F"&,,u"5"5GJ..t{{7F/K/KLLLLLLLL  65%@@@rE  c           	      r   K   ddi}|                      ||||                     ||                     d{V S )a  

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

        fetches information on multiple closed orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch open orders for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        rI  r,  NrJ  rL  s         rD  fetch_closed_ordersz$coinbaseexchange.fetch_closed_orders  sQ       f
 ++FE5$++gW]B^B^_________rE  rX  r  r[  r}  c                   K   |                                   d{V  |                     |          }|||d         d}|                     |dd          }	|	|	|d<   |                     |g d          }
|
|                     ||
          |d<   |                     |dd	          }|||d	<   |                     |d
dd          }|rd|d<   |                     |g d          }|dk    r3|                     ||          |d<   |                     ||          |d<   nt|dk    rn|                     |dd          }||||z  }n|                     |ddg          }|| 	                    ||          |d<   n|                     ||          |d<   | 
                    |                     ||                     d{V }|                     ||          S )a  

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

        create a trade order
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr+   )rX  r  r  r9  r8  )	stopPricer7  r   r7  r   r5  r;  r6  FT)	r   r5  rT  r7  r9  r8  r;  r6  r   r   r}  r  r  r  funds)r  r  r  safe_number_nprice_to_precisionr  r  amount_to_precisionsafe_number_2cost_to_precisionprivatePostOrdersr  rA  )rB  rs  rX  r  r[  r}  rg  r  r  r9  r   r   r;  r  rh  s                  rD  create_orderzcoinbaseexchange.create_order  sL      !!!!!!!!!V$$  ,
 
( **6?LQQ$$1GL!))&2]2]2]^^#$($;$;FL$Q$QGL!((PP"'2GO$$$VZeLL 	(#'GK 6  $g  $g  $g  h  h7??#66vuEEGG"66vvFFGFOOX%%ffg>>D|$!E>D6FG+<==#'#9#9&$#G#G  "&":":66"J"J//GV0L0LMMMMMMMM( &111rE  c                   K   |                                   d{V  i }|                     |dd          }d}|d}||d<   nd}||d<   |                     |ddg          }d}| |                     |          }|d         |d<    t	          | |          |                     ||                     d{V }|                     d	|i          S )
a  

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

        cancels an open order
        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr9  r8  privateDeleteOrdersIdr+   "privateDeleteOrdersClientClientOidrs  r  rW  )r  r  r  r  r  r  r?  )	rB  r+   rs  rg  r  r9  r  r  rh  s	            rD  cancel_orderzcoinbaseexchange.cancel_order  s	      !!!!!!!!!
 **6?LQQ ,FGDMM9F$1GL!YYv'FGGF[[((F$*8$4GL!.v..t{{7F/K/KLLLLLLLL1222rE  c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   |                     |                     ||                     d{V }|                     d|i          gS )a  

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

        cancel all open orders
        :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not 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>`
        Nrs  r  rW  )r  r  privateDeleteOrdersr  r?  )rB  rs  rg  r  r  rh  s         rD  cancel_all_ordersz"coinbaseexchange.cancel_all_orders  s       !!!!!!!!![[((F$*8$4GL!11$++gv2N2NOOOOOOOO 23344rE  c                 <   K   |                      |           d {V S N)privateGetPaymentMethods)rB  rg  s     rD  fetch_payment_methodsz&coinbaseexchange.fetch_payment_methods-  s,      226:::::::::rE  r\  addresstagc                   K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }|d         |d}d}d|v r|dz  }nd|v r|dz  }n|d	z  }||d
<   |||d<    t	          | |          |                     ||                     d{V }	|	s-t          | j        dz   |                     |	          z             | 	                    |	|          S )a[  
        make a withdrawal

        https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawpaymentmethod
        https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawcoinbaseaccount

        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nr+   )rk  r[  privatePostWithdrawalspayment_method_idPaymentMethodcoinbase_account_idCoinbaseAccountCryptocrypto_addressdestination_tagz withdraw() error: )
handle_withdraw_tag_and_paramscheck_addressr  rk  r  r  r   r+   jsonparse_transaction)
rB  r\  r[  rh  ri  rg  rk  r  r  rh  s
             rD  r   zcoinbaseexchange.withdraw0  sZ      99#vFFV7###!!!!!!!!!==&& 
 
 *&((o%FF"f,,''FFhF(/G$%-0)*.v..t{{7F/K/KLLLLLLLL 	W*? ?$))HBUBU UVVV%%h999rE  c                 @    dddddd}|                      |||          S )Ntransferr  rS  rebate)rx  matchrS  ry  
conversionr.  )rB  rX  typess      rD  parse_ledger_entry_typez(coinbaseexchange.parse_ledger_entry_typeU  s7    "!
 
 tT222rE  itemrk  c                    |                      |d          }|                      |d          }d }|                      |d          }t          j        ||          }t          j        |d          rd}t          j        |          }nd}|                     |          }|                     |          }	|                     |          }
|                     |                     |d                    }|                     |                      |d                    }| 	                    d |          }|                     |d	i           }d }d }d }|d
k    rC|                      |d          }|                      |d          }|                      |d          }n|                      |d          }d}| 
                    ||||                     |          ||||||||
|	|d d|          S )Nr+   r[  r  0outinr  rX  rG  rx  fromtoprofile_transfer_idr  ok)rW  r+   r  r  	directionr  referenceAccountreferenceIdrX  rk  r[  beforeafterrI  rS  )r`  r&   
string_sub	string_lt
string_absrA  r  r  r}  ra  safe_ledger_entryr  )rB  r~  rk  r+   amountStringr  afterStringbeforeStringr[  r  r  r  rX  r\  rG  r  r  r  rI  s                      rD  parse_ledger_entryz#coinbaseexchange.parse_ledger_entry_  s   2 dD))''h77	&&tY77)+|DD\3// 	I"-l;;LLI""<00!!+..""<00NN4??4#F#FGG	++D,<,<T6,J,JKK&&tX66//$	266:&&w77G#//>>**74IJJKK**7J??K%%"Y//" 0&'
 '
  !  	rE  c                 .  K   |t          | j        dz             |                                  d{V  |                                  d{V  |                     |          }|                     | j        d          }|                     ||          }|t          | j        dz   |z             d|d         i}|| 	                    |          |d<   |||d<   | 
                    |dd	          }	|	/|                     |dg          }| 	                    |	          |d	<   |                     |                     ||                     d{V }
t          d
t          |
                    D ]}||
|         d<   |                     |
|||          S )a  
        fetch the history of changes, actions done by the user or operations that altered the balance of the user

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

        :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 int [params.until]: the latest time in ms to fetch trades for
        :returns dict: a `ledger structure <https://docs.ccxt.com/?id=ledger-entry-structure>`
        Nz$ fetchLedger() requires a code paramr\  z- fetchLedger() could not find account id for r+   r  r   r   r  r   rk  )r   r+   r  load_accountsrk  index_byr   r  r   r  r  r  privateGetAccountsIdLedgerr  r^  r_  parse_ledger)rB  r\  r  r   rg  rk  accountsByCurrencyCoder  r  r   rh  rj  s               rD  fetch_ledgerzcoinbaseexchange.fetch_ledger  s      <#DG.T$TUUU!!!!!!!!!  """""""""==&&!%t}f!E!E//"8$???*Y Y\` `aaa'$-
 $(LL$7$7GL!$GG!!&':>>YYvy11F"&,,u"5"5GJ88Wf9U9UVVVVVVVVq#h--(( 	+ 	+A&*HQK
##  8UEBBBrE  c                   K   |                                   d{V  |                                  d{V  d}|                     |d          }|l|j|                     |          }|                     | j        d          }|                     ||          }|t          | j        dz   |z             |d         }i }	|||	d<   |||	d<   d}
|| 	                    | 
                    |	|                     d{V }
t          dt          |
                    D ]Z}|                     |
|         d          }|                     | j        |          }|                     |d          }||
|         d<   [nZ|                     | 
                    |	|                     d{V }
t          dt          |
                    D ]}||
|         d<   |                     |
|||          S )	ag  
        fetch history of deposits and withdrawals

        https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
        https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers

        :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 is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.id]: account id, when defined, the endpoint used is '/accounts/{account_id}/transfers/' instead of '/transfers/'
        :returns dict: a list of `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nr+   r\  z: fetchDepositsWithdrawals() could not find account id for r   r   
account_idrk  )r  r  r`  rk  r  r   r  r   r+   privateGetTransfersr  r^  r_  accountsByIdprivateGetAccountsIdTransfersparse_transactions)rB  r\  r  r   rg  rk  r+   r  r  r  rh  rj  r  	codeInners                 rD  fetch_deposits_withdrawalsz+coinbaseexchange.fetch_deposits_withdrawals  s7      !!!!!!!!!  """""""""fd++:==..)-t}f)M)M&//*@$GG?'2n(nqu(uvvvT]>GDM$GG:!55dkk'66R6RSSSSSSSSH: 1c(mm,, 4 4!--hqk<HH
//$*;ZHH ,,Wf==	*3J''	4 "??GU[@\@\]]]]]]]]H6 1c(mm,, / /*.J''&&x5%HHHrE  c           	      n   K   |                      ||||                     ddi|                     d{V S )a~  
        fetch all deposits made to an account

        https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
        https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers

        :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
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        rX  r   Nr  r  rB  r\  r  r   rg  s        rD  fetch_depositszcoinbaseexchange.fetch_deposits5  sJ       44T5%V\^gUhjpIqIqrrrrrrrrrrE  c           	      n   K   |                      ||||                     ddi|                     d{V S )a  
        fetch all withdrawals made from an account

        https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
        https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers

        :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
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        rX  r   Nr  r  s        rD  fetch_withdrawalsz"coinbaseexchange.fetch_withdrawalsD  sJ       44T5%V\^hUikqIrIrsssssssssrE  c                     |                      |d          }|rdS |                      |d          }|                      |d          }|rdS |r|sdS dS )Ncanceled_atr*  processed_atcompleted_atr  failedr+  )r  )rB  transactionr*  	processed	completeds        rD  parse_transaction_statusz)coinbaseexchange.parse_transaction_statusS  sn    ??;>> 	:OOK@@	OOK@@	 	4 	y 	89rE  r  c                 *   |                      |di           }|                     |                     |d                    }|                     |d          }|                     ||          }|                     |d          }|                     |d          }|                     |d          }	|                     |d|	          }	d d d d}
|dk    rBd	}|                     |d
|	          }	|                     |d          }||||z  }||
d<   ||
d<   |                     |d          }i d|d|                     |d          d|                     |d          d|d|d|                     |          d|d|                     |          d|d|                     |          d|	dd d|                     |d          d|                     |d          dd dd d|                     |                     |d                    d d|
dS ) NrG  r  rk  r[  rX  rq  )rk  r  r  r   
withdrawalsent_to_addressrS  r  rQ  rW  r+   txidcrypto_transaction_hashrI  r  r  rh  addressFrom	addressTori  rr  tagFromtagToupdatedr  F)commentinternalrS  )r  r  r`  ra  re  rd  r  r  )rB  r  rk  rG  r  r  r\  r[  rX  rh  rS  r  rn  s                rD  rv  z"coinbaseexchange.parse_transaction`  s   > //+y"==NN4#3#3K#N#NOO	%%k:>>
&&z8<<!!+x88V44""7,<=="";0@'JJ
 

 :D&&w0A7KKG&&w66G"%g%F%F"&J$$Wi88	
K
$"";55
 D$$W.GHH
 D	

 
 t..y99
 f
 d33K@@
 
 Y//
 w
 4
 ))'3CDD
 4##G->??
 t
  T!
" t~~d&6&6{N&S&STT#
$ )
 
 
 	
rE  c                   K   |                                   d{V  |                     |          }|                     | j        d          }|B|                                  d{V }|| j        d<   |                     |d          | j        d<   |d         }|                     | j        d         |          }|#t          | j        dz   |z   dz   |z   dz             d|d         i}|                     | 	                    ||                     d{V }| 
                    |d	          }	| 
                    |d
          }
||                     |	          d|
|dS )a  
        create a currency deposit address

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

        :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>`
        NcoinbaseAccountsrk  coinbaseAccountsByCurrencyIdr+   z5 createDepositAddress() could not find currency code z with id = z0 in self.options['coinbaseAccountsByCurrencyId']rh  rr  )rk  rh  rQ  ri  rW  )r  rk  r  r   privateGetCoinbaseAccountsr  r    r+   &privatePostCoinbaseAccountsIdAddressesr  r`  rt  )rB  r\  rg  rk  r   r  r  r  rh  rh  ri  s              rD  create_deposit_addressz'coinbaseexchange.create_deposit_address  s      !!!!!!!!!==&&??4<1CDD!<<>>>>>>>>H/7DL+,;?==S];^;^DL78d^
//$,/M"NPZ[[? +b!bei!ily!y  }G  "G  J|  "|  }  }  }'$-
 DDT[[QXZ`EaEabbbbbbbb""8Y77x):;;))'22
 
 	
rE  r   GETc                    d|                      ||          z   }|                     ||                     |                    }|dk    r|r|d|                     |          z   z  }|                     | j        d         |                   |z   }	|dk    r|                                  t          |                                           }
d}|dk    r|r| 	                    |          }|}|
|z   |z   |z   }d }	 | 
                    | j                  }n)# t          $ r}t          | j        dz             d }~ww xY w|                     |                     |          |t"          j        d          }| j        ||
| j        d	d
}|	|||dS )Nrt  r  ?r   r    z sign() invalid base64 secretbase64zapplication/json)zCB-ACCESS-KEYzCB-ACCESS-SIGNzCB-ACCESS-TIMESTAMPzCB-ACCESS-PASSPHRASEzContent-Type)urlr  bodyheaders)implode_paramsr  extract_params	urlencodeimplode_hostnamer   check_required_credentialsstrr  ru  base64_to_binaryr   	Exceptionr   r+   hmacencodehashlibsha256r   r   )rB  pathr   r  rg  r  r  r  queryr  r  payloadwhatr   e	signatures                   rD  signzcoinbaseexchange.sign  s   ++D&999		&$"5"5d";";<<U?? 73!6!666##DIe$4S$9::WD)++---

%%EG #99U++D"G6>G+g5DFU..t{;; U U U)$'4S*STTTU		$++d"3"3VW^XVVI!%"+',(, 2 G fdwOOOs   9D 
D:D55D:reasonr  r  r  r  c
                 V   |dk    s|dk    r|d         dk    rv|                      |d          }
| j        dz   |
z   }|                     | j        d         |
|           |                     | j        d         |
|           t          |          t          | j        dz   |z             d S )	Ni  i  r   {message r;  r<  )r`  r+   throw_exactly_matched_exceptionr9  throw_broadly_matched_exceptionr   )rB  r\  r  r  r  r  r  rh  requestHeadersrequestBodyr  feedbacks               rD  handle_errorszcoinbaseexchange.handle_errors  s    CKKTS[[Aw#~~**8Y??7S=7244T_W5MwX`aaa44T_W5MwX`aaa#H---# 4555trE  c           	         K   |                      |||||||           d {V }t          |t                    s1d|v r-t          | j        dz   |                     |          z             |S )Nr  r  )fetch2r  r  r   r+   ru  )	rB  r  r   r  rg  r  r  configrh  s	            rD  r  zcoinbaseexchange.request  s}      T3vVVVVVVVV(C(( 	IH$$#DGcMDIIh4G4G$GHHHrE  re  )I__name__
__module____qualname__r   r?  r   rp  r   r   r  r   r  r  r   r  r  r  r   r   r  dictr   r  r   r   r  r  r   r  r   r  r  r   r  r  r  r#  r'  r0  r   rA  rE  rG  rM  rK  rR  r   r   floatr   r\  r`  rc  rg  r   r   r}  r	   r   r  r  r  r  r  r  rv  r
   r  r  intr  r  __classcell__)rC  s   @rD  r(   r(      s	       }# } } } } } }~ -/ i i: i i i iV *, v vV v v v vp +- 5 5g 5 5 5 5B
 
 
&) ) ) ) ) *, , , , , , , @DB % %S % %S\ % % % %NM M4 M M6 M M M M^ 6:" ,G ,G7 ,G ,G ,G ,G ,G\ 68 (3 (3 (3F (3 (3 (3 (3TC C Cv C C C C CJ 37TX\eg "A "AC "As "ARU "A "A "A "AH <@d[] A A AS A Abfglbm A A A AB /1  [    B
 
 
4 
 
 
 
( ?CQUdhqs 6L 6L 6L 6L3 6L^a 6Lx|  ~B  yC 6L 6L 6L 6Lp ') 6 6S 6 6 6 6	: 	: 	: 	: 	:F F Fv F F F F FP 8<B * *C * * * * *2 ?CQUdhqs A A3 A A3 A^a A A A A( 04$UYbd ` ` `C `s `imnsit ` ` ` `$ 59tZ^gi !A !Ac !A !ATW !Anrsxny !A !A !A !AF 7;\`ik ` ` `3 `VY `ptuzp{ ` ` ` `$ mqy{ S2 S2 S2I S2Y S2X] S2fi S2 S2 S2 S2j 9=R 3 3S 3# 3 3 3 3> 59 5 5c 5 5 5 5& 24 ; ; ; ; QU]_ #: #:3 #: #: #:# #:do #: #: #: #:J3 3 3D Dt Dx D; D D D DL .2SW`b +C +Cs +C# +CS +Cgklwgx +C +C +C +CZ <@daenp aI aIS aI aI[^ aIuy  {F  vG aI aI aI aIF 04$UYbd s s sC ss simnyiz s s s s 37TX\eg t tC ts tRU tlpq|l} t t t t  K
 K
T K
X K
Q\ K
 K
 K
 K
Z >@ "
 "
 "
N "
 "
 "
 "
H &eBSW P P P P>	# 	s 	 	c 	TX 	`c 	 	 	 	 '/uRQU\`ik        rE  r(   )- ccxt.async_support.base.exchanger   ccxt.abstract.coinbaseexchanger   r  ccxt.base.typesr   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$   ccxt.base.decimal_to_precisionr%   ccxt.base.preciser&   r(    rE  rD  <module>r     sr   6 5 5 5 5 5 6 6 6 6 6 6  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `  `       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . . . . . . . + + + + + + ) ) ) ) ) ) * * * * * * . . . . . . * * * * * * 4 4 4 4 4 4 % % % % % %g g g g gx g g g g grE  