
    E#i'                        S SK Jr  S SKJr  S SKrS SKrS SKJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SK J!r!  S SK J"r"  S SK J#r#  S S	K J$r$  S S
K J%r%  S SK J&r&  S SK J'r'  S SK(J)r)  S SK*J+r+   " S S\\5      r,g)    )Exchange)ImplicitAPIN)AccountAnyBalances
CurrenciesCurrencyDepositAddressIntLedgerEntryMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeeInterfaceTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)InsufficientFunds)NullResponse)	TICK_SIZE)Precisec                     ^  \ rS rSrS\4U 4S jjr0 4S\4S jjrS\S\	4S jr
0 4S\\   4S jjrS\S\4S	 jr0 4S\4S
 jjr0 4S\S\4S jjrS0 4S\S\4S jjrSSS\S\S\4S jjrSS0 4S\S\S\S\\   4S jjrSSS\S\S\4S jjrS0 4S\S\S\4S jjrSSS0 4S\S\S\S\S\\   4
S jjrSSS\S\4S jjr0 4S\ 4S jjr!STS\ 4S jjr"SSS\S\S\#4S jjr$0 4S\\%   4S  jjr&S!\S\%4S" jr'0 4S\(4S# jjr)S\(4S$ jr*SSS0 4S%\S\+S\S\S\\,   4
S& jjr-SSS0 4S\+S\S\4S' jjr.SSS0 4S\+S\S\4S( jjr/S0 4S)\S\+4S* jjr0S0 4S)\S\+4S+ jjr1S%\+4S, jr2SSS-\S\S\,4S. jjr3S0 4S\S/\4S0\5S1\6S2\74
S3 jjr8S0 4S)\S\+4S4 jjr9S0 4S\+4S5 jjr:SSS0 4S6\+S\S\S\\;   4S7 jjr<SSS8\S9\	S\;4S: jjr=S; r>SSS0 4S6\+S\S\S\\?   4S< jjr@SSS=\S9\	S\?4S> jjrAS%\+4S? jrB0 4S6\S1\6S@\SA\S\C4
SB jjrD0 4S6\S1\6S@\SA\S\C4
SC jjrE0 4S6\S1\6S@\SA\S\C4
SD jjrFSSSE\S9\	S\C4SF jjrG0 4S6\S\H4SG jjrISSS9\	S\H4SH jjrJSISJ0 SS4SK jrKS6\LSL\SM\SN\SO\SP\4SQ jrMSRrNU =rO$ )Ucex   returnc                   > U R                  [        [        U ]  5       SS/ SQSS0 SS _SS_SS	_S
S	_SS	_SS	_SS	_SS	_SS	_SS	_SS_SS_SS	_SS	_SS_SS	_SS	_0 SS	_SS	_SS_SS_SS_SS_SS	_SS	_S S	_S!S	_S"S	_S#S	_S$S_S%S_S&S	_S'S	_S(S_E0 S)S_S*S_S+S	_S,S	_S-S	_S.S	_S/S	_S0S	_S1S	_S2S	_S3S	_S4S	_S5S	_S6S_S7S	_S8S	_S9S	_E0 S:S	_S;S	_S<S	_S=S	_S>S	_S?S	_S@S	_SAS_SBS	_SCS	_SDS	_SES	_SFS_SGS	_SHS	_SIS	_SJS_E0 SKS_SLS	_SMS	_SNS_SOS	_SPS	_SQS	_SRS	_SSS	_STS	_SUS	_SVS	_SWS	_SXS_SYS_SZS_S[S_ESS	S	S	S	S	S	S	S	S	SS\.ES]S^S_S`.SaSbScSd/SeSf.0 SgSgSgShSgSgSgSgSi.Sj.0 0 SkSl_SmSg_SnSl_SoSg_SpSl_SqSl_SrSl_SsSg_StSg_SuSl_SvSg_SwSg_SxSg_SySg_SzSl_S{Sg_S|Sh_SlSgSgS}.ESj.S`.S	S	SS S	S	S	S SSS	SS~.S	S	S	SS	S	S	S.S S S S	SS	S	S	S.S S	SSSgSS	S	S	S.SS0S.	S S S.S S S.S.[        0 [
        [        [        [        [
        [        [        [        S.S.SSSSSSSSS.S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_ESSSSSSS.E0S.5      $ )Nr'   zCEX.IO)GBEUCYRUi,  TCORSspotmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercloseAllPositionsclosePositioncreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopOrdercreateTriggerOrderfetchAccountsfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrderfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLedgerfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistory
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrderfetchOpenOrdersfetchOptionfetchOptionChainfetchOrderBookfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickers	fetchTimefetchTrades)fetchTradingFeesfetchVolatilityHistoryreduceMarginrepayCrossMarginrepayIsolatedMarginrepayMarginsetLeverage	setMarginsetMarginModesetPositionModetransferzchttps://user-images.githubusercontent.com/1294454/27766442-8ddc33b0-5ed8-11e7-8b98-f786aef0f3c9.jpgz)https://trade.cex.io/api/spot/rest-publicz"https://trade.cex.io/api/spot/rest)publicprivatezhttps://cex.iozhttps://trade.cex.io/docs/zhttps://cex.io/fee-schedulez!https://cex.io/limits-commissionsz!https://cex.io/r/0/up105393824/0/)logoapiwwwdocfeesreferral   
   )get_server_timeget_pairs_infoget_currencies_infoget_processing_info
get_tickerget_trade_historyget_order_bookget_candles)getpostget_my_current_fee   get_fee_strategyget_my_volumedo_create_accountget_my_account_status_v3get_my_wallet_balanceget_my_ordersdo_my_new_orderdo_cancel_my_orderdo_cancel_all_ordersr   r   r   get_my_transaction_historyget_my_funding_historydo_my_internal_transferr   )get_deposit_addressdo_deposit_funds_from_walletdo_withdrawal_funds_to_wallet)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedleveragemarketBuyRequiresPricemarketBuyByCostselfTradePreventiontrailingicebergi  )r   limittriggerr   symbolRequiredi )r   r   daysBackdaysBackCanceled	untilDaysr   r   r   r   )	sandboxr=   createOrdersfetchMyTrades
fetchOrderrs   fetchOrdersrM   rn   )linearinverse)r0   r2   r3   )z/You have negative balance on following accountsz2Mandatory parameter side should be one of BUY,SELLz,API orders from Main account are not allowedzcheck failedzInsufficient fundsz3Get deposit address for main account is not allowedz%Market Trigger orders are not allowedzkey not passed or incorrect)exactbroad1m5m15m30m1h2h4h1d)r   r   r   r   r   r   r   r   networksBTCbitcoinERC20BSC20binancesmartchainDOGEdogecoinALGOalgorandXLMstellarATOMcosmosLTClitecoinXRPrippleFTMfantomMINAminaTHETAthetaXTZtezosTIAcelestiaCRONOScronosMATICpolygonTONtonTRC20tronSOLANAsolanaSGBsongbirdDYDXdydxDASHdashZILzilliqaEOSeos
AVALANCHEC	avalancheETHPOWethereumpowNEARnearARBarbitrumDOTpolkadotOPToptimismINJ	injectiveADAcardanoONTontologyICPicpkavakusamaseineoneo3xdc)KAVAKSMSEINEONEO3XDC)idname	countries	rateLimitprohasurlsr   featuresprecisionMode
exceptions
timeframesoptions)	deep_extendsuperr'   describer$   r"   r!   r   r   )self	__class__s    P/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/cex.pyr<  cex.describe   s4	   c4 9 ;1aaa %a 	a
 %a %a Ua $Ua 'a a "4a ta $Ua  a ta  7!a" 9%#a$ &u%a& ('a( "4)a* %d+a,  -a. /a0 &u1a2 "53a4 +E5a6 )%7a8 #E9a: ,U;a< #D=a> $T?a@ 'AaB (CaD "4EaF &tGaH +DIaJ &uKaL 'MaN (OaP #EQaR *5SaT $UUaV uWaX "5YaZ *5[a\ +E]a^ )%_a` taab  cad !%eaf %egah $Uiaj &ukal -eman /oap "5qar #Esat +Euav wax !%yaz "5{a| &u}a~ +Ea@ dAaB $UCaD +EEaF %eGaH !$IaJ "4KaL uMaN #EOaP !$QaR  SaT 'UaV $UWaX !%YaZ *5[a\ (]a^ %e_a` )%aab )%cad teaf gah Tiaj tkal %)*/ %$)',$$"!&#( AaF ~IC (317 @  +,*+/0/1&'-.*+'(	 ,a*A ( ,Q	
 3A 0 ( *1 -a / )! &q ,Q 5a 1!  21!" .r#$ 01899:)'T  %&+(,,0,1).+06:#'#'"'#'	( #($)27+//4$)#()$, %)%)"&&+!%#($)*/( $(&+!%$*,-%+#($)*/	*  #[0d ##
 ##m:v 'GXJTDN$.*;K[=G3F	 	  -9-W- 0- J	-
 J- 9- H- :- 8- 8- F- W- 7- :- h-  Y!-" 5#-$ V%-& h'-( :)-* F+-, F--. 9/-0 51-2 !+3-4 m5-6 F7-8 :9-: :;-< :=-> ;?-@ 9A-B :C-D 5E-F ##  " !Y-/ca>
 a a	    c                   #    / nUR                  U R                  U5      5        UR                  U R                  U5      5        [        R                  " U6 I Sh  vN nU R                  US   S/ 5      nU R                  US   S0 5      nU R                  US5      nU R                  Xe5      nU R                  U R                  U5      5      $  Ns7f)z
fetches all available currencies on an exchange

https://trade.cex.io/docs/#rest-public-api-calls-currencies-info

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
Nr   datar   currency)appendpublicPostGetCurrenciesInfopublicPostGetProcessingInfoasynciogather	safe_list	safe_dictindex_byr:  parse_currenciesto_array)r=  paramspromises	responsesdataCurrenciesdataNetworkscurrenciesIndexedrC  s           r?  fetch_currenciescex.fetch_currencies=  s      88@A 	88@A, "..(33		!fbA~~ilFB? MM.*E 1@$$T]]4%899 4s   ACCA4CrawCurrencyc                    U R                  US5      nU R                  U5      nU R                  US5      (       a  SOSnU R                  U R	                  U R                  US5      5      5      n0 nU R                  US0 5      n[        UR                  5       5      n[        S[        U5      5       H  n	X   n
Xz   nU R                  U
5      nU R                  US5      S:H  nU R                  US	5      S:H  nU
US UUS U R                  US
5      UU R                  US5      S S.U R                  US5      S S.S.US.
Xl'   M     U R                  UUS US U R                  US5      U R                  US5      S US S S.S S S.S.UUS.5      $ )NrD  fiatcrypto	precisionblockchainsr   depositenabled
withdrawalwithdrawalFee
minDepositminmaxminWithdrawal)r]  withdraw)
r.  networkr1   r]  rf  activefeer[  limitsinfowalletDepositwalletWithdrawal)amountrf  )r.  coder/  typerh  r]  rf  ri  r[  rj  r   rk  )safe_stringsafe_currency_code	safe_boolparse_numberparse_precisionrK  listkeysrangelennetwork_id_to_codesafe_numbersafe_currency_structure)r=  rW  r.  ro  rp  currencyPrecisionr   rawNetworksrw  j	networkId
rawNetworknetworkCoder]  rf  s                  r?  parse_currencycex.parse_currencys  s   k:6&&r*V<<v( --d.B.B4CSCST_alCm.nonn[-DK$$&'q#d)$AI$/J11)<K&&z9=JG''
LAYNH&"$''
OD.  $//
LI# 
  $//
OL#!	 #'%H! %6 ++~~k?C{4FG*  
  	 !+-
  	rA  c                    #    U R                  U5      I Sh  vN nU R                  US/ 5      nU R                  U5      $  N(7f)z
retrieves data on all markets for ace

https://trade.cex.io/docs/#rest-public-api-calls-pairs-info

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
NrC  )publicPostGetPairsInforJ  parse_markets)r=  rO  responserC  s       r?  fetch_marketscex.fetch_markets  sD      44V<<, ~~h3!!$''/ =s   AA )Amarketc                 p   U R                  US5      nU R                  U5      nU R                  US5      nU R                  U5      nUS-   U-   nUS-   U-   nU R                  0 SU_SU_SU_SU_SU_SU_S	S _S
S _SS_SS_SS_SS_SS_SS_SS_SS _SS _S S S S S U R                  US5      U R                  US5      S.U R                  US5      U R                  US5      S.U R                  US5      U R                  US5      S.S S S.S.U R                  US5      U R	                  U R                  U R                  US5      5      5      U R	                  U R                  U R                  US 5      5      5      U R	                  U R                  U R                  US!5      5      5      S".S S US#.
E5      $ )$Nbasequote-/r.  symbolbaseIdquoteIdsettlesettleIdrp  r0   Tr1   Fr2   r3   r4   contractr   r   baseMinbaseMaxrb  minPricemaxPricequoteMinquoteMax)rn  pricecostr   baseLotSizepricePrecisionbasePrecisionquotePrecision)rn  r  r  r  )
contractSizeexpiryexpiryDatetimestrike
optionTyperj  r[  rh  createdrk  )rq  rr  safe_market_structurer{  rt  ru  )r=  r  r  r  r  r  r.  r  s           r?  parse_marketcex.parse_market  sz   !!&&1&&v.""673''0CZ%e#)) 3+
"3+
f3+
 D3+
 f	3+

 U3+
 w3+
 d3+
 3+
 F3+
 D3+
 e3+
 E3+
 e3+
 e3+
 3+
  d!3+
