
    !:h                    X   d dl mZ d dlmZ d dl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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+ d dl,m-Z- d dl.m/Z/  G d dee      Z0y)    )Exchange)ImplicitAPIN)AccountAnyBalances
CurrenciesCurrencyIntLedgerEntryMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersFundingRateTradeTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)NotSupported)OnMaintenance)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdZi fdefdZi fdefdZ	i fde
e   fdZ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dSdededefdZd	i f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dSdedefdZd	d	i fdededede
e   fdZdSdededefdZi fdefdZdSdefdZ i fde
e!   fdZ"d Z#i fde$fdZ%de$fdZ&d	d	d	i fde'd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)d	d	d	i fde'dedede
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
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fd&Z/d	i fde'fd'Z0d	i fd ede'fd(Z1d	i fde'fd)Z2d	i fded*e3d+e4d,e5d-e6f
d.Z7d	d	i fd eded*e3d+e4d,e6d-e6fd/Z8dSd0edede*fd1Z9d2e'fd3Z:d4 Z;i fd5ed,e5d6ed7ede<f
d8Z=d	d	d	i fd5e'dedede
e<   fd9Z>dSd:ed;e?de<fd<Z@d2e'de'fd=ZAd	d	d	i fd5e'dedede
eB   fd>ZCd	i fd5ed,e5d?edeBfd@ZDdSdAed;e?deBfdBZEdC ZFd	d	d	i fd5e'dedede
eG   fdDZHdSdEed;e?deGfdFZIdG ZJi fdedeKfdHZLdSdedeKfdIZMdJdKi d	d	fdLZNd5eOdMedNedOedPedQefdRZP xZQS )Tcoinlistreturnc                    | j                  t        t        |          i ddddddg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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d0dd1di d2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAddBdi dCddDddEddFddGddHddIddJddKddLddMddNddOddPddQddRddSdi dTddUddVddWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcdddddddddddddddddddedfdgdhdidjdkdldmdmdndodpgdqdrdsdtdudududududududududududududududvii dwdudxdudydudzdud{dud|dud}dud~duddudduddudduddudduddudduddududududdudududududududududududdududdzduidududududddndd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dddddddddddddddddddddddddddd ddddddd
id	d d dd d dddddtdd| j	                  d      | j	                  d      | j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      gg| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      ggddidt
        dddddddddddddddidi dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        t        t        t        t        t        dӜt        t        t         t        t        t        t        t        t        dԜ	d՜      S )Nidr+   nameCoinlist	countriesUSversionv1	rateLimiti,  	certifiedFprohasCORSspotTmarginswapfutureoption	addMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateOrdercreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderdeposit	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeefetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL3OrderBookfetchLedgerfetchLeveragefetchLeverageTiersfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTradingLimitsfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransfers)fetchWithdrawalfetchWithdrawalsfetchWithdrawalWhitelistreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModesignIntransferwithdrawws
timeframes1m5m30m)r   r   r   urlszwhttps://github-production-user-asset-6210df.s3.amazonaws.com/1294454/281108917-eff2ae1d-ce8a-4b2a-950d-8678b12da965.jpgzhttps://trade-api.coinlist.co)publicprivatezhttps://coinlist.cozhttps://trade-docs.coinlist.cozhttps://coinlist.co/fees)logoapiwwwdocfeesr   get   )z
v1/symbolszv1/symbols/summaryzv1/symbols/{symbol}zv1/symbols/{symbol}/summaryzv1/symbols/{symbol}/bookzv1/symbols/{symbol}/quotezv1/symbols/{symbol}/candleszv1/symbols/{symbol}/auctionsz+v1/symbols/{symbol}/auctions/{auction_code}zv1/timez	v1/assetszv1/leaderboardzv1/affiliate/{competition_code}zv1/competition/{competition_id}zv1/symbols/{symbol}/fundingzv1/feeszv1/accountszv1/accounts/{trader_id}zv1/accounts/{trader_id}/aliaszv1/accounts/{trader_id}/ledgerzv1/accounts/{trader_id}/walletsz%v1/accounts/{trader_id}/wallet-ledgerz&v1/accounts/{trader_id}/ledger-summaryv1/keyszv1/fills	v1/ordersv1/orders/{order_id}
v1/reportszv1/balanceszv1/transferszv1/userz
v1/credits)zv1/positions$v1/accounts/{trader_id}/competitionszv1/closedPositions)r   r   zv1/orders/cancel-all-afterr   zv1/transfers/to-walletzv1/transfers/from-walletzv1/transfers/internal-transferzv1/transfers/withdrawal-requestv1/orders/bulkr   z*v1/accounts/{trader_id}/create-competition)r   r   )zv1/keys/{key}r   r   r   )r   postpatchputdeletefeatures)lastmarkindex)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventioniceberg  i )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   )	sandboxrF   createOrdersrp   ru   rt   rx   rV   rq   )linearinverse)defaultr<   r=   r   tradingz0.0045z0.0025020000z0.00350000100000z0.002500000z0.00187500001000000z0.00162500000z0.00135000000z0.001210000000z0.00150000000z0.0005	100000000z0.0015z0.0008z0.0007z0.0006z0.0000z0.00)takermaker)feeSide	tierBased
percentager   r   tiersprecisionModeoptionsaccountsByTypefunding)zCoinList ProzCoinList Pro trading accountPror7   trader   CoinListzCoinList walletWalletwalletfundr   
exceptionsAUTH_SIG_INVALIDDENIED_MAINTENANCEORDER_REJECT_BAD_STATUSORDER_REJECT_INVALID_POST_ONLYORDER_REJECT_INVALID_CLOSE_ONLYORDER_REJECT_POST_ONLY_REQUIREDORDER_REJECT_FROZEN_ORDER-ORDER_REJECT_LIMIT_PRICE_PROTECTION_VIOLATIONORDER_REJECT_CLOSEDORDER_REJECT_MAX_ORDERSORDER_REJECT_NOT_FOUNDORDER_REJECT_PARSE_ERRORORDER_REJECT_PRICE_INVALIDORDER_REJECT_QUANTITY_ZEROORDER_REJECT_TOKEN_LIMITORDER_REJECT_TOKEN_LIMIT_OTHERORDER_REJECT_SELF_TRADE)!ORDER_VALIDATE_BAD_SIZE_ALIGNMENT!ORDER_VALIDATE_BAD_TICK_ALIGNMENTORDER_VALIDATE_SYMBOL_NOT_FOUND&TRANSFERS_WITHDRAWAL_REQUEST_TOO_LARGEWITHDRAWAL_REQUEST_NOT_ALLOWED)	z8A destinationAddress is required for non-USD withdrawalsz6fails to match the JsonSchema date-time format patternzis requiredzmust be a stringzmust be a valid GUIDz must be greater than or equal tozmust be less than or equal tozmust be one ofzSymbol not found)exactbroad)deep_extendsuperr+   describeparse_numberr(   r   r'   r$   r&   r    r%   r"   r!   r   r#   r   )self	__class__s    G/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/coinlist.pyr  zcoinlist.describe   s   h > @ vC
*vC
JvC
 $vC
 t	vC

 vC
 vC
 5vC
  ddd %d 	d
 %d %d Ud "4d td d $Ud  d 'd td &td  (!d" '#d$ (%d& "4'd( 5)d* T+d,  -d. /d0  1d2 &u3d4 +E5d6 )%7d8 &t9d: #E;d< $T=d> '?d@ (AdB "4CdD EdF &uGdH (IdJ 1%KdL  MdN +DOdP *5QdR +ESdT &uUdV #DWdX *5YdZ $U[d\ "5]d^ *5_d` +Eadb #Ecdd tedf  gdh %eidj +Ekdl mdn !%odp  qdr dsdt +Eudv !%wdx "4ydz d{d| !$}d~ "5d@ tAdB #DCdD  EdF 'GdH $UIdJ !%KdL *5MdN (OdP %eQdR )%SdT uUdV tWdX YdZ T[d\ t]d^ "5_d` #Dadb %ecdd &uedf 'gdh $Tidj !$kdl $)$),1 %$)',$"!&#(  GdvC
