
    i                    \   d dl mZ d dlmZ d dlmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlm Z  d dlm!Z! d d	lm"Z" d d
lm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dlm(Z( d dlm)Z) d dlm*Z* d dl+m,Z, d dl-m.Z.  G d dee          Z/dS )    )Exchange)ImplicitAPI)Balances
CurrenciesCurrencyIntLeverage	LeveragesMarginModificationMarketNumOrderOrderRequest	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeeInterfaceTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)RateLimitExceeded)ExchangeNotAvailable)RequestTimeout)	TICK_SIZE)Precisec                       e Zd Z fdZi fdefdZi fdee         fdZd Z	d Z
dmdedefd	Zi fd
edefdZdi fdedefdZi fdZdi fd
edefdZdmdedefdZddi fd
edededee         fdZi fd
edefdZi fdefdZdmdedefdZdmdedefdZdddi fd
edededee         fdZi fdZ i fdZ!i fdZ"i fdZ#i fde$fdZ%d  Z&dmdede'fd!Z(i fd
ed"e)fd#Z*di fd
ed$e+d%e,d&e)d'e-f
d(Z.di fd
ed$e+d%e,d&e)d'e-f
d)Z/i fd*ee0         dee'         fd+Z1di fd
e2fd,Z3ddi fd-ed
ed$e+d%e,d&e-d'e-fd.Z4di fd-ed
e2fd/Z5di fd
e2fd0Z6di fd-ed
e2fd1Z7dddi fd
e2dedefd2Z8dddi fd
e2dededee'         fd3Z9dddi fd
e2dededee'         fd4Z:i fd5efd6Z;i fd5efd7Z<dmd8e=fd9Z>dmd8e=fd:Z?dmd8e=fd;Z@dddi fd
e2dedefd<ZAdi fdefd=ZBi fd
efd>ZCdmdefd?ZDdi fd@ed
e2fdAZEdi fdBed
e2fdCZFdi fdefdDZGdmdefdEZHi fd
efdFZIdmdedeJfdGZKi fd
edeJfdHZLi fd
edeJfdIZMdddi fd
e2dedefdJZNi fd
efdKZOdmdefdLZPdi fdefdMZQdi fd5ed&e)fdNZRdO ZSdddi fd
e2dedefdPZTdmd8e=deUfdQZVi fd5ed&e)dRedSedeWf
dTZXdU ZYdmd8e=fdVZZdddi fd5e2dedefdWZ[dddi fd5e2dededeeU         fdXZ\dddi fd5e2dededeeU         fdYZ]dmdefdZZ^i fd
efd[Z_i fd\Z`ddddi fd5e2d
e2dedefd]Zadmdefd^Zbi fd
ed5ed&e)fd_Zci fd
ed5efd`Zddmd8e=fdaZedi fdbefdcZfdnddZgdi fdee         dehfdeZidmdejfdfZki df fdg	Zldh Zmg dii ddfdjZndk Zoddddi fd
e2d$e2de-de-deeJ         f
dlZp xZqS )ocoinexc                    |                      t          t          |                                           i ddddddddgd	d
dddddi dd ddddddddddddddddddddddddddddddd di d!dd"dd#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1di d2dd3d4d5dd6dd7dd8dd9dd:dd;dd<dd=d4d>dd?dd@ddAd4dBddCdi dDddEddFddGddHddIddJddKddLddMddNddOddPddQddRddSddTddddddddddddU
dVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdgdhdhdidjdkdldmdndodpdqdqdqdqdqdqdqdqdqdqdqdqdqdqdrii dsdtdudtdvdtdwdtdxdtdydtdzdtd{dtd|dtd}dtd~dtddtddqddqddtddtddtdtddddtdtddqdqdqdtdtdtdi dydtddtddtddtddtddtddddddddddddddddtddqddtddtddtidtdtdtdtdtddtdtddtddtdtdtdtd	ddpdqdqdqdqdqdqdqdqdqdqd
idqdtddtdtddddtdtdtdtdtdtdtdi ddqddqddddddddddddddddtddtddddtddddddddddddddddidpi ddqddqddqddqddqddqddqddqddqddqddqddqddqddqddqddqddqdqdqdqdii ddqddtddqddtddtddqddtddtddtddqddtddtddtddtddqddtddti ddtddqddtddddddddtddddtddtddtddddqddddtddddtdqdqdtdqdqdtdqdqdi ddtddtddtddtddtddtddtddtddtddtddtddtddtddtddqddqddi ddddtddqddddddqddddddddd dqddqddddddqddqddddqdddddqdqddddddddd	d
dddddddddddiddddd didddddddiddiddddddd d!id"t          d#t
          t          t          t          t          t          t          t          t          t          t          t          d$t
          t          d%d&          S ('  Nidr,   nameCoinExversionv1	countriesCN	rateLimitg      @proT	certifiedhasCORSspotmarginswapfutureFoption	addMarginborrowCrossMarginborrowIsolatedMargincancelAllOrderscancelOrdercancelOrderscreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateOrderscreateReduceOnlyOrdercreateStopLossOrdercreateTakeProfitOrdercreateTriggerOrder	editOrderfetchBalancefetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressByNetworkfetchDepositAddressesfetchDepositsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeveragesfetchLeverageTiersfetchMarginAdjustmentHistoryfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenOrders
fetchOrderfetchOrderBookfetchPositionfetchPositions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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/deposit-withdraw-configz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-order)zfutures/user-dealsz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   )r2   v2r   gMbP?)makertakerr   g        g-C6?)BCHBTCLTCETHZECDASH)tradingfundinglimitsamountminmaxoptionsx-167673045linearfillResponseFromRequest0BSCTRC20ERC20)BEP20TRXr   )brokerId!createMarketBuyOrderRequiresPricedefaultTypedefaultSubTyperX   accountsByIdnetworkscommonCurrenciesACMActiniumprecisionMode
exceptions)232425343536213107600601602606)zip not allow visitzservice too busy)exactbroad)deep_extendsuperr,   describer)   r   r   r'   r(   r&   r"   r$   r#   )self	__class__s    Q/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/coinex.pyr   zcoinex.describe   sG   fd 3 3 < < > > MA
(MA
HMA
 tMA
 $	MA
 MA
 4MA
  !MA
"  OOO $O 	O
 %O %O TO $UO 'O "4O tO O 'O /O ,UO  0!O" t#O O$ %O& ('O( &t)O* (+O, %d-O. T/O0 1O2 &t3O4 +E5O6 )%7O8 $T9O: ';O< (=O> "4?O@ &tAOB /COD (EO O OF  GOH *:IOJ +DKOL &tMON #DOOP *4QOR $TSOT "5UOV *4WOX +DYOZ  [O\ !$]O^ %d_O` /aOb +JcOd eOf !%gO O Oh  iOj dkOl "4mOn doOp !$qOr  sOt !$uOv %ewOx )%yOz t{O| }O~ TO@ tAOB "4COD #DEOF  GOH !$IO OJ $)$( $$)'+#!%#(  ]O O O#MA
B  CMA
` ~67'I(J	  075N aMA
z  *+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  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 Tn   +Q "A  #A  *1	 
 *1  )!  )!  )!  )!  -a  -a  ,Q  ,Q  ,Q  ,Q   3A! " ;A# $ 78;<56)     2+ *A+ 5r+  0+  /	+ 
 <R+  8+  5b+  22+  5b+  4Q+  7+  3B+  1"+  ;B+  ;A+   5b!+ " 5b#+  + $ .r%+ & =a'+ ( 6r)+ * 0++ , 6q-+ . 1!/+ 0 221+ 2 6q3+ 4 75+ 6 .r7+ 8 /9+ : 3A;+ < 9!=+ > 4Q?+ @ 5bA+ B 9!C+ D :2E+  + F 34348:9:?@@B<=?@U+  +  + X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! 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! 0!F :<89469;:<?AABFG68>@@B>@@B_0! 0! 0![^  ^ 3x xmO O{MA
Z "" 
 "$$$% &! !	 [MA
z   {MA
F )59%"*-t( C! #""  GMA
h z!iMA
n YoMA
p  +---.(,,('''   +;(< ! qMA
 M M M	    returnc                    |                      |          }|                     |dg           }t          |                                          }i }t	          dt          |                    D ]}||         }||         }|                     |d          }	|                     |d          }
|                     |	          }|                     |                     |d                    }| 	                    |          }|                     |d          }|                     |d          }|                     |d          }| 	                    |          }|                     |d	          }| 	                    |          }|                     |d
          }| 	                    |          }|                     ||           |	d |d d |o|||||d d d|d d|d ddd||<   |                     ||         d          }|||nt          j        ||          }|                     ||         d          }|r|n|}|                     ||         d          }|r|n|}|                     ||         d         d         d          }|||nt          j        ||          }|                     ||         d         d         d          }|||nt          j        ||          }|                     ||         d          }|||nt          j        ||          }|                     ||         di           }||
|
d d d d|                     |d	          d d|                     |d
          d dd|o|||||d
}|||
<   |||         d<   |o|||         d<   |||         d<   |||         d<   |                     ||         dg           }|                    |           |||         d<   | 	                    |          ||         d<   | 	                    |          ||         d<   | 	                    |          ||         d         d         d<   | 	                    |          ||         d         d         d<   |S )Ndatar   assetchainwithdrawal_precisioncan_depositcan_withdrawwithdraw_tx_feedeposit_least_amountwithdraw_least_amountr   )r   depositr   )r.   	numericIdcodeinfor/   activer  r   fee	precisionr   r  r  r   r   r   r  r   )
r  r.   networkr/   r   r  r  r   r  r  r  r  )v1PublicGetCommonAssetConfig
safe_valuelistkeysrangelensafe_stringsafe_currency_codeparse_precisionparse_numberr*   
string_minsafe_numberappend)r   paramsresponser  coinsresulticoincurrency
currencyId	networkIdr  precisionStringr  
canDepositcanWithdraw	feeStringr  minNetworkDepositStringminNetworkDepositminNetworkWithdrawStringminNetworkWithdrawminFeeStringdepositAvailablewithdrawAvailableminDepositStringminWithdrawStringminPrecisionStringr   r  r  s                                  r  fetch_currencieszcoinex.fetch_currencies  si   44V<<( x44TYY[[!!q#e**%% `	] `	]A8DDzH))(G<<J((7;;I**:66D"2243C3CHNd3e3effO))/::I=AAJ//(NCCK((3DEEI##I..C&*&6&6xAW&X&X# $ 1 12I J J'+'7'7BY'Z'Z$!%!2!23K!L!Lvt,,4$!%   (8[) +!* $(#'# #
 $5#'$ $
 $6#'% %    t4  ++F4L%@@L$-9-AyyHZ[dfrHsHs#vd|YGG.8Ozz?O $tj I I0; SBS#//tX0Fy0QSXYY&2?O?W#:#:^e^p  rI  K[  _\  _\  $ 0 0h1G
1SUZ [ ['3ARAZ$<$<ahas  uM  O`  ba  ba!!%!1!1&,!L!L*9K9S__ZaZlm|  Q  [R  [R"vd|ZDDH $  $# 
  $//:PQQ#   
  $//:QRR#! !  %4%'&/ G2 #*HY'/F4L$%5%K:KF4L"&6F4L#'8F4L$??6$<<<DKK!!!#'F4L "&"3"3L"A"AF4L(,(9(9:L(M(MF4L%7;7H7HIY7Z7ZF4L"9-e48<8I8IJ[8\8\F4L":.u55r  c                     |                      |          |                     |          g}|}|d         }|d         }|                     ||          S )al  
        retrieves data on all markets for coinex
        :see: https://docs.coinex.com/api/v2/spot/market/http/list-market
        :see: 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
        r   r   )fetch_spot_marketsfetch_contract_marketsarray_concat)r   r$  promisesUnresolvedpromisesspotMarketsswapMarketss         r  fetch_marketszcoinex.fetch_marketsh  s]     ##F++''//
 &qkqk  k:::r  c                    |                      |          }|                     |dg           }g }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |d          }	|                     |          }
