
    E#i%                       S SK Jr  S SKJ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 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&J0r0  S SK&J1r1  S SK&J2r2  S SK&J3r3  S SK&J4r4  S SK&J5r5  S SK6J7r7  S SK8J9r9   " S S\\5      r:g)    )Exchange)ImplicitAPIN)AnyBalancesBorrowInterest
CurrenciesCurrencyDepositAddressIntIsolatedBorrowRateLeverageLeverageTierLeverageTiersMarginModificationMarketNumOrderOrderRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTradingFeeInterfaceTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)OperationFailed)RateLimitExceeded)ExchangeNotAvailable)RequestTimeout)	TICK_SIZE)Precisec                   	  ^  \ rS rSrS\4U 4S jjr0 4S\4S jjr0 4S\\	   4S jjr
S\\	   4S jrS rSS	\S
\	S\4S jjr0 4S\S\4S jjrS0 4S\S\4S jjr0 4S\4S jjrS0 4S\S\4S jjrSS\S
\	S\4S jjrSS0 4S\S\S\S\\   4S jjr0 4S\S\4S jjr0 4S\4S jjrSS\S
\	S\4S jjrSS
\	S\ 4S jjr!SSS0 4S\S\S\S\S\\    4
S jjr"0 4S  jr#0 4S! jr$0 4S" jr%0 4S# jr&0 4S\'4S$ jjr(S%\)4S& jr*SS'\S
\	S\+4S( jjr,0 4S\S)\-4S* jjr.S0 4S\S+\/S,\0S-\-S.\14
S/ jjr2S0 4S\S+\/S,\0S-\-S.\14
S0 jjr30 4S1\\4   S\\+   4S2 jjr5S0 4S3\\   S\)4S4 jjr6SS0 4S5\S\S+\/S,\0S-\1S.\14S6 jjr7S0 4S5\S\)4S7 jjr8S0 4S\)4S8 jjr9S0 4S5\S\)4S9 jjr:SSS0 4S\)S\S\4S: jjr;SSS0 4S\)S\S\S\\+   4S; jjr<SSS0 4S\)S\S\S\\+   4S< jjr=0 4S=\S\>4S> jjr?0 4S=\S\>4S? jjr@SS@\AS\>4SA jjrBSSS0 4S\)S\S\4SB jjrCS0 4S\S\\D   4SC jjrE0 4S\4SD jjrFSSE\S
\	4SF jjrGS0 4SG\S\)4SH jjrHS0 4SI\IS\)4SJ jjrJS0 4S\S\K4SK jjrLSS
\	S\\M   4SL jjrN0 4S\4SM jjrOSSN\S
\	S\P4SO jjrQ0 4S\S-\-S\P4SP jjrR0 4S\S-\-S\P4SQ jjrSSSS0 4S\)S\S\4SR jjrT0 4S\S\U4SS jjrV0 4S\S\U4ST jjrWSS
\	S\U4SU jjrXSV rYS0 4S\S\Z4SW jjr[S0 4S=\S-\-SX\SY\)S\\4
SZ jjr]S%\)4S[ jr^SSS0 4S\)S\S\4S\ jjr_SS]\S@\AS\\4S^ jjr`0 4S=\S-\-S_\S`\S\a4
Sa jjrbSb rcSSc\S@\AS\a4Sd jjrdSSS0 4S=\)S\S\S\\a   4Se jjreSSS0 4S=\)S\S\S\\\   4Sf jjrfSSS0 4S=\)S\S\S\\\   4Sg jjrgSSh\S
\	S\h4Si jjri0 4S\S\h4Sj jjrjSSSS0 4S=\)S\)S\S\S\\k   4
Sk jjrlSSh\S
\	S\k4Sl jjrm0 4S\S=\S-\-4Sm jjrn0 4S\S=\4Sn jjroSS@\A4So jjrp0 4S=\4Sp jjrqS0 4Sq\4Sr jjrrSS@\A4Ss jjrs0 4S\S\t4St jjruSSI\S
\	S\t4Su jjrvSS0 4S\S\S\S\\D   4Sv jjrwS0 4S\S,\0S\+4Sw jjrx0 S4U 4Sx jjrySy rz/ Sz0 SS4S{ jr{S|\IS}\S~\S\S\S\4S jr|SSSS0 4S\)S+\)S\1S\1S\\P   4
S jjr}Sr~U =r$ )coinex   returnc                   > U R                  [        [        U ]  5       0 SS_SS_SS_SS/_S	S
_SS_SS_S0 SS _SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S S_0 S!S_S"S_S#S_S$S_S%S_S&S_S'S_S(S_S)S_S*S_S+S_S,S_S-S_S.S_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_SESF_SGS_SHS_SIS_SJS_SKS_SLS_SMS_SNS_SOS_SPS_SQS_SRS_SSS_STS_E0 SUS_SVS_SWS_SXS_SYS_SZS_S[S_S\S_S]S_S^S_S_S_S`S_SaS_SbS_ScS_SdS_SeS_E_SfSgShSiSjSkSlSmSnSoSpSqSrSsSt._SuSvSwSwSxSxSy.SzS{S|S}S~._SSSSSSSSSSSSSSSSS.00 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSSSSSS.E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS0ESSSSSS.SSSSSSSSSS.	S.SSSSSSSSSSSS.
0SSSSSSSSSSSSSSSS.0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSS.ES.Sy.S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSS.E00 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_ESSSSSSSS.E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_GS S_GSS_GSS_GSS_0 GSS_GSS_GSS_GSS_GSS_GS	S_GS
GS_GSGS_GSGS_GSGS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_ESSGSGSSSSSSSSSSGS.ES.GS.GS._GSGSGSGS.SeGSGSGSGSGSGSGS.0GS ._GS!GS"GSS GS#.0_GS$GS%SSGS&GS'S0GS(GS)GS*GS+.SSSGS,.0 GS-GS-_GS.GS/_GS0GS0_GS1GS1_GS2GS2_GS3GS3_GS4GS4_GS5GS5_GS6GS7_GS8GS9_GS:GS:_GS;GS;_GS<GS=_GS>GS>_GS?GS@_GSAGSB_GSCGSD_0 GSEGSF_GSGGSG_GSHGSH_GSIGSI_GSJGSJ_GSKGSK_GSLGSL_GSMGSM_GSNGSN_GSOGSO_GSPGSP_GSQGSR_GSSGSS_GSTGST_GSUGSU_GSVGSW_GSXGSX_EGSYGSZGS[.EGS\._GS]SSSS SSSS SSSSGS^.SSSSSSSGS_.GS`GSa0SGSbS GScSGSd.SSSSGSe.SGSbSSSGSf.S SGSbS S S SSSGSg.GShGSb0GSi.	SSSSGSj.GSkS0GSkS0GSl.GSmGSn0GSmGSn0GSo.S S GSo.GSp._GSqGSrGSs0_GSt[        _GSu0 GSv[
        _GSw[        _GSx[        _GSy[        _GSz[        _GS{[        _GS|[        _GS}[        _GS~[
        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[
        _GS[        _GS[        _GS[        _GS[
        _GS[        _GS[        _GS[         _E[        [        [        [        [
        GS.E[
        [        ["        GS.GS.0E5      $ (  Nidr6   nameCoinExversionv2	countriesCN	rateLimitg      @proT	certifiedhasCORSspotmarginswapfutureFoption	addMarginborrowCrossMarginborrowIsolatedMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateOrderscreateReduceOnlyOrdercreateStopLossOrdercreateStopOrdercreateTakeProfitOrdercreateTriggerOrder	editOrderfetchBalancefetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositWithdrawFeefetchDepositWithdrawFeesfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeveragesfetchLeverageTiersfetchMarginAdjustmentHistoryfetchMarketLeverageTiersemulatedfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenOrders
fetchOrderfetchOrderBookfetchPositionfetchPositionHistoryfetchPositionsfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransferfetchTransfersfetchWithdrawalfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeveragesetMarginModesetPositionModetransferwithdraw
timeframes1min3min5min15min30min1hour2hour4hour6hour12hour1day3day1week)1m3m5m15m30m1h2h4h6h12h1d3d1wurlszdhttps://user-images.githubusercontent.com/51840849/87182089-1e05fa00-c2ec-11ea-8da9-cc73b45abbbc.jpgzhttps://api.coinex.comz https://api.coinex.com/perpetual)publicprivateperpetualPublicperpetualPrivatezhttps://www.coinex.comzhttps://docs.coinex.com/api/v2zhttps://www.coinex.com/feesz0https://www.coinex.com/register?refer_code=yw5fz)logoapiwwwdocfeesreferralr   get   )z
amm/marketzcommon/currency/ratezcommon/asset/configzcommon/maintain/infozcommon/temp-maintain/infozmargin/marketzmarket/infomarket/listmarket/tickermarket/ticker/allmarket/depthmarket/dealsmarket/klinezmarket/detailzaccount/amm/balance(   zaccount/investment/balancezaccount/balance/historyzaccount/market/feezbalance/coin/depositbalance/coin/withdrawzbalance/info#balance/deposit/address/{coin_type}zcontract/transfer/historyzcredit/infozcredit/balancezinvestment/transfer/historyzmargin/accountzmargin/configzmargin/loan/historyzmargin/transfer/historyzorder/deals   )order/finishedorder/pendingorder/statuszorder/status/batchzorder/user/dealszorder/stop/finishedorder/stop/pendingzorder/user/trade/feezorder/market/trade/infozsub_account/balancezsub_account/transfer/historysub_account/auth/api#sub_account/auth/api/{user_auth_id}zcontract/balance/transferzmargin/flatzmargin/loanzmargin/transferzorder/limit/batchz	order/iocg^I*@zorder/limitzorder/marketzorder/modifyzorder/stop/limitzorder/stop/marketzorder/stop/modifyzsub_account/transferzsub_account/registersub_account/unfrozensub_account/frozenr   )r   r   r   r   zv1/account/settings)	r   zorder/pending/batchr   r   zorder/stop/pending/{id}zorder/pending/by_client_idzorder/stop/pending/by_client_idr   zsub_account/authorize/{id})r   postputdelete)
pingtimer   zmarket/limit_configr   r   r   r   zmarket/funding_historyr   )zmarket/user_dealszasset/queryr   r   zorder/stop_finishedzorder/stop_pendingr   zorder/stop_statuszposition/finishedzposition/pendingzposition/fundingzposition/adl_historymarket/preferencezposition/margin_historyzposition/settle_historyzmarket/adjust_leveragezmarket/position_expectzorder/put_limit   zorder/put_marketzorder/put_stop_limitzorder/put_stop_marketzorder/modify_stopzorder/cancelzorder/cancel_allzorder/cancel_batchzorder/cancel_stopzorder/cancel_stop_allzorder/close_limitzorder/close_marketzposition/adjust_marginzposition/stop_loss)zposition/take_profitzposition/market_closezorder/cancel/by_client_idzorder/cancel_stop/by_client_idr   )r   r   zmaintain/infor   r   zspot/marketzspot/tickerz
spot/depthz
spot/dealsz
spot/klinez
spot/indexzfutures/marketzfutures/tickerzfutures/depthzfutures/dealszfutures/klinezfutures/indexzfutures/funding-ratezfutures/funding-rate-history)zfutures/position-levelzfutures/liquidation-historyzfutures/basis-historyzassets/deposit-withdraw-configz"assets/all-deposit-withdraw-configzaccount/subszaccount/subs/api-detailzaccount/subs/infozaccount/subs/apizaccount/subs/transfer-historyzaccount/subs/spot-balancezaccount/trade-fee-ratezassets/spot/balancezassets/futures/balancezassets/margin/balancezassets/financial/balancezassets/amm/liquidityzassets/credit/infozassets/margin/borrow-historyzassets/margin/interest-limitzassets/deposit-addresszassets/deposit-historyzassets/withdrawzassets/transfer-historyzspot/order-statuszspot/batch-order-statuszspot/pending-orderzspot/finished-orderzspot/pending-stop-orderzspot/finished-stop-orderzspot/user-dealszspot/order-dealszfutures/order-statuszfutures/batch-order-statuszfutures/pending-orderzfutures/finished-orderzfutures/pending-stop-orderzfutures/finished-stop-orderzfutures/user-deals)zfutures/order-dealszfutures/pending-positionzfutures/finished-positionzfutures/position-margin-historyz futures/position-funding-historyzfutures/position-adl-historyzfutures/position-settle-historyzaccount/subs/frozenzaccount/subs/unfrozenzaccount/subs/edit-apizaccount/subs/delete-apizaccount/subs/transferzaccount/settingszassets/margin/borrowzassets/margin/repayzassets/renewal-deposit-addresszassets/cancel-withdrawzassets/transferzassets/amm/add-liquidityzassets/amm/remove-liquidityz
spot/orderzspot/stop-orderzspot/batch-orderzspot/batch-stop-orderzspot/modify-orderzspot/modify-stop-orderzspot/cancel-all-orderzspot/cancel-orderg^I@zspot/cancel-stop-orderzspot/cancel-batch-order
   zspot/cancel-batch-stop-orderzspot/cancel-order-by-client-idz#spot/cancel-stop-order-by-client-idzfutures/orderzfutures/stop-orderzfutures/batch-orderzfutures/batch-stop-orderzfutures/modify-order)zfutures/modify-stop-orderzfutures/cancel-all-orderzfutures/cancel-orderzfutures/cancel-stop-orderzfutures/cancel-batch-orderzfutures/cancel-batch-stop-orderz!futures/cancel-order-by-client-idz&futures/cancel-stop-order-by-client-idzfutures/close-positionzfutures/adjust-position-marginz futures/adjust-position-leveragezfutures/set-position-stop-lossz futures/set-position-take-profit)r   r   )v1r>   r   gMbP?)makertakerg        g-C6?)BCHBTCLTCETHZECDASH)tradingfundinglimitsamountminmaxoptionsx-167673045linearfillResponseFromRequestSPOTMARGINFUTURES)rF   rG   rH   )r   r   r   r   BEP20BSCTRC20ERC20BRC20SOLTONBSVAVAXCAVA_CAVAXXAVASUIACACHZCHILIZADAARBARBITRUMARBNOVAARBITRUM_NOVAOPOPTIMISMAPTAPTOSATOMFTMr   ASTRr   MATICCRONOSr   DOTETCETHWETHPOWFILZILDOGETIACELESTIASEIXRPXMR)r  r  )brokerId!createMarketBuyOrderRequiresPricedefaultTypedefaultSubTyperg   accountsByTypeaccountsByIdnetworksfeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergr        i )r*  limitdaysBack	untilDayssymbolRequired)r*  triggerr3  r>  )r*  r;  r?  r3  r>  )r*  r;  r<  daysBackCanceledr=  r?  r3  r>  r;  )	sandboxrW   rX   r~   r   r   fetchOrdersrc   r   )r*  r.  r/  r*  )extendsrW   r   rc   rC  forDerivatives)r   inverse)rF   rD  rH   rI   commonCurrenciesACMActiniumprecisionMode
exceptions23242534353621310715860060160260630083109312736003606361036123613361436153616361736183619362036213622362736283629363236333634363540014002400340044005400640074008400940104011401741154117)41234130415842134512)zip not allow visitzservice too busyz6Service is not available during funding fee settlement)exactbroad)deep_extendsuperr6   describer3   r&   r%   r1   r2   r0   r+   r-   r,   r$   r)   r'   r*   r/   )self	__class__s    S/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/coinex.pyr  coinex.describe    s   fd < > E
A
(E
A
HE
A
 tE
A
 $	E
A
 E
A
 4E
A
  !E
A
"  VVV $V 	V
 %V %V TV $UV 'V "4V tV V $UV  V 'V  /!V" ,U#V$ 0%V& t'V( )V* (+V, &t-V. "4/V0 (1V2 %d3V4 T5V6 7V8 &t9V: +E;V< )%=V> $T?V@ 'AVB (CVD "4EVF &tGVH (IVJ 1%KVL  MVN *4OVP +DQVR &tSVT 'UVV (WVX #DYVZ *4[V\ $T]V^ "5_V` *4aVb +EcVd  eVf !%gVh %diVj /kVl +JmVn oVp !%qVr  sVt duVv "4wVx dyVz !${V|  }V~ 'V@ !$AVB (CVD %eEVF )%GVH tIVJ KVL TMVN tOVP "4QVR #DSVT  UVV !$WVX "5YVZ #D[V\ ]V^ #E_V` &taVb tcVd  eVf "5gVh DiVj DkV#E
A
P QE
A
n ~67'I(J	 075NoE
A
H  *+4534459:-.+,+,-.12,-,-,--. & 12 8"  6r  1"	 
 3B  4R  +B  B2  8  *2  -b  :2  -a  ,Q  22   6r! " *2# $ /1-.,-23023523457834<>46CE= @!3R!7! *2! *2	!
 .r! 0! (! *6! +F! +F! /! 0! 0! 3B! 3A!  3B!!" 1"#!$ 3B%!* DF4624CE35  6835-3247=:<?ACE:<
#yG R $%$%+,34-.12,-,-67,- (  23+--..03523,-1213020246137979 "!4a!4a! .r! /	!
 3B! 4R! +B! 0! +B! /! 1"! 0! 4R! 0! 1"!  5b!!" 1"#!$ 57579;>@13-!%*)STn   +Q "A  #A  *1	 
 *1  )!  )!  )!  )!  -a  -a  ,Q  ,Q  ,Q  ,Q   3A! " ;A# $ 78;<56>?BC- 6* *A* 5r*  0*  /	* 
 <R*  8*  5b*  22*  5b*  4Q*  7*  3B*  1"*  ;B*  ;A*   5b!* " 5b#* $ .r%* & 6r'* ( 0)* * 6q+* , 1!-* . 22/* 0 6q1* 2 73* 4 .r5* 6 /7* 8 3A9* : 9!;* < 4Q=* > 5b?* @ 9!A* B :2C* D 1!E* F 458:9:?@@B<=?@S* V0!*B0!120! 4R0! /	0!
 4R0! 6r0! 4R0! /0! 3B0! 220! =b0! .r0! 5b0! .r0! 70!  :1!0!" )&#0!$ .v%0!& /'0!( 4Q)0!* 0+0!, 5f-0!. 4Q/0!0 010!2 5e30!4 6r50!6 ;B70!8 =a90!: B1;0!< ,R=0!> 1"?0!@ 21A0!B 7C0!D 3BE0!F :<89469;:<?AABFG68>@@B>@@B_0!Y] 7ymPIE
A
j ""
 "$$$% &!	kE
A
J  KE
A
V )59%"*-t( #&%# #&%!
&5&U& W& W	&
 W& 5& 5& 5& W& U& 5& 5& 8& 5& :&  !&" *#&$ 7%&& F'&( 5)&* 5+&, F-&. 5/&0 W1&2 h3&4 F5&6 57&8 59&: H;&< 5=&> 5?&@ FA&B :C&D 5E&F ! I&%9WE
A
J $&*(,,0,1).+06:#'#'"&#(	( #($)$)+/26/3#')$. q% '+!%$(%+*.& ',#($)*.	# '+!%#'$)*/( $(&*!%$(,0%)#'$)*/	*  #u=~  &&*)-+/$ %e( %e*#  "#3 "#3 	 ##kYKE
A
~ z!E
A
D YEE
A
F :*: -: -	:
 -: .: .: ,: ,: +: =: <: <: <: N:  -!:" L#:$ M%:& L':( M):* L+:, L-:. L/:0 L1:2 L3:4 L5:6 L7:8 L9:: L;:< L=:> L?:@ LA:B LC:D LE:F LG:H LI:J LK:L LM:N 0O:P NQ:R MS:T JU:V /W:X /Y:Z ,[:\ /]:^ M_:` Ma:b ,c:d Me:f ,g:h Ii:j .))-,s:x +;(<N]yAGE
A
 E
 E
	    c                   #    U R                  U5      I Sh  vN nU R                  US/ 5      n0 n[        S[        U5      5       GH   nX5   nU R	                  US0 5      nU R                  US/ 5      nU R                  US5      n	U	c  ME  U R                  U	5      n
U R                  US5      nU R                  US5      nU R	                  US0 5      nU R                  U R                  US	5      5      n0 n[        S[        U5      5       GH  nUU   nU R                  US
5      nU R                  UU
5      nUc  M2  U R                  U R                  US	5      5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nUUSU=(       a    UUUU R                  U5      U R                  U5      SSS.U R                  U5      SS.U R                  U5      SS.S.US.
nUUU'   GM     U R                  U	U
SU=(       a    UUUSU R                  U5      SSS.SSS.SSS.S.USUS.5      XJ'   GM#     U$  GNV7f)a  
fetches all available currencies on an exchange

https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-all-deposit-withdrawal-config

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
Ndatar   assetchainsccydeposit_enabledwithdraw_enabledwithdrawal_precisionchainwithdrawal_feemin_deposit_amountmin_withdraw_amountr   )r   depositr   )
r:   networkr;   activer  r   fee	precisionr   infocrypto)r:   coder;   r  r  r   r  r  r   r$  typer  ))v2PublicGetAssetsAllDepositWithdrawConfig	safe_listrangelen	safe_dictsafe_stringsafe_currency_code	safe_boolparse_precisionnetwork_id_to_codeparse_numbersafe_currency_structure)r  paramsresponser  resulticoinr  r  
currencyIdr  
canDepositcanWithdraw
firstChainfirstPrecisionStringr$  jr  	networkIdnetworkCodeprecisionString	feeStringminNetworkDepositStringminNetworkWithdrawStringcanDepositChaincanWithdrawChainr  s                              r  fetch_currenciescoinex.fetch_currencies  s     GGOOH ~~h3q#d)$A7DNN4"5E^^D(B7F))%7J!**:6D/@AJ..0BCK26J#'#7#78H8HUk8l#m H1c&k*q	 ,,UG<	"55iF$"&"6"6t7G7GOe7f"g ,,U4DE	*.*:*:5BV*W'+/+;+;ECX+Y("&..8I"J#'>>%9K#L #* -B2B. 0,,Y7!%!2!2?!C $(#'#
 $(#4#45L#M#'$
 $(#4#45M#N#'% "/!2 )0%K +L  77 $4%'!../CD  $#
  $# 
  $#! % 39 FLg %\ i Ps   I0I-II0c                    #    U R                  U5      U R                  U5      /n[        R                  " U6 I Sh  vN nUS   nUS   nU R	                  XE5      $  N7f)a2  
retrieves data on all markets for coinex

https://docs.coinex.com/api/v2/spot/market/http/list-market
https://docs.coinex.com/api/v2/futures/market/http/list-market

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
Nr   r   )fetch_spot_marketsfetch_contract_marketsasynciogatherarray_concat)r  r  promisesUnresolvedpromisesspotMarketsswapMarketss         r  fetch_marketscoinex.fetch_markets'  sg      ##F+''/
 !);<<qkqk  :: =s   9AA Ac                   #    U R                  U5      I S h  vN nU R                  US/ 5      n/ n[        S[        U5      5       GH{  nX5   nU R	                  US5      nU R	                  US5      nU R	                  US5      n	U R                  U5      n
U R                  U	5      nU
S-   U-   nUR                  0 SU_SU_S	U
_S
U_SS _SU_SU	_SS _SS_SS_SU R                  US5      _SS_SS_SS_SU R                  US5      _SS_SS _S U R                  US5      U R                  US5      S S S S S U R                  U R                  U R	                  US5      5      5      U R                  U R                  U R	                  US5      5      5      S .S S S!.U R                  US"5      S S!.S S S!.S S S!.S#.S US$.E5        GM~     U$  GN7f)%Nr  r   marketbase_ccy	quote_ccy/r:   symbolbasequotesettlebaseIdquoteIdsettleIdr  rF   TrG   is_margin_availablerH   FrI   rJ   r  is_api_trading_availablecontractr   taker_fee_ratemaker_fee_ratebase_ccy_precisionquote_ccy_precisionr   pricer   
min_amountr4  r   r  costrE  r   r   contractSizeexpiryexpiryDatetimestrike
optionTyper  r   createdr  )v2PublicGetSpotMarketr  r  r  r  r  appendr  safe_numberr  r  )r  r  r  marketsr  r  r  r:   r  r  r  r  r  s                r  r  coinex.fetch_spot_markets:  s    33F;;. ..626q#g,'AZF!!&(3B%%fj9F&&v{;G**62D++G4ECZ%'FMM 2b2&2 2 	2
 $2 &2 72 D2 2 2 $..1FG2 2 %2 %2 $..1KL2  E!2" $#2$  ))&2BC))&2BC $"&""//0D0DTEUEUV\^rEs0tu!..t/C/CDDTDTU[]rDs/tu  $#!
  $//E#
  $#
  $#$  c2 2 (v i <s   GGF1Gc                 d  #    U R                  U5      I S h  vN nU R                  US/ 5      n/ n[        S[        U5      5       GH  nX5   nU R                  nU R                  US/ 5      nU R                  US5      n	U	S:H  n
U	S:H  nU R                  US5      nU R                  US5      nU R                  US	5      nU R                  U5      nU R                  U5      nU	S:X  a  S
OUnU R                  U5      nUS-   U-   S-   U-   n[        U5      nUR                  0 SU_SU_SU_SU_SU_SU_SU_SU_SS_SS_SS_SS_SS_SS_SS _SS_SU
_UUS   S    US   S!   U R                  S"5      S S S S U R                  U R                  U R                  US#5      5      5      U R                  U R                  U R                  US$5      5      5      S%.U R                  US5      U R                  UUS&-
  5      S'.U R                  US(5      S S'.S S S'.S S S'.S).S US*.E5        GM     U$  GN7f)+Nr  r   r4  contract_typer   rE  r  r  r  USDTr  :r:   r  r  r  r  r  r  r  r  rH   rF   FrG   TrI   rJ   r  r  r   r   r   1r  r  r  r   r   r  r  r  )v2PublicGetFuturesMarketr  r  r  r   r  r  r  r  r  r  )r  r  r  r  r  r  entryr   	leveragessubTyper   rE  r:   r  r  r  r  r  r  r  leveragesLengths                        r  r  coinex.fetch_contract_markets  s	    66v>>, ..626q#g,'AJE99Duj"=I&&uo>G)F)+G!!%2B%%eZ8F&&uk:G**62D++G4E")X"5vFH,,X6FCZ%'#-6F!)nOMM 2b2&2 2 	2
 &2 &2 72 H2 2 2 %2 2 %2 %2 $2  D!2" &#2$ #i1i1 $ 1 1# 6"&""//0D0DTEUEUV[]qEr0st!..t/C/CDDTDTUZ\qDr/st  $//	1=#//	?Q;NO!
  $//|D#
  $#
  $#$  c2 2! (F w ?s   H0H-HH0Ntickerr  c           
      :   SU;   a  SOSnU R                  US5      nU R                  XBS U5      nU R                  0 SU_SS _SS _SU R                  US5      _S	U R                  US	5      _S
S _SU R                  US5      _SS _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S _SS _SS _SS _U R                  US5      S U R                  US5      U R                  US5      US.EU5      $ )N
mark_pricerH   rF   r  r  	timestampdatetimehighlowbid	bidVolume
volume_buyask	askVolumevolume_sellvwapopencloselastpreviousClosechange
percentageaveragevolumeindex_price)
baseVolumequoteVolume	markPrice
indexPricer  )r  safe_symbolsafe_ticker)r  r  r  
marketTypemarketIdr  s         r  parse_tickercoinex.parse_ticker  s   H !- 6VV
##FH5!!(D*E !
f!
!
 !
 D$$VV4	!

 4##FE2!
 4!
 ))&,?!
 4!
 ))&-@!
 D!
 D$$VV4!
 T%%fg6!
 D$$VV4!
 T!
 d!
  $!!