" t#3+
$ !"  ++FI>++FI>
  ++FJ?++FJ?
  ++FJ?++FJ?
  & **6=A**4+?+?@P@PQWYi@j+kl))$*>*>t?O?OPVXg?h*ij**4+?+?@P@PQWYi@j+kl e3+
 3 3	rA  c                    #    U R                  U5      I Sh  vN nU R                  US5      nU R                  US5      nU$  N*7f)z
fetches the current integer timestamp in milliseconds from the exchange server
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int: the current integer timestamp in milliseconds from the exchange server
NrC  	timestamp)publicPostGetServerTimerK  safe_integer)r=  rO  r  rC  r  s        r?  
fetch_timecex.fetch_time  sI      55f== ~~h/%%dK8	 >s   AA+Ar  c                    #    U R                  5       I Sh  vN   U R                  U/U5      I Sh  vN nU R                  X10 5      $  N1 N7f)as  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://trade.cex.io/docs/#rest-public-api-calls-ticker

:param str symbol:
: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>`
N)load_marketsfetch_tickersrK  )r=  r  rO  r  s       r?  fetch_tickercex.fetch_ticker   sI      !!!++VHf==~~h33 	"=s   AAAA
A
ANsymbolsc                   #    U R                  5       I Sh  vN   0 nUb  U R                  U5      US'   U R                  U R                  X25      5      I Sh  vN nU R	                  US0 5      nU R                  XQ5      $  Ni N*7f)a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://trade.cex.io/docs/#rest-public-api-calls-ticker

:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
NpairsrC  )r  
market_idspublicPostGetTickerextendrK  parse_tickers)r=  r  rO  requestr  rC  s         r?  r  cex.fetch_tickers.  s      !!!#w7GG11$++g2NOO6 ~~h3!!$00A 	" Ps"   BB A BB)BBtickerc                    U R                  US5      nU R                  X25      nU R                  0 SU_SS _SS _SU R                  US5      _SU R                  US5      _SU R                  US5      _S	S _S
U R                  US5      _SS _SS _SS _SU R                  US5      _SS _SU R                  US5      _SU R                  US5      _SS _SU R                  US5      _U R                  US5      US.EU5      $ )Nr.  r  r  datetimehighlowbidbestBid	bidVolumeaskbestAsk	askVolumevwapopencloselastpreviousClosechangepriceChange
percentagepriceChangePercentageaverage
baseVolumevolumequoteVolume)r  rk  )rq  safe_symbolsafe_tickerr{  )r=  r  r  marketIdr  s        r?  parse_tickercex.parse_tickerZ  s   ##FD1!!(3 !
f!
!
 !
 D$$VV4	!

 4##FE2!
 4##FI6!
 !
 4##FI6!
 !
 D!
 D!
 T%%ff5!
 T!
 d&&v}=!
 $**63JK!
  t!!
" $**68<#!
$  ++FMB'!
( ) 	rA  sincer   c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  U R                  U5      US'   SnU R                  USS5      u  ptUb  U R                  U5      US'   Ub  [	        US5      US	'   U R                  U R                  Xd5      5      I Sh  vN nU R                  US
0 5      n	U R                  U	S/ 5      n
U R                  XX#5      $  N N>7f)a%  
get the list of most recent trades for a particular symbol

https://trade.cex.io/docs/#rest-public-api-calls-trade-history

:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch
:param int [limit]: the maximum amount of trades to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest entry
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
Npairr.  fromDateISOuntiltill	toDateISOi'  pageSizerC  trades)
r  r  iso8601handle_param_integer_2rc  publicPostGetTradeHistoryr  rK  rJ  parse_trades)r=  r  r  r   rO  r  r  r  r  rC  r  s              r?  fetch_tradescex.fetch_tradess  s      !!!V$F4L
 %)\\%%8GM"33FGVL#'<<#6GK "%eU"3GJ77G8TUU  ~~h3h3  >>? 	" Vs"   C.C*BC.-C,.=C.,C.tradec                 P   U R                  US5      nU R                  U5      nU R                  S U5      nU R                  UUU R	                  U5      US   U R                  US5      S S S U R                  US5      U R                  US5      U R                  US5      S S S.U5      $ )NdateISOr  tradeIdsider  rn  )rk  r  r  r  r.  orderrp  takerOrMakerr  r  rn  r  ri  )rq  	parse8601safe_market
safe_trader  safe_string_lower)r=  r  r  dateStrr  s        r?  parse_tradecex.parse_trade  s     ""5)4NN7+	!!$/"Y/X&""5)4 **5&9%%eW5&&uh7 
  	rA  c                 6  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XS5      5      I Sh  vN nU R	                  US0 5      nU R                  US5      nU R                  XtS   U5      $  N~ N@7f)a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://trade.cex.io/docs/#rest-public-api-calls-order-book

: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.  rC  r  r  )r  r  publicPostGetOrderBookr  rK  r  parse_order_book)	r=  r  r   rO  r  r  r  	orderBookr  s	            r?  fetch_order_bookcex.fetch_order_book  s      !!!V$F4L
 44T[[5QRR& NN8VR8	%%i=	$$Yx0@)LL5 	"
 Ss!   BB?BB?BBr   	timeframec                   #    SnU R                  USS5      u  peUc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R	                  U5      nUS   U R
                  U   US.nUb  U R                  U5      US'   Sn	U R                  USS	5      u  pU	b  U R                  U	5      US
'   O%Uc"  U R                  U R                  5       5      US
'   Ub  U	b  Ub  [        U R                  S-   5      eUc  U	b  Uc  [        U R                  S-   5      eUb  XHS'   U R                  U R                  X5      5      I Sh  vN n
U R                  U
S/ 5      nU R                  XX#U5      $  GN. N-7f)a  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://trade.cex.io/docs/#rest-public-api-calls-candles

:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param int [since]: timestamp in ms of the earliest candle to fetch
:param int [limit]: the maximum amount of candles to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest entry
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nrn   dataTypezO fetchOHLCV requires a parameter "dataType" to be either "bestBid" or "bestAsk"r.  )r  
resolutionr  fromISOr  r  toISOzO fetchOHLCV does not support fetching candles with both a limit and since/untilzP fetchOHLCV requires a limit parameter when fetching candles with since or untilr   rC  )handle_option_and_paramsr    r.  r  r  r8  r  r  millisecondspublicPostGetCandlesr  rJ  parse_ohlcvs)r=  r  r   r  r   rO  r  r  r  r  r  rC  s               r?  fetch_ohlcvcex.fetch_ohlcv  s     88zZ#DGG.$  A  A!!!V$4L//)4 

 !%e!4GI33FGVL#||E2GG]#||D,=,=,?@GG!2u7H#DGG.$  A  A5#4%-#DGG  /A  %A  B  B$G224;;w3OPP$ ~~h3  yGGS 	", Qs%   AE;E6	DE;E9+E;9E;c           	          U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )Nr  r  r  r  r  r  )r  r{  )r=  ohlcvr  s      r?  parse_ohlcvcex.parse_ohlcv$  sl    e[1UF+UF+UE*UG,UH-
 	
rA  c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US0 5      nU R                  US0 5      nU R                  US5      $  NU N>7f)a+  
fetch the trading fees for multiple markets

https://trade.cex.io/docs/#rest-public-api-calls-candles

: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
NrC  
tradingFeeT)r  privatePostGetMyCurrentFeerK  parse_trading_fees)r=  rO  r  rC  r   s        r?  fetch_trading_feescex.fetch_trading_fees.  sm      !!!88@@ ~~h3~~dL"5&&tT22 	"@s   A0A,A0A.=A0.A0c                    0 n[        UR                  5       5      n[        S[        U5      5       H<  nXE   nS nU(       a  U R	                  U5      nU R                  X   U5      nXUS   '   M>     [        S[        U R                  5      5       H=  nU R                  U   n	X;  d  M  U R                  U	5      nU R                  X5      X9'   M?     U$ )Nr   r  )rv  rw  rx  ry  r  parse_trading_feer  r  )
r=  r  
useKeyAsIdresultrw  ikeyr  parsedr  s
             r?  r  cex.parse_trading_feesG  s    HMMO$q#d)$A'CF))#.++HM6BF'-6(#$ % q#dll+,A\\!_F$V,!%!7!7!I	 -
 rA  ri  c                 t    UU R                  US5      U R                  US5      U R                  US5      S S S.$ )Nr  percent)rk  r  makertakerr  	tierBased)rq  r{  )r=  ri  r  s      r?  r  cex.parse_trading_feeX  sE    &&vx8%%c95%%c95
 	
rA  c                   #    U R                  5       I S h  vN   U R                  U5      I S h  vN nU R                  US0 5      nU R                  US0 5      nU R                  U5      nU R	                  XQ5      $  Ne NN7f)NrC  balancesPerAccounts)r  privatePostGetMyAccountStatusV3rK  rN  parse_accounts)r=  rO  r  rC  balancesarrayss         r?  fetch_accountscex.fetch_accountsb  sx     !!!==fEE* ~~h3>>$(=rBx(""6223 	"Es    B A<B A>AB >B accountc                     S S S US.$ )N)r.  rp  ro  rk   )r=  r,  s     r?  parse_accountcex.parse_account~  s    	
 	
rA  c                   #    SnU R                  USS5      u  p!SnU R                  USS5      u  p1SnUS:X  aR  U R                  U5      I Sh  vN nU R                  US0 5      nU R                  US0 5      nU R                  Xr0 5      nO,U R                  U5      I Sh  vN nU R                  US0 5      nU R	                  U5      $  Nz N*7f)	a8  
query for balance and get the amount of funds available for trading or funds locked in orders

https://trade.cex.io/docs/#rest-private-api-calls-account-status-v3

:param dict [params]: extra parameters specific to the exchange API endpoint
:param dict [params.method]: 'privatePostGetMyWalletBalance' or 'privatePostGetMyAccountStatusV3'
:param dict [params.account]:  in case 'privatePostGetMyAccountStatusV3' is chosen, self can specify the account name(default is empty string)
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
Nr,   methodprivatePostGetMyWalletBalancer&  rC  r%  )handle_param_stringr&  rK  r4  parse_balance)r=  rO  accountNamer3  accountBalancer  rC  r(  s           r?  fetch_balancecex.fetch_balance  s      "66vy"M11&(Dcd66!AA&IIH >>(FB7D~~d,A2FH!^^H2FN!??GGH "^^HfbAN!!.11A J$ Hs%   ACCACC
 )C
Cc                 6   SU0n[        UR                  5       5      n[        S[        U5      5       HS  nX4   nU R	                  X0 5      nU R                  U5      nU R                  US5      U R                  US5      S.nXU'   MU     U R                  U5      $ )Nrk  r   balanceOnHoldbalance)usedtotal)rv  rw  rx  ry  rK  rr  rq  safe_balance)	r=  r  r  rw  r  r  r=  ro  r,  s	            r?  r6  cex.parse_balance  s    H
 HMMO$q#d)$A'CnnXB7G**3/D((/B))'9=G #4L %   ((rA  statusc                   #    U R                  5       I Sh  vN   0 nUS:H  nU(       a  SUS'   SnUb  U R                  U5      nUS   US'   Ub  XFS'   Ub  X6S'   OU(       a  U R                  5       S	-
  US'   Sn	U R                  US
S5      u  pU	b  XS'   U R	                  U R                  Xe5      5      I Sh  vN n
U R                  U
S/ 5      nU R                  XX45      $  N N+7f)a\  
fetches information on multiple orders made by the user

https://trade.cex.io/docs/#rest-private-api-calls-orders

:param str status: order status to fetch for
:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest entry
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NclosedTarchivedr.  r  r  serverCreateTimestampFroml    P% r  r  serverCreateTimestampTorC  )r  r  r  r  privatePostGetMyOrdersr  rJ  parse_orders)r=  rB  r  r  r   rO  r  isClosedOrdersr  r  r  rC  s               r?  fetch_orders_by_statuscex.fetch_orders_by_status  s     !!! H,"&GJ[[(F$TlGFO"'J38/0373D3D3FIb3bG/033FGVL16-.44T[[5QRRR ~~h3  u<<} 	"( Ss"   C'C#B"C'9C%:*C'%C'c                 D   #    U R                  SXX45      I Sh  vN $  N7f)  

https://trade.cex.io/docs/#rest-private-api-calls-orders

fetches information on multiple canceled orders made by the user
:param str symbol: unified market symbol of the market orders were made in
:param int [since]: timestamp in ms of the earliest order, default is None
:param int [limit]: max number of orders to return, default is None
: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>`
rD  NrK  r=  r  r  r   rO  s        r?  fetch_closed_orderscex.fetch_closed_orders  s"      006%XXXX     c                 D   #    U R                  SXX45      I Sh  vN $  N7f)rN  r  NrO  rP  s        r?  fetch_open_orderscex.fetch_open_orders%  s"      00VVVVrS  r.  c           	         #    U R                  5       I Sh  vN   S[        U5      0nU R                  USSU R                  XC5      5      I Sh  vN nUS   $  NA N7f)aq  
fetches information on an open order made by the user