|                     |	          }|
dz   |z   }|                    i d|d|d	|
d
|dd d|d|	dd dddddd dddddddd dddd d |                     |d          |                     |d          d d d d d |                     | 	                    |                     |d                              |                     | 	                    |                     |d                              dd d d|                     |d           d dd d dd d dd!d |d"           |S )#Nr  r   marketbase_ccy	quote_ccy/r.   symbolbasequotesettlebaseIdquoteIdsettleIdtyper:   Tr;   r<   Fr=   r>   r  contractr   taker_fee_ratemaker_fee_ratebase_ccy_precisionquote_ccy_precisionr   pricer   
min_amountleverager   rX  costinverser   r   contractSizeexpiryexpiryDatetimestrike
optionTyper  r   createdr  )
v2PublicGetSpotMarket	safe_listr  r  r  r  r#  r"  r   r  )r   r$  r%  marketsr'  r(  rF  r.   rN  rO  rK  rL  rJ  s                r  r=  zcoinex.fetch_spot_marketsy  s   --f55* ..6266q#g,,'' :	 :	AQZF!!&(33B%%fj99F&&v{;;G**622D++G44ECZ%'FMM 2b2&2 2 	2
 $2 &2 72 D2 2 2 $2 2 %2 %2 $2  E!2" $#2$  ))&2BCC))&2BCC $"&""//0D0DTEUEUV\^rEsEs0t0tuu!..t/C/CDDTDTU[]rDsDs/t/tuu   $#! !
  $//EE# 
  $# 
  $#  $  c2 2 2 2 2 2 2f r  c                    |                      |          }|                     |dg           }g }t          dt          |                    D ]<}||         }| j        }|                     |dg           }|                     |d          }	|	dk    }
|	dk    }|                     |d          }|                     |d          }|                     |d	          }|                     |          }|                     |          }|	dk    rd
n|}|                     |          }|dz   |z   dz   |z   }t          |          }|                    i d|d|d|d|d|d|d|d|dddddddddddddd ddd|
||d         d          |d         d!         |                     d"          d d d d |                     | 	                    |                     |d#                              |                     | 	                    |                     |d$                              d%| 
                    |d          | 
                    ||d&z
            d'| 
                    |d(          d d'd d d'd d d'd)d |d*           >|S )+Nr  r   r[  contract_typer   r^  rF  rG  rH  USDTrI  :r.   rJ  rK  rL  rM  rN  rO  rP  rQ  r<   r:   Fr;   Tr=   r>   r  rR  r   r   r   1rU  rV  rW  r   r   rY  rZ  r]  )v2PublicGetFuturesMarketrf  r  r  r   r  r  r#  r   r  r"  )r   r$  r%  rg  r'  r(  entryr   	leveragessubTyper   r^  r.   rN  rO  rK  rL  rP  rM  rJ  leveragesLengths                        r  r>  zcoinex.fetch_contract_markets  s   0088, ..6266q#g,,'' B	 B	AAJE9Duj"==I&&uo>>G)F)+G!!%22B%%eZ88F&&uk::G**622D++G44E")X"5"5vvFH,,X66FCZ%'#-6F!)nnO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 6"&""//0D0DTEUEUV[]qErEr0s0stt!..t/C/CDDTDTUZ\qDrDr/s/stt   $//	1==#//	?Q;NOO! !
  $//|DD# 
  $# 
  $#  $  c2 2 2 2 2 2 2f r  NrF  c                    |                      |d          }|                     d |          }|                     |di           }|                     |d          }|                     i d|d|d|                     |          d|                     |d          d|                     |d          d	|                     |d
          d|                     |d          d|                     |d          d|                     |d          dd d|                     |d          d|d|dd dd dd dd |                     |dd          d |d|          S )NdatetickerlastrJ  	timestampdatetimehighlowbidbuy	bidVolume
buy_amountasksell	askVolumesell_amountvwapopenclosepreviousClosechange
percentageaveragevolvolume)
baseVolumequoteVolumer  )safe_integersafe_symbolr  r  safe_tickeriso8601safe_string_2)r   rt  rF  rv  rJ  ru  s         r  parse_tickerzcoinex.parse_ticker,  s   R %%ff55	!!$//266// !
f!
!
 Y//!
 D$$VV44	!

 4##FE22!
 4##FE22!
 ))&,??!
 4##FF33!
 ))&-@@!
 D!
 D$$VV44!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ ,,VUHEE)!
 !
 !
* +  	r  rJ  c                 Z   |                                   |                     |          }d|d         i}d}|d         r*|                     |                     ||                    }n)|                     |                     ||                    }|                     |d         |          S )aa  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market007_single_market_ticker
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http008_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>`
        rF  r.   Nr<   r  )load_marketsrF   v1PerpetualPublicGetMarketTickerextendv1PublicGetMarketTickerr  )r   rJ  r$  rF  requestr%  s         r  fetch_tickerzcoinex.fetch_tickerp  s     	V$$fTl
 &> 	R<<T[[RX=Y=YZZHH33DKK4P4PQQHn   &!16:::r  symbolsc                 &   |                                   |                     |          }d}|+|                     |d          }|                     |          }|                     d||          \  }}d}|dk    r|                     |          }n|                                 }|                     |d          }|                     |d          }	|                     |di           }
t          |
	                                          }i }t          dt          |                    D ]S}||         }|                     |dd|          }|d         }|                     |	|
|         d	|          }||d<   |||<   T|                     |d|          S )
a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market008_all_market_ticker
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http009_market_ticker_all
        :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   rw   r<   r  rs  rt  rJ  )rs  rt  )r  market_symbolsr  rF  handle_market_type_and_params#v1PerpetualPublicGetMarketTickerAllv1PublicGetMarketTickerAllr  r  r  r  r  safe_marketr  filter_by_array_tickers)r   r  r$  rF  rJ  
marketTypequeryr%  r  rv  tickers	marketIdsr'  r(  marketIdmarketInnerrt  s                    r  fetch_tickerszcoinex.fetch_tickers  s    	%%g..__Wa00F[[((F >>~vW]^^
E??FFHH6688Hv x00%%dF33	//$"55((	q#i..)) 		$ 		$A |H**8T4LLK *F&&!!(+( (  F  &F8#F6NN++FHgFFFr  c                     |                      |          }|                     |di           }|                     |d          S )aP  
        fetches the current integer timestamp in milliseconds from the exchange server
        :see: 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
        r  rv  )v2PublicGetTime	safe_dictr  )r   r$  r%  r  s       r  
fetch_timezcoinex.fetch_time  sD     ''// ~~h33  {333r  r   limitc                    |                                   |                     |          }|d}|d         |dd}d}|d         r*|                     |                     ||                    }n)|                     |                     ||                    }|                     |di           }|                     |di           }|                     |d	          }	|                     |||	          S )
a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-depth
        :see: 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.   r   )rF  r  intervalr<   r  depth
updated_at)r  rF  v2PublicGetFuturesDepthr  v2PublicGetSpotDepthr  r  parse_order_book)
r   rJ  r  r$  rF  r  r%  r  r  rv  s
             r  fetch_order_bookzcoinex.fetch_order_book/  s     	V$$=ETl
 

 &> 	O33DKK4P4PQQHH6 00Wf1M1MNNH4 ~~h33tWb11%%e\::	$$UFI>>>r  c                    |                      |dd          }||                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d	          }	|	d
nd}
|                     ||d |
          }|d         }|                     |d          }d }|                     |dd          }|0|                     |d          }|                     |          }||d}|                     |d          }|dk    rd}n|dk    rd}d }|d         dk    r@|                     |d          }|dk    rd}n|dk    rd}||                     |d          }n|                     |d          }|                     |||                     |          |||d ||||||d|          S )Ncreate_timer   date_msr.   order_idrX  r   rF  market_typer:   r<   rJ  
deal_moneyr  deal_fee	fee_assetr\  r*  rolerl  r   2r   rQ  sider   r     r{  )r  rv  rw  rJ  r.   orderrQ  r  takerOrMakerrX  r   r\  r  )safe_timestamp_2r  r  r  r  r  
safe_trader  )r   traderF  rv  tradeIdorderIdpriceStringamountStringr  r  r   rJ  
costStringr  feeCostStringfeeCurrencyIdfeeCurrencyCoder  r  rawSides                       r  parse_tradezcoinex.parse_trade~  s_   ~ ))%GG	))%;;I""5$//""5*55&&ug66''x88##E844%%e];;
!+!3ff&!!(FD+FF!%%e\::
**5%DD$ ,,UK@@M"55mDDO%+ C ''v663"LLS  "L&>V##''v66G!||A|''v66##E622D"Y//( " 
  
   	r  sincec                 l   |                                   |                     |          }d|d         i}|||d<   d}|d         r*|                     |                     ||                    }n)|                     |                     ||                    }|                     |d         |||          S )a  
        get the list of most recent trades for a particular symbol
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market005_market_deals
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http011_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>`
        rF  r.   Nr  r<   r  )r  rF  v1PerpetualPublicGetMarketDealsr  v1PublicGetMarketDealsparse_trades)r   rJ  r  r  r$  rF  r  r%  s           r  fetch_tradeszcoinex.fetch_trades  s     	V$$fTl
 $GG&> 	Q;;DKKQW<X<XYYHH224;;w3O3OPPH&   &!165%HHHr  c                    |                                   |                     |          }d|d         i}d}|d         r*|                     |                     ||                    }n)|                     |                     ||                    }|                     |dg           }|                     |di           }|                     ||          S )a  
        fetch the trading fees for a market
        :see: https://docs.coinex.com/api/v2/spot/market/http/list-market
        :see: 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>`
        rF  r.   Nr:   r  r   )r  rF  re  r  rm  rf  r  parse_trading_fee)r   rJ  r$  rF  r  r%  r  r'  s           r  fetch_trading_feezcoinex.fetch_trading_fee  s     	V$$fTl
 &> 	S11$++gv2N2NOOHH, 44T[[&5Q5QRRH, ~~h33a,,%%ff555r  c                    |                                   d}|                     dd|          \  }}d}|dk    r|                     |          }n|                     |          }|                     |dg           }i }t          dt          |                    D ]Y}||         }|                     |d          }|                     |dd|          }	|	d         }
| 	                    ||	          ||
<   Z|S )a  
        fetch the trading fees for multiple markets
        :see: https://docs.coinex.com/api/v2/spot/market/http/list-market
        :see: 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{   r<   r  r   rF  rJ  )
r  r  rm  re  rf  r  r  r  r  r  )r   r$  rQ  r%  r  r'  r(  rn  r  rF  rJ  s              r  fetch_trading_feeszcoinex.fetch_trading_fees_  s    	99:LdTZ[[f6>>44V<<HH. 11&99H* ~~h33q#d))$$ 	C 	CAGE''x88H%%hdDAAFH%F!33E6BBF6NNr  c                     |                      |d          }|                     ||          }|||                     |d          |                     |d          dddS )NrF  rT  rS  T)r  rJ  r   r   r  	tierBased)r  r  r"  )r   r  rF  r  rJ  s        r  r  zcoinex.parse_trading_fee  sm    ??311!!(F33%%c+;<<%%c+;<<
 
 	
r  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   r         r     )safe_timestampr"  )r   ohlcvrF  s      r  parse_ohlcvzcoinex.parse_ohlcv  s     q))UA&&UA&&UA&&UA&&UA&&
 	
r  r   c                    |                                   |                     |          }|d         |                     | j        ||          d}|||d<   d}|d         r*|                     |                     ||                    }n)|                     |                     ||                    }|                     |dg           }	|                     |	||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market006_market_kline
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http012_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
        r.   )rF  rQ  Nr  r<   r  )	r  rF  r  r   v1PerpetualPublicGetMarketKliner  v1PublicGetMarketKlinerf  parse_ohlcvs)
r   rJ  	timeframer  r  r$  rF  r  r%  r  s
             r  fetch_ohlcvzcoinex.fetch_ohlcv  s     	V$$Tl$$T_iKK
 
 $GG&> 	Q;;DKKQW<X<XYYHH224;;w3O3OPPH4 ~~h33  vy%GGGr  c                    |                                   |                     |d          }|                     |d          }d }||                     |          }|d         }n|t          | j        dz             |                     |ddg          }d|i}|                     |                     ||                    }d|i}|                     |di           }|                     |di           }	|                     |di           }
|                     |d	i           }|                     |d
i           }| 	                                }|                     |d          }| 
                    |          }|                     |	d          |d<   |                     |
d          |d<   |                     |d          }|                     |d          }t          j        ||          |d<   |||<   | 	                                }|                     |d          }| 
                    |          }|                     |	d          |d<   |                     |
d          |d<   |                     |d          }|                     |d          }t          j        ||          |d<   |||<   |                     |          S )NrJ  rF  r.   za fetchMarginBalance() fetching a margin account requires a market parameter or a symbol parameterr  r  can_transferbalanceloaninterestsell_asset_type	sell_typefreetotaldebtbuy_asset_typebuy_type)r  r  rF  r   r.   omitv1PrivateGetMarginAccountr  r  accountr  r*   
string_addsafe_balance)r   r$  rJ  r  rF  r  r%  r'  r  r  r  r  r  sellAccountsellCurrencyIdsellCurrencyCodesellDebtsellInterest
buyAccountbuyCurrencyIdbuyCurrencyCodebuyDebtbuyInterests                          r  fetch_margin_balancezcoinex.fetch_margin_balance  s   !!&(33##FH55[[((Fd|HH#DG  /R  %R  S  S  S6Hh#788h
 11$++gv2N2NOOH (#x44t^R88i44tVR00??4R88llnn))$0ABB22>BB"..t[AAF#//{CCG##D+66''+>>%0<HHF#. \\^^
((/?@@11-@@!--dJ??
6"..ujAA
7""444&&x<<$/EE
6",  (((r  c                 4   |                                   |                     |          }d|i}|                     |di           }t          |                                          }t          dt          |                    D ]}||         }|                     |          }|                     ||i           }	|                                 }
| 	                    |	d          |
d<   | 	                    |	d          |
d<   |
||<   | 
                    |          S )Nr  r  r   	availabler  frozenused)r  v1PrivateGetBalanceInfor  r  r  r  r  r  r  r  r  r   r$  r%  r'  balancescurrencyIdsr(  r+  r  r  r  s              r  fetch_spot_balancezcoinex.fetch_spot_balanceH  s   //77* (#??8VR888==??++q#k**++ 	# 	#A$QJ**:66Dooh
B??GllnnG"..wDDGFO"..wAAGFO"F4LL  (((r  c                 f   |                                   |                     |          }d|i}|                     |di           }t          |                                          }t          dt          |                    D ]}||         }|                     |          }|                     ||i           }	|                                 }
| 	                    |	d          |
d<   | 	                    |	d          |
d<   | 	                    |	d          |
d	<   |
||<   | 
                    |          S )
Nr  r  r   r	  r  r
  r  balance_totalr  )r  v1PerpetualPrivateGetAssetQueryr  r  r  r  r  r  r  r  r  r  s              r  fetch_swap_balancezcoinex.fetch_swap_balancel  s'   77??" (#??8VR888==??++q#k**++ 	# 	#A$QJ**:66Dooh
B??GllnnG"..wDDGFO"..wAAGFO#//IIGG"F4LL  (((r  c                 F   |                                   |                     |          }d|i}|                     |di           }t          dt	          |                    D ]}||         }|                     |d          }|                     |          }|                                 }	|                     |d          |	d<   |                     |d          }
|                     |d          }t          j	        |
|          |	d	<   |	||<   | 
                    |          S )
Nr  r  r   r  r	  r  r
  lockr  )r  $v1PrivateGetAccountInvestmentBalancer  r  r  r  r  r  r*   r  r  )r   r$  r%  r'  r  r(  r  r+  r  r  r
  lockeds               r  fetch_financial_balancezcoinex.fetch_financial_balance  s   <<VDD* (#??8VR88q#h--(( 		# 		#AqkG))'7;;J**:66DllnnG"..wDDGFO%%gx88F%%gv66F%0@@GFO"F4LL  (((r  c                 t   d}|                      dd|          \  }}d}|                     d|          \  }}|dn|}|                     |d          }|dk    r|                     |          S |dk    r|                     |          S |dk    r|                     |          S |                     |          S )a;  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account001_account_info         # spot
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account004_investment_balance   # financial
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account006_margin_account       # margin
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http016_asset_query       # swap
        :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>`
        NrP   r;   r<   	financial)r  handle_margin_mode_and_paramsr  r  r  r  r  )r   r$  r  