Z [vC
d  R=> -4 3evC
| &'.//07845567889GH#$%&*+;<;<78(!1%q 21 8	
 9! :1 @ A! "1 #A $Q / %a &q '  "1!" %a#$ )*@A./). $%%&67&'2345:;;<*+@AFG 12*+
 8 *+%&01*+	W1)F}vC
J $&+(,$($(%)-
 -2).+06:#(#("&#(	( #($($)+027/3#(1$4 %)&+!$$*%+*/& ',#($)*/	# ',!$#($)*/( ',!$$*%+#($)*/$ ',!$$*,0%+#($)*/	*  #IGR ##
 ##[QKvC
n $!%"&!..x8!..x8 "..s3T5F5Fx5PQ!..w79J9J79ST!..w79J9J89TU!..x8$:K:KG:TU!..x8$:K:KH:UV!..x8$:K:KH:UV!..y94;L;LX;VW!..y94;L;LX;VW!..y94;L;LX;VW!..z:D<M<Mg<VW!..z:D<M<Mh<WX!..{;T=N=Nx=XY" "..s3T5F5Fx5PQ!..w79J9J89TU!..w79J9J89TU!..x8$:K:KG:TU!..x8$:K:KH:UV!..x8$:K:KH:UV!..y94;L;LW;UV!..y94;L;LX;VW!..y94;L;LX;VW!..z:D<M<Mh<WX!..z:D<M<Mh<WX!..{;T=N=Nv=VW"$&ovC
|	 Y}	vC
@
  $-4=$$&( )'0''%(#A
vC
`
 &(;(- .| 5l	
 6| 6| 0 D\ *< .z -m /
 1, 1, /0A  5l!" .|#$ :F9E7@>O6F-2 Q_NX#4(2,68B5?&0(1
5%a
vC
 v v	    c                 |    t        |t              r,t        |      }t        t	        j
                  |dz              S y)N   r   )
isinstancelistlenintmathceil)r  r   methodpathparamsconfiglengths          r  calculate_rate_limiter_costz$coinlist.calculate_rate_limiter_cost  s0    fd#[Ftyy!,--r  c                 j    | j                  |      }| j                  |d      }| j                  |      S )a_  
        fetches the current integer timestamp in milliseconds from the exchange server

        https://trade-docs.coinlist.co/?javascript--nodejs#get-system-time

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        iso)publicGetV1Timesafe_string	parse8601)r  r  responsestrings       r  
fetch_timezcoinlist.fetch_time  s7     ''/ !!(E2~~f%%r  c                    | j                  |      }| j                  |dg       }i }t        dt        |            D ]  }||   }| j	                  |d      }| j                  |      }|dk(  }	| j                  |dd      }
| j                  ||||d|
|
d| j                  | j                  | j	                  |d                  ddd	| j                  |d
      dd	di |	rdndd      ||<    |S )a(  
        fetches all available currencies on an exchange

        https://trade-docs.coinlist.co/?javascript--nodejs#list-supported-assets

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        assetsr   assetUSDis_transferableFNdecimal_placesminmaxmin_withdrawal)amountr   fiatcrypto)r.   coder/   infoactiverL   r   fee	precisionlimitsnetworkstype)publicGetV1Assets
safe_valueranger  r&  safe_currency_code	safe_boolsafe_currency_structurer  parse_precisionsafe_number)r  r  r(  
currenciesresulticurrencyr.   r8  isFiatisTransferables              r  fetch_currencieszcoinlist.fetch_currencies  s'    ))&1. __Xx<
q#j/* 	A!!}H!!(G4B**2.DU]F!^^H6GON77 )*!..t/C/CDDTDTU]_oDp/qr  $#
  $//:JK#!	 "(h+9 F4L	: r  c                 l    | j                  |      }| j                  |dg       }| j                  |      S )a!  
        retrieves data on all markets for coinlist

        https://trade-docs.coinlist.co/?javascript--nodejs#list-symbols

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        symbols)publicGetV1SymbolsrA  parse_markets)r  r  r(  marketss       r  fetch_marketszcoinlist.fetch_markets  s9     **624 //(Ir:!!'**r  marketc                    | j                  |d      dk(  }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |      }| j                  |      }| j                  |d      }| j                  |d      }	| j                  |d      }
d }d }d }d }d }|d	z   |z   }|r!| j                  d
      }d}d}|}|}|dz   |z   }|rdn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 | j                  |      | j                  |	      dd d dd d dd d dd d dd| j                  |
      |d 
S )!Nr?  z	perp-swapsymbolbase_currencyquote_currencyminimum_size_incrementminimum_price_increment	list_time/1TF:r<   r:   r.   basequotesettlebaseIdquoteIdsettleIdr;   r=   r>   r:  contractr   )r5  pricer1  )r   r5  rg  cost)
r   contractSizeexpiryexpiryDatetimestrike
optionTyper<  r=  createdr9  )r&  rC  r  r'  )r  rU  isSwapr.   rc  rd  r`  ra  amountPrecisionpricePrecisionrn  	settledIdsettledr   r   ri  rW  r?  s                     r  parse_marketzcoinlist.parse_market  si   p !!&&1[@fh/!!&/:""6+;<&&v.''0**63KL))&2KL""6;7	e#,,S1LFGIGc\E)FvV0
"0
f0
 D0
 U	0

 g0
 f0
 w0
 	0
 D0
 J0
 e0
 F0
 e0
 e0
 d0
  !0
" f#0
$ ("++O<**>:  
  
  
  $ ~~g._0
 0	
r  NrP  c                     | j                          i }| j                  | j                  ||            }| j                  |||      S )a   
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://trade-docs.coinlist.co/?javascript--nodejs#get-symbol-summaries

        :param str[] [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>`
        )load_marketspublicGetV1SymbolsSummaryextendparse_tickers)r  rP  r  requesttickerss        r  fetch_tickerszcoinlist.fetch_tickers  sG     	00Wf1MN. !!'7F;;r  rW  c                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  ||      S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://trade-docs.coinlist.co/?javascript--nodejs#get-market-summary

        :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>`
        rW  r.   )rv  rU  publicGetV1SymbolsSymbolSummaryrx  parse_ticker)r  rW  r  rU  rz  tickers         r  fetch_tickerzcoinlist.fetch_ticker  s`     	V$fTl
 55dkk'66RS*   00r  r  c                 B   | j                  |di       }| j                  | j                  |d            }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }	| j                  |d      }
| j                  |d	      }| j                  |d
      }| j                  i d|d   d|d| j	                  |      dd d|	d|
d|d|dd d|dd dd dd dd d|dd d|||d|      S )N
last_tradelogicalTimehighest_bid
lowest_askvolume_base_24hvolume_quote_24hhighest_price_24hlowest_price_24h
last_priceprice_change_percent_24hrW  	timestampdatetimeopenhighlowclosebid	bidVolumeask	askVolumevwappreviousClosechanger   average
baseVolume)quoteVolumer9  )rA  r'  r&  safe_tickeriso8601)r  r  rU  	lastTrader  r  r  r  r  r  r  r  
changePcnts                r  r  zcoinlist.parse_ticker  s   * OOFL"=	NN4#3#3I}#MN	v}5v|4%%f.?@
&&v/AB(;<v'9:  6%%f.HI
 !
fX&!
!
 Y/!
 D	!

 D!
 3!
 U!
 3!
 !
 3!
 !
 D!
 T!
 d!
 *!
  t!!
" *#!
$ ''!
( ) 	r  r   c                 
   | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  | j                  |d            }| j                  |||      }d|d<   |S )a]  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://trade-docs.coinlist.co/?javascript--nodejs#get-order-book-level-2

        :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(default 100, max 200)
        :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
        rW  r.   logical_timeNnonce)rv  rU  publicGetV1SymbolsSymbolBookrx  r'  r&  parse_order_book)	r  rW  r   r  rU  rz  r(  r  	orderbooks	            r  fetch_order_bookzcoinlist.fetch_order_book  s     	V$fTl
 44T[[&5QR$ ~~d&6&6x&PQ))(FLI	!	'r  r   sincec                    | j                          | j                  |      }| j                  | j                  |      }|d   |d}|t| j	                  |      |d<   |<| j                  |      dz  }	| j	                  | j                  ||	|z              |d<   n"| j	                  | j                               |d<   | j                  |d      }
|
'| j                  |dg      }| j	                  |
      |d<   | j                  | j                  ||            }| j                  |dg       }| j                  |||||      S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://trade-docs.coinlist.co/?javascript--nodejs#get-candles

        :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 entries for
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r.   )rW  granularity
start_timei  end_timeuntilcandles)rv  rU  r&  r   r  parse_timeframesummillisecondssafe_integeromitpublicGetV1SymbolsSymbolCandlesrx  	safe_listparse_ohlcvs)r  rW  	timeframer  r   r  rU  r  rz  durationr  r(  r  s                r  fetch_ohlcvzcoinlist.fetch_ohlcv?  s?    	V$&&t	BTl&
 $(LL$7GL! //	:TA&*ll488E8uCU3V&W
#&*ll43D3D3F&G
#!!&'2YYvy1F"&,,u"5GJ77GV8TU2 ..9b9  &)UEJJr  c           	          | j                  | j                  |d            | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )Nr   r   r           )r'  r&  rG  )r  ohlcvrU  s      r  parse_ohlcvzcoinlist.parse_ohlcv{  sw     NN4++E156UA&UA&UA&UA&UA&
 	
r  c                    | j                          | j                  |      }d|d   i}|| j                  |      |d<   |t        |d      |d<   | j	                  |d      }|'| j                  |dg      }| j                  |      |d<   | j                  | j                  ||            }| j                  |dg       }	| j                  |	|||      S )	a  
        get the list of most recent trades for a particular symbol

        https://trade-docs.coinlist.co/?javascript--nodejs#list-auctions

        :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(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        rW  r.   r  r   countr  r  auctions)
rv  rU  r  r2  r  r   publicGetV1SymbolsSymbolAuctionsrx  r  parse_trades)
r  rW  r  r   r  rU  rz  r  r(  r  s
             r  fetch_tradeszcoinlist.fetch_trades  s     	V$fTl
 $(LL$7GL!"5#GG!!&'2YYvy1F"&,,u"5GJ88Wf9UV2 >>(J;  65%@@r  r   c                    | j                  |d      }| j                  ||      }|d   }| j                  |d      }| j                  | j                  |d            }| j                  |d      }| j                  |dd      }| j                  |d      }	d }
d }| j                  |d      }|Ht	        j
                  |d	      }|rd
}t	        j                  |      }nd}|| j                  |d      d}
n-| j                  |d      }t	        j
                  |d	      rd}nd
}| j                  |d      }| j                  ||	|| j                  |      |d ||||d |
|d|      S )NrW  auction_coder  rg  volumequantityorder_idr;  r   sellbuyfee_currencyrh  rK  	imbalancefee_type)r.   orderr  r  rW  r?  sidetakerOrMakerrg  r5  rh  r;  r9  )	r&  safe_marketr'  safe_string_2r)   	string_lt
string_neg
safe_trader  )r  r   rU  marketIdrW  r.   r  priceStringamountStringr  r;  r  feeCostamountIsNegativer  r  s                   r  parse_tradezcoinlist.parse_trade  s   4 ##E84!!(F3!e^4NN4#3#3E>#JK	&&ug6))%:F  
3""5%0&00sC&11,? ,,UNCC
 ((<I  C0''z:"Y/( " 
  	r  c           
      j   | j                          | j                  |      }| j                  |di       }i }t        |j	                               }t        dt        |            D ]  }||   }| j                  ||i       }| j                  |      }	| j                  |di       }
| j                  |
di       }|j                  d      }t        dt        |            D ]Q  }||   }| j                  |      }|d   }i }|||<   ||| j                  |d      | j                  |d      d	d	|	d
||<   S  |S )aW  
        fetch the trading fees for multiple markets

        https://trade-docs.coinlist.co/?javascript--nodejs#list-fees

        :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
        fees_by_symbolsr   r`  r   ,rW  r   r   T)r9  rW  r   r   r   r   r   )rv  privateGetV1FeesrA  r  keysrB  r  parse_fee_tierssplitr  rG  )r  r  r(  r   rI  groupsOfSymbolsrJ  groupfeeTiersr   	firstTierfirstTierFeesidsjr.   rU  rW  r9  s                     r  fetch_trading_feeszcoinlist.fetch_trading_fees  sP    	((0r x):B?tyy{+q#o./ 	A#A&EtUB7H((2E&"=I OOIvrBM++c"C1c#h' V))"-)&U $!--mWE!--mWE"&!%""v	, r  c                 z   g }g }t        |j                               }t        |      }|dkD  rt        d|      D ]  }||   }| j	                  ||i       }	| j	                  |	di       }
| j                  |
d      }| j                  |
d      }|j                  d | j                  |      g       |j                  d | j                  |      g        | j                  |dd      }| j                  |dd      }| j                  |dg       }| j                  | di       }| j                  |di       }| j                  |di       }| j                  |dg       }| j                  |dg       }t        |      }t        |      }||k(  r2|dkD  r-t        d|      D ]  }||   d   ||   d<   ||   d   ||   d<     ||d	S )
Nr   r   r   r   r   Tr   r   )r   r   )r  r  r  rB  rA  r&  appendr  sort_by	safe_dictr  )r  r  rU  	takerFees	makerFeesr  
keysLengthrJ  keytiertierFeesr   r   r  exchangeFeesexchangeFeesTradingexchangeFeesTradingTiersexchangeFeesTradingTiersTakerexchangeFeesTradingTiersMaker#exchangeFeesTradingTiersTakerLengthfirstTierLengths                        r  r  zcoinlist.parse_fee_tiersl  s   f 		HMMO$Y
>1j) C1gxb9??4<((7;((7;  $(9(9%(@!AB  $(9(9%(@!ABC Y48IY48Iy!R8I>>$;L"&..y""M'+~~6I7TV'W$,0NN;SU\^`,a),0NN;SU\^`,a)256S2T/!)nOAAZ[H[q*- JA&CA&Fq&IIaLO&CA&Fq&IIaLOJ 
 	
r  c                     | j                          | j                  |      }| j                  |dg       }| j                  ||      S )aj  
        fetch all the accounts associated with a profile

        https://trade-docs.coinlist.co/?javascript--nodejs#list-accounts

        :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
        accounts)rv  privateGetV1AccountsrA  parse_accounts)r  r  r(  r   s       r  fetch_accountszcoinlist.fetch_accounts  sG     	,,V4 ??8Z<""8V44r  c                 0    | j                  |d      dd |dS )N	trader_idr   )r.   r?  r8  r9  r&  )r  accounts     r  parse_accountzcoinlist.parse_account  s'     ""7K8	
 	
r  c                 f    | j                          | j                  |      }| j                  |      S )al  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://trade-docs.coinlist.co/?javascript--nodejs#list-balances

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        )rv  privateGetV1Balancesparse_balance)r  r  r(  s      r  fetch_balancezcoinlist.fetch_balance  s1     	,,V4!!(++r  c                    |d d d}| j                  |di       }| j                  |di       }t        |j                               }t        dt	        |            D ]X  }||   }| j                  |      }| j                         }	| j                  ||      |	d<   | j                  ||d      |	d<   |	||<   Z | j                  |      S )N)r9  r  r  asset_balancesasset_holdsr   totalr   used)	rA  r  r  rB  r  rC  r  r&  safe_balance)
r  r(  rI  totalBalancesusedBalancescurrencyIdsrJ  
currencyIdr8  r  s
             r  r  zcoinlist.parse_balance  s     

 2BBGxC=--/0q#k*+ 	#A$QJ**:6DllnG#//zJGG"..|ZMGFO"F4L	#   ((r  c                    | j                          i }d}|| j                  |      }|d   |d<   || j                  |      |d<   |||d<   | j                  |d      }|'| j	                  |dg      }| j                  |      |d<   | j                  | j                  ||            }| j                  |dg       }	| j                  |	|||      S )	ab  
        fetch all trades made by the user

        https://trade-docs.coinlist.co/?javascript--nodejs#list-fills

        :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(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nr.   rW  r  r  r  r  fills)	rv  rU  r  r  r  privateGetV1Fillsrx  r  r  )