https://trade.cex.io/docs/#rest-private-api-calls-orders

:param str id: order id
:param str [symbol]: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NorderIdr   )r  intrU  r  r=  r.  r  rO  r  r  s         r?  fetch_open_ordercex.fetch_open_order3  sb      !!!s2w
 --fdD$++gB^__ay 	" `!   AA7AA
AAc           	         #    U R                  5       I Sh  vN   S[        U5      0nU R                  USSU R                  XC5      5      I Sh  vN nUS   $  NA N7f)as  
fetches information on an closed order made by the user

https://trade.cex.io/docs/#rest-private-api-calls-orders

:param str id: order id
:param str [symbol]: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NrX  r   )r  rY  rQ  r  rZ  s         r?  fetch_closed_ordercex.fetch_closed_orderE  sc      !!!s2w
 //dDKKPWD`aaay 	" br]  c           	      <    SSSSSSSSS.nU R                  X!U5      $ )Nr  rD  expiredrejected	cancelingcanceled)PENDING_NEWNEWPARTIALLY_FILLEDFILLEDEXPIREDREJECTEDPENDING_CANCEL	CANCELLEDrq  r=  rB  statusess      r?  parse_order_statuscex.parse_order_statusW  s6    ! & ")#	
 &99rA  r  c           	         U R                  US5      nU R                  US5      nS nUb  Ub  US-   U-   nU R                  XR5      nUS   nU R                  U R                  US5      5      n0 nU R                  US5      n	U	b+  U R                  US5      n