marginModes       r  fetch_balancezcoinex.fetch_balance  s     
!??PTV\]]
F
!??PVWW
F","8XXz
68,,!!,,V4446!!**6222;&&//777**6222r  c                 B    ddddddd}|                      |||          S )Nrejectedr  closedcanceled)r   r  not_deal	part_dealdonecancelr  r   statusstatusess      r  parse_order_statuszcoinex.parse_order_status  s:    " 
 
 &&999r  c                    |                      |d          }|                     |d          }|                      |d          }|                      | j        d          }d|v rdn|}|                     ||d |          }|                      |d          }|                     |          }	|	|d         }	|                     |d	          }
d }|
d
k    rd}n|
dk    rd}n|                      |d          }|                      |d          }d }|(|                     |d          }|d
k    rd}n|dk    rd}n|}|                      |d          }|dk    rd }|                     i d|                     |dd          d|d|                     |          d|d|                     |d          d| 	                    |          d|d         d|dd dd dd d	|d|                      |d          d|                      |d           d!|                      |d           d"| 
                    |d#          d$| 
                    |d%          |                      |d&          |                      |d'          |                      |d(          |                      |d)          |                      |d*          d |	|                      |d+          d,|d-|          S ).Nr)  r  rF  r   sourcer<   r  rL  r  r   r  r  r{  rQ  
order_typer  	client_id r.   r  clientOrderIdrw  rv  lastTradeTimestampupdate_timerJ  timeInForcepostOnly
reduceOnlyrX  	stopPrice
stop_pricetriggerPricetakeProfitPricetake_profit_pricestopLossPricestop_loss_pricer  	avg_pricer   deal_amountleftr  )r*  r\  )r\  r  r   filled	remainingtradesr  r  )r  r  r   r  r  r  
safe_orderr  r  r+  r"  )r   r  rF  	rawStatusrv  r  r   	orderTyper  feeCurrencyr  r  rawTyperQ  typeIntegerr1  s                   r  parse_orderzcoinex.parse_order  s   V $$UH55	''}==	##E844&&t|]CC'500FF{	!!(FD)DD((<<--m<< /K##E622a<<DD\\DD##E622D""5,77?++E6::Ka!!D((<<B M  
$$$UD*== 
] 
 Y// 
 	 

 !$"5"5e]"K"K 
 d--i88 
 fX& 
 D 
 4 
  
 $ 
 D 
 T%%eW55 
 ))%>> 
 D,,ULAA 
  t//7JKK! 
" T--e5FGG# 
$ $$UL99''{;;&&uh77&&um<<))%88'((
;;  9 
  
  
: ;  	r  r\  c                     |                                   |                     |          }|d         st          | j        dz             d|d<   |                     |dd|d|          S )a  
        create a market buy order by providing the symbol and cost
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_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>`
        r:   z9 createMarketBuyOrderWithCost() supports spot orders onlyFr   rF  r{  N)r  rF  r%   r.   create_order)r   rJ  r\  r$  rF  s        r  !create_market_buy_order_with_costz(coinex.create_market_buy_order_with_cost   ss     	V$$f~ 	ftw)ddeee6;23  5$fMMMr  rQ  r  r   rX  c                 
   |                      |          }|d         }|                     |dd          }	|                     |dd          }
|                     |d          }|                     |d          }|                     |d          }|d	k    }|                     ||d
k    |          }|                     |dd          }|                     |d          }|                     |d          }|rD|d         s#t          | j        dz   |d         z   dz             |t          | j        dz             d	|d         i}|	<d}|                     | j
        d|          }|dz   |                                 z   |d<   n|	|d<   |r|s|rr|                     |dd          |d<   |t          | j        dz             ||d<   |r|                     ||          |d<   n|r|                     ||          |d<   n|dk    rdnd}|
|                     ||
          |d<   |                     |dd          |d<   |                     ||          |d<   ||d <   |d!k    r|                     ||          |d"<   |                     ||          |d<   d }|d	k    s|
#|rd|d<   n||d#k    rd}n|d$k    rd%}nd}||d&<   |d!k    rC|
A|r||d<   n||d <   |                     ||          |d"<   |                     ||          |d<   n|d	k    r)|
'|r||d<   n||d <   |                     ||          |d<   n||d<   |d	k    r|dk    rd'}|                     |d(d)d'          \  }}|                     |d*          }|                     |d*          }|r||t          | j        d+z             |                     |          }|                     |          }|                     t)          j        ||                    }||n|}|                     ||          |d<   n3|                     ||          |d<   n|                     ||          |d<   |d!k    s|d,k    r|                     ||          |d"<   |
|                     ||
          |d<   |d	k    s|
:||r6|s|d#k    r|d!k    r|
t          | j        d-z             |rd
|d<   n|||d<   |                     |d.          }d }|                     d(|          \  }}||t1          | j        d/z             ||d.<   |                     |g d0          }|                     ||          S )1Nr<   r/  r1  r7  r9  r<  r:  r>   rF  
MAKER_ONLYposition_id
positionIdr4  r6  z/ createOrder() does not support reduceOnly for rQ  z> orders, reduceOnly orders are supported for swap markets onlyzP createOrder() requires a position_id/positionId parameter for reduceOnly ordersr.   r   r   -	stop_typer   zT createOrder() requires a position_id parameter for stop loss and take profit ordersr=  r;  r{  r  r8  r   r  r  rX  IOCFOKr  effect_typeTrI   r   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ioczA createOrder() only supports the IOC option for stop-limit orders
account_idzA createOrder() requires an account_id parameter for margin orders)r6  rQ  r4  r5  r7  r9  r<  r:  )rF  r  safe_value_2r  r  is_post_onlysafe_integer_2r#   r.   r   r   uuid16r  price_to_precisionamount_to_precisionhandle_option_and_paramsr"  r  number_to_stringparse_to_numericr*   
string_mulcost_to_precisionr  r    r  ) r   rJ  rQ  r  r   rX  r$  rF  r<   r1  r7  r<  r:  r>   isMarketOrderr5  rQ  timeInForceRawr6  r  	defaultIdr   requestSider4  r   r\  r  r  quoteAmountcostRequest	accountIdr  s                                    r  create_order_requestzcoinex.create_order_request0  s   V$$f~**6;PP%%fk>JJ	@@//&2CDD!!&(33($$]Fl4JFSS((MM
))&-@@__V\::
 	F&> t"47-^#^aghnao#o  ss  $s  t  t  t!'  3E  )E  F  F  FfTl
  %I''j)LLH#+c>DKKMM#AGK  #0GK  N	? +U +U'+'8'8a'P'P$%+DG  7M  -M  N  N  N)3&  d151H1HQ^1_1_G-..$ d373J3J6Sb3c3cG/0$(EMMaa(,0,C,CFI,V,VGL)+/+<+<V[RS+T+TGK((,(@(@(P(PGH%&1GFOw+/+B+B65+Q+Q((,(@(@(P(PGH%"H$$)*? 	=,-))'3)U22*+KK+u44*+KK*+K1<.7??y'8! 61;..*5'+'>'>vu'M'MGG$(,(@(@(P(PGH%%X%%)*;! U1;..*5,0,D,DVV,T,T)"GFO  tu}}481<@<Y<YZ`bo  rU  W[  =\  =\916''7766224 
ODL*47  6q  ,q  r  r  r'+'<'<V'D'D&*&;&;E&B&B&*&;&;G<N|]h<i<i&j&j/3/?ddk,0,B,B6;,W,W))(,(>(>vv(N(NGH%%$($<$<VV$L$L!TU]]#'#:#:65#I#I $(,(?(?	(R(R%  i&;".8.  z^u%<%<TW__[d[p*475x+xyyy ?,8)))50>GH-%%fl;;	
!??vVV
F!  +n!nooo$-GL!6  $\  $\  $\  ]  ]{{7F+++r  c                 ,   |                                   |                     |          }|                     |d          }|                     |dd          }	|                     |d          }
|                     |d          }|	du}|
du}|du}|p|}|                     ||||||          }d}|d         rg|r3|dk    r|                     |          }n|                     |          }n|dk    r|                     |          }n| 	                    |          }n|r2|dk    r| 
                    |          }n|                     |          }n|r0|r|                     |          }n}|r|                     |          }ne|r2|dk    r|                     |          }nG|                     |          }n1|dk    r|                     |          }n|                     |          }|                     |d	i           }|                     ||          S )
