
    E#i                       S SK Jr  S SKJr  S SK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!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)AnyBalancesBool
CurrenciesCurrencyDepositAddressIntLedgerEntryLeverage
MarginModeMarginModificationMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateTradeTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)DDoSProtection)RateLimitExceeded)OnMaintenance)InvalidNonce)	TICK_SIZE)Precisec                   	  ^  \ rS rSrS\4U 4S jjr0 4S jr0 4S\4S jjr0 4S\	4S jjr
S0 4S\4S	 jjrSS
\4S jjr0 4S\\   4S jjrS\S\4S jrS r0 4S\S\4S jjrS0 4S\S\4S jjrSS\S\4S jjrS0 4S\S\S\4S jjrSSS0 4S\S\S\S\S\\   4
S jjrSS\S\4S jjrSS0 4S\S\S\S\\    4S jjr!SS\S\S\ 4S jjr"0 4S\S\#4S jjr$SS\4S  jjr%SS!\&S"\S#\S$\&S%\4
S& jjr'SSS0 4S\(S\S\4S' jjr)0 4S\*4S( jjr+S\*4S) jr,0 4S*\S+\-S,\S-\S\.4
S. jjr/SS
\4S/ jjr00 4S*\S\14S0 jjr2SS
\S\14S1 jjr3SSS0 4S*\(S\S\S\\4   4S2 jjr5SSS0 4S*\(S\S\S\\4   4S3 jjr6S0 4S*\S+\-S4\S5\(S\44
S6 jjr7SS
\S\44S7 jjr80 4S\S8\-4S9 jjr9S0 4S\S:\:S;\;S+\-S<\<S\=4S= jjr>S0 4S\S:\:S;\;S+\-S<\<S\=4S> jjr?S0 4S\S:\:S;\;S+\-S<\<S\4S? jjr@0 SSSS@4S"\S!\S<\<S+\<S8\(S;\4SA jjrA0 SB4S"\S!\SC\B4SD jjrCS0 4S\S:\:S;\;S+\-S<\<S\=4SE jjrDS0 4S\S:\:S;\;S+\-S<\<S\4SF jjrESG0 4SH jrFSSS0 4S\S:\:S;\;S+\-S<\<SI\<SJ\<S\=4U 4SK jjjrGSL\(S\(4SM jrH0 4SN\\I   4SO jjrJS0 4S\S:\:S;\;S+\-S<\<S\4SP jjrKSS0 4SQ\S\S:\:S;\;S+\<S<\<4SR jjrLS0 4SQ\S\S:\:S;\;S+\-S<\<4SS jjrMS0 4SQ\S\(S\=4ST jjrNSSS0 4S\(S\S\S\\=   4SU jjrOSSS0 4S\(S\S\S\\=   4SV jjrPSSS0 4S\(S\S\S\\=   4SW jjrQSSS0 4S\(S\S\S\\=   4SX jjrRSSS0 4S\(S\S\S\\=   4SY jjrSSSS0 4S\(S\S\S\\=   4SZ jjrTS0 4SQ\S\(4S[ jjrUS0 4S\(4S\ jjrVS0 4S]\\   S\(4S^ jjrWS_ rXSS\=4S` jjrYSa\(S\(4Sb jrZS;\(S\(4Sc jr[SL\(S\(4Sd jr\Se\(4Sf jr]SSS0 4S\(S\S\S\\    4Sg jjr^SSS0 4SQ\S\(S\S\S\\    4
Sh jjr_0 4S\S\`4Si jjraSSj\S\`4Sk jjrbS:\S\4Sl jrcS0 4Sj\S\(4Sm jjrdS:\S\4Sn jreS0 4S\(4So jjrfS0 4Sp\gS\(4Sq jjrh0 4S\S\i4Sr jjrjS0 4Ss\kS\(4St jjrlSSs\S\S\i4Su jjrm0 4S\S\n4Sv jjroSSw\S\S\n4Sx jjrp0 4S\S+\-S\n4Sy jjrq0 4S\S+\-S\n4Sz jjrr0 4S\S\s4S{ jjrt0 4S\S\\s   4S| jjruS0 4S\S\\s   4S} jjrvSS~\S\4S jjrwSS\(S\S\(S\4S jjrxSSS0 4S*\(S\S\4S jjrySS\S
\S\z4S jjr{S:\S\4S jr|S*\kS\S\S\S\S\4S jr}SS0 SS4S jr~SrU =r$ )	coincatch   returnc                 n  > 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_S/S_S0S_S1S_E0 S2S_S3S_S4S_S5S_S6S_S7S_S8S_S9S_S:S_S;S_S<S_S=S_S>S_S?S_S@S_SAS_SBS_E0 SCS_SDS_SES_SFS_SGS_SHS_SIS_SJS_SKS_SLS_SMS_SNS_SOS_SPS_SQS_SRS_SSS_E0 STS_SUS_SVS_SWS_SXS_SYS_SZS_S[S_S\S_S]S_S^S_S_S_S`S_SaS_SbS_ScS_SdS_ESSSSSSSSSSSSSe.E_SfSgShSiSjSkSlSmSnSoSpSqSrSsStSu._SvSwSxSxSy.SzS{S|S}S~S.S._SS0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSS.	E00 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSS.E0 SS_SS_SS_SS_SS_SSSS._SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSS._SS_SS_SS_SS_SS_SS_ESSSSSSSSS.ES.Sy._SSSSS._SSSSSSU R	                  S5      U R	                  S5      S.00_SSSSSSSSSSSSSSStS.SgShSiSjSkSlSmSnSoSpSqSrSsStSu.S.S S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SG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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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SSSGSGS
GSGSGSGSGS)GSGS*GS+SGS,.GS-._GS.SSSSSSGS/.SSSS SSSSGS0.SSSSSSSGS1.GS2S0SGS3GS4GS4SGS5.SSSSGS6.SGS7SSSSGS8.S S GS9GS:0GS;.	GS<GS=0GS=GS>S SGS?.0GS9GS70GS@.GS<GSA0GS<GSA0GSB.S S GSB.GSC._GSD0 _GSE0 GSF[
        _GSG[        _GSH[        _GSI[        _GSJ[        _GSK[        _GSL[        _GSM[        _GSN[        _GSO[        _GSP[        _GSQ[        _GSR[        _GSS[        _GST[        _GSU[        _GSV[        _0 GSW[        _GSX[        _GSY[        _GSZ[        _GS[[        _GS\[        _GS][        _GS^[        _GS_[        _GS`[        _GSa[        _GSb[        _GSc[        _GSd[        _GSe[        _GSf[        _GSg[        _E0 GSh[
        _GSi[        _GSj[
        _GSk[        _GSl[        _GSm[        _GSn[        _GSo[        _GSp[        _GSq[        _GSr[        _GSs[        _GSt[        _GSu[        _GSv[        _GSw[        _E0 GSx._GSy[         0E5      $ (z  Nidr2   name	CoinCatch	countriesVG	rateLimit2   versionv1	certifiedFproThasCORSspotmarginswapfutureoption	addMargincancelAllOrderscancelAllOrdersAftercancelOrdercancelOrderscancelWithdrawclosePositioncreateConvertTradecreateDepositAddresscreateLimitBuyOrdercreateLimitSellOrdercreateMarketBuyOrdercreateMarketBuyOrderWithCostcreateMarketOrdercreateMarketOrderWithCostcreateMarketSellOrdercreateMarketSellOrderWithCostcreateOrdercreateOrders$createOrderWithTakeProfitAndStopLosscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingAmountOrdercreateTrailingPercentOrdercreateTriggerOrderfetchAccountsfetchBalancefetchCanceledAndClosedOrdersfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCurrenciesfetchDepositAddressfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchLedgerfetchLeveragefetchLeverageTiersfetchMarginAdjustmentHistoryfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFee)fetchTradingFeesfetchTransactionsfetchTransfersfetchWithdrawalsreduceMarginsandboxsetLeverage	setMarginsetMarginModesetPositionModetransferwithdraw
timeframes1m3m5m15m30m1H2H4H6H12H1D3D1W1M)r   r   r   15301h2h4h6h12h1d3d1wr   urlszOhttps://github.com/user-attachments/assets/3d49065f-f05d-4573-88a2-1b5201ec6ff3zhttps://api.coincatch.com)publicprivatezhttps://www.coincatch.com/z)https://coincatch.github.io/github.io/en/z"https://www.coincatch.com/en/rate/z5https://partner.coincatch.cc/bg/92hy70391729607848548g?)urldiscount)logoapiwwwdocfeesreferralr   getzapi/spot/v1/public/time   zapi/spot/v1/public/currenciesg@zapi/spot/v1/market/tickerzapi/spot/v1/market/tickerszapi/spot/v1/market/fills   z api/spot/v1/market/fills-historyzapi/spot/v1/market/candlesz"api/spot/v1/market/history-candleszapi/spot/v1/market/depthzapi/spot/v1/market/merge-depthzapi/mix/v1/market/contractszapi/mix/v1/market/merge-depthzapi/mix/v1/market/depthzapi/mix/v1/market/tickerzapi/mix/v1/market/tickerszapi/mix/v1/market/fillszapi/mix/v1/market/fills-history)	zapi/mix/v1/market/candleszpi/mix/v1/market/indexzapi/mix/v1/market/funding-timez"api/mix/v1/market/history-fundRatez"api/mix/v1/market/current-fundRatezapi/mix/v1/market/open-interestzapi/mix/v1/market/mark-pricez!api/mix/v1/market/symbol-leveragez$api/mix/v1/market/queryPositionLeverz"api/spot/v1/wallet/deposit-address   z!pi/spot/v1/wallet/withdrawal-listz%api/spot/v1/wallet/withdrawal-list-v2zapi/spot/v1/wallet/deposit-listzapi/spot/v1/account/getInfozapi/spot/v1/account/assetsz#api/spot/v1/account/transferRecordszapi/mix/v1/account/accountzapi/mix/v1/account/accountsz%api/mix/v1/position/singlePosition-v2z"api/mix/v1/position/allPosition-v2zapi/mix/v1/account/accountBillz&api/mix/v1/account/accountBusinessBillzapi/mix/v1/order/currentz"api/mix/v1/order/marginCoinCurrentzapi/mix/v1/order/historyz#api/mix/v1/order/historyProductType)zapi/mix/v1/order/detailzapi/mix/v1/order/fillszapi/mix/v1/order/allFillszapi/mix/v1/plan/currentPlanzapi/mix/v1/plan/historyPlanzapi/spot/v1/wallet/transfer-v2z api/spot/v1/wallet/withdrawal-v2z&api/spot/v1/wallet/withdrawal-inner-v2zapi/spot/v1/account/billszapi/spot/v1/trade/orderszapi/spot/v1/trade/batch-orders
   )coststepzapi/spot/v1/trade/cancel-orderz!api/spot/v1/trade/cancel-order-v2z%api/spot/v1/trade/cancel-symbol-orderz%api/spot/v1/trade/cancel-batch-ordersz(api/spot/v1/trade/cancel-batch-orders-v2zapi/spot/v1/trade/orderInfozapi/spot/v1/trade/open-orderszapi/spot/v1/trade/historyzapi/spot/v1/trade/fillszapi/spot/v1/plan/placePlanzapi/spot/v1/plan/modifyPlanzapi/spot/v1/plan/cancelPlanzapi/spot/v1/plan/currentPlanzapi/spot/v1/plan/historyPlanz api/spot/v1/plan/batchCancelPlanzapi/mix/v1/account/open-countzapi/mix/v1/account/setLeveragezapi/mix/v1/account/setMarginz api/mix/v1/account/setMarginModez"api/mix/v1/account/setPositionModezapi/mix/v1/order/placeOrderzapi/mix/v1/order/batch-orderszapi/mix/v1/order/cancel-orderz$api/mix/v1/order/cancel-batch-ordersz%api/mix/v1/order/cancel-symbol-ordersz"api/mix/v1/order/cancel-all-orderszapi/mix/v1/plan/placePlanzapi/mix/v1/plan/modifyPlan)z api/mix/v1/plan/modifyPlanPresetzapi/mix/v1/plan/placeTPSLzapi/mix/v1/plan/placeTrailStopz"api/mix/v1/plan/placePositionsTPSLzapi/mix/v1/plan/modifyTPSLPlanzapi/mix/v1/plan/cancelPlanz api/mix/v1/plan/cancelSymbolPlanzapi/mix/v1/plan/cancelAllPlan)r   postrequiredCredentials)apiKeysecretpasswordr   tradingz0.001)	tierBased
percentagefeeSidemakertakeroptions47cfy1min5min15min30minr   r   r   r   1day3day1week)r   r   r   r   r   r   r   r   r   r   r   r   )rC   rE    BTCBITCOINERC20TRC20BEP20ARBArbitrumOneOPTIMISMOptimismLTCBCHETCSOLNEO3STXstacksEGLDElrondNEARNEARProtocolACA
AcalaTokenKLAYKlaytnFTMFantomTERRATerraWAVESTAOSUISEIRUNE	THORChainZILSXPSolarFETAVAXC-ChainXRPEOSDOGEDOGECOINCAP20MATICPolygonCSPRGLMRMoonbeamMINACFX
StratisEVMCelestiaChilizChainAptosOntologyICPCardanoFILCELODOTStellarLumensATOMCronosChain)r  r  STRATTIAr  APTONTr  ADAr  r  r   XLMr"  CROr$  r)  r*  )r   z
TRX(TRC20)r   r  r  r
  r  	CFXeSpacer  r  r  r!  r#  r   )brokerId!createMarketBuyOrderRequiresPricer   currencyIdsListForParseMarketbrokernetworksnetworksByIdfeatures)lastmarkindex)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergmax  i )r:  limitdaysBack	untilDayssymbolRequired)r:  triggerrC  rN  d   )r:  rK  rO  rC  
marketTyperN  rK    )	r   rY   rZ   r   r   r   r   rk   r   extendsdefaultr@  )r<  price)rS  rY   r   forDerivatives)linearinverse)rT  rC   rV  rE   rF   commonCurrencies
exceptions220014294000140002400034000540006400074000840009400114001240013400144001540016400174001840019400204003440017240912409134010240200403054040940704407244072540762407744080843001430024300443005430064300743008430094301043011430124311743118431224500645110)exactbroadprecisionMode)deep_extendsuperr2   describeparse_numberr)   r+   r"   r.   r%   r!   r#   r-   r'   r(   r,   r/   )self	__class__s    V/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/coincatch.pyr  coincatch.describe!   s   i ? A zD
+zD
KzD
 $zD
 	zD

 tzD
 zD
 4zD
  bbb %b 	b
 %b %b Tb "4b 'b tb b !%b  b %eb 'b  &t!b" '#b$ '%b& /'b( $T)b* ,U+b, (-b. 0/b0 t1b2 3b4 75b6 &t7b8 (9b: ';b< &t=b> (?b@ "4AbB (CbD ,UEbF -eGbH %dIbJ  KbL MbN /ObP &uQbR #ESbT $UUbV )%WbX $UYbZ $U[b\ +E]b^ "4_b` &tabb  cbd +Eebf +Dgbh &uibj #Dkbl *4mbn $Uobp "5qbr tsbt  ubv %ewbx /ybz "4{b| }b~ !$b@  AbB dCbD +EEbF !%GbH "4IbJ dKbL !$MbN uObP #DQbR  SbT 'UbV $TWbX !$YbZ *4[b\ (]b^ )%_b` uabb tcbd ebf Tgbh tibj "5kbl %*%*"'$( $ #"!%#'! CbzD
V WzD
v i9: 4B<R #wzD
R  117 4Q 5a	
 3A ;A 5a =a 3A 9! 6q 8 21 3A 4Q  21!" :1#$ 6723:;>?>?;<89=>@A5><a;Q @ :1	
 6q 5a >q 5a 6q @ =a 9! A! 3A =a  3A!" >q#$ 4523567878-0+8!+:A+ A!+ 4Q	+
 3A+ 91b:Q+ 9!+ <Q+ @+ @+ CA+ 6q+ 8+ 4Q+ 21+  5a!+" 6q#+$ 6q%+& 7'+( 7)+* ;A++, 8-+. 9!/+0 71+2 ;A3+4 =a5+6 6q7+8 8!R9P9+: 8;+< ?=+> @?+@ =aA+B 4QC+D 5aE+F =>56:;>?:;67<=9:U+3E?eSzD
^ " $_zD
h %*&*#(!%!2!27!;!%!2!27!;
izD
~ #59 %$&&"""$$$%" #""##""""$""""@ 26292W2 W2 W	2
 =2 
2 52 52 52 52 F2 82 H2 N2 <2  H!2" 8#2$ W%2& W'2( 5)2* 5+2, 5-2. K/20 5122 7324 5526 I728 592: 5;2< J=2> W?2@ YA2B FC2D JE2F # )%#0"% $ " *"(c2h %")#(!'"%$!& ")#0%*#( *!qhzD
P $&+(,$($(%*-
 -2).+06:#'#'"&#(	( #($)$)+/27/4#(1$6 r% ',!$$*%+*.& ',#($)*/	# ',!$#'$)&**/( $()-#m9v y  ) 504%*7$  &# "#3 "#3 	 ##gWQzD
@ AzD
B 4]4>4 04 0	4
 04 \4 04 Z4 \4 04 04 04 ]4 -4 ]4  -!4" ]#4$ -%4& Z'4( Z)4* Z+4, j-4. Z/40 Z142 Z344 ]546 Z748 ]94: ];4< Z=4> ]?4@ .A4B ZC4D ZE4F ]G4H \I4J ]K4L .M4N ZO4P ZQ4R ZS4T ZU4V ZW4X ZY4Z .[4\ .]4^ Z_4` Za4b .c4d Ze4j m7CzD
r YszD
 z z	    c                     U R                  US5      nU R                  USS5      nU R                  USS/ 5      n[        U5      n	Ub*  X:  a%  [        [        R
                  " X-  5      5      n
Xz-  $ U$ )Nr   r   r   	orderListorderDataList)safe_integersafe_list_2lenintmathceil)r  r   methodpathparamsconfigr   r   ordersordersLengthnumberOfStepss              r  calculate_rate_limiter_cost%coincatch.calculate_rate_limiter_cost  sv      0  3!!&+K6{<#6		,*= >?M''Kr  c                 d   #    U R                  U5      I Sh  vN nU R                  US5      $  N7f)a3  
fetches the current integer timestamp in milliseconds from the exchange server

https://coincatch.github.io/github.io/en/spot/#get-server-time

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int: the current integer timestamp in milliseconds from the exchange server
Ndata)publicGetApiSpotV1PublicTimer  )r  r  responses      r  
fetch_timecoincatch.fetch_time)  s5      ::6BB   622 Cs   0.0c                 r  #    U R                  U5      I Sh  vN nU R                  US/ 5      n0 n/ n[        S[        U5      5       GH:  nX6   nU R	                  US5      nUR                  U5        U R                  U5      n	U R                  US5      n
0 n[        S[        U
5      5       H  nX   nU R	                  US5      nU R                  U5      nUUU R                  US5      SS.U R                  US	5      SS.S
.SU R	                  US5      S:H  U R	                  US5      S:H  U R                  US5      SUS.	X'   M     U R                  UU R                  US5      U	SSSSSSSSSS.SSS.S
.UUS.5      XI'   GM=     U R                  U R                  S5      c  XPR                  S'   U$  GN7f)z
fetches all available currencies on an exchange

https://coincatch.github.io/github.io/en/spot/#get-coin-list

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
Nr  r   coinNamechainschainminDepositAmountminrI  minWithdrawAmountdepositr   rechargeabletruewithdrawablewithdrawFee)	r6   networklimitsactiver  r   fee	precisioninfocoinId)r6   	numericIdcoder  typer7   r  r  r   r  r  r0  r  r.  )"publicGetApiSpotV1PublicCurrencies	safe_listranger  safe_stringappendsafe_currency_codenetwork_id_to_codesafe_numbersafe_currency_structurer  r   )r  r  r  r  resultcurrenciesIdsicurrecy
currencyIdr  r0  parsedNetworksjr  	networkIdnetworkCodes                   r  fetch_currenciescoincatch.fetch_currencies=  s     @@HH~~h3@ q#d)$AgG))':>J  ,**:6D~~gx8H#%N1c(m,"+ ,,Wg>	"55i@#* $(#3#3G=O#P#'$
 $(#3#3G=P#Q#'%	 ##//HFR $ 0 0. IV S++G]C!%#%/+	 -0  77 !..wA!   $# 
  $#!	 +-9 FL? %n >>$,,(GHP<ILL89y Is   F7F4FF7Ncodesc                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US/ 5      nU R                  XAS5      $  NB N+7f)a8  
fetch deposit and withdraw fees

https://coincatch.github.io/github.io/en/spot/#get-coin-list

:param str[] [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>`
Nr  r  )load_marketsr  r  parse_deposit_withdraw_fees)r  r  r  r  r  s        r  fetch_deposit_withdraw_fees%coincatch.fetch_deposit_withdraw_fees  sY      !!!@@HH~~h3//ZHH 	"Hs   AAAA*AAcurrencyc                    U R                  US/ 5      n[        U5      nUS S S.S S S.0 S.n[        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  )r  r   )r  r   r  r0  r   r  r  r  Fr  r0  r   r   r  r   )r  r  r  r  r  r  )r  r  r  r  chainsLengthr  r  r  r  currencyCoder  s              r  parse_deposit_withdraw_fee$coincatch.parse_deposit_withdraw_fee  s    , Xr26{"
 " 
 q,'AIE((8I++Hf=L11)JK#'t<$($4$4UM$JZ_`/F:{+ q ,0,<,<UM,Rz"5)38z"<0 ( r  c                 t  #    U R                  U5      I Sh  vN nU R                  U R                  S5      c  U R                  5       I Sh  vN   U R                  US/ 5      n0 nSnU R	                  USSU5      u  pQ/ nSUS'   U R                  U R                  XA5      5      I Sh  vN nU R                  US/ 5      nSUS'   U R                  U R                  XA5      5      I Sh  vN nU R                  US/ 5      n/ n	[        S[        U5      5       H_  n
X   nU R                  US	/ 5      n[        S[        U5      5       H,  nX   nS	U/0nU	R                  U R                  X5      5        M.     Ma     U R                  Xy5      nU R                  X65      nU R                  U5      $  GN GNd GN N7f)
a:  
retrieves data on all markets for the exchange

https://coincatch.github.io/github.io/en/spot/#get-all-tickers
https://coincatch.github.io/github.io/en/mix/#get-all-symbols

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
Nr.  r  r   productTypeumcbldmcblr   supportMarginCoins)publicGetApiSpotV1MarketTickersr  r   r  handle_option_and_params publicGetApiMixV1MarketContractsextendr  r  r  array_concatparse_markets)r  r  r  spotMarketsrequestr  swapMarkets	swapUMCBL	swapDMCBLswapDMCBLExtendedr  marketr  r  settleobjmarketss                    r  fetch_marketscoincatch.fetch_markets  s     ==fEE8 >>$,,(GHP'')))nnXvr:";;FNTacno!(>>t{{7?[\\H NN8VR8	!(>>t{{7?[\\L NN8VR8	q#i.)A\F!%8Lb!Q1c"456+.(6( "((V)AB 7 * ''	E##K=!!'**{ F: * ]L ]sG   F8F-4F8F0AF8(F3)?F8(F6)CF80F83F86F8r  c                 @   U R                  US5      nU R                  U R                  S5      nU R                  US5      nU R                  US5      nU R                  US5      nS nSnS n	Sn
S nS nS nUS L nU(       a;  U R                  U5      nU R                  US5      nU R                  US5      nUS	-  nOS
n
U R	                  US5      US'   U R	                  US5      US'   U R                  US/ 5      nU R                  US5      nU R                  U5      n	SU	-   nXg:H  nXW:H  nU(       a  SnO	U(       a  SnU R                  U5      nU R                  U5      nUS-   U-   U-   nU R                  US5      nU(       a  US:H  OS nU R                  US5      nU R                  U5      nU R                  US5      nU R                  US5      n[        R                  " U R                  U5      U5      nU R                  0 SU_SU_SU_SU_SU_SU_SU_SU
_SU_SU_S U(       a  S!OS _S
U(       + _S"S!_S#S!_S$U(       + _S%U	_S&U_0 S'U R	                  US(5      _SU_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+U R                  US+5      _S,S _S-S _S.S _S/S _S0U R                  U5      U R                  U5      S1._S2U R	                  US35      S S4.S S S4.S S S4.S S S4.S5._S6S _S7U_E5      $ )8Nsymbolr   rC   baseCoin	quoteCoinr   baseIdquoteId_SPBLrE   takerFeeRater   makerFeeRater   r  r   :rW  rX  /symbolStatusnormalvolumePlace
pricePlacepriceEndStepr6   basequoter  r  subTyperD   FrF   rG   contractr  settleIdcontractSizesizeMultiplierr   r   r   expiryexpiryDatetimestrike
optionTyper  )amountrU  r  minTradeNumr  )r  rU  rD  r   createdr  )r  	safe_dictr   parse_spot_market_idr  r  r  parse_precisionr0   
string_mulsafe_market_structure	safe_boolr  )r  r  marketIdtradingFeesr   r  r  r  suffixr  r  isLinear	isInverser  isSpotparsedMarketIdr  r  r  r  r  r  r  amountPrecisionStringr  r  pricePrecisionStrings                              r  parse_marketcoincatch.parse_marketn  sr   b ##FH5nnTYY	:~~k62!!&*5""6;7	4!66x@N%%nh?F&&~yAGHD ,,V^DDM ,,V^DDM!%8Lb!Q''(:A>H,,X6F6\F*H*I"#&&v.''0e#f,''?/;,(*&&v}= $ 4 4[ A%%fl;
''?&11$2F2Fz2RT`a)) 6+
(6+
f6+
 D6+
 U	6+

 f6+
 w6+
 f6+
 D6+
 w6+
 F6+
 ve46+
 J6+
 e6+
 e6+
 F
6+
  f!6+
" #6+
$ D,,V5EF%6+
& h'6+
( y)6+
* T%%dG4+6+
, T%%dG4-6+
. $..|</6+
0 k:16+
2 t''i836+
4 d56+
6 d76+
8 d96+
: $;6+
< ++,AB**+?@=6+
D ++FMB
  
  
  E6+
h ti6+
j Fk6+
 6 6	r  c                    S nS nU R                  U R                  S/ 5      n[        S[        U5      5       HA  nXE   nUR	                  U5      nUS:  d  M   UR                  US5      nUS:X  a  UnUnOUnUn  O   UUS.n	U	$ )Nr.  r   r   )r  r  )r  r   r  r  findreplace)
r  r$  r  r  currencyIdsr  r  
entryIndexrestIdr  s
             r  r  coincatch.parse_spot_market_id  s    nnT\\3RTVWq#k*+A$J!z2JB!))*b9?'F$G#F(G , 
 r  r  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnUS   (       a)  U R                  U R                  XB5      5      I Sh  vN nOWUS   (       a)  U R	                  U R                  XB5      5      I Sh  vN nO$[        U R                  S-   S-   US   -   S	-   5      eU R                  US
0 5      nU R                  Xc5      $  N N NQ7f)a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://coincatch.github.io/github.io/en/spot/#get-single-ticker
https://coincatch.github.io/github.io/en/mix/#get-single-symbol-ticker

:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr  r6   rC   rE    z#fetchTicker() is not supported for r   type of marketsr  )	r  r  publicGetApiSpotV1MarketTickerr  publicGetApiMixV1MarketTickerr*   r6   r  parse_tickerr  r  r  r  r  r  r  s          r  fetch_tickercoincatch.fetch_ticker  s      !!!V$fTl
 &>!@@WA]^^H2 F^!??G@\]]H@ tww}/TTW]^dWeehzz{{~~h3  ..G 	" _4 ^s5   C)C#AC)"C%#2C)C'AC)%C)'C)symbolsc                 (  #    SnU R                  5       I Sh  vN   U R                  USSS5      nU R                  U5      nSnU R                  X4X%5      u  pRSnUS:X  a  U R	                  U5      I Sh  vN nOnUS:X  aD  SnU R                  X#SU5      u  prSU0nU R                  U R                  X5      5      I Sh  vN nO$[        U R                  S-   U-   S	-   U-   S
-   5      eU R                  US/ 5      n	U R                  X5      $  N N NQ7f)a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://coincatch.github.io/github.io/en/spot/#get-all-tickers
https://coincatch.github.io/github.io/en/mix/#get-all-symbol-ticker

:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: 'spot' or 'swap'(default 'spot')
:param str [params.productType]: 'umcbl' or 'dmcbl'(default 'umcbl') - USDT perpetual contract or Universal margin perpetual contract
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
r   NTrC   rE   r  r  r8  () is not supported for r9  r  )r  market_symbolsget_market_from_symbolshandle_market_type_and_paramsr  r  publicGetApiMixV1MarketTickersr  r*   r6   r  parse_tickers)
r  r@  r  
methodNamer  rQ  r  r  r  r  s
             r  fetch_tickerscoincatch.fetch_tickersg  s4     $
!!!%%gtT4@--g6
!??
TZg
!AA&IIH8 6!!K"&"?"?Tacn"oK{G "@@WA]^^HF tww}z9<VVYccfxxyy~~h3!!$00] 	" JD _s6   DDAD4D5A	D>D?ADDDc                    U R                  USS5      nU R                  USS5      nUR                  S5      S:  a  US-  nU R                  XB5      nU R	                  US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S5      _SU R                  US5      _SU R	                  USS5      _SU R                  US5      _SS _SU R	                  USS5      _SU_S	U_SS _SS _S[        R                  " U R	                  US S!5      S"5      _S#S _U R	                  US$S%5      U R	                  US&S'5      U R                  US(5      S US).EU5      $ )*Nts	timestampr  r   _r   r  closer3  datetimehighhigh24hlowlow24hbidbuyOnebestBid	bidVolumebidSzasksellOnebestAsk	askVolumeaskSzvwapopenopenUtc0openUtcpreviousClosechanger   	changeUtcchgUtc100averagebaseVol
baseVolumequoteVolquoteVolume
indexPrice)rj  rl  rm  	markPricer  )	safe_integer_2r  r1  safe_market_customsafe_string_2safe_tickeriso8601r0   r!  )r  tickerr  rM  r$  r3  s         r  r<  coincatch.parse_ticker  s   \ ''kB	##FHb9==!H((:!!&'6: !
fX&!
!
 Y/!
 D$$VY7	!

 4##FH5!
 4%%fh	B!
 ))&':!
 4%%fiC!
 ))&':!
 D!
 D&&vz9E!
 T!
 D!
 T!
 d!
  ',,T-?-?U]-^`ef!!
" t#!
$ ,,VYM--fj-P**6<@-!
. / 	r  rK  c                 T  #    U R                  5       I Sh  vN   SnU R                  U5      nSUS   0nUb  X&S'   SnU R                  X4S5      u  psUb  XvS'   SnUS   (       a)  U R                  U R	                  Xc5      5      I Sh  vN nOZUS   (       a)  U R                  U R	                  Xc5      5      I Sh  vN nO'[        U R                  S	-   U-   S
-   US   -   S-   5      eU R                  US0 5      n	U R                  U	S5      n
U R                  XU
SS5      $  GN N Nj7f)a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://coincatch.github.io/github.io/en/spot/#get-merged-depth-data
https://coincatch.github.io/github.io/en/mix/#get-merged-depth-data

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return(maximum and default value is 100)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.precision]: 'scale0'(default), 'scale1', 'scale2' or 'scale3' - price accuracy, according to the selected accuracy step size to return the cumulative depth
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nr   r  r6   rK  r  rC   rE   r8  rB  r  r9  r  rL  bidsasks)r  r  r  "publicGetApiSpotV1MarketMergeDepthr  !publicGetApiMixV1MarketMergeDepthr*   r6   r  r  parse_order_book)r  r  rK  r  rH  r  r  r  r  r  rM  s              r  fetch_order_bookcoincatch.fetch_order_book  s@     !!!%
V$fTl
 $G	 99&kZ	 #,K &>!DDT[[QXEabbH  F^!CCDKKPWD`aaHtww}z9<VVY_`fYggj||}}~~h3%%dD1	$$T9ffMMI 	" c" bs5   D(D!A1D(D$	2D(;D&<A&D($D(&D(r   	timeframesincec                   #    SnU R                  5       I Sh  vN   U R                  U5      nSUS   0nSn	U R                  XVS5      u  pUS   n
U R                  S   U
   nU R	                  XU5      nSnUnUc  U	b  UnUb  XS	'   SnUS
   (       a`  XS'   Ub  X8S'   U	b  XS'   U R                  U R                  X5      5      I Sh  vN nU R                  US/ 5      nU R                  UXrX45      $ US   (       a  XS'   U	c  U R                  5       n	Uc  U R                  U5      nU	UU-  S-  -
  nX8S'   XS'   SnU R                  XVS5      u  nnUS:X  a  SUS'   U R                  U R                  X5      5      I Sh  vN nU R                  XX#U5      $ [        U R                  S-   U-   S-   US   -   S-   5      e GN N NC7f)a  

https://coincatch.github.io/github.io/en/spot/#get-candle-data
https://coincatch.github.io/github.io/en/mix/#get-candle-data

fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param int [since]: timestamp in ms of the earliest candle to fetch
:param int [limit]: the maximum amount of candles to fetch(default 100)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest candle to fetch
:param str [params.price]: "mark" for mark price candles
:returns int[][]: A list of candles ordered, open, high, low, close, volume
r   Nr  r6   untilr  r   rR  rK  rC   periodafterbeforer  rE   granularity	startTimeendTimerU  r4  zmarket mark index	kLineTyper8  rB  r9  )r  r  r  r   r  publicGetApiSpotV1MarketCandlesr  r  parse_ohlcvsmillisecondsparse_timeframepublicGetApiMixV1MarketCandlesr*   r6   )r  r  r~  r  rK  r  rH  r  r  r  rQ  r   encodedTimeframemaxLimitrequestedLimitr  r  duration	priceTypes                      r  fetch_ohlcvcoincatch.fetch_ohlcvE  s#      "
!!!V$fTl
 55f'RF^
\\,/
;
++J9M5#4%N%-G&> 0H #(  $)!!AA$++gB^__H* >>(FB7D$$T6eKKF^%5M"}))+}//	:H!4t!;<#(K !&I!I $ = =fRY ZIvF"':$!@@WA]^^H $$XyOOtww}z9<VVY_`fYggj||}}Y 	". `H _s5   GF?B/GG	B7G G?GGGc           
          U R                  USS5      U R                  USS5      U R                  USS5      U R                  USS5      U R                  US	S
5      U R                  USS5      /$ )NrL  r   r`  r   rQ  r   rS     rO  r   ri     )ro  safe_number_2)r  ohlcvr  s      r  parse_ohlcvcoincatch.parse_ohlcv  sx    tQ/ufa0ufa0ueQ/ugq1ui3
 	
r  c                 R  #    SnU R                  5       I Sh  vN   U R                  U5      nSUS   0nSnU R                  XES5      u  pSn	Un
Uc  Ub  U	n
Ub  X'S'   Ub  XS'   U
b  XS	'   SnUS
   (       a)  U R                  U R	                  Xt5      5      I Sh  vN nOZUS   (       a)  U R                  U R	                  Xt5      5      I Sh  vN nO'[        U R                  S-   U-   S-   US   -   S-   5      eU R                  US/ 5      nU R                  XX#5      $  GN N NV7f)ah  
get the list of most recent trades for a particular symbol

https://coincatch.github.io/github.io/en/spot/#get-recent-trades
https://coincatch.github.io/github.io/en/mix/#get-fills

:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch
:param int [limit]: the maximum amount of trades to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest entry to fetch
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
r   Nr  r6   r  rR  r  r  rK  rC   rE   r8  rB  r  r9  r  )
r  r  r  $publicGetApiSpotV1MarketFillsHistoryr  #publicGetApiMixV1MarketFillsHistoryr*   r6   r  parse_trades)r  r  r  rK  r  rH  r  r  r  r  requestLimitr  r  s                r  fetch_tradescoincatch.fetch_trades  sS     #
!!!V$fTl
 55f'R5#4#L ',$ %*	"#+G&>!FFt{{SZGcddH$ F^!EEdkkRYFbccH( tww}z9<VVY_`fYggj||}}~~h3  u<<y 	"& e& ds5   D'D BD'D#2D'D%AD'#D'%D'tradec                    U R                  US5      nU R                  X25      nU R                  U/ SQ5      nU R                  USS5      nS nUb  [        R
                  " U5      nU R                  US5      nUc  US   b  US   nU R                  USS5      nU R                  U R                  US	S
5      U R                  US5      UU R                  U5      US   U R                  US5      U R                  U5      U R                  US5      U R                  USS5      U R                  U/ SQ5      U R                  USS5      UUS.US.U5      $ )Nr  )fillTimerM  cTimer   r  feeCcyr  	tradeSidesidetradeIdfillIdorderId	orderTypetakerMakerFlag	fillPricerU  )fillQuantitysizesizeQtyfillTotalAmount
fillAmountr   r  )r6   orderrM  rP  r  r  r  takerOrMakerrU  r  r   r  r  )r  rp  safe_integer_nrq  r0   
string_abssafe_string_lower_2
safe_traders  parse_order_sidesafe_string_n)	r  r  r  r$  rM  r   feeCostfeeCurrencyr  s	            r  parse_tradecoincatch.parse_trade  sr   r ##E84((:''/QR	!!%7((.G&&uh7fX&6&B *K''{FC$$UIx@%%eY7"Y/X&$$UK8))$/ ,,U4DE''{GD((0ST&&u.?N' ! 
" # 	r  c                 R  #    U R                  5       I Sh  vN   U R                  U5      nUS   nUR                  S5      nUU R                  US5      S.nU R	                  U R                  Xb5      5      I Sh  vN nU R                  US0 5      nU R                  X5      $  N N*7f)a>  
fetch the current funding rate

https://coincatch.github.io/github.io/en/mix/#get-current-funding-rate

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
Nr6   rN  r   )r  r  r  )r  r  splitr  &publicGetApiMixV1MarketCurrentFundRater  r  parse_funding_rate)	r  r  r  r  r$  partsr  r  r  s	            r  fetch_funding_ratecoincatch.fetch_funding_rateR  s      !!!V$$<s#++E15
 DDT[[QXEabb ~~h3&&t44+ 	" cs"   B'B#A#B':B%;)B'%B'c                     U R                  US5      nU R                  X25      nU R                  US5      n0 SU_SUS   _SS _SS _SS _SS _SS _S	S _SU_S
S _SS _SS _SS _SS _SS _SS _SS _$ )Nr  fundingRater  rn  rm  interestRateestimatedSettlePricerM  rP  fundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetime)r  rp  r  )r  r  r  r$  r  s        r  r  coincatch.parse_funding_rates  s   ##Hh7((:&&x?
H
fX&
 
 $	

 D
 #D
 
 
 ;
 
 t
 t
 #D
 "4
 "4
  '!
" &t#
 	
r  r  rH  
optionNamer  requestPropertyc                 >    U R                  XX65      u  pxUb  XtU'   XH/$ N)r  )	r  r  rH  r  r  r  defaultValuerG   paramsOmiteds	            r   handle_option_params_and_request*coincatch.handle_option_params_and_request  s/    #<<VQ[j'-O$&&r  c           
        #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   SnU R                  U5      nSUS   0nUnUb  UnUb  XS'   U R	                  U R                  Xt5      5      I Sh  vN n	U R                  U	S/ 5      n
/ n[        S[        U
5      5       Hq  nX   nU R                  US	5      nUR                  UU R                  U R                  US5      USS
5      U R                  US5      UU R                  U5      S.5        Ms     U R                  US5      nU R!                  XU5      $  GN N7f)a  
fetches historical funding rate prices

https://coincatch.github.io/github.io/en/mix/#get-history-funding-rate

: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 entries to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.pageNo]: the page number to fetch
:param bool [params.nextPage]: whether to query the next page(default False)
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
Nz5 fetchFundingRateHistory() requires a symbol argumentrP  r  r6   pageSizer  r   
settleTimerE   r  )r  r  r  rM  rP  rM  )r$   r6   r  r  &publicGetApiMixV1MarketHistoryFundRater  r  r  r  r  r  safe_symbolr  r  rs  sort_byfilter_by_since_limit)r  r  r  rK  r  maxEntriesPerRequestr  r  r  r  r  ratesr  entryrM  sorteds                   r  fetch_funding_rate_history$coincatch.fetch_funding_rate_history  sb     >#DGG.e$eff!!!"V$fTl
 1N%"0JDDT[[QXEabb ~~h3q#d)$AGE))%>ILL**4+;+;E8+LfVZ\bc#//}E& LL3  % e[1))&??O 	" cs#   /EE	AEECEEc                   #    U R                  5       I Sh  vN   SnSnU R                  USU5      u  p1SnUS:X  a  U R                  U5      I Sh  vN nOnUS:X  aD  SnU R                  XSU5      u  pQSU0nU R	                  U R                  Xa5      5      I Sh  vN nO$[        U R                  S-   U-   S-   U-   S	-   5      eU R                  US
/ 5      nU R                  U5      $  N N NQ7f)a  
query for balance and get the amount of funds available for trading or funds locked in orders

https://coincatch.github.io/github.io/en/spot/#get-account-assets

:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: 'spot' or 'swap' - the type of the market to fetch balance for(default 'spot')
:param str [params.productType]: *swap only* 'umcbl' or 'dmcbl'(default 'umcbl')
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
Nrg   rC   rE   r  r  r8  rB  r9  r  )
r  rE   privateGetApiSpotV1AccountAssetsr  !privateGetApiMixV1AccountAccountsr  r*   r6   r  parse_balance)r  r  rH  rQ  r  r  r  r  s           r  fetch_balancecoincatch.fetch_balance  s     !!!#

!??
DRXY
$ "BB6JJH6!!K"&"?"?Tacn"oK{G8 "CCDKKPWD`aaHtww}z9<VVYccfxxyy~~h3!!$''w 	". K@ bs5   C.C(9C.C*A	C.C,AC.*C.,C.c                    SU0n[        S[        U5      5       H  nU R                  X0 5      nU R                  USS5      nU R	                  U5      nU R                  5       nU R                  US5      US'   U R                  USS5      nU R                  US	S
5      n	[        R                  " X5      US'   U R                  US5      US'   XrU'   M     U R                  U5      $ )Nr  r   r  
marginCoin	availablefreelocklockedfrozen0usedequitytotal)
r  r  r  rq  r  accountr  r0   
string_addsafe_balance)
r  balancesr  r  balanceEntryr  r  r  r  r  s
             r  r  coincatch.parse_balance  s    F H
 q#h-(A>>(r:L++L*lSJ**:6DllnG"..|[IGFO''fhGF%%lHcBF%00@GFO#//hGGG"4L )   ((r  r  r  fromAccount	toAccountc                   #    U R                  5       I Sh  vN   U R                  U5      nUS:X  a  US:X  a  SnOSnUS:X  a  US:X  a  SnOSnUS   U R                  X5      UUS.nSnU R                  USS	5      u  pUb  XS
'   U R	                  U R                  Xu5      5      I Sh  vN n	U R                  X5      $  N N7f)ai  
transfer currency internally between wallets on the same account

https://coincatch.github.io/github.io/en/spot/#transfer

:param str code: unified currency code
:param float amount: amount to transfer
:param str fromAccount: 'spot' or 'swap' or 'mix_usdt' or 'mix_usd' - account to transfer from
:param str toAccount: 'spot' or 'swap' or 'mix_usdt' or 'mix_usd' - account to transfer to
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.clientOrderId]: a unique id for the transfer
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
NrE   USDTmix_usdtmix_usdr6   )coinr  fromTypetoTyper   clientOrderId	clientOid)r  r  currency_to_precisionr  $privatePostApiSpotV1WalletTransferV2r  parse_transfer)
r  r  r  r  r  r  r  r  r  r  s
             r  r   coincatch.transferD  s      !!!==&& v~('v~&	%	TN00>#	
 " $ = =fjRa b$#0K BB4;;wC_`` ""866E 	", as"   CB>BC(C )C Cc           
          U R                  US5      nS nUS:X  a  SnU R                  US0 5      nU R                  US5      S S U R                  S U5      S S S UUS.	$ )Nmsgsuccessokr  
transferId)	r6   rM  rP  r  r  r  r  statusr  )r  r  r  )r  r   r  r  r  r  s         r  r  coincatch.parse_transferv  sw    x/)F~~h3""46//h?

 
	
r  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnU R                  U5      u  pRUc  U R                  U5      nUc  [	        U R
                  S-   5      eU R                  XQ5      US'   U R                  U R                  XB5      5      I Sh  vN nU R                  US0 5      nU R                  Xs5      nU$  N N,7f)a  
fetch the deposit address for a currency associated with self account

https://coincatch.github.io/github.io/en/spot/#get-coin-address

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.network]: network for fetch deposit address
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
Nr  r6   zM fetchDepositAddress() requires a network parameter or a default network coder  r  )r  r  handle_network_code_and_paramsdefault_network_coder$   r6   network_code_to_id'privateGetApiSpotV1WalletDepositAddressr  r  parse_deposit_address)	r  r  r  r  r  r  r  r  depositAddresss	            r  fetch_deposit_addresscoincatch.fetch_deposit_address  s      !!!==&HTN
  "AA&I33D9K#DGG.}$}~~22;EEEdkkRYFbcc ~~h333DC; 	" ds"   CCBC.C/+CCc                     U R                  US5      nU R                  U5        U R                  US5      nU R                  U R                  S   XD5      nU R                  US5      nUS   UUUUS.$ )Naddressr  r1  tagr  )r  r"  r#  r  r  )r  check_addressr   )r  r  r  r"  r  r  r#  s          r  r  coincatch.parse_deposit_address  s     "">9=7#$$^W=	""4<<#?V~u5 ("
 	
r  c                 h  #    SnU R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   Ub  X&S'   SnU R                  XES5      u  pUb  XS'   U R                  U R	                  Xd5      5      I Sh  vN n	U R                  U	S/ 5      n
U R                  XX#5      $  N N+7f)	a  
fetch all deposits made to an account

https://coincatch.github.io/github.io/en/spot/#get-deposit-list

:param str code: unified currency code of the currency transferred
:param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
:param int [limit]: the maximum number of transfer structures to retrieve(not used by exchange)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch transfers for(default time now)
:param int [params.pageNo]: pageNo default 1
:param int [params.pageSize]: pageSize(default 20, max 100)
:returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
rr   Nr6   r  r  r  r  r  )r  r  r  $privateGetApiSpotV1WalletDepositListr  r  parse_transactionsr  r  r  rK  r  rH  r  r  r  r  r  s              r  fetch_depositscoincatch.fetch_deposits  s      %
!!!!}}T*H&tnGFO#(K 55f'R!&IBB4;;wC_``8 ~~h3&&tuDDS 	" as"   B2B.A+B2B0*B20B2c                 v  #    SnU R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   Ub  X&S'   Ub  X6S'   SnU R                  XES5      u  pUb  XS'   U R                  U R	                  Xd5      5      I Sh  vN n	U R                  U	S	/ 5      n
U R                  XX#5      $  N N+7f)
az  
fetch all withdrawals made from an account

https://coincatch.github.io/github.io/en/spot/#get-withdraw-list-v2

:param str code: unified currency code of the currency transferred
:param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
:param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch transfers for(default time now)
:param str [params.clientOid]: clientOid
:param str [params.orderId]: The response orderId
:param str [params.idLessThan]: Requests the content on the page before self ID(older data), the value input should be the orderId of the corresponding interface.
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
r   Nr6   r  r  rK  r  r  r  )r  r  r  )privateGetApiSpotV1WalletWithdrawalListV2r  r  r(  r)  s              r  fetch_withdrawalscoincatch.fetch_withdrawals  s       (
!!!!}}T*H&tnGFO#(K $G55f'R!&IGGT[Hdee ~~h3&&tuDD% 	" fs"   B9B5A2B9B7*B97B9r"  r#  c                   #    U R                  XE5      u  pEU R                  5       I Sh  vN   U R                  U5      nUS   UUS.nUb  XGS'   SnU R                  U5      u  pUb  U R	                  U5      US'   U R                  U R                  Xu5      5      I Sh  vN n	U R                  U	S0 5      n
U R                  X5      $  N N*7f)a  
make a withdrawal

https://coincatch.github.io/github.io/en/spot/#withdraw

: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
:param str params['network']: network for withdraw(mandatory)
:param str [params.remark]: remark
:param str [params.clientOid]: custom id
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr6   )r  r"  r  r#  r  r  )	handle_withdraw_tag_and_paramsr  r  r  r  &privatePostApiSpotV1WalletWithdrawalV2r  r  parse_transaction)r  r  r  r"  r#  r  r  r  r  r  r  s              r  r   coincatch.withdraw)  s       99#F!!!==&TN

 ? EN"AA&I"#66{CGGDDT[[QXEabb ~~h3%%d553 	" cs"   'CCA4CC	)C	Cc                    U R                  US5      nUS:X  a  SnU R                  US5      nU R                  US5      nU R                  XR5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  U R                  S	   X5      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S nUb  UUS.n0 SU_SU R                  USS5      _SU_SU_SU R                  U5      _SU
_SS _SU_SU_SU_SS _SS _SU_SU_SU_SU_SS _S S US.E$ )Nr  r  r  txIdr  r  r  r  r1  	toAddressfromAddressr#  r  r  r  r  r6   r  txidrM  rP  r  r"  	addressToaddressFromtagTotagFromr  updated)internalcommentr  )r  r  r  r  r   rq  rs  )r  transactionr  r  r9  r  r  rM  r  r  r  r:  r;  r#  r  r  r  s                    r  r3  coincatch.parse_transactionU  s   D !!+x8YFV4V4&&t6%%k7;	!!+x8$$[':	""4<<#?V$$[+>	&&{MB{E2V4"";6 C
K
$$$[$	B
 D
 	

 Y/
 w
 t
 
 ;
 3
 T
 t
 D
 f
 
  f!
" t#
$ )
 	
r  r   c                   #    U R                  5       I Sh  vN   SnU R                  U5      nUS   (       d  [        U R                  S-   U-   S-   5      eXCS'   SUS'   U R	                  US	S
USU5      I Sh  vN $  Nf N7f)a  
create a market buy order by providing the symbol and cost

https://coincatch.github.io/github.io/en/spot/#place-order

:param str symbol: unified symbol of the market to create an order in
:param float cost: how much you want to trade in units of the quote currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NrT   rC   r8  z() supports spot orders onlyrH  Fr-  r  buy)r  r  r*   r6   create_order)r  r  r   r  rH  r  s         r  !create_market_buy_order_with_cost+coincatch.create_market_buy_order_with_cost  s      !!!3
V$f~tww}z9<ZZ[[)|6;23&&vxdFSSS 	" Ts"   BA=A!B8A?9B?Br  r  rU  c                 j  #    U R                  5       I Sh  vN   U R                  USS5      US'   U R                  U5      nUS   (       a  U R                  XX4XV5      I Sh  vN $ US   (       a  U R	                  XX4XV5      I Sh  vN $ [        U R                  S-   US   -   S-   5      e N NL N)7f)	a~  
create a trade order

https://coincatch.github.io/github.io/en/spot/#place-order
https://coincatch.github.io/github.io/en/spot/#place-plan-order
https://coincatch.github.io/github.io/en/mix/#place-order
https://coincatch.github.io/github.io/en/mix/#place-plan-order

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit' or 'LIMIT_MAKER' for spot, 'market' or 'limit' or 'STOP' for swap
:param str side: 'buy' or 'sell'
:param float amount: how much of you want to trade in units of the base currency
:param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param bool [params.hedged]: *swap markets only* must be set to True if position mode is hedged(default False)
:param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
:param float [params.triggerPrice]: the price that the order is to be triggered
:param bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately
:param str [params.timeInForce]: 'GTC', 'IOC', 'FOK' or 'PO'
:param str [params.clientOrderId]: a unique id for the order - is mandatory for swap
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NrH  rY   rC   rE   z$ createOrder() is not supported for r  r9  )r  r  r  create_spot_ordercreate_swap_orderr*   r6   )r  r  r  r  r  rU  r  r  s           r  rE  coincatch.create_order  s     . !!!#//mT|V$&>//dEZZZF^//dEZZZtww)OORXY_R``cuuvv 	" [Zs4   B3B-AB3"B/#$B3B1&B3/B31B3c                   #    U R                  5       I Sh  vN   U R                  USS5      US'   U R                  XX4XV5      nU R                  US5      SLnSn	U(       a  U R                  U5      I Sh  vN n	OU R	                  U5      I Sh  vN n	U R                  U	S0 5      n
U R                  U5      nU R                  X5      $  N NU N=7f)aX  
create a trade order on spot market

https://coincatch.github.io/github.io/en/spot/#place-order
https://coincatch.github.io/github.io/en/spot/#place-plan-order

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of you want to trade in units of the base currency
:param float [price]: the price that 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 float [params.cost]: *market buy only* the quote quantity that can be used alternative for the amount
:param float [params.triggerPrice]: the price that the order is to be triggered at
:param bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately
:param str [params.timeInForce]: 'GTC', 'IOC', 'FOK' or 'PO'
:param str [params.clientOrderId]: a unique id for the order(max length 40)
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NrH  createSpotOrderr;  r  )r  r  create_spot_order_request!privatePostApiSpotV1PlanPlacePlanprivatePostApiSpotV1TradeOrdersr  r  parse_order)r  r  r  r  r  rU  r  r  
isPlanOrerr  r  r  s               r  rI  coincatch.create_spot_order  s     ( !!!#//FWX|66vTSXa%%g~>dJ
!CCGLLH "AA'JJH~~h3V$--- 	" M Ks4   CC	AC5C6CC:CCCc                    SnU R                  USU5      u  pvU R                  U5      nUS   UUS.n	US:H  n
U R                  XvU
5      nUS   nUS   nSnU R                  US	5      u  pSnU R                  US
5      u  pU
=(       a    US:H  nU(       d!  Ub  [        U R                  S-   U-   S-   5      eU(       a  U R                  XvXTU5      nUS	   nUS   nUc6  US:X  a  XYS'   U(       a  UOU R                  U5      U	S'   U(       a  UOSU	S'   OdXS
'   Ub  XS'   SnU R                  US5      u  nnUb  UU	S'   US:X  a  XYS'   SnU
(       a  SnOSnUU	S'   U
(       a  UOU R                  U5      U	S'   U R                  X5      $ )a1  
@ignore
       helper function to build request
       :param str symbol: unified symbol of the market to create an order in
       :param str type: 'market' or 'limit'
       :param str side: 'buy' or 'sell'
       :param float amount: how much of you want to trade in units of the base currency
       :param float [price]: the price that 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 float [params.triggerPrice]: the price that the order is to be triggered at
       :param float [params.cost]: *market buy only* the quote quantity that can be used alternative for the amount
       :param bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately
       :param str [params.timeInForce]: 'GTC', 'IOC', 'FOK' or 'PO'(default 'GTC')
       :param str [params.clientOrderId]: a unique id for the order(max length 40)
       :returns dict: request to be sent to the exchange
       createSpotOrderRequestrH  r6   )r  r  r  r  r  rA  Nr   r;  rD  r8  z3 supports cost parameter for market buy orders onlyrK  rU  quantityr  forcetimeInForceValuer  r  executePricemarket_price
fill_pricetriggerTyper  )handle_param_stringr  "handle_time_in_force_and_post_onlyr*   r6   handle_requires_price_and_costnumber_to_stringr  )r  r  r  r  r  rU  r  rH  r  r  isMarketOrdertimeInForceAndParamsrA  r   r;  isMarketBuycostAndParamsr  r\  s                      r  rN  #coincatch.create_spot_order_request	  s   " .
!55flJW
V$Tl

 )#FFz[hi%h/*=9//? #77O#7$"2tww}z9<qqrr ??
TYcghM (D"8,Fw#( *5$4;P;PQW;XGJ.9{xGG&2N#&.9*+!%M$($<$<V_$U!M6('4$w*/'#K,*%0GM"&3d9N9Nv9VGFO{{7++r  rD  c                 |   SU R                  U5      -   S-   nSnU R                  X!US5      u  pS n	Ub  U R                  U5      n	S n
Ub  U R                  U5      n
U(       aJ  Uc-  Uc*  [        U R                  S-   U-   S-   U-   S-   U-   S-   5      eUc  [
        R                  " X5      nOU(       a  UOU	nUUS.nU$ )	NcreateMarketOrderRequiresPriceTr8  z*() requires the price argument for market zT orders to calculate the total cost to spend(amount * price), alternatively set the zK option or param to False and pass the cost to spend in the amount argument)r   r  )
capitalizer  r`  r(   r6   r0   r!  )r  rH  r  rU  r  r   r  r  requiresPriceamountStringpriceStringr  s               r  r_  (coincatch.handle_requires_price_and_costF	  s    #dood&;;>RR
 $ = =fR\^b c 008L//6KDL"477S=:#=@l#los#s  wM  $M  PZ  $Z  ]j  $j  k  k)),D4\D
 r  Fra  c                     S nU R                  X!S5      u  pBSnU R                  X4S:H  U5      u  pRU(       a  SnU R                  U5      nUUS.nU$ )NrA  F	post_onlyr8  )rA  r  )r  handle_post_onlyencode_time_in_force)r  rH  r  ra  rA  postOnlyr  s          r  r^  ,coincatch.handle_time_in_force_and_post_only]	  si    ";;FP]^00{@Z\bcK//<&
 r  c                   #    U R                  USS5      US'   U R                  5       I Sh  vN   U R                  U5      nU R                  XX4XV5      nU R                  US5      n	U R	                  US5      nSn
U	S:X  a  U R                  U5      I Sh  vN n
O9U	S:X  a  U R                  U5      I Sh  vN n
OU R                  U5      I Sh  vN n
U R                  U
S0 5      nU R                  X5      $  N Nd NF N.7f)a  
create a trade order on swap market

https://coincatch.github.io/github.io/en/mix/#place-order
https://coincatch.github.io/github.io/en/mix/#place-plan-order
https://coincatch.github.io/github.io/en/mix/#place-stop-order

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of you want to trade in units of the base currency
:param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param bool [params.hedged]: must be set to True if position mode is hedged(default False)
:param bool [params.postOnly]: *non-trigger orders only* if True, the order will only be posted to the order book and not executed immediately
:param bool [params.reduceOnly]: True or False whether the order is reduce only
:param str [params.timeInForce]: *non-trigger orders only* 'GTC', 'FOK', 'IOC' or 'PO'
:param str [params.clientOrderId]: a unique id for the order
:param float [params.triggerPrice]: the price that the order is to be triggered at
:param float [params.stopLossPrice]: The price at which a stop loss order is triggered at
:param float [params.takeProfitPrice]: The price at which a take profit order is triggered at
:param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered(perpetual swap markets only)
:param float [params.takeProfit.triggerPrice]: take profit trigger price
:param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered(perpetual swap markets only)
:param float [params.stopLoss.triggerPrice]: stop loss trigger price
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
rH  createSwapOrderNendpointTyperO  tpslr  )
r  r  r  create_swap_order_requestomit privatePostApiMixV1PlanPlacePlan privatePostApiMixV1PlanPlaceTPSL"privatePostApiMixV1OrderPlaceOrderr  rQ  )r  r  r  r  r  rU  r  r  r  rv  r  r  s               r  rJ  coincatch.create_swap_orderk	  s     8  $//FWX|!!!V$00tU[''@))G^49$!BB7KKHV#!BB7KKH!DDWMMH ~~h3--3 	" LKMsF   *D C8A(D C:D 5C<6D C>)D :D <D >D c                 Z   SnU R                  USU5      u  pvU R                  U5      nUS   US   U R                  X5      S.n	U R                  XgSU	S5      u  pUS:H  n
U R	                  XX%Xv5      nU R                  US	5      nUb  US
:X  a:  U R                  XvU
5      nUS   nUS   nUb  XS'   Ub  U R                  X5      U	S'   US:w  a  X)S'   SnSnUS:X  d  US:X  d  US:X  d  US:X  d  US:X  d  US:X  a  SnUS:w  a  US:w  a  SnU(       do  U R                  XgSU5      u  pU R                  US5      nU(       a.  Ub  U(       a  US:X  a  SnO.US:X  a  SnO%US:X  a  SnOUS:X  a  SnOUR                  5       S-   nU(       a  U R                  US5      nX9S'   U R                  X5      $ )aZ  
@ignore
       helper function to build request
       :param str symbol: unified symbol of the market to create an order in
       :param str type: 'market' or 'limit'
       :param str side: 'buy' or 'sell'
       :param float amount: how much of you want to trade in units of the base currency
       :param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param bool [params.hedged]: must be set to True if position mode is hedged(default False)
       :param bool [params.postOnly]: *non-trigger orders only* if True, the order will only be posted to the order book and not executed immediately
       :param bool [params.reduceOnly]: True or False whether the order is reduce only
       :param str [params.timeInForce]: *non-trigger orders only* 'GTC', 'FOK', 'IOC' or 'PO'
       :param str [params.clientOrderId]: a unique id for the order
       :param float [params.triggerPrice]: the price that the order is to be triggered at
       :param float [params.stopLossPrice]: The price at which a stop loss order is triggered at
       :param float [params.takeProfitPrice]: The price at which a take profit order is triggered at
       :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered(perpetual swap markets only)
       :param float [params.takeProfit.triggerPrice]: take profit trigger price
       :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered(perpetual swap markets only)
       :param float [params.stopLoss.triggerPrice]: stop loss trigger price
       :returns dict: request to be sent to the exchange
       createSwapOrderRequestrH  r6   r  )r  r  r  r  r  r  rv  standardr  rA  rX  rU  rw  r  F
buy_singlesell_single	open_long
open_short
close_longclose_shortTrB  
reduceOnlyrD  sell_singler  )r]  r  amount_to_precisionr  (handle_trigger_stop_loss_and_take_profitr  r^  price_to_precisionr  r#  lowerry  r  )r  r  r  r  r  rU  r  rH  r  r  ra  rv  rb  rA  sideIsExchangeSpecificrB  r  s                    r  rx  #coincatch.create_swap_order_request	  s   0 .
!55flJW
V$Tl ,,,V<

 ??Tcelnyz)>>vTZdm''? lj&@#'#J#J:_l#m )(3F.}=K&.9*+ #'#:#:6#I F"#'K %*"F$$-*?T[EX^bfr^rx|  AM  yM  SW  [h  Sh)-&L(t}/D!F)!%!>!>vS[]c!d!^^FLA
".J5=#0D!V^#/D5=#.D!V^#/D::<)3D6<8"FO{{7++r  rY   c                    0 nSnU R                  US5      n	U R                  US5      n
S nU R                  US5      nU R                  US5      nU R                  USS5      nUS L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(       d  U R                  US5      n
U
S LnUS LnU(       a  U(       d  U R                  US5      n	U	S LnU=(       a    UnUS LnUS
:H  nU(       d  U(       d  US:X  ab  U(       a<  U(       a  SUS'   OSUS'   U R                  X5      US'   U R                  X5      US'   SnUS:X  a  S nU(       a  XS'   U(       a  XS'   OU(       d  U(       d  U(       a  U(       d$  [	        U R
                  S-   U-   S-   U-   S-   5      eSnSnUS:X  a  SnUUS'   U(       a.  Uc  [        U R
                  S-   U-   S-   5      eUnUUS'   SUS'   OU(       a  U
nS US'   OU	nS!US'   U R                  X5      US'   Ub  XS"'   U R                  U/ S#Q5      nU R                  Xv5      $ )$Nr  r>  r?  
takeProfitstopLossr;  	stopPricetrailingPercenttrailingTriggerPricer  r[   rZ  r\  r[  rY  rO  rZ   presetTakeProfitPricepresetStopLossPricer8  z() supports does not support z type of stop loss and take profit orders(only market type is supported for stop loss and take profit orders). To create a market order with stop loss or take profit attached use createOrderWithTakeProfitAndStopLoss()rw  longrD  shortholdSidezG() requires the trailingTriggerPrice parameter for trailing stop orders	rangeRatemoving_planplanTypeprofit_plan	loss_planrv  )r  r  r>  r?  r;  r  r  r  )	r  r  rq  r  r*   r6   r$   ry  r  )r  r  r  r  rU  rH  r  r  rv  r>  r?  requestTriggerPricetakeProfitParamsstopLossParamsr;  	isTriggerr  r  
hasTPPrice
hasSLPricehasTPParamshasSLParamshasBothTPAndSLisTrailingPercentOrderra  r  s                             r  r  2coincatch.handle_trigger_stop_loss_and_take_profit	  s   !((A**63DE#'>>&,?
;))&.+N!-	**63DE#//8NO%T1
#4/
't3z"../?PO)5J%T1z ,,^^LM't3J#2
"1"=)Y:9_+_ -;GM*-9GM*.2.E.Ef.TGN+*.*A*A&*W'(^+#3B/01>-.:)? "477S=:#=@_#_bf#f  jE  $E  F  F!LHu}""*GJ%'/+DGGcMJ,F  JS  -S  T  T&:#'6$&3
#&5#&3
#&3#&1
#&*&=&=f&ZGN##&2N#6  $j  k{{7++r  r  r  c	           
         >#    Sn	U R                  5       I Sh  vN   U R                  U5      n
U
S   (       d  [        U R                  S-   U	-   S-   5      eXS'   [        [
        U ]  XX4XVXx5      $  NW7f)a  
*swap markets only* create an order with a stop loss or take profit attached(type 3)
:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much you want to trade in units of the base currency or the number of contracts
:param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
:param float [takeProfit]: the take profit price, in units of the quote currency
:param float [stopLoss]: the stop loss price, in units of the quote currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
r[   NrE   r8  z%() is supported for swap markets onlyrH  )r  r  r*   r6   r  r2   +create_order_with_take_profit_and_stop_loss)r  r  r  r  r  rU  r  r  r  rH  r  r  s              r  r  5coincatch.create_order_with_take_profit_and_stop_loss0
  s      <
!!!V$f~tww}z9<ccdd)|YQRX`dns  BJ  S  	S 	"s   A3A1AA3rA  c                 4    SSSSS.nU R                  X!U5      $ )Nr  iokfokro  )GTCr6  r7  r8  r  )r  rA  timeInForceMaps      r  rq  coincatch.encode_time_in_forceE
  s*    	
 [IIr  r  c           	      "  #    U R                  5       I Sh  vN   SnX2S'   / n/ n[        S[        U5      5       GH  nX   nU R                  US5      nUR	                  U5        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                  XXX5      nU R                  US5      nUb  [        U R                  S-   U-   S-   5      eU R                  US5      nUc  U R                  5       US'   UR	                  U5        GM     U R                  U5      n[        U5      nUS:w  a  [        U R                  S-   5      eU R                  US5      nU R                  U5      nSUS   0nUS   nSnSnSnUS:X  a1  UUS'   U R                  U R                  UU5      5      I Sh  vN nSnOgUS   (       a9  US   US'   UUS'   U R!                  U R                  UU5      5      I Sh  vN nSnO$[        U R                  S-   U-   S-   U-   S-   5      eU R                  US0 5      nU R#                  UU/ 5      nU R%                  U5      $  GNr N Ng7f)a  
create a list of trade orders(all orders should be of the same symbol)

https://coincatch.github.io/github.io/en/spot/#batch-order

: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(max 50 entries)
:param dict [params]: extra parameters specific to the api endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NrZ   rH  r   r  r  r  r  rU  r  r;  r8  z"() does not support trigger ordersr  r   z< createOrders() requires all orders to be of the same symbolr6   rC   r  
resultListrE   r  r  r  	orderInforB  r9  r  )r  r  r  r  r  r  r  create_order_requestr*   r6   uuiduniquer%   r  $privatePostApiSpotV1TradeBatchOrdersr  #privatePostApiMixV1OrderBatchOrdersr  parse_orders)r  r  r  rH  ordersRequestsr@  r  rawOrderr  r  r  r  rU  orderParamsorderRequestr;  r  symbolsLengthordersSymbolr  r  rQ  r  responseOrderspropertyNamer  s                             r  create_orderscoincatch.create_ordersN
  s     !!!#
)|q#f+&AyH%%h9FNN6"##Hf5D##Hf5D%%h9F$$Xw7E..8R@K44V4QVdL++KHL'"477S=:#=@d#dee ,,\?KM$04		_-!!,/! '" ++g&GATWW'eeff''3\*fTl
 F^
 #1GK !FFt{{SZ\bGcddH< (LF^$*:$6GL!'5GO$!EEdkkRY[aFbccH2 'Ltww}z9<VVYccfxxyy~~h3lB?  00M 	"L eD ds6   JJGJ"J#AJ%J&A#JJJc                    U R                  USS5      nXvS'   U R                  U5      nUS   (       a  U R                  XX4XV5      $ US   (       a  U R                  XX4XV5      $ [	        U R
                  S-   U-   S-   US   -   S-   5      e)	NrH  createOrderRequestrC   rE   r8  rB  r  r9  )r  r  rN  rx  r*   r6   )	r  r  r  r  r  rU  r  rH  r  s	            r  r  coincatch.create_order_request
  s    %%fl<PQ
)|V$&>11&e\\F^11&e\\tww}z9<VVY_`fYggj||}}r  r6   c           	      
  #    SnXS'   U R                  5       I Sh  vN   U R                  U5      n	U	S   (       a  U R                  XX4XVU5      I Sh  vN $ [        U R                  S-   U-   S-   U	S   -   S-   5      e Nb N-7f)	a  
edit a trade trigger, stop-looss or take-profit order

https://coincatch.github.io/github.io/en/spot/#modify-plan-order

:param str id: order id
:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
	editOrderrH  NrC   r8  rB  r  r9  )r  r  edit_spot_orderr*   r6   )
r  r6   r  r  r  r  rU  r  rH  r  s
             r  
edit_ordercoincatch.edit_order
  s      !
)|!!!V$&>--b$fU[\\\ tww}z9<VVY_`fYggj||}} 	" ]s!   BA?6BB,BBc                 H  #    U R                  5       I Sh  vN   SnU R                  USU5      u  pU R                  U5      n	U	S   (       d!  [        U R                  S-   U	S   -   S-   5      eSU0n
U R                  US	5      nUb  XS
'   O%Uc  [        U R                  S-   U-   S-   5      eXS'   SnU R                  US5      u  pUS:H  =(       a    US:H  nU(       d!  Ub  [        U R                  S-   U-   S-   5      eUb9  U(       a  U R                  XXeU5      nUS   nUS   nOU R                  U5      U
S'   Ub  XS'   US:X  a  Ub  XjS'   U R                  U R                  X5      5      I Sh  vN nU R                  US0 5      nU R                  UU	5      $  GN N,7f)a
  
@ignore
       edit a trade order

       https://coincatch.github.io/github.io/en/spot/#modify-plan-order

       :param str id: order id
       :param str symbol: unified symbol of the market to create an order in
       :param str type: 'market' or 'limit'
       :param str side: 'buy' or 'sell'
       :param float amount: how much of currency you want to trade in units of base currency
       :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param str [params.clientOrderId]: a unique id for the order that can be used alternative for the id
       :param str params['triggerPrice']: *mandatory* the price that the order is to be triggered at
       :param float [params.cost]: *market buy only* the quote quantity that can be used alternative for the amount
       :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
       NeditSpotOrderrH  rC   z" editSpotOrder() does not support r  z ordersr  r  r  r8  z() requires id or clientOrderIdr  r   r  rD  z5() supports cost parameter for market buy orders onlyr  r  rK  rU  r  )r  r]  r  r*   r6   r  r%   r_  r`  "privatePostApiSpotV1PlanModifyPlanr  r  rQ  )r  r6   r  r  r  r  rU  r  rH  r  r  r  r   rc  rd  r  r  s                    r  r  coincatch.edit_spot_order
  s    & !!!$
!55flJW
V$f~tww)MMPVW]P^^ajjkk
 ((A$#0K ZTWWs]Z7:[[\\!#I//?x'<dem$"2tww}z9<sstt $ C CJX]gk l$V,&x0"&"7"7"?"FOGO%"3$G@@WA]^^ ~~h3f--[ 	"@ _s"   F"FEF"3F 4*F" F"c                 b  #    SnU R                  5       I Sh  vN   0 nU R                  US5      nUc  XS'   SnUb  U R                  U5      nSnU R                  XGX85      u  pSn	Sn
US:X  az  U R	                  U R                  XS5      5      I Sh  vN n	U R                  U	S5      nUc)  [        R                  " U	5      n	U R                  U	S/ 5      nU R                  US0 5      n
OUS:X  a  Uc$  [        U R                  S	-   U-   S
-   U-   S-   5      eUS   US'   Ub  U R                  US5      nXeS'   U R                  U R                  XS5      5      I Sh  vN n	U R                  U	S0 5      n
O$[        U R                  S	-   U-   S-   U-   S-   5      eU R                  X5      $  GN GN NS7f)a  
fetches information on an order made by the user(non-trigger orders only)

https://coincatch.github.io/github.io/en/spot/#get-order-details
https://coincatch.github.io/github.io/en/mix/#get-order-details

:param str id: the order id
:param str symbol: unified symbol of the market the order was made in(is mandatory for swap)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: 'spot' or 'swap' - the type of the market to fetch entry for(default 'spot')
:param str [params.clientOrderId]: a unique id for the order that can be used alternative for the id
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
r   Nr  r  rC   r  r   rE   r8  z"() requires a symbol argument for r9  r6   r  r  rB  )r  r  r  rE  "privatePostApiSpotV1TradeOrderInfor  r  jsonloadsr  r$   r6   ry  privateGetApiMixV1OrderDetailr*   rQ  )r  r6   r  r  rH  r  r  r  rQ  r  r  r  s               r  fetch_ordercoincatch.fetch_order'  s     "
!!!((A !#I[[(F
!??
TZg
!DDT[[QXEabbHT >>(F3D|::h/~~h;NN4B/E6!~'#
(BEi(ilv(v  zL  )L  M  M &tGH(6?;'4$!??G@\]]HF NN8VR8Etww}z9<VVYccfxxyy..U 	" cl ^s6   F/F'A8F/F*CF/F-AF/*F/-F/c                 r  #    SnU R                  5       I Sh  vN   SnUb  U R                  U5      nSnU R                  XVXG5      u  ptXTS'   US:X  a  U R                  XX45      I Sh  vN $ US:X  a  U R	                  XX45      I Sh  vN $ [        U R                  S-   U-   S-   U-   S-   5      e N NJ N,7f)	a9  
fetch all unfilled currently open orders

https://coincatch.github.io/github.io/en/spot/#get-order-list
https://coincatch.github.io/github.io/en/spot/#get-current-plan-orders
https://coincatch.github.io/github.io/en/mix/#get-open-order
https://coincatch.github.io/github.io/en/mix/#get-all-open-order
https://coincatch.github.io/github.io/en/mix/#get-plan-order-tpsl-list

:param str [symbol]: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: True if fetching trigger orders(default False)
:param str [params.type]: 'spot' or 'swap' - the type of the market to fetch entries for(default 'spot')
:param str [params.productType]: *swap only* 'umcbl' or 'dmcbl' - the product type of the market to fetch entries for(default 'umcbl')
:param str [params.marginCoin]: *swap only* the margin coin of the market to fetch entries for
:param str [params.isPlan]: *swap trigger only* 'plan' or 'profit_loss'('plan'(default) for trigger(plan) orders, 'profit_loss' for stop-loss and take-profit orders)
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
r   NrC   rH  rE   r8  rB  r9  )r  r  rE  fetch_open_spot_ordersfetch_open_swap_ordersr*   r6   r  r  r  rK  r  rH  r  rQ  s           r  fetch_open_orderscoincatch.fetch_open_orders  s     * '
!!![[(F
!??
TZg
)|44VERRR6!44VERRRtww}z9<VVYccfxxyy 	" SR4   B7B1AB7(B3)B7B5	)B73B75B7c                   #    U R                  5       I Sh  vN   SnU R                  USU5      u  pT0 nSnUb  U R                  U5      nUS   US'   SnU R                  XESSU5      u  pSn	U(       aw  Uc  [	        U R
                  S	-   U-   S
-   5      eUb  X6S'   U R                  U R                  Xd5      5      I Sh  vN n
U R                  U
S0 5      nU R                  US/ 5      n	O;U R                  U R                  Xd5      5      I Sh  vN n
U R                  U
S/ 5      n	U R                  XX#5      $  GN! N{ N.7f)aG  
@ignore
       fetch all unfilled currently open orders for spot markets

       https://coincatch.github.io/github.io/en/spot/#get-order-list
       https://coincatch.github.io/github.io/en/spot/#get-current-plan-orders

       :param str [symbol]: unified market symbol of the market orders were made in
       :param int [since]: the earliest time in ms to fetch orders for
       :param int [limit]: the maximum number of order structures to retrieve
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param boolean [params.trigger]: True if fetching trigger orders(default False)
       :param str [params.lastEndId]: *for trigger orders only* the last order id to fetch entries after
       :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
       NfetchOpenSpotOrdersrH  r6   r  FrO  stopr8  z0() requires a symbol argument for trigger ordersr  r  r  )r  r]  r  handle_option_and_params_2r$   r6   #privatePostApiSpotV1PlanCurrentPlanr  r  r  #privatePostApiSpotV1TradeOpenOrdersr  )r  r  r  rK  r  rH  r  r  r  r  r  r  s               r  r   coincatch.fetch_open_spot_orders  sU      !!!*
!55flJW
[[(F &tGH	 ;;FPY[aclm	~'#
(BEw(wxx &+
#!EEdkkRYFbccH< >>(FB7D^^D+r:F!EEdkkRYFbccH: ^^Hfb9F  >>_ 	"  dB ds5   D>D7B'D>>D:?AD>D<*D>:D><D>c                 <  #    U R                  5       I Sh  vN   SnU R                  USU5      u  pTSnU R                  XESSU5      u  pdSnU R                  XESU5      u  ptU R	                  US5      nSn	Sn
Ub  U R                  U5      n	S	U	S
   0nU(       d  Ub7  Ub  XS'   Ub  X{S'   U R                  U R                  X5      5      I Sh  vN n
OU R                  U R                  X5      5      I Sh  vN n
OrU(       a  [        U R                  S-   U-   S-   5      eUc  SnSU0nSnU R	                  USU5      nUb  XS'   U R                  U R                  X5      5      I Sh  vN n
U R                  U
S/ 5      nU R                  XX#5      $  GN} N N N07f)a  
@ignore
       fetch all unfilled currently open orders for swap markets

       https://coincatch.github.io/github.io/en/mix/#get-open-order
       https://coincatch.github.io/github.io/en/mix/#get-all-open-order
       https://coincatch.github.io/github.io/en/mix/#get-plan-order-tpsl-list

       :param str [symbol]: unified market symbol of the market orders were made in
       :param int [since]: the earliest time in ms to fetch orders for
       :param int [limit]: the maximum number of order structures to retrieve
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param boolean [params.trigger]: True if fetching trigger orders(default False)
       :param str [params.isPlan]: 'plan' or 'profit_loss'('plan'(default) for trigger(plan) orders, 'profit_loss' for stop-loss and take-profit orders)
       :param str [params.productType]: 'umcbl' or 'dmcbl' - the product type of the market to fetch entries for(default 'umcbl')
       :param str [params.marginCoin]: the margin coin of the market to fetch entries for
       :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
       NfetchOpenSwapOrdersrH  FrO  r  isPlanr  r  r6   r8  z5() requires a symbol argument for swap trigger ordersr  r  r  )r  r]  r  r  handle_optionr  !privateGetApiMixV1PlanCurrentPlanr  privateGetApiMixV1OrderCurrentr$   r6   (privateGetApiMixV1OrderMarginCoinCurrentr  r  )r  r  r  rK  r  rH  r  planr  r  r  r  r  r  s                 r  r   coincatch.fetch_open_swap_orders(  s    & !!!*
!55flJW
	 ;;FPY[aclm	44VSWX((]C[[(F&,G t/*-8M*#(,H%B "&!G!GT[Hd!ee!%!D!DT[[QXEa!bb#DGGcMJ$>Ax$xyy"%{G #J++JjQJ%(2%H "JJ4;;W^KghhH~~h3  u<<Q 	"h fb` isG   FFB6FF(F6F7A2F)F**FFFFc                 r  #    SnU R                  5       I Sh  vN   SnUb  U R                  U5      nSnU R                  XVXG5      u  ptXTS'   US:X  a  U R                  XX45      I Sh  vN $ US:X  a  U R	                  XX45      I Sh  vN $ [        U R                  S-   U-   S-   U-   S-   5      e N NJ N,7f)	a[  
fetches information on multiple canceled and closed orders made by the user

https://coincatch.github.io/github.io/en/spot/#get-order-list
https://coincatch.github.io/github.io/en/spot/#get-history-plan-orders
https://coincatch.github.io/github.io/en/mix/#get-history-orders
https://coincatch.github.io/github.io/en/mix/#get-producttype-history-orders
https://coincatch.github.io/github.io/en/mix/#get-history-plan-orders-tpsl

:param str symbol: *is mandatory* unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch orders for
:param boolean [params.trigger]: True if fetching trigger orders(default False)
:param str [params.isPlan]: *swap only* 'plan' or 'profit_loss'('plan'(default) for trigger(plan) orders, 'profit_loss' for stop-loss and take-profit orders)
:param str [params.type]: 'spot' or 'swap' - the type of the market to fetch entries for(default 'spot')
:param str [params.productType]: *swap only* 'umcbl' or 'dmcbl' - the product type of the market to fetch entries for(default 'umcbl')
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
rh   NrC   rH  rE   r8  rB  r9  )r  r  rE  %fetch_canceled_and_closed_spot_orders%fetch_canceled_and_closed_swap_ordersr*   r6   r  s           r   fetch_canceled_and_closed_orders*coincatch.fetch_canceled_and_closed_orders  s     * 4
!!![[(F
!??
TZg
)|CCFSXaaa6!CCFSXaaatww}z9<VVYccfxxyy 	" bar  c                 `  #    SnU R                  USU5      u  pTUc  [        U R                  S-   U-   S-   5      eSnU R                  5       I Sh  vN   U R	                  U5      nSUS   0nUn	S	n
U R                  XES
SU
5      u  pSnU
(       a  SnU R                  XESU5      u  pUnSnU R                  5       nUc
  Uc  X-
  nUnOUb  X-
  nOX.-   nXS'   XS'   U	c  Un	XS'   U R                  U R                  X5      5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      nOaUb  X(S'   Un	U	b  XS'   U R                  U R                  X5      5      I Sh  vN n[        R                  " U5      nU R                  US/ 5      nU R                  XX#5      $  GNW N ND7f)a  
@ignore
       fetches information on multiple canceled and closed orders made by the user on spot markets

       https://coincatch.github.io/github.io/en/spot/#get-order-history
       https://coincatch.github.io/github.io/en/spot/#get-history-plan-orders

       :param str symbol: *is mandatory* unified market symbol of the market orders were made in
       :param int [since]: the earliest time in ms to fetch orders for
       :param int [limit]: the maximum number of order structures to retrieve
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param int [params.until]: *for trigger orders only* the latest time in ms to fetch orders for
       :param boolean [params.trigger]: True if fetching trigger orders(default False)
       :param str [params.lastEndId]: *for trigger orders only* the last order id to fetch entries after
       :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        fetchCanceledAndClosedSpotOrdersrH  Nr8  .() requires a symbol argument for spot marketsrJ  r  r6   FrO  r  r      X r  r  r  r  r  r  rK  )r]  r$   r6   r  r  r  r  r  #privatePostApiSpotV1PlanHistoryPlanr  r  r   privatePostApiSpotV1TradeHistoryr  r  r  )r  r  r  rK  r  rH  r  r  r  r  r  r  r  requestSinceintervalnowr  r  parsedResponses                      r  r  /coincatch.fetch_canceled_and_closed_spot_orders  s    " 8
!55flJW
>#DGGcMJ$>Aq$qrr!!!V$fTl
 	 ;;FPY[aclm	E 99&gW\]ME L/H##%CL$8"~"$/(#/K !&I#'".J!EEdkkRYFbccH< >>(FB7D^^D+r:F #( ''#/ !BB4;;wC_``HX "ZZ1N^^NFB?F  >>c 	": dL as9   AF.F'B7F.F*	AF.'F,(A F.*F.,F.c                   #    SnU R                  USU5      u  pTUnSnU R                  XESU5      u  ptU R                  5       nSn	Uc
  Uc  X-
  nUnOUb  Xy-
  nOX)-   nUUS.n
Ub  X:S'   SnUb  U R                  U5      nUS   U
S	'   U R	                  US
5      nSnU R                  XESSU5      u  pSnU R                  XESU5      u  pSnSnU(       d  UbJ  Ub  XS'   Ub  XS
'   U R                  U R                  X5      5      I Sh  vN nU R                  US/ 5      nOUbB  U R                  U5      nUS   U
S	'   U R                  U R                  X5      5      I Sh  vN nO1Uc  SnXS
'   U R                  U R                  X5      5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      nU R                  UU5      $  N Np N@7f)a  
@ignore
       fetches information on multiple canceled and closed orders made by the user on swap markets

       https://coincatch.github.io/github.io/en/mix/#get-history-orders
       https://coincatch.github.io/github.io/en/mix/#get-producttype-history-orders
       https://coincatch.github.io/github.io/en/mix/#get-history-plan-orders-tpsl

       :param str [symbol]: unified market symbol of the market orders were made in
       :param int [since]: the earliest time in ms to fetch orders for
       :param int [limit]: the maximum number of order structures to retrieve
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param int [params.until]: the latest time in ms to fetch orders for
       :param boolean [params.trigger]: True if fetching trigger orders(default False)
       :param str [params.isPlan]: *swap only* 'plan' or 'profit_loss'('plan'(default) for trigger(plan) orders, 'profit_loss' for stop-loss and take-profit orders)
       :param str [params.productType]: *swap only* 'umcbl' or 'dmcbl' - the product type of the market to fetch entries for(default 'umcbl')
       :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        fetchCanceledAndClosedSwapOrdersrH  Nr  r  )r  r  r  r6   r  r  FrO  r  r  r  r  r  )r]  r  r  r  r  r  !privateGetApiMixV1PlanHistoryPlanr  r  privateGetApiMixV1OrderHistory)privateGetApiMixV1OrderHistoryProductTyper  r  )r  r  r  rK  r  rH  r  r  r  r  r  r  r  r  r  r  r  r  s                     r  r  /coincatch.fetch_canceled_and_closed_swap_ordersR  s8    & 8
!55flJW
55f'SXY! ,M 4>LE +L$E%
 "'J[[(F &tGH((]C	 ;;FPY[aclm	44VSWX4+$(!&)4&!CCDKKPWD`aaHH ^^Hfb9F!V,$*4L!!%!D!DT[[QXEa!bb&")K)4&!%!O!OPTP[P[\cPl!mmR >>(FB7D^^D+r:F  00s bR c
 ns7   DGG	AG G!1GG=GGGc                 L  #    SnUc  [        U R                  S-   U-   S-   5      eU R                  5       I Sh  vN   U R                  U5      n0 nSnU R	                  US5      u  psUc!  Uc  [        U R                  S-   U-   S-   5      eUb  XvS'   OXS'   US	   nS
n	U R                  X4SSU	5      u  pSn
U	(       a  US:w  a  US   US'   US:X  aY  U	(       a)  U R                  U R                  Xc5      5      I Sh  vN n
OU R                  U R                  Xc5      5      I Sh  vN n
OUS:X  a  SnU R                  X4SU5      u  pUS   US'   U	(       d  UbN  Uc  [        U R                  S-   U-   S-   5      eXS'   U R                  U R                  Xc5      5      I Sh  vN n
OMU R                  U R                  Xc5      5      I Sh  vN n
O$[        U R                  S-   U-   S-   U-   S-   5      eU R                  U
S0 5      nU R                  X5      $  GN GN  N N~ NW7f)a8  
cancels an open order

https://coincatch.github.io/github.io/en/spot/#cancel-order-v2
https://coincatch.github.io/github.io/en/spot/#cancel-plan-order
https://coincatch.github.io/github.io/en/mix/#cancel-order
https://coincatch.github.io/github.io/en/mix/#cancel-plan-order-tpsl

: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
:param str [params.clientOrderId]: a unique id for the order that can be used alternative for the id
:param bool [params.trigger]: True for canceling a trigger order(default False)
:param bool [params.stop]: *swap only* an alternative for trigger param
:param str [params.planType]: *swap trigger only* the type of the plan order to cancel: 'profit_plan' - profit order, 'loss_plan' - loss order, 'normal_plan' - plan order, 'pos_profit' - position profit, 'pos_loss' - position loss, 'moving_plan' - Trailing TP/SL, 'track_plan' - Trailing Stop
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
rK   Nr8  () requires a symbol argumentr  z5() requires an id argument or clientOrderId parameterr  r  r  FrO  r  rC   r6   r  rE   r  r  r    () requires a planType parameter for swap trigger orders("profit_plan" - profit order, "loss_plan" - loss order, "normal_plan" - plan order, "pos_profit" - position profit, "pos_loss" - position loss, "moving_plan" - Trailing TP/SL, "track_plan" - Trailing Stop)rB  r9  r  )r$   r6   r  r  r]  r  "privatePostApiSpotV1PlanCancelPlanr  &privatePostApiSpotV1TradeCancelOrderV2r  !privatePostApiMixV1PlanCancelPlan#privatePostApiMixV1OrderCancelOrderr*   r  rQ  )r  r6   r  r  rH  r  r  r  rQ  rO  r  r  r  s                r  cancel_ordercoincatch.cancel_order  sK    $ #
>#DGGcMJ$>A`$`aa!!!V$! $ 8 8 QJ]2#DGGcMJ$>Ax$xyy$#0K !#IF^
99&iY_ahi:/ &tGH!%!H!HU\Ie!ff!%!L!LT[[Y`Mi!jj6! H#<<VQ[]efH$*:$6GL!X1#+DGGcMJ,F  JR  -R  S  S&.
#!%!G!GT[Hd!ee!%!I!I$++V]Jf!ggtww}z9<VVYccfxxyy~~h3--I 	"& gj fgsZ   7H$HCH$;H<(H$$H%A<H$!H "(H$
H"AH$H$H$ H$"H$c                   #    SnU R                  5       I Sh  vN   SnUb  U R                  U5      n0 nSnU R                  X4X&5      u  pbSnU R                  X#SSU5      u  prSnUS:X  a  U(       aX  Ub	  US   /US'   U R	                  U R                  XR5      5      I Sh  vN nU R                  US	/ 5      n	U R                  X5      $ Uc  [        U R                  S
-   U-   S-   5      eUS   US'   U R                  U R                  XR5      5      I Sh  vN nGOUS:X  Ga  Sn
Ub	  US   US'   OU R                  USU
5      n
XS'   SnU R                  X#SU5      u  pU(       d  Ubz  Uc  [        U R                  S
-   U-   S-   5      eXS'   Ub)  U R                  U R                  XR5      5      I Sh  vN nOU R                  U R                  XR5      5      I Sh  vN nOUb1  US   US'   U R                  U R                  XR5      5      I Sh  vN nOmSnU
S:X  a  SnO6U R                  X#SU5      u  pUc  [        U R                  S
-   U-   S-   5      eXS'   U R!                  U R                  XR5      5      I Sh  vN nU R#                  U5      nU R                  X5      $ [%        U R                  S
-   U-   S-   U-   S-   5      eU R'                  U5      nXS'   U/$  GN GNE GN GN7 GN N Ns7f)a  
cancels all open orders

https://coincatch.github.io/github.io/en/spot/#cancel-all-orders
https://coincatch.github.io/github.io/en/spot/#batch-cancel-plan-orders
https://coincatch.github.io/github.io/en/mix/#batch-cancel-order
https://coincatch.github.io/github.io/en/mix/#cancel-order-by-symbol
https://coincatch.github.io/github.io/en/mix/#cancel-plan-order-tpsl-by-symbol
https://coincatch.github.io/github.io/en/mix/#cancel-all-trigger-order-tpsl

:param str [symbol]: unified symbol of the market the orders were made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: 'spot' or 'swap' - the type of the market to cancel orders for(default 'spot')
:param bool [params.trigger]: True for canceling a trigger orders(default False)
:param str [params.productType]: *swap only(if symbol is not provided* 'umcbl' or 'dmcbl' - the product type of the market to cancel orders for(default 'umcbl')
:param str [params.marginCoin]: *mandatory for swap non-trigger dmcb(if symbol is not provided)* the margin coin of the market to cancel orders for
:param str [params.planType]: *swap trigger only* the type of the plan order to cancel: 'profit_plan' - profit order, 'loss_plan' - loss order, 'normal_plan' - plan order, 'pos_profit' - position profit, 'pos_loss' - position loss, 'moving_plan' - Trailing TP/SL, 'track_plan' - Trailing Stop
:returns dict: response from the exchange
rI   NrC   FrO  r  r6   r@  r  r8  z9() requires a symbol argument for spot non-trigger ordersr  rE   r  r  r  r
  r  r  r  z9() requires a marginCoin parameter for dmcbl product typerB  r9  r  )r  r  rE  r  'privatePostApiSpotV1PlanBatchCancelPlanr  r  r  r$   r6   *privatePostApiSpotV1TradeCancelSymbolOrderr  r  'privatePostApiMixV1PlanCancelSymbolPlan$privatePostApiMixV1PlanCancelAllPlan*privatePostApiMixV1OrderCancelSymbolOrders'privatePostApiMixV1OrderCancelAllOrders+get_result_from_batch_canceling_swap_ordersr*   
safe_order)r  r  r  rH  r  r  rQ  rO  r  r  r  r  r  r  r  s                  r  cancel_all_orderscoincatch.cancel_all_orders!  sc    ( '
!!![[(F
!??
TZg
99&iY_ahi%*0,GI&!%!M!MdkkZaNj!kk ~~h;((66>+DGGcMJ,F  JE  -E  F  F$*4L! "&!P!PQUQ\Q\]dQm!nn6!!K!$*4L!"00]KX)4& H#<<VQ[]efHX1#+DGGcMJ,F  JR  -R  S  S&.
#%%)%Q%QRVR]R]^eRn%ooH%)%N%Nt{{[bOk%llH#(.z(:%!%!P!PQUQ\Q\]dQm!nn"&
')!'J)-)F)Fv[gis)t&J!)/#
0J  NI  1I  J  J(2%!%!M!MdkkZaNj!kk EEhOF$$V44tww}z9<VVYccfxxyy) fw{ 	" l: o  pl o ls   K6K#BK6!K&"A4K6K)BK65K,6(K6K/3K6K2A-K6 K4A#K6&K6)K6,K6/K62K64K6idsc                   #    SnUc  [        U R                  S-   U-   S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nUS   nU R	                  US5      nUb  XS	'   U R                  US5      nO%Uc  [        U R                  S-   U-   S
-   5      eXS'   Sn	Sn
US:X  aO  U R                  U R                  U5      5      I Sh  vN n	U R                  U	S0 5      nU R	                  US/ 5      n
OlUS:X  aB  US   US'   U R                  U R                  Xc5      5      I Sh  vN n	U R                  U	5      n
O$[        U R                  S-   U-   S-   U-   S-   5      eU R                  X5      $  GNI N NP7f)a  
cancel multiple non-trigger orders

https://coincatch.github.io/github.io/en/spot/#cancel-order-in-batch-v2-single-instruments

:param str[] ids: order ids
:param str symbol: *is mandatory* unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str[] [params.clientOrderIds]: client order ids
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
rL   Nr8  r	  r  r6   r  clientOrderIds
clientOidsz;() requires either ids argument or clientOrderIds parameterorderIdsrC   r  r  rE   r  r  rB  r9  )r$   r6   r  r  r  ry  ,privatePostApiSpotV1TradeCancelBatchOrdersV2r  r  )privatePostApiMixV1OrderCancelBatchOrdersr  r*   r  )r  r  r  r  rH  r  r  rQ  r  r  r  r  s               r  cancel_orderscoincatch.cancel_orders  s     $
>#DGGcMJ$>A`$`aa!!!V$fTl
 F^
0@A%$2L!YYv'78F[#DGGcMJ$>A~$~"%J!NNt{{[bOcddH0 >>(FB7D^^D,;F6!$*:$6GL!!KKDKKX_LhiiH EEhOFtww}z9<VVYccfxxyy  00 	"" e8 js6   7F	FBF	FAF	6F7AF	F	F	c                     U R                  US0 5      n/ nU R                  US/ 5      n[        S[        U5      5       H  nXE   nSU0nUR	                  U5        M     U$ )Nr  	order_idsr   r  )r  
safe_valuer  r  r  )r  r  r  r  r   r  r  
resultItems           r  r  5coincatch.get_result_from_batch_canceling_swap_orders  sh    ~~h3??4b9q#h-(AkG7J MM*% ) r  c                 r   U R                  US5      nU R                  US5      nU R                  X2U5      nU R                  US5      nU R                  U R	                  USS5      5      nU R                  U R                  US5      5      nUc  UnU R                  US5      nU R                  U R                  US5      5      n	U R	                  US	S
5      n
U R                  US5      S LnUS:H  =(       a    U	S:H  nUS   (       a  U(       a	  U(       d  S n
U R	                  USS5      nU R                  US5      nS nS nS nUb  U R                  U5      nO@U(       a  U R                  U5      OS n[        R                  " U R                  US5      5      nU R                  U R                  US5      5      nS nUb  US:H  nU R                  U R                  US5      5      nU R                  U R                  US5      5      nU R                  U R	                  USS5      5      nU R                  US5      nUS:X  a  UnOUS:X  a  UnU R                  0 SU R                  US5      _SU R	                  USS5      _SU R                  U5      _S U_S!S _S"U R                  US#5      _SU R                  U5      _SUS   _S$U_SU_SU	_SU_S%U(       a  UOU R                  US&5      _S'U
_S(U R	                  US)S*5      _S+S _SU_UUU R	                  US,S-5      S UUS..UU R                  US/5      UUS0.	EU5      $ )1Nr  r  r  rU  rY  priceAvgr  r  rV  r  r\  r  rD  rC   r  state	feeDetailr  rA  r8  r;  r  presetTakeLossPricer  r  r  r6   r  r  r  rP  rM  lastTradeTimestamplastUpdateTimestampuTimer  rh  r  r  filledr  	filledQty	remainingr  filledAmount)r  r   r  )	r?  r>  r   tradesr  r   r  rr  r  )r  rp  r  	omit_zerorq  r  safe_string_lowerparse_fee_detail_stringr  r0   r  parse_order_time_in_forcer  rs  parse_order_statusr#  )r  r  r  r$  r  rM  rU  r+  r  r  r  r  rc  r  feeDetailStringr   r  r  rA  rr  r;  r?  r>  r  s                           r  rQ  coincatch.parse_order  s   X ##E84%%e\:
((:F%%eW5	t11%.QR>>$"2"25*"EF=E{3$$T%;%;E6%JK##E:v>$$UM:$F	x'<dem6NyF##E8W=**5+>&//@DAK$11*=QUK(()9)9%)GHG44T5K5KES`5ab""d*H~~d&6&6un&MN..)9)9%AX)YZt'9'9%AXZo'pq##E:6{"(M&*O  
$""5)4 
T//T 
 Y/ 
 	 

 !$ 
 "4#4#4UG#D 
 d--f5 
 fX& 
 D 
 ; 
 D 
 U 
 8x1A1A%1U 
 f 
 d((L 
  ! 
" L# 
$  /*&&u.?P' ..= ; 
< = 	r  r  c           
      >    SSSSSSSSSS.	nU R                  X!U5      $ )Nr`  closedcanceled)	not_triggerinitnewpartially_filled	full_fillr2  cancelr@  	cancelledr  )r  r  satusess      r  r;  coincatch.parse_order_status  s9    ! &! "#

 88r  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_nU R                  X!U5      $ )NrD  r  r  r  r  r  reduce_close_longreduce_close_shortoffset_close_longoffset_close_shortburst_close_longburst_close_shortdelivery_close_longdelivery_close_shortr  r  r  )r  r  sidess      r  r  coincatch.parse_order_side  s    
5
F
 
 &	

 &
 5
  
 !%
  
 !%
 
  
 "6
 #E
 %
  6!
$ T22r  c                 4    SSSSS.nU R                  X!U5      $ )Nr  r8  r6  r7  )r  ro  r  r  r  )r  rA  timeInForcess      r  r:  #coincatch.parse_order_time_in_force  s*    	
 ;GGr  r<  c                    / nU R                  U5      nU(       a  [        UR                  5       5      n[        S[	        U5      5       H  nU R                  XE5      nX`R                  ;   d  M%  U R                  U5      nU R                  X60 5      n[        R                  " U R                  US5      5      n	UR                  UU	S.5        M     U$ )Nr   totalFee)r  r  )
parse_jsonlistkeysr  r  r  currencies_by_idr  r  r0   r  r  )
r  r<  r  r-  r\  r  r  r  feeEntryr  s
             r  r9  !coincatch.parse_fee_detail_string  s    OOO4		()D1c$i(!--d6
!6!66#66zBH#~~iRHH$//0@0@:0VWFMM$,"(#  ) r  c                   #    SnU R                  USU5      u  pTU R                  5       I Sh  vN   SnSn0 nUb  U R                  U5      nUS   nUS   US'   O8U R                  XVXG5      u  ptUS:X  a  [	        U R
                  S-   U-   S	-   5      eSn	Un
US:X  a7  S
nUb  Un
U
b  XS'   U R                  U R                  X5      5      I Sh  vN n	OUS:X  a  Ub  X$S'   OSUS'   SnU R                  XES5      u  pUb  XS'   OU R                  5       US'   Ub)  U R                  U R                  X5      5      I Sh  vN n	OfSnU R                  USU5      nXS'   U R                  U R                  X5      5      I Sh  vN n	O$[        U R
                  S-   U-   S-   U-   S-   5      eU R                  U	S/ 5      nU R                  XX#5      $  GN GN N NV7f)aA  
fetch all trades made by the user

https://coincatch.github.io/github.io/en/spot/#get-transaction-details
https://coincatch.github.io/github.io/en/mix/#get-order-fill-detail
https://coincatch.github.io/github.io/en/mix/#get-producttype-order-fill-detail

:param str symbol: *is mandatory* unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum amount of trades to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: *swap markets only* the latest time in ms to fetch trades for, only supports the last 30 days timeframe
:param str [params.lastEndId]: *swap markets only* query the data after self tradeId
:returns Trade[]: a list of `trade structures <https://github.com/ccxt/ccxt/wiki/Manual#trade-structure>`
r   rH  NrC   r  r6   r  r8  r  rJ  rK  rE   r  r   r  r  r  r  rB  r9  r  )r]  r  r  rE  r$   r6   privatePostApiSpotV1TradeFillsr  r  r  privateGetApiMixV1OrderFillsr  privateGetApiMixV1OrderAllFillsr*   r  r  )r  r  r  rK  r  rH  r  rQ  r  r  r  maxSpotLimitr  r  r  s                  r  fetch_my_tradescoincatch.fetch_my_trades   s       %
!55flJW
!!!
[[(FJ &tGH!%!C!CJX^!kJV#'#
(BEu(uvvL +'#/ 4 "@@WA]^^H6! &+{#&'{#E 99&gVME %*	"%)%6%6%8	"!4 "&!B!B4;;wC_!``%"00]KX)4&6 "&!E!EdkkRYFb!cctww}z9<VVYccfxxyy~~h3  u<<m 	"Z _L a> dsI   +GGBGGA/G=G>AG?G AGGGGc           	         #    SnUc  [        U R                  S-   U-   S-   5      eUUS.nU R                  X#X@R                  Xu5      5      I Sh  vN $  N7f)a  
fetch all the trades made from a single order

https://coincatch.github.io/github.io/en/spot/#get-transaction-details

:param str id: order id
:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
r   Nr8  r	  )r  rH  )r$   r6   re  r  )r  r6   r  r  rK  r  rH  r  s           r  fetch_order_tradescoincatch.fetch_order_trades  s`      (
>#DGGcMJ$>A`$`aa$
 ))&G@\]]]]s   AAAAc                   #    U R                  5       I Sh  vN   U R                  U5      nUS   US   S.nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R                  Xc5      $  Nl N*7f)ag  
fetches the margin mode of the trading pair

https://coincatch.github.io/github.io/en/mix/#get-single-account

:param str symbol: unified symbol of the market to fetch the margin mode for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
Nr6   r  r  r  r  )r  r   privateGetApiMixV1AccountAccountr  r  parse_margin_moder=  s          r  fetch_margin_modecoincatch.fetch_margin_mode  s      !!!V$Tl ,
 >>t{{7?[\\: ~~h3%%d33I 	" ]s"   BBABB)BBr:  c                 p    U R                  US5      nUU R                  S U5      U R                  U5      S.$ )Nr:  )r  r  r:  )r8  r  parse_margin_mode_type)r  r:  r  
marginTypes       r  rm  coincatch.parse_margin_mode  s?    ++JE
&&tV455jA
 	
r  c                 0    SSS.nU R                  X!U5      $ )Ncrossisolated)crossedfixedr  r  r  typess      r  rq   coincatch.parse_margin_mode_type  s$    
 T22r  c                   #    Uc  [        U R                  S-   5      eUR                  5       nU R                  5       I Sh  vN   U R	                  U5      nUS   S:w  a!  [        U R                  S-   US   -   S-   5      eUS   US   U R                  U5      S	.nU R                  U R                  XS5      5      I Sh  vN nU$  N N7f)
a:  
set margin mode to 'cross' or 'isolated'

https://coincatch.github.io/github.io/en/mix/#change-margin-mode

:param str marginMode: 'cross' or 'isolated'
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: response from the exchange
Nz+ setMarginMode() requires a symbol argumentr  rE   z& setMarginMode() is not supported for r9  r6   r  )r  r  r:  )	r$   r6   r  r  r  r*   encode_margin_mode_type'privatePostApiMixV1AccountSetMarginModer  )r  r:  r  r  r  r  r  s          r  set_margin_modecoincatch.set_margin_mode  s      >#DGG.[$[\\%%'
!!!V$&>V#tww)QQTZ[aTbbewwxxTl ,66zB

 EEdkkRYFbcc  3 	" ds$   ?C
CA=C
?C C
C
c                 0    SSS.nU R                  X!U5      $ )Nrw  rx  )ru  rv  r  ry  s      r  r}  !coincatch.encode_margin_mode_type  s$    
 T22r  c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   S:w  a!  [	        U R                  S-   US   -   S-   5      eUS   US   S	.nU R                  U R                  XB5      5      I Sh  vN nU R                  US
0 5      nU R                  US5      nUUS:H  S.$  N N37f)aS  
fetchs the position mode, hedged or one way

https://coincatch.github.io/github.io/en/mix/#get-single-account

:param str symbol: unified symbol of the market to fetch entry for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an object detailing whether the market is in hedged or one-way mode
Nz/ fetchPositionMode() requires a symbol argumentr  rE   z* fetchPositionMode() is not supported for r9  r6   r  rk  r  holdModedouble_hold)r  rB  )	r$   r6   r  r  r*   rl  r  r  r  )r  r  r  r  r  r  r  r  s           r  fetch_position_modecoincatch.fetch_position_mode  s      >#DGG._$_``!!!V$&>V#tww)UUX^_eXffi{{||Tl ,
 >>t{{7?[\\~~h3##D*5-/
 	
 	" ]s"   /CCA-CC 2CCrB  c                   #    SnSnU R                  5       I Sh  vN   U R                  US5      nUc{  Ube  U R                  U5      nUS   S:w  a!  [        U R                  S-   US   -   S-   5      eUS	   nUR                  S
5      n	U R                  U	SU5      nOU R                  USU5      nUU(       a  SOSS.n
U R                  U R                  X5      5      I Sh  vN $  N N7f)a  
set hedged to True or False for a market

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Set%20Position%20Mode

:param bool hedged: set to True to use dualSidePosition
:param str symbol: unified symbol of the market to fetch entry for
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.productType]: 'umcbl' or 'dmcbl'(default 'umcbl' if symbol is not provided)
:returns dict: response from the exchange
r   r  Nr  r  rE   z( setPositionMode() is not supported for r9  r6   rN  r   r  single_hold)r  r  )
r  r  r  r*   r6   r  r8  r  )privatePostApiMixV1AccountSetPositionModer  )r  rB  r  r  rH  defaultProductTyper  r  r$  r  r  s              r  set_position_modecoincatch.set_position_mode+  s     '
$!!!&&v}=!V,&>V+&tww1['[^dek^l'l  pB  (B  C  C!$< s+"44UA{K"00]L^_&)/]
 CCDKKPWD`aaa7 	"6 bs"   C)C%CC) C'!C)'C)c                 f  #    U R                  5       I Sh  vN   U R                  U5      nUS   S:w  a!  [        U R                  S-   US   -   S-   5      eUS   US   S.nU R	                  U R                  XB5      5      I Sh  vN nU R                  US	0 5      nU R                  Xc5      $  N N*7f)
a5  
fetch the set leverage for a market

https://coincatch.github.io/github.io/en/mix/#get-single-account

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
Nr  rE   z& fetchLeverage() is not supported for r9  r6   r  rk  r  )r  r  r*   r6   rl  r  r  parse_leverager=  s          r  fetch_leveragecoincatch.fetch_leverageV  s      !!!V$&>V#tww)QQTZ[aTbbewwxxTl ,
 >>t{{7?[\\~~h3""400 	" ]s"   B1B-A-B1B/)B1/B1rD  c                   #    SnUc  [        U R                  S-   U-   S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   S:w  a'  [	        U R                  S-   U-   S-   US   -   S-   5      eUS	   US
   US.nSnU R                  X4S5      u  psUb  XvS'   U R                  U R                  Xc5      5      I Sh  vN nU R                  US0 5      n	U R                  X5      $  N N*7f)a  
set the level of leverage for a market

https://hashkeyglobal-apidoc.readme.io/reference/change-futures-leverage-trade

:param float leverage: the rate of leverage
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.side]: *for isolated margin mode with hedged position mode only* 'long' or 'short'
:returns dict: response from the exchange
r   Nr8  r	  r  rE   rB  r9  r6   r  )r  r  rD  r  r  r  )
r$   r6   r  r  r*   r  %privatePostApiMixV1AccountSetLeverager  r  r  )
r  rD  r  r  rH  r  r  r  r  r  s
             r  set_leveragecoincatch.set_leveragel  s     #
>#DGGcMJ$>A`$`aa!!!V$&>V#tww}z9<VVY_`fYggj||}}Tl , 

 44VP"&JCCDKKPWD`aa  ~~h3""400= 	" bs"   7C8C4BC8C6)C86C8c                 $   U R                  US5      nU R                  X25      nU R                  U R                  US5      5      nU R	                  USS5      nU R	                  USS5      nU R                  US5      nUS:X  a  UnUnUUS   UUUS	.$ )
Nr  r:  fixedLongLeveragelongLeveragefixedShortLeverageshortLeveragecrossMarginLeverageru  )r  r  r:  r  r  )r  rp  rq  r8  ro  r  )r  rD  r  r$  r:  r  r  r  s           r  r  coincatch.parse_leverage  s    F ##Hh7((:001G1GR^1_`
**85H.Y++H6JO\"//:OP .L/MX&$(*
 	
r  c                 T  #    SnU R                  USU5      u  pTU R                  5       I S h  vN   U R                  U5      nUS   S:w  a'  [        U R                  S-   U-   S-   US   -   S-   5      eU R                  X5      nUS   US	   US
.nS nU R                  XES5      u  pUb  XS'   U R                  U R                  Xt5      5      I S h  vN n	US:X  a  [        R                  " U5      nU R                  U R                  X5      U R                  U5      US.5      $  N NU7f)NmodifyMarginHelperrH  r  rE   r8  rB  r9  r6   r  )r  r  r  r  r  reduce)r  r  )r]  r  r  r*   r6   r  r  #privatePostApiMixV1AccountSetMarginr  r0   r  parse_margin_modificationr  )
r  r  r  r  r  rH  r  r  r  r  s
             r  modify_margin_helpercoincatch.modify_margin_helper  sE    )
!55flJW
!!!V$&>V#tww}z9<VVY_`fYggj||}}))&9Tl ,

 44VP"&JAA$++gB^__
 8''/F{{499(K''/N
  	+ 	" `s#   +D(D$B"D(D&AD(&D(r  c                 `    U R                  US5      nUS:X  a  SOSnUUS   S S S S US   US S S.
$ )Nr  r  r  failedr  r  )
r  r  r  r:  r  r  r  r  rM  rP  r  )r  r  r  r  r  s        r  r  #coincatch.parse_margin_modification  sU     tU+*X&7O
 	
r  c                 P   #    SUS'   U R                  X* SU5      I Sh  vN $  N7f)a  
remove margin from a position

https://coincatch.github.io/github.io/en/mix/#change-margin

:param str symbol: unified market symbol
:param float amount: the amount of margin to remove
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.side]: *for isolated margin mode with hedged position mode only* 'long' or 'short'
:returns dict: a `margin structure <https://docs.ccxt.com/#/?id=reduce-margin-structure>`
r   rH  r  Nr  r  r  r  r  s       r  reduce_margincoincatch.reduce_margin  s.       .|..vw&QQQQs   &$&c                 N   #    SUS'   U R                  XSU5      I Sh  vN $  N7f)a  
add margin

https://coincatch.github.io/github.io/en/mix/#change-margin

:param str symbol: unified market symbol
:param float amount: amount of margin to add
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.side]: *for isolated margin mode with hedged position mode only* 'long' or 'short'
:returns dict: a `margin structure <https://docs.ccxt.com/#/?id=add-margin-structure>`
rH   rH  addNr  r  s       r  
add_margincoincatch.add_margin  s,       +|..vufMMMMs   %#%c                   #    SnSnU R                  X#S5      u  pBU R                  X5      I Sh  vN n[        U5      nUS:  a-  [        S[        U5      5       H  nXW   nUS   U:X  d  M  Us  $    U R	                  US0 5      $  NU7f)a
  
       fetch data on a single open contract trade position

       https://coincatch.github.io/github.io/en/mix/#get-symbol-position

       :param str symbol: unified market symbol of the market the position is held in, default is None
       :param dict [params]: extra parameters specific to the exchange API endpoint
@param {str}  [params.side] 'long' or 'short' *for non-hedged position mode only* (default 'long')
       :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
       r   r  r  Nr   r   )r  fetch_positions_for_symbolr  r  r  )	r  r  r  rH  r  	positionsarrayLengthr  positions	            r  fetch_positioncoincatch.fetch_position  s      %
44VP99&II	)n?1c)n-$<F#t+#O . ~~iB// Js   -BB8B,Bc                   #    U R                  5       I Sh  vN   U R                  U5      nUS   US   S.nU R                  U R                  XB5      5      I Sh  vN nU R	                  US/ 5      nU R                  Xa/5      $  Nm N+7f)ar  
fetch open positions for a single market

https://coincatch.github.io/github.io/en/mix/#get-symbol-position

fetch all open positions for specific symbol
:param str symbol: unified market symbol
: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>`
Nr6   r  rk  r  )r  r  *privateGetApiMixV1PositionSinglePositionV2r  r  parse_positionsr=  s          r  r  $coincatch.fetch_positions_for_symbol3  s      !!!V$Tl ,
 HHU\Ieff@ ~~h3##D(33O 	" gs"   BBABB*BBc                   #    SnU R                  5       I Sh  vN   SnUb  U R                  U5      n/ n[        S[        U5      5       H;  nXW   nUR	                  S5      n	U R                  U	S5      n
UR                  U
5        M=     U R                  U5      n[        U5      nUS:  a  [        U R                  S-   U-   S-   5      eUS   nOU R                  X#S	U5      u  pBS	U0nUS
:X  a2  SnU R                  X#S5      u  pUb  U R                  U5      nUS   US'   U R                  U R                  X5      5      I Sh  vN nU R                  US/ 5      nU R                  UU5      $  GNU N,7f)a8  
fetch all open positions

https://coincatch.github.io/github.io/en/mix/#get-all-position

:param str[] [symbols]: list of unified market symbols(all symbols must belong to the same product type)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.productType]: 'umcbl' or 'dmcbl'(default 'umcbl' if symbols are not provided)
:param str [params.marginCoin]: the settle currency of the positions, needs to match the productType
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
r   Nr  r   rN  r   r8  zJ() requires all symbols to belong to the same product type(umcbl or dmcbl)r  r  r  r6   r  )r  
market_idsr  r  r  r  r  r  r&   r6   r  r  'privateGetApiMixV1PositionAllPositionV2r  r  r  )r  r@  r  rH  r  	marketIdsproductTypesr  r$  r  marketProductTyper  r  r  r  r  r  s                    r  fetch_positionscoincatch.fetch_positionsg  s     &
!!!0IL1c)n-$< s+$($4$4UA$>!##$56	 .
  ;;|4Ll+KQ#
 :  >J  !J  K  K*1o"&"?"?Tacn"oK;
 '!"J!%!>!>vS_!`J%==4(0%EEdkkRYFbccB ~~h3##D'22{ 	"6 ds"   E2E-D*E2E0*E20E2r  c                    U R                  US5      nU R                  US5      nU R                  X2U5      nU R                  US5      nU R                  US5      nS nU R                  US5      nUS:X  a  SnOUS:X  a  S	nU R                  US
5      n	U R                  US5      n
U R	                  0 SUS   _SS _SU_SU R                  U5      _SU R                  US5      _SS _SU R                  US5      _SU	_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U R                  US5      _SU R                  US5      _SU R                  U5      _S U_S U R                  [        R                  " U
S!5      5      U	S U R                  US"5      U R                  US#5      S S S S US$.E5      $ )%Nr  r  r  r:  r  r  Tr  FrD   keepMarginRater6   rM  rP  	contractsr  r  r  r  notionalrD  unrealizedPnlunrealizedPLrealizedPnlachievedProfits
collateral
entryPriceaverageOpenPricern  marketPriceliquidationPricerB  rg  marginRatior1  )maintenanceMarginmaintenanceMarginPercentageinitialMargininitialMarginPercentager  r0  	lastPricer>  r?  r   r  )r  rp  r  r  safe_positionrs  r8  rq  r  r0   r!  )r  r  r  r$  r  rM  r:  isHedgedr  rD   r  s              r  parse_positioncoincatch.parse_position  st   4 ##Hh7##Hl;((8D%%h8	%%h=
##Hj9}$H&H!!(H5))(4DE!! #
fX&#
$#
 #
 Y/	#

 ))(G<#
 D#
 D**8Z@#
 #
 ))(J?#
 T--hG#
 4++H6GH#
 $#
 $**85GH#
 ))(MB#
  0 0;M N#
  $55jA!#
" h##
$ "&+/+<+<W=O=OP^`e=f+g#'+++HmD#'#4#4Xw#G!#9#
  	r  r$  r  c                     U R                  X5      nU$ ! [         ah  nU R                  U R                  U/ 5      nUc  US   n S nAU$ [	        S[        U5      5       H  nXV   nUS   U:X  d  M  Un   S nAU$     S nAU$ S nAff = f)Nr   r  )safe_market	Exceptionr  markets_by_idr  r  )r  r$  r  r  emarketsWithCurrentIdr  marketWithCurrentIds           r  rp  coincatch.safe_market_custom  s    	%%h7F   	 $(>>$2D2DhPR#S -a0  q#&:";<A*>*A'*:6(B!4 =
 	s&    
B%B
#B1B:BBc                   #    SnU R                  5       I Sh  vN   0 nSnU R                  USXG5      u  ptSnSn	Ub  U R                  U5      n	US:X  a\  U	b  U R                  U	S5      n
XS'   Ub  X6S'   U R	                  U R                  Xd5      5      I Sh  vN nU R                  US/ 5      nOUS:X  a  Ub  X&S	'   OS
US	'   SnU R                  XES5      u  pUb  XS'   OU R                  5       US'   Ub  X6S'   SnUc  U R                  USU5      nOUS:X  a  SnOSnU R                  USU5      u  pXS'   U R                  U R                  Xd5      5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      nO![        U R                  S-   U-   S-   U-   5      eU R                  XX#5      $  GN GN& Nd7f)a  
fetch the history of changes, actions done by the user or operations that altered balance of the user

https://coincatch.github.io/github.io/en/spot/#get-bills
https://coincatch.github.io/github.io/en/mix/#get-business-account-bill

:param str [code]: unified currency code
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
:param int [limit]: max number of ledger entrys to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: *swap only* the latest time in ms to fetch entries for
:param str [params.type]: 'spot' or 'swap'(default 'spot')
:param str [params.after]: *spot only* billId, return the data less than self billId
:param str [params.before]: *spot only* billId, return the data greater than or equals to self billId
:param str [params.groupType]: *spot only*
:param str [params.bizType]: *spot only*
:param str [params.productType]: *swap only* 'umcbl' or 'dmcbl'(default 'umcbl' or 'dmcbl' if code is provided and code is not equal to 'USDT')
:param str [params.business]: *swap only*
:param str [params.lastEndId]: *swap only*
:param bool [params.next]: *swap only*
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
rz   NrC   r  r  rK  r  rE   r  r   r  r  r  r  r  r  r  r  r8  z () does not support market type )r  rE  r  r   privatePostApiSpotV1AccountBillsr  r  r  r  r  r]  ,privateGetApiMixV1AccountAccountBusinessBillr  r*   r6   parse_ledger)r  r  r  rK  r  rH  r  rQ  r  r  r  r  r  r  r  s                  r  fetch_ledgercoincatch.fetch_ledger
  s	    . #
!!!
!??
DRXe
}}T*H# ,,X{C	$-! #( !BB4;;wC_``H, ^^Hfb9F6! ',$'($E 99&gVME %*	"%)%6%6%8	" &+
#!K|"00]KX%%"&":":6=R]"^K%0M"!NNt{{[bOkllHb >>(FB7D^^D(B7Ftww}z9<^^akkll  5@@a 	" aZ ms6   GF:A>GF=CGG AG=G Gitemc                    U R                  US5      nU R                  USS5      nS nU R                  US5      nU R                  XeU5      nU R                  USS5      nSn[        R
                  " US5      (       a  S	n[        R                  " US
5      n[        R                  " U R                  USS5      5      U R                  US5      S.n	U R                  0 SU R                  USS5      _SU_SU_SU R                  U5      _SS _SU_SS _SS _SU R                  U R                  USS5      5      _SU R                  XB5      _SUS   _SU_SS _SU R                  US5      _SS _SU	_U5      $ )!Nr  r  r  r  rV  r  inr  outz-1r  r   feeCoinr  r6   billIdr  rM  rP  r  	directionreferenceIdreferenceAccountr  bizTypebusinessr  r  r  balancer  r  )r  rq  r  rp  r0   	string_ltr!  r  safe_ledger_entryrs  parse_ledger_entry_typer  r  )
r  r  r  rM  r  r  r$  rk  r  r  s
             r  parse_ledger_entrycoincatch.parse_ledger_entry  s   8 %%dG4	%%dJE##D(3((8D))$
HE	\3//I"--lDAL&&t'9'9$v'NO((y9
 %% '
$$$T8T:'
D'
 '
 Y/	'

 t'
 '
 4'
 '
 D001I1I$PY[e1fg'
 //C'
 fX&'
 l'
 d'
 T%%dI6'
 d'
  3!'
" # 	r  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SS.EnU R                  X!U5      $ )Nr  r   
withdrawalrD  r  r  zdeduction of handling feer  ztransfer-inr   ztransfer inztransfer outzrebate rewardsrebatezairdrop rewardszusdt contract rewardszmix contract rewardszsystem lockz	user lockr  r  r  )r  trans_from_exchangetrans_to_exchangecontract_settle_feeburst_long_loss_queryburst_short_loss_queryr  ry  s      r  r  !coincatch.parse_ledger_entry_type  s    
y

 7
 G	

 (
 :
 :
 J
 h
 x
 $X
 #H
 =
 
 
  '!
" '#
$ ##-!+#(%,&-/
2 T22r  reasonr   r  headersbodyc
                 V   U(       d  g U R                  US5      n
U R                  S-   U-   nU R                  US5      nU
S:H  =(       d    U
S L nUR                  S5      S:  av  U R                  US0 5      nU R	                  USS	/ 5      nU R                  U5      (       d9  S
nU R                  US0 5      nU R                  US5      nU R                  US5      n
U(       dI  U R                  U R                  S   X5        U R                  U R                  S   X5        [        U5      eg )Nr  r8  r  r  batchr   r  failure
fail_infosF	errorCodeerrorMsgr  r  )
r  r6   r1  r  r  is_emptythrow_exactly_matched_exceptionrZ  throw_broadly_matched_exceptionr!   )r  r  r  r   r  r  r  r  requestHeadersrequestBodymessagefeedbackmessageCoder  r  r  
firstEntrys                    r  handle_errorscoincatch.handle_errors  s   ""8U377S=4'&&x8i'=W_88G!>>(FB7D&&tYbIG==))!^^GQ;
"..z;G**:zB001I;a001I7]))r  r   GETc           
      T   SU-   nUS:X  a(  U R                  U5      n[        U5      S:w  a  USU-   -  nUS:X  a  U R                  5         U R                  U R	                  5       5      n	Sn
US:w  a  U R                  U5      nUn
X-   U-   U
-   nU R                  U R                  U5      U R                  U R                  5      [        R                  S5      nU R                  UU	U R                  SU R                  U R                  S	S
5      S.nU R                  S   U   U-   nXXeS.$ )Nr
  r  r   ?r   r   base64zapplication/jsonr,  r   )z
ACCESS-KEYzACCESS-SIGNzACCESS-TIMESTAMPzACCESS-PASSPHRASEzContent-TypezX-CHANNEL-API-CODEr   )r   r  r  r  )	urlencoder  check_required_credentialsr`  r  r  hmacencoder   hashlibsha256r   r   r  r   r   )r  r  r   r  r  r  r  endpointqueryrM  r&  payload	signaturer   s                 r  signcoincatch.sign"  s#   :U?NN6*E5zQC%K')++---d.?.?.ABIFyy((83f<G		$++g"6DKK8PRYR`R`bjkI"kk($-%)]] 2&*&6&6t||ZQX&YG iis#h.dOOr   r  )NN)__name__
__module____qualname____firstlineno__r   r  r  r   r  r   r  r   r  r	   r  r    r   r  dictr-  r  strr   r>  r   rI  r<  r   r|  r[  r  r  r   r  r  r   r  r  objectr  r   r  r   r  r  floatr   r   r  r
   r  r  r   r*  r.  r   r3  rF  r   r   r   r   rE  rI  rN  r_  r   r^  rJ  rx  r  r  rq  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r#  r  rQ  r;  r  r:  r9  re  rh  r   rn  rm  rq  r  r}  r  boolr  r   r  r  r  r  r   r  r  r  r  r   r  r  r  r  rp  r  r   r  r  r  r$  __static_attributes____classcell__)r  s   @r  r2   r2      s   {# {z MO 	 ') 3S 3( -/ e: eN BFb Iw I0 0d *, G+V G+RQ4 QF Qf, 68 N/ N/F N/` 6:" \17 \1 \1|K6 KV KZ @DB 1NS 1N 1NS\ 1Nf ?CQUdhqs ]~ ]~ ]~3 ]~^a ]~x|  ~B  yC ]~~
 
4 
 <@d[] K= K=S K= K=bfglbm K=ZU Uv U Un <> 5s 5+ 5B
6 
0'v '3 '\_ 'jp '  DG ' >BPTcgpr 7@s 7@# 7@]` 7@r *, F( F(P0) 0)d ac 073 07 07C 07TW 07gt 07d
 
$ =? ( (> (T
h 
R` 
. 04$UYbd 9E 9EC 9Es 9Eimnyiz 9Ev 37TX\eg #EC #Es #ERU #Elpq|l} #EJ QU]_ *63 *6 *6 *6# *6do *6XL
x L
; L
\ XZ Tc T T( mqy{ w wI wY wX] wfi w  AF wB rv  A *.c *. *.) *.]b *.kn *.  FK *.X tx  AC @, @,9 @,I @,_d @,mp @,  HL @,D NP^brv  EI  W\  d X[ lo   B   QT . RTkp S $ dh  rv  A 6.c 6. 6.) 6.]b 6.kn 6.  FK 6.p tx  AC H, H,9 H,I H,_d H,mp H,  HL H,T ^ksu A,F LP  dh  z~  GI S SS\ Sdm Sw| S  FI S  ^a S  tw S  NS S S*J J J FH p1$|*< p1d os{} 	~3 	~i 	~y 	~Z_ 	~hk 	~  CG 	~ fjx|  FH ~3 ~ ~9 ~I ~_b ~ru ~4 y}  FH @. @.S @.	 @.QZ @.di @.ru @.D 8<B z/C z/ z/5 z/x 59tZ^gi "zc "z "zTW "znrsxny "zH :>D_cln _?3 _?c _?Y\ _?swx}s~ _?B :>D_cln {=3 {=c {=Y\ {=swx}s~ {=z DHVZimvx "zS "zPS "zcf "z  ~B  CH  ~I "zH IM[_nr{} G?# G?UX G?hk G?  CG  HM  CN G?R IM[_nr{} R1# R1UX R1hk R1  CG  HM  CN R1h 9=R 9.S 9.# 9.v 59 rc rh AER O1tCy O1# O1b
O Ob9 9 93S 3S 3*HS HS Hs " 37TX\eg H=C H=s H=RU H=lpqvlw H=T ?CQUdhqs ^3 ^ ^3 ^^a ^x|  ~C  yD ^, ;= .4c .4 .4`
D 
* 
33 33 3 DHPR ' 'S 'R3C 3C 3 7;2 
 
8 CGr )bd )bC )bV 8: 13 1h 1, ?C2 -13 -1 -1^2
t 2
V 2
x 2
h LN  Rd :
d 
F 
N` 
$ FH R# Ru RL^ R CE Ns NE NI[ N 8: 03 0h 0. DF 24s 24$x. 24h 8<B J3W J34PX> J3XDt DV DL3  QT `f " .2SW`b hAs hA# hAS hAT;t ;x ;; ;z3C 3C 38# s  c TX `c * &eBSW P Pr  r2   )9 ccxt.async_support.base.exchanger   ccxt.abstract.coincatchr   r  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   r   typingr    ccxt.base.errorsr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   ccxt.base.decimal_to_precisionr/   ccxt.base.preciser0   r2   r&  r  r  <module>r9     s    6 /    n  n  n  n  n  n  n  n  * 0 - . ' & . ) * ) + . * ) 4 %[PP+ [PPr  