
    i#4                    0   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 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Balances
CurrenciesCurrencyInt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                       e Zd Z 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d<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d<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d<dede fdZ!dd	d	i fd
edededee          fdZ"i fdZ#d Z$d<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%e.d&e/f
d'Z0d	i fded
efd(Z1d	i fd
efd)Z2i fd*Z3d	i fd+ed%e.fd,Z4d- Z5d<d.e6fd/Z7d	d	d	i fd+ededefd0Z8d	d	d	i fd+edededee9         fd1Z:d	d	d	i fd+edededee9         fd2Z;d	d	d	i fd+edededee9         fd3Z<d4 Z=d<d.e6de9fd5Z>i fd+efd6Z?d7d8i d	d	fd9Z@d: ZAd7d8i d	d	i fd;ZB xZCS )=coinbaseproc                    |                      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ddddd1ddd2d3d4d5d6d7d8d9d:d;d<d=d>d>d?d@dAdAd?dBdCdDdEgdFdGddddHdIdJg dKig dLg dMg dNdOd?dPdQdRidSt
          dTdd|                     dU          |                     dV          dWdddXdXdXdXdYdZd[dXdXdXdXdYd\d[d]d^d_t          t          t          t          t          t          t          t          t          d`	t          t          t          t          t          t          t          dadb          S )cNidr%   namezCoinbase Pro	countriesUS	rateLimitd   	userAgentchromeproThasCORSspotmarginFswapfutureoptioncancelAllOrderscancelOrdercreateDepositAddresscreateOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchAccountsfetchBalancefetchClosedOrdersfetchCurrenciesfetchDepositAddressfetchDepositsfetchDepositsWithdrawalsfetchFundingRatefetchLedgerfetchMarginModefetchMarketsfetchMyTrades
fetchOHLCVfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionModefetchTickerfetchTickersemulated)	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsfetchWithdrawalswithdraw
timeframes<   ,  i  i  i`T  iQ )1m5m15m1h6h1dhostnamezpro.coinbase.comurlsz+https://api-public.sandbox.pro.coinbase.com)publicprivatezchttps://user-images.githubusercontent.com/1294454/41764625-63b7ffde-760a-11e8-996d-a6328fa9347a.jpgzhttps://api.{hostname}zhttps://pro.coinbase.com/zhttps://docs.pro.coinbase.comz#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passwordrj   get)

currenciesproductszproducts/{id}zproducts/{id}/bookzproducts/{id}/candleszproducts/{id}/statszproducts/{id}/tickerzproducts/{id}/tradestimezproducts/spark-lines)$zaddress-bookaccountszaccounts/{id}zaccounts/{id}/holdszaccounts/{id}/ledgerzaccounts/{id}/transferszcoinbase-accountsfillsfundingrm   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}zconversions/fees)conversionszdeposits/coinbase-accountzdeposits/payment-methodz coinbase-accounts/{id}/addresseszfunding/repayrz   zposition/closezprofiles/margin-transferzprofiles/transferreportszwithdrawals/coinbasezwithdrawals/coinbase-accountzwithdrawals/cryptozwithdrawals/payment-method)rz   r|   r{   )rr   postdeletecommonCurrenciesCGLDCELOprecisionModerm   z0.004z0.006)	tierBased
percentagemakertakerr   g333333?   )BCHBTCLTCETHEURUSD
   )r   r   rZ   deposit)tradingrx   
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    d/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/coinbasepro.pyr   zcoinbasepro.describe   s   k4 8 8 A A C C TF
-TF
NTF
 $TF
 	TF

 2TF
 4TF
  *** %* 	*
 %* %* "4* t* '* t* '* (* "4*  * *  $T!*" "4#* *$ &u%*&  '*( +D)** #E+*, t-*. "5/*0 1*2  3*4 d5*6 "47*8 d9*: !$;*< t=*> #D?*@ $UA*B tC*D E* *F "##($(%/$( S* * *TF