r  rW  r  r   r  rz  rU  r  r(  r  s
             r  fetch_my_tradeszcoinlist.fetch_my_trades  s     	[[(F &tGH$(LL$7GL!$GG!!&'2YYvy1F"&,,u"5GJ))$++gv*FG: x"5  u==r  r.   c           	      R    d|i}| j                  |||| j                  ||            S )a  
        fetch all the trades made from a single order

        https://trade-docs.coinlist.co/?javascript--nodejs#list-fills

        :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>`
        r  )r  rx  )r  r.   rW  r  r   r  rz  s          r  fetch_order_tradeszcoinlist.fetch_order_tradesL  s4     
 ##FE5$++gv:VWWr  c                    | j                          | j                  |d      }|g d}d|i}d}|| j                  |      }|d   |d<   || j                  |      |d<   |||d<   | j	                  |d      }|'| j                  |dg      }| j                  |      |d	<   | j                  | j                  ||            }	| j                  |	d
g       }
| j                  |
|||      S )aX  
        fetches information on multiple orders made by the user

        https://trade-docs.coinlist.co/?javascript--nodejs#list-orders

        :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(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for
        :param string|str[] [params.status]: the status of the order - 'accepted', 'done', 'canceled', 'rejected', 'pending'(default ['accepted', 'done', 'canceled', 'rejected', 'pending'])
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        statusN)accepteddonecanceledrejectedpendingr.   rW  r  r  r  r  orders)
rv  r&  rU  r  r  r  privateGetV1Ordersrx  r  parse_orders)r  rW  r  r   r  r  rz  rU  r  r(  r$  s              r  fetch_orderszcoinlist.fetch_orders^  s    	!!&(3>LFf
 [[(F &tGH$(LL$7GL!$GG!!&'2YYvy1F"&,,u"5GJ**4;;w+GH6 (B7  >>r  c                     | j                          d|i}| j                  | j                  ||            }| j                  |      S )a  
        fetches information on an order made by the user

        https://trade-docs.coinlist.co/?javascript--nodejs#get-specific-order-by-id

        :param int|str id: order id
        :param str symbol: not used by coinlist fetchOrder()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r  )rv  privateGetV1OrdersOrderIdrx  parse_orderr  r.   rW  r  rz  r(  s         r  fetch_orderzcoinlist.fetch_order  sL     	
 11$++gv2NO2 ))r  c           	      r    | j                          ddi}| j                  |||| j                  ||            S )as  
        fetch all unfilled currently open orders

        https://trade-docs.coinlist.co/?javascript--nodejs#list-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 order structures to retrieve(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r  r  rv  r'  rx  r  rW  r  r   r  rz  s         r  fetch_open_orderszcoinlist.fetch_open_orders  @     	j
   t{{7F7STTr  c           	      r    | j                          ddi}| j                  |||| j                  ||            S )a  
        fetches information on multiple closed orders made by the user

        https://trade-docs.coinlist.co/?javascript--nodejs#list-orders

        :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 closed order structures to retrieve(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r  r   r.  r/  s         r  fetch_closed_orderszcoinlist.fetch_closed_orders  s@     	f
   t{{7F7STTr  c           	      r    | j                          ddi}| j                  |||| j                  ||            S )a  
        fetches information on multiple canceled orders made by the user

        https://trade-docs.coinlist.co/?javascript--nodejs#list-orders

        :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 canceled order structures to retrieve(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for
        :returns dict: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r  r!  r.  r/  s         r  fetch_canceled_orderszcoinlist.fetch_canceled_orders  r1  r  c                     | j                          d}i }|| j                  |      }|d   |d<   | j                  | j                  ||            }|g}| j	                  ||      S )ag  
        cancel open orders of market

        https://trade-docs.coinlist.co/?javascript--nodejs#cancel-all-orders

        :param str symbol: unified market symbol
        :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.   rW  )rv  rU  privateDeleteV1Ordersrx  r&  )r  rW  r  rU  rz  r(  r$  s          r  cancel_all_orderszcoinlist.cancel_all_orders   ss     	[[(F &tGH--dkk'6.JK   00r  c                     | j                          d|i}| j                  | j                  ||            }| j                  |      S )a  
        cancels an open order

        https://trade-docs.coinlist.co/?javascript--nodejs#cancel-specific-order-by-id

        :param str id: order id
        :param str symbol: not used by coinlist cancelOrder()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r  )rv  privateDeleteV1OrdersOrderIdrx  r*  r+  s         r  cancel_orderzcoinlist.cancel_order  sL     	
 44T[[&5QR ))r  c           
      @   | j                          |}| j                  |      }| j                  |dg       }g }| j                  |d      }t	        dt        |            D ];  }|j                  | j                  ||   ||   | j                  |      d             = |S )a  
        cancel multiple orders

        https://trade-docs.coinlist.co/?javascript--nodejs#cancel-specific-orders

        :param str[] ids: order ids
        :param str symbol: not used by coinlist cancelOrders()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        	order_idsr  r   )r9  r.   lastUpdateTimestamp)	rv  privateDeleteV1OrdersBulkr  r&  rB  r  r  
safe_orderr'  )	r  r  rW  r  r(  orderIdsr$  r  rJ  s	            r  cancel_orderszcoinlist.cancel_orders3  s     	11&9 >>(K<##Hk:q#h-( 	AMM$// qk'+~~h'?+  	 r  r?  r  r5  rg  c                 2   | j                          | j                  |      }|d   ||| j                  ||      d}d}	|dk(  s
|dk(  s|dk(  r6|t        | j                  dz   |z   d	z         | j                  ||      |d
<   nd}	d}
| j                  |	d|      \  }
}|
rd|d<   | j                  |g d      }|?| j                  |g d      }| j                  ||      |d<   |dk(  rd|d<   n7|dk(  r2d|d<   n,|dk(  s|dk(  s
|dk(  s|dk(  rt        | j                  dz         | j                  |dd      }|||d<   | j                  |ddg      }| j                  | j                  ||            }| j                  |di       }| j                  ||      S )ai  
        create a trade order

        https://trade-docs.coinlist.co/?javascript--nodejs#create-new-order

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or 'stop_market' or 'stop_limit' or 'take_market' or 'take_limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately(default False)
        :param float [params.triggerPrice]: only for the 'stop_market', 'stop_limit', 'take_market' or 'take_limit' orders(the price at which an order is triggered)
        :param str [params.clientOrderId]: client order id(default None)
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r.   )rW  r?  r  sizeFr   
stop_limit
take_limitNz/ createOrder() requires a price argument for a z orderrg  T	post_only)r   trigger_price	stopPrice
stop_price)r   rH  rI  rJ  rU  stop_marketr?  take_marketzU createOrder() requires a triggerPrice parameter for stop-loss and take-profit ordersclientOrderId	client_idr  )rv  rU  amount_to_precisionr   r.   price_to_precisionhandle_post_onlysafe_number_nr  r  privatePostV1Ordersrx  r  r*  )r  rW  r?  r  r5  rg  r  rU  rz  isMarketpostOnlyr   rM  r(  r  s                  r  create_orderzcoinlist.create_orderU  s   " 	V$Tl,,VV<	
 GO!54<;O}'2c(cfj(jmu(uvv#66vuEGGH005&I&#'GK ))&2no#YYv'UVF$($;$;FL$QGL!x"/".m#)=4=CX^bfr^r#DGG  /F  %F  G  G**6?KP$#0GK YYv'EFF++DKK,HI x"5v..r  c                 :   | j                          |t        | j                  dz         | j                  |      }|||| j	                  ||      d}	|| j                  ||      |	d<   | j                  | j                  |	|            }
| j                  |
|      S )a  
        create a trade order

        https://trade-docs.coinlist.co/?javascript--nodejs#modify-existing-order

        :param str id: order id
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or 'stop_market' or 'stop_limit' or 'take_market' or 'take_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>`
        z( editOrder() requires an amount argument)r  r?  r  rD  rg  )	rv  r   r.   rU  rO  rP  privatePatchV1OrdersOrderIdrx  r*  )r  r.   rW  r?  r  r5  rg  r  rU  rz  r(  s              r  
edit_orderzcoinlist.edit_order  s     	>#DGG.X$XYYV$,,VV<	
 #66vuEGG33DKK4PQ&11r  r  c                 |   | j                  |d      }| j                  |d      }| j                  ||      }| j                  |d      }| j                  |dd      }|| j                  |d      }| j                  |      }| j	                  | j                  |d            }| j                  | j                  |d            }	| j                  |d	      }
| j                  |d
      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }d }|	|d   |d d}| j                  i d|d|d|d| j                  |      dd d|d|d   d|	ddd	|
d
|d|d|d|dd d|dd |d ||d|      S ) Nr  rW  rN  
created_atepoch_timestampr  r  r?  r  rg  rJ  average_fill_pricerD  size_filled	fill_feesrG  ra  )rK  rh  rater.   rM  r  lastTradeTimestampr   GTCr   r  r5  rh  filled	remaining)r;  tradesr9  rU  )	r&  r  r  r'  parse_order_statusparse_order_typerA  r@  r  )r  r  rU  r.   r  rM  timestampStringr  r  r?  r  rg  r   r  r5  rc  r  rU  r;  s                      r  r*  zcoinlist.parse_order  sv   T eZ0##E84!!(F3((<,,ULBST""..ukBONN?3	(()9)9%)JK$$T%5%5eV%DEv.  0''|<""5*>?!!%0!!%7""5+6??5+6"7OC
   