a	  
        create a trade order
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade001_limit_order
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade004_IOC_order
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade005_stop_limit_order
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade006_stop_market_order
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http017_put_limit
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http018_put_market
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http019_put_limit_stop
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http020_put_market_stop
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http031_market_close
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http030_limit_close
        :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 fullfilled, 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
        :param int [params.position_id]: *required for reduce only orders* the position id to reduce
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r6  r7  r9  r<  r:  Nr:   r  r  )r  rF  r  safe_number_2r"  rk  v1PrivatePostOrderStopLimitv1PrivatePostOrderStopMarketv1PrivatePostOrderLimitv1PrivatePostOrderMarket'v1PerpetualPrivatePostOrderPutStopLimit(v1PerpetualPrivatePostOrderPutStopMarket&v1PerpetualPrivatePostPositionStopLoss(v1PerpetualPrivatePostPositionTakeProfit%v1PerpetualPrivatePostOrderCloseLimit&v1PerpetualPrivatePostOrderCloseMarket#v1PerpetualPrivatePostOrderPutLimit$v1PerpetualPrivatePostOrderPutMarketr  rJ  )r   rJ  rQ  r  r   rX  r$  rF  r6  r9  stopLossTriggerPricetakeProfitTriggerPriceisTriggerOrderisStopLossTriggerOrderisTakeProfitTriggerOrderisStopLossOrTakeProfitTriggerr  r%  r  s                      r  rL  zcoinex.create_order  sc   : 	V$$__V\::
))&+~NN#//HH!%!1!1&:K!L!L%T1!5T!A#9#E (>(ZBZ%++FD$vVV&>  	V 	F7??#??HHHH#@@IIHH7??#;;GDDHH#<<WEEHH V7??#KKGTTHH#LLWUUHH. V) V#JJ7SSHH- V#LLWUUH 	Vw#'#M#Mg#V#V#'#N#Nw#W#Ww#'#K#KG#T#T#'#L#LW#U#U\ ~~h33f---r  ordersc           	         |                                   g }d}t          dt          |                    D ]}||         }|                     |d          }||}n||k    rt	          | j        dz             |                     |d          }|                     |d          }	|                     |d          }
|                     |d          }|                     |d	i           }|d
k    rt          | j        dz   |z   dz             |                     |||	|
||          }|	                    |           | 
                    |          }|d         s#t          | j        dz   |d         z   dz             |d         |                     |          d}|                     |          }|                     |dg           }g }t          dt          |                    D ]v}||         }d}|                     |d          }||dk    rd}nd}|                     |di           }||d<   |                     ||          }|	                    |           w|S )a  
        create a list of trade orders(all orders should be of the same symbol)
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade002_batch_limit_orders
        :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>`
        Nr   rJ  z; createOrders() requires all orders to have the same symbolrQ  r  r   rX  r$  r  z! createOrders() does not support z' orders, only limit orders are acceptedr:   & orders, only spot orders are acceptedr.   )rF  batch_ordersr  r  r   r  r)  )r  r  r  r  r    r.   r  r%   rk  r#  rF  jsonv1PrivatePostOrderLimitBatchr  rJ  )r   r  r$  ordersRequestsrJ  r(  rawOrderr  rQ  r  r   rX  orderParamsorderRequestrF  r  r%  r  resultsrn  r)  r  itemr  s                           r  create_orderszcoinex.create_orders>	  s    	q#f++&& 	0 	0AayH''(;;H~!X%%$TW/l%lmmm##Hf55D##Hf55D__Xx88FOOHg66E//(HbAAKw"47-P#PSW#W  [D  $D  E  E  E44XtT6SXZeffL!!,////V$$f~ 	Jtw)LLvV\~]  aI   I  J  J  JTl IIn55
 
 44W==L x44q#d))$$ 	" 	"AGEF$$UF33D199'FF#F??5&"55D#DN$$T622ENN5!!!!r  c                    |t          | j        dz             |                                  |                     |          }d|d         i}d                    |          }d}|d         r/||d<   |                     |                     ||                    }n.||d<   |                     |                     ||                    }|                     |d	g           }g }	t          d
t          |                    D ]X}
||
         }|d         rd	nd}|                     ||i           }|                     ||          }|	                    |           Y|	S )a	  
        cancel multiple orders
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade016_batch_cancel_order
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http021-0_cancel_order_batch
        :param str[] ids: order ids
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz* cancelOrders() requires a symbol argumentrF  r.   ,r:   	batch_ids	order_idsr  r   r  )r   r.   r  rF  join v1PrivateDeleteOrderPendingBatchr  &v1PerpetualPrivatePostOrderCancelBatchr  r  r  rJ  r#  )r   idsrJ  r$  rF  r  	idsStringr%  r  r  r(  rn  dataRequestr  r  s                  r  cancel_orderszcoinex.cancel_orders	  sj    >#DG.Z$Z[[[V$$fTl
 HHSMM	&> 	a#,GK <<T[[RX=Y=YZZHH#,GK BB4;;wX^C_C_``Hx x44q#d))$$ 	" 	"AGE$*6N?&&K??5+r::D$$T622ENN5!!!!r  r.   c                 $   |t          | j        dz             |                                  |                     |          }|d         s#t	          | j        dz   |d         z   dz             |d         t          |          d}	||                     ||          |	d	<   ||                     ||          |	d
<   |                     | 	                    |	|                    }
| 
                    |
di           }|                     ||          S )a  
        edit a trade order
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade022_modify_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 fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz' editOrder() requires a symbol argumentr:   z editOrder() does not support rQ  r  r.   )rF  r.   r   rX  r  )r   r.   r  rF  r%   intr^  r]  v1PrivatePostOrderModifyr  r  rJ  )r   r.   rJ  rQ  r  r   rX  r$  rF  r  r%  r  s               r  
edit_orderzcoinex.edit_order
  s2    >#DG.W$WXXXV$$f~ 	Gtw)IIFSYNZ  ^F   F  G  G  GTlb''
 
  $ 8 8 H HGH#66vuEEGG00Wf1M1MNN@ ~~h33f---r  c                    |t          | j        dz             |                                  |                     |          }|                     |d          }|d         }d|d         i}|                     |d          }d}	|                     d|          \  }	}|                     |d	d
          }
|	|t          | j        dz             ||d<   | 	                    |g d          }d}|
|
|d	<   |rX|r+| 
                    |                     ||                    }n9|                     |                     ||                    }n|r*|                     |                     ||                    }n|                     |                     ||                    }n|rdnd}|||<   |rV|r*|                     |                     ||                    }n|                     |                     ||                    }nU|r*|                     |                     ||                    }n)|                     |                     ||                    }|                     |d          }|                     ||          S )aU  
        cancels an open order
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade018_cancle_stop_pending_order
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade015_cancel_order
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade024_cancel_order_by_client_id
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade025_cancel_stop_order_by_client_id
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http023_cancel_stop_order
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http021_cancel_order
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http042_cancel_order_by_client_id
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http043_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.stop]: if stop order = True, default = False
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz) cancelOrder() requires a symbol argumentstopr<   rF  r.   rX  rC   r/  r1  zA cancelOrder() requires an account_id parameter for margin orders)r  rX  r1  r  r  )r   r.   r  rF  r  r  r  r  r    r  /v1PerpetualPrivatePostOrderCancelStopByClientIdr  )v1PrivateDeleteOrderStopPendingByClientId+v1PerpetualPrivatePostOrderCancelByClientId%v1PrivateDeleteOrderPendingByClientId%v1PerpetualPrivatePostOrderCancelStop!v1PrivateDeleteOrderStopPendingId!v1PerpetualPrivatePostOrderCancelv1PrivateDeleteOrderPendingr  rJ  )r   r.   rJ  r$  rF  r  r<   r  rj  r  r1  r  r%  	idRequestr  s                  r  cancel_orderzcoinex.cancel_orderT
  s   $ >#DG.Y$YZZZV$$vv..f~fTl
 %%fl;;	
!??vVV
F**6;PP!  +n!nooo$-GL!		&"I"I"IJJ$#0GK  	g k#SSTXT_T_`ginToToppHH#MMdkkZachNiNijjHH g#OOPTP[P[\cejPkPkllHH#II$++V]_dJeJeffHH&*4

I!#GI 	] c#II$++V]_dJeJeffHH#EEdkkRY[`FaFabbHH ]#EEdkkRY[`FaFabbHH#??GUZ@[@[\\HV ~~h//f---r  c                    |t          | j        dz             |                                  |                     |          }|d         }|                     |dd          }d|i}|d         }|                     |d          }|                     |ddg          }d}	|rV|r*|                     |                     ||                    }	n| 	                    |                     ||                    }	nZ||d<   |r*| 
                    |                     ||                    }	n)|                     |                     ||                    }	|	S )	a  
        cancel all open orders in a market
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade018_cancle_stop_pending_order
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade015_cancel_order
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http024_cancel_stop_all
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http022_cancel_all
        :param str symbol: unified market symbol of the market to cancel orders in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz- cancelAllOrders() requires a symbol argumentr.   rX  r   rF  r<   r  )r   r.   r  rF  r  r  r  (v1PerpetualPrivatePostOrderCancelStopAllr  $v1PerpetualPrivatePostOrderCancelAllv1PrivateDeleteOrderStopPendingr  )
r   rJ  r$  rF  r  rj  r  r<   r  r%  s
             r  cancel_all_orderszcoinex.cancel_all_orders
  se    >#DG.]$]^^^V$$$<%%flA>>	h

 f~vv..6FL#9:: 
	Z cHHU\^dIeIeffDDT[[QXZ`EaEabb$-GL! Z??GU[@\@\]];;DKKQW<X<XYY r  c                 v   |t          | j        dz             |                                  |                     |          }|d         }|                     |d          }|                     |d          }d|d         i}|rdnd}|||<   d}	|rV|r*|                     |                     ||                    }	nS|                     |                     ||                    }	n)| 	                    |                     ||                    }	| 
                    |	d          }
|                     |
|          S )	ak  
        fetches information on an order made by the user
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http028_stop_status
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http026_order_status
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade007_order_status
        :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  rF  r.   r  r  )r   r.   r  rF  r  r  $v1PerpetualPrivateGetOrderStopStatusr   v1PerpetualPrivateGetOrderStatusv1PrivateGetOrderStatusr  rJ  )r   r.   rJ  r$  rF  r<   r  r  r  r%  r  s              r  fetch_orderzcoinex.fetch_order/  sH    >#DG.X$XYYYV$$f~vv..66**fTl

 #'0JJD		 	R _DDT[[QXZ`EaEabb@@WV\A]A]^^33DKK4P4PQQHF ~~h//f---r  c                    |                                   |dn|}d|i}|                     |d          }|                     |d          }|                     |d          }d }	| |                     |          }	|	d         |d<   |                     d|	|          \  }
}|                     |d          }d }|                     d|          \  }}||t          | j        d	z             ||d<   |                     |d          }d }|
d
k    r|t          | j        dz             |||d<   nd|d<   d|d<   |r+| 
                    |                     ||                    }n|dk    r*|                     |                     ||                    }n|dk    r)|                     |                     ||                    }nd|d<   |dk    rV|r*|                     |                     ||                    }n|                     |                     ||                    }n[|dk    rU|r*|                     |                     ||                    }n)|                     |                     ||                    }|
