
    E#i7U                       S SK Jr  S SKJr  S SKrS SKrS SKJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r   S SK!J"r"  S SK#J$r$  S SK#J%r%  S SK#J&r&  S S	K#J'r'  S S
K#J(r(  S SK#J)r)  S SK#J*r*  S SK#J+r+  S SK#J,r,  S SK#J-r-  S SK#J.r.  S SK#J/r/  S SK#J0r0  S SK#J1r1  S SK#J2r2  S SK#J3r3  S SK4J5r5  S SK6J7r7   " S S\\5      r8g)    )Exchange)ImplicitAPIN)AccountAnyBalances
CurrenciesCurrencyDepositAddressIntLedgerEntryMarketNumOrder	OrderBookOrderRequestCancellationRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateTradeTradingFeeInterfaceTradingFeesTransaction)List)ExchangeError)AuthenticationError)PermissionDenied)AccountNotEnabled)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)DDoSProtection)RateLimitExceeded)OnMaintenance)InvalidNonce)RequestTimeout)	TICK_SIZE)Precisec                   r  ^  \ rS rSrS\4U 4S jjr0 4S\4S jjr0 4S\\	   4S jjr
S0 4S\S\4S jjr0 4S	\S\4S
 jjrSSS0 4S	\S\S\S\\   4S jjrSS0 4S	\S\S\S\\   4S jjrSSS0 4S	\S\S\S\S\\   4