" 
] 
  
 Y/	 

 !$ 
 f 
 fX& 
 D 
 5 
 D 
 U 
 L 
 w 
 f 
 D 
  f! 
" # 
$  + 
, - 	r  r  c                 8    dddddd}| j                  |||      S )Nr  r"  closedr!  )r#  r  r"  r   r!  r  r  r  statusess      r  rf  zcoinlist.parse_order_status2  s/    ""
 &&99r  c                 :    ddddddd}| j                  |||      S )NrU  r   )rU  r   rK  rE  rL  rF  r  rk  s      r  rg  zcoinlist.parse_order_type<  s2    #!#!
 &&99r  r8  fromAccount	toAccountc                 ,   | j                          | j                  |      }|d   | j                  ||      d}| j                  | j                  di       }| j                  |||      }	| j                  |||      }
d}|	dk(  r'|
dk(  r"| j                  | j                  ||            }nW|	dk(  r'|
dk(  r"| j                  | j                  ||            }n+|	|d<   |
|d<   | j                  | j                  ||            }| j                  ||      }|S )	a  
        transfer currency internally between wallets on the same account

        https://trade-docs.coinlist.co/?javascript--nodejs#transfer-funds-between-entities
        https://trade-docs.coinlist.co/?javascript--nodejs#transfer-funds-from-wallet-to-pro
        https://trade-docs.coinlist.co/?javascript--nodejs#transfer-funds-from-pro-to-wallet

        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from
        :param str toAccount: account to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        r.   )r-  r5  r   Nr   r   from_trader_idto_trader_id)rv  rK  currency_to_precisionrA  r   r&   privatePostV1TransfersFromWalletrx  privatePostV1TransfersToWallet&privatePostV1TransfersInternalTransferparse_transfer)r  r8  r5  rn  ro  r  rK  rz  r   fromAcctoAccr(  r   s                r  r   zcoinlist.transferG  s"    	==&d^00v>
 7GL"">;L  IFy u	'9<<T[[RX=YZH"));::4;;wPV;WXH(/G$%&+GN#BB4;;wX^C_`H &&x:r  c                    | j                          d}|| j                  |      }i }|| j                  |      |d<   |||d<   | j                  |d      }|'| j	                  |dg      }| j                  |      |d<   | j                  | j                  ||            }| j                  |dg       }	| j                  |	|||      S )a  
        fetch a history of internal transfers between CoinList.co and CoinList Pro. It does not return external deposits or withdrawals

        https://trade-docs.coinlist.co/?javascript--nodejs#list-transfers

        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch transfers for
        :param int [limit]: the maximum number of transfer structures to retrieve(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for
        :returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
        Nr  r  r  r  	transfers)	rv  rK  r  r  r  privateGetV1Transfersrx  r  parse_transfers)