d
k    rdnd}|                     |d          }|                     ||g           }|                     ||	||          S )Nd   r  r  r  r.   rF  fetchOrdersByStatusrX  z\ fetchOpenOrders() and fetchClosedOrders() require an account_id parameter for margin ordersr<   zB fetchOrdersByStatus() requires a symbol argument for swap marketsr   offsetfinishedpendingr   pagerecordsr  )r  r  r  r  rF  r  r  r    r.   r   %v1PerpetualPrivateGetOrderStopPendingr  "v1PerpetualPrivateGetOrderFinished!v1PerpetualPrivateGetOrderPendingv1PrivateGetOrderStopFinishedv1PrivateGetOrderFinishedv1PrivateGetOrderStopPendingv1PrivateGetOrderPendingrf  parse_orders)r   r)  rJ  r  r  r$  r  r  r  rF  r  r  rj  r  r%  tradeRequestr  r  s                     r  fetch_orders_by_statuszcoinex.fetch_orders_by_status  s*   EU
 vv..  0066**[[((F &tGH >>?TV\^dee
E%%fl;;	
!??@UW]^^
F!    ,J  "J  K  K  K$-GL!5,//~'2v(vwww"&"# !GH dEEdkkRY[aFbFbccZ''#FFt{{SZ\bGcGcddHHy((#EEdkkRY[aFbFbccHGFO## \#AA$++gW]B^B^__HH#==dkk'SY>Z>Z[[HH9$$ [#@@WV\A]A]^^HH#<<T[[RX=Y=YZZHn &06%9%9yyx00lB77  >>>r  c                 4    |                      d||||          S )ad  
        fetch all unfilled currently open orders
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http027_query_pending_stop
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http025_query_pending
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade013_stop_pending_order
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade011_pending_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 orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r  r  r   rJ  r  r  r$  s        r  fetch_open_orderszcoinex.fetch_open_orders  s      **9feUFSSSr  c                 4    |                      d||||          S )a'  
        fetches information on multiple closed orders made by the user
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http029_query_finished
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade010_stop_finished_order
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade012_finished_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
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r  r  r  s        r  fetch_closed_orderszcoinex.fetch_closed_orders  s      **:vueVTTTr  r  c                 ~   |                                   |                     |          }d|d         i}d|v r1|                     |d          }|                     |d          }||d<   |                     |                     ||                    }|                     |di           }|                     ||          S )a  
        create a currency deposit address
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account019_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
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        	coin_typer.   r  smart_contract_namer  )r  r*  r  r  )v1PrivatePutBalanceDepositAddressCoinTyper  r  parse_deposit_address)r   r  r$  r*  r  r  r%  r  s           r  create_deposit_addresszcoinex.create_deposit_address  s     	==&&$
 &&vy99GYYvy11F-4G)*AA$++gW]B^B^__ ~~h33))$999r  c                 >   |                                   |                     |          }d|d         i}|                     |di           }|                     |d          }|                     |d          }t          |                                          }t          |          }|I|dk    rC|t          | j	        dz   |z   dz             ||vr t          | j	        dz   |z   d	z   |z             |||d
<   |                     |                     ||                    }	|                     |	di           }
|                     |
|          }|                     | j        di           }|                     |dd          }|r|                     ||          |d<   |S )a  
        fetch the deposit address for a currency associated with self account
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account020_query_deposit_address
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        r  r.   r   r  Nr   z fetchDepositAddress() z requires a network parameterz network not supported for r  r  rX   r   T)r  r*  r  r  r  r  r  r  r   r.   r   )v1PrivateGetBalanceDepositAddressCoinTyper  r  r   	safe_boolsafe_network_code)r   r  r$  r*  r  r   r  networksKeysnumOfNetworksr%  r  depositAddressr   r   s                 r  fetch_deposit_addresszcoinex.fetch_deposit_address  s    	==&&$
 ??8Z<<""695569--HMMOO,,L))MA$5$5'2K(Kd(RUt(tuuux''#DG.G$G'$QTq$qtx$xyyy-4G)*AA$++gW]B^B^__ x4433D(CC//$,0ErJJ"&..:SUY"Z"Z" 	R(,(>(>w(Q(QN9%r  r*  c                     |                      |di           }t          |                                          }t          |          }||dk    r||d                  S ||d n|                                dS )Nr   r   r   )r.   r  )r  r  r  r  upper)r   r,  r*  r   networksCodesnetworksCodesLengths         r  safe_networkzcoinex.safe_network  s    ??8Z<<X]]__--!-00!4!9!9M!,-- ) 1tt	8I8I
 
 	
r  c                 >    |                      ||          }|d         S )Nr  )r  )r   r,  r*  r  s       r  r  zcoinex.safe_network_code  s"    ##Ix88y!!r  c                     |                      |d          }|                    d          }d }d }t          |          }|dk    r|d         dk    r|d         }|d         }n|}||                     d |          ||d dS )Ncoin_addressrk  r   r   cfx)r  r*  addresstagr  )r  splitr  r  )r   r  r*  coinAddresspartsr  r  partsLengths           r  r  zcoinex.parse_deposit_address  s     &&~~FF!!#&&%jj??uQx500AhG(CC!G"//h??
 
 	
r  c                 :   |                                   d}|d}|dd}| |                     |          }|d         |d<   d}|                     d||          \  }}|dk    r|t          | j        d	z             |d
k    }|                     |d          }	d}
|                     d|          \  }
}|
4|	t          | j        dz             |	|d<   |                     |d          }d}|r6|||d<   d|d<   | 	                    | 
                    ||                    }n.d|d<   |                     | 
                    ||                    }|rdnd}|                     |d          }|                     ||g           }|                     ||||          S )ay  
        fetch all trades made by the user
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http013_user_deals
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade014_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 trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nr  r   )r  r  r.   rF  rm   r:   z@ fetchMyTrades() requires a symbol argument for non-spot marketsr<   rX  zC fetchMyTrades() requires an account_id parameter for margin trades
start_timer  r   r  r  r  )r  rF  r  r   r.   r  r  r    r  $v1PerpetualPrivateGetMarketUserDealsr  v1PrivateGetOrderUserDealsr  rf  r  )r   rJ  r  r  r$  rF  r  rQ  r<   rj  r  r%  r  r  rC  s                  r  fetch_my_tradeszcoinex.fetch_my_trades  s    	=E
 
 [[((F &tGH99/6SYZZf6>>fn#DG.p$pqqq%%fl;;	
!??QWXX
F!  +p!pqqq$-GL!YYv|44F 	U (-%GFO@@WV\A]A]^^HHGFO66t{{7F7S7STTHR %)4yyfx00lB77  >>>r  c                    |                                   d}|                     |ddd          \  }}|dk    }|                     |          }i }d}|od}t          |t                    r5t          |          }|dk    rt          | j        dz             |d         }n|}|                     |          }|d	         |d
<   n|rt          | j        dz             |rd|d<   | 
                    |dd          |d<   d}	|dk    r*|                     |                     ||                    }	n)|                     |                     ||                    }	|                     |	dg           }
g }t          dt          |
                    D ]1}|                    |                     |
|         |                     2|                     |d|d          S )a  
        fetch all open positions
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033_pending_position
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033-0_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 'perpetualPrivateGetPositionPending' or 'perpetualPrivateGetPositionFinished' default is 'perpetualPrivateGetPositionPending'
        :param int [params.side]: *history endpoint only* 0: All, 1: Sell, 2: Buy, default is 0
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
        Nrs   method$v1PerpetualPrivateGetPositionPending%v1PerpetualPrivateGetPositionFinishedr   zD fetchPositions() symbols argument cannot contain more than 1 symbolr   r.   rF  zA fetchPositions() requires a symbol argument for closed positionsr  r  r  r  rJ  F)r  r_  r  
isinstancer  r  r    r.   rF  r   r  r  r  r  r  r  r#  parse_positionfilter_by_array_positions)r   r  r$  defaultMethod	isHistoryr  rF  rJ  symbolsLengthr%  positionr'  r(  s                r  fetch_positionszcoinex.fetch_positions  s    	 $ = =fFVX`  cI  !J  !Jv"&MM	%%g..F'4(( ! #G 1$$$TW/u%uvvv  [[((F &tGH w'2u(uvvv 	C"GG"//BBGFOBBB@@WV\A]A]^^HHAA$++gW]B^B^__Hx ??8VR88q#h--(( 	D 	DAMM$--hqk6BBCCCC--fhOOOr  c                     |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |dg           }|                     |d         |          S )a  
        fetch data on a single open contract trade position
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033_pending_position
        :param str symbol: unified market symbol of the market the position is held in, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
        rF  r.   r  r   )r  rF  r  r  rf  r  r   rJ  r$  rF  r  r%  r  s          r  fetch_positionzcoinex.fetch_position  s     	V$$fTl
 <<T[[RX=Y=YZZx ~~h33""47F333r  c                    |                      |d          }|                     ||d d          }|d         }|                     |d          }|                     |d          }|dk    rdnd}|                      |d	          }|                      |d
          }	|                      |d          }
|                     |d          }|                     |d          }|dk    rdnd}|                     |d          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }t          j        ||          }t          j        d|          }|                     i d|d|d|d|                     |          d|d|d|                     |	          d|                     |
          dd d|d |                     |d           d!d d"d d|d#d d$|d%| 	                    |          d |                     |          |                     |          |                     |          |                     |          |                     |          |                     |          d | 
                    |                      |d&                    | 
                    |                      |d'                    d(
          S ))NrF  r<   rJ  rP  rQ  r   isolatedcross	liq_price