S jjrS0 4S	\S\S\4S jjrS\4S jr0 4S\4S jjrS0 4S\S	\4S jjrS0 4S	\S\S\ S\!S\"4
S jjr#S0 4S	\S\S\ S\!S\"4
S jjr$0 4S\\%   4S jjr&S0 4S	\S\S\ S\!S\"4
S jjr'SS0 4S\S	\S\S\ S\"S\"4S  jjr(S0 4S\S	\S\!S\"4S! jjr)S0 4S	\4S" jjr*S0 4S\S	\4S# jjr+S0 4S$\\   S	\4S% jjr,0 4S\\-   4S& jjr.SSS0 4S	\S\S\S\\   4S' jjr/SSS0 4S	\S\S\4S( jjr0S) r1S0 4S*\S\!S+\S,\S\24
S- jjr30 4S*\S\\4   4S. jjr50 4S*\S\44S/ jjr6SSS0 4S*\S\S\S\\2   4S0 jjr7SSS0 4S*\S\S\S\\2   4S1 jjr8SiS2\9S3\	S\4S4 jjr:SiS5\9S3\	S\4S6 jjr;SiS3\	S\4S7 jjr<S8\4S9 jr=S:\4S; jr>SiS<\9S3\	S\4S= jjr?S> r@S? rASiS@\9SA\BS\24SB jjrC0 4SC jrDSiSA\B4SD jjrES0 4SE\4SF jjrFSSS0 4S*\S\S\S\\G   4SG jjrHSiSH\9SA\BS\G4SI jjrISJ rJ0 4S\\K   4SK jjrLSL rMSSS0 4S	\S\S\4SM jjrNSN rOSO rP0 4S	\4SP jjrQSiS3\	S\R4SQ jjrSSSS0 4S	\S\S\4SR jjrT0 4S	\4SS jjrUS0 4S\S\\V   4ST jjrWSiSU\9S3\	4SV jjrXSW rYSX rZS0 4S	\S\ S\4SY jjr[0 4S	\S\\4SZ jjr]0 4S\^4S[ jjr_S\ r`SiS]\9S3\	S\\4S^ jjraS_S`0 SS4Sa jrbS*\cSb\Sc\Sd\Se\9Sf\4Sg jrdShreU =rf$ )j	cryptocom    returnc                   > U R                  [        [        U ]  5       0 SS_SS_SS/_SS_S	S
_SS_SS_S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S S_0 S!S_S"S_S#S_S$S_S%S_S&S_S'S_S(S_S)S_S*S_S+S,_S-S_S.S_S/S_S0S_S1S_S2S_E0 S3S_S4S_S5S,_S6S_S7S_S8S_S9S_S:S_S;S_S<S_S=S_S>S_S?S_S@S_SAS_SBS_SCS_E0 SDS_SES_SFS_SGS_SHS_SIS_SJS_SKS_SLS_SMS_SNS_SOS_SPS_SQS_SRS_SSS_STS_E0 SUS_SVS_SWS_SXS_SYS_SZS_S[S_S\S_S]S_S^S_S_S_S`S_SaS_SbS_ScS_SdS_SeS_ESSSSSSf.E_SgShSiSjSkSlSmSnSoSpSqSrSsSt._SuSvSwSxSxSy.SzS{S|S}S~.SSSS./ SQSS._SSSSS000SSSSSSSSSSS.
SS0S.S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_ESSSSSS.E0S.SSSSSSSSSSS.	0S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSSSSS.E0S.SSSSSSSSSSS.	0S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSS.E0S.S~._SSU R	                  S5      U R	                  S5      U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //S.S.0_SSSSSSSSS.SSSS.SS._SSSSSSSS.SSSS SSSSS.SSSSSSSS.SS
0SSS SSS.SSSSS.SSSSSS.SSS SSSSS.SSS S SSSSS.SS0S.	SSS0S.SS0SS0S.SS0SS0S.S._SSS0_GS [
        _GS0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS	[        _GS
[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS [        _GS![        _GS"[        _GS#[        _E0 GS$[        _GS%[        _GS&[        _GS'[        _GS([        _GS)[        _GS*[        _GS+[        _GS,[        _GS-[        _GS.[         _GS/["        _GS0[$        _GS1[        _GS2[        _GS3[        _GS4[        _E[        [&        GS5.E0 GS6._5      $ (7  Nidr3   namez
Crypto.com	countriesMTversionv2	rateLimit
   	certifiedTprohasCORSFspotmarginswapfutureoption	addMargincancelAllOrderscancelOrdercancelOrderscancelOrdersForSymbolscloseAllPositionsclosePositioncreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateOrderscreateStopOrdercreateTriggerOrder	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersemulatedfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeefetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLedgerfetchLeveragefetchLeverageTiersfetchMarginAdjustmentHistoryfetchMarginModefetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsHistoryfetchPremiumIndexOHLCVfetchSettlementHistoryfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeesfetchTransactionsfetchTransfersfetchUnderlyingAssetsfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginsandbox)setLeveragesetMarginModesetPositionModetransferwithdraw
timeframes1m5m15m30m1h4h6h12h1D7D14D1M)r   r   r   r   r   r   r   r   1d1w2wr   urlszehttps://user-images.githubusercontent.com/1294454/147792121-38ed5e36-c229-48d6-b49a-48d05fc19ed4.jpegz#https://uat-api.3ona.co/exchange/v1zhttps://uat-api.3ona.co/v2)v1r<   derivativeszhttps://api.crypto.comz"https://api.crypto.com/exchange/v1zhttps://api.crypto.com/v2zhttps://deriv-api.crypto.com/v1)baser   r<   r   zhttps://crypto.com/z"https://crypto.com/exch/kdacthrnxtg      ?)urldiscount)z?https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.htmlz0https://exchange-docs.crypto.com/spot/index.htmlz7https://exchange-docs.crypto.com/derivatives/index.htmlz0https://crypto.com/exchange/document/fees-limits)logotestapiwwwreferraldocfeesr   publicgetzv1/public/get-announcements   g
@)
public/authpublic/get-instrumentspublic/get-bookpublic/get-candlestickpublic/get-tradespublic/get-tickerspublic/get-valuations#public/get-expired-settlement-pricepublic/get-insurancezpublic/get-risk-parametersz"public/staking/get-conversion-rate   )r   postr   z private/set-cancel-on-disconnectz private/get-cancel-on-disconnectzprivate/user-balancezprivate/user-balance-historyzprivate/get-positionszprivate/create-ordergUUUUUU?zprivate/amend-ordergUUUUUU?zprivate/create-order-listzprivate/cancel-orderzprivate/cancel-order-listzprivate/cancel-all-orderszprivate/close-positionzprivate/get-order-historyd   zprivate/get-open-ordersprivate/get-order-detailgUUUUUU?private/get-tradeszprivate/change-account-leverageprivate/get-transactions"private/create-subaccount-transferprivate/get-subaccount-balancesprivate/get-order-listzprivate/create-withdrawalzprivate/get-currency-networkszprivate/get-deposit-addressprivate/get-accountszprivate/get-withdrawal-historyzprivate/get-deposit-historyzprivate/get-fee-ratezprivate/get-instrument-fee-ratezprivate/staking/stakezprivate/staking/unstakez$private/staking/get-staking-positionz'private/staking/get-staking-instrumentszprivate/staking/get-open-stake)z!private/staking/get-stake-historyz"private/staking/get-reward-historyzprivate/staking/convertz private/staking/get-open-convertz#private/staking/get-convert-history)r   private)	r   r   r   r   zpublic/get-tickerr   z%public/margin/get-transfer-currenciesz!public/margin/get-load-curreniceszpublic/respond-heartbeatz$private/export/create-export-requestz"private/export/get-export-requestsz%private/export/download-export-outputzprivate/get-account-summary)r   r   r   r   r   zprivate/otc/get-otc-userzprivate/otc/get-instrumentszprivate/otc/request-quotezprivate/otc/accept-quotezprivate/otc/get-quote-historyzprivate/otc/get-trade-historyzprivate/otc/create-order)	r   r   r   r   r   r   r   r   r   zprivate/convert-collateral)r   r   r   r   r   tradingz0.0025z0.005010000z0.00250000z0.0015250000z0.001500000z0.00082500000z0.000651000000025000000	100000000	250000000	500000000z0.004z0.0018z0.0005z0.0004z0.00035z0.00031z0.00025)makertaker)r   r   tiersoptionsSPOTMARGINDERIVATIVES)fundingrC   rD   r   rE   rF   BSCETHTRON)BEP20ERC20TRC20CCXT)defaultTypeaccountsByIdnetworksbrokerfeatures)lastmarkindex)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedselfTradePreventiontrailingicebergleveragemarketBuyByCostmarketBuyRequiresPricemax)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  ,  )	r   rR   rS   rz   r}   r|   r   r]   r{   defaultr   )extendsra   r  )linearinverse)r  rC   rE   rF   commonCurrenciesUSD_STABLE_COINUSDCprecisionMode
exceptions21930631432541510001100021000310004100051000610007100081000920001200022000530003300043000530006300073000830009300103001330014300163001730023300243002540001400024000340004400054000640007401014010240103401044010740401408014290143005430034300443012)500019010001)exactbroad)deep_extendsuperr3   describeparse_numberr0   r(   r'   r    r"   r%   r+   r.   r#   r&   r!   r)   r/   r,   r-   )self	__class__s    H/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/cryptocom.pyrQ  cryptocom.describe"   s   i ? A D
+D
LD
 $D
 t	D

 D
 D
 4D
  [[[ $[ 	[
 $[ $[ U[ "4[ t[ [ )$[ $U[  [ /[ ,U[  0![" t#[$ %[& "4'[( %d)[* T+[,  -[. /[0  1[2 &u3[4 +E5[6 )%7[8 $Z9[: ';[< (=[> "4?[@ &tA[B (C[D 1$E[F  G[H +EI[J *:K[L +DM[N &uO[P #DQ[R *4S[T $UU[V uW[X "5Y[Z *5[[\ +E][^ t_[`  a[b %ec[d /e[f "5g[h +Ei[j k[l !%m[n +Eo[p  q[r ds[t "4u[v dw[x !$y[z t{[|  }[~ '[@ $UA[B !$C[D (E[F )%G[H )$I[J uK[L tM[N O[P UQ[R tS[T "4U[V #DW[X 'Y[Z $U[[\ !%][^ (_[` )%a[b #Dc[d e[f #Eg[h &ui[j 4k[l  %!&#(! u[D
H ID
d ?6#? 5>5#D	 -? $
 K/eD
V 91  ,26</067122356CI45:;  A!!$  (!>(!>(! 3F(! ;F	(!
 4V(! 3E(! 25(! 8(! 3E(! 8(! 8(! 5f(! 8(! 6v(! 7(!  1#!(!" >v#(!$ 7%(!& A&'(!( >v)(!* 5f+(!, 8-(!. <V/(!0 :61(!2 3F3(!4 =f5(!6 :67(!8 3A9(!: >q;(!< 4Q=(!> 6q?(!@ CAA(!B FqC(!D =aE(!F BCBC78@ACDO(!* %=@ +,67/0671212EFAB89
   !>!>! 8! =f	!
 <V! :6! :6! CF! A&! DV! :6! 3E! 3E! 8! 8!  8!!" 6v#!$ 9>254:?EBH8>;A9<8;=C=C8>;!  /d +16</067122356CI45
   !>!>! 3F! ;F	!
 4V! 3E! 8! 3E! 8! 8! 5f! 9&! 8! 6v! 7!  1#!!" >v#!$ 9?BH?E6<+! ' m^WD
T	 !..x8!..w7 "..s3T5F5Fx5PQ!..w79J9J79ST!..w79J9J89TU!..x8$:K:KG:TU!..x8$:K:KH:UV!..y94;L;LY;WX!..z:D<M<Mc<RS!..z:D<M<Mc<RS!..{;T=N=Ns=ST!..{;T=N=Ns=ST!..{;T=N=Ns=ST" "..s3T5F5Fw5OP!..w79J9J79ST!..w79J9J89TU!..x8$:K:KG:TU!..x8$:K:KH:UV!..y94;L;LW;UV!..z:D<M<Mh<WX!..z:D<M<Mh<WX!..{;T=N=Ny=YZ!..{;T=N=Ny=YZ!..{;T=N=Ny=YZ"!U	D
X
 %%"&#0)+! #"#
 !Y
D
z
 #&*(, %)$(%)-
 -2)-+/6:#'#'"&#(	( #(/3$)#($)+/263$8 r% ',!$$(%&*/& ',#($)*/	# '+!$#($)*/( ',!$$(%&#($)*/$ ',!$$(,0%&#($)*/	*  #OJX  )!4( "9 "9 	 "9 "9 	ub{
D
B !6!CD
H YID
J 6<6,6 <6 <	6
 <6 ]6 -6 -6 Z6 -6 ^6 \6 Z6 Z6 Z6  .!6" .#6$ Y%6& Z'6( Z)6* \+6, \-6. \/60 \162 Z364 \566 \768 \96: \;6< \=6> \?6@ \A6B ZC6D ZE6F ZG6H ZI6J ZK6L ZM6N ZO6P 0Q6R \S6T 0U6V 0W6X ZY6Z ][6\ ^]6^ ._6` \a6b \c6d \e6f Zg6h +,k6n q9KD
  	    c                    U R                  S5      (       d  0 $ SnU R                  USSS5      u  p!U(       a  0 $ 0 n U R                  U5      nU R                  US0 5      nU R                  US0 5      n[        UR                  5       5      n0 n[        S[        U5      5       GH  n	Xy   n
Xj   nU
nU R                  U5      n0 nU R                  US/ 5      n[        S[        U5      5       H  nUU   nU R                  US	5      nU R                  U5      nUUUSU R                  US
S5      U R                  USS5      U R!                  US5      SSU R!                  US5      SS.0S.	UU'   M     U R#                  UUUU R                  US5      SSSSSSSSS.0SUS.5      X'   GM     U$ ! [         a#  n[	        U[
        5      (       a  0 s SnA$ UeSnAff = f)a  
fetches all available currencies on an exchange

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-currency-networks

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
Fra   skipFetchCurrenciesNresultcurrency_mapr   network_list
network_iddeposit_enabledwithdraw_enabledwithdrawal_feer   min_withdrawal_amountminr  )	infor7   networkactivedepositr   fee	precisionlimits	full_nameamountcrypto)rd  r7   coder8   rf  rg  r   rh  ri  rj  typer   )check_required_credentialshandle_option_and_params'v1PrivatePostPrivateGetCurrencyNetworks	Exception
isinstancer    	safe_dictlistkeysrangelensafe_currency_code	safe_listsafe_stringnetwork_id_to_code	safe_boolsafe_numbersafe_currency_structure)rS  paramsrY  responsee
resultDatacurrencyMaprw  rZ  ikeycurrencyr7   rn  r   chainsjchain	networkIdre  s                       rU  fetch_currenciescryptocom.fetch_currencies$  s-    ..u55I#&*&C&CFL]_tv{&|#I	CCFKHf ^^Hh;
nnZDK$$&'q#d)$A'C"'HB**2.DH^^HnbAF1c&k*q	 ,,ULA	11)<!#&"#~~e5FN $u6H% P++E3CD!%"#'#3#3E;R#S#'%%!	 +(  77 ((;? !## !$#9 FL7 %\ I  	!]++ 	G	s#   F. .
G8GGGGc                 D   U R                  U5      nU R                  US0 5      nU R                  US/ 5      n/ n[        S[	        U5      5       GH  nXF   nU R                  US5      nUS:H  n	US:H  n
US:H  nUS:H  nU R                  US	5      nU R                  US
5      nU	(       a  SOUnU R                  U5      nU R                  U5      nU	(       a  SOU R                  U5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  U R                  US5      5      nUb  [        U5      OSnUS-   U-   nSnSnUS:X  a  SnSnOxUS:X  a  SnUS-   U-   nSnOeUS:X  a"  SnUS-   U-   S-   U R                  U5      -   nSnO=US:X  a7  SnUS:X  a  SOSnUS-   U-   S-   U R                  U5      -   S-   U-   S-   U-   nSnUR                  0 SU R                  US5      _SU_SU_S U_S!U_S"U_S#U_S$U_S%U_SU	_S&U=(       d    U_SU
_SU_SU_S'U R                  US(5      _S)U_S*U(       a  SOS_U(       a  SOSU R                  US+5      UU R                  U5      U R                  U5      UU R                  U R                  US,5      5      U R                  U R                  US-5      5      S..U R                  S/5      U R                  US05      S1.SSS1.SSS1.SSS1.S2.SUS3.
E5        GM     U$ )4a  

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-instruments

retrieves data on all markets for cryptocom
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
rZ  datar   	inst_typeCCY_PAIRPERPETUAL_SWAPFUTUREWARRANTbase_ccy	quote_ccyNput_callstrikemargin_buy_enabledmargin_sell_enabledexpiry_timestamp_ms/rC   FrE   :TrF   -rG   callCPr7   symbolr   quotesettlebaseIdquoteIdsettleIdro  rD   rf  tradablecontractr  contract_sizeprice_tick_sizeqty_tick_size)pricerl  1max_leveragerb  )r  rl  r  cost)
r  contractSizeexpiryexpiryDatetimer  
optionTyperi  rj  createdrd  )v1PublicGetPublicGetInstrumentsru  r{  rx  ry  r|  rz  safe_string_lowerr~  	omit_zerointyymmddappendr  iso8601rR  )rS  r  r  resultResponser  rZ  r  marketr  rC   rE   rF   rG   r  r  r  r   r  r  r  r  marginBuyEnabledmarginSellEnabledexpiryStringr  r  ro  r  symbolOptionTypes                                rU  fetch_marketscryptocom.fetch_markets  s    77?p (B?~~nfb9q#d)$AWF((=I
*D 00D(*F)+F%%fj9F&&v{;G#tH**62D++G4E!Tt'>'>x'HF//
CJ%%fh7F#~~f6JK $v7L M>>$*:*:6CX*YZL+7+CS&$FCZ%'FDHJ& ..#-h&#-3dkk&6IIi'+5+?3c #-3dkk&6IICORXX[^^aqqMM 0d&&vx80&0 0 	0
 &0 &0 70 H0 0 0 ,D2C0 0 &0 &0 $..<0  H!0" 8$$#0$ &.5D $ 0 0 I "&,,v"6++F3(!..t/?/?HY/Z["//0@0@0YZ  $005#//G!
  $#
  $#
  $#$  _0 0M %n rW  Nsymbolsc                    U R                  5         Sn0 nUba  Sn[        U[        5      (       a/  [        U5      nUS:  a  [	        U R
                  S-   5      eUS   nOUnU R                  U5      nUS   US'   U R                  U R                  XB5      5      nU R                  US0 5      nU R                  US/ 5      n	U R                  X5      $ )	aI  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-tickers
https://exchange-docs.crypto.com/derivatives/index.html#public-get-tickers

: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   zB fetchTickers() symbols argument cannot contain more than 1 symbolr   r7   instrument_namerZ  r  )load_marketsrt  rv  ry  r%   r7   r  v1PublicGetPublicGetTickersextendru  r{  parse_tickers)
rS  r  r  r  requestr  symbolsLengthr  rZ  r  s
             rU  fetch_tickerscryptocom.fetch_tickers[  s     	F'4(( #G 1$$TWW/s%stt  [[(F)/G%&33DKK4PQ2 (B7~~ffb1!!$00rW  r  c                     U R                  5         U R                  U5      nU R                  U/U5      nU R                  X15      $ )a  

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-tickers

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>`
)r  r  r  
safe_value)rS  r  r  tickerss       rU  fetch_tickercryptocom.fetch_ticker  sA     	V$$$fXv6w//rW  sincer  c                    U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX45      $ Sn0 nUb  U R                  U5      nUS   US'   Ub  X'S'   Ub  X7S'   U R	                  US	5      nU R                  US	/5      nUb  XS
'   U R                  U R                  Xt5      5      n	U R                  U	S0 5      n
U R                  U
S/ 5      nU R                  XX#5      $ )a  
fetches information on multiple orders made by the user

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-order-history

:param str symbol: unified market symbol of the market the orders were made in
:param int [since]: the earliest time in ms to fetch orders for, max date range is one day
:param int [limit]: the maximum number of order structures to retrieve, default 100 max 100
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms for the ending date filter, default is the current time
: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>`
Fr   paginateNr7   r  
start_timer  untilend_timerZ  r  )r  rq  fetch_paginated_call_dynamicr  safe_integeromit#v1PrivatePostPrivateGetOrderHistoryr  ru  r{  parse_orders)rS  r  r  r  r  r  r  r  r  r  r  orderss               rU  fetch_orderscryptocom.fetch_orders  s    	88PZ[44]FSXaa[[(F)/G%&$)L!$G!!&'26G9-"'J;;DKK<XYP ~~h"5fb1  >>rW  c                    U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX45      $ U R                  U5      nSUS   0nUb  X'S'   Ub  X7S'   U R	                  US5      nU R                  US/5      nUb  XS	'   U R                  U R                  Xt5      5      n	U R                  U	S
0 5      n
U R                  U
S/ 5      nU R                  XX#5      $ )ag  
get a list of the most recent trades for a particular symbol

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-trades

:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch, maximum date range is one day
:param int [limit]: the maximum number of trades to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms for the ending date filter, default is the current time
: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=public-trades>`
Fr   r  r  r7   start_tscountr  end_tsrZ  r  )r  rq  r  r  r  r  v1PublicGetPublicGetTradesr  ru  r{  parse_trades)rS  r  r  r  r  r  r  r  r  r  rZ  tradess               rU  fetch_tradescryptocom.fetch_trades  s    	88PZ[44]FSXaaV$vd|
 "'J$G!!&'26G9- %H224;;w3OP* (B73  >>rW  r   	timeframec           	         U R                  5         SnU R                  USSS5      u  peU(       a  U R                  SXXBUS5      $ U R                  U5      nUS   U R	                  U R
                  X"5      S.nUb  US:  a  SnXHS'   U R                  5       n	U R                  U5      n
U R                  USU	5      nU R                  US/5      nUb-  X:S	-  -
  US
'   Ub  U R                  X:U-  S	-  5      US'   O	XS'   OXS'   U R                  U R                  X5      5      nU R                  US0 5      nU R                  US/ 5      nU R                  XX#U5      $ )a  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-candlestick

: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]: timestamp in ms for the ending date filter, default is the current time
: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
Fr{   r  r  r7   )r  r  r  r  i  r  r  rZ  r  )r  rq  "fetch_paginated_call_deterministicr  r|  r   microsecondsparse_timeframer  r  sumv1PublicGetPublicGetCandlestickr  ru  r{  parse_ohlcvs)rS  r  r  r  r  r  r  r  r  nowdurationr  r  rZ  r  s                  rU  fetch_ohlcvcryptocom.fetch_ohlcv$  s|    	88z[`a::<X]jpruvvV$%d|))$//9P
 s{$G!''	2!!&'376G9-"'T/"9GJ $(HHUu4Dt4K$L!$)! %H77G8TU, (B7~~ffb1  yGGrW  c                 v   U R                  5         U R                  U5      nSUS   0nU(       a  [        US5      US'   U R                  U R	                  XS5      5      nU R                  US0 5      nU R                  US/ 5      nU R                  US5      n	U R                  U	S5      n
U R                  XU
5      $ )	a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-book

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the number of order book entries to return, max 50
: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
r  r7   2   depthrZ  r  r   t)
r  r  rc  v1PublicGetPublicGetBookr  ru  r{  r  r  parse_order_book)rS  r  r  r  r  r  r  rZ  r  	orderBook	timestamps              rU  fetch_order_bookcryptocom.fetch_order_bookg  s     	V$vd|
 "5"~GG00W1MN& (B7~~ffb1OOD!,	%%i5	$$Y	BBrW  c                    U R                  US0 5      nU R                  US/ 5      nU R                  US   S/ 5      nSU0n[        S[	        U5      5       Hh  nXF   nU R                  US5      nU R                  U5      n	U R                  5       n
U R                  US5      U
S'   U R                  US	5      U
S
'   XU	'   Mj     U R                  U5      $ )NrZ  r  r   position_balancesrd  r  quantitytotalreserved_qtyused)	ru  r{  r  rx  ry  r|  rz  accountsafe_balance)rS  r  responseResultr  positionBalancesrZ  r  balance
currencyIdrn  r	  s              rU  parse_balancecryptocom.parse_balance  s    (B?~~nfb9??474GL)q#./0A&)G))'3DEJ**:6DllnG#//DGG"..wGGFO"4L 1   ((rW  c                 f    U R                  5         U R                  U5      nU R                  U5      $ )aX  
query for balance and get the amount of funds available for trading or funds locked in orders

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-user-balance

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
)r  v1PrivatePostPrivateUserBalancer  )rS  r  r  s      rU  fetch_balancecryptocom.fetch_balance  s4     	77?X !!(++rW  r7   c                     U R                  5         SnUb  U R                  U5      nSU0nU R                  U R                  XS5      5      nU R	                  US0 5      nU R                  Xt5      $ )a  
fetches information on an order made by the user

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-order-detail

: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>`
Norder_idrZ  )r  r  "v1PrivatePostPrivateGetOrderDetailr  ru  parse_order)rS  r7   r  r  r  r  r  orders           rU  fetch_ordercryptocom.fetch_order  sv     	[[(F
 ::4;;w;WXD x26..rW  ro  siderl  r  c                    U R                  U5      nUR                  5       nUS   UR                  5       U R                  X5      S.n	US:X  d  US:X  d  US:X  a  U R                  X5      U	S'   U R	                  U R
                  SS5      n
XS	'   S nS nU R                  S
Xv5      u  pU R                  S
U5      u  pUS:X  d  Ub  SU	S'   OUS:X  a  SU	S'   U R                  USS5      nUb(  US:X  a  SU	S'   OUS:X  a  SU	S'   OUS:X  a  SU	S'   OXS'   U R                  USS5      nU(       d  US:X  a  S/U	S'   SU	S'   U R                  U/ SQ5      nU R                  US5      nU R                  US5      nUS LnUS LnUS LnU(       a  U R                  X5      U	S '   U R                  U5      nUS:X  d  US:X  d  US:X  aV  US!:X  a(  [        R                  " UU5      (       a  SU	S"'   OSU	S"'   O[        R                  " UU5      (       a  SU	S"'   OSU	S"'   OUS!:X  a(  [        R                  " UU5      (       a  S#U	S"'   OS$U	S"'   O[        R                  " UU5      (       a  S$U	S"'   OrS#U	S"'   OlU(       a-  US:X  d  US:X  a  SU	S"'   OS$U	S"'   U R                  UU5      U	S '   O8U(       a-  US:X  d  US:X  a  SU	S"'   OS#U	S"'   U R                  UU5      U	S '   OXS"'   U R                  U/ S%Q5      nU R!                  X5      $ )&Nr7   )r  r  r  LIMIT
STOP_LIMITTAKE_PROFIT_LIMITr  r   r   	broker_idrR   rD   r   spot_marginrC   r   r   time_in_forceGTCGOOD_TILL_CANCELr   IMMEDIATE_OR_CANCELr   FILL_OR_KILLpostOnlyFr   	POST_ONLY	exec_inst	stopPricer   	ref_pricer   r   r-  buyro  TAKE_PROFIT	STOP_LOSSr(  clientOrderIdr   r,  r   r   r   )r  upperamount_to_precisionprice_to_precisionr|  r   handle_market_type_and_params$custom_handle_margin_mode_and_paramssafe_string_upper_2r~  safe_string_nr  number_to_stringr1   	string_ltr  r  )rS  r  ro  r  rl  r  r  r  uppercaseTyper  r   
marketTyper   r   r(  r   r   r   	isTriggerisStopLossTriggerisTakeProfitTriggerpriceStrings                         rU  create_order_requestcryptocom.create_order_request  sT   V$

%d|JJL00@

 W$-<*G]^qMq#66vEGG!!$,,&A%

!??v^
!FF}V\]
("
(>%-GM"6!%+GM"..v}oV"e#+=(%+@(%+9(+6(>>&*e<+-$/=GK '9GO$))&2\]((A**63DE!-	*$6.d:#'#:#:6#PGK //6K(m|.KQ^buQu5=((lCC*=*6((lCC*6*=5=((lCC*7*5((lCC*5*7(m|.K"."-#'#:#:6=#QGK  (m?R.R"5"/#'#:#:6?#SGK +FO6  $Q  R{{7++rW  c                     U R                  5         U R                  U5      nU R                  XX4XV5      nU R                  U5      n	U R	                  U	S0 5      n
U R                  X5      $ )aJ  
create a trade order

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market', 'limit', 'stop_loss', 'stop_limit', 'take_profit', 'take_profit_limit'
:param str side: 'buy' or 'sell'
:param float amount: how much 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 str [params.timeInForce]: 'GTC', 'IOC', 'FOK' or 'PO'
:param str [params.ref_price_type]: 'MARK_PRICE', 'INDEX_PRICE', 'LAST_PRICE' which trigger price type to use, default is MARK_PRICE
:param float [params.triggerPrice]: price to trigger a trigger order
:param float [params.stopLossPrice]: price to trigger a stop-loss trigger order
:param float [params.takeProfitPrice]: price to trigger a take-profit trigger order
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
rZ  )r  r  rB  v1PrivatePostPrivateCreateOrderru  r  )rS  r  ro  r  rl  r  r  r  r  r  rZ  s              rU  create_ordercryptocom.create_orderb  sg    & 	V$++F$V77@ (B7//rW  r  c           	         U R                  5         / n[        S[        U5      5       H  nX   nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  US5      n	U R	                  US5      n
U R                  US0 5      nU R                  XgXX5      nUR                  U5        M     U R                  USS	5      nUUS
.nU R                  U R                  X5      5      nU R	                  US/ 5      nU R                  US5      nUb  SU0/nU R                  U5      $ U R                  U5      $ )a#  
create a list of trade orders

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order-list-list
https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order-list-oco

:param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
r   r  ro  r  rl  r  r  contingency_typeLISTrI  
order_listrZ  list_idr  )r  rx  ry  r|  r  ru  create_advanced_order_requestr  #v1PrivatePostPrivateCreateOrderListr  r  )rS  r  r  ordersRequestsr  rawOrdermarketIdro  r  rl  r  orderParamsorderRequest
contigencyr  r  rZ  listId	ocoOrderss                      rU  create_orderscryptocom.create_orders  sW    	q#f+&AyH''(;H##Hf5D##Hf5D__Xx8FOOHg6E..8R@K==hd\aoL!!,/ ' %%f.@&I
 *(
 ;;DKK<XYT 8R8!!&)4$f-.I$$Y//  ((rW  c                    U R                  U5      nUR                  5       nUS   UR                  5       S.n	US:X  d  US:X  d  US:X  a  U R                  X5      U	S'   U R                  U R                  SS5      n
XS	'   U R                  US
S5      nUb(  US:X  a  SU	S'   OUS:X  a  SU	S'   OUS:X  a  SU	S'   OXS'   U R                  USS5      nU(       d  US:X  a  S/U	S'   SU	S'   U R                  U/ SQ5      nU R                  US5      nU R                  US5      nUS LnUS LnUS LnU(       a  U R                  U5      nUS:X  d  US:X  d  US:X  aV  US:X  a(  [        R                  " UU5      (       a  SU	S'   OSU	S'   O[        R                  " UU5      (       a  SU	S'   OSU	S'   OUS:X  a(  [        R                  " UU5      (       a  SU	S'   OpSU	S'   Oj[        R                  " UU5      (       a  SU	S'   OHSU	S'   OBU(       a  US:X  d  US:X  a  SU	S'   O)SU	S'   O#U(       a  US:X  d  US:X  a  SU	S'   O
SU	S'   OXS'   US:X  a  US:X  d  US:X  d  US:X  a  S nSnU R                  US S!S5      u  nnU R                  US"S#5      nU R                  US"5      nUb  U R                  UU5      nOU(       ag  Uc  [!        U R"                  S$-   5      eU R                  U5      nU R                  U5      n[        R$                  " UU5      nU R                  UU5      nOU R                  X5      nUU	S#'   OU R'                  X5      U	S%'   U R                  U/ S&Q5      nU R)                  X5      $ )'Nr7   )r  r  r  r  r   r  r   r   r!  r   r#  r$  r%  r   r&  r   r'  r(  Fr   r)  r*  r+  r   r   r.  ro  r/  r0  MARKETTrR   !createMarketBuyOrderRequiresPricer  notionala	   createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend(quote quantity) in the amount argumentr  r1  )r  r3  r5  r|  r   r8  r~  r9  r  r:  r1   r;  rq  safe_number_2r  cost_to_precisionr(   r7   
string_mulr4  r  )rS  r  ro  r  rl  r  r  r  r<  r  r   r   r(  r   r   r   r>  r?  r@  rA  quoteAmountr\  r  amountStringcostRequests                            rU  rN  'cryptocom.create_advanced_order_request  s   
 V$

%d|JJL
 W$-<*G]^qMq#66vEGG!!$,,&A%..v}oV"e#+=(%+@(%+9(+6(>>&*e<+-$/=GK '9GO$))&2\]((A**63DE!-	*$6.d://6K(m|.KQ^buQu5=((lCC*=*6((lCC*6*=5=((lCC*7*5((lCC*5*7(m|.K"."- (m?R.R"5"/+FOEM(!:Q\@\bo  tA  cAK04-8<8U8UV\^k  nQ  SW  9X5-v%%ffjADYYvv.F"44VTB2=&tww  2}  (}  ~  ~#'#8#8#@L"&"7"7">K")"4"4\;"OK"&"8"8"MK"44VD"-GJ"&":":6"JGJ6  $Q  R{{7++rW  c                     U R                  5         U R                  XXVU5      nU R                  U5      n	U R                  U	S0 5      n
U R	                  U
5      $ )a  
edit a trade order

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-amend-order

:param str id: order id
:param str symbol: unified market symbol of the order to edit
:param str [type]: not used by cryptocom editOrder
:param str [side]: not used by cryptocom editOrder
:param float amount:(mandatory) how much of the currency you want to trade in units of the base currency
:param float price:(mandatory) the price for the order, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.clientOrderId]: the original client order id of the order to edit, required if id is not provided
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
rZ  )r  edit_order_requestv1PrivatePostPrivateAmendOrderru  r  )rS  r7   r  ro  r  rl  r  r  r  r  rZ  s              rU  
edit_ordercryptocom.edit_order4  sW      	))"fVL66w?(B7''rW  c                 P   0 nUb  XS'   OFU R                  USS5      nUc  [        U R                  S-   5      eXvS'   U R                  USS/5      nUb  Uc  [        U R                  S-   5      eU R	                  X#5      US'   U R                  X$5      US'   U R                  Xe5      $ )Nr  orig_client_oidr2  zA editOrder() requires an id argument or orig_client_oid parameterz editOrder() requires both amount and price arguments. If you do not want to change the amount or price, you should pass the original valuesnew_quantity	new_price)safe_string_2r$   r7   r  r4  r5  r  )rS  r7   r  rl  r  r  r  originalClientOrderIds           rU  rf  cryptocom.edit_order_requestJ  s    >"$J$($6$6v?PRa$b!$,'2u(uvv-B)*6,=+OPN#DGG  /}  %}  ~  ~"&":":6"J#66vE{{7++rW  c                     U R                  5         Sn0 nUb  U R                  U5      nUS   US'   U R                  U R                  XB5      5      nU R	                  SU05      /$ )aa  
cancel all open orders

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-all-orders

:param str symbol: unified market symbol of the orders to cancel
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict} Returns exchange raw message{@link https://docs.ccxt.com/#/?id=order-structure:
Nr7   r  rd  )r  r  #v1PrivatePostPrivateCancelAllOrdersr  
safe_order)rS  r  r  r  r  r  s         rU  cancel_all_orderscryptocom.cancel_all_orders[  sm     	[[(F)/G%&;;DKK<XY 2344rW  c                     U R                  5         SnUb  U R                  U5      nSU0nU R                  U R                  XS5      5      nU R	                  US0 5      nU R                  Xt5      $ )a  
cancels an open order

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-order

:param str id: the order id of the order to cancel
: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  rZ  )r  r  v1PrivatePostPrivateCancelOrderr  ru  r  )rS  r7   r  r  r  r  r  rZ  s           rU  cancel_ordercryptocom.cancel_ordern  su     	[[(F
 77G8TU (B7//rW  idsc                    Uc  [        U R                  S-   5      eU R                  5         U R                  U5      n/ n[	        S[        U5      5       H)  nX   nUS   [        U5      S.nUR                  U5        M+     SUS.n	U R                  U R                  X5      5      n
U R                  U
S/ 5      nU R                  XSSU5      $ )	af  
cancel multiple orders

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-order-list-list

:param str[] ids: order ids
:param str symbol: unified market symbol
: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>`
Nz* cancelOrders() requires a symbol argumentr   r7   r  r  rJ  rK  rZ  )r$   r7   r  r  rx  ry  strr  #v1PrivatePostPrivateCancelOrderListr  r{  r  )rS  rz  r  r  r  orderRequestsr  r7   r  r  r  rZ  s               rU  cancel_orderscryptocom.cancel_orders  s     >#DGG.Z$Z[[V$q#c(#AB#)$<GE   ' $ !''
 ;;DKK<XY(B7  tVDDrW  c                    U R                  5         / n[        S[        U5      5       H^  nX   nU R                  US5      nU R                  US5      nU R	                  U5      nUS   [        U5      S.n	UR                  U	5        M`     SUS.n
U R                  U R                  X5      5      nU R                  US/ 5      nU R                  USSSU5      $ )	a  
cancel multiple orders for multiple symbols

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-order-list-list

:param CancellationRequest[] orders: each order should contain the parameters required by cancelOrder namely id and symbol, example [{"id": "a", "symbol": "BTC/USDT"}, {"id": "b", "symbol": "ETH/USDT"}]
: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>`
r   r7   r  r|  rJ  rK  rZ  N)r  rx  ry  r|  r  r}  r  r~  r  r{  r  )rS  r  r  r  r  r  r7   r  r  	orderItemr  r  rZ  s                rU  cancel_orders_for_symbols#cryptocom.cancel_orders_for_symbols  s     	q#f+&AIE!!%.B%%eX6F[[(F#)$<GI   + ' !''
 ;;DKK<XY(B7  tT6BBrW  c                    U R                  5         Sn0 nUb  U R                  U5      nUS   US'   U R                  U R                  Xd5      5      nU R	                  US0 5      nU R                  US/ 5      n	U R                  XX#5      $ )a  
fetch all unfilled currently open orders

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-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 order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr7   r  rZ  r  )r  r  !v1PrivatePostPrivateGetOpenOrdersr  ru  r{  r  )
rS  r  r  r  r  r  r  r  r  r  s
             rU  fetch_open_orderscryptocom.fetch_open_orders  s     	[[(F)/G%&99$++g:VWL ~~h"5fb1  >>rW  c                    U R                  5         SnU R                  USS5      u  pTU(       a  U R                  SXX4S5      $ 0 nSnUb  U R                  U5      nUS   US'   Ub  X&S'   Ub  X6S	'   U R	                  US
5      nU R                  US
/5      nUb  XS'   U R                  U R                  Xd5      5      n	U R                  U	S0 5      n
U R                  U
S/ 5      nU R                  XX#5      $ )a>  
fetch all trades made by the user

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-trades

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for, maximum date range is one day
:param int [limit]: the maximum number of trade structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms for the ending date filter, default is the current time
: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>`
Frz   r  r   Nr7   r  r  r  r  r  rZ  r  )r  rq  r  r  r  r  v1PrivatePostPrivateGetTradesr  ru  r{  r  )rS  r  r  r  r  r  r  r  r  r  rZ  r  s               rU  fetch_my_tradescryptocom.fetch_my_trades	  s    	88R\]44_fUZdghh[[(F)/G%&$)L!$G!!&'26G9-"'J55dkk'6RS< (B73  >>rW  c                     S nS nS nUR                  S5      S:  a,  UR                  S5      u  p$UR                  S5      nUS   nX#/$ UnX#/$ )N?r   =r   )findsplit)rS  addressStringaddresstagrawTagsplitteds         rU  parse_addresscryptocom.parse_addressK  sf    c"Q&+11#6OG||C(H1+C ~ $G~rW  rn  r  r  c                 j   U R                  XE5      u  pEU R                  5         U R                  U5      nUS   UUS.nUb  XGS'   SnU R                  U5      u  pU R	                  U5      n	U	b  XS'   U R                  U R                  Xu5      5      n
U R                  U
S5      nU R                  X5      $ )a  
make a withdrawal

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-withdrawal

: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>`
r7   )r  rl  r  Naddress_tagr]  rZ  )	handle_withdraw_tag_and_paramsr  safe_currencyhandle_network_code_and_paramsnetwork_code_to_id$v1PrivatePostPrivateCreateWithdrawalr  ru  parse_transaction)rS  rn  rl  r  r  r  r  r  networkCoder  r  rZ  s               rU  r   cryptocom.withdrawW  s     99#F%%d+ 

 ?%(M""AA&I++K8	 $-L!<<T[[=YZ" (3%%f77rW  c                    U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US0 5      nU R                  US/ 5      n[        U5      nUS:X  a  [        U R                  S-   5      e0 n	[        SU5       H  n
U R	                  Xz5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      u  nnU R                  U5        U R                  US5      nU R                  UU5      nUUUUUS	.U	U'   M     U	$ )
a  
fetch a dictionary of addresses for a currency, indexed by network

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-deposit-address

:param str code: unified currency code of the currency for the deposit address
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `address structures <https://docs.ccxt.com/#/?id=address-structure>` indexed by the network
r  r7   rZ  deposit_address_listr   z7 fetchDepositAddressesByNetwork() generating address...r  re  )rd  r  re  r  r  )r  r  %v1PrivatePostPrivateGetDepositAddressr  ru  r{  ry  r    r7   rx  r|  rz  r  check_addressr}  )rS  rn  r  r  r  r  r  	addressesaddressesLengthrZ  r  valuer  r  responseCoder  r  r  re  s                      rU  "fetch_deposit_addresses_by_network,cryptocom.fetch_deposit_addresses_by_network  sW    	%%d+
 ==dkk'>Z[( ~~h"5NN4)?D	i.a*c cddq/*ANN90E ,,UI>M))%<J22:>L--m<LGSw'((	:I--iFG(""F7O +  rW  c                     U R                  US5      nU R                  US/5      nU R                  X5      nX4;   a  XC   $ [        UR	                  5       5      nXES      $ )ao  
fetch the deposit address for a currency associated with self account

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-deposit-address

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
re  r   )safe_string_upperr  r  rv  rw  )rS  rn  r  re  depositAddressesrw  s         rU  fetch_deposit_addresscryptocom.fetch_deposit_address  si     ((;6I;/BB4P&#,,(--/0D#G,,rW  c                    U R                  5         Sn0 nUb  U R                  U5      nUS   US'   Ub  X&S'   Ub  X6S'   U R                  US5      nU R                  US/5      nUb  XvS'   U R	                  U R                  Xd5      5      nU R                  US0 5      n	U R                  U	S	/ 5      n
U R                  XX#5      $ )
aP  
fetch all deposits made to an account

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-deposit-history

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch deposits for
:param int [limit]: the maximum number of deposits structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms for the ending date filter, default is the current time
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr7   r  r  	page_sizer  r  rZ  deposit_list)	r  r  r  r  %v1PrivatePostPrivateGetDepositHistoryr  ru  r{  parse_transactions)rS  rn  r  r  r  r  r  r  r  r  depositLists              rU  fetch_depositscryptocom.fetch_deposits  s     	))$/H"*4.GJ"'J#(K !!&'26G9- %H==dkk'>Z[. ~~h"5nnT>2>&&{eKKrW  c                    U R                  5         Sn0 nUb  U R                  U5      nUS   US'   Ub  X&S'   Ub  X6S'   U R                  US5      nU R                  US/5      nUb  XvS'   U R	                  U R                  Xd5      5      nU R                  US0 5      n	U R                  U	S	/ 5      n
U R                  XX#5      $ )
a^  
fetch all withdrawals made from an account

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-withdrawal-history

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch withdrawals for
:param int [limit]: the maximum number of withdrawals structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms for the ending date filter, default is the current time
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr7   r  r  r  r  r  rZ  withdrawal_list)	r  r  r  r  (v1PrivatePostPrivateGetWithdrawalHistoryr  ru  r{  r  )rS  rn  r  r  r  r  r  r  r  r  withdrawalLists              rU  fetch_withdrawalscryptocom.fetch_withdrawals  s     	))$/H"*4.GJ"'J#(K !!&'26G9- %H@@WA]^2 ~~h"5.?D&&~NNrW  tickerr  c                 `   U R                  US5      nU R                  US5      nU R                  XBS5      nU R                  US5      nU R                  US5      nU R                  0 SUS   _SU_SU R	                  U5      _S	U R                  US
5      _SU R                  US5      _SU R                  US5      _SS _SU R                  US5      _SS _SS _SS _SU_SU_SS _SS _SU R                  US5      _SS _U R                  US5      US:X  a  U R                  US5      OS US.EU5      $ ) Nr  r  _r  ar  r   datetimehighhlowlbidb	bidVolumeaskk	askVolumevwapopencloser   previousClosechange
percentagecaveragevUSDvv)
baseVolumequoteVolumerd  )r  r|  safe_marketsafe_tickerr  r  )rS  r  r  r   rR  r  r   s          rU  parse_tickercryptocom.parse_tickerE  s   B %%fc2	##FC0!!(C8  1, !
fX&!
!
 Y/!
 D$$VS1	!

 4##FC0!
 4##FC0!
 !
 4##FC0!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $**637!!
" t#!
$ **637>Cun4++FD9SW)!
* + 	rW  tradec                 P   U R                  USS5      nU R                  USS5      nU R                  XBS5      nU R                  US5      nU R                  US5      nU R	                  UU R                  USS	5      UU R                  U5      US
   U R                  US5      U R                  USS5      U R                  US5      U R                  USS5      U R                  USS5      S S U R                  U5      U R                  [        R                  " U5      5      S.S.U5      $ )Nr  create_timer  r  r  fee_instrument_namer   dtrade_idr  r  sr  
taker_sideptraded_priceqtraded_quantityr  r  )rd  r7   r   r  r  r  r  takerOrMakerr  rl  r  ro  rh  )safe_integer_2rn  r  r|  
safe_trader  safe_string_lower_2r  r^  rz  rR  r1   
string_neg)rS  r  r  r   rR  feeCurrencyfeeCostStrings          rU  parse_tradecryptocom.parse_trade  s5   F ''sMB	%%eS2CD!!(C8&&u.CD((7$$UC<"Y/X&%%eZ8,,UC@ 225,G''sNC((5FG 33K@))'*<*<]*KL 
" # 	rW  c           	          U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )Nr  or  r  r  r  )r  r  )rS  ohlcvr  s      rU  parse_ohlcvcryptocom.parse_ohlcv  sn     eS)UC(UC(UC(UC(UC(
 	
rW  statusc                 6    SSSSSS.nU R                  X!U5      $ )Nr  canceledclosedrejectedexpired)ACTIVECANCELEDFILLEDREJECTEDEXPIREDr|  rS  r  statusess      rU  parse_order_statuscryptocom.parse_order_status  s-    "" 
 &99rW  r   c                 2    SSSS.nU R                  X!U5      $ )Nr$  r   r   )r%  r&  r'  r  )rS  r   timeInForcess      rU  parse_time_in_forcecryptocom.parse_time_in_force  s'     %#(!

 ;GGrW  r  c           
      l   U R                  US5      nUb<  US:w  a6  U R                  U R                  US5      U R                  US5      USS.5      $ U R                  US5      nU R                  US5      nU R                  XR5      nU R	                  US	5      nS nUb,  S
n[        S[        U5      5       H  n	Xy   n
U
S:X  d  M  Sn  O   U R                  US5      nU R                  0 SU_SU R                  US5      _SU R                  US5      _SU_SU R                  U5      _SU R                  US5      _SU R                  U R                  US5      5      _SU_SU R                  US5      _SU R                  U R                  US5      5      _SU_SU R                  US5      _SU R                  US5      _SU R                  US 5      _S!U R                  US"5      _S#S _S$U R                  US%5      _U R                  US&5      U R                  U5      U R                  US'5      S(./ S).EU5      $ )*Nrn  r   r  
client_oidr   )r7   r2  rd  r  r  r  r*  Fr)  Tr  rd  r7   r2  r   r  lastTradeTimestampupdate_timer  r  ro  
order_typer   r#  r(  r  r  limit_pricerl  r  filledcumulative_quantity	remainingr  	avg_pricecumulative_valuecumulative_feer  )r  rh  r  )r  rs  r|  safe_symbolr  rx  ry  r  r
  r  r  r  rz  )rS  r  r  rn  r  rR  r  execInstr(  r  instr  s               rU  r  cryptocom.parse_order  s   ^   /419??&&uj9!%!1!1%!F$	$   ##E=9##E+<=!!(3??5+6H1c(m,{;&#H	 -
 &&u.CD  
E 
$""5*5 
 T--e\B 
 	 

 W- 
 !$"3"3E="I 
 d--d.>.>uh.OP 
 f 
 D**5,? 
 433D4D4DUO4\] 
  
 D**5&9 
 T%%e]; 
 d&&uj9 
 d&&u.CD 
  ! 
" t''{;# 
$ $$U,>? 33K@((0@A / 
0 1 	rW  c                 4    SSSSS.nU R                  X!U5      $ )Npendingokfailed)r   r  23r  r  s      rU  parse_deposit_statuscryptocom.parse_deposit_statusA	  s*    	
 &99rW  c                 :    SSSSSSSS.nU R                  X!U5      $ )Nr!  r#  r"  r  )r   r  r$  r%  456r  r  s      rU  parse_withdrawal_status!cryptocom.parse_withdrawal_statusJ	  s3    
 &99rW  transactionr  c                    S nU R                  US5      nS nSU;   a  SnU R                  U5      nOSnU R                  U5      nU R                  US5      nU R                  U5      u  pxU R                  US5      n	U R	                  X5      n
U R                  US5      nU R                  US5      nS nUb  XS	.n0 S
U_SU R                  US5      _SU R                  US5      _SU_SU R                  U5      _SS _SU_SU_SS _SU_SU_SS _SU_SU R                  US5      _SU
_SU_SU R                  US5      _S U R                  US5      US.E$ )Nr  
client_wid
withdrawalrg  r  r  r  rh  r  rd  r7   txidr   r  re  	addressToaddressFromr  tagTotagFromro  rl  updatedr  )internalcommentrh  )r|  r,  r&  r  rz  r  r  r  )rS  r.  r  ro  	rawStatusr  r  r  r  r  rn  r   feeCostrh  s                 rU  r  cryptocom.parse_transactionV	  s   X $$[(;	;&D11)<FD..y9F((i@))-8%%k:>
&&z<%%k=A	"";6#5C
K
$"";5
 D$$[&9
 	

 Y/
 t
 w
 
 4
 3
 S
 t
 D
 d&&{H=
 
  f!
" t((mD#
$ ''\B)
 	
rW  c                    U R                  U R                  S5      nU R                  USS5      nU R                  US5      nSnU R	                  X5      u  pRUb"  US:w  a  [        U R                  S-   5      e XR/$ US:X  d  USL a  SnXR/$ )aM  
@ignore
       marginMode specified by params["marginMode"], self.options["marginMode"], self.options["defaultMarginMode"], params["margin"] = True or self.options["defaultType"] = 'margin'
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :returns Array: the marginMode in lowercase
       r   rD   FNcrossz only cross margin is supportedT)r|  r   r~  r  handle_margin_mode_and_paramsr*   r7   )rS  
methodNamer  r   isMarginr   s         rU  r7  .cryptocom.custom_handle_margin_mode_and_params	  s     &&t||]C>>&(E:68,
!??
S
!W$"477-N#NOO %
 ## x'X-=$
##rW  c                    U R                  US/ 5      n[        U5      nUS S S.S S S.0 S.nUb  [        SU5       H  nX6   nU R                  US5      nU R                  US5      n	U R	                  X5      n
S S S.U R                  US5      SS.S	.US
   U
'   US:X  d  Me  U R                  US5      US   S'   SUS   S'   M     U$ )Nr\  )rh  r  )rd  r   rg  r   r   r]  rn  r`  F)rg  r   r   r   r   rh  r  )r{  ry  rx  r|  r}  r  )rS  rh  r  networkListnetworkListLengthrZ  r  networkInfor  currencyCoder  s              rU  parse_deposit_withdraw_fee$cryptocom.parse_deposit_withdraw_fee	  s
   " nnS."=,"
 " 
 "1/0)n ,,[,G	#//&A"55iN'+4@(,(8(8FV(Wgl m3z";/ %)040@0@N^0_F:&u-7<F:&|4 1 rW  codesc                     U R                  5         U R                  U5      nU R                  US5      nU R                  US5      nU R	                  XQS5      $ )a\  
fetch deposit and withdraw fees

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-currency-networks

:param str[]|None codes: list of unified currency codes
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
rZ  r[  rk  )r  rr  r  r{  parse_deposit_withdraw_fees)rS  rJ  r  r  r  r  s         rU  fetch_deposit_withdraw_fees%cryptocom.fetch_deposit_withdraw_fees	  sS     	??Gx2nnT>://KPPrW  c                 v   U R                  5         0 nSnUb  U R                  U5      nUb  X%S'   Ub  X5S'   U R                  US5      nU R                  US/5      nUb  XuS'   U R	                  U R                  XT5      5      nU R                  US0 5      n	U R                  U	S/ 5      n
U R                  XX#5      $ )ad  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-transactions

:param str [code]: unified currency code
:param int [since]: timestamp in ms of the earliest ledger entry
:param int [limit]: max number of ledger entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms for the ending date filter, default is the current time
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
Nr  r  r  r  rZ  r  )	r  r  r  r  #v1PrivatePostPrivateGetTransactionsr  ru  r{  parse_ledger)rS  rn  r  r  r  r  r  r  r  rZ  ledgers              rU  fetch_ledgercryptocom.fetch_ledger	  s     	))$/H$)L!$G!!&'26G9-"'J;;DKK<XY< (B73  5@@rW  itemc                 h   U R                  US5      nU R                  US5      nU R                  XB5      nU R                  XB5      nU R                  US5      nS n[        R
                  " US5      (       a  Sn[        R                  " U5      nOSnU R                  UU R                  US5      UU R                  US5      U R                  US	5      U R                  US
5      U R                  U R                  US5      5      UU R                  U5      UU R                  U5      S S S S S S.S.U5      $ )Nevent_timestamp_msr  transaction_qtyr   outinr  
account_idr  trade_match_idjournal_typer  )rd  r7   	directionr	  referenceIdreferenceAccountro  r  rl  r   r  beforeafterr  rh  )r  r|  rz  r  r1   r;  
string_abssafe_ledger_entryparse_ledger_entry_typerR  r  )rS  rU  r  r   r  rn  rl  r^  s           rU  parse_ledger_entrycryptocom.parse_ledger_entry9
  sB   * %%d,@A	%%d,=>
&&z<%%j;!!$(9:	VS))I''/FI%%""44"''l;++D*= $ 0 07G H001A1A$1WX''/"Y/ '
& ' 	rW  c                     0 SS_SS_SS_SS_SS	_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSS.EnU R                  X!U5      $ )NTRADINGr  	TRADE_FEErh  WITHDRAW_FEEWITHDRAWr1  DEPOSITrg  ROLLBACK_WITHDRAWrollbackROLLBACK_DEPOSITFUNDINGREALIZED_PNLINSURANCE_FUND	insuranceSOCIALIZED_LOSSLIQUIDATION_FEESESSION_RESETreset
ADJUSTMENT
adjustmentSESSION_SETTLE
settlementUNCOVERED_LOSSADMIN_ADJUSTMENTdelist
conversion)DELISTSETTLEMENT_FEEAUTO_CONVERSIONMANUAL_CONVERSIONr  )rS  ro  
ledgerTypes      rU  re  !cryptocom.parse_ledger_entry_typen
  s    
w

 E
 	

 y
  
 

 u
 G
 k
 w
 u
 W
 ,
 l
  g!
" #
$ #+!-+

. 
$77rW  c                     U R                  5         U R                  U5      nU R                  US0 5      nU R                  US0 5      nU R                  US/ 5      nUR	                  U5        U R                  XQ5      $ )aV  
fetch all the accounts associated with a profile

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-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
rZ  master_accountsub_account_list)r  v1PrivatePostPrivateGetAccountsru  r{  r  parse_accounts)rS  r  r  rZ  masterAccountaccountss         rU  fetch_accountscryptocom.fetch_accounts
  sx     	77?@ (B7v/?D>>&*<bA&""844rW  c                 P    U R                  US5      U R                  US5      S US.$ )Nuuidlabel)r7   ro  rn  rd  r  )rS  r	  s     rU  parse_accountcryptocom.parse_account
  s4    6 ""7F3$$Wg6	
 	