d  eTF
t *uTF
v KL  ~67  369_ wTF
X " $ $YTF
b    % % %L     o< <L LcTF
| !}TF
B YCTF
D !%"&!..w77!..w77	  "'"'    #!! !  !   #!     ETF
| *; -':)<*=(43D2B)5
 
 +8'4'3)5)6)5(5  }TF
 T T T	    returnc                 R  K   |                      |           d{V }i }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |          }|                     |di           }	|                     |d          }
|
dk    }||||                     |	d          ||ddd|                     |d	          |                     |	d
          dd|                     |	d          dddi d||<   |S )a4  
        fetches all available currencies on an exchange
        :see: 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statusonlinetypemax_precisionmin_sizeminmaxmin_withdrawal_amount)amountrZ   )r'   codeinfor   r(   activer   rZ   fee	precisionlimitsnetworks)publicGetCurrenciesrangelensafe_stringsafe_currency_code
safe_valuesafe_number)r   paramsresponseresulticurrencyr'   r(   r   r   r   r   s               r   fetch_currencieszcoinbasepro.fetch_currencies   sx      11&999999996 q#h--(( 	 	A{H!!(D11B##Hf55D**2..Dooh	2>>G%%h99F(F ((&99  !--hHH  $//DD# 
  $//9PQQ#! !	 	 + F4LL. r   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 )#a7  
        retrieves data on all markets for coinbasepro
        :see: 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'   -r   r   symbol/basequotesettlebaseIdquoteIdsettleIdr   r2   Tr3   margin_enabledr4   Fr5   r6   r   r   contractlinearbase_incrementquote_increment)r   pricer   min_market_funds)leverager   r   cost)
inversecontractSizeexpiryexpiryDatetimestrike
optionTyper   r   createdr   )publicGetProductsr   r   r   splitr   appendextendrm   r   r   )r   r   r   r   r   marketr'   r   r   r   r   r   s               r   fetch_marketszcoinbasepro.fetch_markets6  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 r   c                    K   |                                   d{V  |                     |           d{V }|                     ||          S )a|  
        fetch all the accounts associated with a profile
        :see: 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r   r   r   s      r   fetch_accountszcoinbasepro.fetch_accounts  si       !!!!!!!!!0088888888* ""8V444r   c                     |                      |d          }|                      |d          d |                     |          |dS )Nr   r'   )r'   r   r   r   )r   r   )r   account
currencyIds      r   parse_accountzcoinbasepro.parse_account  sR     %%gz::
""7D11++J77	
 
 	
r   c                    d|i}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d          |d	<   |||<   |                     |          S )
Nr   r   r   	availablefreeholdusedbalancetotal)r   r   r   r   r   safe_balance)r   r   r   r   r   r   r   r   s           r   parse_balancezcoinbasepro.parse_balance  s    (#q#h--(( 	# 	#AqkG))':>>J**:66DllnnG"..wDDGFO"..w??GFO#//CCGG"F4LL  (((r   c                    K   |                                   d{V  |                     |           d{V }|                     |          S )a~  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: 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      r   fetch_balancezcoinbasepro.fetch_balance  se       !!!!!!!!!0088888888!!(+++r   Nr   limitc                 *  K   |                                   d{V  |                     |          dd}|                     |                     ||                     d{V }|                     ||          }|                     |d          |d<   |S )aS  
        :see: 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)r   r   r   r   requestr   	orderbooks          r   fetch_order_bookzcoinbasepro.fetch_order_book  s       !!!!!!!!!
 ..((
 
 55dkk'66R6RSSSSSSSS  ))(F;;	!..xDD	'r   r   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 )Nr      ru   bidaskhighlowopenr   lastvolume	timestampdatetime	bidVolume	askVolumevwapclosepreviousClosechanger   average)
baseVolumequoteVolumer   )	
isinstancelistr   milliseconds	parse8601r   safe_string_2safe_tickeriso8601)r   tickerr   r  r  r	  r  r
  r  r  r  r   s               r   parse_tickerzcoinbasepro.parse_ticker  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#!
$ !)!
 !
 !