U R	                  U
5      nXS'   XS	'   U R                  US
5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  0 SU R                  US5      _SU R                  US5      _SU_SU R                  U5      _SU R                  US5      _SS _SU_SU R                  US5      _SU R                  US5      _SS _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU_S	U_SU R                  US5      _S U_S UUS US!.EU5      $ )"N	currency1	currency2r  r  rB  	feeAmountfeeCurrencyrD  r  serverCreateTimestamprequestedAmountCcy1executedAmountCcy1executedAmountCcy2r.  rX  clientOrderIdr  r  lastUpdateTimestamplastTradeTimestamprp  	orderTyper   postOnlyr  r  r   	stopPricern  r  averagePricefilled)	remainingrB  ri  r  rk  )	rq  r  rq  r{  rr  r  
safe_orderr  r  )r=  r  r  rt  ru  r  r  rB  ri  rv  
currencyIdfeeCoder  requestedBaseexecutedBaseexecutedQuotes                   r?  parse_ordercex.parse_orderd  s   B $$UK8	$$UK8	 Y%: 32H!!(3!(()9)9%)JK$$UK8	 ))%?J--j9G%
O#K%%e-DE	((0EF''/CD((0DE  
$""5)4 
T--e_E 
  
 Y/	 

 "4#4#4U<Q#R 
 !$ 
 f 
 D**5+> 
 4++E=A 
  
 D**5&9 
 T%%eW5 
 D,,UK@ 
 m 
 M 
  t''~>! 