rW  c                    U R                  5         SnUb  U R                  U5      nSnU R                  SXT5      u  pdU R                  SUS/ SQ5        US:X  a  SnSUR	                  5       0nU R                  U R                  Xt5      5      nU R                  US0 5      n	U R                  U	S	/ 5      n
U R                  X5      nU R                  US
5      nU R                  XX#5      $ )a  
fetches historical settlement records

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-expired-settlement-price

:param str symbol: unified market symbol of the settlement history
:param int [since]: timestamp in ms
:param int [limit]: number of records
:param dict [params]: exchange specific params
:param int [params.type]: 'future', 'option'
:returns dict[]: a list of `settlement history objects <https://docs.ccxt.com/#/?id=settlement-history-structure>`
Nr   ro  )rF   rG   r  r  rG   r  instrument_typerZ  r  r   )r  r  r6  check_required_argumentr3  *v1PublicGetPublicGetExpiredSettlementPricer  ru  r{  parse_settlementssort_byfilter_by_symbol_since_limit)rS  r  r  r  r  r  ro  r  r  rZ  r  settlementssorteds                rU  fetch_settlement_history"cryptocom.fetch_settlement_history
  s     	[[(F99:RTZc$$%=tVMvw8Dtzz|
 BB4;;wC_`$ (B7~~ffb1,,T:k;700NNrW  c                     U R                  US5      nU R                  US5      nUU R                  XB5      U R                  US5      UU R	                  U5      S.$ )Nxr  r  )rd  r  r  r   r  )r  r|  r  r  r  )rS  r|  r  r   rR  s        rU  parse_settlementcryptocom.parse_settlement
  sb     %%j#6	##J4&&x8%%j#6"Y/
 	
rW  c                     / n[        S[        U5      5       H&  nUR                  U R                  X   U5      5        M(     U$ )Nr   )rx  ry  r  r  )rS  r  r  rZ  r  s        rU  r  cryptocom.parse_settlements  s?     q#k*+AMM$//GH ,rW  c                 n   U R                  5         U R                  U5      nUS   (       d  [        U R                  S-   5      eUS   SSS.nU R	                  U R                  XB5      5      nU R                  US0 5      nU R                  US/ 5      nU R                  US	0 5      nU R                  X5      $ )
a  
fetches historical funding rates

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-valuations

:param str symbol: unified symbol of the market to fetch the funding rate history for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
rE   z0 fetchFundingRate() supports swap contracts onlyr7   estimated_funding_rater   )r  valuation_typer  rZ  r  r   )	r  r  r&   r7   v1PublicGetPublicGetValuationsr  ru  r{  parse_funding_rate)	rS  r  r  r  r  r  rZ  r  entrys	            rU  fetch_funding_ratecryptocom.fetch_funding_rate-  s     	V$f~DGG&XXYY%d|6

 66t{{77ST" (B7~~ffb1tQ+&&u55rW  c                 h   U R                  US5      nS nUb%  [        [        R                  " US-  5      5      S-  n0 SU_SU R	                  S U5      _SS _SS _SS _SS _S	U_S
U R                  U5      _SU R                  US5      _SU_SU R                  U5      _SS _SS _SS _SS _SS _SS _SS0E$ )Nr  i6 rd  r  	markPrice
indexPriceinterestRateestimatedSettlePricer   r  fundingRater  fundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimeintervalr   )r  r  mathceilr  r  r  )rS  r  r  r   r  s        rU  r  cryptocom.parse_funding_rateV  sL    %%h4	 "499Y-@#ABWL
H
d&&tV4
 
 $	

 D
 #D
 
 Y/
 4++Hc:
  0
 t||,<=
 t
 #D
 "4
 "4
  '!
" &t#
$ %
 	
rW  c           
         Uc  [        U R                  S-   5      eU R                  5         SnU R                  USS5      u  pTU(       a  U R	                  SXUSU5      $ U R                  U5      nUS   (       d  [        U R                  S-   5      eUS   S	S
.nUb  X'S'   Ub  X7S'   U R                  US5      nU R                  US/5      nUb  XS'   U R                  U R                  Xt5      5      n	U R                  U	S0 5      n
U R                  U
S/ 5      nU R                  U
S5      n/ n[        S[        U5      5       H^  nX   nU R                  US5      nUR!                  UU R#                  X5      U R%                  US5      UU R'                  U5      S.5        M`     U R)                  US5      nU R+                  UUS   X#5      $ )as  
fetches historical funding rates

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-valuations

:param str symbol: unified symbol of the market to fetch the funding rate history for
:param int [since]: timestamp in ms of the earliest funding rate to fetch
:param int [limit]: the maximum amount of [funding rate structures] to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms for the ending date filter, default is the current time
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
z5 fetchFundingRateHistory() requires a symbol argumentFrk   r  8hrE   z7 fetchFundingRateHistory() supports swap contracts onlyr7   funding_hist)r  r  r  r  r  r  rZ  r  r  r   r  r  )rd  r  r  r   r  r   r  )r$   r7   r  rq  r  r  r&   r  r  r  r  ru  r{  r|  rx  ry  r  r  r  r  r  r  )rS  r  r  r  r  r  r  r  r  r  rZ  r  rR  ratesr  r  r   r  s                     rU  fetch_funding_rate_history$cryptocom.fetch_funding_rate_historyv  s    >#DGG.e$eff88AZ\fg::;TV\ejlprxyyV$f~DGG&__``%d|,
 "'J$G!!&'26G9- %H66t{{77ST" (B7~~ffb1##F,=>q#d)$AGE))%5ILL**8<#//s;& LL3  % e[1009I5XXrW  c                 "   U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US0 5      nU R                  US/ 5      nU R                  U R	                  US5      U5      $ )a  
fetch data on a single open contract trade position

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-positions

:param str symbol: unified market symbol of the market the position is held in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
r  r7   rZ  r  r   )r  r   v1PrivatePostPrivateGetPositionsr  ru  r{  parse_position)rS  r  r  r  r  r  rZ  r  s           rU  fetch_positioncryptocom.fetch_position  s     	V$vd|
 88W9UV. (B7~~ffb1""4>>$#:FCCrW  c                    U R                  5         U R                  U5      n0 nSnUba  Sn[        U[        5      (       a/  [	        U5      nUS:  a  [        U R                  S-   5      eUS   nOUnU R                  U5      nUS   US'   U R                  U R                  X25      5      nU R                  US0 5      nU R                  US/ 5      n	/ n
[        S[	        U	5      5       HM  nX   nU R                  US5      nU R                  USSS	5      nU
R                  U R!                  X5      5        MO     U R#                  U
S
SS5      $ )aZ  
fetch all open positions

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-positions

:param str[]|None symbols: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nr   zD fetchPositions() symbols argument cannot contain more than 1 symbolr   r7   r  rZ  r  r  r  F)r  market_symbolsrt  rv  ry  r%   r7   r  r  r  ru  r{  rx  r|  r  r  r  filter_by_array_positions)rS  r  r  r  r  r  r  r  r  	positionsrZ  r  r  rR  marketInners                  rU  fetch_positionscryptocom.fetch_positions  sL    	%%g.F'4(( #G 1$$TWW/u%uvv  [[(F)/G%&88W9UV. (B?NN>62>	q#i.)ALE''/@AH**8T4LKMM$--eAB	 *
 --fheLLrW  positionc                 @   U R                  US5      nU R                  X2S S5      nU R                  X2S S5      nU R                  US5      nU R                  US5      nU R	                  0 SU_SS _SU_SU_S	U R                  U5      _S
S _S[        R                  " US5      (       a  SOS_S[        R                  " U5      _SUS   _SS _SS _SS _SS _SU R                  US5      _SU R                  US5      _SS _SS _S U R                  US5      S S S S S S S.E5      $ )Nr  r  update_timestamp_msr  rd  r7   r  r   r  r   r  r   r.  sell	contractsr  
entryPricer  r]  r  
collateralopen_pos_costinitialMarginr  maintenanceMargininitialMarginPercentageopen_position_pnl)maintenanceMarginPercentageunrealizedPnlliquidationPricer   r  marginRatior   r   )
r|  r  r  r  safe_positionr  r1   	string_gtrc  r  )rS  r  r  rR  r  r   rl  s          rU  r  cryptocom.parse_position   s    ##H.?@!!(D*E!!(D*E%%h0EF	!!(J7!! #
H#
$#
 f#
 	#

 Y/#
 d#
 W..vs;;E#
 ++F3#
 F>2#
 $#
 #
 #
 #
 $**8_E#
 T--h?#
   !#