open_priceprofit_unrealr   r  shortlongr3  mainten_margin_amountmainten_marginmargin_amountr[  open_valrl  r  r.   notionalr  liquidationPrice
entryPriceunrealizedPnlr  	contractsr_  	markPrice	lastPricehedgedrv  rw  r=  r;  )
lastUpdateTimestampmaintenanceMarginmaintenanceMarginPercentage
collateralinitialMargininitialMarginPercentager[  marginRatior<  r:  )r  r  r  r"  r  r*   
string_divsafe_positionr   r  	omit_zero)r   r  rF  r  rJ  rQ  marginModeIntegerr  r  r	  r
  r  sideIntegerr  rv  r  r  r  r[  r  r  r  s                         r  r  zcoinex.parse_positionF  s   l ##Hh77!!(FD&AA!&&x??
 --h??$5$:$:ZZ
++HkBB%%h==
((?CC$$Xx88	''&99&!++ww&''-@@	 ,,X7NOO&*&6&6xAQ&R&R#%%h@@
##Hj99##Hj99*8X>>")"4S("C"C!! #
H#
*#
 f#
 ))(33	#

 *#
  0#
 $++J77#
 T..}==#
 $#
 #
 D,,V^DD#
 #
 #
 D#
 d#
  !#
" Y//##
$ $(!%!2!23D!E!E+/+<+<=X+Y+Y++J77!..}=='+'8'89P'Q'Q))(33!^^D,<,<XGX,Y,YZZ#~~d.>.>xI\.].]^^7#
 #
 #
   	r  r  c                 Z   |t          | j        dz             |                                }|dk    r|dk    rt          | j        dz             |                                  |                     |          }|d         dk    rt          | j        dz             d}|dk    rd	}n|dk    rd
}|                     |d          }|                     |d         d         dd          }|                     |d|          }|t          | j        dz             |t          | j        dz             |dk     s||k    r-t          | j        dz   t          |          z   dz   |z             |d         t          |          |d}	| 	                    | 
                    |	|                    S )a  
        set margin mode to 'cross' or 'isolated'
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http014_adjust_leverage
        :param str marginMode: 'cross' or 'isolated'
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        Nz+ setMarginMode() requires a symbol argumentr  r  z@ setMarginMode() marginMode argument should be isolated or crossrQ  r<   z- setMarginMode() supports swap contracts onlyr   r  r[  r   r   r  position_typez. setMarginMode() requires a leverage parameterzk setMarginMode() requires a position_type parameter that will transfer margin to the specified trading pairr  z2 setMarginMode() leverage should be between 3 and  for r.   rF  r[  r  )r   r.   lowerr    r  rF  r!   r  str*v1PerpetualPrivatePostMarketAdjustLeverager  )
r   r  rJ  r$  rF  defaultPositionTyper[  maxLeveragepositionTyper  s
             r  set_margin_modezcoinex.set_margin_mode  s    >#DG.[$[\\\%%''
##
g(=(=TW'iijjjV$$&>V##DG&UUVVV"##"#7"""#$$VZ88''x(8(DeSQQ((BUVV#DG.^$^___#DG  /\  %\  ]  ]  ]qLLh44TW'[[^abm^n^nnqxx  |B  B  C  C  CTlH)
 

 >>t{{7TZ?[?[\\\r  r[  c                    |t          | j        dz             |                                  |                     |          }|d         st	          | j        dz             d}|                     d|d          \  }}d}|dk    rd}n|dk    rd	}|                     |d
         d         dd          }|                     |d
         d         dd          }||k     s||k    r@t          | j        dz   t          |          z   dz   t          |          z   dz   |z             |d         t          |          |d}	| 	                    | 
                    |	|                    S )a  
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http014_adjust_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 argumentr<   z+ setLeverage() supports swap contracts onlyr   r  r  r   r  r   r[  r   r   r  z* setLeverage() leverage should be between z and r  r.   r  )r   r.   r  rF  r!   r  r  r    r   r!  r  )
r   r[  rJ  r$  rF  r  r$  minLeverager#  r  s
             r  set_leveragezcoinex.set_leverage  s    >#DG.Y$YZZZV$$f~ 	UDG&SSTTT
!??vW^__
F##LL7""L''x(8(DeQOO''x(8(DeSQQ{"";(>(>TW'SSVYZeVfVffippsv  xC  tD  tD  D  GN  N  QW  W  X  X  XTlH)
 

 >>t{{7TZ?[?[\\\r  c                     |                                   |                     |          }|                     |di           }|                     ||d          S )a
  
        retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http007_market_limit
        :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
        r  N)r  %v1PerpetualPublicGetMarketLimitConfigr  parse_leverage_tiers)r   r  r$  r%  r  s        r  fetch_leverage_tierszcoinex.fetch_leverage_tiers  sX     	==fEE$ x44((w===r  c                 J   g }d}t          dt          |                    D ]}||         }|                     |d          }|                    |dz   |d         r|d         n|d         |||                     |d          |                     |d          |d           |}|S )Nr   r   r   rK  rL  r  )tierr*  minNotionalmaxNotionalmaintenanceMarginRater#  r  )r  r  r"  r#  r  )r   r  rF  tiersr/  jbracketr0  s           r  parse_market_leverage_tiersz"coinex.parse_market_leverage_tiers  s    q#d))$$ 	& 	&A1gG**7A66KLLA.4X.>SF6NNF7O**)-)9)9'1)E)E#00!<<     &KKr  c                    |                                   |                     |          }|d         |                     ||          |d}|                     |                     ||                    }|                     |d          }|                     |d          }	|                     |                     ||          |                     |          |	d          S )Nr.   )rF  r   rQ  r  message)r   r)  )	r  rF  r^  *v1PerpetualPrivatePostPositionAdjustMarginr  r  r  parse_margin_modificationr   )
r   rJ  r   addOrReducer$  rF  r  r%  r  r)  s
             r  modify_margin_helperzcoinex.modify_margin_helper'  s    V$$Tl..vv>>
 

 BB4;;wX^C_C_``t ~~h//!!(I66{{499$GG''//J
 J
   	r  c                 b   |                      |d          }|                      |d          }|                     |ddd          }||                     ||d d          |dk    rdnd	d
|                     |d          |                     |d          |d         d ||                     |          d
S )NrF  rQ  r   r3    r<   rl  addreducer  margin_changeposition_amountrL  )
r  rJ  rQ  r  r   r  r  r)  rv  rw  )r  safe_integer_product_2r  r"  r  )r   r  rF  r  rQ  rv  s         r  r9  z coinex.parse_margin_modificationp  s    T ##D(33f--//fmTRR	&&xvFF"ckkEE$&&t_==%%d,=>>7O"Y//
 
 	
r  c                 2    |                      ||d|          S )a  
        add margin
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http032_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   r;  r   rJ  r   r$  s       r  
add_marginzcoinex.add_margin       ((FCCCr  c                 2    |                      ||d|          S )a  
        remove margin from a position
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http032_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  rD  rE  s       r  reduce_marginzcoinex.reduce_margin  rG  r  c                    |t          | j        dz             |dn|}|                                  |                     |          }|d         |d}|||d<   |                     |                     ||                    }|                     |di           }|                     |dg           }	g }
t          d	t          |	                    D ]}|	|         }| 	                    |d
          }| 
                    |d          }|                     |          }|
                    |||||                     |          |                     |d          |                     |d          d           |
S )a`  
        fetch the history of funding payments paid and received on self account
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http034_funding_position
        :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.   )rF  r  r  r  r  r   r   r  rP  r   )r  rJ  r  rv  rw  r.   r   )r   r.   r  rF  $v1PerpetualPrivateGetPositionFundingr  r  r  r  r  r  r  r#  r  r"  )r   rJ  r  r  r$  rF  r  r%  r  
resultListr'  r(  rn  rv  r+  r  s                   r  fetch_funding_historyzcoinex.fetch_funding_history  s    >#DG.a$abbbEV$$Tl
 
 $)GL!<<T[[RX=Y=YZZ8 x44__T9b99
q#j//** 	 	AqME++E6::I))%99J**:66DMM & LL33&&um<<**5)<<      r  c                    |                                   |                     |          }|d         st          | j        dz             d|d         i}|                     |                     ||                    }|                     |di           }|                     |di           }|                     |d          }||d<   |                     ||          S )	a  
        fetch the current funding rate
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http008_market_ticker
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
        r<   z0 fetchFundingRate() supports swap contracts onlyrF  r.   r  rt  rs  rv  )	r  rF  r!   r.   r  r  r  r  parse_funding_rate)	r   rJ  r$  rF  r  r%  r  rt  rv  s	            r  fetch_funding_ratezcoinex.fetch_funding_rate'  s     	V$$f~ 	ZDG&XXYYYfTl
 88Wf9U9UVVB x44x44%%dF33	'{&&vv666r  c                    |                      |d          }|                     |d          }|                      |d          dz  dz  }||z   dz  }t          t          |                    dz  }i d|d|                     d |          d|                     |d	          d
|                     |d          dd dd d|d|                     |          d|                     |d          d|d|                     |          d|                     |d          dd dd d|                     |d          dd dd S )Nrv  funding_time<   r=  i6 r  rJ  r  
sign_price
indexPriceindex_priceinterestRateestimatedSettlePricerw  fundingRatefunding_rate_nextfundingTimestampfundingDatetimenextFundingRatefunding_rate_predictnextFundingTimestampnextFundingDatetimepreviousFundingRatefunding_rate_lastpreviousFundingTimestamppreviousFundingDatetime)r  r  r  roundr  r"  r  )r   rR  rF  rv  fundingDeltafundingHourr[  s          r  rO  zcoinex.parse_funding_rate]  s   6 %%h<<	99X{33((>BBRG$N </7:u[1122W<
H
d&&tV44
 ))(LAA
 $**8]CC	

 D
 #D
 
 Y//
 4++H6IJJ
  0
 t||,<==
 t//:PQQ
 #D
 "4
 "4#3#3H>Q#R#R
  '!
" &t#
 	
r  c                 4   |                                   |                     |          }d}|J|                     |d          }|                     |          }|d         st	          | j        dz             |                     |          }|                     |di           }|                     |di           }|                     |d          }g }	t          |	                                          }
t          dt          |
                    D ]q}|
|         }|                    d          d	k    rN|                     |ddd          }||         }||d
<   |	                    |                     ||                     r|                     |	d|          S )a  
         *  @method
        fetch the current funding rates
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http009_market_ticker_all
        :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   r<   z1 fetchFundingRates() supports swap contracts onlyr  rt  rs  _rv  rJ  )r  r  r  rF  r!   r.   r  r  r  r  r  r  findr  r#  rO  filter_by_array)r   r  r$  rF  rJ  r%  r  r  rv  r'  r  r(  r  r  rt  s                  r  fetch_funding_rateszcoinex.fetch_funding_rates  s    	%%g..__Wa00F[[((F&> _*] ]^^^;;FCCD x44//$"55%%dF33	((	q#i..)) 	L 	LA |H}}S!!R''"..xtVLL *&/{#d55fkJJKKK##FHg>>>r  c                 V   |                      ||          \  }}|                     |           |                                  |                     |          }|                     |d          }|                     |d          }|r|dz   |z   }|d         |t          |                     |                    dd}||                     |          |d<   | 	                    | 
                    ||                    }	|                     |	di           }
|                     |
|          S )	a/  
        make a withdrawal
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account015_submit_withdraw
        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.network]: unified network code
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        r  rk  r.   onchain)r  r  actual_amounttransfer_methodNr  r  )handle_withdraw_tag_and_paramscheck_addressr  r*  safe_string_upperr  floatr`  network_code_to_id v1PrivatePostBalanceCoinWithdrawr  r  parse_transaction)r   r  r   r  r  r$  r*  networkCoder  r%  transactions              r  r   zcoinex.withdraw  s3    99#vFFV7###==&&,,VY??69-- 	*mc)G!$#"4#8#8#@#@AA(	
 
 "-1-D-D[-Q-QG)*88Wf9U9UVV& nnXvr::%%k8<<<r  c           	      F    ddddddddd}|                      |||          S )Nr  failedr"  ok)auditpass
processing
confirmingnot_passr&  finishfailr'  r(  s      r  parse_transaction_statuszcoinex.parse_transaction_status  s@    ##  	
 	
 &&999r  c           
         |t          | j        dz             |                                  d}|                     |dd          \  }}|r|                     d|||d|d          S |d}|                     |          }|d	         |d
d}|||d<   |                     d||          \  }}|                     |                     ||                    }| 	                    |d          }	| 	                    |	dg           }
g }t          d
t          |
                    D ]}|
|         }|                     |d          }|                     ||dd          }|                     |d          }|                    |||                     |d          ||                     |          d           |                     |d          }|                     ||d         ||          S )a  
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http038_funding_history
        fetches historical funding rate prices
        :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 [availble 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 argumentFra   paginate8hr=  r  r.   r   )rF  r  r  r  end_timer  r  rF  r<   r   funding_rate)r  rJ  rY  rv  rw  rv  rJ  )r   r.   r  r_  "fetch_paginated_call_deterministicrF  handle_until_option(v1PerpetualPublicGetMarketFundingHistoryr  r  r  r  r  r  r  r#  r"  r  sort_byfilter_by_symbol_since_limit)r   rJ  r  r  r$  r  rF  r  r%  r  r'  ratesr(  rn  r  symbolInnerrv  sorteds                     r  fetch_funding_rate_historyz!coinex.fetch_funding_rate_history  s&    >#DG.e$efff88AZ\fgg& 	@::;TV\^cejlprxz~=EV$$Tl
 
 $)GL!22:wOO@@WV\A]A]^^( x00y"55q#f++&& 	 	A1IE''x88H**8VT6JJK++E6::ILL%#//~FF& LL33      e[11009I5RWXXXr  c                    |                      |dd          }|                     |d          }|                     |d          }|t          |          dk     rd }|                     |d          }|t          |          dk     rd }|                     |d          }|                     ||          }|                     |d          }	d|v rd	nd
}
|                     |                     |d                    }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|dk    }d }d }|
d
k    rd}|}n|}|                     |          |d}i d|d|d|d|	d| 	                    |	          d| 
                    |          d|dd dd d|d|d|d|