" t#!
$ **68<))&,?**6=A-!
. / 	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O(U R	                  U R                  XB5      5      I Sh  vN nU R                  US/ 5      nU R                  US0 5      nU R                  Xs5      $  N Nf N?7f)a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
https://docs.coinex.com/api/v2/futures/market/http/list-market-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  r:   rH   r  r   )load_marketsr  v2PublicGetFuturesTickerextendv2PublicGetSpotTickerr  r  r  r  r  r  r  requestr  r  r  s           r  fetch_tickercoinex.fetch_ticker/  s      !!!V$fTl
 &>!::4;;w;WXXH!77G8TUUH` ~~h3a,  00w 	" YU4   CCAC"C	#(CC<C	CCsymbolsc                   #    U R                  5       I Sh  vN   U R                  U5      nSnUb#  U R                  US5      nU R                  U5      nU R	                  SX25      u  pVSnU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/ 5      nU R                  X5      $  N ND N,7f)a4  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker

:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr   r   rH   r  )	r   market_symbols
safe_valuer  handle_market_type_and_paramsr!  r#  r  parse_tickers)	r  r)  r  r  r  r  queryr  r  s	            r  fetch_tickerscoinex.fetch_tickersw  s      !!!%%g.__Wa0F[[(F >>~v^
!::5AAH!77>>H` ~~h3!!$00y 	" B>s4   CCA-CC	CC)C	CCc                    #    U R                  U5      I Sh  vN nU R                  US0 5      nU R                  US5      $  N)7f)a$  
fetches the current integer timestamp in milliseconds from the exchange server