" &t##
$ ,0!--h8KL $!#3#
  	rW  c                 "    U R                  5       $ N)milliseconds)rS  s    rU  noncecryptocom.nonceO  s      ""rW  c                    SnX#:  a  [        U5      $ [        U[         5      (       a  U$ SnS n[        U[        5      (       a  UnO*U R                  U5      n[        UR	                  5       5      n[        S[        U5      5       Hv  nXW   nXH-  nX   n	U	S:X  a  US-  nM  [        U	[        5      (       a7  [        S[        U	5      5       H  n
X@R                  X   US-   5      -  nM     Mh  U[        U	5      -  nMx     U$ )N    r   Noner   )r}  rt  rv  keysortrw  rx  ry  params_to_string)rS  objectlevelmaxLevelreturnString
paramsKeysr  r  r  r  r  s              rU  r  cryptocom.params_to_stringR  s    v;fc""M
fd##J\\&)Ffkkm,Jq#j/*A-CLKE&E4((q#e*-A $9$9%(EAI$NNL . E
* + rW  c                 f   U R                  5         U R                  U5      nUS   SS.nU R                  US5      nU R                  US5      nUb  XeS'   Ub  U R	                  US   U5      US'   U R                  U R                  XS5      5      nU R                  US5      n	U R                  X5      $ )aH  
       closes open positions for a market

       https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-close-position

       :param str symbol: Unified CCXT market symbol
       :param str [side]: not used by cryptocom.closePositions
       :param dict [params]: extra parameters specific to the okx api endpoint