" l# 
$ - 
. / 	rA  rp  r  rn  r  c                   #    SnU R                  USS5      u  pvUc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R	                  U5      nU R                  5       US   US   UU R                  UR                  5       5      UR                  5       U R                  5       U R                  X5      S.n	Sn
U R                  USSS	5      u  pUS
:X  a  U R                  X5      U	S'   XS'   SnU R                  US5      u  pUb	  SU	S'   XS'   U R                  U R                  X5      5      I Sh  vN nU R                  US5      nU R!                  X5      $  GN  N*7f)a  
create a trade order

https://trade.cex.io/docs/#rest-private-api-calls-new-order

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.accountId]: account-id to use(default is empty string)
:param float [params.triggerPrice]: the price at which a trigger order is triggered at
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr=   	accountIdz createOrder() : API trading is now allowed from main account, set params["accountId"] or .options["createOrder"]["accountId"] to the name of your sub-accountr  r  )r|  rt  ru  r  r  r  r  
amountCcy1r   GTCr   r  r   z
Stop Limitrp  r  rC  )r  r    r.  r  r  uuid
capitalizelowerupperr  amount_to_precisionprice_to_precisionr5  privatePostDoMyNewOrderr  rK  r  )r=  r  rp  r  rn  r  rO  r  r  r  r   r   r  rC  s                 r?  create_ordercex.create_order  s      	 99&-Q\]	#DGG  /O  %O  P  P!!!V$!YY[)	*"6JJL**,226B	
 ";;FMS`bgh7?#66vEGG%0M"#77O#*GFO#/K 55dkk'6RSSb ~~h/--Q 	", Ts%   AE-E(	C7E- E+(E-+E-c                 H  #    U R                  5       I Sh  vN   [        U5      S[        U R                  5       5      -   U R                  5       S.nU R	                  U R                  XC5      5      I Sh  vN nU R                  US0 5      nU R                  U5      $  N N*7f)aU  