https://docs.coinex.com/api/v2/common/http/time

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int: the current integer timestamp in milliseconds from the exchange server
Nr  r  )v2PublicGetTimer  safe_integer)r  r  r  r  s       r  
fetch_timecoinex.fetch_time  sF      --f55 ~~h3  {33 6s   AA*Ar   r;  c                   #    U R                  5       I Sh  vN   U R                  U5      nUc  SnUS   USS.nSnUS   (       a)  U R                  U R                  XS5      5      I Sh  vN nO(U R	                  U R                  XS5      5      I Sh  vN nU R                  US0 5      nU R                  US0 5      nU R                  US	5      n	U R                  XU	5      $  N Ny NR7f)
aL  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://docs.coinex.com/api/v2/spot/market/http/list-market-depth
https://docs.coinex.com/api/v2/futures/market/http/list-market-depth

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nr   r:   0)r  r;  intervalrH   r  depth
updated_at)r   r  v2PublicGetFuturesDepthr"  v2PublicGetSpotDepthr  r4  parse_order_book)
r  r  r;  r  r  r%  r  r  r:  r  s
             r  fetch_order_bookcoinex.fetch_order_book  s      !!!V$=ETl

 &>!99$++g:VWWH6 "66t{{77STTH4 ~~h3tWb1%%e\:	$$UI>>G 	" X6 Us5   C'C!AC')C#*(C'C%AC'#C'%C'tradec                 z   U R                  US5      nU R                  U R                  S5      nUb  US   nU R                  US5      nU R                  XRS U5      nU R                  US5      nS nUb(  U R                  US5      nU R	                  U5      n	UU	S.nU R                  UUU R                  U5      US   U R                  US	5      U R                  US
5      S U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      US.U5      $ )N
created_atr   r  r  r  fee_ccyr  currencyr  deal_idorder_idsideroler  r   
deal_money)r  r  r  r  r:   orderr  rI  takerOrMakerr  r   r  r  )r4  r  r   safe_marketr  
safe_tradeiso8601)
r  rA  r  r  r   r  feeCostStringr  feeCurrencyIdfeeCurrencyCodes
             r  parse_tradecoinex.parse_trade'  s[   P %%e\:	&&t||]C .K##E84!!(D+F((6$ ,,UI>M"55mDO%+C "Y/X&""5)4%%eZ8$$UF3 ,,UF;%%eW5&&uh7$$UL9 
  	r  sincec                 j  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X6S'   SnUS   (       a)  U R                  U R                  Xd5      5      I Sh  vN nO(U R	                  U R                  Xd5      5      I Sh  vN nU R                  US   XRU5      $  N NE N7f)a2  
get the list of the most recent trades for a particular symbol

https://docs.coinex.com/api/v2/spot/market/http/list-market-deals
https://docs.coinex.com/api/v2/futures/market/http/list-market-deals

:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch
:param int [limit]: the maximum amount of trades to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
Nr  r:   r;  rH   r  )r   r  v2PublicGetFuturesDealsr"  v2PublicGetSpotDealsparse_trades)r  r  rV  r;  r  r  r%  r  s           r  fetch_tradescoinex.fetch_tradesn  s      !!!V$fTl
 $G&>!99$++g:VWWH!66t{{77STTH$   &!16%HH= 	" XTs4   B3B-AB3)B/*(B3B1B3/B31B3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O(U R	                  U R                  XB5      5      I Sh  vN nU R                  US/ 5      nU R                  US0 5      nU R                  Xs5      $  N Nf N?7f)ae  
fetch the trading fees for a market

https://docs.coinex.com/api/v2/spot/market/http/list-market
https://docs.coinex.com/api/v2/futures/market/http/list-market

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
Nr  r:   rF   r  r   )r   r  r  r"  r  r  r  parse_trading_feer$  s           r  fetch_trading_feecoinex.fetch_trading_fee  s      !!!V$fTl
 &>!77G8TUUH, "::4;;w;WXXH, ~~h3a,%%f55k 	" V, Yr(  c                   #    U R                  5       I Sh  vN   SnU R                  SSU5      u  p!SnU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/ 5      n0 n[        S[        U5      5       HE  nXF   nU R                  US5      nU R                  USSU5      n	U	S   n
U R                  Xy5      XZ'   MG     U$  N N N}7f)am  
fetch the trading fees for multiple markets

https://docs.coinex.com/api/v2/spot/market/http/list-market
https://docs.coinex.com/api/v2/futures/market/http/list-market

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
Nr   rH   r  r   r  r  )
r   r-  r  r  r  r  r  r  rN  r^  )r  r  r  r  r  r  r  r  r  r  r  s              r  fetch_trading_feescoinex.fetch_trading_fees  s      !!!99:LdTZ[6>!::6BBH. "77??H* ~~h3q#d)$AGE''x8H%%hdDAFH%F!33EBFN % s 	"
 C. @s4   C(C"7C(C$C((C&)A:C($C(&C(r  c                     U R                  US5      nU R                  X25      nUUU R                  US5      U R                  US5      SSS.$ )Nr  r  r  T)r  r  r   r   r  	tierBased)r,  r  r  )r  r  r  r  r  s        r  r^  coinex.parse_trading_fee"  sZ    ??31!!(3%%c+;<%%c+;<
 	
r  c           	          U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )NrC  r  r  r  r  value)r4  r  )r  ohlcvr  s      r  parse_ohlcvcoinex.parse_ohlcv.  sn     e\2UF+UF+UE*UG,UG,
 	
r  r   	timeframec                   #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  U R                  X"5      S.nUb  XGS'   SnUS   (       a)  U R	                  U R                  Xu5      5      I Sh  vN nO(U R                  U R                  Xu5      5      I Sh  vN nU R                  US/ 5      n	U R                  XX#U5      $  N NU N.7f)a  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://docs.coinex.com/api/v2/spot/market/http/list-market-kline
https://docs.coinex.com/api/v2/futures/market/http/list-market-kline

:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param int [since]: timestamp in ms of the earliest candle to fetch
:param int [limit]: the maximum amount of candles to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nr:   )r  periodr;  rH   r  )	r   r  r  r   v2PublicGetFuturesKliner"  v2PublicGetSpotKliner  parse_ohlcvs)
r  r  rl  rV  r;  r  r  r%  r  r  s
             r  fetch_ohlcvcoinex.fetch_ohlcvD  s      !!!V$Tl&&t	M
 $G&>!99$++g:VWWH!66t{{77STTH* ~~h3  yGGE 	" XTs4   CCA-CC(C-C.+CCCc                   #    U R                  5       I S h  vN   U R                  U5      I S h  vN nSU0nU R                  US/ 5      n[        S[	        U5      5       H  nXE   nU R                  US0 5      nU R                  US0 5      nU R                  US0 5      n	U R                  US0 5      n
U R                  5       nU R                  US5      nU R                  U5      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[        R                  " X5      US'   XU'   M     U R                  U5      $  GNP GN:7f)Nr  r  r   	availablefrozenrepaidinterestr  freeuseddebt)r   v2PrivateGetAssetsMarginBalancer  r  r  r  accountr  r  r4   
string_addsafe_balance)r  r  r  r  balancesr  r  ry  rz  loanrx  baseAccountbaseCurrencyIdbaseCurrencyCodebaseDebtbaseInterests                   r  fetch_margin_balancecoinex.fetch_margin_balancev  sg    !!!==fEE@ )>>(FB7q#h-(AKE>>%b9D>>%26D>>%26D~~eZ<H,,.K!--eZ@N#66~F"&"2"24"DK"&"2"24"DK''j9H++HjAL")"4"4X"LK'2#$ )   ((e 	"Es    E,E&E,E)D7E,)E,c                   #    U R                  5       I S h  vN   U R                  U5      I S h  vN nSU0nU R                  US/ 5      n[        S[	        U5      5       Hh  nXE   nU R                  US5      nU R                  U5      nU R                  5       n	U R                  US5      U	S'   U R                  US5      U	S'   XU'   Mj     U R                  U5      $  N N7f	Nr  r  r   r  ru  ry  rv  rz  )	r   v2PrivateGetAssetsSpotBalancer  r  r  r  r  r}  r  
r  r  r  r  r  r  r  r  r  r}  s
             r  fetch_spot_balancecoinex.fetch_spot_balance  s     !!!;;FCC )>>(FB7q#h-(AKE))%7J**:6DllnG"..ukBGFO"..uh?GFO"4L )   ((3 	"C    C!CC!CB.C!C!c                   #    U R                  5       I S h  vN   U R                  U5      I S h  vN nSU0nU R                  US/ 5      n[        S[	        U5      5       Hh  nXE   nU R                  US5      nU R                  U5      nU R                  5       n	U R                  US5      U	S'   U R                  US5      U	S'   XU'   Mj     U R                  U5      $  N N7fr  )	r    v2PrivateGetAssetsFuturesBalancer  r  r  r  r  r}  r  r  s
             r  fetch_swap_balancecoinex.fetch_swap_balance  s     !!!>>vFF" )>>(FB7q#h-(AKE))%7J**:6DllnG"..ukBGFO"..uh?GFO"4L )   ((9 	"Fr  c                   #    U R                  5       I S h  vN   U R                  U5      I S h  vN nSU0nU R                  US/ 5      n[        S[	        U5      5       Hh  nXE   nU R                  US5      nU R                  U5      nU R                  5       n	U R                  US5      U	S'   U R                  US5      U	S'   XU'   Mj     U R                  U5      $  N N7fr  )	r   "v2PrivateGetAssetsFinancialBalancer  r  r  r  r  r}  r  r  s
             r  fetch_financial_balancecoinex.fetch_financial_balance  s     !!!@@HH )>>(FB7q#h-(AKE))%7J**:6DllnG"..ukBGFO"..uh?GFO"4L )   ((3 	"Hr  c                   #    SnU R                  SSU5      u  p!SnU R                  SU5      u  p1USL=(       d    US:H  nUS:X  a  U R                  U5      I Sh  vN $ US:X  a  U R                  U5      I Sh  vN $ U(       a  U R	                  U5      I Sh  vN $ U R                  U5      I Sh  vN $  N\ N? N! N
7f)a  
query for balance and get the amount of funds available for trading or funds locked in orders

https://docs.coinex.com/api/v2/assets/balance/http/get-spot-balance         # spot
https://docs.coinex.com/api/v2/assets/balance/http/get-futures-balance      # swap
https://docs.coinex.com/api/v2/assets/balance/http/get-marigin-balance      # margin
https://docs.coinex.com/api/v2/assets/balance/http/get-financial-balance    # financial

:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: 'margin', 'swap', 'financial', or 'spot'
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
Nr_   rG   rH   	financial)r-  handle_margin_mode_and_paramsr  r  r  r  )r  r  r  r*  isMargins        r  fetch_balancecoinex.fetch_balance  s      
!??PTV\]

!??PVW
d*G
h0F00888;&55f===226:::00888 9=:8sH   AB?B7B?9B9:B?B;B?2B=3B?9B?;B?=B?statusc                 8    SSSSSSS.nU R                  X!U5      $ )Nrejectedr  closedcanceled)r  r  not_deal	part_dealdonecancelr  r  r  statusess      r  parse_order_statuscoinex.parse_order_status  s0    " 
 &99r  rL  c                    U R                  US5      nU R                  US5      nU R                  US5      nUS:X  a  UnU R                  US5      nU R                  U R                  S5      nU R                  USU5      nUS:X  a  S	nUS	:X  a  S	OS
n	U R	                  XbS U	5      nU R                  US5      n
U R                  U
5      nUc  U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S:X  a  S nU R                  0 SU R                  U/ SQ5      _SU_SU R                  U5      _SU_SU_SU R                  U5      _SUS   _SU R                  US5      _SS _SS _SS _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      _U R                  US(5      U R                  US)5      U R                  US*5      U R                  US+5      S UU R                  US,S-5      S..US/.EU5      $ )0Nr  rC  r;  r   r  r   market_typefuturesrH   rF   rD  r  rI  longbuyshortsell	client_id r:   )position_idrH  stop_idclientOrderIdr  r  lastTradeTimestampr  r  r1  postOnly
reduceOnlyr  r+  trigger_pricer/  take_profit_pricer.  stop_loss_pricer  filled_valueavg_entry_pricer   filled_amountunfilled_amount	quote_feer  )rF  r  )r  r   filled	remainingtradesr  r  )r  r4  r   safe_string_lowerrN  r  
safe_ordersafe_string_nrP  r  r  safe_string_2)r  rL  r  	rawStatusr  updatedTimestampr  r   	orderTyper  rR  feeCurrencyrI  r  s                 r  parse_ordercoinex.parse_order(  s   ` $$UH5	%%e\:	,,ULAq (##E84&&t||]C**5-M		!I )V 3V&
!!(D*E((	:--m< /Kv.6>DW_D((<B M  
$$$U,RS 
] 
 Y/ 
 	 

 !"2 
 d--i8 
 fX& 
 D$$UF3 
 4 
  
 $ 
 D 
 T%%eW5 
 D,,UOD 
 t//7JK 
  T--e5FG! 
" D$$UN;# 
$ ''/@A&&uh7&&uo>))%1BC'**5+uE 7 
8 9 	r  r  c                    #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSUS'   U R	                  USSUSU5      I Sh  vN $  NZ N7f)a  
create a market buy order by providing the symbol and cost

https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order
https://docs.coinex.com/api/v2/spot/order/http/put-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>`
NrF   z9 createMarketBuyOrderWithCost() supports spot orders onlyFr  r  r  )r   r  r.   r:   create_order)r  r  r  r  r  s        r  !create_market_buy_order_with_cost(coinex.create_market_buy_order_with_cost.  sw      !!!V$f~tww)ddee6;23&&vxdFSSS 	"
 Ts"   A5A1AA5,A3-A53A5r  rI  r   r  c                 <   U R                  U5      nUS   nU R                  USS5      n	U R                  USS5      n