EXCHANGE SPECIFIC PARAMETERS
       :param str [params.type]: LIMIT or MARKET
       :param number [params.price]: for limit orders only
       :returns dict[]: `A list of position structures <https://docs.ccxt.com/#/?id=position-structure>`
       r7   r[  )r  ro  ro  r  r  rZ  )	r  r  r  r|  r5  !v1PrivatePostPrivateClosePositionr  ru  r  )
rS  r  r  r  r  r  ro  r  r  rZ  s
             rU  close_positioncryptocom.close_positionl  s     	V$%d|
 %%ff5  1"FO#66vh7GOGG99$++g:VW (3//rW  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US0 5      nU R                  Xc5      $ )aJ  
fetch the trading fees for a market

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-instrument-fee-rate

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
r  r7   rZ  )r  r  (v1PrivatePostPrivateGetInstrumentFeeRater  ru  parse_trading_fee)rS  r  r  r  r  r  r  s          rU  fetch_trading_feecryptocom.fetch_trading_fee  sn     	V$vd|
 @@WA]^  ~~h"5%%d33rW  c                     U R                  5         U R                  U5      nU R                  US0 5      nU R                  U5      $ )aG  

https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-fee-rate

fetch the trading fees for multiple markets
: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
rZ  )r  v1PrivatePostPrivateGetFeeRateru  parse_trading_fees)rS  r  r  rZ  s       rU  fetch_trading_feescryptocom.fetch_trading_fees  sE     	66v>  (B7&&v..rW  c                    0 nXS'   [        S[        U R                  5      5       H  nU R                  U   nU R                  U5      nUS   nU(       a  SOSnU(       a  SOSnUUU R	                  [
        R                  " U R                  X5      S5      5      U R	                  [
        R                  " U R                  X5      S5      5      S S S	.n	XU'   M     U$ )
Nrd  r   rE   effective_deriv_taker_rate_bpseffective_spot_taker_rate_bpseffective_deriv_maker_rate_bpseffective_spot_maker_rate_bpsr   rd  r  r   r   r  	tierBased)rx  ry  r  r  rR  r1   
string_divr|  )
rS  r  rZ  r  r  r  isSwaptakerFeeKeymakerFeeKey
tradingFees
             rU  r  cryptocom.parse_trading_fees  s     !vq#dll+,A\\!_F[[(FF^F>D:JiK>D:JiK  **7+=+=d>N>Nx>egn+op**7+=+=d>N>Nx>egn+op"!J (6N - rW  rh  c                 *   U R                  US5      nU R                  X25      nUUU R                  [        R                  " U R                  US5      S5      5      U R                  [        R                  " U R                  US5      S5      5      S S S.$ )Nr  effective_maker_rate_bpsr   effective_taker_rate_bpsr	  )r|  r  rR  r1   r  )rS  rh  r  rR  r  s        rU  r  cryptocom.parse_trading_fee  s     ##C):;!!(3&&w'9'9$:J:J3Pj:kmt'uv&&w'9'9$:J:J3Pj:kmt'uv
 	