* +  	r   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
        :see: 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>`
        Nr   r   r   )r   market_symbolspublicGetProductsSparkLinesr   r  keysr   r   r   safe_marketr"  filter_by_array_tickers)r   r#  r   r  r   r   	marketIds	delimiterr   marketIdentryfirstr   r   s                 r   fetch_tickerszcoinbasepro.fetch_tickersj  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Fr   c                 B  K   |                                   d{V  |                     |          }d|d         i}|                     | j        dd          } t	          | |          |                     ||                     d{V }|                     ||          S )a  
        :see: 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   optionsgetattrr   r"  )r   r   r   r   r  methodr   s          r   fetch_tickerzcoinbasepro.fetch_ticker  s       !!!!!!!!!V$$&,
 !!$,0CE`aa.v..t{{7F/K/KLLLLLLLL.   6222r   c                    |                      |                     |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 )Nru   
created_at
product_idr   r   _value	liquidityTr   r   	fill_feesr   r   r   r   ratetrade_idsidebuysellorder_idmaker_order_idtaker_order_idr   sizer   )r'   orderr   r  r  r   r   takerOrMakerrA  r   r   r   r   )r  r  r   r(  safe_string_lower
safe_trader   )r   trader   r  r,  feeRaterI  r   feeCurrencyId	costFieldr;  feeCostr   r'   rA  orderIdmakerOrderIdtakerOrderIdr   r   s                       r   parse_tradezcoinbasepro.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&( 
  
   	r   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 )aO  
        :see: 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 argumentFrI   paginater,   r9  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)