U R                  US5      nU R                  US5      nU R                  US5      nUS	:H  nU R                  XS
:H  U5      nU R	                  US5      nU R                  US5      nU(       a+  US   (       d!  [        U R                  S-   US   -   S-   5      eS	US   0nU	c9  SnU R                  U R                  SU5      nUS-   U R                  5       -   US'   OU	US'   UcO  UcL  U(       d  UUS'   UnU(       a  S
nOUb  US:X  a  SnOUS:X  a  SnU(       d  U R                  X5      US'   UUS'   U(       a  SUS'   U(       d  U(       af  U(       a,  U R                  X5      US'   U R                  USS5      US'   GOU(       a*  U R                  X5      US '   U R                  USS5      US!'   GO{U R                  X5      US"'   U
b*  U R                  X5      US#'   U R                  USS5      US$'   GO8S nU R                  S%U5      u  nnUb  S&US'   OS'US'   US	:X  a  US(:X  a  S)nU R                  US%S*S)5      u  nnU R                  US+5      nU R                  US+5      nU(       a  Uc  Uc  [        U R                  S,-   5      eU R!                  U5      nU R!                  U5      nU R#                  [$        R&                  " UU5      5      nUb  UOUnU R)                  UU5      US"'   O)U R)                  X5      US"'   OU R                  X5      US"'   U
b  U R                  X5      US#'   U R                  U/ S-Q5      nU R+                  UU5      $ ).NrH   r  r  	stopPricer+  r.  r/  rJ   r  
maker_onlyr1  r  z/ createOrder() does not support reduceOnly for r  z> orders, reduceOnly orders are supported for swap markets onlyr:   r   r  -rI  r&  iocr'  fokr  r   r  r  	stop_typelatest_pricestop_loss_typer  take_profit_typer   r  trigger_price_typerW   r   r   r  Tr  r  z createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argument)r  r1  r  r  r+  r.  r/  )r  r  r  is_post_onlysafe_string_upperr  r,   r:   r   uuid16price_to_precisionamount_to_precisionr  handle_option_and_paramsr  omitnumber_to_stringparse_to_numericr4   
string_mulcost_to_precisionr"  )r  r  r  rI  r   r  r  r  rH   r  r+  r.  r/  rJ   isMarketOrderr  timeInForceRawr  r%  	defaultIdr  requestTyper*  r  r  amountStringpriceStringquoteAmountcostRequests                                r  create_order_requestcoinex.create_order_requestA  s   V$f~**6;P))&+~N((A**63DE!!&(3($$]l4JFS//F^^FL9
&>"477-^#^aghnao#o  ss  $s  t  tfTl
  %I''j)LH#+c>DKKM#AGK #0GK !(?"&K*+!U*"'K#u,"'K #'#:#:6#I )GFO%.GM" 151H1H1_G-.040@0@Vd0eG,-$373J3J63cG/0262B2B6;Xf2gG./$($<$<V$L!+/3/F/Fv/\GO,484D4DV[Zh4iG01J!%!C!CMSY!ZJ%)1&)/& tu}481<@<Y<YZ`bo  rU  W[  =\916''76624DL*477  6q  ,q  r  r'+'<'<V'D&*&;&;E&B&*&;&;G<N<N|]h<i&j/3/?dk,0,B,B6;,W)(,(>(>v(NGH%$($<$<V$L!'+/+B+B6+X(6  $N  O{{7F++r  c                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  US5      nU R                  USS5      n	U R	                  US5      n
U R	                  US5      nU	SLnU
SLnUSLnU=(       d    UnU R                  XX4XV5      nSnUS   (       a;  U(       a  U R                  U5      I Sh  vN nOU R                  U5      I Sh  vN nOU(       a  U R                  U5      I Sh  vN nOU(       aB  U(       a  U R                  U5      I Sh  vN nO[U(       a  U R                  U5      I Sh  vN nO: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U5      $  GN N N N N No NP N87f)	a  
create a trade order

https://docs.coinex.com/api/v2/spot/order/http/put-order
https://docs.coinex.com/api/v2/spot/order/http/put-stop-order
https://docs.coinex.com/api/v2/futures/order/http/put-order
https://docs.coinex.com/api/v2/futures/order/http/put-stop-order
https://docs.coinex.com/api/v2/futures/position/http/close-position
https://docs.coinex.com/api/v2/futures/position/http/set-position-stop-loss
https://docs.coinex.com/api/v2/futures/position/http/set-position-take-profit

: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
: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 float [params.triggerPrice]: price to trigger stop orders
:param float [params.stopLossPrice]: price to trigger stop loss orders
:param float [params.takeProfitPrice]: price to trigger take profit orders
:param str [params.timeInForce]: 'GTC', 'IOC', 'FOK', 'PO'
:param boolean [params.postOnly]: set to True if you wish to make a post only order
:param boolean [params.reduceOnly]: *contract only* indicates if self order is to reduce the size of a position
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r  r+  r.  r/  rF   r  )r   r  r  r  r  r  v2PrivatePostSpotStopOrderv2PrivatePostSpotOrderv2PrivatePostFuturesStopOrder'v2PrivatePostFuturesSetPositionStopLoss)v2PrivatePostFuturesSetPositionTakeProfit!v2PrivatePostFuturesClosePositionv2PrivatePostFuturesOrderr  r  )r  r  r  rI  r   r  r  r  r  r+  stopLossTriggerPricetakeProfitTriggerPriceisTriggerOrderisStopLossTriggerOrderisTakeProfitTriggerOrderisStopLossOrTakeProfitTriggerr%  r  r  s                      r  r  coinex.create_order  s    4 !!!V$^^FL9
))&+~N#//H!%!1!1&:K!L%T1!5T!A#9#E (>(ZBZ%++F$V&>!%!@!@!II "&!<!<W!EE> !%!C!CG!LL /)%)%Q%QRY%ZZHN .%)%S%ST[%\\HP %)%K%KG%TTH< &*%C%CG%LLH: ~~h3f--e 	" J F@ M  [P  ]R  U<  Ms   G F/B/G F2G  F4! G F6'G )F8* G 
F: G +F<,G F>*G 2G 4G 6G 8G :G <G >G ordersc           	      N  #    U R                  5       I Sh  vN   / nSnSnSnSn[        S[        U5      5       GH@  nX   n	U R                  U	S5      n
Uc  U
nOXJ:w  a  [	        U R
                  S-   5      e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S:w  a  [        U R
                  S-   U-   S-   5      eU R                  US5      nU R                  USS5      nU R                  US5      nU R                  US5      nUSLnUSLnUSLnU=(       d    UnU R                  XXX5      nUR                  U5        GMC     U R                  U5      nUS   US.nSnUS   (       a;  U(       a  U R                  U5      I Sh  vN nOU R                  U5      I Sh  vN nOxU(       a  U R                  U5      I Sh  vN nOWU(       a  [        U R
                  S-   5      eU(       a  [        U R
                  S-   5      eU R!                  U5      I Sh  vN nU R#                  US/ 5      n/ n[        S[        U5      5       H  nUU   nSnU R%                  US5      nUb  US:w  a  SnOSnU R'                  US0 5      nSnUS   (       a  U(       d  UUS'   U R)                  UU5      nOUUS'   U R)                  UU5      nUR                  U5        M     U$  GN GN[ GND GN& N7f)a  
create a list of trade orders(all orders should be of the same symbol)

https://docs.coinex.com/api/v2/spot/order/http/put-multi-order
https://docs.coinex.com/api/v2/spot/order/http/put-multi-stop-order
https://docs.coinex.com/api/v2/futures/order/http/put-multi-order
https://docs.coinex.com/api/v2/futures/order/http/put-multi-stop-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
:param dict [params]: extra parameters specific to the api endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NFr   r  z; createOrders() requires all orders to have the same symbolr  rI  r   r  r  r;  z! createOrders() does not support z' orders, only limit orders are acceptedr  r  r+  r.  r/  r:   )r  r  rF   zH createOrders() does not support stopLossPrice or takeProfitPrice ordersz2 createOrders() does not support reduceOnly ordersr  r  r  r  r  )r   r  r  r  r)   r:   r,  r.   safe_number_2r  r  r  r  v2PrivatePostSpotBatchStopOrderv2PrivatePostSpotBatchOrder"v2PrivatePostFuturesBatchStopOrderv2PrivatePostFuturesBatchOrderr  r4  r  r  ) r  r  r  ordersRequestsr  r  r  r  r  rawOrderr  r  rI  r   r  orderParamsr+  r  r  r  r   orderRequestr  r%  r  r  resultsr  r  r  	innerDatarL  s                                    r  create_orderscoinex.create_orders	  sS     !!!
(-%q#f+&AyH''(;H~!%$TWW/l%lmm##Hf5D##Hf5D__Xx8FOOHg6E//(HbAKw"477-P#PSW#W  [D  $D  E  ElCJ--k;WL#'#3#3K#Q %)%5%5kCT%U")5N%9%E"'=T'I$,B,^F^)44XTSXfL!!,/1 '2 V$Tl$
 &>!%!E!Eg!NN" "&!A!A'!JJL !%!H!H!QQ  /"477-w#wxx&tww1e'eff%)%H%H%QQHF ~~h3q#d)$AGEF$$UF3D19'F#Fufb9IEf~n"(h((7&,	(#((F;NN5!# %$ Y 	"N O" KN R,  RsZ   L%LF(L%?L L%L L%:L ;AL%L#CL%L%L% L%#L%idsc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nU R	                  USS5      nU R                  USS/5      nSn/ n[        S[        U5      5       H  n	UR                  [        X   5      5        M!     U(       a  XS'   OXS	'   US
   (       aY  U(       a)  U R                  U R                  XS5      5      I Sh  vN nOU R                  U R                  XS5      5      I Sh  vN nO]SUS'   U(       a)  U R                  U R                  XS5      5      I Sh  vN nO(U R                  U R                  XS5      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0 5      nU R#                  X5      nUR                  U5        M>     U$  GN N N N Ny7f)ae  
cancel multiple orders

https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-order
https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-stop-order
https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-order
https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-stop-order

:param str[] ids: order ids
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: set to True for canceling stop orders
:returns dict: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nz* cancelOrders() requires a symbol argumentr  r:   stopr?  r   stop_ids	order_idsrF   r   r  r  )r(   r:   r   r  safe_bool_2r  r  r  r  int%v2PrivatePostSpotCancelBatchStopOrderr"  !v2PrivatePostSpotCancelBatchOrder(v2PrivatePostFuturesCancelBatchStopOrder$v2PrivatePostFuturesCancelBatchOrderr  r  r  )r  r  r  r  r  r%  r?  r  
requestIdsr  r  r  r  itemrL  s                  r  cancel_orderscoinex.cancel_orders<
  s     >#DGG.Z$Z[[!!!V$fTl
 ""669=6FI#67
q#c(#Ac#&k* $",J#-K &>!%!K!KDKKX_Lh!ii< "&!G!GT[Hd!eeJ &/GM"!%!N!Nt{{[bOk!ll: "&!J!J4;;W^Kg!hhF ~~h3q#d)$AGE>>%4D$$T2ENN5!	 %
 { 	"" j< fN m: isY   /G8G-CG85G06(G8G24G8G4(G8<G6=A1G80G82G84G86G8r:   c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0n	Ub  U R	                  X%5      U	S'   Ub  U R                  X&5      U	S'   Sn
U R                  U/ SQ5      nU R                  USS	/5      nUSLnU(       a)  U R                  X+5      U	S
'   U R                  U5      U	S'   OU R                  U5      U	S'   SnU R                  SU5      u  pUS   (       ag  Ub  SU	S'   OSU	S'   U(       a)  U R                  U R                  X5      5      I Sh  vN n
OU R                  U R                  X5      5      I Sh  vN n
O]SU	S'   U(       a)  U R                  U R                  X5      5      I Sh  vN n
O(U R                  U R                  X5      5      I Sh  vN n
U R                  U
S0 5      nU R!                  X5      $  GN N N NX N17f)at  
edit a trade order

https://docs.coinex.com/api/v2/spot/order/http/edit-order
https://docs.coinex.com/api/v2/spot/order/http/edit-stop-order
https://docs.coinex.com/api/v2/futures/order/http/edit-order
https://docs.coinex.com/api/v2/futures/order/http/edit-stop-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 the currency you want to trade in units of the 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 float [params.triggerPrice]: the price to trigger stop orders
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nz' editOrder() requires a symbol argumentr  r:   r   r  )r  r+  r  r  r+  r  r  rH  r^   rF   r   r  r   r   r  )r(   r:   r   r  r  r  r  r  r  r   v2PrivatePostSpotModifyStopOrderr"  v2PrivatePostSpotModifyOrder#v2PrivatePostFuturesModifyStopOrderv2PrivatePostFuturesModifyOrderr  r  )r  r:   r  r  rI  r   r  r  r  r%  r  r+  r  r*  r  s                  r  
edit_ordercoinex.edit_order
  s    & >#DGG.W$WXX!!!V$fTl
  $ 8 8 HGH#66vEGG))&2`a6K#@A%T1'+'>'>v'TGO$!%!6!6r!:GI"&"7"7";GJ
!??VT
&>%)1&)/&!%!F!Ft{{SZGc!dd "&!B!B4;;wC_!``@ &/GM"!%!I!I$++V]Jf!gg "&!E!EdkkRYFb!cc: ~~h3--a 	"4 e aD h dsX   /HG6DHG9(H/G;04H$G=%(HG?)H9H;H=H?Hc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nU R	                  USS5      nUS   nSUS   0nSnU R                  SU5      u  pU(       a  S	US
'   OUb  SUS
'   OSUS
'   U R                  USS5      n	U R                  U/ SQ5      nSn
U	b  XS'   U(       a[  U(       a*  U R                  U R                  Xs5      5      I Sh  vN n
GOdU R                  U R                  Xs5      5      I Sh  vN n
GO:U(       a*  U R                  U R                  Xs5      5      I Sh  vN n
GO	U R                  U R                  Xs5      5      I Sh  vN n
OU(       am  U R                  U5      US'   U(       a)  U R                  U R                  Xs5      5      I Sh  vN n
OU R                  U R                  Xs5      5      I Sh  vN n
OlU R                  U5      US'   U(       a)  U R!                  U R                  Xs5      5      I Sh  vN n
O(U R#                  U R                  Xs5      5      I Sh  vN n
SnU	b*  U R%                  U
S/ 5      nU R'                  US   S0 5      nOU R'                  U
S0 5      nU R)                  X5      $  GN GN GN GNl GNE N N N Nl7f)a  
cancels an open order

https://docs.coinex.com/api/v2/spot/order/http/cancel-order
https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order
https://docs.coinex.com/api/v2/spot/order/http/cancel-order-by-client-id
https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order-by-client-id
https://docs.coinex.com/api/v2/futures/order/http/cancel-order
https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order
https://docs.coinex.com/api/v2/futures/order/http/cancel-order-by-client-id
https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order-by-client-id

: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]: client order id, defaults to id if not passed
:param boolean [params.trigger]: set to True for canceling a trigger order
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nz) cancelOrder() requires a symbol argumentr  r?  rH   r  r:   rO   r   r  r   r   r  r  )r  r?  r  r  rH  r  r   )r(   r:   r   r  r  r  r  r  -v2PrivatePostFuturesCancelStopOrderByClientIdr"  *v2PrivatePostSpotCancelStopOrderByClientId)v2PrivatePostFuturesCancelOrderByClientId&v2PrivatePostSpotCancelOrderByClientIdr  #v2PrivatePostFuturesCancelStopOrder v2PrivatePostSpotCancelStopOrderv2PrivatePostFuturesCancelOrderv2PrivatePostSpotCancelOrderr  r  r  )r  r:   r  r  r  r  rH   r%  r*  r  r  r  rowss                r  cancel_ordercoinex.cancel_orders  s    ( >#DGG.Y$YZZ!!!V$))&&)Df~fTl
 
!??vV
%.GM"%)1&)/&**6;P6#GH$#0K %)%W%WX\XcXcdkXt%uuH6 &*%T%TUYU`U`ahUq%rrH8 %)%S%STXT_T_`gTp%qqHD &*%P%PQUQ\Q\]dQm%nnHF %)%:%:2%>	"%)%M%MdkkZaNj%kkH, &*%J%J4;;W^Kg%hhH, '+&;&;B&?
#%)%I%I$++V]Jf%ggH8 &*%F%Ft{{SZGc%ddH8 $>>(FB7D>>$q'626D>>(FB7D--G 	".  v6  s:  rD  oL  l,  i0  h8  es   /KJ6CK8J99)K"J<#0KJ?)K=K>A
KK	(K1K2AK5K	6(KKAK9K<K?KKKK	KKc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nSnUS   (       a.  SUS'   U R	                  U R                  XB5      5      I Sh  vN nOLSnU R                  SU5      u  pbUb  S	US'   OS
US'   U R                  U R                  XB5      5      I Sh  vN nU R                  SU05      /$  N Ng N7f)a  
cancel all open orders in a market

https://docs.coinex.com/api/v2/spot/order/http/cancel-all-order
https://docs.coinex.com/api/v2/futures/order/http/cancel-all-order

:param str symbol: unified market symbol of the market to cancel orders in
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'cross' or 'isolated' for canceling spot margin orders
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nz- cancelAllOrders() requires a symbol argumentr  r:   rH   r   r  rN   r   r   r  )	r(   r:   r   r  "v2PrivatePostFuturesCancelAllOrderr"  r  v2PrivatePostSpotCancelAllOrderr  )r  r  r  r  r%  r  r*  s          r  cancel_all_orderscoinex.cancel_all_orders  s     >#DGG.]$]^^!!!V$fTl
 &>%.GM"!DDT[[QXEabbH
 J!%!C!CDUW]!^J%)1&)/&!AA$++gB^__H
 OO 
 	
/ 	" c `s5   /C.C(AC.C*AC.C,C.*C.,C.c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   U R	                  U5      S.nSnUS   (       a)  U R                  U R                  XS5      5      I Sh  vN nO(U R                  U R                  XS5      5      I Sh  vN nU R                  US0 5      nU R                  Xt5      $  N NS N,7f)a  
fetches information on an order made by the user

https://docs.coinex.com/api/v2/spot/order/http/get-order-status
https://docs.coinex.com/api/v2/futures/order/http/get-order-status

:param str id: order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nz( fetchOrder() requires a symbol argumentr:   )r  rH  rH   r  )
r(   r:   r   r  r  v2PrivateGetFuturesOrderStatusr"  v2PrivateGetSpotOrderStatusr  r  )r  r:   r  r  r  r%  r  r  s           r  fetch_ordercoinex.fetch_order  s      >#DGG.X$XYY!!!V$Tl--b1
 &>!@@WA]^^H> "==dkk'>Z[[H> ~~h3--O 	" _> \s4   /C%CAC%C!(C%6C#7)C%!C%#C%c                 "  #    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  XFS'   U R                  USS5      nU R                  USS/5      nSn	U R	                  SXu5      u  pSn
US:H  =(       d    US	:H  nUS
:H  =(       d    US:H  nU	S:X  a  SUS'   U(       a[  U(       a*  U R                  U R                  Xe5      5      I Sh  vN n
GOmU R                  U R                  Xe5      5      I Sh  vN n
GOCU(       aY  U(       a*  U R                  U R                  Xe5      5      I Sh  vN n
GOU R                  U R                  Xe5      5      I Sh  vN n
OSnU R                  SU5      u  pUb  SUS'   OSUS'   U(       aY  U(       a)  U R                  U R                  Xe5      5      I Sh  vN n
OU R                  U R                  Xe5      5      I Sh  vN n
O^US
:X  aX  U(       a)  U R                  U R                  Xe5      5      I Sh  vN n
O(U R                  U R                  Xe5      5      I Sh  vN n
U R                  U
S/ 5      nU R!                  XX45      $  GNb GN GNu GN@ GN N N Ne N>7f)a~  
fetch a list of orders

https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order

:param str status: order status to fetch for
: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]: set to True for fetching trigger orders
:param str [params.marginMode]: 'cross' or 'isolated' for fetching spot margin orders
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr:   r  r;  r  r?  fetchOrdersByStatusfinishedr  pendingr  rH   r   r  r   r   r  )r   r  r  r  r-  $v2PrivateGetFuturesFinishedStopOrderr"   v2PrivateGetFuturesFinishedOrder#v2PrivateGetFuturesPendingStopOrderv2PrivateGetFuturesPendingOrderr  !v2PrivateGetSpotFinishedStopOrderv2PrivateGetSpotFinishedOrder v2PrivateGetSpotPendingStopOrderv2PrivateGetSpotPendingOrderr  parse_orders)r  r  r  rV  r;  r  r%  r  r?  r  r  isClosedisOpenr*  r  s                  r  fetch_orders_by_statuscoinex.fetch_orders_by_status  s    $ !!![[(F &tGH$G""669=6FI#67
!??@UW]f
j(Af.@I%<6V+;%.GM"%)%N%Nt{{[bOk%llH8 &*%J%J4;;W^Kg%hhH> %)%M%MdkkZaNj%kkH: &*%I%I$++V]Jf%ggHH J!%!C!CDY[a!bJ%)1&)/&%)%K%KDKKX_Lh%iiH: &*%G%GT[Hd%eeHB 9$%)%J%J4;;W^Kg%hhH< &*%F%Ft{{SZGc%ddHH ~~h3  u<<y 	"&  m8  iB  l:  hX  j:  fF  i<  es   JI8CJI; )J	I>
7JJ)J+J,AJJ(J/J	05J%J&(JJ*J;J>JJJJ	JJJc                    #    U R                  SXX45      I Sh  vN n[        S[        U5      5       H
  nSXV   S'   M     U$  N)7f)aG  
fetch all unfilled currently open orders

https://docs.coinex.com/api/v2/spot/order/http/list-pending-order
https://docs.coinex.com/api/v2/spot/order/http/list-pending-stop-order
https://docs.coinex.com/api/v2/futures/order/http/list-pending-order
https://docs.coinex.com/api/v2/futures/order/http/list-pending-stop-order

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch open orders for
:param int [limit]: the maximum number of open order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: set to True for fetching trigger orders
:param str [params.marginMode]: 'cross' or 'isolated' for fetching spot margin orders
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
rA  Nr   r  r  )rM  r  r  )r  r  rV  r;  r  
openOrdersr  s          r  fetch_open_orderscoinex.fetch_open_orders@  sL     "  66y&QV__
q#j/*A&,JM(# + `s   AA*Ac                 D   #    U R                  SXX45      I Sh  vN $  N7f)ay  
fetches information on multiple closed orders made by the user

https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order

: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]: set to True for fetching trigger orders
:param str [params.marginMode]: 'cross' or 'isolated' for fetching spot margin orders
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
r@  N)rM  )r  r  rV  r;  r  s        r  fetch_closed_orderscoinex.fetch_closed_ordersV  s"     " 00VEZZZZ     r  c                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  USS5      nUc  [        U R                  S-   5      eU R                  US5      nUS   U R                  XCS   5      S.nU R                  U R                  XR5      5      I Sh  vN nU R                  US0 5      nU R                  Xs5      $  N N*7f)	a  
create a currency deposit address

https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/update-deposit-address

:param str code: unified currency code of the currency for the deposit address
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.network]: the blockchain network to create a deposit address on
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
Nr  r  z4 createDepositAddress() requires a network parameterr:   r  )r  r  r  )r   rF  r  r(   r:   r  network_code_to_id(v2PrivatePostAssetsRenewalDepositAddressr"  r  parse_deposit_address)r  r  r  rF  r  r%  r  r  s           r  create_deposit_addresscoinex.create_deposit_addressi  s      !!!==&$$VWi@?#DGG.d$dee69-D>,,Wv6FG
 FFt{{SZGcdd ~~h3))$99- 	" es"   CCBC)C*)CC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                  S-   5      eU R                  U5      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 N*7f)a  
fetch the deposit address for a currency associated with self account

https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-address

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.network]: the blockchain network to create a deposit address on
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
Nr  r:   z5 fetchDepositAddress() requires a "network" parameterr  r  )
r   rF  handle_network_code_and_paramsr(   r:   rX   v2PrivateGetAssetsDepositAddressr"  r  rZ  )r  r  r  rF  r%  r  r  r  s           r  fetch_deposit_addresscoinex.fetch_deposit_address  s      !!!==&8D>
 "AA&I#DGG.e$eff22;?>>t{{7?[\\ ~~h3))$99- 	" ]s"   CCBCC)CCrF  c           	          U R                  US5      nUR                  S5      nS nS n[        U5      nUS:  a  US   S:w  a  US   nUS   nOUnUU R                  S U5      S UU R                  USU5      S.$ )Naddressr  r   r   cfxmemo)r  rF  r  rc  tag)r  splitr  r  )r  depositAddressrF  coinAddresspartsrc  rf  partsLengths           r  rZ  coinex.parse_deposit_address  s     &&~yA!!#&%j?uQx50AhG(C!G"//h?##NFC@
 	
r  c                 F  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X6S'   Ub  X&S'   U R	                  SXd5      u  pdSnUS   (       a.  S	US
'   U R                  U R                  Xd5      5      I Sh  vN nOLSnU R                  SU5      u  pUb  SUS
'   OSUS
'   U R                  U R                  Xd5      5      I Sh  vN nU R                  US/ 5      n	U R                  XX#5      $  N Nx N-7f)a  
fetch all trades made by the user

https://docs.coinex.com/api/v2/spot/deal/http/list-user-deals
https://docs.coinex.com/api/v2/futures/deal/http/list-user-deals

: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 trade structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest trades
:param str [params.side]: the side of the trades, either 'buy' or 'sell', required for swap
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Nz+ fetchMyTrades() requires a symbol argumentr  r:   r;  
start_timeend_timerH   r   r  r~   r   r   r  )r(   r:   r   r  handle_until_optionv2PrivateGetFuturesUserDealsr"  r  v2PrivateGetSpotUserDealsr  rZ  )
r  r  rV  r;  r  r  r%  r  r*  r  s
             r  fetch_my_tradescoinex.fetch_my_trades  sA     >#DGG.[$[\\!!!V$fTl
 $G$)L!22:wO&>%.GM"!>>t{{7?[\\H, J!%!C!COU[!\J%)1&)/&!;;DKK<XYYH, ~~h3  u<<A 	" ]8 Zs5   /D!DA2D!$D%AD!1D2*D!D!D!c                   #    U R                  5       I Sh  vN   SnU R                  USSS5      u  p2U R                  U5      nSS0nSnUba  Sn[        U[        5      (       a/  [        U5      nUS:  a  [        U R                  S-   5      eUS	   nOUnU R                  U5      nUS
   US'   SnUS:X  a)  U R                  U R                  XB5      5      I Sh  vN nO(U R                  U R                  XB5      5      I Sh  vN nU R                  US/ 5      n	/ n
[        S	[        U	5      5       H&  nU
R                  U R                  X   U5      5        M(     U R!                  U
SUS5      $  GNY N Nq7f)aD  
fetch all open positions

https://docs.coinex.com/api/v2/futures/position/http/list-pending-position
https://docs.coinex.com/api/v2/futures/position/http/list-finished-position

:param str[] [symbols]: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.method]: the method to use 'v2PrivateGetFuturesPendingPosition' or 'v2PrivateGetFuturesFinishedPosition' default is 'v2PrivateGetFuturesPendingPosition'
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nr   method"v2PrivateGetFuturesPendingPositionr  r   r   zD fetchPositions() symbols argument cannot contain more than 1 symbolr   r:   r  r  r  F)r   r  r+  
isinstancelistr  r)   r:   r  rw  r"  #v2PrivateGetFuturesFinishedPositionr  r  r  parse_positionfilter_by_array_positions)r  r)  r  defaultMethodr%  r  r  symbolsLengthr  positionr  r  s               r  fetch_positionscoinex.fetch_positions  s     !!! $ = =fFVX`  cG  !H%%g.9
 F'4(( #G 1$$TWW/u%uvv  [[(F &tGH@@!DDT[[QXEabbH!EEdkkRYFbccHX >>(FB7q#h-(AMM$--hk6BC )--fhOOO 	"* ccs5   E6E/CE6E2(E6E4A-E62E64E6c                   #    U R                  5       I Sh  vN   U R                  U5      n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                  US   U5      $  Nm N.7f)au  
fetch data on a single open contract trade position

https://docs.coinex.com/api/v2/futures/position/http/list-pending-position

:param str symbol: unified market symbol of the market the position is held in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nr   r:   r  r  r  r   )r   r  rw  r"  r  r{  )r  r  r  r  r%  r  r  s          r  fetch_positioncoinex.fetch_positionp  s      !!!V$$Tl
 @@WA]^^X ~~h3""47F33g 	" _s"   BBA BB-BBr  c                    U R                  US5      nU R                  X2S S5      nU R                  US5      nU R                  0 SU_SU R                  US5      _SUS   _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U R	                  US5      _SS _SU R	                  US5      _SU R	                  US5      _SS _SS _SU R                  US5      _SS _SU_U R                  U5      U R                  US5      U R	                  US5      U R	                  US5      U R	                  US 5      S S U R	                  US!5      U R	                  US"5      U R                  U R                  US#5      5      U R                  U R                  US$5      5      S%.E5      $ )&Nr  rH   rC  r  r:   r  r  notionalsettle_valuer*  margin_modeliquidationPrice	liq_price
entryPricer  unrealizedPnlunrealized_pnlrealizedPnlrealized_pnlr  	contracts
close_avblr  r  	lastPricerI  r2  r  r;  maintenance_margin_valuemaintenance_margin_ratemargin_avblr4  position_margin_rater  r  )r  lastUpdateTimestampmaintenanceMarginmaintenanceMarginPercentage
collateralinitialMargininitialMarginPercentager4  marginRatior.  r/  )r  rN  r4  safe_positionr  rP  	omit_zero)r  r  r  r  r  s        r  r{  coinex.parse_position  sV   F ##Hh7!!(D&A%%h=	!! #
H#
$##Hm<#
 fX&#
 ((>B	#

 $**8]C#
  0 0; G#
 $**85FG#
 T--h8HI#
 4++HnE#
 $#
 ))(LA#
 D,,V^D#
 #
 #
 D$$Xv6#
  d!#
" ##
$ Y/#'#4#4X|#L!%!1!1(<V!W+/+;+;HF_+`**8]C!'+((:>++H6LM!^^D,<,<XGX,YZ#~~d.>.>xI\.]^9#
  	r  r*  c                   #    Uc  [        U R                  S-   5      eUR                  5       nUS:w  a  US:w  a  [        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-   5      eU R                  US	5      nU R                  US
   S	   SS5      nUc  [        U R                  S-   5      eUS:  d  XV:  a*  [        U R                  S-   [        U5      -   S-   U-   5      eUS   SUUS.nU R                  U R                  Xs5      5      I Sh  vN $  N N7f)a{  
set margin mode to 'cross' or 'isolated'

https://docs.coinex.com/api/v2/futures/position/http/adjust-position-leverage

:param str marginMode: 'cross' or 'isolated'
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int params['leverage']: the rate of leverage
:returns dict: response from the exchange
Nz+ setMarginMode() requires a symbol argumentisolatedcrossz@ setMarginMode() marginMode argument should be isolated or crossr  rH   z- setMarginMode() supports swap contracts onlyr4  r   r   d   z. setMarginMode() requires a leverage parameterr   z2 setMarginMode() leverage should be between 1 and  for r:   r   r  r  r  r4  )r(   r:   lowerr)   r   r  r*   r4  str*v2PrivatePostFuturesAdjustPositionLeverager"  )r  r*  r  r  r  r4  maxLeverager%  s           r  set_margin_modecoinex.set_margin_mode  sg     >#DGG.[$[\\%%'
#
g(=TWW'iijj!!!V$&>V#DGG&UUVV$$VZ8''x(8(DeSQ#DGG.^$^__qLh4TWW'[[^abm^nnqxx  |B  B  C  CTl$% 	
 DDT[[QXEabbb! 	"  cs%   A#E%E	&CEEEEr4  c                 Z  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   (       d  [	        U R                  S-   5      eSnU R                  SUS5      u  pSU R                  US   S   S	S
5      nU R                  US   S   SS5      nX:  d  X:  a9  [        U R                  S-   [        U5      -   S-   [        U5      -   S-   U-   5      eUS   SUUS.nU R                  U R                  X5      5      I Sh  vN $  N N7f)a  

https://docs.coinex.com/api/v2/futures/position/http/adjust-position-leverage

set the level of leverage for a market
: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.marginMode]: 'cross' or 'isolated'(default is 'cross')
:returns dict: response from the exchange
Nz) setLeverage() requires a symbol argumentrH   z+ setLeverage() supports swap contracts onlyr   r  r   r4  r   r   r   r  z* setLeverage() leverage should be between z and r  r:   r   r  )r(   r:   r   r  r*   r  r4  r)   r  r  r"  )	r  r4  r  r  r  r*  minLeverager  r%  s	            r  set_leveragecoinex.set_leverage!  sa     >#DGG.Y$YZZ!!!V$f~DGG&SSTT
!??vW^_
''x(8(DeQO''x(8(DeSQ"(>TWW'SSVYZeVffippsv  xC  tD  D  GN  N  QW  W  X  XTl$% 	
 DDT[[QXEabbb! 	"  cs"   /D+D'C0D+"D)#D+)D+c                 0  #    U R                  5       I Sh  vN   0 nUb%  U R                  U5      nSR                  U5      US'   U R                  U R	                  X25      5      I Sh  vN nU R                  US/ 5      nU R                  XaS5      $  N{ N+7f)a  
retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes

https://docs.coinex.com/api/v2/futures/market/http/list-market-position-level

:param str[]|None symbols: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
N,r  r  )r   
market_idsjoinv2PublicGetFuturesPositionLevelr"  r  parse_leverage_tiers)r  r)  r  r%  	marketIdsr  r  s          r  fetch_leverage_tierscoinex.fetch_leverage_tiersK  s      !!!0I # 3GH==dkk'>Z[[4 ~~h3((AAA 	"
 \s"   BBAB(B)*BBc                    / nU R                  US/ 5      nSn[        S[        U5      5       H  nXF   nU R                  US5      nU R	                  XS S5      nU R                  US5      n	UR                  U R                  US5      U R                  XS S5      US   (       a  US   OUS	   UU	U R                  US
5      U R                  US5      US.5        U	nM     U$ )Nlevelr   r  rH   r   r   r   r  r  r  r4  )tierr  rF  minNotionalmaxNotionalmaintenanceMarginRater  r  )
r  r  r  r  rN  r  r  sumr  r4  )
r  r  r  tiersbracketsr  r  r  r  r  s
             r  parse_market_leverage_tiers"coinex.parse_market_leverage_tiersw  s    >>$4q#h-(A;D''h7H%%hfEF**4:KLLA**8T6J.4X.>F6NF7O**)-)9)9$@Y)Z#00zB	 	 &K )  r  c                   #    U R                  5       I S h  vN   U R                  U5      nU R                  X5      nUnUS:X  a  [        R                  " U5      nUS   SUS.nU R                  U R                  X5      5      I S h  vN n	U R                  U	S5      n
U R                  U	S5      nUS:X  a  SOSnU R                  U R                  X5      UU R                  U5      US.5      $  N Nh7f)	Nreducer:   r   )r  r  r   r  messageadd)r  r   r  )r   r  r  r4   
string_neg(v2PrivatePostFuturesAdjustPositionMarginr"  r  r  parse_margin_modificationr  )r  r  r   addOrReducer  r  	rawAmountrequestAmountr%  r  r  r  r  s                r  modify_margin_helpercoinex.modify_margin_helper  s     !!!V$,,V<	!("#..y9MTl$#

 FFt{{SZGcddN ~~h/'')<'83x%{{499$G''/J
  	k 	" es#   C2C.A0C2C0A'C20C2r  c                 6   U R                  US5      nU R                  USS5      nU R                  US5      nUU R                  X2S S5      S SU R                  [        R
                  " U5      5      U R                  US5      US   S UU R                  U5      S	.
$ )
Nr  r;  rC  margin_changerH   r  r  r  )
r  r  r  r*  r   totalr  r  r  r  )r  safe_integer_2r  r  r4   
string_absr  rP  )r  r  r  r  r  r  s         r  r   coinex.parse_margin_modification  s    l ##D(3''lLI	!!$8&&xvF$''(:(:6(BC%%dM:7O"Y/
 	
r  c                 D   #    U R                  XSU5      I Sh  vN $  N7f)aT  
add margin

https://docs.coinex.com/api/v2/futures/position/http/adjust-position-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
:returns dict: a `margin structure <https://docs.ccxt.com/#/?id=add-margin-structure>`
r  Nr  r  r  r   r  s       r  
add_margincoinex.add_margin  s"      ..vufMMMMrV  c                 D   #    U R                  XSU5      I Sh  vN $  N7f)aq  
remove margin from a position

https://docs.coinex.com/api/v2/futures/position/http/adjust-position-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
:returns dict: a `margin structure <https://docs.ccxt.com/#/?id=reduce-margin-structure>`
r  Nr  r  s       r  reduce_margincoinex.reduce_margin  s"      ..vxPPPPrV  c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   SS.nU R	                  SXd5      u  pdUb  X&S'   Ub  X6S'   U R                  U R                  Xd5      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U R                  US5      nU R                  U5      nU	R                  UUUUU R                  U5      U R                  US5      U R                  US5      S.5        M     U	$  GN N7f)a  
fetch the history of funding fee payments paid and received on self account

https://docs.coinex.com/api/v2/futures/position/http/list-position-funding-history

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch funding history for
:param int [limit]: the maximum number of funding history structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
Nz1 fetchFundingHistory() requires a symbol argumentr:   r   )r  r  ro  rn  r;  r  r   rC  r  r  funding_value)r  r  r  r  r  r:   r   )r(   r:   r   r  rp  )v2PrivateGetFuturesPositionFundingHistoryr"  r  r  r  r4  r  r  r  rP  r  )r  r  rV  r;  r  r  r%  r  r  r  r  r  r  r  r  s                  r  fetch_funding_historycoinex.fetch_funding_history)  sf     >#DGG.a$abb!!!V$Tl$
 22:wO$)L!$GGGT[Hdee, ~~h3q#d)$AGE))%>I))%7J**:6DMM & LL3&&um<**5/B  % c 	" fs#   /EEA"EEB9EEc                 t  #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSUS   0nU R	                  U R                  XB5      5      I Sh  vN nU R                  US/ 5      nU R                  US0 5      nU R                  Xs5      $  N N=7f)aC  
fetch the current funding rate

https://docs.coinex.com/api/v2/futures/market/http/list-market-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>`
NrH   z0 fetchFundingRate() supports swap contracts onlyr  r:   r  r   )	r   r  r*   r:   v2PublicGetFuturesFundingRater"  r  r  parse_funding_rate)r  r  r  r  r%  r  r  firsts           r  fetch_funding_ratecoinex.fetch_funding_ratej  s      !!!V$f~DGG&XXYYfTl
 ;;DKK<XYY& ~~h3tQ+&&u559 	" Zs"   B8B4A!B88B69<B86B8c                 @   #    U R                  X5      I Sh  vN $  N7f)aL  
fetch the current funding rate interval

https://docs.coinex.com/api/v2/futures/market/http/list-market-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>`
N)r  )r  r  r  s      r  fetch_funding_intervalcoinex.fetch_funding_interval  s      ,,V<<<<s   c                 0   U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n[        R                  " Xe5      nU R                  US5      n0 SU_SU R	                  XS S5      _SU R                  US5      _S	S _S
S _SS _SS _SS _SU R                  US5      _SU_SU R                  U5      _SU R                  US5      _SU_SU R                  U5      _SS _SS _SS _SU R                  U5      0E$ )Nlatest_funding_timenext_funding_timer  r  r  rH   r  r   r  interestRateestimatedSettlePricer  r  fundingRatelatest_funding_ratefundingTimestampfundingDatetimenextFundingRatenext_funding_ratenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimer9  )r4  r  r4   
string_subr  r  rP  parse_funding_interval)	r  r  r  currentFundingTimestampfutureFundingTimestampfundingTimeStringnextFundingTimeStringmillisecondsIntervalr  s	            r  r  coinex.parse_funding_rate  s    #'"3"3H>S"T!%!2!28=P!Q ,,X7LM $ 0 0;N O&112G[##Hh7
H
d&&xvF
 ))(LA
 $	

 D
 #D
 
 
 4++H6KL
  7
 t||,CD
 t//:MN
 #$:
 "4<<0F#G
 "4
  '!
" &t#
$ 334HI%
 	
r  c                 6    SSSSSS.nU R                  X!U5      $ )Nr   r   8h16h24h)360000014400000288000005760000086400000r  )r  r9  	intervalss      r  r  coinex.parse_funding_interval  s-    
	 	X>>r  c                   #    U R                  5       I Sh  vN   U R                  U5      n0 nSnUbj  U R                  US5      nU R                  U5      nUS   (       d  [	        U R
                  S-   5      eU R                  U5      nSR                  U5      US'   U R                  U R                  X25      5      I Sh  vN nU R                  US/ 5      nU R                  X5      $  N N*7f)aj  