d |                     |          d!|d|d"d |d |d#S )$Ncoin_withdraw_idcoin_deposit_idr  remarkr   tx_idr  r  
withdrawalr  r)  r  rp  tx_feerq  localr   r  r  r.   txidrv  rw  r  r  	addressToaddressFromr  tagTotagFromrQ  r   r*  updated)r  commentinternal)r  r  r  r  r  r  r  r"  r   r  network_id_to_code)r   rz  r*  r.   r  r  r  r+  r  rv  rQ  r)  r,  r   feeCosttransferMethodr  r  r  r  s                       r  rx  zcoinex.parse_transactionV  s   l -?ARSS"";??{H55?3xx!||{G444yy1}}%%k;??
&&z8<<'']CC	 2k A A||	..t/?/?X/V/VWW$$[2GHH	!!+??"";99))+7HII!W,	9GII!K%%g..
 

K
"
 D
 	

 Y//
 t..y99
 w
 
 4
 3
 Y
 {
 D
 d''//
 
  f!
" t#
$  )
 
 
 	
r  fromAccount	toAccountc                 6   |                                   |                     |          }|                     ||          }||d         d}d}	|dk    r5|dk    r/d|d<   |                     |                     ||                    }	n|dk    r5|dk    r/d|d<   |                     |                     ||                    }	n|                     | j        d	i           }
|                     |
||          }|                     |
||          }t          |          |d
<   t          |          |d<   | 	                    |                     ||                    }	|                     | 
                    |	|          |                     |          ||d          S )a  
        transfer currency internally between wallets on the same account
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account014_balance_contract_transfer
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account013_margin_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
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        r.   )r   r  Nr:   r<   intransfer_sideoutr   from_account
to_account)r   r  r  )r  r*  currency_to_precision$v1PrivatePostContractBalanceTransferr  r  r   r  r  v1PrivatePostMarginTransferparse_transferr   )r   r  r   r  r  r$  r*  amountToPrecisionr  r%  r   fromIdtoIds                r  r   zcoinex.transfer  s    	==&& 66tVDD'!$
 
 6!!	V(;(;'+GO$@@WV\A]A]^^HHV##)v*=*=',GO$@@WV\A]A]^^HH??4<LLL%%lKMMF##L)YGGD '*&kkGN#$'IIGL!77GV8T8TUUH {{4..xBB''(9::&"E
 E
   	r  c                 :    ddd}|                      |||          S )Nr}  )r   SUCCESSr'  r(  s      r  parse_transfer_statuszcoinex.parse_transfer_status  s.    
 
 &&999r  c                    |                      |d          }|                     |d          }d }d }|dk    rd}d}n |dk    rd}d}n|dk    rd}d}n
|d	k    rd}d}|                     |d
          }|                     ||          }||                     |d          ||                     |          ||                     |d          |||                     |                     |dd                    d	S )N
created_attransfer_typetransfer_outr<   r:   transfer_inINr;   OUTr  r.   r   r  r)  )	r  r.   rv  rw  r*  r   r  r  r)  )r  r  r  r  r  r"  r  r  )	r   r   r*  rv  transferTyper  r  r+  currencyCodes	            r  r  zcoinex.parse_transfer  s3   6 '',??	''/BB	>)) KII]** KIIT!! K IIU"""KI%%h88
..z8DD##Hd33"Y//$&&x::&"001C1CHfV^1_1_``

 

 
	
r  c                 x   |                                   d}ddi}|                     |d          }|||d<   | |                     |          }|d         |d<   |||d<   |||d<   nd|d<   |                     |d          }d}|                     d	|          \  }}d}	|*|                     |                     ||                    }	n)|                     |                     ||                    }	|                     |	d
i           }
| 	                    |
dg           }| 
                    ||||          S )a  
        fetch a history of internal transfers made on an account
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account025_margin_transfer_history
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account024_contract_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  transfers structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
        Nr  r   r.   r  r  r  r  r}   r  r  )r  r  r*  r  r  !v1PrivateGetMarginTransferHistoryr  #v1PrivateGetContractTransferHistoryr  rf  parse_transfers)r   r  r  r  r$  r*  r  r  r  r%  r  	transferss               r  fetch_transferszcoinex.fetch_transfers.  sk    	A
   00"GFO}}T**H'~GG$)GL!$GG"GG66**
!??@PRXYY
F!==dkk'SY>Z>Z[[HH??GU[@\@\]]HZ x44NN4B77	##IxFFFr  c                    i }d}|4|                                   |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     |d          }t          |t                    s|                     |dg           }|                     ||||          S )a6  
        fetch all withdrawals made from an account
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account026_withdraw_list
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch withdrawals for
        :param int [limit]: the maximum number of withdrawals structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr.   r  Limitr  )r  r*  v1PrivateGetBalanceCoinWithdrawr  r  r  r  parse_transactions	r   r  r  r  r$  r  r*  r%  r  s	            r  fetch_withdrawalszcoinex.fetch_withdrawals  s     }}T**H#+D>GK $GG77GV8T8TUUN x00$%% 	5??444D&&tXueDDDr  c                    i }d}|4|                                   |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     |d          }t          |t                    s|                     |dg           }|                     ||||          S )a*  
        fetch all deposits made to an account
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account009_deposit_list
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch deposits for
        :param int [limit]: the maximum number of deposits structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr.   r  r  r  )r  r*  v1PrivateGetBalanceCoinDepositr  r  r  r  r  r  s	            r  fetch_depositszcoinex.fetch_deposits  s     }}T**H#+D>GK $GG66t{{7F7S7STTN x00$%% 	5??444D&&tXueDDDr  c           
      Z   |                      |d          }|                     ||d d          }|                     ||d                   }|                     ||d                   }|d         |d         |                     |d          |d         |                     |d          d	d d |d
	S )NrF  r:   rN  rO  rJ  rK  day_raterL  i \&)	rJ  rK  baseRaterL  	quoteRateperiodrv  rw  r  )r  r  r  r"  )r   r  rF  r  baseInfo	quoteInfos         r  parse_isolated_borrow_ratez!coinex.parse_isolated_borrow_rate  s    " ##D(33!!(FD&AA??4)9::OOD&*;<<	X&6N((:>>G_)))Z@@

 

 
	
r  c                    |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |di           }|                     ||          S )a  
        fetch the rate of interest to borrow a currency for margin trading
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
        :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
        :returns dict: an `isolated borrow rate structure <https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure>`
        rF  r.   r  )r  rF  v1PrivateGetMarginConfigr  r  r  r  s          r  fetch_isolated_borrow_ratez!coinex.fetch_isolated_borrow_rate$  s     	V$$fTl
 00Wf1M1MNN* x44..tV<<<r  c                 &   |                                   |                     |          }|                     |dg           }g }t          dt	          |                    D ]0}|                    |                     ||                              1|S )a  
        fetch the borrow interest rates of all currencies
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `isolated borrow rate structures <https://github.com/ccxt/ccxt/wiki/Manual#isolated-borrow-rate-structure>`
        r  r   )r  r  r  r  r  r#  r  )r   r$  r%  r  r  r(  s         r  fetch_isolated_borrow_ratesz"coinex.fetch_isolated_borrow_ratesI  s     	0088. x44q#d))$$ 	C 	CALL88aAABBBBr  c                    |                                   i }d }| |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     |di           }	|                     |	dg           }
|                     |
|          }|                     ||||          S )Nr.   rF  r  r  )r  rF  v1PrivateGetMarginLoanHistoryr  r  parse_borrow_interestsfilter_by_currency_since_limit)r   r  rJ  r  r  r$  r  rF  r%  r  rowsr  s               r  fetch_borrow_interestzcoinex.fetch_borrow_interestn  s    [[((F &tGH$GG55dkk'66R6RSS> x44tVR00..tV<<228T5%PPPr  c                 L   |                      |d          }|                     ||d d          }|                      |d          }|                     |d          }|                      |d          }|                      |d          }t          j        ||          }|dk    rd }d |dd |                     |                      |d	                    |                     |          |                     |d
          |                     |          ||                     |          |dS )Nr  r:   rJ  expire_timeunflat_amountloan_amountr   r  r  r  )r  rJ  r  
marginTyper*  r  rW  amountBorrowedrv  rw  r  )	r  r  r  r*   
string_subr  r   r"  r  )	r   r  rF  r  rJ  rv  unflatAmount
loanAmountr  s	            r  parse_borrow_interestzcoinex.parse_borrow_interest  s.     ##D-88!!(FD&AA!!&(33''m<<	''o>>%%dM::
%lJ??3H$//0@0@{0S0STT))(33 ,,T:>>"//
;;"Y//
 
 	
r  c                    |                                   |                     |          }|                     |          }|d         |d         |                     ||          d}|                     |                     ||                    }|                     |di           }	|                     |	|          }
|                     |
||d          S )a  
        create a loan to borrow margin
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account017_margin_loan
        :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
        :returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
        r.   rF  r  r   r  r   rJ  )r  rF  r*  r  v1PrivatePostMarginLoanr  r  parse_margin_loan)r   rJ  r  r   r$  rF  r*  r  r%  r  rz  s              r  borrow_isolated_marginzcoinex.borrow_isolated_margin  s     	V$$==&&Tl!$00v>>
 

 //GV0L0LMM x44,,T8<<{{;)
 )
   	r  c                 z   |                                   |                     |          }|                     |          }|d         |d         |                     ||          d}|                     |                     ||                    }|                     ||          }	|                     |	||d          S )aY  
        repay borrowed margin and interest
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account018_margin_flat
        :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.loan_id]: extra parameter that is not required
        :returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
        r.   r  r  )r  rF  r*  r  v1PrivatePostMarginFlatr  r  )
r   rJ  r  r   r$  rF  r*  r  r%  rz  s
             r  repay_isolated_marginzcoinex.repay_isolated_margin  s     	V$$==&&Tl!$00v>>
 

 //GV0L0LMM ,,Xx@@{{;)
 )
   	r  c                 f    |                      |d          |                     d |          d d d d |dS )Nloan_id)r.   r*  r   rJ  rv  rw  r  )r  r  )r   r  r*  s      r  r  zcoinex.parse_margin_loan  sH    " ##D)44//h??
 
 	
r  codesc                    |                                   i }|.t          |          }|dk    r|                     |d          |d<   |                     |                     ||                    }|                     ||          S )a  
        fetch deposit and withdraw fees
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market010_asset_config
        :param str[]|None codes: list of unified currency codes
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `fees structures <https://docs.ccxt.com/#/?id=fee-structure>`
        Nr   r   r  )r  r  r  r  r  parse_deposit_withdraw_fees)r   r  r$  r  codesLengthr%  s         r  fetch_deposit_withdraw_feesz"coinex.fetch_deposit_withdraw_fees   s     	e**Ka'+ua'@'@$44T[[&5Q5QRR6 //%@@@r  c                 d   i }|                      |          }|                     |d          }t          |                                          }t	          dt          |                    D ]E}||         }|                    d          }	|||                  }
|                     |
d          }|                     |          }|                     |d          }|| 	                    ||          r|                     ||          }|| 
                    i           ||<   |