r  r8  r  r   r  rK  rz  r  r(  r{  s
             r  fetch_transferszcoinlist.fetch_transfersy  s     	}}T*H$(LL$7GL!$GG!!&'2YYvy1F"&,,u"5GJ--dkk'6.JK. NN8["=	##IxFFr  r   rK  c                    | j                  |d      }| j                  |d      }| j                  |      }| j                  |d      }| j                  |d      }d }d }	d }
|Gt        j                  |d      }|rd}d}	t        j                  |      }nd}d}	| j                  |      }
|| j                  |d      || j                  |      | j                  ||      |
||	| j                  |      d		S )
Nr-  confirmed_atr  r5  r   r   r   transfer_id)	r9  r.   r  r  rK  r5  rn  ro  r  )	r&  r'  r)   r  r  r  r  rC  parse_transfer_status)r  r   rK  r  confirmedAt
timetstampr  r  rn  ro  r5  r  s               r  rw  zcoinlist.parse_transfer  s   2 %%h8
&&x@^^K0
!!(H5''(;	#&00sC'%	&11,?'%	&&|4F""8];#Z0//
HE&"008

 
	
r  c                 0    ddi}| j                  |||      S )N	confirmedokr  rk  s      r  r  zcoinlist.parse_transfer_status  s%    
 &&99r  c                    |t        | j                  dz         | j                  |dd      }|t        | j                  dz         | j                          | j	                  |      }|d   |d}|||d<   | j                  |ddg      }| j                  | j                  ||            }| j                  ||||      S )a  
        fetch history of deposits and withdrawals from external wallets and between CoinList Pro trading account and CoinList wallet

        https://trade-docs.coinlist.co/?javascript--nodejs#get-coinlist-wallet-ledger

        :param str [code]: unified currency code for the currency of the deposit/withdrawals
        :param int [since]: timestamp in ms of the earliest deposit/withdrawal
        :param int [limit]: max number of deposit/withdrawals to return(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        z4 fetchDepositsWithdrawals() requires a code argumentr  traderIdzF fetchDepositsWithdrawals() requires a traderId argument in the paramsr.   )r-  r  r  )	r   r.   r  rv  rK  r  (privateGetV1AccountsTraderIdWalletLedgerrx  parse_transactions)	r  r8  r  r   r  r  rK  rz  r(  s	            r  fetch_deposits_withdrawalsz#coinlist.fetch_deposits_withdrawals  s     <#DGG.d$dee%%fk:F#DGG.v$vww==&d^!
 $GG6K#<=@@WV\A]^\ &&x5%HHr  addressc                    | j                          | j                  |      }|d   | j                  ||      |d}| j                  | j	                  ||            }| j                  |di       }	| j                  |	|      S )aF  
        request a withdrawal from CoinList wallet.(Disabled by default. Contact CoinList to apply for an exception.)

        https://trade-docs.coinlist.co/?javascript--nodejs#request-withdrawal-from-wallet

        :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>`
        r.   )r-  r5  destination_addressdata)rv  rK  rs  'privatePostV1TransfersWithdrawalRequestrx  r  parse_transaction)
r  r8  r5  r  tagr  rK  rz  r(  r  s
             r  r   zcoinlist.withdraw4  s     	==&d^00v>#*

 ??GU[@\] ~~h3%%dH55r  transactionc                    | j                  |d      }| j                  ||      }| j                  |dd      }| j                  |d      }| j	                  | j                  |d            }| j                  |dd       }|d}n| j                  |      }d }	| j                  |d      }
|
|
|d	}	i d
|d|dd d|d| j                  |      dd dd dd dd dd dd dd d|d|d|dd dd |	| j                  |d      d dS )Nr-  r.   r  r5  r[  r?  
withdrawalwithdrawal_fee_amountr  r9  txidr  r  networkaddressFromr  	addressTotagFromr  tagTorK  r  updateddescription)r;  commentinternal)r&  rC  r  rG  r'  parse_transaction_typer  )r  r  rK  r  r8  r.   r5  r  r?  r;  r  s              r  r  zcoinlist.parse_transactionQ  s   & %%k7;
&&z8<T=A!!+x8NN4#3#3K#NO	VT:<D..t4D"";0GH C
K
"
 D
 	

 Y/
 t
 4
 t
 
 t
 4
 T
 D
 f
 
  d!
" t#
$ '']C)
 	
r  c                 4    dddd}| j                  |||      S )NrL   r  r   )CRYPTO_DEPOSITCRYPTO_WITHDRAWALPRO_TRANSFERr  r  r?  typess      r  r  zcoinlist.parse_transaction_type  s)    '!-&

 tT22r  c                    | j                  |dd      }|t        | j                  dz         | j                          d|i}d}|| j	                  |      }|| j                  |      |d<   |||d<   | j                  |d      }|'| j                  |dg      }| j                  |      |d<   | j                  |ddg      }| j                  | j                  ||            }	| j                  |	d	g       }
| j                  |
|||      S )
a  
        fetch the history of changes, actions done by the user or operations that altered the balance of the user

        https://trade-docs.coinlist.co/?javascript--nodejs#get-account-history

        :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 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for
        :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
        r  r  Nz9 fetchLedger() requires a traderId argument in the paramsr  r  r  r  transactions)r  r   r.   rv  rK  r  r  r  "privateGetV1AccountsTraderIdLedgerrx  rA  parse_ledger)r  r8  r  r   r  r  rz  rK  r  r(  ledgers              r  fetch_ledgerzcoinlist.fetch_ledger  s)    %%fk:F#DGG.i$ijj
 }}T*H$(LL$7GL!$GG!!&'2YYvy1F"&,,u"5GJ6K#<=::4;;wPV;WXD >2>  5%@@r  itemc                 &   | j                  |d      }| j                  |d      }| j                  |      }| j                  |d      }t        j                  |d      }d }|rd}t        j                  |      }nd}| j                  |d      }	| j                  |	|      }
| j                  |	|      }| j                  | j                  |d            }| j                  |||| j                  |      |d	d d ||
| j                  |      d d d
d d|      S )Ntransaction_idr[  r5  r   outinr-  r?  r   r  )r9  r.   r  r  	directionr  referenceIdreferenceAccountr?  rK  r5  beforeafterr  r;  )r&  r'  r)   r  r  rC  safe_currencyparse_ledger_entry_typesafe_ledger_entryr  r  )r  r  rK  r.   	createdAtr  r5  r  r  r  r8  r?  s               r  parse_ledger_entryzcoinlist.parse_ledger_entry  s0   N d$45$$T<8	NN9-	!!$1",,VS9	I''/FI%%dG4
&&z8<%%j(;++D,<,<T6,JK%%"Y/"  $''/'
  ! 	r  c                 6    ddddd}| j                  |||      S )Nr   r;  r   )zatomic token swapr;  rL   r  r  r  s      r  r  z coinlist.parse_ledger_entry_typea	  s,    !(!$	
 tT22r  c                     | j                          | j                  |      }|d   st        | j                  dz         d|d   i}| j	                  | j                  ||            }| j                  ||      S )af  
        fetch the current funding rate

        https://trade-docs.coinlist.co/#coinlist-pro-api-Funding-Rates

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
        r<   z0 fetchFundingRate() supports swap contracts onlyrW  r.   )rv  rU  r!   r.   publicGetV1SymbolsSymbolFundingrx  parse_funding_rate)r  rW  r  rU  rz  r(  s         r  fetch_funding_ratezcoinlist.fetch_funding_ratej	  s|     	V$f~DGG&XXYYfTl
 77GV8TU$ &&x88r  c                 n   | j                  |di       }| j                  |di       }| j                  |di       }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }	i d|d| j                  d |      dd d	d d
d dd d| j                  |	      d|	d| j	                  |d      d| j                  |      d|d| j	                  |d      d| j                  |      d|d| j	                  |d      d| j                  |      d|ddiS )Nr   next
indicativefunding_timer  r9  rW  	markPrice
indexPriceinterestRateestimatedSettlePricer  fundingRatefunding_ratefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimeinterval8h)r  r&  safe_symbolr'  rG  )
r  rf  rU  previouscurrentr  previousDatetimecurrentDatetimenextDatetimer  s
             r  r  zcoinlist.parse_funding_rate	  s   $ >>(FB7..626~~hb9++HnE**7NC''n=##Hk:
H
d&&tV4
 
 $	

 D
 #D
 1
 
 4++G^D
  ?
 
 t//nE
 #DNN<$@
 "<
 "4#3#3Hn#M
  '7G(H!
" &'7#
$ %
 	
r  r   GETc                    | j                  || j                  |            }d| j                  ||      z   }| j                  d   |   |z   }	t	        |t
              }
d }|
s| j                  |      }|dk(  r| j                          t        | j                               }||z   |z   }|dk(  s|dk(  s|
r| j                  |      }||z  }n |t        |      dk7  r|d|z   z  }|	d|z   z  }	| j                  | j                  |      | j                  | j                        t         j"                  d      }| j$                  ||d	d
}n|t        |      dk7  r|	d|z   z  }	|	|||dS )Nr]  r   r   POSTPATCHr   ?base64zapplication/json)zCL-ACCESS-KEYzCL-ACCESS-SIGzCL-ACCESS-TIMESTAMPzContent-Type)urlr  bodyheaders)r  extract_paramsimplode_paramsr   r  r  	urlencodecheck_required_credentialsstrsecondsjsonr  hmacencodebase64_to_binarysecrethashlibsha256apiKey)r  r  r   r  r  r  r  rz  endpointr  isBulkqueryr  auth	signatures                  r  signzcoinlist.sign	  so   ))FD$7$7$=>,,T6::iis#h.FD)NN7+E)++-DLLN+Iv%0D& f&7Fyy)"s5zQe#sU{"		$++d"3T5J5J4;;5WY`YgYgiqrI!%!*'0 2	G 3u:?3;CfdwOOr  reasonr  r  r  r  c
                    |`|dk(  rZ|j                  d      dk\  rF|dk(  rA|j                  d      }
| j                  |
d      }t        | j                  dz   |z   dz         y | j                  |d      }| j                  |d	      }|||d
k7  r~|dk7  ry|dk7  rt|dk7  ro| j                  dz   |z   }| j                  |d      }| j                  | j                  d   ||       | j                  | j                  d   ||       t        |      y )Ni  z/orders/r   r  r   z order z, not found(or rejected on the exchange side)r  message_code      200202 messager  r  )	findr  r&  r%   r.   throw_broadly_matched_exceptionr   throw_exactly_matched_exceptionr   )r  r8  r  r  r  r  r  r(  requestHeadersrequestBodypartsorderIdresponseCodemessageCodefeedbackr  s                   r  handle_errorszcoinlist.handle_errors	  s8    #((:"6!";&E/		*-**5!4#DGGi$7'$ADr$rss''(;&&x@#,*BQT[_cf[fmy  ~C  nC  JV  Z_  J_ww}t+H&&x;G001I7T\]001I;X`a))r  )N)R__name__
__module____qualname__r   r  r"  r
   r*  r   rN  r   r   rT  dictrt  r   r   r|  r  r   r  r  r   r  r  r  r  r   r  r  r   r  r  r   r  r  r   r  r  r   r  r  r   r'  r,  r0  r3  r5  r8  r;  rB  r   r   floatr   rV  rY  r*  rf  rg  r   r   r~  r	   rw  r  r   r  r   r  r  r   r  r  r  r   r  r  r  r  r  __classcell__)r  s   @r  r+   r+      s*   w# wr MO  !# &s && ') ?Z ?B $& $+$v, $+L
