
    iXO                    L   d dl mZ d dlmZ d dl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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/  G d dee          Z0dS )    )Exchange)ImplicitAPIN)AccountBalances
CurrenciesCurrencyIntLeverage	Leverages
MarginModeMarginModesMarginModificationMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)NotSupported)	TICK_SIZE)Precisec                   0    e Zd Z fdZi fdZi fdefdZi fdee         fdZ	i fdZ
i fdee         fdZdefdZd	 Zd
 Zi fdefdZdi fdededefdZdVd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dVdedefdZdddi fdedededee         fdZdVdedefdZ ddi fdedededee         fdZ!d Z"dVdede#fdZ$i f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e-         fd%Z.di fd&ede/fd'Z0dddi fde/dededee#         fd(Z1dddi fde/dededee#         fd)Z2di fd&ede/fd*Z3di fde/fd+Z4dVd,e5fd-Z6d. Z7i fd/efd0Z8dddi fd/e/dededee9         fd1Z:dddi fd/e/dededee9         fd2Z;dddi fd/e/dededee9         fd3Z<d4 Z=dVd,e5de9fd5Z>di fdefd6Z?dVdefd7Z@dVdefd8ZAdi fdefd9ZBi fdedeCfd:ZDdVdedeCfd;ZEi fdedeCfd<ZFi fdedeCfd=ZGdi fd>ede/fd?ZHdi fd@ede/fdAZIdi fdefdBZJdVdefdCZKdVd,e5fdDZLdi fdEefdFZMi fd/ed e)dGedHedeNf
dIZOdVd,e5fdJZPdK ZQdddi fde/dedefdLZRdVdefdMZSdi fdee         deTfdNZUdVdeVfdOZWdi fdee         deXfdPZYdVdeZfdQZ[dRdSi ddfdTZ\dU Z] xZ^S )Wascendexc                 r   |                      t          t          |                                           i 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
d/d(d0di d1dd2d(d3dd4d(d5dd6d
d7dd8d
d9d
d:dd;dd<dd=d
d>d
d?d
d@ddAd
i dBd
dCddDddEddFddGd
dHddId
dJd
dKd(dLd
dMd
dNd
dOddPddQddRdd
ddSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgidfdhidgdigdjdkdldmdndodpi dqdrdsdrdtdrdudrdvdrdwdrdxdrdydrdzdrd{drd|drd}drd~drddrddrddrddrddriidrdrdrdrdrddrdrdrdrdrddrdrddrdrdrdddrdrdrdrdrdrdrdrdrd	drdrdrdddddpdrdrdrdrdrdrdidpddriiddridrdrdrdrdrdrdrddrdrdrdrdrdrdrdrdrdrd
drdrdrddddddddpdd|                     d          |                     d          didt
          ddd ddidddddddidddddddddddddddddddddddddddi dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          t          t          t          t          t          t          t          t          t          d	i dddddddd          S )Nidr,   nameAscendEX	countriesSG	rateLimiti  	certifiedFproThasCORSspotmarginswapfutureoption	addMargincancelAllOrderscancelOrdercreateOrdercreateOrderscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchAccountsfetchBalancefetchClosedOrdersfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchLeveragefetchLeveragesfetchLeverageTiersfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCV
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransferfetchTransfersfetchWithdrawalfetchWithdrawalsreduceMarginsetLeveragesetMarginMode)setPositionModetransfer
timeframes151530601202403607201d1w1m)r   5m15m30m1h2h4h6h12hr   r   1Mversionv2urlszdhttps://user-images.githubusercontent.com/1294454/112027508-47984600-8b48-11eb-9e17-d26459cc36c6.jpgrestzhttps://ascendex.comz%https://api-test.ascendex-sandbox.comzKhttps://ascendex.github.io/ascendex-pro-api/#ascendex-pro-api-documentationz8https://ascendex.com/en/feerate/transactionfee-traderatez7https://ascendex.com/en-us/register?inviteCode=EL6BXBQMg      ?)urldiscount)logoapitestwwwdocfeesreferralr   getassets   productstickerzbarhist/infobarhistdepthtradeszcash/assetszcash/productszmargin/assetszmargin/productsfutures/collateralzfutures/contractszfutures/ref-pxzfutures/market-datazfutures/funding-ratesrisk-limit-infozexchange-info)infozwallet/transactionszwallet/deposit/addresszdata/balance/snapshotzdata/balance/history)balancez
order/openzorder/statuszorder/hist/currentrisk)orderorder/batch)r   z	order/allr   )r   postdelete)	cash/balancemargin/balancezmargin/riskzfutures/collateral-balancefutures/positionzfutures/riskfutures/funding-payments
order/histspot/fee)r}   futures/transfer/depositfutures/transfer/withdraw)r   r   )r   accountCategoryaccountGroup)publicprivate)r   zfutures/contractr   zfutures/pricing-datazfutures/tickerr   r   zaccount/info)r   r   zfutures/free-marginzfutures/order/hist/currentr   futures/order/openzfutures/order/status)
z futures/isolated-position-marginzfutures/margin-typezfutures/leverager   r   futures/orderfutures/order/batchr   zsubuser/subuser-transferzsubuser/subuser-transfer-hist)r   r   zfutures/order/all)datar   r   )v1r   r   tradingz0.002)feeSide	tierBased
percentagetakermakerprecisionModeoptionscashmethodv2PrivateDataGetOrderHistfutures)r8   r:   r9   fillResponseFromRequestzBEP20 (BSC)arbitrumSolanaavalanche C chainOmniTRC20ERC20)BSCARBSOLAVAXOMNITRCTRXERCr   r   r   r   r   GO20BEP2BTCBCHLTCMATICSTAKEAKT)z
BEP20(BSC)r   r   r   r   r   r   r   r   BitcoinzBitcoin ABCLitecoinzMatic NetworkxDaiAkash)account-categoryaccount-grouprI   defaultTypeaccountsByTyper}   networksnetworksById
exceptions1900210050026001601060060600503100001100002100003100004100005100006100007100008100009100010100011100012100013100101150001200001200002200003200004200005200006200007200008200009200010200011200012200013200014200015300001300002300003300004300005300006300007300008300009300011300012300013300014300020)	300021300031310001310002310003310004310005510001900001)exactbroadcommonCurrenciesBONDEDBEARBULLBeyondFiPollen)BONDBTCBEARBTCBULLBYNPLN)deep_extendsuperr,   describeparse_numberr)   r$   r    r%   r&   r'   r   r!   r"   )self	__class__s    S/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/ascendex.pyr<  zascendex.describe   s   h 5 5 > > @ @ kC
*kC
JkC
 $kC
 kC
 kC
 4kC
  GGG $G 	G
 %G %G TG "4G tG tG G &tG (G 'G (G  "4!G"  #G G$ %G& $T'G( "4)G* &t+G, (-G. 1%/G0  1G2 +D3G4 *:5G6 +D7G8 &t9G: #J;G< *5=G> $T?G@ "5AGB  CGD !$EG G GF %dGGH ":IGJ #DKGL +JMGN OGP !%QGR dSGT $UUGV +EWGX "4YGZ d[G\ !$]G^ u_G`  aGb $UcGd !$eGf %egG G Gh )%iGj tkGl mGn ToGp tqGr "5sGt #DuGv &uwGx 'yGz $Z{G|  }G~ !%G@ "5AGB #DCGD EGF tGGH  IG GJ $) MG G GkC
d  ekC
@ tAkC
B ~2 C .a ST $  CkC
f    $a &  %a  +A	 
 &q  $Q  %a  *1  ,Q  ,Q  .q  1!  0  -a  21   4Q! " .q# $ ,Q%   0 %&34675645    ,-./0167()$ $ *+/0% %
 *+-./0' ', ,( 1223/0>?4501<=./,-
$ 
$ -.<==>% %) )5,  , /D DN &'012345.//0   	 " ,a$! +A 
 /04578>?<=6789$ $ EF7845<==>127867<=AB% % 237856' '-) )%  % 1 1Mx xgkC