r   r   rU  r   r   rW  r   r  rY  r   s
             r   fetch_my_tradeszcoinbasepro.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%@@@r   c                   K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     ||||          S )a?  
        :see: 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`  )r   r   rU  r   r   r   r  r   s           r   fetch_tradeszcoinbasepro.fetch_trades%  s       !!!!!!!!!V$$&,
 $GG77GV8T8TUUUUUUUU   65%@@@r   c                 L  K   |                                   d{V  |                     |           d{V }|                     |d          }|                     |d          }i }t          dt	          | j                            D ]}| j        |         }||||ddd||<   |S )ai  
        fetch the trading fees for multiple markets
        :see: 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)r   r   r   r   r   r   )r   privateGetFeesr   r   r   r#  )r   r   r   r   r   r   r   r   s           r   fetch_trading_feeszcoinbasepro.fetch_trading_feesD  s       !!!!!!!!!,,V44444444   +;<<  +;<<q#dl++,, 		 		A\!_F  "! F6NN r   c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr      r      r     )safe_timestampr   )r   ohlcvr   s      r   parse_ohlcvzcoinbasepro.parse_ohlcvc  s     q))UA&&UA&&UA&&UA&&UA&&
 	
r   r^   c           	        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  
        :see: 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
        NFrJ   rW  r]   r'   granularityrY  endstarti  rl  )r   r[  "fetch_paginated_call_deterministicr   r  r[   r]  r^  r   r   is_round_numbersumpublicGetProductsIdCandlesr   parse_ohlcvs)r   r   	timeframerU  r   r   rW  r   parsedTimeframer  rY  parsedTimeframeMillisecondsr   s                r   fetch_ohlcvzcoinbasepro.fetch_ohlcvw  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Kr   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)publicGetTimern  r   s      r   
fetch_timezcoinbasepro.fetch_time  sE       ++F33333333 ""8W555r   c                 B    ddddddd}|                      |||          S )Nr  closedcanceled)pendingr   r  doner  	cancelingr   )r   r   statusess      r   parse_order_statuszcoinbasepro.parse_order_status  s:    "
 
 &&999r   c           	      N   |                      |                     |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 )#Nr8  r9  r   r   done_reasonr  r  r   filled_sizerG  executed_valuer=  r   r>  r'   r   rA  time_in_force	post_only
stop_price
client_oidclientOrderIdr   r  r  lastTradeTimestampr   timeInForcepostOnly	stopPricetriggerPricer   r   )filled	remainingr   r  trades)r  r   r(  r  r   r   
safe_orderr   )r   rH  r   r  r,  r   
doneReasonr   r  r   r   rP  r   r'   r   rA  r  r  r  r  s                       r   parse_orderzcoinbasepro.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$$UL99	((==  
" 
] 
 E 
 	 

 Y// 
 !$ 
 f 
 fX& 
 D 
 ; 
  
 D 
 U 
  
 I 
  D! 
" f# 
$ - 
  
  
. /  	r   r'   c                 R  K   |                                   d{V  i }|                     |dd          }d}|d}||d<   nd}||d<   |                     |ddg          } t          | |          |                     ||                     d{V }|                     |          S )a  
        :see: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getorder
        fetches information on an order made by the user
        :param str symbol: not used by coinbasepro fetchOrder
        :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  privateGetOrdersIdr'   privateGetOrdersClientClientOid)r   r  r^  r4  r   r  )r   r'   r   r   r  r  r5  r   s           r   fetch_orderzcoinbasepro.fetch_order  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)))r   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>`
        NrD  )r   r   r_  r   r`  )	r   r'   r   rU  r   r   r   r  r   s	            r   fetch_order_tradeszcoinbasepro.fetch_order_trades&  s       !!!!!!!!![[((F
 --dkk'6.J.JKKKKKKKK  65%@@@r   c           	      r   K   ddi}|                      ||||                     ||                     d{V S )a  
        :see: 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>`
        r   allNfetch_open_ordersr   r   r   rU  r   r   r  s         r   fetch_orderszcoinbasepro.fetch_orders:  sQ       e
 ++FE5$++gW]B^B^_________r   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 )ag  
        :see: 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>`
        NFrK   rW  r,   r'   r9  r   rX  rY  rZ  )
r   r[  r\  r   r   r]  r^  privateGetOrdersr   parse_orders)
r   r   rU  r   r   rW  r  r   rY  r   s
             r   r  zcoinbasepro.fetch_open_ordersJ  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%@@@r   c           	      r   K   ddi}|                      ||||                     ||                     d{V S )a  
        :see: 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>`
        r   r  Nr  r  s         r   fetch_closed_orderszcoinbasepro.fetch_closed_ordersk  sQ       f
 ++FE5$++gW]B^B^_________r   r   rA  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  
        :see: 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 fullfilled, 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'   )r   rA  r9  r  r  )r  r  r  r  r  r  r  r  FT)	r  r  r  r  r  r  r  r  r  r   r   rG  r   r   funds)r   r   r  safe_number_nprice_to_precisionr]  r^  amount_to_precisionsafe_number_2cost_to_precisionprivatePostOrdersr   r  )r   r   r   rA  r   r   r   r   r  r  r  r  r  r   r   s                  r   create_orderzcoinbasepro.create_order{  sL      !!!!!!!!!V$$  ,
 
( **6?LQQ$$1GL!&&v/Z/Z/Z[[	 $($;$;FI$N$NGL!((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1r   c                 p  K   |                                   d{V  i }|                     |dd          }d}|d}||d<   nd}||d<   |                     |ddg          }d}| |                     |          }|d         |d<    t	          | |          |                     ||                     d{V S )	a  
        :see: 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>`
        Nr  r  privateDeleteOrdersIdr'   "privateDeleteOrdersClientClientOidr   r9  )r   r  r^  r   r4  r   )r   r'   r   r   r  r  r5  r   s           r   cancel_orderzcoinbasepro.cancel_order  s       !!!!!!!!!
 **6?LQQ ,FGDMM9F$1GL!YYv'FGGF[[((F$*8$4GL!*WT6**4;;w+G+GHHHHHHHHHr   c                    K   |                                   d{V  i }d}| |                     |          }|d         |d<   |                     |                     ||                     d{V S )a  
        :see: 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>`
        Nr   r9  )r   r   privateDeleteOrdersr   )r   r   r   r  r   s        r   cancel_all_orderszcoinbasepro.cancel_all_orders  s       !!!!!!!!![[((F$*8$4GL!--dkk'6.J.JKKKKKKKKKr   c                 <   K   |                      |           d {V S N)privateGetPaymentMethods)r   r   s     r   fetch_payment_methodsz!coinbasepro.fetch_payment_methods  s,      226:::::::::r   r   c                   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 )ag  
        make a withdrawal
        :see: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawpaymentmethod
        :see: 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'   )r   r   privatePostWithdrawalspayment_method_idPaymentMethodcoinbase_account_idCoinbaseAccountCryptocrypto_addressdestination_tagz withdraw() error: )
handle_withdraw_tag_and_paramscheck_addressr   r   r4  r   r   r'   jsonparse_transaction)
r   r   r   addresstagr   r   r  r5  r   s
             r   rZ   zcoinbasepro.withdraw  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9r   c                 @    dddddd}|                      |||          S )NtransferrL  r   rebate)r  matchr   r  
conversionr  )r   r   typess      r   parse_ledger_entry_typez#coinbasepro.parse_ledger_entry_type   s7    "!
 
 tT222r   r   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inr8  r   r   r  fromtoprofile_transfer_idrD  ok)r'   r   r   referenceAccountreferenceIdr   r   beforeafterr   	directionr  r  r   r   )r   r#   