4 
F 
B 04B #<W #<7 #<J 02 $13 $1f $1L34 3 36 3j :>b %s %3 %Y %N 26DW[df :K# :Kc :KQT :Kkoptku :Kx
 
4 
* 6:UW 4A3 4As 4A# 4A\`af\g 4AlF Fv F FP )+ \{ \|Q
 Q
f %' 54= 50
 $& ,( ,) )> -1tRV_a 9>c 9> 9>C 9>v 9=4^bkm XS X# XS XX[ Xrvw|r} X$ *.Dt\^ =?3 =?c =? =?cghmcn =?~ 26b (*c (*3 (*T /3TXac U U3 Uc Uhlmrhs U& 154VZce U# US UPS Ujnotju U& 37TX\eg UC Us URU U& /32 1 14 37r *s *C *2 04B    D gksu B/3 B/i B/y B/RW B/`c B/H `drv  @B 2S 2# 2Y 2i 2Y\ 2lo 2<y yv y yv: :	: [] 0S 0% 0c 0c 0an 0d +/TPT]_ 2GC 2Gs 2G# 2Gdhivdw 2Gh5
t 5
x 5
= 5
n:C :C : 6:[_hj HIs HI# HIUX HIost  pA HIT DHPR 6S 6% 6# 6Wb 6:9
T 9
X 9
Q\ 9
v3 (,$TZ\ cA cAC cAs cAaefqar cAJft fx f; fP3 68 #9 #9K #9J,
6 ,
[ ,
\ &eBSW P:# s  c TX `c r  r+   )1ccxt.base.exchanger   ccxt.abstract.coinlistr   r  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   ccxt.base.decimal_to_precisionr(   ccxt.base.preciser)   r+    r  r  <module>r     st    ( .   l  l  l  l  l  l  * 0 - . ' & . + ) * ) * 4 %R'x R'r  