X $!%"&!..w77!..w77 YkC
j YkkC
l $*!%9&  &"%&# # .t .%#/""""	 	 #( %#)/"$$""$#( %%,#"! !3* *mkC
B	 ?J? /? I	?
 I? -? \? l? j? j? j? j? j? j?  j!?" i#?$ 1%?& j'? ?( j)?* j+?, j-?. m/?0 j1?2 13?4 m5?6 m7?8 m9?: m;?< m=?> m??@ mA?B mC?D 1E?F mG?H mI? ? ?J mK?L .M?N .O?P lQ?R lS?T lU?V lW?X lY?Z l[?\ l]?^ l_?` la?b /c?d ie?f lg?h li?j lk? ?l /*/**'*++}? ? ?@ CB BC	kC
H  !!!! !IkC
 k k k	    c                     |                      |d| j        d                   }|                                }|                     |          S )Naccount)
safe_valuer   lower
capitalize)r>  paramsrC  lowercaseAccounts       r@  get_accountzascendex.get_account  s?    //&)T\)5LMM"==??/000rA  returnc                    |                      |          }|                     |          }|                     |          }|                     |dg           }|                     |dg           }|                     |dg           }|                     |d          }|                     |d          }	|                     |d          }
|                     ||	|
          }t          |                                          }i }t          dt          |                    D ]}||         }||         }| 
                    |          }|                     |dd          }|                     |                     |                    }|                     |dd          }|                     |dd	          }|d
k    }d|v }|||d||                     |d          |dd|||dd|                     |d          dddi d||<   |S )z
        fetches all available currencies on an exchange
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        r   	assetCoder   precisionScalenativeScalewithdrawFeewithdrawalFeestatus
statusCodeNormalborrowAssetCodeN	assetNameminmaxminWithdrawalAmt)amountwithdraw)r.   coder   typer9   r/   activedepositr[  fee	precisionlimitsr   )v1PublicGetAssetsv1PublicGetMarginAssetsv1PublicGetCashAssetsrD  index_byr:  listkeysrangelensafe_currency_codesafe_string_2r=  parse_precisionsafe_number_2safe_stringsafe_number)r>  rG  r   r9   r   
assetsData
marginDatacashData
assetsById
marginByIdcashByIddataByIdidsresultir.   currencyr\  scalera  r`  rQ  r^  marginInsides                           r@  fetch_currencieszascendex.fetch_currencies  s9    ''//" --f55( ))&11" __VVR88
__VVR88
??444]]:{;;
]]:{;;
==;77##J
HEE8==??##q#c((## !	 !	AQB|H**2..D&&x1A=QQE))$*>*>u*E*EFFI$$X}oNNC''(LIIF(F-9L &((;??  &  )# 
  $//:LMM#! !	 	 - F4LL0 rA  c                 `   |                      |          }|                     |          }|                     |          }|                     |dg           }|                     |d          }|                     |dg           }|                     |dg           }|                     ||          }	|                     |	d          }
|                     ||
          }t          |                                          }g }t          dt          |                    D ]}||         }||         }|                     |d          }|                     |          }|                     |d          }|                     |d          }d}|dk    s|d	k    r|d
k    rd}|du }| }|rdnd}|                     |d          }|                     |d          }|                     |d          }d}|                     |dd          }|                    d          }|                     |d          }|                     |d          } |                     |          }!|                     |           }"|!dz   |"z   }#|r|                     |d          }$|                     |$d          }|                     |$d          }|                     |d          }%|                     |%d          }|                     |%d          }|!dz   |"z   dz   |z   }#|                     |d          }&|                     |dd          }'|                    i d|d|#d|!d|"d|d|d| d |d!|rd"nd#d#|d$|r|'ndd"|d%dd&dd'|d(|d)||r| nd|&|&|r|                     d*          nddddd|                     |d+          |                     |d          d,ddd-||d-||d-|                     |d.          |                     |d/          d-d0|                     |d1          |d2           |S )3z
        retrieves data on all markets for ascendex
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r   symbolr   settlementAssetrQ  domainFrS  InternalTradingLeveragedETFTNminQtymaxQtytickSize
underlying/r   lotSizeFilterpriceFilterminPricemaxPrice:commissionReserveRatemarginTradabler.   basequotesettlebaseIdquoteIdsettleIdr]  r:   r8   r9   r;   r<   r^  contractlinearr   lotSize)rZ  pricerV  minNotionalmaxNotional)leveragerZ  r  costtradingStartTime)inverser   r   contractSizeexpiryexpiryDatetimestrike
optionTypera  rb  createdr   )v1PublicGetProductsv1PublicGetCashProductsv2PublicGetFuturesContractrD  rf  array_concatr:  rg  rh  ri  rj  rk  ro  rp  rl  split	safe_boolappendr=  safe_integer)(r>  rG  r   r   
perpetualsproductsDataproductsByIdrs  perpetualsDatacashAndPerpetualsDatacashAndPerpetualsByIdrw  rx  ry  rz  r.   marketr  r  rQ  r  r^  r8   r:   r  r  r  r  r  r  partsr  r  r  r  r  r  r  r`  r  s(                                           r@  fetch_marketszascendex.fetch_markets  sZ    ++F33* ++F33< 44V<<
L x<<}}\8<<??444VR@@ $ 1 1(N K K $.CX N N##L2GHH8==??##q#c((## T	 T	AQBb\Fv/@AAH,,X66F%%fh77F%%fh77FF8##3D)D)DFVdLdLdT>D8D!+TTtF%%fh77F%%fh77F''
;;H H++FL(KKJ$$S))E%%eQ//F&&ua00G**622D++G44ECZ%'F ; $ H H))-BB))-BB"oofmDD++KDD++KDDe+c1F:""6+BCCC!^^F4DeLLNMM 2b2&2 2 	2
 &2 &2 72 H2 $2F2 2 D:..d2 2 %2 %2 &2  D!2" &#2$ *.7v::4:> H 1 1# 6 6 6D"&""..vyAA!--fjAA   $#! !
  &% 
  (' 
  $//FF#//FF  $  ,,V5GHHc2 2 2 2 2 2 2f rA  c                     d|                                  i}|                     |                     ||                    }|                     |d          }|                     |d          S )a  
        fetches the current integer timestamp in milliseconds from the ascendex server
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the ascendex server
        requestTimer   requestReceiveAt)millisecondsv1PublicGetExchangeInfoextendrD  r  )r>  rG  requestresponser   s        r@  
fetch_timezascendex.fetch_time  sk     4,,..
 //GV0L0LMM x00  '9:::rA  c                     |                      | j        d          }d}|L|                     |          }|                     |di           }|                      |d          }|| j        d<   |dd|dgS )a  
        fetch all the accounts associated with a profile
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
        r   Nr   r   )r.   r]  r\  r   )ro  r   v1PrivateGetInforD  )r>  rG  r   r  r   s        r@  fetch_accountszascendex.fetch_accounts  s     ''oFF,,V44H" ??8VR88D++D.AAL,8DL) # 	 
 	
rA  c                    |d d d}|                      |dg           }t          dt          |                    D ]~}||         }|                     |                     |d                    }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )	Nr   	timestampdatetimer   r   assetavailableBalancefreetotalBalancetotalrD  ri  rj  rk  ro  rC  safe_balance)r>  r  ry  balancesrz  r   r\  rC  s           r@  parse_balancezascendex.parse_balance  s    
 

 ??8VR88q#h--(( 	# 	#AqkG**4+;+;GW+M+MNNDllnnG"..w8JKKGFO#//HHGG"F4LL  (((rA  c                 &   |d d d}|                      |dg           }t          dt          |                    D ]}||         }|                     |                     |d                    }|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d	          }|                     |d
          }	t          j        ||	          |d<   |||<   |                     |          S )Nr  r   r   r  r  r  r  r  borrowedinterestdebt)	rD  ri  rj  rk  ro  rC  r*   
string_addr  )
r>  r  ry  r  rz  r   r\  rC  r  r  s
             r@  parse_margin_balancezascendex.parse_margin_balance  s   
 

 ??8VR88q#h--(( 		# 		#AqkG**4+;+;GW+M+MNNDllnnG"..w8JKKGFO#//HHGG##GZ88D''<<H%0x@@GFO"F4LL  (((rA  c                    |d d d}|                      |di           }|                      |dg           }t          dt          |                    D ]e}||         }|                     |                     |d                    }|                                 }|                     |d          |d<   |||<   f|                     |          S )Nr  r   collateralsr   r  r   r  r  )	r>  r  ry  r   r  rz  r   r\  rC  s	            r@  parse_swap_balancezascendex.parse_swap_balance  s    
 

 x44oodM2>>q#k**++ 	# 	#A!!nG**4+;+;GW+M+MNNDllnnG#//CCGG"F4LL  (((rA  c                    |                                   |                                  d}d}|                     dd|          \  }}|                     d|          \  }}|                     |dd          }|dk    }|s|rdn|}|                     |d          }|                     | j        di           }|                     ||d          }|                     | j	        di           }|                     |d	          }	d
|	i}
|dk    r|dk    rt          | j        dz             |dk    s|dk    r||
d<   d}|dk    s|dk    r*|                     |                     |
|                    }nM|dk    r*|                     |                     |
|                    }nt          | j        dz   |z   dz             |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://ascendex.github.io/ascendex-pro-api/#cash-account-balance
        :see: https://ascendex.github.io/ascendex-pro-api/#margin-account-balance
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: wallet type, 'spot', 'margin', or 'swap'
        :param str [params.marginMode]: 'cross' or None, for spot margin trading, value of 'isolated' is invalid
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        NrH   r9   Fcrossr   r   r   r.   r   isolatedr:   z+ does not supported isolated margin tradingr   r8   z/ fetchBalance() is not currently supported for  markets)load_marketsload_accountshandle_market_type_and_paramshandle_margin_mode_and_paramsr  omitrD  r   ro  accountsr$   r.   "v1PrivateAccountCategoryGetBalancer  'v2PrivateAccountGroupGetFuturesPositionr(   r  r  r  )r>  rG  
marketType
marginModeisMarginisCrossr   r   rC  r   r  r  s               r@  fetch_balancezascendex.fetch_balance'  sI    	

!??PTV\]]
F!??PVWW
F>>&(E::'"*FgFXXJ
68,,7GLL**>:vNN//$-B77''66\
 *$$:+?+?TW'TTUUUv%%?h+F+F*9G&'&  jH&<&<>>t{{7TZ?[?[\\HH6!!CCDKKPWY_D`D`aaHHtw)ZZ]ggjttuuuX **84448##,,X666%%h///rA  Nr  limitc                    |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |di           }|                     |di           }|                     |d          }	|                     |||	          }
|                     |d          |
d<   |
S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        r  r.   r   tsseqnumnonce)r  r  v1PublicGetDepthr  rD  r  parse_order_book)r>  r  r  rG  r  r  r  r   	orderbookr  ry  s              r@  fetch_order_bookzascendex.fetch_order_book  s     	V$$fTl
 ((Wf)E)EFF0 x44OOD&"55	%%i66	&&y&)DD++Ix@@wrA  r  c                 
   d }|                      |d          }|                      |d          }|dk    rdnd }|                     |||          }|                      |d          }|                     |dg           }	|                     |dg           }
|                      |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|          S )Nr  r]  r8   r  closebidaskopenr  r  highlowr   	bidVolumer   	askVolumevwaplastpreviousClosechanger   averagevolume)
baseVolumequoteVolumer   )ro  safe_symbolrD  safe_ticker)r>  r   r  r  marketIdr]  	delimiterr  r  r  r  r  s               r@  parse_tickerzascendex.parse_ticker  s#    	##FH55// FNNCC	!!(FI>>  11oofeR00oofeR00// !
f!
!
 !
 D$$VV44	!

 4##FE22!
 4##C++!
 ))#q11!
 4##C++!
 ))#q11!
 D!
 D!
 U!
 E!
 T!
 d!
  $!!
" t#!
$ **68<<)!
 !
 !
* +  	rA  c                    |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |di           }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        r  r.   r   )r  r  v1PublicGetTickerr  	safe_dictr	  )r>  r  rG  r  r  r  r   s          r@  fetch_tickerzascendex.fetch_ticker  s     	V$$fTl
 ))$++gv*F*FGG" ~~h33  v...rA  symbolsc                    |                                   i }d}|X|                     |d          }|                     |          }|                     |          }d                    |          |d<   d}|                     d||          \  }}d}|dk    r*|                     |                     ||                    }n)|                     |                     ||                    }|                     |dg           }	t          |	t                    s|                     |	g|          S |                     |	|          S )a`  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: https://ascendex.github.io/ascendex-pro-api/#ticker
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#ticker
        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   ,r  rm   r8   r   )r  rD  r  
market_idsjoinr  r  r  v2PublicGetFuturesTicker
isinstancerg  parse_tickers)
r>  r  rG  r  r  r  	marketIdsr]  r  r   s
             r@  fetch_tickerszascendex.fetch_tickers  s;    	__Wa00F[[((F00I # 3 3GH99.&RXYYf6>>--dkk'6.J.JKKHH44T[[&5Q5QRRH& x44$%% 	7%%tfg666!!$000rA  c           	      0   |                      |di           }|                     |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   r  ohlcv)rD  r  rp  )r>  ohlcvr  r   s       r@  parse_ohlcvzascendex.parse_ohlcv)  s      ufb11dD))T3''T3''T3''T3''T3''
 	
rA  r   sincec                 h   |                                   |                     |          }|d         |                     | j        ||          d}|                     |          }|                     | j        di           }	|                     |	dd          }
|;||d<   ||
}nt          ||
          }| 	                    |||z  dz  d	          |d
<   n|||d<   | 
                    |                     ||                    }|                     |dg           }|                     |||||          S )aQ  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r.   )r  intervalr`   r  i  Nfromi  r   tonr   )r  r  ro  r~   parse_timeframerD  r   r  rW  sumv1PublicGetBarhistr  	safe_listparse_ohlcvs)r>  r  	timeframer   r  rG  r  r  durationr   defaultLimitr  r   s                r@  fetch_ohlcvzascendex.fetch_ohlcvC  sF    	V$$Tl(()YOO
 
 ''	22//$,bAA(('3??#GFO}$E<00 HHUEH,<t,CQGGGDMM GCL**4;;w+G+GHH* ~~h33  vy%GGGrA  c                 h   |                      |d          }|                     |dd          }|                     |d          }|                     |dd          }|rdnd}|                     d |          }|                     |||                     |          |d	         d d d d |||d d d
|          S )Nr  r  pqbmFsellbuyr  )r   r  r  r  r.   r   r]  takerOrMakersider  rZ  r  r`  )r  rl  ro  r  safe_market
safe_tradeiso8601)r>  trader  r  priceStringamountStringbuyerIsMakerr6  s           r@  parse_tradezascendex.parse_tradey  s     %%eT22	((==''s33~~eT599%0vv5!!$//"Y//X&  " 
  
   	rA  c                 T   |                                   |                     |          }d|d         i}|||d<   |                     |                     ||                    }|                     |dg           }|                     |dg           }	|                     |	|||          S )a&  
        get the list of most recent trades for a particular symbol
        :see: https://ascendex.github.io/ascendex-pro-api/#market-trades
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :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>`
        r  r.   Nr%  r   )r  r  v1PublicGetTradesr  rD  r)  parse_trades)
r>  r  r   r  rG  r  r  r  recordsr   s
             r@  fetch_tradeszascendex.fetch_trades  s     	V$$fTl
  GCL))$++gv*F*FGG //(FB7744  >>>rA  c                 B    ddddddd}|                      |||          S )Nr  closedcanceledrejected)
PendingNewNewPartiallyFilledFilledCanceledRejectedro  r>  rQ  statusess      r@  parse_order_statuszascendex.parse_order_status  s:     %""
 
 &&999rA  c           
         |                      |                     |d                    }|                     |d          }|                     ||d          }|                     |dd          }|                     |d          }||}|                     |d          }|                     |d          }	|                     |d	          }
|                     |g d
          }|                     |d          }|                     |d          }|t          |          dk     rd }|                     |d          }|}||dk    rd}|dk    rd}|                     |d          }|                     |dd          }d }|0|                     |d          }| 	                    |          }||d}| 
                    |d          }d }|                     |d          }|dk    rd}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'|          S )(NrQ  r  r  r  sendingTimelastExecTimer  orderQtyavgPx)cumFilledQtycumQtyfillQtyorderIdr.   r   	orderType	stoplimitr  
stopmarketr  r6  cumFeer`  feeAsset)r  r{  	stopPriceexecInst
reduceOnlyTPostr   clientOrderIdr  lastTradeTimestampr]  timeInForcepostOnlytriggerPricerZ  r  )r  filled	remainingrQ  r`  r   )rQ  ro  r  safe_integer_2r  safe_string_nrj  safe_string_lowerrn  rk  rp  
safe_orderr9  )r>  r   r  rQ  r  r  r  re  r  rZ  r  ri  r.   rd  rawTypeLowerr]  r6  feeCostr`  feeCurrencyIdfeeCurrencyCoder`  rb  ra  rg  s                            r@  parse_orderzascendex.parse_order  sN   R (()9)9%)J)JKK##E844!!(FC88''{MJJ	!..unEE*I  00!!%44""5'22##E+P+P+PQQeY//((55$=!!A%% $--e[AA#{**|++%%eV44$$UHe<< ,,UJ??M"55mDDO+ C $$UK88	
##E:66|##JvH  
E 
" 
 ] 
 	 

 Y// 
 !"4 
 f 
 D 
 4 
  
 * 
 D 
 U 
  
 I 
  f! 
" D# 
$ / 
  
  
0 1  	rA  c                    |                                   |                                  |                     | j        di           }|                     |d          }d|i}|                     |                     ||                    }|                     |di           }|                     |dg           }i }t          dt          |                    D ]}	||	         }
|                     |
d          }| 	                    |dd          }|                     |
d	i           }|
|| 
                    |d
          | 
                    |d          ddd||<   |S )a  
        fetch the trading fees for multiple markets
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
        r   r.   r   r   r   r  Nr  r`  r   r   )r   r  r   r   r   r   )r  r  rD  r  ro  v1PrivateAccountGroupGetSpotFeer  ri  rj  r  rp  )r>  rG  rC  r   r  r  r   r   ry  rz  r`  r  r  
takerMakers                 r@  fetch_trading_feeszascendex.fetch_trading_feesv  sh    	//$-B77''66\
 77GV8T8TUU" x44tVR00q#d))$$ 	 	Aq'C''X66H%%hc::FeR88J ))*g>>))*g>>"! F6NN rA  r]  r6  rZ  r  c                 `   |                      |          }d}d}	|                     d|          \  }}|                     d||          \  }	}|                     | j        di           }
|                     |
|	d          }|d}|                     | j        di           }|                     |d          }|                     |dd          }|||d         |                                 | 	                    ||          ||d	}|d
k    p|dk    }|dk    p|dk    }|                     |d          }| 
                    |d|          }|                     |dd          }|                     |dd          }|r|                     ||          |d<   |dk    rd|d<   |dk    rd|d<   |rd|d<   |(|                     ||          |d<   |rd|d<   n|rd|d<   |||d<   |d         r|||d<   n||d<   |rd|d<   |rd|d<   |                     |ddg          }|                     ||          S )a.  
         * @ignore
        helper function to build request
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much 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 str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
        :param bool [params.postOnly]: True or False
        :param float [params.stopPrice]: the price at which a trigger order is triggered at
        :returns dict: request to be sent to the exchange
        NcreateOrderRequestr   r   r9   r   r.   rd  )r   r   r  timerU  r[  r6  r  stop_marketr  
stop_limitrf  Frb  rh  r`  
orderPriceIOCFOKTrg  r[  r8   categoryr   
ReduceOnlyra  rc  )r  r  r  rD  r   ro  r  rl  r  amount_to_precisionis_post_onlyr  safe_value_2price_to_precisionr  r  )r>  r  r]  r6  rZ  r  rG  r  r  r  r   r   rC  r   rd  r  isMarketOrderisLimitOrderrf  rg  rb  r`  s                         r@  create_order_requestzascendex.create_order_request  s    V$$

!??@TV\]]
F!??@TV\^dee
F7GLL**>:vNN!&O//$-B77w55**6?DII) /Tl%%''00@@

 

 (*F0ECdl.B&&v}==$$]E6BB^^FL%@@
%%fnkJJ	 	K$($;$;FE$J$JGL!%%*GM"%%*GM" 	'"&GJ #'#:#:69#M#MGK  5'3$$ 5'4$$)GDM&> 	-*&5
#*9G&' 3&2
# -&,
#6L.#ABB{{7F+++rA  c                    |                                   |                                  |                     |          }|                     ||||||          }d}	|d         r|                     |          }	n|                     |          }	|                     |	di           }
|                     |
ddi           }|                     ||          S )a  
        create a trade order on the exchange
        :see: https://ascendex.github.io/ascendex-pro-api/#place-order
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#new-order
        :param str symbol: unified CCXT market symbol
        :param str type: "limit" or "market"
        :param str side: "buy" or "sell"
        :param float amount: the amount of currency to trade
        :param float [price]: *ignored in "market" orders* the price at which the order is to be fullfilled at in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
        :param bool [params.postOnly]: True or False
        :param float [params.stopPrice]: the price at which a trigger order is triggered at
        :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice that the attached take profit order will be triggered(perpetual swap markets only)
        :param float [params.takeProfit.triggerPrice]: *swap only* take profit trigger price
        :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice that the attached stop loss order will be triggered(perpetual swap markets only)
        :param float [params.stopLoss.triggerPrice]: *swap only* stop loss trigger price
        :returns: `An order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr:   r   r   r   )	r  r  r  r  %v2PrivateAccountGroupPostFuturesOrder!v1PrivateAccountCategoryPostOrderrD  r  rs  )r>  r  r]  r6  rZ  r  rG  r  r  r  r   r   s               r@  create_orderzascendex.create_order  s    ( 	V$$++FD$vVV&> 	GAA'JJHH==gFFH@ x44!!$<<v...rA  ordersc           	          |                                   |                                  g }d}d}t          dt          |                    D ]#}||         }|                     |d          }||}n||k    rt          | j        dz             |                     |d          }	|                     |d          }
|                     |d          }|                     |d          }|                     |d	i           }|                     d
|          }|d         }|"||}n||k    rt          | j        dz             | 	                    ||	|
|||          }|
                    |           %|                     |          }|                     | j        di           }|                     ||d         d          }|d}|                     | j        di           }|                     |d          }i }d}|d         rt          | j        dz             ||d<   ||d<   ||d<   |                     |          }|                     |di           }|                     |dg           }|                     ||          S )a
  
        create a list of trade orders
        :see: https://ascendex.github.io/ascendex-pro-api/#place-batch-orders
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#place-batch-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 exchange API endpoint
        :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
        :param bool [params.postOnly]: True or False
        :param float [params.stopPrice]: the price at which a trigger order is triggered at
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   r  z; createOrders() requires all orders to have the same symbolr]  r6  rZ  r  rG  rA   zS createOrders() requires all orders to have the same margin mode(isolated or cross)r   r   r9   r.   r:   zG createOrders() is not currently supported for swap markets on ascendexr   r   r  r   r   )r  r  ri  rj  ro  r$   r.   rD  r  r  r  r  r   r  r(   &v1PrivateAccountCategoryPostOrderBatchr)  parse_orders)r>  r  rG  ordersRequestsr  r  rz  rawOrderr  r]  r6  rZ  r  orderParamsmarginResultcurrentMarginModeorderRequestr  r   r   rC  r   r  r  r   r   s                             r@  create_orderszascendex.create_ordersN  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==nkZZL ,Q ,%!2JJ!%666(  4I  *I  J  J  J44XtT6SXZeffL!!,////V$$7GLL**>6&>6RR!&O//$-B77w55&> 
	Ltw)rrsss (4GO$*9G&' .GHBB7KKH. x44~~dFB//  v...rA  r.   c                    |                                   |                                  d}||                     |          }|                     d||          \  }}|                     | j        di           }|                     ||d          }|                     | j        di           }	|                     |	d          }
|
||d}d}|dk    s|d	k    r*|                     | 	                    ||                    }nR|d
k    r/||d<   | 
                    | 	                    ||                    }nt          | j        dz   |z   dz             |                     |di           }|                     ||          S )a  
        fetches information on an order made by the user
        :see: https://ascendex.github.io/ascendex-pro-api/#query-order
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#query-order-by-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>`
        Nrd   r   r   r   r.   )r   r   rZ  r8   r9   r:   r   z- fetchOrder() is not currently supported for r  r   )r  r  r  r  rD  r   ro  r  &v1PrivateAccountCategoryGetOrderStatusr  *v2PrivateAccountGroupGetFuturesOrderStatusr(   r.   r  rs  )r>  r.   r  rG  r  r]  queryr   r   rC  r   r  r  r   s                 r@  fetch_orderzascendex.fetch_order  s    	[[((F88vvVVe7GLL**>4HH//$-B77w55) /
 

 FNN 0 0BB4;;wX]C^C^__HHV^^*9G&'FFt{{SZ\aGbGbccHHtw)XX[__bllmmmH ~~h33f---rA  c                    |                                   |                                  d}||                     |          }|d         }|                     | j        di           }|                     |d          }|                     d||          \  }}	|                     | j        di           }
|                     |
|d          }||d}d}|d	k    s|d
k    r*|                     | 	                    ||	                    }nR|dk    r/||d<   | 
                    | 	                    ||	                    }nt          | j        dz   |z   dz             |                     |dg           }|dk    r|                     ||||          S g }t          dt          |                    D ]3}|                     ||         |          }|                    |           4|                     ||||          S )ak  
        fetch all unfilled currently open orders
        :see: https://ascendex.github.io/ascendex-pro-api/#list-open-orders
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-open-orders
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open 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>`
        Nr  r   r.   rc   r   r   )r   r   r8   r9   r:   r   z2 fetchOpenOrders() is not currently supported for r  r   r   )r  r  r  rD  r  r  r   ro  $v1PrivateAccountCategoryGetOrderOpenr  (v2PrivateAccountGroupGetFuturesOrderOpenr(   r.   r  ri  rj  rs  r  filter_by_symbol_since_limit)r>  r  r   r  rG  r  rC  r   r]  r  r   r   r  r  r   r  rz  r   s                     r@  fetch_open_orderszascendex.fetch_open_orders
  s    	[[((FH%F//$-B77w55889JFTZ[[e7GLL**>4HH) /
 
 FNN 0 0@@WV[A\A\]]HHV^^*9G&'DDT[[QXZ_E`E`aaHHtw)]]`ddgqqrrrH x44i''$$T65%@@@q#d))$$ 	! 	!A$$T!Wf55EMM%    00NNNrA  c                    |                                   |                                  |                     | j        di           }|                     |d          }i }d}| |                     |          }|d         |d<   |                     d||          \  }	}
|                     | j        di           }|                     |dd          }|                     |	||dd	          }|||d
<   |                     |d          }|||d<   |                     | j        di           }|                     ||	d          }d}|dk    r;||d<   ||d<   |||d<   | 	                    | 
                    ||
                    }n|dk    r6||d<   |||d<   |                     | 
                    ||
                    }n^|dk    r;||d<   ||d<   |||d<   |                     | 
                    ||
                    }nt          | j        dz   |	z   dz             |                     |d          }t          |t                     }|s|                     |dg           }|                     ||||          S )a  
        fetches information on multiple closed orders made by the user
        :see: https://ascendex.github.io/ascendex-pro-api/#list-history-orders-v2
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-current-history-orders
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch orders for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r   r.   Nr  rI   r   r   /v2PrivateAccountGroupGetFuturesOrderHistCurrent)r8   r9   r:   	startTimeuntilendTimer   r   +v1PrivateAccountCategoryGetOrderHistCurrentr   r   r  rC  pageSizez4 fetchClosedOrders() is not currently supported for r  r   )r  r  rD  r  r  r  r   ro  get_supported_mappingr  r  r   r  r(   r.   r  rg  r  )r>  r  r   r  rG  rC  r   r  r  r]  r  r   defaultMethodr   r  r   r   r  r   isArrays                       r@  fetch_closed_orderszascendex.fetch_closed_ordersy  s    	//$-B77w55

 [[((F &tGH889LfV\]]e//$,0CRHH(((<WXX++D!#E3
 3
  
 #(GK   11!&GI7GLL**>4HHBBB'3GO$*9G&' #( GGT[]bHcHcddHH222!0GI #( 55dkk'56Q6QRRHHHHH'3GO$*9G&' &+
#KKDKKX_afLgLghhHHtw)__bffisstttx x00T4(( 	5??444D  vue<<<rA  c                    |t          | j        dz             |                                  |                                  |                     |          }|                     d||          \  }}|                     | j        di           }|                     ||d          }|                     | j	        di           }	|                     |	d          }
|
||d         | 
                                dd	}|                     |d
d          }|||d<   n||d<   |                     |d
dg          }d}|dk    s|dk    r*|                     |                     ||                    }nR|dk    r/||d<   |                     |                     ||                    }nt!          | j        dz   |z   dz             |                     |di           }|                     |ddi           }|                     ||          S )a  
        cancels an open order
        :see: https://ascendex.github.io/ascendex-pro-api/#cancel-order
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#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>`
        Nz) cancelOrder() requires a symbol argumentr?   r   r   r   r.   foobar)r   r   r  rz  r.   rd  rZ  r8   r9   r:   r   z. cancelOrder() is not currently supported for r  r   r   r   )r#   r.   r  r  r  r  rD  r   ro  r  r  rl  r  #v1PrivateAccountCategoryDeleteOrderr  'v2PrivateAccountGroupDeleteFuturesOrderr(   r  rs  )r>  r.   r  rG  r  r]  r  r   r   rC  r   r  rd  r  r   r   s                   r@  cancel_orderzascendex.cancel_order  s    >#DG.Y$YZZZV$$88PVWWe7GLL**>4HH//$-B77w55) /Tl%%''
 
 **6?DII !#GI)GDMYYv'>??FFNN 0 0??GUZ@[@[\\HHV^^*9G&'CCDKKPWY^D_D_``HHtw)YY\``cmmnnn@ x44!!$<<v...rA  c                    |                                   |                                  d}||                     |          }|                     d||          \  }}|                     | j        di           }|                     ||d          }|                     | j        di           }|                     |d          }	|	||                                 d}
||d         |
d<   d}|d	k    s|d
k    r*| 	                    | 
                    |
|                    }nR|dk    r/||
d<   |                     | 
                    |
|                    }nt          | j        dz   |z   dz             |S )a  
        cancel all open orders
        :see: https://ascendex.github.io/ascendex-pro-api/#cancel-all-orders
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-all-open-orders
        :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not 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>`
        Nr>   r   r   r   r.   )r   r   rz  r  r8   r9   r:   r   z2 cancelAllOrders() is not currently supported for r  )r  r  r  r  rD  r   ro  r  r  &v1PrivateAccountCategoryDeleteOrderAllr  *v2PrivateAccountGroupDeleteFuturesOrderAllr(   r.   )r>  r  rG  r  r]  r  r   r   rC  r   r  r  s               r@  cancel_all_orderszascendex.cancel_all_orders  s    	[[((F889JFTZ[[e7GLL**>4HH//$-B77w55) /%%''
 

  &tGHFNN 0 0BB4;;wX]C^C^__HHV^^*9G&'FFt{{SZ\aGbGbccHHtw)]]`ddgqqrrrF rA  r{  c                 0   |                      |d          }|                      |d          }|                      ||          }|                     |           |d n|d         }|                      |d          }|                     ||          }|||||dS )NaddresstagIdr\  
blockchain)r{  r  tagnetworkr   )ro  check_addressnetwork_id_to_code)	r>  depositAddressr{  r  r  r  r\  	chainNamer  s	            r@  parse_deposit_addresszascendex.parse_deposit_address  s     "">9==  99~u557### (ttx/?$$^\BB	)))T::"
 
 	
rA  c                 f    |                      | j        d          }|                     |||          S )Nr   )r  r   ro  )r>  	networkIdr   s      r@  safe_networkzascendex.safe_network  s/    ~~dlNCCiCCCrA  r\  c                 V   |                                   |                     |          }|                     |dd          }|                     |          }|                     |dg          }|d         |d}|                     |                     ||                    }|                     |di           }|                     |dg           }	t          |	          }
d}|
dk    r| 
                    |	d          }|Pt          |                                          }d	                    |          }t          | j        d
z   |z             |                     ||i           }n|                     |	di           }|                     ||          }|                     |d|i          S )a  
        fetch the deposit address for a currency associated with self account
        :see: https://ascendex.github.io/ascendex-pro-api/#query-deposit-addresses
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.network]: unified network code for deposit chain
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        r  r  r.   )r  r  r   r  Nr   z, za fetchDepositAddress() returned more than one address, a chainName parameter is required, one of r   r   )r  r{  rl  network_code_to_idr   v1PrivateGetWalletDepositAddressr  r  r)  rj  rf  rg  rh  r  r#   r.   r  )r>  r\  rG  r{  networkCoder  r  r  r   	addressesnumAddressesr  addressesByChainName
chainNameschainsry  s                   r@  fetch_deposit_addresszascendex.fetch_deposit_address  s    	==&&((KHH++K88	6K=11d^#
 
 88Wf9U9UVVD ~~h33NN4B77	9~~!#'==K#H#H  !"6";";"="=>>
:..'  3V  )V  Y_  )_  `  `  `nn%99bIIGG nnY266G++GX>>{{6H$
   	rA  c           	      b    ddi}|                      ||||                     ||                    S )a  
        fetch all deposits made to an account
        :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>`
        txTyper_  fetch_transactionsr  r>  r\  r   r  rG  r  s         r@  fetch_depositszascendex.fetch_deposits6	  s;     i
 &&tUE4;;wPV;W;WXXXrA  c           	      b    ddi}|                      ||||                     ||                    S )a  
        fetch all withdrawals made from an account
        :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>`
        r  
withdrawalr  r  s         r@  fetch_withdrawalszascendex.fetch_withdrawalsD	  s;     l
 &&tUE4;;wPV;W;WXXXrA  c                 p   |                                   i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |                     ||                    }|                     |di           }|                     |dg           }	|                     |	|||          S )a$  
        fetch history of deposits and withdrawals
        :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  startTsr  r   )r  r{  v1PrivateGetWalletTransactionsr  rD  r)  parse_transactions)
r>  r\  r   r  rG  r  r{  r  r   transactionss
             r@  fetch_deposits_withdrawalsz#ascendex.fetch_deposits_withdrawalsR	  s     	
 }}T**H'~GG!&GI"'GJ66t{{7F7S7STT4 x44~~dFB77&&|XueLLLrA  c                 >    ddddd}|                      |||          S )NpendingokrG  )	reviewingr  	confirmedrG  rN  rO  s      r@  parse_transaction_statusz!ascendex.parse_transaction_status	  s4    " "	
 
 &&999rA  c                 D   |                      |di           }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }	t          j        ||	          }|                     ||          }
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S )NdestAddressr  destTagrz  r  rZ  
commissionr   r.   	requestIdtxidnetworkTransactionIdr]  transactionTyper{  r  rQ  r  r  addressFrom	addressTor  tagFromtagToupdated)r{  r  rateF)commentr`  internal)	rD  ro  r  r*   
string_subrk  r=  r  r9  )r>  transactionr{  r  r  r  r  
currencyIdr<  feeCostStringr\  s              r@  parse_transactionzascendex.parse_transaction	  s5   & ook="EE"";	::{I66%%k6::	%%k7;;
''X>>((lCC),FF&&z8<<
K
$"";<<
 D$$[2HII
 D$$[2CDD	

 
 t
 d''55
 d33D4D4D[RZ4[4[\\
 
 Y//
 w
 4
 
 3
 t
  S!
" t#
$  ))-88 
 1
 
 
 	
rA  c                 f   |                                   |                                  |                     | j        di           }|                     |d          }d|i}|                     |                     ||                    }|                     |di           }|                     |dg           }g }	t          dt          |                    D ]0}
|		                    | 
                    ||
                              1|                     |          }|                     |	d|d          S )a*  
        fetch all open positions
        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
        r   r.   r   r   	contractsr  F)r  r  rD  r  ro  r  r  ri  rj  r  parse_positionmarket_symbolsfilter_by_array_positions)r>  r  rG  rC  r   r  r  r   positionry  rz  s              r@  fetch_positionszascendex.fetch_positions	  s)    	//$-B77''66\
 ??GU[@\@\]]P x44??4b99q#h--(( 	< 	<AMM$--hqk::;;;;%%g..--fhOOOrA  c                    |                      |d          }|                     ||          }|                      |d          }t          j        |d          r|                      |d          }|                      |d          }|dk    rdnd}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 |                     |d          |                     |d          d
          S ) Nr  buyOpenOrderNotional0sellOpenOrderNotional
marginTypecrossedr  r  isolatedMarginr   r.   notionalr  liquidationPrice
entryPriceavgOpenPriceunrealizedPnlr   r  r  r  	markPrice	lastPricer6  hedgedr  r  r  stopLossPricetakeProfitPrice)
lastUpdateTimestampmaintenanceMarginmaintenanceMarginPercentage
collateralinitialMargininitialMarginPercentager  marginRatior  r  )	ro  r7  r*   	string_eqsafe_positionr=  rp  rm  r  )r>  r  r  r  r  r  r  r  s           r@  r  zascendex.parse_position
  sv   . ##Hh77!!(F33##H.DEEXs++ 	K''2IJJH%%h==
!+y!8!8WWz

##))(4DEEJ!! #
H#
$#
 fX&#
 ))(33	#

 *#
 #
 $**8^DD#
 T--hHH#
 $#
 ))(J??#
 D,,V^DD#
 ))(K@@#
 #
 D**8V<<#
 d#
  !#
" ##
$ $(!%+/$!'+))(J??!--hHH#//:KLL7#
 #
 #
   	rA  c                 
   |                      |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|                     |          S )Nr  rz  fundingRatenextFundingTimer   r  
indexPriceinterestRater  estimatedSettlePricer  r  previousFundingRatenextFundingRatepreviousFundingTimestampnextFundingTimestamppreviousFundingDatetimenextFundingDatetimefundingTimestampfundingDatetime)ro  r  r  rp  r=  r9  )r>  r  r  r  r  currentTimer   nextFundingRateTimestamps           r@  parse_funding_ratezascendex.parse_funding_rateG
  s    ##Hh77!!(F33''&99**8]CC#'#4#4X?P#Q#Q 
H
f
 ))(K@@
 $**8\BB	

 D--c22
 #D
 
 [11
 "4
 t
 '
 #D
 &t
 "4
 ?
   8!
" t||,DEE#
 	
rA  c                 2   |                                   |                     |          }|                     |          }|                     |di           }|                     |dg           }|                     |          }|                     |d|          S )af  
        fetch the funding rate for multiple markets
        :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 `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
        r   r  r  )r  r  v2PublicGetFuturesPricingDatarD  parse_funding_ratesfilter_by_array)r>  r  rG  r  r   r  ry  s          r@  fetch_funding_rateszascendex.fetch_funding_ratesl
  s     	%%g..55f==2 x44OOD+r::	)))44##FHg>>>rA  c                 *   |                                   |                                  |                     |          }|                     | j        di           }|                     |d          }|                     ||          }||d         |d}|                     |                     ||                    }	|dk    rt          j
        |          }|                     |                     |	|          |                     |          |d          S )Nr   r.   )r   r  rZ  reduce)rZ  r]  )r  r  r  rD  r  ro  r  6v2PrivateAccountGroupPostFuturesIsolatedPositionMarginr  r*   
string_absparse_margin_modificationr=  )
r>  r  rZ  r]  rG  r  rC  r   r  r  s
             r@  modify_margin_helperzascendex.modify_margin_helper
  s   V$$//$-B77''66))&&99)Tl
 

 NNt{{[bdjOkOkll 8'//F{{499(FKK''//N
 N
   	rA  c                 t    |                      |d          }|dk    rdnd}||d         d dd d |d         |d d d
S )	Nr\  r  r  failedr  r  r  )
r   r  r]  r  rZ  r  r\  rQ  r  r  rN  )r>  r   r  	errorCoderQ  s        r@  r3  z"ascendex.parse_margin_modification
  sb     $$T622	#s**X&$7O
 
 	
rA  c                 4    |                      || d|          S )aS  
        remove margin from a position
        :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>`
        r0  r4  r>  r  rZ  rG  s       r@  reduce_marginzascendex.reduce_margin
  s      ((&(FKKKrA  c                 2    |                      ||d|          S )a6  
        add 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>`
        addr9  r:  s       r@  
add_marginzascendex.add_margin
  s     ((GGGrA  r  c                     |t          | j        dz             |dk     s|dk    rt          | j        dz             |                                  |                                  |                     |          }|d         st          | j        dz             |                     | j        di           }| 	                    |d	          }||d	         |d
}| 
                    |                     ||                    S )a  
        set the level of leverage for a market
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-contract-leverage
        :param float leverage: the rate of leverage
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        Nz) setLeverage() requires a symbol argumentr   d   z% leverage should be between 1 and 100r:   z+ setLeverage() supports swap contracts onlyr   r.   )r   r  r  )r#   r.   r$   r  r  r  r%   rD  r  ro  (v2PrivateAccountGroupPostFuturesLeverager  )r>  r  r  rG  r  rC  r   r  s           r@  set_leveragezascendex.set_leverage
  s    >#DG.Y$YZZZqLLhnnTW'NNOOOV$$f~ 	UDG&SSTTT//$-B77''66)Tl 
 

 <<T[[RX=Y=YZZZrA  r  c                 8   |t          | j        dz             |                                }|dk    rd}|dk    r|dk    rt          | j        dz             |                                  |                                  |                     |          }|                     | j        di           }| 	                    |d          }||d         |d	}|d
         st          | j        dz             |                     |                     ||                    S )a  
        set margin mode to 'cross' or 'isolated'
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-margin-type
        :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  r  z@ setMarginMode() marginMode argument should be isolated or crossr   r.   )r   r  r  r:   z- setMarginMode() supports swap contracts only)r#   r.   rE  r$   r  r  r  rD  r  ro  r%   *v2PrivateAccountGroupPostFuturesMarginTyper  )r>  r  r  rG  r  rC  r   r  s           r@  set_margin_modezascendex.set_margin_mode
  s-    >#DG.[$[\\\%%''
  "J##
i(?(?TW'iijjjV$$//$-B77''66)Tl$
 

 f~ 	WDG&UUVVV>>t{{7TZ?[?[\\\rA  c                     |                                   |                     |          }|                     |d          }|                     |          }|                     ||d          S )a  
        retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
        :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   r  )r  r  rD  r  parse_leverage_tiers)r>  r  rG  r  r   s        r@  fetch_leverage_tierszascendex.fetch_leverage_tiers  si     	226::: x00%%g..((wAAArA  c                 >   |                      |dg           }|                     |d          }|                     ||          }g }t          dt	          |                    D ]}||         }|                     |d          }|                    |                     |d          |d         |                     |d          |                     |d          |                     |d	          |                     t          j
        d
|                    |d           |S )zq
        :param dict info: Exchange market response for 1 market
        :param dict market: CCXT market
        marginRequirementsr  r   initialMarginRater   r  positionNotionalLowerBoundpositionNotionalUpperBoundmaintenanceMarginRater   )tierr{  r  r  rN  maxLeverager   )rD  ro  r7  ri  rj  r  r'  rp  r=  r*   
string_div)	r>  r   r  rJ  r.   tiersrz  rO  rK  s	            r@  parse_market_leverage_tiersz$ascendex.parse_market_leverage_tiers;  s-   8 "__T3GLLdH--!!"f--q#01122 	 	A%a(D $ 0 07J K KLLA"7O#//6RSS#//6RSS)-)9)9$@W)X)X#001CCIZ1[1[\\      rA  c                    |                      |dg           }t          |          }|d d dd d di d}t          d|          D ]}||         }|                     |d          }|                     |d          }	|                     ||	          }
d d d|                     |d          ddd	|d
         |
<   |dk    r*|                     |d          |d         d<   d|d         d<   |S )N
blockChain)r`  r   )r   r[  r_  r   r   r  r\  rO  F)r_  r[  r   r   r[  r`  r   )rD  rj  ri  ro  r  rp  )r>  r`  r{  blockChainsblockChainsLengthry  rz  rU  r  currencyCoder  s              r@  parse_deposit_withdraw_feez#ascendex.parse_deposit_withdraw_feei  s?   ( ooc<<<,," 
 "  
 
 q+,, 	9 	9A$QJ(([AAI++Hf==L11)\JJK#'t<<$($4$4Z$O$O_dee/ /F:{+ !A%%,0,<,<Z,W,Wz"5)38z"<0rA  codesc                     |                                   |                     |          }|                     |d          }|                     ||d          S )ao  
        fetch deposit and withdraw fees
        :see: https://ascendex.github.io/ascendex-pro-api/#list-all-assets
        :param str[]|None codes: list of unified currency codes
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
        r   rL  )r  v2PublicGetAssetsr)  parse_deposit_withdraw_fees)r>  rZ  rG  r  r   s        r@  fetch_deposit_withdraw_feesz$ascendex.fetch_deposit_withdraw_fees  sT     	))&11~~h////e[IIIrA  fromAccount	toAccountc                    |                                   |                                  |                     | j        di           }|                     |d          }|                     |          }|                     ||          }|                     | j        di           }	|                     |	||          }
|                     |	||          }|
dk    r|dk    rt          | j	        dz             |||d         |
|d}| 
                    |                     ||                    }|                     | j        di           }|                     |dd	          }|                     ||          }|r||d
<   ||d<   ||d<   ||d<   |S )u  
        transfer currency internally between wallets on the same account
        :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   r   zX transfer() only supports direct balance transfer between spot and swap, spot and margin)r   rZ  r  r_  r`  r}   r   Tr_  r`  rZ  r{  )r  r  rD  r  ro  r{  currency_to_precisionr   r   r.   !v1PrivateAccountGroupPostTransferr  r  parse_transfer)r>  r\  rZ  r_  r`  rG  rC  r   r{  r   fromIdtoIdr  r  transferOptionsr   r}   s                    r@  r}   zascendex.transfer  s    	//$-B77''66==&&++D&997GLL!!.+{KK	9EEV  +E  !E  F  F  F)d^!
 
 99$++gv:V:VWW //$,
BGG"&..B[]a"b"b&&x::" 	(&1H]#$-H[!!'HX#'HZ rA  c                     |                      |d          }|                     d |          }|d d d |d d d |                     |          d	S )Nr\  )	r   r.   r  r  r{  rZ  r_  r`  rQ  )r  rk  parse_transfer_status)r>  r}   r{  rQ  rX  s        r@  rd  zascendex.parse_transfer  sf     ""8V44..tX>>$0088

 

 
	
rA  c                     |dk    rdS dS )Nr   r  r6   )r>  rQ  s     r@  ri  zascendex.parse_transfer_status  s    Q;;4xrA  c           	      d   |                                   |                                  d}|                     |dd          \  }}|r|                     d||||dd          S |                     | j        di           }|                     |d          }d|i}d	}	| |                     |          }	|	d         |d
<   |||d<   |                     | 	                    ||                    }
|                     |
di           }| 
                    |dg           }|                     ||	||          S )aI  
        fetch the history of funding payments paid and received on self account
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#funding-payment-history
        :param str [symbol]: unified market symbol
        :param int [since]: the earliest time in ms to fetch funding history for
        :param int [limit]: the maximum number of funding history structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns dict: a `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
        FrS   paginatepage   r   r.   r   Nr  r  r   )r  r  handle_option_and_params fetch_paginated_call_incrementalrD  r  ro  r  .v2PrivateAccountGroupGetFuturesFundingPaymentsr  r)  parse_incomes)r>  r  r   r  rG  rm  rC  r   r  r  r  r   rowss                r@  fetch_funding_historyzascendex.fetch_funding_history  sX    	88AVXbcc& 	z889NPVX]_dflntvxyyy//$-B77''66\
 [[((F &tGH"'GJFFt{{SZ\bGcGcdd& x44~~dFB//!!$u===rA  c           
          |                      |d          }|                     |d          }||                     ||dd          d||                     |          d |                     |d          dS )Nr  r  -r:   USDTpaymentInUSDT)r   r  r\  r  r  r.   rZ  )ro  r  r  r9  rp  )r>  incomer  r  r  s        r@  parse_incomezascendex.parse_income  s     ##FH55%%fk::	&&xfEE"Y//&&v??
 
 	
rA  c                    |                                   |                                  |                     | j        di           }|                     |d          }d|i}|                     |                     ||                    }|                     |di           }|                     |dg           }| 	                    ||d          S )a  
        fetches the set margin mode of the user
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
        :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 `margin mode structures <https://docs.ccxt.com/#/?id=margin-mode-structure>`
        r   r.   r   r   r  r  )
r  r  rD  r  ro  r  r  r  r)  parse_margin_modes)	r>  r  rG  rC  r   r  r  r   marginModess	            r@  fetch_margin_modeszascendex.fetch_margin_modes/  s     	//$-B77''66\
 ??GU[@\@\]]P ~~h33nnT;;;&&{GXFFFrA  c                     |                      |d          }|                      |d          }|dk    rdnd}||                     ||          |dS )Nr  r  r  r  r  )r   r  r  )ro  r  )r>  r  r  r  r  r9   s         r@  parse_margin_modezascendex.parse_margin_modej  sg    ##J99%%j,??
'944:&&x88 
 
 	
rA  c                    |                                   |                                  |                     | j        di           }|                     |d          }d|i}|                     |                     ||                    }|                     |di           }|                     |dg           }| 	                    ||d          S )a  
        fetch the set leverage for all contract markets
        :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
        :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>`
        r   r.   r   r   r  r  )
r  r  rD  r  ro  r  r  r  r)  parse_leverages)	r>  r  rG  rC  r   r  r  r   	leveragess	            r@  fetch_leverageszascendex.fetch_leveragest  s     	//$-B77''66\
 ??GU[@\@\]]P ~~h33NN4b99	##IwAAArA  c                     |                      |d          }|                     |d          }|                      |d          }|dk    rdnd}||                     ||          |||dS )Nr  r  r  r  r  r  )r   r  r  longLeverageshortLeverage)ro  r  r  )r>  r  r  r  leverageValuer  r  s          r@  parse_leveragezascendex.parse_leverage  s    ##Hh77))(J??%%h==
!+y!8!8WWz
&&x88$)*
 
 	
rA  r   GETc                    |d         }|d         }|                      |d          }	d}
|	dk    }|s|	dk    r/|
|                     d|          z  }
|                     |d          }|                     ||          }|
d	z  }
|d
k    r|	dk    rd|z   dz   |z   }n|dz   |z   }n|
|dz   z  }
|r|
|                     d|          z  }
|                     |d          }|
|z  }
|dk    r|dk    s|dk    rd}|dk    r|dk    rd}|                    d          dk    r|                    d          }|d         }|                     ||                     |                    }|dk    r|r|
d|                     |          z   z  }
n|                                  t          | 	                                          }|dz   |z   }| 
                    |                     |          |                     | j                  t          j        d          }| j        ||d}|dk    r|r|
d|                     |          z   z  }
nd|d<   |                     |          }| j        d         d          |
z   }
|
|||d!S )"Nr   r       r   r   z/{account-group}r   z	/api/pro/r   r   zdata/r  z{account-category}/r   r   r   r   r   r   r`  subuserr   ?+base64)z
x-auth-keyzx-auth-timestampzx-auth-signaturer  zapplication/jsonzContent-Typer   r   )r   r   bodyheaders)ro  implode_paramsr  findr  extract_params	urlencodecheck_required_credentialsstrr  hmacencodesecrethashlibsha256apiKeyjsonr   )r>  pathr   r   rG  r  r  r   accessr]  r   r   r  r  r  payloadr  s                    r@  signzascendex.sign  s   a&QQ''#44 	8t~554&&'96BBBCYYv77F%%dF33{d??v~~!G+c1G;!C-'17S= C 	F4&&'<fEEEC6#566wtOO'^";";L\A\A\GtOO'Z"7"7G<<	""a''MM#&&EAhG64#6#6t#<#<==X 4sT^^F3333++---D--//00I#o/G99T[[114;;t{3K3KW^]effD"k$-$( G
  83!7!777C*<'yy((iv&,fdwOOOrA  c
                    |d S |                      |d          }
|                      |d          }|
d uo|
dk    }|s|| j        dz   |z   }|                     | j        d         |
|           |                     | j        d         ||           |                     | j        d         ||           t          |          d S )Nr\  messager   r-  r.  )ro  r.   throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr   )r>  httpCodereasonr   r   r  r  r  requestHeadersrequestBodyr\  r  errorfeedbacks                 r@  handle_errorszascendex.handle_errors  s    4 &11""8Y77T!4 	*W(w}t+H001I4QYZZZ001I7T\]]]001I7T\]]])))trA  )N)___name__
__module____qualname__r<  rI  r   r~  r   r   r  r  r   r  r   r  r  r  r  r  r	   r   r  r   r	  r  r   r   r  rg  r  r.  r   r>  rC  rQ  r   rs  r   rw  r   r   floatr   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   r4  r3  r;  r>  rB  rE  rH  rS  rY  r^  r   r}   rd  ri  ru  r{  r   r  r   r  r   r  r
   r  r  r  __classcell__)r?  s   @r@  r,   r,      s1       l l l l l\ "$ 1 1 1 1 ') g gZ g g g gR $& } }$v, } } } }~ !# ; ; ; ;. %' $
 $
4= $
 $
 $
 $
L) ) ) ) ) ) ) )&) ) )  $& W0 W0( W0 W0 W0 W0r :>b * *s *3 *Y * * * *X, ,6 ,V , , , ,\ 02 / /3 /f / / / /@ 04B -1 -1W -17 -1 -1 -1 -1^
 
 
4 
 
 
 
4 26DW[df 4H 4H# 4Hc 4HQT 4Hkoptku 4H 4H 4H 4Hl     5        D 6:UW "? "?3 "?s "?# "?\`af\g "? "? "? "?H	: 	: 	:j j j5 j j j jX )+ . .{ . . . .` os{} F, F,3 F,i F,y F,Z_ F,hk F, F, F, F,P gksu ^/ ^/3 ^/i ^/y ^/RW ^/`c ^/ ^/ ^/ ^/@ @B T/ T/D$6 T/ T/ T/ T/l 26b d. d.c d.3 d. d. d. d.L /3TXac mO mO mO3 mOc mOhlmrhs mO mO mO mO^ 154VZce a= a=# a=S a=PS a=jnotju a= a= a= a=F 37r j/ j/s j/C j/ j/ j/ j/X /32 D D D D D DL
 
h 
 
 
 
:D D D 79 E E# E E E EN *.Dt\^ Y Y3 Yc Y Ycghsct Y Y Y Y -1tRV_a Y Yc Y YC Yfjkvfw Y Y Y Y 6:[_hj 6M 6Ms 6M# 6MUX 6Most  pA 6M 6M 6M 6Mp: : :5
 5
x 5
; 5
 5
 5
 5
n 26b <P <Pw <P <P <P <P|= =v = = = =~#
 #
6 #
 #
 #
 #
J 6:" %? %?7 %? %? %? %?N FH  3 L^    6
 
f 
HZ 
 
 
 
. 9; L LC L?Q L L L L 68 H H H<N H H H H 9=R [ [S [# [ [ [ [6 >B" ] ]# ]s ] ] ] ]< 7;2 'B 'BG 'B 'B 'B 'BR, , , , , ,\. . . . . .` <@ J J J J J J [] ( (S (% (c (c (an ( ( ( (T
 
 
 
 
 
$  
 37TX\eg 1> 1>C 1>s 1>RU 1> 1> 1> 1>f
 
6 
 
 
 
* 7;2 9G 9G$s) 9G+ 9G 9G 9G 9Gv
 
J 
 
 
 
 48 9B 9BtCy 9By 9B 9B 9B 9Bv
 
x 
 
 
 
 &eBSW 2P 2P 2P 2Ph      rA  r,   )1ccxt.base.exchanger   ccxt.abstract.ascendexr   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r    r!   r"   r#   r$   r%   r&   r'   r(   ccxt.base.decimal_to_precisionr)   ccxt.base.preciser*   r,   rk  rA  r@  <module>r     s   ( ' ' ' ' ' . . . . . .  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]  ]       * * * * * * 0 0 0 0 0 0 - - - - - - - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) ) ) ) ) ) ) 4 4 4 4 4 4 % % % % % %i3 i3 i3 i3 i3x i3 i3 i3 i3 i3rA  