rW  r   GETc           	      6   U R                  US5      nU R                  US5      nU R                  S   U   S-   U-   n	U R                  X@R                  U5      5      n
US:X  a   U
(       a  U	SU R	                  U
5      -   -  n	GOU R                  5         [        U R                  5       5      nU R                  0 U5      n[        UR                  5       5      nU R                  US5      nX-   U R                  -   U-   U-   nU R                  U R                  U5      U R                  U R                  5      [         R"                  5      n[%        U5      nU R'                  UUUU R                  UUS.5      nUS:X  a  SnS	nUR)                  UU5      nS
S0nXXeS.$ )Nr   r   r   r  r   r  )r7   methodr  api_keysigr  z{}z[]zContent-Typezapplication/json)r   r  bodyheaders)r|  r   r  extract_params	urlencoderp  r}  r  r  rv  rw  r  apiKeyhmacencodesecrethashlibsha256ry  jsonreplace)rS  pathr   r  r  r  r  ro  accessr   queryr  requestParamsr  
strSortKeypayload	signatureparamsKeysLengthparamsStringarrayStrings                       rU  signcryptocom.sign  s   Q'!!#q)iit$s*T1		&"5"5d";<XsT^^E222++-

%E KKF3Mm0023J..}a@JlT[[0:=EG		$++g"6DKK8PRYR`R`aI":99 ;;  D  1$#"||K> 2G dOOrW  reasonr   r  r  r  c
                     U R                  US5      n
U
S:w  aL  U R                  S-   U-   nU R                  U R                  S   X5        [	        U R                  S-   U-   5      eg )Nrn  r    rM  )r|  r7   throw_exactly_matched_exceptionr  r    )rS  rn  r2  r   r  r  r  r  requestHeadersrequestBody	errorCodefeedbacks               rU  handle_errorscryptocom.handle_errors-  sb    $$Xv6	ww}t+H001I9_# 455rW   r  )g__name__
__module____qualname____firstlineno__r   rQ  r   r  r   r   r  r   r   r  r}  r   r  r   r   r   r  r   r  rv  r  r   r  r   r  r  r  r   r   floatr   rB  rF  r   rX  rN  rh  rf  rt  rx  r  r   r  r  r  r  r   r   r
   r  r  r  r  dictr  r  r  r
  r  r  r&  r,  r	   r  r7  rH  rM  r   rS  rf  re  r   r  r  r  r  r  r  r   r  r  r  r   r  r  r  r  r  r   r  r   r  r  r  r0  r  r:  __static_attributes____classcell__)rT  s   @rU  r3   r3       s^   @# @D ') xZ xt $& {$v, {z 04B 41W 417 41l 02 03 0f 0 *.Dt\^ J?3 J?c J? J?cghmcn J?X 6:UW 6?3 6?s 6?# 6?\`af\g 6?p 9=4^bkm AH# AH# AHS AHX[ AHrvw{r| AHF :>b )Cs )C3 )CY )CV) ) $& 6,( 6,p 26b 5/c 5/3 5/n os{} P,3 P,i P,y P,Z_ P,hk P,d gksu #03 #0i #0y #0RW #0`c #0J @B K)D$6 K)Z x|  EG ^,C ^,y ^,PY ^,ch ^,qt ^,@ `drv  @B (S (# (Y (i (Y\ (lo (, TX`b ,S ,# ,u ,S ," /32 5 5& 37r  0s  0C  0D ;?r Ec EC E> SU C5H0I C< /3TXac :? :?3 :?c :?hlmrhs :?x -1tRV_a @?c @? @?C @?D
 KOWY .8S .8% .8# .8C .8^i .8` DF 9s 9$~J^ 9v 79 -# -^ -& *.Dt\^ 5L3 5Lc 5L 5Lcghsct 5Ln -1tRV_a 7Oc 7O 7OC 7Ofjkvfw 7Or;4 ; ;6 ;z9 9v 9 9v
 
4 
(: :Hs H\ \v \ \|:
:S
T S
X S
Q\ S
j GI $(, ,\ <@ Q Q  (,$TZ\ :A :AC :As :Aaefqar :Ax3t 3x 3; 3j84 %' .54= .5`
B 6:[_hj /Os /O# /OUX /Ob
&  68 '6 '6R
6 
[ 
@ 8<$]ajl DY DYC DYWZ DYL 24 (DS (DT 26b 8Mw 8MT(^ 8Mt-t -V -^#4 =A (0S (0	 (0PU (0T 57  4  4;N  4D )+ /{ /:<
T 
6 
EX 
& &eBSW %PN# s  c TX `c  rW  r3   )9ccxt.base.exchanger   ccxt.abstract.cryptocomr   r"  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   ccxt.base.decimal_to_precisionr0   ccxt.base.preciser1   r3   r<  rW  rU  <module>rL     s    ( /   o  o  o  o  o  o  o  * 0 - . . ' & . ) * ) + . * ) + 4 %S4+ S4rW  