string_sub	string_lt
string_absr   r  r   r  r   r   )r   itemr   r'   amountStringr  afterStringbeforeStringr   r  r  r  r   r   r   r   r  r  r   s                      r   parse_ledger_entryzcoinbasepro.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 0&""Y//
 
 	
r   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  
        :see: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccountledger
        fetch the history of changes, actions done by the user or operations that altered balance of the user
        :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 entrys 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-structure>`
        Nz$ fetchLedger() requires a code paramr   z- fetchLedger() could not find account id for r'   rX  r   rY  rZ  r   r   )r   r'   r   load_accountsr   index_byrv   r   r   r   r]  r^  privateGetAccountsIdLedgerr   r   r   parse_ledger)r   r   rU  r   r   r   accountsByCurrencyCoder   r  rY  r   r   s               r   fetch_ledgerzcoinbasepro.fetch_ledgerp  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Br   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 )	as  
        fetch history of deposits and withdrawals
        :see: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
        :see: 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_idr   )r   r  r   r   r  rv   r   r   r'   privateGetTransfersr   r   r   accountsByIdprivateGetAccountsIdTransfersparse_transactions)r   r   rU  r   r   r   r'   r  r   r  r   r   r  	codeInners                 r   fetch_deposits_withdrawalsz&coinbasepro.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Hr   c           	      n   K   |                      ||||                     ddi|                     d{V S )a  
        fetch all deposits made to an account
        :see: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
        :see: 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>`
        r   r   Nr  r   r   r   rU  r   r   s        r   fetch_depositszcoinbasepro.fetch_deposits  sJ       44T5%V\^gUhjpIqIqrrrrrrrrrr   c           	      n   K   |                      ||||                     ddi|                     d{V S )a  
        fetch all withdrawals made from an account
        :see: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
        :see: 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>`
        r   rZ   Nr  r   s        r   fetch_withdrawalszcoinbasepro.fetch_withdrawals	  sJ       44T5%V\^hUikqIrIrsssssssssr   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   )r   transactionr  	processed	completeds        r   parse_transaction_statusz$coinbasepro.parse_transaction_status  sn    ??;>> 	:OOK@@	OOK@@	 	4 	y 	89r   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 ) Nr   r8  r   r   r   r  )r   r   r?  rZ   
withdrawalsent_to_addressr   r   networkr   r'   txidcrypto_transaction_hashr   r  r  r  addressFrom	addressTor  r  tagFromtagToupdatedr  F)commentinternalr   )r   r  r   r   r   network_id_to_coder  r   )r   r	  r   r   r  r   r   r   r   r  r   rP  	networkIds                r   r  zcoinbasepro.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#
$ )
 
 
 	
r   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S )a  
        create a currency deposit address
        :see: 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coinbaseAccountsr   coinbaseAccountsByCurrencyIdr'   z5 createDepositAddress() could not find currency code z with id = z0 in self.options['coinbaseAccountsByCurrencyId']r  r  )r   r  r  r   )r   r   r   r3  privateGetCoinbaseAccountsr  r   r'   &privatePostCoinbaseAccountsIdAddressesr   r   r  )r   r   r   r   rv   r   r   r  r   r  r  s              r   create_deposit_addressz"coinbasepro.create_deposit_addressp  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	
 
 	
r   rf   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 )Nr   r"  ?rj   rg    z sign() invalid base64 secretbase64zapplication/json)zCB-ACCESS-KEYzCB-ACCESS-SIGNzCB-ACCESS-TIMESTAMPzCB-ACCESS-PASSPHRASEzContent-Type)urlr5  bodyheaders)implode_paramsr^  extract_params	urlencodeimplode_hostnamere   check_required_credentialsstrr   r  base64_to_binaryrp   	Exceptionr   r'   hmacencodehashlibsha256ro   rq   )r   pathrj   r5  r   r)  r(  r  queryr'  r   payloadwhatrp   e	signatures                   r   signzcoinbasepro.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: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_exceptionr   throw_broadly_matched_exceptionr   )r   r   reasonr'  r5  r)  r(  r   requestHeadersrequestBodyr?  feedbacks               r   handle_errorszcoinbasepro.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tr   c           	         K   |                      |||||||           d {V }t          |t                    s1d|v r-t          | j        dz   |                     |          z             |S )Nr?  r@  )fetch2r  r/  r   r'   r  )	r   r6  rj   r5  r   r)  r(  configr   s	            r   r  zcoinbasepro.request  s}      T3vVVVVVVVV(C(( 	IH$$#DGcMDIIh4G4G$GHHHr   r  )D__name__
__module____qualname__r   r   r   r   r
   r   r   r   r   r   r   r   r/  r	   r   r  r   r"  r   r   r/  r6  r   rT  r   ra  rd  r   ri  r  rp  r}  r  r  r   r  r  r  r  r  r  r   r   floatr   r  r  r  r  rZ   r  r   r  r  r   r  r  r  r  r  r!  r<  rG  r  __classcell__)r   s   @r   r%   r%      sR       U U U U Un -/ B B: B B B BH *, t tV t t t tl +- 5 5g 5 5 5 5>
 
 
&) ) ) ) ) *, 	, 	, 	, 	, 	, 	, @DB # #S # #S\ # # # #JM M6 MV M M M M^ 6:" *G *G7 *G *G *G *G *GX 68 &3 &3 &3F &3 &3 &3 &3PC C C5 C C C CJ 37TX\eg  A  AC  As  ARU  A  A  A  AD <@d[] A A AS A Abfglbm A A A A> /1  [    >
 
 
4 
 
 
 
( 8<$]ajl 4L 4L 4LC 4LWZ 4Lquvzq{ 4L 4L 4L 4Ll ') 6 6 6 6	: 	: 	:G G G5 G G G GR 8<B * *C * * * * *, ?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B 7;\`ik ` ` `3 `VY `ptuzp{ ` ` ` `  mqy{ Q2 Q2 Q2I Q2Y Q2X] Q2fi Q2 Q2 Q2 Q2f 9=R I IS I# I I I I8 59 L Lc L L L L  24 ; ; ; ; EIQS !: !:3 !: !: !: !: !:F3 3 3D
 D
 D
 D
 D
 D
L .2SW`b )C )Cs )C# )CS )C )C )C )CV <@daenp _I _IS _I _I[^ _Iuy  {F  vG _I _I _I _IB 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
x K
; K
 K
 K
 K
Z >@ 
 
 
 
 
 
B &eBSW P P P P>	 	 	 '/uRQU\`ik        r   r%   )* ccxt.async_support.base.exchanger   ccxt.abstract.coinbasepror   r4  ccxt.base.typesr   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%    r   r   <module>rX     sN   6 5 5 5 5 5 1 1 1 1 1 1  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . . . . . . . + + + + + + ) ) ) ) ) ) * * * * * * . . . . . . * * * * * * 4 4 4 4 4 4 % % % % % %g g g g g(K g g g g gr   