fetch the current funding rates for multiple markets

https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate

:param str[] symbols: unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
Nr   rH   z1 fetchFundingRates() supports swap contracts onlyr  r  r  )r   r+  r,  r  r*   r:   r  r  r  r"  r  parse_funding_rates)	r  r)  r  r%  r  r  r  r  r  s	            r  fetch_funding_ratescoinex.fetch_funding_rates  s      !!!%%g.__Wa0F[[(F&>*] ]^^0I # 3GH;;DKK<XYY& ~~h3''66? 	" Zs"   C-C)B)C- C+)C-+C-rc  rf  c                   #    U R                  XE5      u  pEU R                  U5        U R                  5       I Sh  vN   U R                  U5      nUS   UU R	                  X5      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://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/withdrawal

:param str code: unified currency code
:param float amount: the amount to withdraw
:param str address: the address to withdraw to
:param str [tag]: memo
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.network]: unified network code
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr:   )r  
to_addressr   re  r  r  )handle_withdraw_tag_and_paramscheck_addressr   rF  currency_to_precisionr^  rX  v2PrivatePostAssetsWithdrawr"  r  parse_transaction)r  r  r   rc  rf  r  rF  r%  r  r  transactions              r  r   coinex.withdraw  s      99#F7#!!!==&D>!00>

 ?!FO"AA&I"#66{CGG99$++g:VWW6 nnXvr:%%k<<S 	" Xs"   8C+C'BC+>C)?)C+)C+c                 @    SSSSSSSSSSS.