cancels an open order

https://trade.cex.io/docs/#rest-private-api-calls-cancel-order

:param str id: order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nc_)rX  cancelRequestIdr  rC  )r  rY  strr  privatePostDoCancelMyOrderr  rK  r  )r=  r.  r  rO  r  r  rC  s          r?  cancel_ordercex.cancel_order  s      !!!2w#c4+<+<+>&@@**,

 88W9UVV ~~h3%% 	" Ws"   B"BAB"5B 6)B" B"c                 L  #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      n/ n[	        S[        U5      5       H  nXW   nUR                  SU05        M     U R                  U5      $  N Nr7f)as  
cancel all open orders in a market

https://trade.cex.io/docs/#rest-private-api-calls-cancel-all-orders

:param str symbol: alpaca cancelAllOrders cannot setting symbol, it will cancel all open orders
: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>`
NrC  clientOrderIdsr   r|  )r  privatePostDoCancelAllOrdersrK  rJ  rx  ry  rE  rI  )	r=  r  rO  r  rC  idsordersr  r.  s	            r?  cancel_all_orderscex.cancel_all_orders(  s      !!!::6BB ~~h3nnT#3R8q#c(#ABMM?B/0 $   ((% 	"Bs    B$B B$B"A1B$"B$ro  c                 t  #    U R                  5       I Sh  vN   Sn0 nUb  U R                  U5      nUS   US'   Ub  X&S'   Ub  X6S'   SnU R                  USS5      u  ptUb  XvS'   U R                  U R	                  Xd5      5      I Sh  vN nU R                  US	/ 5      n	U R                  XX#5      $  N N+7f)
a4  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

https://trade.cex.io/docs/#rest-private-api-calls-transaction-history

:param str [code]: unified currency code
:param int [since]: timestamp in ms of the earliest ledger entry
:param int [limit]: max number of ledger entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest ledger entry
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
Nr.  rD  dateFromr  r  r  dateTorC  )r  rD  r  "privatePostGetMyTransactionHistoryr  rJ  parse_ledger)
r=  ro  r  r   rO  rD  r  r  r  rC  s
             r?  fetch_ledgercex.fetch_ledgerF  s      !!!}}T*H"*4.GJ"'J"'J33FGVL %H@@WA]^^  ~~h3  >>? 	" _s"   B8B4A3B8
B6*B86B8itemrD  c                 L   U R                  US5      nS n[        R                  " US5      (       a  Sn[        R                  " SU5      nOSnU R                  US5      nU R	                  XR5      nU R                  XR5      nU R                  US5      nU R                  U5      nU R                  US5      n	U R                  UU R                  US	5      UU R                  US
S5      S S U R                  U	5      UU R                  U5      UU R                  U5      S S S S S.U5      $ )Nrn  0outz-1inrD  r  rp  transactionIdr  r2  )rk  r.  	directionr,  referenceAccountreferenceIdrp  rD  rn  r  r  beforeafterrB  ri  )rq  r%   	string_le
string_mulsafe_currencyrr  r  safe_ledger_entryparse_ledger_entry_typert  r  )
r=  r  rD  rn  r  r  ro  timestampStringr  rp  s
             r?  parse_ledger_entrycex.parse_ledger_entryt  s1   !!$1	VS))I''f5FI%%dJ7
%%j;&&z<**4=NN?3	f-%%""49"''k2> $006''/"Y/'
  ! 	rA  c                 2    SSSS.nU R                  X!U5      $ )Nr]  r_  ri  )r]  rf  
commissionrn  )r=  rp  
ledgerTypes      r?  r  cex.parse_ledger_entry_type  s'     $


 
$77rA  c                 d  #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUb  X%S'   Ub  X5S'   SnU R                  USS5      u  ptUb  XuS'   U R                  U R	                  XT5      5      I Sh  vN nU R                  US/ 5      n	U R                  XX#5      $  N N+7f)a0  
fetch history of deposits and withdrawals

https://trade.cex.io/docs/#rest-private-api-calls-funding-history

:param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
:param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
:param int [limit]: max number of deposit/withdrawals to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr  r  r  r  r  rC  )r  rD  r  privatePostGetMyFundingHistoryr  rJ  parse_transactions)
r=  ro  r  r   rO  r  rD  r  r  rC  s
             r?  fetch_deposits_withdrawalscex.fetch_deposits_withdrawals  s      !!!}}T*H"'J"'J33FGVL %H<<T[[=YZZ& ~~h3&&tuDDC 	" [s"   B0B,A+B0B.*B0.B0transactionc                    U R                  US5      nU R                  US5      nUS:X  a  SOSnU R                  X25      nU R                  US5      nU R                  U5      n0 SU_SU R                  US	5      _S
S _SU_SU_SS _SU R                  US5      _SU R	                  U R                  US5      5      _SU_SU R                  U5      _SS _SS _SS _SS _SS _SS _SS _S UU R                  US5      S.S S.E$ )NrD  r  rf  r_  r]  	updatedAtrk  r.  txIdtxidrp  rg  rn  rB  r  r  addressaddressFrom	addressTotagtagFromtagToupdatedcommissionAmount)rD  r  )commentri  internal)rq  rr  r  r{  parse_transaction_statusr  )	r=  r  rD  r  r  rp  ro  r  r  s	            r?  parse_transactioncex.parse_transaction  s   %%k:>
$$[+>	 )Z 7|i&&z<$$[+>	NN9-	
K
$"";7
 D
 D	

 
 t
 d&&{H=
 d33D4D4D[RZ4[\
 
 Y/
 t
 4
 
 4
 t
  T!
" t#
$  ((6HI /
 	
rA  c                 2    SSSS.nU R                  X!U5      $ )Nrc  pendingok)rc  r  approvedrn  ro  s      r?  r  cex.parse_transaction_status  s'    " 

 &99rA  fromAccount	toAccountc                    #    SnUS:w  a"  US:w  a  U R                  XX4U5      I Sh  vN nOU R                  XX4U5      I Sh  vN nU R                  SSS5      nU(       a  X6S'   XFS'   U$  ND N*7f)a  
transfer currency internally between wallets on the same account

https://trade.cex.io/docs/#rest-private-api-calls-internal-transfer

:param str code: unified currency code
:param float amount: amount to transfer
:param str fromAccount: 'SPOT', 'FUND', or 'CONTRACT'
:param str toAccount: 'SPOT', 'FUND', or 'CONTRACT'
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
Nr2  r   fillResponseFromRequestTr  r  )transfer_between_sub_accounts%transfer_between_main_and_sub_accounthandle_option)r=  ro  rn  r  r  rO  r   r  s           r?  r   cex.transfer  s      ?{b0!??kflmmH!GGVantuuH"&"4"4ZAZ\`"a"&1]#$-[! nus!   %A0A,A0A.)A0.A0c                   #    U R                  5       I S h  vN   U R                  U5      nUS:H  nU(       a  UOUnU R                  USU R                  5       5      n	US   U R	                  X5      UU	S.n
S nU(       a)  U R                  U R                  X5      5      I S h  vN nO(U R                  U R                  X5      5      I S h  vN nU R                  US0 5      nU R                  X5      $  N NS N,7f)Nr2  guidr.  )rD  rn  r  
clientTxIdrC  )
r  rD  rq  r  currency_to_precision#privatePostDoDepositFundsFromWalletr  $privatePostDoWithdrawalFundsToWalletrK  parse_transfer)r=  ro  rn  r  r  rO  rD  fromMaintargetAccountr  r  r  rC  s                r?  r  )cex.transfer_between_main_and_sub_account  s     !!!==&2%%-	;		< 00>&	
 !EEdkkRYFbccH!FFt{{SZGcddH ~~h3""422= 	" dds4   C:C4BC:"C6#(C:C8)C:6C:8C:c                 .  #    U R                  5       I S h  vN   U R                  U5      nUS   U R                  X5      UUS.nU R                  U R	                  Xu5      5      I S h  vN nU R                  US0 5      n	U R                  X5      $  Nz N*7f)Nr.  )rD  rn  fromAccountIdtoAccountIdrC  )r  rD  r  privatePostDoMyInternalTransferr  rK  r  )
r=  ro  rn  r  r  rO  rD  r  r  rC  s
             r?  r  !cex.transfer_between_sub_accounts-  s     !!!==& 00>($	
 ==dkk'>Z[[ ~~h3""422% 	" \s"   BBAB(B))BBr   c                     U R                  US5      nU R                  X25      nUU R                  USS5      S S US S S U R                  U R                  US5      5      S.	$ )NrD  r  r  rB  )	rk  r.  r  r  rD  rn  r  r  rB  )rq  rr  safe_string_2r  )r=  r   rD  r  currencyCodes        r?  r  cex.parse_transferB  sr    . %%h
;
..zD$$XM$33D4D4DXx4XY

 
	
rA  c                   #    SnU R                  USS5      u  p2Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   SnU R	                  U5      u  pBU R                  U5      nUUS   U R                  U5      S.nU R                  U R                  Xb5      5      I Sh  vN nU R                  US0 5      nU R                  X5      $  N N*7f)a  
fetch the deposit address for a currency associated with self account

https://trade.cex.io/docs/#rest-private-api-calls-deposit-address

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.accountId]: account-id(default to empty string) to refer to(at self moment, only sub-accounts allowed by exchange)
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
Nr=   r  z fetchDepositAddress() : main account is not allowed to fetch deposit address from api, set params["accountId"] or .options["createOrder"]["accountId"] to the name of your sub-accountr.  )r  rD  
blockchainrC  )r  r    r.  r  handle_network_code_and_paramsrD  network_code_to_idprivatePostGetDepositAddressr  rK  parse_deposit_address)	r=  ro  rO  r  r  rD  r  r  rC  s	            r?  fetch_deposit_addresscex.fetch_deposit_addressg  s      	 99&-Q\]	#DGG  /h  %h  i  i!!!"AA&I==&" 11+>

 ::4;;w;WXX ~~h3))$99- 	" Ys%   ACC	A%C.C/)CCc                     U R                  US5      nU R                  US5      nU R                  XB5      nU R                  U5        UUS   U R                  U R                  US5      5      US S.$ )Nr  rD  ro  r  )rk  rD  rg  r  r  )rq  r  check_addressrz  )r=  depositAddressrD  r  r  s        r?  r  cex.parse_deposit_address  s{    "">9=%%njA
%%j;7#" (..t/?/?P\/]^
 	
rA  r   GETc                 T   U R                   S   U   S-   U R                  X5      -   nU R                  X@R                  U5      5      nUS:X  a;  US:X  a  U(       a  USU R	                  U5      -   -  nOU R                  U5      nSS0nOU R                  5         [        U R                  5       5      n	U R                  U5      nX-   U-   n
U R                  U R                  U
5      U R                  U R                  5      [        R                  S5      nSU R                  U	US	.nXsXeS
.$ )Nr   r  r   r	  ?Content-Typezapplication/jsonbase64)r  z
X-AGGR-KEYzX-AGGR-TIMESTAMPzX-AGGR-SIGNATURE)urlr3  bodyheaders)r4  implode_paramsomitextract_params	urlencodejsoncheck_required_credentialsr  secondshmacencodesecrethashlibsha256apiKey)r=  pathr   r3  rO  r  r  r  queryr  auth	signatures               r?  signcex.sign  s   iis#c)D,?,?,MM		&"5"5d";<(?3!666Cyy'"$6 ++-$,,.)G99U#D>D(D		$++d"3T[[5Mw~~_ghI 2"kk$+$-	G dOOrA  reasonr  r3  r  r  c
                    Ucb  Uc  [        U R                  S-   5      eUS   S:X  a#  U R                  U5      n
U R                  U
5      nO[        U R                  S-   U-   5      eU R	                  US5      nUb[  U R                  S-   U-   nU R                  U R                  S   X5        U R                  U R                  S   X5        [        U5      eUR                  S	5      S:  ab  U R                  US
0 5      nU R	                  US5      nUb:  U R                  U R                  S   X5        [        U R                  S-   U-   5      eg )Nz returned empty responser   {z returned unparsed response: error r   r   r   rC  rejectReasonz createOrder() )r#   r.  fix_stringified_json_members
parse_jsonrq  throw_exactly_matched_exceptionr7  throw_broadly_matched_exceptionr   findrK  )r=  ro  r$  r  r3  r  r  r  requestHeadersrequestBodyfixedr'  feedbackrC  r)  s                  r?  handle_errorscex.handle_errors  s@    |"477-G#GHHaC99$???51"477-L#Lt#STT  73ww}t+H001I5[001I5[))88%&!+>>(FB7D++D.AL'44T__W5M|j#DGG.?$?,$NOOrA  r.  )N)F)P__name__
__module____qualname____firstlineno__r   r<  r   rU  dictr	   r  r   r   r  r  r   r  r  r   r  r   r   r  r  r   r  r  r   r  rv  r
  r  r   r  r  r   r  r   r*  r/  r   r9  r6  r   r   rK  rQ  rU  r[  r_  rq  r  r   r   floatr   r  r  r  r   r  r  r  r   r  r  r  r   r   r  r  r  r
   r  r  r"  rY  r3  __static_attributes____classcell__)r>  s   @r?  r'   r'      s~   b# bH	 -/ 4:: 4:l9$ 98 9v *,  (V  (D:4 :F :x ') S ( 68 4 4F 4 6:" *17 *1 *1X4  6 2 <@d[] ,? ,?S ,? ,?bfglbm ,?\ v  > @DB %MS %M %MS\ %MN ?CQUdhqs ;H ;H ;H3 ;H^a ;Hx|  ~B  yC ;Hz
 
4 
 /1 3[ 32 "
T 
6 
EX 
 +- 3g 38
T 
g 
 *, 12 12f) )  GKY]lpy{ L=3 L= L=SV L=fi L=  AE  FK  AL L=\ 7;\`ik Y Y3 YVY Y 59tZ^gi Wc W WTW W =A  c $ ?C2 3  $: :L Lv L L\ mqy{ \. \.I \.Y \.X] \.fi \.| 9=R &S &# &0 59 )c )< .2SW`b ,?s ,?# ,?S ,?gklwgx ,?\t x ; @8 <@daenp -ES -E -E[^ -Euy  {F  vG -E^
T 
X 
Q\ 
B:s : ac 3  C TW gt 0 ~@ 3 3U 3ad 3qt 3  ER 3B vx 3 3U 3Y\ 3il 3  }J 3*#
t #
x #
= #
J =? %: %:> %:N
h 
R` 
 &eBSW P4# s  c TX `c  rA  r'   )- ccxt.async_support.base.exchanger   ccxt.abstract.cexr   rH  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r    r!   r"   r#   ccxt.base.decimal_to_precisionr$   ccxt.base.preciser%   r'   r.  rA  r?  <module>rD     sk    6 )   D  D  D  D  D  D  D  * 0 - . ' . ) 4 %w(K wrA  