||         d         |<   |                     |	d          }|                     |
d          }||d	nd d
}d d d
}|+|                     |          }||d||         d         |<   /|||         d<   |||         d<   Gt          |                                          }t	          dt          |                    D ]>}||         }|                     |          }|                     ||         |          ||<   ?|S )Nr  r   rR  r  r  r  r   r  F)r  r  )r   r  r   r   r  )market_codesr  r  r  r  r  r  r  safe_currencyin_arraydeposit_withdraw_feer  r*  $assign_default_deposit_withdraw_fees)r   r%  r  currencyIdKeydepositWithdrawFeesr  r  r(  rn  
splitEntryfeeInfor+  r*  r  depositWithdrawFeer,  withdrawFeewithdrawResultdepositResultry  depositWithdrawCodess                        r  r  z"coinex.parse_deposit_withdraw_feesK  so    !!%((x00499;;''q#k**++ 	I 	IANES))J;q>*G))'7;;J))*55H##Hf55D4==u#=#=%)__5H$%O%O"%-040I0I"0M0M'-;B#D)&1%8 ,,Z;;	"oog7HII&,7,C%%$" "
  "&! ! ("&"9"9)"D"DK$2#0J J'-j9+FF
 =K'-j9;H'-i8#$7$<$<$>$>??q#23344 	w 	wA'*D}}T**H(,(Q(QRefjRkmu(v(v%%""r  c                    |                                   |                     |          }d}|+|                     |d          }|                     |          }d}|                     d||          \  }}|dk    rt          | j        dz             |                     |          }|                     |dg           }| 	                    ||d|          S )a  
        fetch the set leverage for all contract and margin markets
        :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
        :param str[] [symbols]: a list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `leverage structures <https://docs.ccxt.com/#/?id=leverage-structure>`
        Nr   rg   r:   z3 fetchLeverages() supports spot margin markets onlyr  rF  )
r  r  r  rF  r  r%   r.   r  rf  parse_leverages)r   r  r$  rF  rJ  r  r%  ro  s           r  fetch_leverageszcoinex.fetch_leveragesv  s     	%%g..__Wa00F[[((F
!??@PRXZ`aa
Ftw)^^___0088. NN8VR88	##Iw*MMMr  c                     |                      |d          }|                     |d          }||                     ||d d          d ||dS )NrF  r[  r:   )r  rJ  r  longLeverageshortLeverage)r  r  r  )r   r[  rF  r  leverageValues        r  parse_leveragezcoinex.parse_leverage  s^    ##Hh77))(J??&&xvFF)*
 
 	
r  c                     |                      | j        d          }|                     |dd          }d}t          t          |                               |||          \  }}||dk    s|du rd}||gS )aZ  
         * @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   r;   FNTr  )r  r   r  r   r,   r  )r   
methodNamer$  defaultValuer   isMarginr  r  s          r  r  z$coinex.handle_margin_mode_and_params  s     &&t|]CC>>&(E::
"6400NNz[acopp
Fx''X-=-='
F##r  c                 *    |                                  S N)milliseconds)r   s    r  noncezcoinex.nonce  s      """r  GETc                 l   |                      ||          }|d         }|d         }| j        d         |         dz   |z   dz   |z   }	|                     ||                     |                    }
t	          |                                           }|dk    r|                    d          }|                     |dd          }t          |          }|                     ||dz
  d          }|                    d          }t          |          }|                     ||dz
  d          }|dk    r_|d	k    s|d
k    rS|                     |d          }|;d}| 	                    | j
        d|          }|dz   |                                 z   |
d<   |dk    r|                                  |                     | j        |d|
          }
|                     |
          }
|                     |
          }|                     |                     |dz   | j        z             d          }|                                | j        d}|dk    s|dk    r
|	d|z   z  }	nd|d<   |}n|dk    s|dk    r|
r|	d|                     |
          z   z  }	n|dk    r|                                  |                     | j        |d|
          }
|                     |
          }
|                     |
          }|                     |                     |dz   | j        z             d          }|                                dd}|dk    s|dk    s|dk    r	|	d|z   z  }	n|                     |
          }n|d k    r|                                  |                     |
          }
|                     |
          }|dz   |z   dz   |z   dz   |z   |z   | j        z   }|                     |                     |          d          }| j        ||d!}|dk    s|dk    s|dk    r	|	d|z   z  }	n|                     |
          }|	|||d"S )#Nr   r   r   rI  POSTr0  ri  r  r  rF  r/  r   r   r   )	access_idrv  z&secret_key=sha256)AuthorizationAccessIdr  PUT?z!application/x-www-form-urlencodedContent-Typer   r   r2   )r   toncemd5zapplication/json)r"  r&  DELETEr   )zX-COINEX-KEYzX-COINEX-SIGNzX-COINEX-TIMESTAMP)urlr  bodyheaders)implode_paramsr   r  extract_paramsr   r  r  r  r  r  r   r\  check_required_credentialsr  apiKeykeysort	rawencodehashencodesecretr  	urlencoder  r  )r   pathr   r  r$  r,  r+  r1   
requestUrlr*  r  r  r  	firstPartnumPartslastPart	lastWordsnumWordslastWordr1  rf  r   
urlencoded	signaturepreparedStrings                            r  signzcoinex.sign  s   ""400a&V
iz*S07:S@4G		&$"5"5d";";<<DJJLL!!VJJsOOE((266I5zzH''x!|R@@H s++I9~~H''	8a<DDHW$$8w+>+>(hBVBV !% 0 0 E E ( -I#t|ZSSH)1C$++--)GE+&+++++---KK!["! !  E LL''E..J		$++j>.IDK.W"X"XZbccI!*!2!2 K G %Vu__sZ''*M'!8##z5F'F'F 3sT^^E2222$//111!%"% %   U++!^^E22
 IIdkk*~2MPTP[2[&\&\^cdd	%.__%6%6$6  eOO8););53++CC99U++DDD//111U++!^^E22
!'#!7#!=!Ds!JZ!WZ_!_bfbm!m IIdkk.&A&A8LL	$(K%.*/ 
 eOO8););53++CC99U++DfdwOOOr  c
                    |d S |                      |d          }
|                     |d          }|                      |d          }|
dk    s|dk    rn|dk    rh|dk    rb|s`| j        dz   |z   }|                     | j        d	         ||           |                     | j        d
         |
|           t          |          d S )Nr  r  r7  r   Success	SucceededOk r   r   )r  r  r.   throw_broadly_matched_exceptionr   throw_exactly_matched_exceptionr   )r   httpCodereasonr*  r  r,  r+  r%  requestHeadersrequestBodyr  r  r7  feedbacks                 r  handle_errorszcoinex.handle_errors  s    4&11x00""8Y77CKKg22K9O9OV]aeVeVeosVew}w.H001I7T\]]]001I4QYZZZ)))tr  c                    |                                   |                     |d          }|                     |d          }|d}ddd|d}| |                     |          }|d         |d<   |||d	<   |||d
<   |                     |                     ||                    }	|                     |	di           }
|                     |
dg           }|                     |ddd          }| 	                    ||||          S )ab  
        fetches the history of margin added or reduced from contract isolated positions
        :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http046_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=100, max=100
        :param dict params: extra parameters specific to the exchange api endpoint
        :param int [params.until]: timestamp in ms of the latest change to fetch
         *
         * EXCHANGE SPECIFIC PARAMETERS
        :param int [params.offset]: offset
        :returns dict[]: a list of `margin structures <https://docs.ccxt.com/#/?id=margin-loan-structure>`
        untilNr  r0  r   )rF  rP  r  r  r.   rF  r  r  r  r  r<   )
r  r  r  rF  *v1PerpetualPrivateGetPositionMarginHistoryr  r  rf  parse_margin_modificationsr  )r   rJ  rQ  r  r  r$  rQ  r  rF  r%  r  r  modificationss                r  fetch_margin_adjustment_historyz&coinex.fetch_margin_adjustment_history#  s)    	!!&'2267++=E	
 
 [[((F &tGH$)GL!"'GJBB4;;wX^C_C_``8 ~~h33..y"5577xQWXX00uUUUr  r  )NN)r__name__
__module____qualname__r   r   r;  r   r   rD  r=  r>  r   r  r   r  r   r   r  r  r   r  r   r  r  r   r  r   r  r  r  r  r  r  r  r  r  r   r  r+  r   rJ  ru  rM  r   r   r   rk  rL  r   r  r   r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r%  r(  r,  r5  r;  r   r9  rF  rI  rM  rP  rO  rm  r   r  r  r   rx  r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
   r  r	   r  r  r  rB  rO  rU  __classcell__)r  s   @r  r,   r,      s       N N N N N` ') y yZ y y y yv $& ; ;$v, ; ; ; ;"S S Sj\ \ \|B B6 BV B B B BH 02 I; I;3 I;f I; I; I; I;V 04B ^G ^GW ^G7 ^G ^G ^G ^G@ !# 4 4 4 4( :<B M? M?s M?3 M? M? M? M?^s s s5 s s s sj 6:UW *I *I3 *Is *I# *I\`af\g *I *I *I *IX 57 >6 >6 >6;N >6 >6 >6 >6@ )+ A A{ A A A AF

 

V 

?R 

 

 

 


 
 
4 
 
 
 
, 26DW[df 3H 3H# 3Hc 3HQT 3Hkoptku 3H 3H 3H 3Hj +- M) M) M) M)^ )+ ") ") ") ")H )+ ) ) ) )B .0 #) #) #) #)J $& 3 3( 3 3 3 34	: 	: 	:G G G5 G G G GR
 RT N N N5 N N N N  os{} r, r,3 r,i r,y r,Z_ r,hk r, r, r, r,h gksu X. X.3 X.i X.y X.RW X.`c X. X. X. X.t @B X XD$6 Xd5k X X X Xt 04B | | | | | || `drv  @B <. <.S <.# <.Y <.i <.Y\ <.lo <. <. <. <.| 37r i. i.s i.C i. i. i. i.V /32 . . . . . .` 26b C. C.c C.3 C. C. C. C.J <@daenp N? N?S N? N?[^ N? N? N? N?` /3TXac T T T3 Tc Thlmrhs T T T T 154VZce U U# US UPS Ujnotju U U U U 8: : :3 : : : :< 79 + +# + + + +Z	
 	
 	
 	
 	
 	
" "X " " " "
 
h 
 
 
 
2 -1tRV_a {? {?c {? {?C {? {? {? {?z 26b gP gPw gP gP gP gPR 24 J4 J4S J4 J4 J4 J4Xf fv f f f fP >B" %] %]# %]s %] %] %] %]N 9=R  ]  ]S  ]#  ]  ]  ]  ]D 7;2 > >G > > > ><     $ MO G G3 G G G GRX
 X
f X
HZ X
 X
 X
 X
t 68 	D 	D 	D<N 	D 	D 	D 	D 9; 	D 	DC 	D?Q 	D 	D 	D 	D 37TX\eg E EC Es ERU E E E EN 68 47 47 47 47 47 47l2
 2
6 2
 2
 2
 2
h 6:" ?? ??7 ?? ?? ?? ??B ?C2 0= 0=S 0=% 0= 0= 0= 0=d: : : 8<$]ajl CY CY CYC CYWZ CY CY CY CYJj
 j
x j
; j
 j
 j
 j
X [] * *S *% *c *c *an * * * *X: : :7
 7
 7
 7
 7
 7
r +/TPT]_ WG WGC WGs WG# WG WG WG WGr -1tRV_a <E <Ec <E <EC <Efjkvfw <E <E <E <E| *.Dt\^ <E <E3 <Ec <E <Ecghsct <E <E <E <E|
 
v 
 
 
 
B >@ #= #= #= #= #= #=J 24 # # # #J 15DW[jnwy +Q +Q# +Qc +QQT +Qdg +Q +Q +Q +QZ%
 %
& %
 %
 %
 %
N TV ! !S ! !U ! ! ! !F LN  C s    B
 
 
 
 
 
4 <@ )A )A )A )A )A )AV)# )# )# )#V 48 *N *NtCy *Ny *N *N *N *NX	
 	
x 	
 	
 	
 	
 @BPT $ $ $ $ $ $ # # #  b$T TP TP TP TPl   =Adaetx  BD @V @Vc @V @V[^ @Vnq @V  IM  N`  Ia @V @V @V @V @V @V @V @Vr  r,   N)0ccxt.base.exchanger   ccxt.abstract.coinexr   ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   ccxt.base.decimal_to_precisionr)   ccxt.base.preciser*   r,    r  r  <module>rb     s   ( ' ' ' ' ' , , , , , , E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E  E       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) . . . . . . 1 1 1 1 1 1 + + + + + + 4 4 4 4 4 4 % % % % % %HUV HUV HUV HUV HUVX{ HUV HUV HUV HUV HUVr  