nU R                  X!U5      $ )NrA  failedr  ok)
auditpassaudit_required
processing
confirmingnot_passr  finishr@  failr  r  s      r  parse_transaction_statuscoinex.parse_transaction_status8  s<    '##  
 &99r  c           
      P  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R	                  SXUSUS5      I Sh  vN $ U R                  U5      nSUS	   0nUb  X'S
'   Ub  X7S'   U R                  SXt5      u  ptU R                  U R                  Xt5      5      I Sh  vN nU R                  US/ 5      n	/ n
[        S[        U	5      5       Ht  nX   nU R                  US5      nU R                  XSS5      nU R                  US5      nU
R                  UUU R!                  US5      UU R#                  U5      S.5        Mv     U R%                  U
S5      nU R'                  UUS   X#5      $  GNm GN4 N7f)a  
fetches historical funding rate prices

https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate-history

:param str symbol: unified symbol of the market to fetch the funding rate history for
:param int [since]: timestamp in ms of the earliest funding rate to fetch
:param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:param int [params.until]: timestamp in ms of the latest funding rate
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
Nz5 fetchFundingRateHistory() requires a symbol argumentFrq   paginater  r:  r  r:   rn  r;  ro  r  r   rH   funding_timeactual_funding_rate)r  r  r  r  r  r  r  )r(   r:   r   r  "fetch_paginated_call_deterministicr  rp  $v2PublicGetFuturesFundingRateHistoryr"  r  r  r  r  r  r4  r  r  rP  sort_byfilter_by_symbol_since_limit)r  r  rV  r;  r  r,  r  r%  r  r  ratesr  r  r  symbolInnerr  sorteds                    r  fetch_funding_rate_history!coinex.fetch_funding_rate_historyG  s     >#DGG.e$eff!!!88AZ\fg@@AZ\bkprvx~  AE  F  F  FV$fTl
 $)L!$G22:wOBB4;;wC_``$ ~~h3q#d)$AGE''x8H**8T6JK))%@ILL%#//7LM& LL3  % e[1009I5XX_ 	" F as5   /F&F;F&-F!.A!F&F$CF&!F&$F&r  c                    U R                  US5      nU R                  US5      nUb  [        U5      S:  a  S nU R                  US5      nUb  [        U5      S:  a  S nU R                  US5      nUb  [        U5      S:  a  S nU R                  US5      nU R                  Xr5      nU R                  US5      n	SU;   a  S	OS
n
U R                  US5      nU R                  US5      nU R	                  USS5      nUS:H  nU R                  US5      nUc  U R                  US5      nU
S
:X  a  SnU R                  US5      nU R                  U5      U R                  U5      S.n0 SU_SU R                  USS5      _SU_SU	_SU R                  U	5      _SU R                  U5      _SU_SU_SS _SU_S S _S!S _S"U
_SU_S#U_S$U R                  U R                  US$5      5      _S%S _UUUS&.E$ )'Nr  re  r   remarktx_idr  rC  withdraw_id
withdrawalr  r  tx_feewithdraw_methoddeposit_methodlocalactual_amountr   r8  	fee_assetrE  r  r:   
deposit_idtxidr  r  r  rc  	addressToaddressFromrf  tagTotagFromr  rF  r  updated)r  commentinternal)r  r  r  r4  safe_string_lower_2r  r  r  rP  r  r)  )r  r  rF  rc  rf  r9  rD  r  r  r  r  r  feeCosttransferMethodrK  r   rR  r  s                     r  r  coinex.parse_transaction  s   Z "";={F3?3x!|!!+x86{QW54y1}%%k59
&&z<%%k<@	 - <|9$$[':	"";911+?PRbc!W,!!+?>%%k8<F9G((kB%%g.//>

K
$$$[-N
 D
 	

 Y/
 t..y9
 w
 
 4
 3
 T
 t
 D
 f
 
  d33D4D4D[RZ4[\!
" t#
$  )
 	
r  fromAccount	toAccountc                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  X5      nU R                  U R                  S0 5      nU R                  XU5      n	U R                  XU5      n
US   UU	U
S.nUS:X  d  US:X  aS  U R                  US5      nUc  [        U R                  S-   5      eU R                  US5      nU R                  U5      US'   US	:w  a  US	:w  a  [        U R                  S
-   5      eU R                  U R                  X5      5      I Sh  vN nU R                  U R                  X5      U R                  U5      UUS.5      $  GNQ N;7f)a?  
transfer currency internally between wallets on the same account

https://docs.coinex.com/api/v2/assets/transfer/http/transfer

:param str code: unified currency code
:param float amount: amount to transfer
:param str fromAccount: account to transfer from
:param str toAccount: account to transfer to
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.symbol]: unified ccxt symbol, required when either the fromAccount or toAccount is margin
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
Nr"  r:   )r  r   from_account_typeto_account_typerG   r  zE transfer() the symbol parameter must be defined for a margin accountr  rF   zs transfer() can only be between spot and swap, or spot and margin, either the fromAccount or toAccount must be spot)r   rP  rQ  )r   rF  r  r  r   r  r(   r:   r  	market_idr)   v2PrivatePostAssetsTransferr"  parse_transferr  )r  r  r   rP  rQ  r  rF  amountToPrecisionr"  fromIdtoIdr%  r  r  s                 r  r   coinex.transfer  s|     !!!==& 66tD6FK!!.{K9ED>'!'#	
 8#h)>%%fh7F~'2y(yzzYYvx0F $v 6GH6!	V(;TWW  (]  ]  ^  ^99$++g:VWW {{4..xB''(9:&"E
  	9 	"( Xs"   E,E'DE,.E*/9E,*E,c                 6    SSSSSS.nU R                  X!U5      $ )Nr   )r8  SUCCESSOKr@  FINISHEDr  r  s      r  parse_transfer_statuscoinex.parse_transfer_status  s-    
 &99r  r   c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  U R                  S0 5      nS UU R	                  U5      U R                  XB5      U R                  US5      U R                  XuU5      U R                  XvU5      U R                  U R                  USS5      5      S	.$ )
NrC  r  rS  rT  r#  r   r  r  )r:   r  r  rF  r   rP  rQ  r  )	r4  r  r,  r   rP  r  r  r`  r  )r  r   rF  r  r  rY  rZ  r#  s           r  rW  coinex.parse_transfer%  s    %%h=	%%h6
!!(,?@*;<t||^RH"Y///
E&&x:++L&I)),dC001C1CHfV^1_`	
 		
r  c                   #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eU R                  U5      nSUS   0nSnU R	                  SU5      u  ptUb  SUS'   OSUS'   Ub  X&S	'   Ub  X6S
'   U R                  SXd5      u  pdU 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)ar  
fetch a history of internal transfers made on an account

https://docs.coinex.com/api/v2/assets/transfer/http/list-transfer-history

:param str code: unified currency code of the currency transferred
:param int [since]: the earliest time in ms to fetch transfers for
:param int [limit]: the maximum number of transfer structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'cross' or 'isolated' for fetching transfers to and from your margin account
:returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
Nz* fetchTransfers() requires a code argumentr  r:   r   r   transfer_typer   rn  r;  ro  r  )
r   r(   r:   rF  r  rp  !v2PrivateGetAssetsTransferHistoryr"  r  parse_transfers)
r  r  rV  r;  r  rF  r%  r*  r  r  s
             r  fetch_transferscoinex.fetch_transfers6  s     !!!<#DGG.Z$Z[[==&8D>
 
!??@PRXY
!'/GO$'0GO$$)L!$G22:wO??G@\]]* ~~h3##DEAAQ 	"$ ^s"   C%C!B C%7C#8*C%#C%c                 *  #    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  X5S'   U R                  U R                  XT5      5      I Sh  vN nU R	                  US/ 5      nU R                  XX#5      $  Nx N+7f)a  
fetch all withdrawals made from an account

https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-withdrawal-history

:param str [code]: unified currency code
:param int [since]: the earliest time in ms to fetch withdrawals for
:param int [limit]: the maximum number of withdrawal structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr:   r  r;  r  )r   rF  v2PrivateGetAssetsWithdrawr"  r  parse_transactions	r  r  rV  r;  r  r%  rF  r  r  s	            r  fetch_withdrawalscoinex.fetch_withdrawalsm  s      !!!}}T*H%d^GEN$G88W9UVVB ~~h3&&tuDDU 	" W"   BBAB%B&*BBc                 *  #    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  X5S'   U R                  U R                  XT5      5      I Sh  vN nU R	                  US/ 5      nU R                  XX#5      $  Nx N+7f)a  
fetch all deposits made to an account

https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-deposit-history

:param str [code]: unified currency code
:param int [since]: the earliest time in ms to fetch deposits for
:param int [limit]: the maximum number of deposit structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr:   r  r;  r  )r   rF   v2PrivateGetAssetsDepositHistoryr"  r  rl  rm  s	            r  fetch_depositscoinex.fetch_deposits  s      !!!}}T*H%d^GEN$G>>t{{7?[\\< ~~h3&&tuDDO 	" ]rp  r  c           
          U R                  US5      nU R                  X2S S5      nU R                  US5      nU R                  US5      nS nS nXBS   :X  a  UnO
XBS   :X  a  UnUS   US   UUS	   US
S S US.	$ )Nr  rF   r  daily_interest_rater  r  r  r  r  i \&)	r  r  baseRater  	quoteRatern  r  r  r  )r  rN  r  )r  r  r  r  rF  raterw  rx  s           r  parse_isolated_borrow_rate!coinex.parse_isolated_borrow_rate  s     ##D(3!!(D&A##D%0&;<	h''H	**IX&6N G_"

 
	
r  c                   #    U R                  5       I Sh  vN   U R                  US5      nUc  [        U R                  S-   5      eU R	                  US5      nU R                  U5      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                  X5      $  N N*7f)a  
fetch the rate of interest to borrow a currency for margin trading

https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit

:param str symbol: unified symbol of the market to fetch the borrow rate for
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str params['code']: unified currency code
:returns dict: an `isolated borrow rate structure <https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure>`
Nr  z4 fetchIsolatedBorrowRate() requires a code parameterr:   r  r  r  )r   r  r(   r:   r  rF  r  %v2PrivateGetAssetsMarginInterestLimitr"  r  rz  	r  r  r  r  rF  r  r%  r  r  s	            r  fetch_isolated_borrow_rate!coinex.fetch_isolated_borrow_rate  s      !!!/<#DGG.d$dee66*==&V$TlD>
 CCDKKPWD`aa ~~h3..t<<7 	" b"   CCBC*C+)CCc                 L  #    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  XFS'   U R                  U R                  Xe5      5      I Sh  vN nU R	                  US/ 5      n	U R                  X5      n
U R                  XX45      $  N N<7f)ae  
fetch the interest owed by the user for borrowing currency for margin trading

https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history

:param str [code]: unified currency code
:param str [symbol]: unified market symbol when fetch interest in isolated markets
:param int [since]: the earliest time in ms to fetch borrrow interest for
:param int [limit]: the maximum number of structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `borrow interest structures <https://docs.ccxt.com/#/?id=borrow-interest-structure>`
Nr:   r  r;  r  )r   r  %v2PrivateGetAssetsMarginBorrowHistoryr"  r,  parse_borrow_interestsfilter_by_currency_since_limit)r  r  r  rV  r;  r  r%  r  r  r1  rx  s              r  fetch_borrow_interestcoinex.fetch_borrow_interest#  s      !!![[(F &tGH$GCCDKKPWD`aa2 x4..t<2285PPG 	" bs"   B$B AB$%B"&;B$"B$c                 J   U R                  US5      nU R                  X2S S5      nU R                  US5      nUUS   U R                  U R                  US5      5      U R	                  US5      U R	                  US5      U R	                  US5      S	UU R                  U5      S
.	$ )Nr  rF   
expired_atr  r  to_repaied_amountrv  borrow_amountr  )	r  r  rF  rx  r  amountBorrowedr*  r  r  )r  rN  r4  r  r  rP  )r  r  r  r  r  s        r  parse_borrow_interestcoinex.parse_borrow_interestU  s     ##D(3!!(D&A%%dL9	X&//0@0@u0MN((/BC ,,T3HI"..t_E$"Y/

 
	
r  c                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      nU R                  USSS5      nU R	                  US5      nUS   US   U R                  X#5      US.nU R                  U R                  X5      5      I Sh  vN n	U R                  U	S0 5      n
U R                  X5      nU R                  UUUS.5      $  N N?7f)	a%  
create a loan to borrow margin

https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-borrow

:param str symbol: unified market symbol, required for coinex
:param str code: unified currency code of the currency to borrow
:param float amount: the amount to borrow
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.isAutoRenew]: whether to renew the margin loan automatically or not, default is False
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
NisAutoRenewis_auto_renewFr:   )r  r  r  r  r  r   r  )
r   r  rF  r  r  r  v2PrivatePostAssetsMarginBorrowr"  r  parse_margin_loan)r  r  r  r   r  r  rF  r  r%  r  r  r  s               r  borrow_isolated_margincoinex.borrow_isolated_margins  s      !!!V$==&&&v}ouU6=1TlD>!77E(	
 ==dkk'>Z[[" ~~h3,,T<{{;)
  	= 	" \s"   C$C BC$"C"#>C$"C$c                 ~  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      nUS   US   U R                  X#5      S.nU R	                  U R                  Xt5      5      I Sh  vN nU R                  US0 5      n	U R                  X5      n
U R                  U
UUS.5      $  N N?7f)a  
repay borrowed margin and interest

https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-repay

:param str symbol: unified market symbol, required for coinex
:param str code: unified currency code of the currency to repay
:param float amount: the amount to repay
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.borrow_id]: extra parameter that is not required
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
Nr:   )r  r  r   r  r  )r   r  rF  r  v2PrivatePostAssetsMarginRepayr"  r  r  )r  r  r  r   r  r  rF  r%  r  r  r  s              r  repay_isolated_margincoinex.repay_isolated_margin  s      !!!V$==&TlD>00>

 <<T[[=YZZ ~~h3,,T<{{;)
  	% 	" [s"   B=B9A$B=;B;<>B=;B=c           	      "   U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      U R                  X25      U R                  US5      U R                  US S S5      UU R	                  U5      US.$ )Nr  r  r  	borrow_idr  rF   )r:   rF  r   r  r  r  r  )r  r4  r  r  rP  )r  r  rF  r  r  r  s         r  r  coinex.parse_margin_loan  s     %%dE2
##D(3%%dL9	##D+6//
E&&t_=&&xtVD"Y/
 	
r  c                 
  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R                  Xc5      $  Nh N*7f)aK  
fetch the fee for deposits and withdrawals

https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-withdrawal-config

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
Nr  r:   r  )r   rF  &v2PublicGetAssetsDepositWithdrawConfigr"  r  parse_deposit_withdraw_fee)r  r  r  rF  r%  r  r  s          r  fetch_deposit_withdraw_fee!coinex.fetch_deposit_withdraw_fee  s      !!!==&8D>
 DDT[[QXEabbD ~~h3..t>>Q 	"
 cs!   BA??BB)BB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0 n[        S[	        U5      5       Hp  nXF   nU R                  US0 5      nU R                  US5      n	U	c  M1  U R                  U	5      n
Ub  U R                  X5      (       d  M]  U R                  U5      XZ'   Mr     U$  N N7f)ai  
       fetch the fees for deposits and withdrawals

       https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-all-deposit-withdrawal-config

@param codes
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
       Nr  r   r  r  )
r   r  r  r  r  r  r  r  in_arrayr  )r  r  r  r  r  r  r  r  r  r  r  s              r  fetch_deposit_withdraw_fees"coinex.fetch_deposit_withdraw_fees  s      !!!GGOOH ~~h3q#d)$A7DNN4"5E))%7J!**:6D}d : :#>>tD % a 	"Os&   CCCCBC;CCc                    US S S.S S S.0 S.nU R                  US/ 5      nU R                  US0 5      n[        S[        U5      5       H  nXF   nU R	                  US5      nU(       d  M"  U R                  US5      US   S	'   S
US   S'   U R                  US5      n	U	(       d  M]  U R                  XR                  US5      5      n
U R                  US5      S
S.S S S.S.US   U
'   M     U$ )N)r  r  )r  r   r  r$  r  r  r   r  r  r   r  Fr  r  r  )r   r  r$  )r  r  r  r  r  r  r  r  )r  r  rF  r  r  r  r  r  isWithdrawEnabledr  r  s              r  r  !coinex.parse_deposit_withdraw_feeQ  s'   > "
 " 
 Xr2sGR0q#f+&AIE $u6H I  ,0,<,<UDT,Uz"5)38z"<0 ,,UG<	9"&"9"9)EUEUV[]bEc"dK $(#3#3E;K#L*/%
 $(*.$	7F:&{3 '& r  c                   #    U R                  5       I Sh  vN   U R                  US5      nUc  [        U R                  S-   5      eU R	                  US5      nU R                  U5      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                  X5      $  N N*7f)au  
fetch the set leverage for a market

https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str params['code']: unified currency code
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
Nr  z* fetchLeverage() requires a code parameterr:   r}  r  )r   r  r(   r:   r  rF  r  r~  r"  r  parse_leverager  s	            r  fetch_leveragecoinex.fetch_leverage  s      !!!/<#DGG.Z$Z[[66*==&V$TlD>
 CCDKKPWD`aa ~~h3""4007 	" br  c                 |    U R                  US5      nU R                  US5      nUU R                  X2S S5      SUUS.$ )Nr  r4  rF   r  )r  r  r*  longLeverageshortLeverage)r  r4  r  )r  r4  r  r  leverageValues        r  r  coinex.parse_leverage  sP     ##Hh7))(J?&&xvF$)*
 	
r  c                 t  #    U R                  5       I Sh  vN   U R                  U5      nSUS   S.nUb  X6S'   Ub  X&S'   U R                  SXd5      u  pdU R                  U R	                  Xd5      5      I Sh  vN nU R                  US/ 5      nU R                  U5      n	U R                  XX#5      $  N N<7f)	a  
fetches historical positions

https://docs.coinex.com/api/v2/futures/position/http/list-finished-position

:param str symbol: unified contract symbol
:param int [since]: the earliest time in ms to fetch positions for
:param int [limit]: the maximum amount of records to fetch, default is 10
:param dict [params]: extra parameters specific to the exchange api endpoint
:param int [params.until]: the latest time in ms to fetch positions for
:returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
Nr   r:   r  r;  rn  ro  r  )r   r  rp  rz  r"  r  parse_positionsr2  )
r  r  rV  r;  r  r  r%  r  records	positionss
             r  fetch_position_historycoinex.fetch_position_history  s      !!!V$$Tl
 $G$)L!22:wOAA$++gB^__X ..626((1	00EQQs 	" `s"   B8B4A"B89B6:;B86B8c                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  USS5      nUS   SUS.nU R                  USS5      nUb  XvS'   U R	                  US5      n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  
closes an open position for a market

https://docs.coinex.com/api/v2/futures/position/http/close-position

:param str symbol: unified CCXT market symbol
:param str [side]: buy or sell, not used by coinex
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str params['type']: required by coinex, one of: limit, market, maker_only, ioc or fok, default is *market*
:param str [params.price]: the price to fulfill the order, ignored in market orders
:param str [params.amount]: the amount to trade in units of the base currency
:param str [params.clientOrderId]: the client id of the order
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r  r:   r   )r  r  r  r  r  r  )	r   r  r  r  r  r  r"  r  r  )
r  r  rI  r  r  r  r%  r  r  r  s
             r  close_positioncoinex.close_position  s      !!!V$9Tl$

 **6;P$#0K 6?3??G@\]]: ~~h3--U 	" ^s"   CC B CC)CCc                    > U R                  U R                  S5      nU R                  USS5      nSn[        [        U ]  XU5      u  pbUc  US:X  d  USL a  SnXb/$ )aK  
@ignore
       marginMode specified by params["marginMode"], self.options["marginMode"], self.options["defaultMarginMode"], params["margin"] = True or self.options["defaultType"] = 'margin'
       :param dict params: extra parameters specific to the exchange api endpoint
       :returns Array: the marginMode in lowercase
       r   rG   FNTr  )r  r   r  r  r6   r  )r  
methodNamer  defaultValuer   r  r*  r  s          r  r  $coinex.handle_margin_mode_and_paramsR  sl     &&t||]C>>&(E:
"64Nzcop
x'X-='
##r  c                 "    U R                  5       $ N)milliseconds)r  s    r  noncecoinex.nonceb  s      ""r  GETc                    U R                  X5      nUS   nUS   nU R                  S   U   S-   U-   S-   U-   n	U R                  X@R                  U5      5      n
[	        U R                  5       5      nUS:X  a  UR                  S5      nU R                  USS5      n[        U5      nU R                  XS-
  S5      nUR                  S5      n[        U5      nU R                  UUS-
  S5      nUS:X  aY  US	:X  d  US
:X  aM  U R                  US5      nUc8  SnU R                  U R                  SU5      nUS-   U R                  5       -   U
S'   US:X  a  U R                  5         U R                  U R                  US.U
5      n
U R                  U
5      n
U R!                  U
5      nU R#                  U R%                  US-   U R&                  -   5      S5      nUR)                  5       U R                  S.nUS:X  d  US:X  a
  U	SU-   -  n	GOSUS'   UnGOUS:X  d  US:X  a   U
(       a  U	SU R+                  U
5      -   -  n	GOUS:X  a  U R                  5         U R                  U R                  US.U
5      n
U R                  U
5      n
U R!                  U
5      nU R#                  U R%                  US-   U R&                  -   5      S5      nUR-                  5       SS.nUS:X  d  US:X  d  US:X  a	  U	SU-   -  n	OU R/                  U
5      nOUS :X  a  U R                  5         U R                  U
5      n
U R!                  U
5      nUS-   U-   S-   U-   nUS:X  a  U R/                  U
5      nUU-  nOU(       a  USU-   -  nUXR&                  -   -  nU R#                  U R%                  U5      S5      nSSU R                  UUS!.nUS:w  a  U(       a  U	SU-   -  n	XXeS".$ )#Nr   r   r   r  POSTr  _rL  r;  r  r  r   r  r   )	access_idr  z&secret_key=sha256)AuthorizationAccessIdr  PUT?z!application/x-www-form-urlencodedContent-Typer   r   r   )r  toncemd5zapplication/json)r  r  DELETEr>   )r  AcceptzX-COINEX-KEYzX-COINEX-SIGNzX-COINEX-TIMESTAMP)urlrv  bodyheaders)implode_paramsr   r  extract_paramsr  r  rg  r  r  r,  r   r  check_required_credentialsr"  apiKeykeysort	rawencodehashencodesecretr  	urlencodeupperjson)r  pathr   rv  r  r  r  r=   
requestUrlr  r/  r  rj  	firstPartnumPartslastPart	lastWordsnumWordslastWordr  r  r  
urlencoded	signaturepreparedStrings                            r  signcoinex.signe  s   ""40a&V
iiz*S07:S@4G		&"5"5d";<DJJL!VJJsOE((26I5zH''!|R@H s+I9~H''	8a<DHW$8w+>(hBV !% 0 0 E ( -I#t||ZSH)1C$++-)GE+&++++-KK![["! E LL'E.J		$++j>.IDKK.W"XZbcI!*!2 KKG %Vu_sZ''*M'!8#z5F'FsT^^E222$//1!%"%  U+!^^E2
 IIdkk*~2MPTP[P[2[&\^cd	%.__%6$6 eO8);53++C99U+DD//1U+!^^E2
!'#!7#!=!DV#99U+D"d*N"cJ&66N%++"55 IIdkk.&A8L	$60$(KK%.*/ V#!sZ//dOOr  httpCodereasonr  rv  r  r  c
                    Uc  g U R                  US5      n
U R                  US5      nU R                  US5      nU
S:w  d'  US:w  a|  US:w  av  UR                  5       S:w  ab  U(       d[  U R                  S-   U-   nU R	                  U R
                  S	   X5        U R                  U R
                  S
   X5        [        U5      eg )Nr  r  r  r8  Success	Succeededr    r  r  )r  r,  r  r:   throw_broadly_matched_exceptionrJ  throw_exactly_matched_exceptionr$   )r  r  r  r  rv  r  r  r  requestHeadersrequestBodyr  r  r  feedbacks                 r  handle_errorscoinex.handle_errors  s    &1x0""8Y7CKg2K9OV]VcVcVeimVmw{ww}w.H001I7]001I4Z))r  c                 2  #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eU R                  USS5      nU R	                  US5      nUc  [        U R                  S-   5      eU R                  U5      nUS   SUS.nU R                  S	X5      u  pUb  X8S
'   Ub  XHS'   U R                  U R                  X5      5      I Sh  vN n	U R                  U	S/ 5      n
U R                  U
SSS5      nU R                  XX45      $  N N?7f)a  
fetches the history of margin added or reduced from contract isolated positions

https://docs.coinex.com/api/v2/futures/position/http/list-position-margin-history

:param str symbol: unified market symbol
:param str [type]: not used by coinex fetchMarginAdjustmentHistory
:param int [since]: timestamp in ms of the earliest change to fetch
:param int [limit]: the maximum amount of changes to fetch, default is 10
:param dict params: extra parameters specific to the exchange api endpoint
:param int [params.until]: timestamp in ms of the latest change to fetch
:param int [params.positionId]: the id of the position that you want to retrieve margin adjustment history for
:returns dict[]: a list of `margin structures <https://docs.ccxt.com/#/?id=margin-loan-structure>`
Nz: fetchMarginAdjustmentHistory() requires a symbol argument
positionIdr  z? fetchMarginAdjustmentHistory() requires a positionId parameterr:   r   )r  r  r  ro  rn  r;  r  r  rH   )r   r(   r:   r  r  r  rp  (v2PrivateGetFuturesPositionMarginHistoryr"  r  parse_margin_modificationsr2  )r  r  r  rV  r;  r  r   r  r%  r  r  modificationss               r  fetch_margin_adjustment_history&coinex.fetch_margin_adjustment_history  s,     !!!>#DGG.j$jkk((}M
6<0#DGG.o$oppV$Tl$%

 22:wO$)L!$GFFt{{SZGcdd4 ~~h377dHfU00UU] 	"$ es"   DDB>DD>DD r  )__name__
__module____qualname____firstlineno__r   r  r   r  r#   r   r  r  r  dictr   r  r  r&  r   r   r0  r   r5  r?  r   rT  r[  r   r_  r    rb  r^  ry  rj  rr  r  r  r  r  r   r  r   r  r   r  floatr  r   r   r   r  r  r   r  r  r&  r2  r7  r<  rM  rQ  rT  r
   r[  r`  r	   rZ  rs  r   r  r  r{  r  r  r  r   r  r   r  r  r   r  r  r  r  r   r  r  r  r  r   r  r!   r   r)  r6  r  r"   r   r`  rW  rh  rn  rs  r   rz  r  r   r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  __static_attributes____classcell__)r  s   @r  r6   r6      s
   F
# F
P -/ }: }~ *, ;V ;&U$v, Un\|>4 > >6 >@ 68 F1 F1F F1P 6:" G17 G1 G1R ') 4S 4, @B" O?S O? O?bE Ev E EN <@d[] +I +IS +I +Ibfglbm +IZ ;= @6c @6AT @6D /1 C[ CJ

T 

6 

EX 


 
4 
, ?CQUdhqs 0H 0H 0H3 0H^a 0Hx|  ~B  yC 0Hd 13 3)j /1 )8 /1 )> 46 )8 *, 9 96	: 	:D Dv D DL XZ Tc T T& os{} P,3 P,i P,y P,Z_ P,hk P,d mqy{ l. l.I l.Y l.X] l.fi l.\ FH y$|*< yDQVK yv AER ntCy n# n` fjx|  FH E.3 E. E.9 E.I E._b E.ru E.N 9=R Y.S Y.# Y.v 59 )
c )
V 8<B U.C U. U.n BFTXgktv n=3 n=c n=ad n=`	 59tZ^gi c  TW nrsxny , 7;\`ik [ [3 [VY [ptuzp{ [& >@ !: !:N !:F =? !: !:> !:F
h 
R` 
2 37TX\eg Q=C Q=s Q=RU Q=f 8<B SPW SP4PX> SPj 8: =43 =4~Ct CV CJ DHPR !c !cS !cZ ?C2 c3 c cT =A *B' *BP] *BX $|J\ , SU : :xD
d D
F D
N` D
L CE Ns NE NI[ N FH Q# Qu QL^ Q 9=4^bkm ?# ?S ?X[ ?B <> &6s &6+ &6P @B 
=3 
=k 
=(
6 (
[ (
T? <@ )7 )7| )7V QU]_ 9=3 9= 9= 9=# 9=do 9=v:s : >BPTcgpr ?Ys ?Y# ?Y]` ?YBa
T a
X a
Q\ a
F ac .3 . .C .TW .gt .`:
t 
x 
= 
" 154VZce 5B# 5BS 5BPS 5Bjno|j} 5Bn 37TX\eg 6EC 6Es 6ERU 6Elpq|l} 6Ep 04$UYbd 3E 3EC 3Es 3Eimnyiz 3Ej
t 
V 
Oa 
B DF &=s &=J\ &=P 7;$]apt} 0Q 0QC 0QWZ 0Qjm 0Q  EI  JX  EY 0Qd
$ 
 
. 
< Z\ .3 .c .5 .` RT "# "S "H
 
4 BD 2?S 2?h BFb :w :x? ?B 8: &13 &1h &1P
t 
V 
x 
* FJX\eg FR3 FRs FRRU FRlpqylz FRP CGr 9.3 9.i 9.V[ 9.v @BPT $ #  b$T [Pzc 3 S # X\ dg  CGTXgkz~  HJ =VC =Vc =Vad =Vtw =V  OS  Tf  Og =V =Vr  r6   ); ccxt.async_support.base.exchanger   ccxt.abstract.coinexr   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   r    r!   r"   typingr#   ccxt.base.errorsr$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   ccxt.base.decimal_to_precisionr3   ccxt.base.preciser4   r6   r  r  r  <module>r     s    6 ,  u  u  u  u  u  u  u  u  * 0 - - . ' & . ) * ) , . 1 + 4 %n[VX{ n[Vr  