
    ":hU                       d Z dZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lm	Z	 dd
lm
Z
 ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZmZmZmZmZmZmZmZ ddlmZ ddl m!Z! ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7m8Z8 ddl9m:Z: ddl;m<Z< ddl;m=Z= 	 dd l>Z?dd!lAmBZB dd"lAmCZC dd#lDmEZE dd$lFmGZG dd%lHmIZI dd&lJmKZK dd'lLmMZMmNZN dd(lOmPZQ 	 dd lRmSZS d)gZTdd lUZUdd lVZVdd lWZWdd lXZXdd lYZYdd lZZZdd l[Z[dd*l\m]Z] dd l^Z^dd l_Z_dd l`Z`dd laZad Zb	 dd lbZbdd lcZcdd ldZddd leZedd+lfmgZg dd lhZhdd,limjZj dd-lkmlZl dd.lmmnZnmoZompZpmqZqmrZs dd/ltmuZu dd lvZvdd lwZwdd lxZxdd0lymzZz dd1lvm{Z{ dd2l|m}Z} dd l~mZ dd3lmZmZ dd4l"mZ  G d5 d6ecj
                        Z G d7 d)e      Zy # e@$ r d Z?Y 	w xY w# e@$ r d ZSY w xY w# e@$ r Y w xY w)8Base exchange classz4.4.86    )ExchangeError)NetworkError)NotSupported)AuthenticationError)DDoSProtection)RequestTimeout)ExchangeNotAvailable)InvalidAddress)InvalidOrder)ArgumentsRequired)	BadSymbol)NullResponse)RateLimitExceeded)OperationFailed)
BadRequest)BadResponse)InvalidProxySettings)UnsubscribeError)decimal_to_precision)DECIMAL_PLACES	TICK_SIZE
NO_PADDINGTRUNCATEROUNDROUND_UP
ROUND_DOWNSIGNIFICANT_DIGITS)number_to_string)Precise)ConstructorArgsBalanceAccountCurrency	IndexType	OrderSide	OrderTypeTradeOrderRequestMarket
MarketTypeStrNumStringsCancellationRequestBool)backends)hashes)paddinged25519)load_pem_private_key)ecdsa)keccakN)abi)accountpackb)"get_private_key_from_eth_signature)compute_address)get_selector_from_name)message_signatureprivate_to_stark_key)	TypedDataExchange)	parsedate)Number)Session)default_user_agent)	HTTPErrorTimeoutTooManyRedirectsRequestExceptionConnectionError)SSLError)Decimal)mktime)format_date_time)AnyList)Intc                        e Zd Z fdZ xZS )SafeJSONEncoderc                     t        |t              rd|j                  j                  iS 	 t        |   |      S # t        $ r dt        |      j                   dcY S w xY w)NnamezTypeError: Object of type z is not JSON serializable)
isinstance	Exception	__class____name__superdefault	TypeErrortype)selfobjrX   s     L/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/base/exchange.pyr[   zSafeJSONEncoder.default   sc    c9%CMM2233	^7?3'' 	^/S	0B0B/CC\]]	^s   : "AA)rY   
__module____qualname__r[   __classcell__)rX   s   @r`   rS   rS      s    ^ ^    rS   c                   <E   e Zd ZU dZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZi Z dZ!dddddddi i dd	Z"d
dii i dd	Z#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5dZ6dZ7dZ8dZ9dZ:dZ;dZ<dZ=dZ>dZ?dZ@dZAddddZBdZCdZD eEd      ZFdZGdZHdZIdZJdZKdZLdZMdZNdZOdZPdZQdZRdZSdZTdZUdddddddddddddZVi deWdeXdeYdeZdeZdeZdeZdeZdeZdeZdeZd eZd!eZd"eZd#eZd$eZd%eZeZeZeZe[e[e\e\e\d&Z]dZ^dZ_dZ`dZadZbdZcdZddZedZfdZgdZhdZidZjdZkdZldZmdZndZodZpdZqdZrddddddddddd'
Zsi Zti ZuevZwexZyd(ZzdZ{dZ|eEZ}e~ed)<   dZdZd*Zd*ZdZdZd+Zd+Zd*ZdZdZdZdZdZdZdZdZdZdZdZdZd,Zd-d.d/d0ZdZi fd1efd2Zd3 Zd4 Zd5 Zd(d6Zd(d7Zed8        Zd(d9Zd: Zd; Zd< Zd)d>Zd? Zd@ ZedA        Zed(dB       Zed(dC       Zed(dD       Zed(dE       Zed(dF       Zed(dG       Zed(dH       Zed(dI       Zed(dJ       Zed(dK       Zed(dL       Zed(dM       Zed(dN       Zed(dO       Zed(dP       Zed(dQ       Zed(dR       Zed(dS       Zed(dT       Zed(dU       Zed(dV       Zed(dW       Zed(dX       Zed(dY       ZedZ        Zed(d[       Zed*d\       Zed*d]       Zed+d^       Zed,d_       Zed`        Zeda        Zedb        Zedc        Zedd        Zede        Zedf        Zed(dg       Zed(dh       Zedi        Zedj        Zedk        Zed-dl       Zed.dm       Zedn        Zedo        Zedp        Zedq        Zedr        Zei ddfds       Zei fdt       Zedu        Zei fdv       Zed/dw       Zedx        Zedy        Zedz        Zed{        Zed|        Zed}        Zed~        Zed        Zed        Zed        Zed        Zed        Zed(d       Zed(d       Zed0d       Zed1d       Zed2d       Zed0d       Zed3d       Zed(d       Zed(d       Zed4d       Zeej                  dfd       Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zeddi fd       Zed5d       Z ed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed6d       Z	ed7d       Z
ed7d       Zed(d       Zed        Zed        Zed        Zed        Zed8d       Zd Zdi fdZi fdZi fdZd Zed        Zeefd       Zd Zd Zd Zed        Zed        Zed        Zed        Z ed        Z!ed        Z"d Z#ed        Z$ed        Z%d(dZ&d Z'd Z(d Z)ed.d       Z*dÄ Z+dĄ Z,dń Z-dƄ Z.d(dǄZ/d(dȄZ0dɄ Z1dʄ Z2d˄ Z3d̄ Z4d̈́ Z5d΄ Z6dτ Z7dЄ Z8i fdѐe9fd҄Z:i fdѐe9fdӄZ;dԐe<fdՄZ=d(d֐e>e?   dאe@fd؄ZAd(dِe?dڐe?dאe@fdۄZBd(dܐe?dאe@fd݄ZCd(d֐e>e?   dאeDfdބZEd(dܐe?dאeDfd߄ZFd(dِe?dڐe9dאeDfdZGd(d֐e>e?   dאe>e<   fdZHd(dِe?dڐe9dאe>e<   fdZId(dܐe?dאe>e<   fdZJd ZKd ZLd9de<de?de?de?fdZMd ZNd(dZOd:dePdePfdZQde9fdZRd:dePdePfdZSd ZTd ZUd(dePfdZVde9fdZWd;de>eX   deYdܐe?de@fdZZd<de>eX   deYdeYdܐe?fdZ[d=de>eX   d e?deYdeYfdZ\de@fdZ]dd=i ddfde<de<de<fdZ^i fd	Z_ddi fd
e9deYdeYfdZ`ddi fd
e9deYdeYfdZaddi fd
e9deYdeYfdZbddi fde>e9   deYdeYfdZcddi fd
e9deYdeYfdZdddi fde>e9   deYdeYfdZeddi fd
e9deYdeYfdZfi fd
e9fdZgddi fde>e9   deYdeYfdZhi fde>e9   fdZiddi fde>e9   deYdeYfdZjddi fde>e9   deYdeYfdZkddi fde>e>e9      deYdeYfdZli fde>e>e9      fdZmdi fde>e9   deYfdZni fde>e9   fdZodi fdepfdZqdi fd
e9deYfdZrdi fd
e9deYfd Zsi fd
e9fd!Ztdi fdepfd"Zudi fd#Zvdi fd
e9deYfd$Zwi fd
e9fd%Zxi fd&Zydi fdepfd'Zzd(eDfd)Z{d* Z|d+eDfd,Z}d- Z~d(d.eDd+efd/Zd(d0efd1Zd(d2eDd+efd3Zd(d4eDd0efd5Zd(d6eDd0efd7Zd8eDfd9Zd(d:eDd0efd;Zd(d<eDd+efd=Zi fd>Zi fd?Zd(d+efd@Zdi fdepfdAZd(dBeDd+efdCZd(d+efdDZd(dEeDd+efdFZd(dEeDd+efdGZd(d2eDd+efdHZd(d<eDd+efdIZd(d2eDd+efdJZd(d+efdKZdi fdepfdLZdi fdepfdMZi fd
e9fdNZi fde>e9   fdOZi fde>e9   fdPZi fdQe9dReEdSe9dTe9fdUZdi fdQe9dReEde9fdVZi fdQe9fdWZdi fdXeYd
ePfdYZi fd
e9fdZZdi fdepfd[Zdi fd\e@d
ePfd]Zi fd
e9dReEfd^Zi fd
e9dReEfd_Zi fd
e9dReEfd`Zdi fd
e9daePfdbZddddi fd
ePdaePdeYdeYfdcZddddi fd
ePddePde~de~fdeZdi fdfe9d
ePfdgZi fdQe9fdhZdiddi fd
e9deYdeYfdjZi fd
e9fdkZdi fdepfdlZi fdmZi fdnZdo Zdp ZdqeEfdrZd(dseXdܐe?de~fdtZd(dseXdܐe?dאeYfduZdv Zdw Zdx Zd(dye<dzePd{ePfd|Zd
ePfd}Zd~ Zd Zd(deXd0efdZd0eXfdZd(d+eDfdZd(dZde<de<deDfdZdeDfdZd(d<eDd+efdZdddi fdeXd+edeYdeYfdZdi fd
e9dde9de9dReEdeEf
dZd(deDd+efdZÐd(d2eDd+efdZĐde<fdZŐde<fdZƐde>eE   deEfdZǐd ZȐd Zɐd(d.eDd+efdZi fdQe9dReEfdZi fdQe9dReEfdZi fd
e9dQe9dReEfdZi fdQe9dReEfdZi fd
e9dQe9dReEfdZdi fdQe9dReEd
ePfdZdi fdQe9dReEd
ePfdZѐdddi fd
e9deYdeYfdZҐdddi fd
e9deYdeYfdZӐdddi fd
e9deYdeYfdZԐd>de>e>eE      fdZՐd>de>e>eE      fdZ֐d?dZאd(depfdZؐd(depfdZِd(depfdZڐd@depddePfdZېd(depfdZܐd9de?de?de?fdZdi fd
e9deYfdZސd(d
ePfdZߐd(d+edԐefdZd(de9dePfdZd?dePdePfdZd Zde9fdZd Zd Zd.dZd(deXdِe?dڐe?fdZdAdÐeXd
e9deYde?de?de?fdĄZdBde>eX   d+e<dae9deYdeYdŐefdƄZd?dǐe<de>e9   fdȄZddi fdepfdɄZdBeDfdʄZdi fdːe>e<   de>e9   fd̄Zi fd͐e>e<   fd΄Zdddi fdϐe>e<   d+edeYdeYfdЄZdddi fdѐe>e<   d0edeYdeYfd҄Zdddi fdӐe>e<   d0edeYdeYfdԄZdddi fd0edeYdeYfdՄZdք Zdׄ ZdQe9fd؄Zd
e9fdلZd
e9fdڄZd(dېeXdܐe9dאePfd݄Zd(dېeXdސe9dߐe9dאePfdZd(dېeXdܐe9dאeYfdZd(dېeXdސe9dߐe9dאeYfdZd(dېeXdܐe9dאefdZd(dېeXdސe9dߐe9dאefdZ dCdېeDdeDde9dePde@f
dZd Zdܐe?fdZdDdzePd{ePde@de@fdZdEdܐe?fdZdd=i ddi fde<de<de<fdZdd=i ddi fde<de<de<fdZdi fdZdFdϐe>e	   dae9deEdeEfdZ
dGdeYdeYfdZdi fde9d
e9dReEde~fdZdi fde9d
e9dReEde~fdZdi fde9d
e9dedReEde~f
dZddi fde9d
e9ddededRe~de~fdZddi fde9d
e9ddededRe~de~fdZi fd
e9fdZi fd
e9fdZdi fd
ePfdZdddi fdepdeYdeYfdZdddi fdepdeYdeYfdZi fd
e9fdZi fd
e9fd Zdi fdepfdZdi fdepfdZdi fdepfdZdi fdepfdZddddi fdQePd
ePdeYdeYfdZdddi fdQePdeYdeYfdZdi fde9dQePfdZ d9de?de?de?fdZ!d(d	ePd0efd
Z"d:dePd+edePdzePfdZ#d8dZ$d Z%i fdZ&i fdZ'd Z(i fdZ)i fdZ*i fdZ+i fdZ,i fdZ-i fdZ.i fdQe9fdZ/di fdepfdZ0di fdepfdZ1i fdQe9fdZ2i fdZ3i fdQe9fdZ4i fd
e9fdZ5d(dېeXd e9d!e9fd"Z6d(dېeXd#e9d$e9d%e9fd&Z7d(d e9d!e9fd'Z8di dfd e9d+efd(Z9di dfd e9fd)Z:i dfd e9fd*Z;d+ Z<d, Z=d- Z>d.e?d/e9de9de9d0eDd1e9fd2Z@i fd3ZAi fd
e9fd4ZBi fd
e9fd5ZCi fd
e9fd6ZDi fd
e9fd7ZEdi fdepfd8ZFdi fdepfd9ZGdi fdepfd:ZHddi fdepdeYfd;ZIdi fdepfd<ZJdi fdepfd=ZKdi fdepfd>ZLdi fde9d
ePfd?ZMdi fde9d
ePfd@ZNdi fde9d
ePfdAZOi fdBZPdi fd
e9ddededReEde~f
dCZQdi fde9dDe9dEe9dRe~fdFZRdi fde9dQePfdGZSdddi fdQePdeYdeYfdHZTdi fd
ePfdIZUdddi fd
e9ddededReEde~f
dJZVdddi fd
e9ddededReEde~f
dKZWdddi fd
e9ddededReEde~f
dLZXdddi fd
e9ddededReEde~f
dMZYi fd
e9dedNeEfdOZZi fd
e9dNeEfdPZ[i fd
e9dNeEfdQZ\i fd
e9dedNeEfdRZ]ddi fd
e9ddededReEde~dSe~fdTZ^ddi fd
e9ddededReEde~dSe~fdUZ_ddi fd
e9ddededReEde~dVe~fdWZ`ddi fd
e9ddededReEde~dVe~fdXZaddi fd
e9ddededReEde~dYe~fdZZbddi fd
e9ddededReEde~dYe~fd[Zcdddi fd
e9ddededReEde~d\e~d]e~fd^Zddddi fd
e9ddededReEde~d\e~d]e~fd_Zedddi fd
e9ddededReEde~d\e~d]e~fd`Zfi fde>eg   fdaZhi fde>eg   fdbZidi fd
e9ddededReEde~f
dcZjdi fde9d
ePfddZkdi fde9d
ePfdeZldi fdfe>e9   d
ePfdgZmdi fd
ePfdhZni fdieYfdjZoi fde>ep   fdkZqdi fd
ePfdlZri fdmZsdddi fd
ePdeYdeYfdnZtdddi fd
ePdeYdeYfdoZudddi fde9d
ePdeYdeYfdpZvdddi fd
ePdeYdeYfdqZwdddi fd
ePdeYdeYfdrZxdddi fd
ePdeYdeYfdsZydddi fd
ePdeYdeYfdtZzdddi fd
ePdeYdeYfduZ{dddi fd
ePdeYdeYfdvZ|dddi fd
ePdeYdeYfdwZ}dddi fd
ePdeYdeYfdxZ~ddi fd
e9deYdeYfdyZdddi fd
ePdeYdeYfdzZdddi fd
ePdeYdeYfd{Zi fd
e9fd|Zi fdQe9fd}Zi fd
e9fd~Zdi fdDe9dEe9dRe~fdZdddi fdQePdeYdeYfdZdddi fd
ePdeYdeYfdZdddi fd
ePdeYdeYfdZdddi fdQePdeYdeYfdZdddi fdQePdeYdeYfdZdddi fd
ePdeYdeYfdZdddi fd
ePdeYdeYfdZdi fd
e9defdZi fdZdi fd
e9deYfdZd(d+efdZi fdQe9fdZdԐefdZdQe9fdZdQe9fdZd
e9fdZd
e9fdZdHdedeDfdZd Zi fd
e9dedReEdeEfdZi fd
e9dedReEdeEfdZdi fd
e9dedReEde~fdZdi fd
e9dedReEde~fdZi fd
e9dReEdeEfdZi fd
e9dReEdeEfdZi fd
e9dReEdeEfdZi fd
e9dReEdeEfdZi fd
e9dReEfdZi fd
e9dReEfdZi fd
e9dReEfdZi fd
e9dReEfdZd
e9fdZd
e9fdZd
e9fdZd
e9fdZd(dQe9fdZd Zd Zd Zd Zd(dܐe?de~fdZd(dseXde>e?   de~fdZde9fdZdePfdZi fdZde9fdZi fd
e9fdZdi fd
e9ddededReEde~f
dZdi fd
e9ddededReEde~f
dZdi fd
e9ddededReEde~f
dZdi fd
e9ddededReEde~f
dZddi fd
e9ddededReEde~dSe~fdZddi fd
e9ddededReEde~dSe~fdZi fd
e9dedReEdeEdSeEf
dZi fd
e9dedReEdeEdSeEf
dZi fd
e9dedReEdSeEfdZi fd
e9dedReEdSeEfdZd(d	ePd0efdZdId
ePdeYdeYfdZdIdeYdeYfdZdIde>e9   deYdeYfdZdi fde>e9   fdZdi fdepfdZddi fdepfdÄZƐd(d+efdĄZǐd(d0efdńZȐdQePdeYdeYfdƄZɐdEe<fdǄZʐdJdeYdeYfdȄZːdJdePd+edePdzePfdɄZ̐d(dʐe9d+efd˄Z͐d(depfd̄Zΐd(dEeDd+efd̈́ZϐdJdeYdeYfd΄ZАdCdePdϐefdЄZѐdф ZҐd҄ Zi fdӐe@fdԄZi fdӐe@dՐe@dېe<fdքZdi fdepfdׄZi fd؄Zi fdلZi fd
e9fdڄZi fdۄZڐd(d+efd܄Zېd(depfd݄ZܐdJdeYdeYfdބZi fd
e9fd߄Zi fd
e9fdZߐdddi fdeYdeYfdZdddi fd
e9deYdeYfdZdddi fd
e9deYdeYfdZi fdZd Zg fd e9fdZd e9d
ePdfe9fdZd?depfdZd(d0efdZd Zd(dZd(d+efdZdJdeYdeYfdZd(depfdZdGde>eX   d+e<dae9deYdeYf
dZdddi fdQePdeYdeYfdZdEdܐe?fdZdEdܐe?fdZd
e9dae9fdZdi fde9deYfdZdddi ddfde9d
ePdeYdeYdeYf
dZddddi fde9d
ePdeYdeYdaePf
dZddddi dfde9d
ePdeYdeYdaePf
dZdddi ddddfde9d
ePfdZdddi ddfde9d
ePfdZd Zd8de@fdZd ZdKdܐe9fdZd(d eDd+efdZd(d+efdZdJde>eD   d+edeYdeYfdZd(deDd+efdZ d?deDd0ed+efdZd?dǐe>eX   d	ePd
ePfdZdJdǐe>eX   de>e9   d
ePdzefdZd(dfeDd+efdZdJdǐe>eX   de>e9   d
ePdzefdZd(dXeDd+efdZdddddi fde>e<   dQePdePdePdeYdeYfdZd?deDdedefdZ	de9fdZ
de9fdZde9fdZddi fd
e9deYdeYfdZdddi fdepdeYdeYfdZd(deDd+efdZdJdǐe>eX   depd
ePdzefd Zdi fde9dQePfd!Zdddi fdQePdeYdeYfd"Zd#e9d$e9fd%Zd&eDfd'Zy(L  rA   r   NFT  '  	tierBased
percentagetakermakerri   rj   withdrawdeposittradingfundingrj   )rn   ro   zrMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36zlMozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36zyMozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36)chromechrome39	chrome100*inf minmaxleverageamountpricecost422418429404409410451500501502520521522525526400403405503530408504401407511
apiKeysecretuid	accountIdloginpasswordtwofa
privateKeywalletAddresstoken   numberr      :123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyzBTCBCHBSV)XBTBCCBCHSVconfigc                 $
   	  j                   xs  j                   _          j                  xs  j                   _         j                  
t	               n j                   _         j
                  
t	               n j
                   _         j                  
t	               n j                   _         j                  
t	               n j                   _         j                  
t	               n j                   _         j                  
t	               n j                   _	         j                  
t	               n j                   _
         j                  
t	               n j                   _         j                  
t	               n j                   _         j                  
t	               n j                   _         j                  
t	               n j                   _         j                  
t	               n j                   _         j                   
t	               n j                    _         j"                  
t	               n j"                   _         j$                  
t	               n j$                   _         j&                   j)                         n j&                   _        t*         _        t,         _         j/                          _        t3                _         j7                   j9                         |      }|D ]c  }t;         |      rEt=        t?         |      t              r+tA         | j7                  t?         |      ||                TtA         |||          e  jC                           jE                  |d      s jE                  |d      r jG                  d       tI               }tK               D ]  }|d   dk7  s|d   dk7  sd|v s|jM                  d      }ddd	d
	|d   djO                  	 fd|dd  D              z   }t?         |      }t=        |tP        jR                        rtA        ||t?        ||             t;         |      r|tA         ||       tA         ||         jT                  s6 jV                  r*tY                _*         j                   jT                  _         jZ                  r jZ                   _-        y t]        j^                  t`               _-        y )NsandboxtestnetTr   _OHLCVLEBE)ohlcvleberx   c              3   `   K   | ]%  }j                  |j                  |             ' y wN)get
capitalize).0i
exceptionsr^   s     r`   	<genexpr>z$Exchange.__init__.<locals>.<genexpr>  s'     .hYZz~~aQRAS/T.hs   +.r   )1aiohttp_trust_env	trust_envrequests_trust_env	precisiondictlimitsr   headersbalance
orderbooksfundingRatestickersbidsaskstradestransactionsohlcvsliquidationsmyLiquidations
currenciesoptionsget_default_optionsr   r   uuidoriginrE   	userAgentdeep_extenddescribehasattrrV   getattrsetattrafter_construct	safe_boolset_sandbox_moder]   dirsplitjointypes
MethodTypesessionsynchronousrD   loggerlogging	getLoggerrY   )
r^   r   settingskeyclsrU   parts	camelcaseattrr   s
   `        @r`   __init__zExchange.__init__x  s   !%!7!7!I4>>"&"9"9"KT^^#'>>#9t~~ $ 3df$(OO$;$&!%!5tv4<<!%!5tv4<<$(OO$;$&&*&7&7&?DFTEVEV!%!5tv4<<"&--"7T]] $ 3df&*&7&7&?DFTEVEV $ 3df&*&7&7&?DFTEVEV(,(;(;(CdfI\I\$(OO$;$&59\\5It//1t||$8! 0 iik+-##DMMOV< 	2CtS!js1CT&Jc4#3#3GD#4FQT#VWc8C=1		2 	>>&),vy0Q!!$' 4jI 	7DAw#~$r(c/cTk

3'.d$G
!!Hrww.h^cdedf^g.h'hh	tT*dE$4$45CGC,>?tY/+#D)T:i6	7  || 0 0"9DL%)%<%<DLL"%)[[dkkg6G6G6Qrd   c                     | j                   r	 | j                   j                          y y # t        $ r
}Y d }~y d }~ww xY wr   )r   closerW   )r^   es     r`   __del__zExchange.__del__  s8    <<""$   s   * 	==c                 H    d| j                   rdndz   | j                  z   dz   S )Nzccxt.zasync_support.rx   z())asyncio_loopidr^   s    r`   __repr__zExchange.__repr__  s'    d.?.?*RH477RUYYYrd   c                     | j                   S r   )rU   r   s    r`   __str__zExchange.__str__  s    yyrd   c                      y r    )r^   r   s     r`   init_throttlerzExchange.init_throttler  s    rd   c                     t        | j                               }|| j                  z
  }|dn|}| j                  |z  }||k  r||z
  }t	        j
                  |dz         y y )Nr   g     @@)floatmillisecondslastRestRequestTimestamp	rateLimittimesleep)r^   r   nowelapsed
sleep_timedelays         r`   throttlezExchange.throttle  se    D%%'(555Lqd^^d*
Z(EJJuv~&  rd   c                    | j                         j                  d      }|dv rc|dk(  r%t        j                  |t        j                         S t        j                  dddt        j                  |            j                         S |S )NzContent-Encoding)gzipzx-gzipdeflater  rx   rb	   )
infor   zlib
decompress	MAX_WBITSr  GzipFileioBytesIOread)responsetextencodings      r`   gzip_deflatezExchange.gzip_deflate  sm    ==?&&'9:449$tdnn_==}}Rq"**T2BCHHJJrd   c                    |xs i }| j                   r%|j                  | j                   j                         |j                  | j                         | j                  | j                  n| j                  }|rKt        |      t        u r|j                  d|i       n&t        |      t        u rd|v r|j                  |       |j                  ddi       | j                  |      S )Nz
User-AgentzAccept-Encodingzgzip, deflate)	r   updater   r   
user_agentr]   strr   set_headers)r^   r   r   s      r`   prepare_request_headersz Exchange.prepare_request_headers  s    -R<<NN4<<//0t||$&*nn&@DNNdoo	I#%i89y/T)	0Iy))?;<((rd   c                     t        |  y r   )print)r^   argss     r`   logzExchange.log  s	    trd   c	                 "    |j                         S r   strip)	r^   codereasonurlmethodresponse_headersresponse_bodyrequest_headersrequest_bodys	            r`   on_rest_responsezExchange.on_rest_response  s    ""$$rd   c                     | j                   r&t         t        j                  |t        t              S t        rt        j                  |      S t        j                  |      S )N)parse_float	parse_int)quoteJsonNumbersorjsonjsonloadsr"  )r^   r1  s     r`   on_json_responsezExchange.on_json_response  sC      V^::mLL||M22::m,,rd   GETc                 p
   | j                  |      }| j                  ||||      }|1|j                  d| j                  i       || j	                  |      z   }d}| j                  ||||      \  }}	}
|ri }||d<   n|	ri }|	|d<   n|
ri }|
|d<   |
|d<   |du}| j                  ||       | j                  (|s|rt        | j                  dz         | j                  }| j                  r"| j                  d| j                  ||d|d|       | j                  j                  d	||||       |}|r|j                         }| j                  j                   j#                          d}d}d}d}	 | j                  j%                  ||||| j&                  d
z  || j(                  xr | j*                        }d|_        |j.                  }|j0                  }|j2                  }| j5                  ||||||j6                  ||      }| j9                  |      }| j:                  r|| _        | j>                  r|| _         | jB                  r|| _"        | j                  r#| j                  d| j                  |||d|d|	       | j                  j                  d|||||       |jG                          | jU                  |||||||||	       ||S | jg                  |      r|S ti        |jj                  tl              r|jj                  jo                  d      S |jj                  S # tH        $ r/}djK                  | j                  ||g      }tM        |      |d}~wtN        $ r/}djK                  | j                  ||g      }t        |      |d}~wtP        $ r/}djK                  | j                  ||g      }t        |      |d}~wtR        $ r_}djK                  | j                  ||g      }| jU                  |||||||||	      }|s| jW                  |||||       t        |      |d}~wtX        $ rJ}t[        |      djK                  | j                  ||g      }dv rtM        |      |t]        |      |d}~wt^        $ r:}t[        |      djK                  | j                  ||g      }t]        |      |d}~wt`        $ rv}t[        |      dv rtc        | j                  dz         djK                  | j                  ||g      }te        fddD              rt]        |      |t        |      |d}~ww xY w)z3Perform a HTTP request and return decoded JSON dataNOriginhttphttpszb you have conflicting proxy settings - use either .proxies or http(s)Proxy / socksProxy / proxyUrlz
fetch Request:zRequestHeaders:zRequestBody:z%s %s, Request: %s %s  )datar   timeoutproxiesverifyutf-8z
fetch Response:zResponseHeaders:zResponseBody:z%s %s, Response: %s %s %s zRead timed outz&Missing dependencies for SOCKS supportzo - to use SOCKS proxy with ccxt, you might need "pysocks" module that can be installed by "pip install pysocks"c              3   &   K   | ]  }|v  
 y wr   r   )r   xerror_strings     r`   r   z!Exchange.fetch.<locals>.<genexpr>l  s     j1$js   )
ECONNRESETzConnection aborted.zConnection broken:utf8)8r$  check_proxy_url_settingsr   r   url_encoder_for_proxy_urlcheck_proxy_settingscheck_conflicting_proxiesrE  r   r   verboser(  r   debugencoder   cookiesclearrequestrD  rF  validateServerSslr  r   status_coder-  r4  r  
parse_jsonenableLastHttpResponselast_http_responseenableLastJsonResponselast_json_responseenableLastResponseHeaderslast_response_headersraise_for_statusrG   r   r	   rH   rK   rF   handle_errorshandle_http_status_coderequestsConnectionErrorr"  r   ConnectionResetErrorrI   r   anyis_text_responserV   contentbytesdecode)r^   r.  r/  r   bodyr2  proxyUrlrE  	httpProxy
httpsProxy
socksProxyproxyAgentSetr3  http_responsehttp_status_codehttp_status_textjson_responser  r   detailsskip_further_error_handlingrK  s                        @r`   fetchzExchange.fetch  s    66w?00fgtL""Hdkk#:;T;;C@@C,0,E,Ec6SZ\`,a)	:zG'GFOG)GGG(GFO)GGt+&&}h?LL$#DGG  /S  %S  T  TllG<<HH'&#?PRacqswx163QUV ;;=D""$E	4||++',{{=t'='= , H !(H&&G'33' 112BDTVY[acjltlyly  |K  MY  ZM OOM:M***7'***7'---4*||,dggvsDTVhjq  tC  ER  SKK963HXZacpq%%'X 	+-=sFGUbdq  tC  EQ  	R$  ""7+  (**E2''..v66###e  	1hh56G )q0 	0hh56G(a/ 	0hh56G(a/ 	0hh56G*.*<*<=MO_adflnu  xE  GT  Ve  gs  +t'.,,-=?OQTV\^kl(a/& 	3q6Lhh56G</$W-14"7+2# 	/q6Lhh56Gw'Q. 	4q6L8LH"477  ._  $_  `  `hh56Gj.ijj"7+2#G,!3	4sd   .D=L 	T5%*MT5*NT5*N;;T5AP!!T5-AQ22T5>5R33T5?A1T00T5c                 p    	 t         j                  |      r| j                  |      S y # t        $ r Y y w xY wr   )rA   is_json_encoded_objectr<  
ValueError)r^   rq  s     r`   rZ  zExchange.parse_json{  s=    	..}=,,];; > 		s   %) 	55c                 n    |j                  dd      }|j                  d      xs |j                  d      S )NzContent-Typerx   zapplication/jsonztext/)r   
startswith)r^   r   content_types      r`   rg  zExchange.is_text_response  s5    {{>26&&'9:^l>U>UV]>^^rd   c                     t        | d      rCt        | t              s3t        | t              rt	        |      t
        ury	 | |   }|d uxr |dk7  S y# t        $ r Y yw xY w)N__getitem__Frx   )r   rV   r"  listr]   intLookupError)
dictionaryr   values      r`   
key_existszExchange.key_exists  sh    :}-jS6Q*d+S	0D"3D(8Ub[8   s    A 	AAc                     |}	 t         j                  | |      rt        | |         }|S # t        $ r}|}Y d }~|S d }~ww xY wr   )rA   r  r  rz  )r  r   default_valuer  r   s        r`   
safe_floatzExchange.safe_float  sM    	""":s3jo.   	"!E	"s   $* 	A ;A c                 N    t         j                  | |      rt        | |         S |S r   )rA   r  r"  r  r   r  s      r`   safe_stringzExchange.safe_string  s&    '/':'::s'Ks:c?#^Q^^rd   c                     t         j                  | |      rt        | |         j                         S ||j                         S |S r   )rA   r  r"  lowerr  s      r`   safe_string_lowerzExchange.safe_string_lower  C    z3/z#'--//,9,E=&&(X=Xrd   c                     t         j                  | |      rt        | |         j                         S ||j                         S |S r   )rA   r  r"  upperr  s      r`   safe_string_upperzExchange.safe_string_upper  r  rd   c                     t         j                  | |      s|S | |   }	 t        t        |            S # t        $ r |cY S t
        $ r |cY S w xY wr   )rA   r  r  r  rz  r\   )r  r   r  r  s       r`   safe_integerzExchange.safe_integer  sZ    "":s3  3	! uU|$$ 	!   	!  	!s   3 A 
AAc                     t         j                  | |      s|S | |   }t        |t              rt	        ||z        S t        |t
              r	 t	        t        |      |z        S |S # t        $ r Y |S w xY wr   )rA   r  rV   rC   r  r"  r  rz  )r  r   factorr  r  s        r`   safe_integer_productzExchange.safe_integer_product  s    "":s3  3eV$uv~&&s#5<&011   s   A& &	A32A3c                 2    t         j                  | |d|      S NrB  rA   r  r  s      r`   safe_timestampzExchange.safe_timestamp  s    ,,ZdMRRrd   c                 <    t         j                  | |      r| |   S |S r   )rA   r  r  s      r`   
safe_valuezExchange.safe_value  s     "*"5"5j#"Fz#YMYrd   c                 P    t         j                  t         j                  | |||      S r   )rA   safe_eitherr  r  key1key2r  s       r`   safe_float_2zExchange.safe_float_2  "    ##H$7$7T4Q^__rd   c                 P    t         j                  t         j                  | |||      S r   )rA   r  r  r  s       r`   safe_string_2zExchange.safe_string_2  s"    ##H$8$8*dDR_``rd   c                 P    t         j                  t         j                  | |||      S r   )rA   r  r  r  s       r`   safe_string_lower_2zExchange.safe_string_lower_2  #    ##H$>$>
DRVXeffrd   c                 P    t         j                  t         j                  | |||      S r   )rA   r  r  r  s       r`   safe_string_upper_2zExchange.safe_string_upper_2  r  rd   c                 P    t         j                  t         j                  | |||      S r   )rA   r  r  r  s       r`   safe_integer_2zExchange.safe_integer_2  s"    ##H$9$9:tTS`aard   c                 h    t         j                  | ||      }||S t         j                  | |||      S r   r  )r  r  r  r  r  r  s         r`   safe_integer_product_2zExchange.safe_integer_product_2  s:    --j$G)uux/L/LZY]_egt/uurd   c                 4    t         j                  | ||d|      S r  )rA   r  r  s       r`   safe_timestamp_2zExchange.safe_timestamp_2  s    ..z4t][[rd   c                 P    t         j                  t         j                  | |||      S r   )rA   r  r  r  s       r`   safe_value_2zExchange.safe_value_2  r  rd   c                     t         j                  | |      }||S 	 t        |      }|S # t        $ r}|}Y d }~|S d }~ww xY wr   )rA   get_object_value_from_key_listr  rz  )r  key_listr  r  r   s        r`   safe_float_nzExchange.safe_float_n  sP    77
HM=  	"%LE   	"!E	"s   ) 	?:?c                 L    t         j                  | |      }|t        |      S |S r   )rA   r  r"  r  r  r  r  s       r`   safe_string_nzExchange.safe_string_n  s(    77
HM".s5zAMArd   c                     t         j                  | |      }|t        |      j                         S ||S |j                         S r   )rA   r  r"  r  r  s       r`   safe_string_lower_nzExchange.safe_string_lower_n	  H    77
HMu:##%%"   &&((rd   c                     t         j                  | |      }|t        |      j                         S ||S |j                         S r   )rA   r  r"  r  r  s       r`   safe_string_upper_nzExchange.safe_string_upper_n  r  rd   c                     t         j                  | |      }||S 	 t        t        |            S # t        $ r |cY S t
        $ r |cY S w xY wr   )rA   r  r  r  rz  r\   r  s       r`   safe_integer_nzExchange.safe_integer_n  sX    77
HM=  	! uU|$$ 	!   	!  	!s   0 A

A
	A
c                     | |S t         j                  | |      }||S t        |t              rt	        ||z        S t        |t
              r	 t	        t        |      |z        S |S # t        $ r Y |S w xY wr   )rA   r  rV   rC   r  r"  r  rz  )r  r  r  r  r  s        r`   safe_integer_product_nzExchange.safe_integer_product_n+  s      77
HM=  eV$uv~&&s#5<&011   s   A' '	A43A4c                 2    t         j                  | |d|      S r  )rA   r  )r  r  r  s      r`   safe_timestamp_nzExchange.safe_timestamp_n;  s    ..z8T=YYrd   c                 B    | |S t         j                  | |      }||S |S r   )rA   r  r  s       r`   safe_value_nzExchange.safe_value_n?  s0      77
HM)u<}<rd   c                     t        | t              }t        | t              }|D ]W  }|r|| v s
| |   | |   dk7  s| |   c S |s#t        |t              r4|t	        |       k  sC| |   I| |   dk7  sR| |   c S  y Nrx   )rV   r  r   r"  len)dictionary_or_listr  isDataArray
isDataDictr   s        r`   r  z'Exchange.get_object_value_from_key_listF  s     !3T: 2D9
 	3C,,1CC1H1TYkloYptvYv-c22ZS%9#0118J38O8[btuxby}b-c22	3 rd   c                 0     | ||      }||S  | |||      S )z/A helper-wrapper for the safe_value_2() family.r   )r/  r  r  r  r  r  s         r`   r  zExchange.safe_eitherS  s)     z4()uVvj$/VVrd   c                     |dkD  r1t        j                  d|      }t        j                  | |z        |z  S t        t        j                  | |            S )z,Deprecated, use decimal_to_precision insteadr   
   )mathpowtruncr  rA   truncate_to_string)numr   decimal_precisions      r`   truncatezExchange.truncateY  sO     q= $Y 7::c$5569JJJ8..sI>??rd   c                     |dkD  r]d|z  j                  t        |             j                  d      }|d   d| j                  d      }t	        |      r|nd}|d   dz   |z   S d| z  S )z3Deprecated, todo: remove references from subclassesr   z{0:.%df}.r   N0%d)formatrL   r   rstripr  )r  r   r   decimal_digitss       r`   r  zExchange.truncate_to_stringa  su     q=)+33GCLAGGLE"1Xjy188=N/2>/B^N8c>N22s
rd   c                 F    t        t        j                  | dz        d      S N   rJ  r  randomgetrandbitslengths    r`   uuid22zExchange.uuid22k      f((!4c::rd   c                 F    t        t        j                  | dz        d      S r  r  r  s    r`   uuid16zExchange.uuid16o  r  rd   c                  <    t        t        j                               S r   )r"  r   uuid4r   rd   r`   r   zExchange.uuids  s    4::<  rd   c                  \    t        t        j                               j                  dd      S )N-rx   )r"  r   uuid1replacer   rd   r`   uuidv1zExchange.uuidv1w  s     4::< ((b11rd   c                 r    t        |       dkD  r| d   j                         | dd  S | j                         S Nr   r   )r  r  strings    r`   r   zExchange.capitalize{  s7    
 v;?#AY__.qr
;;||~rd   c                 "    | j                         S r   r*  r  s    r`   r+  zExchange.strip  s    ||~rd   c                 `    t        j                  t        | j                         d             S )Nc                     | d   S Nr   r   )ts    r`   <lambda>z"Exchange.keysort.<locals>.<lambda>  s    PQRSPT rd   )r   )collectionsOrderedDictsorteditems)r  s    r`   keysortzExchange.keysort  s#    &&vj.>.>.@n'UVVrd   c                      | Qd }t        | d         t        j                  u rt        j                         }ni }| D ]  }|j                  |        |S i S r  )r]   r  r  r   r'  resultargs      r`   extendzExchange.extend  s[    FDG} 7 77$002 #c"#M	rd   c                      d }| D ]S  }t        |t              r?t        |t              si }|D ]'  }t        j                  ||v r||   nd ||         ||<   ) R|}U |S r   )rV   r   rA   r   )r'  r  r  r   s       r`   r   zExchange.deep_extend  sx     	C#t$!&$/F iC"*"6"6cVmvc{Y]_bcf_g"hF3Ki 	 rd   c                 b    t         j                  |       } t        t        fd|             S )Nc                     |    k(  S r   r   )rJ  r   r  s    r`   r  z$Exchange.filter_by.<locals>.<lambda>  s    QsVu_ rd   )rA   to_arrayr  filterarrayr   r  s    ``r`   	filter_byzExchange.filter_by  s&    !!%(F4e<==rd   c                 0    t         j                  | ||      S r   )rA   r  r  s      r`   filterByzExchange.filterBy  s    !!%e44rd   c                     i }t         j                  |       } | D cg c]  }||v s||   | } }| D ](  }||   |vrg |||   <   |||      j                  |       * |S c c}w r   )rA   r	  append)r  r   r  entrys       r`   group_byzExchange.group_by  s    !!%($)Y5cUlsAWYY 	-ESz'%'uSz"5:%%e,	-  Zs   	A!A!A!c                 .    t         j                  | |      S r   )rA   r  )r  r   s     r`   groupByzExchange.groupBy  s      ,,rd   c                     i }t        |       t        u r#t        j                  |       j	                         } t        |t              }| D ]'  }|r|t        |      k  s||v s||   ||   }|||<   ) |S r   )r]   r   rA   r   valuesrV   r  r  )r  r   r  
is_int_keyelementks         r`   index_byzExchange.index_by  s    ;$$$U+224ES)
 	$Gs7|!3#.PWX[P\PhCL#q		$ rd   c                 *    t        | fd|      S )Nc                     |    |    S S r   r   )r  r[   r   s    r`   r  z"Exchange.sort_by.<locals>.<lambda>  s    QsV5G1S6 W rd   r   reverser  )r  r   
descendingr[   s    ` `r`   sort_byzExchange.sort_by  s    e!T^hiird   c                 *    t        | fd|      S )Nc                 6    |    |    nd|    |    fS dfS r  r   )r  r  r  s    r`   r  z$Exchange.sort_by_2.<locals>.<lambda>  s7    qw7JAdGPR_`ae_f_rTUVZT[+{ xz+{ rd   r  r   )r  r  r  r!  s    `` r`   	sort_by_2zExchange.sort_by_2  s    e!{  FP  Q  	Qrd   c                     | |z   S r   r   )abs     r`   array_concatzExchange.array_concat  s    1urd   c                 
    | |v S r   r   )needlehaystacks     r`   in_arrayzExchange.in_array  s    !!rd   c                     |  S r   r   )objects    r`   is_emptyzExchange.is_empty  s
    zrd   c                 .    t        j                  d|       S )Nz
{([\w-]+)})refindallr  s    r`   extract_paramszExchange.extract_params  s    zz-00rd   c                     t        |t              r?|D ]:  }t        ||   t              r| j                  d|z   dz   t	        ||               } < | S )N{})rV   r   r  r  r"  )r  paramsr   s      r`   implode_paramszExchange.implode_params  sS    fd# O!&+t4#^^C#IOS=MNFO rd   c                     | j                         }| j                         D ]  \  }}t        |t              s|rdnd||<   ! t	        j
                  ||t        j                        S )Ntruefalse	quote_via)copyr  rV   bool
_urlencode	urlencodequote)r8  doseqsort	newParamsr   r  s         r`   rB  zExchange.urlencode  sZ    KKM	 ,,. 	>JC%&+0g	#	> ##Iu
@P@PQQrd   c                 X    t        j                  ddt        j                  | d            S )Nz	%5B\d*%5Drx   T)r2  subrA   rB  r8  s    r`   urlencode_with_array_repeatz$Exchange.urlencode_with_array_repeat  s"    vvlB(:(:64(HIIrd   c                     i dfd	t        | t              r| D ]  } | |   |        t        j                  t        j                        S )Nc                 $   i }t        | t              r"| D ]  }dj                  ||      }| |   ||<    nFt        | t        t        f      r+t        |       D ]  \  }}dj                  ||      }|||<    n| |<   |D ]  }||   } ||        y )Nz{}[{}])rV   r   r  r  tuple	enumerate)	r8  p_keyencode_paramsr   
encode_keyoffsetr  _encode_paramsr  s	          r`   rS  z1Exchange.urlencode_nested.<locals>._encode_params  s    M&$'! <C!)!<J06sM*-< FT5M2%.v%6 6MFE!)!?J05M*-6 !'u$ +%c*uc*+rd   r=  r   )rV   r   rA  rB  rC  )r8  r   rS  r  s     @@r`   urlencode_nestedzExchange.urlencode_nested  sO    	+ fd# 1vc{C01##Fj6F6FGGrd   c                 R    t        j                  t        j                  |             S r   )rA  unquoterA   rB  rI  s    r`   	rawencodezExchange.rawencode  s    !!("4"4V"<==rd   c                 0    t        j                  | |      S )N)safe)rA  rC  )urirY  s     r`   encode_uri_componentzExchange.encode_uri_component  s    $//rd   c                     t        | t              rB| j                         }|D ]+  }t        |      t        u r|D ]
  }||v s||=  $||v s)||= - |S | S r   )rV   r   r?  r]   r  )dr'  r  r  r   s        r`   omitzExchange.omit  sk    aVVXF (9$" ,&= &s, f}"3K( Mrd   c                 *    t        t        |             S r   )r  setr  s    r`   uniquezExchange.unique%  s    CJrd   c                 D    | D cg c]  }||v r
||   ||    c}S c c}w r   r   )r  r   r  s      r`   pluckzExchange.pluck)  s8     !
wWS\%= CL
 	
 
s   c            
      l    t        | D cg c]  }t        |t        t        f      s| c}      S c c}w r   )sumrV   r  r  )r'  r  s     r`   rf  zExchange.sum1  s(    4IC:cE3<+HCIJJIs   11c                 ,    t        j                  |       S r   )r  r  ra  s    r`   orderedzExchange.ordered5  s    &&u--rd   c                     t         j                  i       }| D ]  ^}}}|dkD  s||v r||   nd|z   ||<    g }t        |j                               }|D ]  \  }}|j	                  ||g        |S r  )rA   rh  r  r  r  )bidasksrh  r   volumer   r  r  s          r`   	aggregatezExchange.aggregate9  s    ""2&#* 	VUFQz49W4D'%.!v!U	V W]]_%" 	+ME6MM5&/*	+rd   c                  *    t         j                         S r   )rA   secondsr   rd   r`   seczExchange.secE  s    !!rd   c                  *    t         j                         S r   )rA   r  r   rd   r`   mseczExchange.msecI      $$&&rd   c                  *    t         j                         S r   )rA   microsecondsr   rd   r`   useczExchange.usecM  rr  rd   c                  <    t        t        j                               S r   r  r  r   rd   r`   rn  zExchange.secondsQ  s    499;rd   c                  B    t        t        j                         dz        S r  rw  r   rd   r`   r  zExchange.millisecondsU  s    499;%&&rd   c                  B    t        t        j                         dz        S )Ni@B rw  r   rd   r`   rt  zExchange.microsecondsY  s    499;())rd   c                 `   | | S t        | t              sy t        |       dk  ry 	 t        j                  j                  | dz  t        j                  j
                        }|j                  d      d d dj                  t        |       dz        z   dz   S # t        t        t        f$ r Y y w xY w)Nr   rB  z%Y-%m-%dT%H:%M:%S.%fz{:03d}Z)rV   r  datetimefromtimestamptimezoneutcstrftimer  r\   OverflowErrorOSError)	timestampr  s     r`   iso8601zExchange.iso8601]  s    )S)y>A	##11)t2CXEVEVEZEZ[C<< 67<xsS\~`dOd?eehkkk='2 		s   A/B B-,B-c                     |t         j                   j                         }n|}t        |j                               }t	        |      S r   )r}  r	  rM   	timetuplerN   )r^   r  tsstamps       r`   rfc2616zExchange.rfc2616l  s<    ""&&(BBr||~&&&rd   c                     t         j                   j                  t        t        | dz              t         j                  j
                        }|j                  d|z   dz   |z   dz         S )NrB  %mr  %Yr}  r~  r  roundr  r  r  r  infixutc_datetimes      r`   dmyzExchange.dmyu  sZ    ((66s5TAQ;R7SU]UfUfUjUjk$$TE\D%85%@4%GHHrd   c                     |rdnd}t         j                   j                  t        t        | dz              t         j                  j
                        }|j                  ||z   dz   |z   dz         S )Nr  z%yrB  r  r  r  )r  r  fullYearyear_formatr  s        r`   ymdzExchange.ymdz  sd    &dD((66s5TAQ;R7SU]UfUfUjUjk$$[5%84%?%%G$%NOOrd   c                 0    t         j                  | |d      S NFrA   r  r  r  s     r`   yymmddzExchange.yymmdd  s    ||Iue44rd   c                 0    t         j                  | |d      S NTr  r  s     r`   yyyymmddzExchange.yyyymmdd  s    ||Iud33rd   c                     t         j                   j                  t        t        | dz              t         j                  j
                        }|j                  d|z   dz         S )NrB  z%Y-%m-%dz%H:%M:%Sr  r  s      r`   ymdhmszExchange.ymdhms  sQ    ((66s5TAQ;R7SU]UfUfUjUjk$$Z%%7*%DEErd   c                    | | S t        | t              sy d| v r	 dj                  t        |       d d D cg c]  }t        |      j	                  d       c}      dz   }t
        j
                  j                  |d      }t        j                  |j                               dz  S t        j                  |       S c c}w # t        t        t        f$ r Y y w xY w)NGMTrx         z.000Z%Y%m%d%H%M%S.%fZrB  )rV   r"  r   rB   zfillr}  strptimecalendartimegmutctimetupler\   r  r  rA   	parse8601)r  r  r  dts       r`   
parse_datezExchange.parse_date  s    )S)I9YCWXZYZC[!\%#e*"2"21"5!\]`gg&&//8JKr'89D@@ %%i00 "] }g6 s#   C !B<AC <C CCc           
         | | S d}d}d}d}d}d}d}d}d|z   |z   |z   |z   |z   |z   |z   |z   }		 t        j                  |	| t         j                        }
|
y |
j                         \
  }}}}}}}}}}|xs d	}|d
z   dd }t	        |dd        }|xs d}t	        |dz         dz  }t	        |xs d      |z  }t	        |xs d      |z  }t        j                  ||      }||z   |z   |z   |z   |z   |z   dz   }t
        j
                  j                  |d      }||z   }t        j                  |j                               dz  |z   S # t        t        t        t        f$ r Y y w xY w)Nz([0-9]{4})-?z([0-9]{2})-?z([0-9]{2})(?:T|[\s])?z([0-9]{2}):?z
([0-9]{2})z(\.[0-9]{1,3})?z%(?:(\+|\-)([0-9]{2})\:?([0-9]{2})|Z)?rx   z.00000r   r  r   1r   )hoursminutesr|  r  rB  )r2  search
IGNORECASEgroupsr  r}  	timedeltar  r  r  r  r\   r  r  rz  )r  yyyymmddhmsmstzregexmatchsignr  r  msintrR  r  r  s                     r`   r  zExchange.parse8601  s   %7d
R"$q(1,q025:	IIeY>E}>Clln;D"b!Q2tUGvBt)Qq!B12KE:2Dtcz?R'D
Od*E',Q'$.G''eWEFBY^a'!+a/"4s:F""++F4FGBfB??2??#45<uDD=':> 		s   'E C-E E"!E"hexc                    |dk(  rt        t        j                  |             }n&t        j                  ||       }|j                         }|dk(  rt        j                  |      S |dk(  rt        j                  |      S |S )Nr6   base64r  )	ri  r6   SHA3hashlibnewdigestrA   binary_to_base64binary_to_base16)rW  	algorithmr  binaryr  s        r`   hashzExchange.hash  sn     6;;w/0FIw/AXXZFX,,V44u_,,V44rd   c                     t        j                  || |      }|j                         }|dk(  rt        j	                  |      S |dk(  rt        j                  |      S |S )Nr  r  )hmacr  r  rA   r  r  )rW  r   r  r  r  r  s         r`   r  zExchange.hmac  sU    HHVWi0U?,,V44x,,V44rd   c                  2    t               }| D ]  }||z   }	 |S r   ri  r  s      r`   binary_concatzExchange.binary_concat  s&     	"Cc\F	"rd   c                 2    t               }| D ]  }||z   }	 |S r   r  )r  r  r  s      r`   binary_concat_arrayzExchange.binary_concat_array  s'     	&Gg%F	&rd   c                 r    t         j                  t        j                  |             j	                  dd      S )N=rx   )rA   rj  r  urlsafe_b64encoder  r  s    r`   urlencode_base64zExchange.urlencode_base64  s)    v77:;CCCLLrd   c                 R    t         j                  t        j                  |             S r   )rA   rj  r  standard_b64encoder  s    r`   r  zExchange.binary_to_base64  s    v88;<<rd   c                 ,    t        j                  |       S r   )r  standard_b64decoder  s    r`   base64_to_binaryzExchange.base64_to_binary  s    ((++rd   c                 R    t         j                  t         j                  |             S r   )rA   r  rT  r  s    r`   string_to_base64zExchange.string_to_base64  s    (();<<rd   c                 R    t         j                  t        j                  |             S r   )rA   rj  r  	b64decoder  s    r`   base64_to_stringzExchange.base64_to_string  s    v//233rd   sha256c                    t         j                  t         j                  t         j                  d}|rdnd|dd  z   }d|v r
|d   |d   }|dd}d|v r|d   |d   |d<   d	|v r|d	   |d	   |d	<   t        j                  t        j                  |            }t        j                  |      }	t        j                  t        j                  t        j                  |                   }
|	d
z   |
z   }|dd }|s|dk(  r>t        j                  t        j                  |t        j                  |      |            }n|dk(  rWt        j                  ||d|      }t        j                  |d   j                  dd      |d   j                  dd      z         }n.t        j                  t        j                  |      |||   d      }|d
z   t        j                  |      z   S )Nr  sha384sha512RSHS   algJWT)r  typkidnoncer  r   r  ESp256r@   r  r  r  )r  r  r  r  rA   rT  r:  r  r  rsarj  r5   base16_to_binaryrjustr  )rW  r   r  is_rsaoptsalgosr  header_optsheaderencoded_headerencoded_datar   algoType	signaturerawSignatures                  r`   jwtzExchange.jwt  s    nnnnnn

 t49QR=8D=T%[4u+C
 D=T%[4!%eKd?tG}8#'=K {!;<!226:00wAW1XY$|3q8X% 11(,,uhooV\F]_h2ijI#>>%KL 11,s2C2I2I"c2RUabeUfUlUlmoqtUu2uvI hooe&<feIFVX`aIs{X66yAAArd   c                 ~   t        j                         t        j                         t        j                         d}||   }t	        t
        j                  |      d t        j                               }t
        j                  |j                  t
        j                  |       t        j                         |            S )Nr  )r1   SHA256SHA384SHA512r4   rA   rT  r0   default_backendr  r  r2   PKCS1v15)rW  r   r  
algorithmsr  priv_keys         r`   r  zExchange.rsa  s     mmommommo


 sO	'(?xG_G_Gab((xw7OQXQaQaQcen)opprd   c                 .    t        j                  | |      S r   )r7   rT  )r   r'  s     r`   eth_abi_encodezExchange.eth_abi_encode"  s    zz%&&rd   c                     t         j                  j                  | ||      }t        j	                  d|j
                  |j                        S )Ns   )r8   messagesencode_typed_datarA   r  r  rk  )domainmessageTypesmessageencodedDatas       r`   eth_encode_structured_dataz#Exchange.eth_encode_structured_data&  s=    &&88wW%%k;3E3E{GWGWXXrd   c                     t        |       }t        |      }t        |d      t        d      d|dg}t	        t        |d      ||      }||t        |      dS )Nr   
initializer  r   )
class_hashconstructor_calldatasalt)r   	publicKeyaddress)r;   r?   r  r=   r<   r  )r  accountClassHashaccountProxyClassHashr   r  calldatar  s          r`   retrieve_stark_accountzExchange.retrieve_stark_account+  so    7	B
(4	 "%"<0
 "0"5!)
 %"7|
 	
rd   c           
      "   t        |j                               }t        |      dkD  rt        d      | |d   t        j                  dddddddd	ddgi|      |d
}t        j                  |      }|j                  t        |d            }|S )Nr   z5starknetEncodeStructuredData only support single typer   StarkNetDomainrU   felt)rU   r]   chainIdversion)r  primaryTyper   r  r   )
r  keysr  r   rA   r  TypedDataDataclass	from_dictmessage_hashr  )r  r  messageDatar  r   rW  typedDataClassmsgHashs           r`   starknet_encode_structured_dataz(Exchange.starknet_encode_structured_dataB  s    \&&()u:>VWW  8__ #V4&7&7#&  #
 ,55g> --c'2.>?rd   c                 r    t        | |      \  }}t        j                  t        |      t        |      g      S r   )r>   rA   r:  r  )r  prir  r  s       r`   starknet_signzExchange.starknet_signX  s0     !s+1}}c!fc!f-..rd   c                     t        |       S r   r9   )os    r`   r:   zExchange.packb^  s    Qxrd   c                     d| z  S )Nz%0.2Xr   )r  s    r`   int_to_base16zExchange.int_to_base16b  s    }rd   c                 F    t        t        j                  | dz        d      S )N   rJ  r  r  s    r`   random_byteszExchange.random_bytesf  r  rd   c           	      &   t         j                  dgt         j                  dgt         j                  dgt         j                  dgt         j
                  dgt         j                  dgd}||vrt        |dz         ||   }t        t        |d         }t        j                  |       }|t        j                  ||d      }	nt        j                  |d	      }	t        |t               rt        j                  |      }|j#                  d
      dkD  r!t         j$                  j'                  ||      }
n9t         j$                  j)                  t        j                  |d	      |d         }
|
j+                  |	|t         j,                  j.                        \  }}}t         j,                  j1                  ||f|
j2                  j4                        \  }}d}ddz  dz
  }|
j2                  j4                  dz  }|r||kD  s
||k  s||k  r|
j+                  |	|t         j,                  j.                  t        j7                  |d            \  }}}t         j,                  j1                  ||f|
j2                  j4                        \  }}|dz  }|r||kD  r||k  r||k  rt        j9                  t        j:                  |            j=                         t        j9                  t        j:                  |            j=                         }}|||dS )Nr  r  r  )p192p224r  p384p521	secp256k1z is not a supported algorithmr   r  Tcasefolds   -----BEGIN EC PRIVATE KEY-----r   r   curve)hashfunc	sigencode   r      )rD  rE  extra_entropy)r  r  v)r5   NIST192pNIST224pNIST256pNIST384pNIST521p	SECP256k1r   r   r  rA   rT  r  r  	b16decoderV   r"  find
SigningKeyfrom_pemfrom_stringsign_digest_deterministicutilsigencode_strings_canonizesigdecode_stringsprivkeyordernumber_to_lerj  	b16encoder  )rW  r   r  r  fixed_lengthr  
curve_infohash_functionencoded_requestr  r   r_binarys_binaryrI  r_ints_intcounterminimum_size
half_orderr  r  s                        r`   r5   zExchange.ecdsaj  s    ^^X.^^X.^^X.^^X.^^X.//84

 J&#I0O$OPP	*
A7"//'2]]?D(CF%%oEFfc"__V,F;;89B>""++FMBC""..v/?/?EI0KR\]^R_ / aC # = =f}HM

HmHm !> !o(Azz33Xx4H#++J[J[\uf*[[&&*

 2e|6KuXdOd$'$A$A&S`LQJJLqLqPXPePefmoqPr %B %t!Hh !::7788LckkN_N_`LE5qLG 
 2e|6KuXdOd v//9:@@BHOOTZTdTdemTnDoDuDuDw1
 	
rd   c                    t        |t              rt        j                  |      }t	        |      dk(  rt
        j                  j                  |      nt        |d       }t        j                  |j                  |             S )NrG  )rV   r"  rA   rT  r  r3   Ed25519PrivateKeyfrom_private_bytesr4   r  r  )rW  r   rC  private_keys       r`   eddsazExchange.eddsa  sq    fc"__V,FNQRXk]_N_g//BB6Jey  {A  CG  fH(()9)9')BCCrd   c                     d}t        j                  | d      } t        j                  |d      }t        j                  |||       }t        j                  |      S )Ns@                                                                   Tr@  )r  rP  rl  calculateSignaturerA   binary_to_base58)rW  r   rC  r  r  s        r`   axolotlzExchange.axolotl  sP    ""7T:!!&48,,VVWE	((33rd   c                     t         r$t        j                  |       j                  d      S t        j                  | dt              S )NrG  ),:)
separatorsr   )r9  dumpsrj  r:  rS   )rC  r8  s     r`   r:  zExchange.json  s2    <<%,,W55zz$:?KKrd   c                 j    t        | t              xr" t        |       dk\  xr | d   dk(  xs | d   dk(  S )Nr  r   r6  [)rV   r"  r  )inputs    r`   ry  zExchange.is_json_encoded_object  s>    5#& 9Uq9(c/7uQx3	:rd   c                 $    | j                  d      S NrG  )rT  r  s    r`   rT  zExchange.encode      }}W%%rd   c                 $    | j                  d      S rz  )rj  r  s    r`   rj  zExchange.decode  r{  rd   c                 Z    t        |       t        u rt        | j                               S | S r   )r]   r   r  r  r  s    r`   r	  zExchange.to_array  s#    '+E{d':tELLN#EErd   c                 l   d}| j                  d      \  }}}t        j                  d      \  }}}t        |      }	t        |      }
t        |      }t        |      }t        |      }t        |      }|	|kD  rd}|	|k(  r|
|kD  rd}n|
|k(  r||kD  rd}|s|rt        dt        z   dz   | z   dz         |S |S )NTr  Fz Your current version of CCXT is z, a newer version z2 is required, please, upgrade your version of CCXT)r   __version__r  r   )required_versionerrorr  major1minor1patch1major2minor2patch2
int_major1
int_minor1
int_patch1
int_major2
int_minor2
int_patch2s                  r`   check_required_versionzExchange.check_required_version  s    #3#9#9##> #.#4#4S#9 [
[
[
[
[
[

"F#J&z)j:.E"#E#SVj#jm}#}  Au  $u  v  vrd   c                     d|v sd|v r%t        j                  dd|      }t        |      dz  S t        j                  dd|      j                  d      }t	        |      dkD  rt	        |d         S d	S )
Nr   Ez\d\.?\d*[eE]rx   r   z0+$r  r   r   )r2  rH  r  r   r  )r^   r"  numStrr   s       r`   precision_from_stringzExchange.precision_from_string  sl    #:VVOR5Fv;##
 vr3'--c2 #E
Qs58}5A5rd   c                    |s?| j                   r3| j                  s| j                  | j                         S | j                   S d}| j                  d   du r| j	                         }| j                  |      }| j                  ||      S )a  
        Loads and prepares the markets for trading.

        Args:
            reload (bool): If True, the markets will be reloaded from the exchange.
            params (dict): Additional exchange-specific parameters for the request.

        Returns:
            dict: A dictionary of markets.

        Raises:
            Exception: If the markets cannot be loaded or prepared.

        Notes:
            It ensures that the markets are only loaded once, even if called multiple times.
            If the markets are already loaded and `reload` is False or not provided, it returns the existing markets.
            If a reload is in progress, it waits for completion before returning.
            If an error occurs during loading or preparation, an exception is raised.
        NfetchCurrenciesT)marketsmarkets_by_idset_marketshasfetch_currenciesfetch_markets)r^   reloadr8  r   r  s        r`   load_marketszExchange.load_markets  s~    ( ||))++DLL99||#
88%&$...0J$$V,44rd   c                 8    | j                  | j                        S r   )r	  r  r^   r8  s     r`   r  zExchange.fetch_markets  s    
 }}T\\**rd   c                     | j                   S r   )r   r  s     r`   r  zExchange.fetch_currencies
  s    
 rd   c                     i }i }| j                   d   r| j                         }| j                   d   r| j                         }||dS )NfetchTradingFeesfetchFundingFeesrp   )r  fetch_trading_feesfetch_funding_fees)r^   rq   rr   s      r`   
fetch_feeszExchange.fetch_fees  sR    88&'--/G88&'--/G
 	
rd   c                    t        | dd       }| d   }d|k(  rd}||z  S d|k(  rd}||z  S d|k(  rd}||z  S d	|k(  rd
}||z  S d|k(  rd}||z  S d|k(  rd}||z  S d|k(  rd}||z  S t        dj                  |            )Nr   r   yi3Mi ' wi:	 r]  iQ r  i  r  <   r  r   z"timeframe unit {} is not supported)r  r   r  )	timeframer~   unitscales       r`   parse_timeframezExchange.parse_timeframe  s    Yq_%}$;&E ~ D[%E ~ D[$E ~ D[ E ~ D[E ~ D[E
 ~	 D[E ~ CJJ4PQQrd   c                 f    t         j                  |       dz  }||z  }||z
  |t        k(  r|z   S dz   S )NrB  r   )rA   r  r   )r  r  	directionr  rR  s        r`   round_timeframezExchange.round_timeframe3  s?    %%i047R6!9+@RHHaHHrd   c                 "    ||
|dkD  r||z  S d S r  r   )r^   
baseVolumequoteVolumes      r`   vwapzExchange.vwap:  s0    .9.EJLbisvwiwj(  	C  C  	Crd   c                 Z    | j                   rt        t        | j                  dz         y y )Nz Eddsa functionality requires python-axolotl-curve25519, install with `pip install python-axolotl-curve25519==0.4.1.post2`: https://github.com/tgalal/python-axolotl-curve25519)requiresEddsarl  r   r   r   s    r`   check_required_dependenciesz$Exchange.check_required_dependencies=  s8    %-tww  *[   [  \  \ #0rd   c                    t        j                  t        j                  |      d      }t        j
                  j                  |t        j                        j                  j                         }t        j                  |      }dt        j                  t        j                  |            dd  j                         z   S )NTrB  0xi)r  rP  rA   rT  r5   rR  rT  rO  verifying_key	to_stringr6   r  rj  r\  r  )r^   r   private_key_bytespublic_key_bytespublic_key_hashs        r`   privateKeyToAddresszExchange.privateKeyToAddressA  s    ",,X__Z-H$O ++778IQVQ`Q`7aooyy{ ++&67hoof&6&6&GHNTTVVVrd   c                      | d d dk(  r| dd  S | S )Nr  r  r   r~  s    r`   remove0x_prefixzExchange.remove0x_prefixG  s!    !99rd   c           	      @   d }d }t        t        j                               dz  }t        j                  |j	                  dd       || j                  dd            t        j                  d      } ||d	         d
z  }t         ||||dz          dz        }|dd  S )Nc                     t        | d      S )Nr   )base)r  )ns    r`   
hex_to_decz!Exchange.totp.<locals>.hex_to_decO  s    qr?"rd   c                     t        |       dz  }|dkD  rd|z
  nd}| j                         d|z  z   }t        j                  |      S )Nr8  r   r  )r  r  r  	b32decode)r  missing_paddingr2   paddeds       r`   base32_to_bytesz&Exchange.totp.<locals>.base32_to_bytesR  sG    !!fqjO-<q-@a/)aGWWY#-0F##F++rd      r8  bigrH  rx   r  r   r  r{  )	r  r  rA   r  to_bytesr  r  sha1r"  )r   r  r  epochhmac_resrR  otps          r`   totpzExchange.totpM  s    	#	, DIIK B&==5!9?3;;WZ\^K_;`bibnbnpuvHRL)A-*Xffqj9:ZGH23xrd   c                 8    t        |       j                  |d      S )Nlittler  r  r  sizes     r`   r[  zExchange.number_to_le^  s    1vtX..rd   c                 8    t        |       j                  |d      S )Nr  r  r  s     r`   number_to_bezExchange.number_to_beb  s    1vtU++rd   c                 .    t        j                  | d      S r  )r  rP  r  s    r`   r  zExchange.base16_to_binaryf  s    4((rd   c                 n    t         j                  t        j                  |             j	                         S r   )rA   rj  r  r\  r  r  s    r`   r  zExchange.binary_to_base16j  s%    v//2399;;rd   c                 2    t        j                  |dz        S r  )r  r  )r^   r  s     r`   r  zExchange.sleepn  s    zz,-..rd   c                    t         j                  ]i t         _        i t         _        t        t         j                        D ]+  \  }}|t         j                  |<   |t         j                  |<   - d}t        t        |             D ]   }|dz  }|t         j                  | |      z  }" |j                  |j                         dz   dz  d      S )z2encodes a base58 string to as a big endian integerr   :      r8  r  )	rA   base58_decoderbase58_encoderrN  base58_alphabetranger  r  
bit_length)r  r   cr  s       r`   base58_to_binaryzExchange.base58_to_binaryq  s     ""*&(H#&(H#!(":":; /1-.''*-.''*/ s1v 	4AbLFh--ad33F	4  1 1 3a 7A=uEErd   c                    t         j                  ]i t         _        i t         _        t        t         j                        D ]+  \  }}|t         j                  |<   |t         j                  |<   - d}| D ]  }|dz  }||z  } g }|dkD  r7t        |d      \  }}|j                  t         j                  |          |dkD  r7|j                          dj                  |      S )Nr      r  rx   )	rA   r  r  rN  r  divmodr  r  r   )r(  r   r  r  byter  next_characters          r`   ro  zExchange.binary_to_base58  s    ""*&(H#&(H#!(":":; /1-.''*-.''*/  	DeOFdNF	 qj%+FB%7"FNMM(11.AB qj 	wwvrd   c                 P    ||S 	 | j                  |      S # t        $ r |cY S w xY wr   )r   rW   )r^   r  r[   s      r`   parse_numberzExchange.parse_number  s4    =N{{5)) s    %%c                 X    	 ||dk(  ry t        |      dk(  ry |S # t        $ r |cY S w xY w)Nrx   r   )r  rW   )r^   string_numbers     r`   	omit_zerozExchange.omit_zero  sB    	!$(;]#q(   	!  	!s      ))c                 |    ||dk(  rt        | j                  dz         |dk  rt        | j                  dz         y )Nlimitz; create_order() requires a price argument for a limit orderr   z( create_order() amount should be above 0)r   r   r   )r^   marketr]   sider~   r   r8  s          r`   check_order_argumentszExchange.check_order_arguments  sD    =w'2o(oppQ;tww)SSTT rd   c                     t        |      }|| j                  v r?| j                  |   } || j                  dz   |z   dz   |z   dz   |z   dz   |z   dz   |z         y )NrH  )r"  httpExceptionsr   )r^   r,  r-  r.  r/  rk  codeAsString
ErrorClasss           r`   rc  z Exchange.handle_http_status_code  sr    4y4...,,\:JTWWs]V3c9C?#ETWZZ]ccfiilppqq /rd   c                 f    t        j                  | j                  d            }|r
|dk\  r|dz
  S |S )NrM  l        l        )binasciicrc32rT  )r  signedunsigneds      r`   r   zExchange.crc32  s3    >>&--"78x:-k))Ord   c                 H    t        |t              r|S | j                  |      S r   )rV   r  r  )r^   r_   s     r`   clonezExchange.clone  s     d+sAS1AArd   c                 <    t        |t              rt        |      S |S r   )rV   r"  r  r^   r  s     r`   convert_to_big_intzExchange.convert_to_big_int  s    's3s5z>>rd   c                     t        |      S r   )r  r  s     r`   string_to_chars_arrayzExchange.string_to_chars_array  s    E{rd   c                 
    |d uS r   r   r  s     r`   value_is_definedzExchange.value_is_defined  s    D  rd   c                     |r||| S ||d  S r   r   )r^   r  firstseconds       r`   array_slicezExchange.array_slice  s    &,uU6"?%-?rd   c                 6    t        ||      rt        ||      S |S r   )r   r   )r^   r_   propertydefaultValues       r`   get_propertyzExchange.get_property  s    )0h)?wsH%Q\Qrd   c                     t        |||       y r   )r   )r^   r_   r  r  s       r`   set_propertyzExchange.set_property  s    Xu%rd   c                 L    t        j                  dd|      j                         S )Nz(?!^)([A-Z]+)z_\1)r2  rH  r  )r^   r"  s     r`   un_camel_casezExchange.un_camel_case  s    vvovs399;;rd   c                 r    |j                  dd      }|j                  dd      }|j                  dd      }|S )N\rx   z"{r6  z}"r7  )r  )r^   rh  modifiedContents      r`   fix_stringified_json_membersz%Exchange.fix_stringified_json_members  s>    
 "//$3)11$<)11$<rd   c                 F    | j                  | j                  |      | _        y r   )r  r   )r^   
newOptionss     r`   extend_exchange_optionsz Exchange.extend_exchange_options  s    {{4<<<rd   c                     i S r   r   r   s    r`   create_safe_dictionaryzExchange.create_safe_dictionary      	rd   c                     |S r   r   )r^   r  s     r`   convert_to_safe_dictionaryz#Exchange.convert_to_safe_dictionary  s    rd   c                     t        dj                  t        |      D cg c]!  }t        t	        j
                  dd            # c}            S c c}w )Nrx   r   r  )r  r   r  r"  r  randint)r^   r  r   s      r`   rand_numberzExchange.rand_number  s8    277uT{K!Cq! 45KLMMKs   &Ac                     t        |      S r   )r  )r^   r  s     r`   binary_lengthzExchange.binary_length  s    6{rd   seedsc                    t         t        d      | j                  |d      }t        | j	                  | j                  | j                  |      dd            d      }d}d}||z  |z  }||z  }t        | j                  |d      d	      |z  }t        | j                  |d
            t        d	      t        d      z  z  j                  t        d      d      }	t        | j                  |d            t        d	      t        d      z  z  j                  t        d      d      }
t        | j                  |d            t        d      z  j                  t        d      d      }t        | j                  |d            t        d      z  j                  t        d      d      }t        j                  t        |      t        d      t        |      t        |      t        | j                  |d            |
j                         |	j                         | j                  |d      dk(  t        |      t        |      d      }t        j                  |      }t        j                  |j                  d            }t        j                          j#                  |      }|j%                  |j'                               }|j(                  }|S )Nrzklink_sdk is not installed, please do pip3 install apexomni-arm or apexomni-x86-mac or apexomni-x86-windows-linuxslotIdr  r  r   l    l    r   r  r   18r   r   )roundingr  takerFeeRaterg   r   makerFeeRatepairIdr  BUYFr  )
zklink_sdkrW   r  r  r  r  rT  rL   quantizeContractBuildersafe_numberr   Contractri  fromhexremoveprefixZkLinkSignernew_from_seed
sign_musig	get_bytesr  )r^   r)  r8  r,  nonceInt	maxUint64	maxUint32r  r   priceStrsizeStrtakerFeeRateStrmakerFeeRateStrbuildertx	seedsByte
signerSeed	auth_datar  s                      r`   get_zk_contract_signature_objz&Exchange.get_zk_contract_signature_obj  s     Q  R  R!!&(3t++DIIdkk&6I8UZ,[\^`a(		Y&)39$((=rBYN	D,,VW=>PWX\P]A]]gghopqhr  ~Jg  K4++FF;<wr{gVZm?[[eefmnofp  |He  I"4#3#3FN#KLwW\~]gghopqhr  ~Hg  I"4#3#3FN#KLwW\~]gghopqhr  ~Hg  I,,	NCFCKUSAQAQRXZbAc=dOOx//143C3CFK3X\a3a #o"6?   )MM%"4"4T":;	,,.<<YG
))",,.9	''	rd   c                    t         t        d      | j                  |dd      }| j                  |d      r\d}t	        | j                  | j                  | j                  |      dd            d      }t        j                  t        |      |      }t        j                  t	        | j                  |d	d
            | j                  |d      t	        | j                  |dd
            t	        | j                  |dd
            t	        | j                  |dd
            | j                  |dd      | j                  |dd      | j                  |      t	        | j                  |dd
            	      }t        j                  |      }t        j!                  |j#                  d            }t        j$                         j'                  |      }	|	j)                  |j+                               }
|
j,                  }|S )Nr+  r  r  
isContract
4294967295r  r  r   zkAccountIdr   receiverAddresssubAccountIdreceiverSubAccountIdtokenIdr~   feetimestampSecondsr  )r3  rW   r  r   r  r  r  rT  r    
string_modr"  TransferBuilderr6  parse_to_intTransferri  r8  r9  r:  r;  r<  r=  r  )r^   r)  r8  r  formattedUint32formattedNonce
tx_builderrF  rG  rH  rI  r  s               r`   get_zk_transfer_signature_objz&Exchange.get_zk_transfer_signature_obj  s     Q  R  R  #6>>&,/*O !5!5diiE@RT\^c6d!egijN&&s>':OLE//  :;V%67  ;<  )?CD  A67VXs3VUC0e$  );Q?@


   ,MM%"4"4T":;	,,.<<YG
))",,.9	''	rd   returnc                    i dd dd dd ddddd| j                   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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 dQdRdSd i dTd dUd dVddWd dXd dYd dZd d[d d\d d]d d^d d_d d`d dad dbd dcd ddd i ded dfd dgd dhd did djdRdkdRdld dmd dnd dod dpd dqd drd dsd dtd dud i dvd dwd dxd dyd dzd d{d d|d d}d d~d dd dd dddd dd dd dd dd i dd dd dd dd dd dd dd dd dddd dd dd dd dd dd dd dd i dd dd dd dd dd dd dd dd dd dddd dd dd dd dd dd dd i dd dd dd dd dd dd dd dd dd dd dd dd dd dddd dd dd i dd dd dddd dd dd dd dd dd dd dd dd dd dd dd dd dd i dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd i dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd dd d d d d ddd dddd
d
d
d
d
d
d
d
d
dd di dd d d d d dd d i i dddd d d dd i dt        dt        dt        dt        dt        dt        d t        dt        dt        dt        dt        dt        dt        dt        dt        d	t        d
t        t        t        t        t
        t
        t        t        t        ddddt        t        d d dd d dd d dd d dddS (  Nr   rU   	countriesenableRateLimitTr  rf   rD  	certifiedFproaliasdexr  	publicAPI
privateAPICORSr   spotmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelAllOrdersWscancelOrdercancelOrderWscancelOrderscancelOrdersWscloseAllPositionsclosePositioncreateDepositAddresscreateLimitBuyOrdercreateLimitBuyOrderWscreateLimitOrdercreateLimitOrderWscreateLimitSellOrdercreateLimitSellOrderWscreateMarketBuyOrdercreateMarketBuyOrderWscreateMarketBuyOrderWithCostcreateMarketBuyOrderWithCostWscreateMarketOrdercreateMarketOrderWscreateMarketOrderWithCostcreateMarketOrderWithCostWscreateMarketSellOrdercreateMarketSellOrderWscreateMarketSellOrderWithCostcreateMarketSellOrderWithCostWscreateOrdercreateOrderWscreateOrders$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreatePostOnlyOrderWscreateReduceOnlyOrdercreateReduceOnlyOrderWscreateStopLimitOrdercreateStopLimitOrderWscreateStopLossOrdercreateStopLossOrderWscreateStopMarketOrdercreateStopMarketOrderWscreateStopOrdercreateStopOrderWscreateTakeProfitOrdercreateTakeProfitOrderWscreateTrailingAmountOrdercreateTrailingAmountOrderWscreateTrailingPercentOrdercreateTrailingPercentOrderWscreateTriggerOrdercreateTriggerOrderWsro   	editOrderemulated
editOrderseditOrderWsfetchAccountsfetchBalancefetchBalanceWsfetchBidsAsksfetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCanceledAndClosedOrdersfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchClosedOrdersWsfetchConvertCurrenciesfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCrossBorrowRatefetchCrossBorrowRatesr  fetchCurrenciesWsfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositsWsfetchDepositWithdrawFeefetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchMarginAdjustmentHistoryfetchIsolatedPositionsfetchL2OrderBookfetchL3OrderBookfetchLastPricesfetchLedgerfetchLedgerEntryfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarketsWsfetchMarkOHLCVfetchMyLiquidationsfetchMySettlementHistoryfetchMyTradesfetchMyTradesWs
fetchOHLCVfetchOHLCVWsfetchOpenInterestfetchOpenInterestsfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrdersfetchOpenOrdersWsfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrderBooksfetchOrderBookWsfetchOrdersfetchOrdersByStatusfetchOrdersWsfetchOrderTradesfetchOrderWsfetchPositionfetchPositionHistoryfetchPositionsHistoryfetchPositionWsfetchPositionModefetchPositionsfetchPositionsWsfetchPositionsForSymbolfetchPositionsForSymbolWsfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchStatusfetchTickerfetchTickerWsfetchTickersfetchMarkPricesfetchTickersWs	fetchTimefetchTradesfetchTradesWsfetchTradingFeer  fetchTradingFeesWsfetchTradingLimitsfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransferfetchTransfersfetchUnderlyingAssetsfetchVolatilityHistoryfetchWithdrawAddressesfetchWithdrawalfetchWithdrawalsfetchWithdrawalsWsfetchWithdrawalWhitelistreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModesignIntransferwatchBalancewatchMyTrades
watchOHLCVwatchOHLCVForSymbolswatchOrderBookwatchBidsAskswatchOrderBookForSymbolswatchOrderswatchOrdersForSymbolswatchPositionwatchPositionswatchStatuswatchTickerwatchTickerswatchTradeswatchTradesForSymbolswatchLiquidationswatchLiquidationsForSymbolswatchMyLiquidationswatchMyLiquidationsForSymbolsrn   wsurls)logoapiwwwdocfeesr@  requiredCredentialsr   r  r   
timeframesrh   rm   rp   ok)statusupdatedetar.  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   ry   r|   )rC  rG  r   r  commonCurrenciesprecisionModepaddingModer   )	rD  r   r   r   r
   r	   r   r   r   r   s    r`   r   zExchange.describe[  s_   }
$}
D}
 }
 t	}

 }
 t||}
 }
 5}
 U}
 5}
  ^T^d^ ^ 4	^
 ^ $^ ^ $^ $^ T^ $T^ '^ ^ "4^ $T^  t!^"  #^$ %^& !$'^( $T)^*  +^, '-^. &t/^0 (1^2 #D3^4 %d5^6 '7^8 )$9^: ';^< )$=^> /?^@ 1$A^B $TC^D &tE^F ,TG^H .tI^J (K^L *4M^N 0O^P 24Q^R tS^T  U^V W^X 7Y^Z 9$[^\ &t]^^ (_^` (a^b *4c^d 'e^f )$g^h &ti^j (k^l (m^n *4o^p "4q^r $Ts^t (u^v *4w^x ,Ty^z .t{^| -d}^~ /^@ %dA^B 'C^D 4E^F ZG^H dI^J tK^L  M^N O^P !$Q^R  S^T &tU^V "4W^X +DY^Z )$[^\ #D]^^ ,T_^` /a^b &tc^d #De^f $Tg^h &ti^j )$k^l $Tm^n $To^p +Dq^r 's^t (u^v ":w^x $Zy^z {^| &t}^~ (^@ 1$A^B  C^D +DE^F "4G^H *4I^J +DK^L &tM^N #DO^P *4Q^R 'S^T (U^V $TW^X tY^Z "4[^\ *4]^^ +D_^` /a^b )$c^d #De^f #Dg^h "4i^j tk^l #Dm^n  o^p !$q^r %ds^t $Tu^v &tw^x -dy^z "4{^| #D}^~ +D^@ A^B !$C^D !$E^F &tG^H +DI^J  K^L "4M^N dO^P Q^R $TS^T %dU^V +DW^X !$Y^Z "4[^\ $T]^^ t_^` #Da^b dc^d !$e^f "4g^h #Di^j tk^l &tm^n  o^p #Dq^r s^t  u^v 'w^x (y^z "4{^| $T}^~ !$^@ #DA^B *4C^D ,TE^F %dG^H )$I^J )$K^L tM^N tO^P  Q^R S^T "4U^V !$W^X TY^Z t[^\  ]^^ "4_^` #Da^b %dc^d %de^f &tg^h 'i^j $Tk^l  m^n !$o^p (q^r )$s^t )$u^v "4w^x #Dy^z %d{^| +D}^~ ^@ #DA^B &tC^D tE^F TG^H  I^J "4K^L $M^N DO^P Q^R  S^T dU^V 'W^X !$Y^Z  [^\ +D]^^ t_^` (a^b  c^d !$e^f tg^h ti^j k^l tm^n (o^p $Tq^r .ts^t &tu^v 0w^x Dy^z d{^}
T U}
b 4c}
d ""!#!&$e}
| t}}
~ "}
@ $A}
F "&"&!!	 "&"& "!	 	 }~ ( +	
 + + + + + + + + + + +  +!" +#$ ,++%%***38 ! '%$(6"&t4!%d3 $T2	o	}
 }	
rd   r(  r  c                 P    | j                  |||      }t        |t              r|S |S zm
 @ignore
        safely extract boolean value from dictionary or list
        :returns bool | None:
        )r  rV   r@  r^   dictionaryOrListr(  r  r  s        r`   safe_bool_nzExchange.safe_bool_n  s.     !!"2D,GeT"Lrd   r  r  c                 ,    | j                  |||g|      S rN  rQ  r^   r  r  r  r  s        r`   safe_bool_2zExchange.safe_bool_2       
T4L,GGrd   r   c                 *    | j                  ||g|      S rN  rS  r^   r  r   r  s       r`   r   zExchange.safe_bool       
SE<@@rd   c                 x    | j                  |||      }||S t        |t              rt        |t              s|S |S zl
 @ignore
        safely extract a dictionary from dictionary or list
        :returns dict | None:
        )r  rV   r   r  rO  s        r`   safe_dict_nzExchange.safe_dict_n  sC     !!"2D,G=ud#eT*rd   c                 *    | j                  ||g|      S r[  r\  rX  s       r`   	safe_dictzExchange.safe_dict  rY  rd   c                 ,    | j                  |||g|      S r[  r^  rT  s        r`   safe_dict_2zExchange.safe_dict_2  rV  rd   c                 X    | j                  |||      }||S t        |t              r|S |S zi
 @ignore
        safely extract an Array from dictionary or list
        :returns Array | None:
        )r  rV   r  rO  s        r`   safe_list_nzExchange.safe_list_n  s9     !!"2D,G=eT"Lrd   c                 ,    | j                  |||g|      S rc  rd  )r^   rP  r  r  r  s        r`   safe_list_2zExchange.safe_list_2  s      04,MMrd   c                 *    | j                  ||g|      S rc  rf  )r^   rP  r   r  s       r`   	safe_listzExchange.safe_list  s      03%FFrd   c                 b    t        dt        |            D ]  }| j                  |||           y r  )r  r  handle_delta)r^   	orderbookdeltasr   s       r`   handle_deltaszExchange.handle_deltas  s0    q#f+& 	4Ai3	4rd   c                 2    t        | j                  dz         )Nz handleDelta not supported yetr   r   )r^   booksidedeltas      r`   rk  zExchange.handle_delta      477%EEFFrd   bookSidepriceKey	amountKeycountOrIdKeyc                     t        dt        |            D ]*  }| j                  ||   |||      }|j                  |       , y r  )r  r  parse_bid_ask
storeArray)r^   rt  rm  ru  rv  rw  r   bidAsks           r`   handle_deltas_with_keysz Exchange.handle_deltas_with_keys  sD    q#f+& 	(A''q	8YUF'	(rd   c                      y)Nr   r   )r^   rl  rm  s      r`   get_cache_indexzExchange.get_cache_index  s    rd   c                     || j                   }t        |j                               }t        dt	        |            D ]  }||   }||   |k(  s|c S  y r  )rE  r  r(  r  r  )r^   r  rE  r(  r   r   s         r`   find_timeframezExchange.find_timeframe	  s[    JJOO%&q#d)$ 	Aq'C#)+
	 rd   r.  r/  c                    g }d }| j                   |j                  d       | j                   }| j                  |j                  d       | j                  }| j                  %|j                  d       | j                  ||||      }| j                  %|j                  d       | j	                  ||||      }| j
                  G|j                  d       t        | j
                        r| j                  ||||      }n| j
                  }t        |      }|dkD  r/dj                  |      }t        | j                  dz   |z   d	z         |S )
Nrl  	proxy_urlproxyUrlCallbackproxy_url_callbackproxyr   rr  . you have multiple conflicting proxy settings(zW), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback)rl  r  r  r  r  r  callabler  r   r   r   )	r^   r.  r/  r   rk  usedProxiesrl  r  joinedProxyNamess	            r`   rN  z!Exchange.check_proxy_url_settings	  sD   ==$z*}}H>>%{+~~H  ,12,,S&'4HH"".34..sFGTJH::!w'

#::c67DA::[!A:"xx4&tww1a'adt't  xQ  (Q  R  Rrd   	targetUrlc                 \    |j                  d      dk\  }|r| j                  |      }|S |}|S )N?r   )rQ  r[  )r^   r  includesQueryfinalUrls       r`   rO  z"Exchange.url_encoder_for_proxy_url'	  s:    !s+q0;H4,,Y7 OXrd   c                    g }d }d }d }| j                  | j                        }	| j                  | j                        }
|	s|
r+|j                  d       |	r| j                  n| j                  }| j                  | j                        }| j                  | j
                        }|s|r;|j                  d       |r| j	                  ||||      n| j                  ||||      }| j                  | j                        }| j                  | j                        }|s|r+|j                  d       |r| j                  n| j                  }| j                  | j                        }| j                  | j                        }|s|r;|j                  d       |r| j                  ||||      n| j                  ||||      }| j                  | j                        }| j                  | j                        }|s|r+|j                  d       |r| j                  n| j                  }| j                  | j                        }| j                  | j                        }|s|r;|j                  d       |r| j                  ||||      n| j                  ||||      }t        |      }|dkD  r/dj                  |      }t!        | j"                  d	z   |z   d
z         |||gS )Nrm  httpProxyCallbackrn  httpsProxyCallbackro  socksProxyCallbackr   rr  r  zy), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback)r  rm  
http_proxyr  r  http_proxy_callbackrn  https_proxyr  https_proxy_callbackro  socks_proxyr  socks_proxy_callbackr  r   r   r   )r^   r.  r/  r   rk  r  rm  rn  ro  isHttpProxyDefinedisHttp_proxy_definedishttpProxyCallbackDefinedishttp_proxy_callback_definedisHttpsProxyDefinedisHttps_proxy_definedishttpsProxyCallbackDefinedishttps_proxy_callback_definedisSocksProxyDefinedisSocks_proxy_definedissocksProxyCallbackDefinedissocks_proxy_callback_definedr  r  s                          r`   rP  zExchange.check_proxy_settings-	  s   	

!224>>B#44T__E!5{+*<$//I%)%:%:4;Q;Q%R"(,(=(=d>V>V(W%%)F23Nh..sFGTJnr  oG  oG  HK  MS  U\  ^b  ocI"33DOOD $ 5 5d6F6F G"7|,,?TEUEUJ&*&;&;D<S<S&T#)-)>)>t?X?X)Y&&*H34Pk00fgtLqu  rK  rK  LO  QW  Y`  bf  rgJ"33DOOD $ 5 5d6F6F G"7|,,?TEUEUJ&*&;&;D<S<S&T#)-)>)>t?X?X)Y&&*H34Pk00fgtLqu  rK  rK  LO  QW  Y`  bf  rgJ[!A:"xx4&tww1a'adt't  xs  (s  t  t:z22rd   c                    g }d }d }d }| j                  | j                        }| j                  | j                        }|s|r+|j                  d       |r| j                  n| j                  }| j                  | j                        }| j                  | j
                        }|s|r+|j                  d       |r| j                  n| j
                  }| j                  | j                        }	| j                  | j                        }
|	s|
r+|j                  d       |	r| j                  n| j                  }t        |      }|dkD  r/dj                  |      }t        | j                  dz   |z   dz         |||gS )NwsProxywssProxywsSocksProxyr   rr  r  z<), please use only one from: wsProxy, wssProxy, wsSocksProxy)r  r  ws_proxyr  r  	wss_proxyr  ws_socks_proxyr  r   r   r   )r^   r  r  r  r  isWsProxyDefinedis_ws_proxy_definedisWssProxyDefinedis_wss_proxy_definedisWsSocksProxyDefinedis_ws_socks_proxy_definedr  r  s                r`   check_ws_proxy_settingsz Exchange.check_ws_proxy_settingsZ	  sf   00>"33DMMB2y)'7dlldmmG 11$--@#44T^^D 4z*):t}}H $ 5 5d6G6G H$($9$9$:M:M$N! $=~.1F4,,TM`M`L[!A:"xx4&tww1a'adt't  xv  (v  w  w<00rd   c                 >    |r|rt        | j                  dz         y y )Nzu you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy)r   r   )r^   rp  proxyUrlSets      r`   rQ  z"Exchange.check_conflicting_proxiesx	  s/    [&tww  2i  (i  j  j )=rd   r  c                 r   |t        | j                  dz         | j                  | j                  |            }t	        |      }|dk(  s,t	        |      | j
                  k  s|j                  d      dkD  r@t        | j                  dz   t        | j
                        z   dz   t        |      z   dz         |S )Nz address is Noner   rH  r   z% address is invalid or has less than z characters: "")r   r   rb  r	  r  minFundingAddressLengthrQ  r"  )r^   r  	uniqCharsr  s       r`   check_addresszExchange.check_address|	  s    ? +=!=>>[[!;!;G!DE	YQ;#g,)E)EEVYIZ]_I_ +R!RUXY]YuYuUv!v  zJ  "J  MP  QX  MY  "Y  \_  "_  `  `rd   r  c                     g }t        |j                  j                               }t        dt	        |            D ]-  }||   }|j                  |      dk\  s|j                  |       / |S r  )r  futuresr(  r  r  rQ  r  )r^   clientr  r  messageHashesr   messageHashs          r`   find_message_hasheszExchange.find_message_hashes	  si    V^^0023q#m,- 	+A'*K(A-k*	+ rd   r  r  r  	fromStartc                 P   | j                  |      rt        |      }|dkD  rd}||d   v r|d   |   }||dz
     |   }||||k  }|r3||kD  r|}|r| j                  |d|      }|S | j                  ||       }|S |r| j                  ||       }|S | j                  |d|      }|S )Nr   Tr   )r  r  r  )	r^   r  r  r   r  arrayLength	ascendingr  lasts	            r`   filter_by_limitzExchange.filter_by_limit	  s      'e*KQ 	58O!!HSME q1#6D(T-=$)TM	{* +  $ 0 05 A  !% 0 0 ? 	 ! $ 0 0 ?  !% 0 05 Ard   sincec                 L   | j                  |      }| j                  |      }|}|rMg }t        dt        |            D ]3  }	||	   }
| j	                  |
|      }|s||k\  s#|j                  |
       5 |r|| j                  ||       S | xr |}| j                  ||||      S r  r  r	  r  r  r  r  r  r  )r^   r  r  r  r   tailsinceIsDefinedparsedArrayr  r   r  r  shouldFilterFromStarts                r`   filter_by_since_limitzExchange.filter_by_since_limit	  s    ..u5mmE*F1c+./ )#As3eunMM%(	)
 E%##FUF33 %) ;^##FE38MNNrd   fieldc                    | j                  |      }| j                  |      }	| j                  |      }
|
}|s|	rmg }t        dt        |
            D ]S  }|
|   }||   |k(  }|r|nd}| j	                  ||      }|xr |d uxr ||k\  }|	r|nd}|s@|sC|j                  |       U |r|| j                  ||       S | j                  ||||	      S )Nr   Tr  )r^   r  r  r  r  r  r   r  valueIsDefinedr  r  r  r   r  entryFiledEqualValuefirstConditionentryKeyValueentryKeyGESincesecondConditions                      r`   filter_by_value_since_limitz$Exchange.filter_by_value_since_limit	  s    ..u5..u5mmE*^F1c+./ )#A',U|u'<$9G!5T $s ;#0"fuD7H"f}`eOe5C/!oMM%() E%##FUF33##FE3GGrd   enabledc                    |rd| j                   v rt        | j                   d   t              r@| j                   d   | j                   d<   | j                   d   | j                   d<   d| _        y| j                  | j                   d         | j                   d<   | j                  | j                   d         | j                   d<   d| _        yt	        | j
                  dz         d| j                   v rt        | j                   d   t              r| j                   d   | j                   d<   n+| j                  | j                   d         | j                   d<   | j                  | j                   d      }|| _         d| _        yy)z
        set the sandbox mode for the exchange
        :param boolean enabled: True to enable sandbox mode, False to disable it
        testr@  	apiBackupz does not have a sandbox URLTFN)r>  rV   r"  r  r   r   isSandboxModeEnabledr^  )r^   r  newUrlss      r`   r   zExchange.set_sandbox_mode	  sA   
 "dii.4-1YYu-=DIIk*'+yy'8DIIe$ )-D% .2ZZ		%8H-IDIIk*'+zz$))F2C'DDIIe$ )-D% #477-K#KLL DII%$))E*C0#'99[#9		% #'::dii.D#E		% ii		;7GDI(-D% &rd   publicr@  r   rk  c                     i S r   r   )r^   pathr@  r/  r8  r   rk  s          r`   r  zExchange.sign	  r!  rd   c                 2    t        | j                  dz         )Nz% fetchAccounts() is not supported yetrp  r  s     r`   fetch_accountszExchange.fetch_accounts	      477%LLMMrd   symbolc                 2    t        | j                  dz         )Nz# fetchTrades() is not supported yetrp  r^   r  r  r  r8  s        r`   fetch_tradeszExchange.fetch_trades	      477%JJKKrd   c                 2    t        | j                  dz         )Nz% fetchTradesWs() is not supported yetrp  r  s        r`   fetch_trades_wszExchange.fetch_trades_ws	  r  rd   c                 z    | j                   d   r| j                  |g|||      S t        | j                  dz         )Nr:  z) watchLiquidations() is not supported yet)r  watch_liquidations_for_symbolsr   r   r  s        r`   watch_liquidationszExchange.watch_liquidations	  s=    881266xvVV477%PPQQrd   symbolsc                 2    t        | j                  dz         )Nz3 watchLiquidationsForSymbols() is not supported yetrp  r^   r  r  r  r8  s        r`   r  z'Exchange.watch_liquidations_for_symbols	  s    477%ZZ[[rd   c                 z    | j                   d   r| j                  |g|||      S t        | j                  dz         )Nr<  z+ watchMyLiquidations() is not supported yet)r  !watch_my_liquidations_for_symbolsr   r   r  s        r`   watch_my_liquidationszExchange.watch_my_liquidations	  s>    8834996(E5RXYY477%RRSSrd   c                 2    t        | j                  dz         )Nz5 watchMyLiquidationsForSymbols() is not supported yetrp  r  s        r`   r  z*Exchange.watch_my_liquidations_for_symbols
  s    477%\\]]rd   c                 2    t        | j                  dz         )Nz# watchTrades() is not supported yetrp  r  s        r`   watch_tradeszExchange.watch_trades
  r  rd   c                 2    t        | j                  dz         )Nz% unWatchTrades() is not supported yetrp  r^   r  r8  s      r`   un_watch_tradeszExchange.un_watch_trades

  r  rd   c                 2    t        | j                  dz         )Nz- watchTradesForSymbols() is not supported yetrp  r  s        r`   watch_trades_for_symbolsz!Exchange.watch_trades_for_symbols
      477%TTUUrd   c                 2    t        | j                  dz         )Nz/ unWatchTradesForSymbols() is not supported yetrp  r^   r  r8  s      r`   un_watch_trades_for_symbolsz$Exchange.un_watch_trades_for_symbols
      477%VVWWrd   c                 2    t        | j                  dz         )Nz/ watchMyTradesForSymbols() is not supported yetrp  r  s        r`   watch_my_trades_for_symbolsz$Exchange.watch_my_trades_for_symbols
  r  rd   c                 2    t        | j                  dz         )Nz- watchOrdersForSymbols() is not supported yetrp  r  s        r`   watch_orders_for_symbolsz!Exchange.watch_orders_for_symbols
  r  rd   symbolsAndTimeframesc                 2    t        | j                  dz         )Nz, watchOHLCVForSymbols() is not supported yetrp  )r^   r  r  r  r8  s        r`   watch_ohlcv_for_symbolsz Exchange.watch_ohlcv_for_symbols
      477%SSTTrd   c                 2    t        | j                  dz         )Nz. unWatchOHLCVForSymbols() is not supported yetrp  )r^   r  r8  s      r`   un_watch_ohlcv_for_symbolsz#Exchange.un_watch_ohlcv_for_symbols
      477%UUVVrd   c                 2    t        | j                  dz         )Nz0 watchOrderBookForSymbols() is not supported yetrp  r^   r  r  r8  s       r`   watch_order_book_for_symbolsz%Exchange.watch_order_book_for_symbols
      477%WWXXrd   c                 2    t        | j                  dz         )Nz2 unWatchOrderBookForSymbols() is not supported yetrp  r  s      r`   un_watch_order_book_for_symbolsz(Exchange.un_watch_order_book_for_symbols"
      477%YYZZrd   codesc                 2    t        | j                  dz         )Nz- fetchDepositAddresses() is not supported yetrp  r^   r  r8  s      r`   fetch_deposit_addressesz Exchange.fetch_deposit_addresses%
  r  rd   c                 2    t        | j                  dz         )Nz& fetchOrderBook() is not supported yetrp  r^   r  r  r8  s       r`   fetch_order_bookzExchange.fetch_order_book(
      477%MMNNrd   c                 2    t        | j                  dz         )Nz( fetchOrderBookWs() is not supported yetrp  r  s       r`   fetch_order_book_wszExchange.fetch_order_book_ws+
      477%OOPPrd   c                     | j                   d   r%| j                  |g|      }| j                  ||      S t        | j                  dz         )Nr  z' fetchMarginMode() is not supported yet)r  fetch_margin_modesr_  r   r   )r^   r  r8  marginModess       r`   fetch_margin_modezExchange.fetch_margin_mode.
  sI    88&'116(FCK>>+v66tww)RRSSrd   c                 2    t        | j                  dz         )Nz( fetchMarginModes() is not supported yetrp  r  s      r`   r  zExchange.fetch_margin_modes5
  r  rd   c                     | j                  ddd      }t        d|      D ]  }	 | j                  |||      }|c S  y # t        $ r}|dz   |k(  r|Y d }~5d }~ww xY w)Nr-  
maxRetriesr  r   r   )handle_optionr  r  rW   )r^   r  r  r8  fetchSnapshotMaxRetriesr   	orderBookr   s           r`   fetch_rest_order_book_safez#Exchange.fetch_rest_order_book_safe8
  s}    "&"4"45E|UV"Wq12 	A 11&%H	  	   E55G 6s   =	A
AAc                 2    t        | j                  dz         )Nz& watchOrderBook() is not supported yetrp  r  s       r`   watch_order_bookzExchange.watch_order_bookC
  r  rd   c                 2    t        | j                  dz         )Nz( unWatchOrderBook() is not supported yetrp  r  s      r`   un_watch_order_bookzExchange.un_watch_order_bookF
  r  rd   c                 2    t        | j                  dz         )Nz! fetchTime() is not supported yetrp  r  s     r`   
fetch_timezExchange.fetch_timeI
      477%HHIIrd   c                 2    t        | j                  dz         )Nz* fetchTradingLimits() is not supported yetrp  r  s      r`   fetch_trading_limitszExchange.fetch_trading_limitsL
      477%QQRRrd   rawCurrencyc                 2    t        | j                  dz         )Nz% parseCurrency() is not supported yetrp  )r^   r2  s     r`   parse_currencyzExchange.parse_currencyO
  r  rd   c                     i }| j                  |      }t        dt        |            D ]   }| j                  ||         }|d   }|||<   " |S )Nr   r,  )r	  r  r  r4  )r^   rawCurrenciesr  arrr   parsedr,  s          r`   parse_currencieszExchange.parse_currenciesR
  s\    mmM*q#c(# 	"A((Q0F&>D!F4L	" rd   r  c                 2    t        | j                  dz         )Nz# parseMarket() is not supported yetrp  )r^   r  s     r`   parse_marketzExchange.parse_market[
  r  rd   c                     g }t        dt        |            D ]%  }|j                  | j                  ||                ' |S r  )r  r  r  r;  )r^   r  r  r   s       r`   parse_marketszExchange.parse_markets^
  sA    q#g,' 	9AMM$++GAJ78	9rd   tickerc                 2    t        | j                  dz         )Nz# parseTicker() is not supported yetrp  )r^   r>  r  s      r`   parse_tickerzExchange.parse_tickerd
  r  rd   currencyc                 2    t        | j                  dz         )Nz+ parseDepositAddress() is not supported yetrp  )r^   depositAddressrA  s      r`   parse_deposit_addresszExchange.parse_deposit_addressg
      477%RRSSrd   tradec                 2    t        | j                  dz         )Nz" parseTrade() is not supported yetrp  r^   rF  r  s      r`   parse_tradezExchange.parse_tradej
      477%IIJJrd   transactionc                 2    t        | j                  dz         )Nz( parseTransaction() is not supported yetrp  )r^   rK  rA  s      r`   parse_transactionzExchange.parse_transactionm
  r  rd   r(  c                 2    t        | j                  dz         )Nz% parseTransfer() is not supported yetrp  )r^   r(  rA  s      r`   parse_transferzExchange.parse_transferp
  r  rd   r8   c                 2    t        | j                  dz         )Nz$ parseAccount() is not supported yetrp  )r^   r8   s     r`   parse_accountzExchange.parse_accounts
      477%KKLLrd   itemc                 2    t        | j                  dz         )Nz( parseLedgerEntry() is not supported yetrp  )r^   rS  rA  s      r`   parse_ledger_entryzExchange.parse_ledger_entryv
  r  rd   rZ  c                 2    t        | j                  dz         )Nz" parseOrder() is not supported yetrp  r^   rZ  r  s      r`   parse_orderzExchange.parse_ordery
  rJ  rd   c                 2    t        | j                  dz         )Nz- fetchCrossBorrowRates() is not supported yetrp  r  s     r`   fetch_cross_borrow_ratesz!Exchange.fetch_cross_borrow_rates|
  r  rd   c                 2    t        | j                  dz         )Nz0 fetchIsolatedBorrowRates() is not supported yetrp  r  s     r`   fetch_isolated_borrow_ratesz$Exchange.fetch_isolated_borrow_rates
  r  rd   c                 2    t        | j                  dz         )Nz0 parseMarketLeverageTiers() is not supported yetrp  r^   r  r  s      r`   parse_market_leverage_tiersz$Exchange.parse_market_leverage_tiers
  r  rd   c                 2    t        | j                  dz         )Nz* fetchLeverageTiers() is not supported yetrp  r  s      r`   fetch_leverage_tierszExchange.fetch_leverage_tiers
  r1  rd   positionc                 2    t        | j                  dz         )Nz% parsePosition() is not supported yetrp  )r^   rb  r  s      r`   parse_positionzExchange.parse_position
  r  rd   c                 2    t        | j                  dz         )Nz/ parseFundingRateHistory() is not supported yetrp  r^  s      r`   parse_funding_rate_historyz#Exchange.parse_funding_rate_history
  r  rd   r  c                 2    t        | j                  dz         )Nz+ parseBorrowInterest() is not supported yetrp  r^  s      r`   parse_borrow_interestzExchange.parse_borrow_interest
  rE  rd   c                 2    t        | j                  dz         )Nz/ parseIsolatedBorrowRate() is not supported yetrp  r^  s      r`   parse_isolated_borrow_ratez#Exchange.parse_isolated_borrow_rate
  r  rd   c                 2    t        | j                  dz         )Nz$ parseWsTrade() is not supported yetrp  rH  s      r`   parse_ws_tradezExchange.parse_ws_trade
  rR  rd   c                 2    t        | j                  dz         )Nz$ parseWsOrder() is not supported yetrp  rW  s      r`   parse_ws_orderzExchange.parse_ws_order
  rR  rd   c                 2    t        | j                  dz         )Nz) parseWsOrderTrade() is not supported yetrp  rH  s      r`   parse_ws_order_tradezExchange.parse_ws_order_trade
      477%PPQQrd   c                 &    | j                  ||      S r   )parse_ohlcvr^   r   r  s      r`   parse_ws_ohlcvzExchange.parse_ws_ohlcv
  s    v..rd   c                 2    t        | j                  dz         )Nz) fetchFundingRates() is not supported yetrp  r  s      r`   fetch_funding_rateszExchange.fetch_funding_rates
  rq  rd   c                 2    t        | j                  dz         )Nz- fetchFundingIntervals() is not supported yetrp  r  s      r`   fetch_funding_intervalsz Exchange.fetch_funding_intervals
  r  rd   c                 2    t        | j                  dz         )Nz( watchFundingRate() is not supported yetrp  r  s      r`   watch_funding_ratezExchange.watch_funding_rate
  r  rd   c                 2    t        | j                  dz         )Nz) watchFundingRates() is not supported yetrp  r  s      r`   watch_funding_rateszExchange.watch_funding_rates
  rq  rd   c                 &    | j                  ||      S r   )r}  r  s      r`   watch_funding_rates_for_symbolsz(Exchange.watch_funding_rates_for_symbols
  s    ''88rd   r,  r~   fromAccount	toAccountc                 2    t        | j                  dz         )Nz  transfer() is not supported yetrp  )r^   r,  r~   r  r  r8  s         r`   r(  zExchange.transfer
      477%GGHHrd   c                 2    t        | j                  dz         )Nz  withdraw() is not supported yetrp  )r^   r,  r~   r  tagr8  s         r`   rn   zExchange.withdraw
  r  rd   c                 2    t        | j                  dz         )Nz, createDepositAddress() is not supported yetrp  r^   r,  r8  s      r`   create_deposit_addresszExchange.create_deposit_address
  r  rd   r}   c                 2    t        | j                  dz         )Nz# setLeverage() is not supported yetrp  )r^   r}   r  r8  s       r`   set_leveragezExchange.set_leverage
  r  rd   c                     | j                   d   r%| j                  |g|      }| j                  ||      S t        | j                  dz         )Nr  z% fetchLeverage() is not supported yet)r  fetch_leveragesr_  r   r   )r^   r  r8  	leveragess       r`   fetch_leveragezExchange.fetch_leverage
  sI    88$%,,fXv>I>>)V44tww)PPQQrd   c                 2    t        | j                  dz         )Nz& fetchLeverages() is not supported yetrp  r  s      r`   r  zExchange.fetch_leverages
  r  rd   hedgedc                 2    t        | j                  dz         )Nz' setPositionMode() is not supported yetrp  )r^   r  r  r8  s       r`   set_position_modezExchange.set_position_mode
      477%NNOOrd   c                 2    t        | j                  dz         )Nz! addMargin() is not supported yetrp  r^   r  r~   r8  s       r`   
add_marginzExchange.add_margin
  r.  rd   c                 2    t        | j                  dz         )Nz$ reduceMargin() is not supported yetrp  r  s       r`   reduce_marginzExchange.reduce_margin
  rR  rd   c                 2    t        | j                  dz         )Nz! setMargin() is not supported yetrp  r  s       r`   
set_marginzExchange.set_margin
  r.  rd   r  c                 2    t        | j                  dz         )Nz+ fetchLongShortRatio() is not supported yetrp  )r^   r  r  r8  s       r`   fetch_long_short_ratiozExchange.fetch_long_short_ratio
  rE  rd   c                 2    t        | j                  dz         )Nz2 fetchLongShortRatioHistory() is not supported yetrp  r^   r  r  r  r  r8  s         r`   fetch_long_short_ratio_historyz'Exchange.fetch_long_short_ratio_history
  r  rd   r]   c                 2    t        | j                  dz         )a  
        fetches the history of margin added or reduced from contract isolated positions
        :param str [symbol]: unified market symbol
        :param str [type]: "add" or "reduce"
        :param int [since]: timestamp in ms of the earliest change to fetch
        :param int [limit]: the maximum amount of changes to fetch
        :param dict params: extra parameters specific to the exchange api endpoint
        :returns dict[]: a list of `margin structures <https://docs.ccxt.com/#/?id=margin-loan-structure>`
        z4 fetchMarginAdjustmentHistory() is not supported yetrp  )r^   r  r]   r  r  r8  s         r`   fetch_margin_adjustment_historyz(Exchange.fetch_margin_adjustment_history
  s     477%[[\\rd   
marginModec                 2    t        | j                  dz         )Nz% setMarginMode() is not supported yetrp  )r^   r  r  r8  s       r`   set_margin_modezExchange.set_margin_mode
  r  rd   c                 2    t        | j                  dz         )Nz6 fetchDepositAddressesByNetwork() is not supported yetrp  r  s      r`   "fetch_deposit_addresses_by_networkz+Exchange.fetch_deposit_addresses_by_network
  s    477%]]^^rd   1hc                 2    t        | j                  dz         )Nz0 fetchOpenInterestHistory() is not supported yetrp  r  s         r`   fetch_open_interest_historyz$Exchange.fetch_open_interest_history
  r  rd   c                 2    t        | j                  dz         )Nz) fetchOpenInterest() is not supported yetrp  r  s      r`   fetch_open_interestzExchange.fetch_open_interest
  rq  rd   c                 2    t        | j                  dz         )Nz* fetchOpenInterests() is not supported yetrp  r  s      r`   fetch_open_interestszExchange.fetch_open_interests
  r1  rd   c                 2    t        | j                  dz         )Nz signIn() is not supported yetrp  r  s     r`   sign_inzExchange.sign_in
  rs  rd   c                 2    t        | j                  dz         )Nz+ fetchPaymentMethods() is not supported yetrp  r  s     r`   fetch_payment_methodszExchange.fetch_payment_methods
  rE  rd   c                 P    | j                  |      }t        |      }t        |      S r   )r   r  r  )r^   r   stringifiedNumberconvertedNumbers       r`   rW  zExchange.parse_to_int
  s+     !11&9 12?##rd   c                 x    | j                  |      }|j                  d      dk\  rt        |      S t        |      S )Nr  r   )r   rQ  r  r  )r^   r   stringVersions      r`   parse_to_numericzExchange.parse_to_numeric
  s=    --f5
 c"a'''=!!rd   r  c                 4    | j                  |dz        }|dk(  S r  )r  )r^   r  ress      r`   is_round_numberzExchange.is_round_number	  s!     ##UQY0axrd   r_   c                 r    | j                  ||      }| j                  | j                  |            }||S |S r   )r  r  r  )r^   r_   r   r  r  finals         r`   safe_number_omit_zerozExchange.safe_number_omit_zero  s<      c*!!$.."78 %|9E9rd   c                 <    | j                  |||      }||dk(  ry |S r  )r  )r^   r_   r   r  r  s        r`   safe_integer_omit_zerozExchange.safe_integer_omit_zero  s+    %%c3=		Qrd   c                    | j                          | j                          | j                  r| j                  | j                         | j	                          | j                  | j                  ddd      }|r| j                  |       y y )Nr   r   F)create_networks_by_id_objectfeatures_generatorr  r  init_rest_rate_limiterrU  r   r   )r^   	isSandboxs     r`   r   zExchange.after_construct  so    ))+!<<T\\*##%$$T\\9iO	!!), rd   c                 h   | j                   | j                  '| j                   dk(  rt        | j                  dz         | j                  }| j                   dkD  rd| j                   z  }dddd|d}| j                  i n| j                  }| j                  ||      | _        | j                          y )Nr   z%.rateLimit property is not configuredr   r   gMbP?rB  )r  capacityr   maxCapacity
refillRate)r  r   r   	MAX_VALUEtokenBucketr  r  )r^   r  defaultBucketexistingBuckets       r`   r  zExchange.init_rest_rate_limiter(  s    >>!dgg&9dnnPR>R*Q QRR^^
>>AT^^+J$
 !% 0 0 8t?O?O;;}nErd   c                    | j                   y | j                   }i | _         g d}ddg}t        dt        |            D ]  }||   }||vrd | j                   |<   |dk(  r!| j                  ||d       | j                   |<   Bi | j                   |<   t        dt        |            D ]*  }||   }| j                  |||      | j                   |   |<   ,  y )N)rh  rj  rk  rl  linearinverser   rh  )featuresr  r  features_mapper)r^   initialFeaturesunifiedMarketTypessubTypesr   
marketTypejsubTypes           r`   r  zExchange.features_generator9  s     == --Ai(q#012 	xA+A.J/1,0j)'040D0D_V`bf0gDMM*-02DMM*-"1c(m4 x"*1+=A=Q=QRacmov=wj1':x	xrd   r  r  r  c                 n   |||   |   n||   }|y | j                  |d      }|6| j                  |d      }| j                  ||      }| j                  ||      }d|v rd| j	                  |d   d      }||d   d<   ||d   d<   |dk(  rd|d   d<   d	|d   vrd|d   d	<   | j                  |d   d
   d      d|d   d
   d<   t        |j                               }t        dt        |            D ]?  }	||	   }
||
   }| j                  |
dg      r!|$d|vs)| j                  |
g d      |d<   A |S )Nextendsr  attachedStopLossTakeProfitstopLoss
takeProfitrh  Fr  r}   timeInForceGTCTr   r   symbolRequired)r  r  r  )r  r^  r  r   r_  r   r  r(  r  r  r-  )r^   r  r  r  featuresObj
extendsStr	extendObjr  r(  r   r   featureBlocks               r`   r  zExchange.features_mapper^  s   ?F?Roj1':YhisYt**;	B
!))K;K,,_jII**9kBK
 K'NN;}#=?[\E5:K&z27<K&|4V#7<M*84"k-&@@=BK.z:~~k-8GOWCGM*=9%@K$$&'q#d)$ 	wAq'C&s+L==yk2|7O(L859]]3Hu5vL!12	w rd   c                     |dz   S )Nz	  = Falser   r^   r  s     r`   orderbook_checksum_messagez#Exchange.orderbook_checksum_message  s    ##rd   c                     | j                  | j                  | j                  di             }| j                  || j                  | j                  di             | j                  d<   y )NnetworksnetworksById)invert_flat_string_dictionaryr  r   r  )r^   networkIdsToCodesGenerateds     r`   r  z%Exchange.create_networks_by_id_object  s`    %)%G%GX\XdXdfprtHu%v"'+{{3Mt_c_k_km{}  PA  (B^$rd   c                 $    dddiddiddidd	id
iS )NdefaultNetworkCodeReplacementsERC20ETHTRC20TRXCRC20CRONOSBRC20r   )r  r  CROr  r   r   s    r`   r   zExchange.get_default_options  s4    ,''*!5)	/
 	
rd   r  c                    | j                  d |      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }|5||t        j                  ||      }n||t        j                  ||      }|4|2|0t        j
                  ||      rd}t        j
                  ||      rd}| j                  |d      }|| j                  |d      |d<   | j                  |d	      }| j                  |d
i       }	| j                  |d      || j                  |      || j                  |d      | j                  |d      | j                  |d      | j                  |d      |d   | j                  |      | j                  |      | j                  |      | j                  |d      ||	dS )Nr  beforeafterr~   outinrS  r   r  r  r   r8   referenceIdreferenceAccountr]   r,  rG  )r   r  r}  r  r8   r  r  r]   rA  r~   r  r  rG  rS  r  )safe_currencyr  r    
string_sub
string_add	string_gtr  r6  r  r_  r  r  )
r^   r  rA  r  r  r  r~   rS  r  r  s
             r`   safe_ledger_entryzExchange.safe_ledger_entry  s   %%dH5$$UK8	!!%2  0!!%2~%"3 ++E6:#**66:%"3 $$VU3 %I$$UF3 $IooeU+?**37CK%%e[9	~~eVR0""5$/"Y/"''y9++E=A $ 0 08J K$$UF3 (''/''/&&u-&&uh7
 	
rd   c                    | j                  |di       }t        |j                               }t        |      }|dk7  r^t	        d|      D ]N  }||   }||   }| j                  |d      }| j                  |d      }	|	|r||d<   | j                  |d      }
| j                  |d      }||
r|
|d<   | j                  |d      }||r|
rd|d   |   d<   n||
d|d   |   d<   | j                  |d   |   d      }| j                  |d      }||r||d<   | j                  |d      }| j                  |d      }|t        j                  ||      r| j                  |      |d<   | j                  |d	      }| j                  |d	      }|t        j                  ||      r| j                  |      |d	<   | j                  |d
      }| j                  |d
      }|i |d
<   | j                  |d      }| j                  |d      }|i |d
   d<   | j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }|t        j                  ||      r| j                  |      |d
   d   d<   |t        j                  ||      r| j                  |      |d
   d   d<   | j                  |d      }| j                  |d      }|i |d
   d<   | j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }|t        j                  ||      r| j                  |      |d
   d   d<   |t        j                  ||      s5| j                  |      |d
   d   d<   Q | j                  d d d d d d d d d d d i i d d dd d ddd|      S )Nr  r   ro   rn   activeTFrS  r   r   rz   r{   ry   )ro   rn   )r  r   	numericIdr,  r   r]   rU   r  ro   rn   rS  rC  r  r   )r_  r  r(  r  r  r   r  r    	string_ltr  r   r  ) r^   rA  r  r(  r  r   r   networkro   currencyDepositrn   currencyWithdrawr  currencyActiverS  feeMainr   precisionMainr   
limitsMainlimitsDepositlimitsDepositMainlimitsDepositMinlimitsDepositMaxlimitsDepositMinMainlimitsDepositMaxMainlimitsWithdrawlimitsWithdrawMainlimitsWithdrawMinlimitsWithdrawMaxlimitsWithdrawMinMainlimitsWithdrawMaxMains                                    r`   safe_currency_structurez Exchange.safe_currency_structure  sa   >>(J;HMMO$TQ;1f% Ba1g"3-..)<"&..9"E"*g*1HY'>>':>#'>>(J#G #+x+3HZ(:>8>B,S1(; ,1E>C,S1(;(<S(A8L!%(!C!)V)/HX&&&w6**8U;?g&7&7W&E&*&7&7&<HUO ,,WkB	 $ 0 0; G (G,=,=i,W,0,=,=i,HH[):!^^Hh?
%)+HX& $vy A$(NN:y$I!$,46HX&y1#'#3#3M5#I #'#3#3M5#I '+'7'78I5'Q$'+'7'78I5'Q$'/73D3DEUWk3l;?;L;LM];^HX&y1%8'/73D3DEUWk3l;?;L;LM];^HX&y1%8!%
!C%)^^J
%K"%-57HX&z2$($4$4^U$K!$($4$4^U$K!(,(8(89KU(S%(,(8(89KU(S%(0G4E4EFWYn4o<@<M<MN_<`HX&z259(0G4E4EFWYn4o<@<M<MN_<`HX&z259EBaF {{  
  	
0 1 	rd   c           	         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 d d d d d d d d d d d!d"d d d#d$d d%d }|K| j                  ||      }|d   r2|d   d&|d<   |d   d&|d<   |d   d&|d<   |d   d&|d<   |d   d&|d<   |S |S )'Nr   lowercaseIdr  r  rC  settlebaseIdquoteIdsettleIdr]   rh  ri  rj  rk  rl  indexr  contractr  r  r  rk   rl   contractSizeexpiryexpiryDatetimestrike
optionTyper   )r~   r   r   r  rC  r   ry   r|   r  )crossisolatedcreatedr  F)r  )r^   r  cleanStructurer  s       r`   safe_market_structurezExchange.safe_market_structure!  sy   <
$<
4<
 d<
 D	<

 T<
 d<
 d<
 t<
 <
 D<
 D<
 d<
 D<
 d<
 d<
  T!<
" d#<
$ %<
& d'<
( t)<
* t+<
, T-<
. T/<
0 D1<
2 d3<
4 d5<
6 d7<
8 $9<
: ;<
H 
  
  
  I<
l  m<
t tu<
v Dw<
z [[8Ff~*%-).F:&&>)%*F6N(#+',F8$(#+',F8$'?*&+F7OMrd   c                 	   g }i | _         | j                  | j                  |      ddd      }t        dt	        |            D ]  }||   }|d   | j                   v r6| j                   |d      }|j                  |       || j                   |d   <   n|g| j                   |d   <   | j                  | j                         | j                  | j                  d| j                  d   |      }|d   rd|d<   n|d	   rd	|d<   nd |d<   |j                  |        | j                  |d
      | _        | j                  | j                        }	| j                  | j                         }
t        |	j                               | _        t        |
j                               | _        |#| j                  | j$                  |      | _        ng }g }t        dt	        |            D ]  }||   }| j&                  t(        k(  rdn| j+                  d      }| j-                  |di       }d|v rj| j/                  | j1                  |dd      | j3                  |d      | j5                  |d      | j7                  |dd|      d      }|j                  |       d|v s| j/                  | j1                  |dd      | j3                  |d      | j5                  |d      | j7                  |dd|      d      }|j                  |       ! | j                  |ddd      }| j                  |ddd      }| j                  |d      | _        | j                  |d      | _        | j=                  ||      }| j?                  |d      }t        |j                               }g }t        dt	        |            D ]  }||   }| jA                  ||g       }| jC                  |d      }t        dt	        |            D ]9  }||   }| j&                  tD        k(  r|d   |d   k  r|n|}+|d   |d   kD  r|n|}; |j                  |        | j                  |d      }| j                  | j$                  | j                  |d            | _        | j                  | j$                  d      | _#        | j                  | j$                        }t        |j                               | _$        | j                  S )Nrh  Tr   r   )r   r   rq   r  r  r  r  r8  z1e-8r   r  r  baseNumericIdr~   )r   r  r,  r   rC  r  quoteNumericIdr   r,  Frx   r   )%r  r"  r	  r  r  r  r   r+  r   r   rC  r  r  r   r  r(  r  idsr   rK  r   r  r_  r  r  r  r  r  baseCurrenciesquoteCurrenciesr)  r  ri  r  r   currencies_by_idr  )r^   r  r   r  marketValuesr   r  marketsByIdArrayr  marketsSortedBySymbolmarketsSortedByIdr0  r1  defaultCurrencyPrecisionmarketPrecisionrA  allCurrenciesgroupedCurrenciesr  resultingCurrenciesr,  groupedCurrenciesCodehighestPrecisionCurrencyr  currentCurrencysortedCurrenciescurrenciesSortedByCodes                              r`   r  zExchange.set_marketsp  s    ||DMM'$:FD$Oq#l+, 	"A OET{d000$($6$6uT{$C  ''.2B""5;/38'""5;/%%d&@&@&B!^^++E yy#U,F h$,y!	"$-y!$(y!MM&!%	"& }}VX6 $T\\ : LL););<16689)..01!"..t
KDON O1c&k* 5151C1C~1U1\`\m\mnt\u("&..b"IV##;;"006J%)%6%6v%O $ 0 0 @%)%6%6PXZr%s	=  H #))(3f$#;;"00GL%)%6%6v?O%P $ 0 0 A%)%6%6QXZr%s	=  H $**84'5( "\\.&%LN"ll?FE2NO"&--"GD#'==&#ID  --noNM $mV D*//12E"$1c%j) 
EQx(,7H$PR(S%+/??;PRS+T(q#&;"<= kA&;A&>O))Y6GVWbGcf~  @K  gL  HL?  Sk0GVWbGcf~  @K  gL  HL?  Sk0k $**+CD
E  $||,?H"..tN^`f@ghDO $doot D!%doo!>05578
||rd   currentRestInstanceparentRestInstancewsBaseDescribec                     | j                  |j                         |j                               }| j                  ||      }|S r   )r   r   )r^   rA  rB  rC  extendedRestDescribesuperWithRestDescribes         r`   %get_describe_for_extended_ws_exchangez.Exchange.get_describe_for_extended_ws_exchange  sC    #//0B0K0K0MObOkOkOmn $ 0 01E~ V$$rd   r   c                    | j                  |g d      }t        |j                               }i |d<   i |d<   i |d<   i }t        dt	        |            D ]E  }||   }| j                  ||   d      }| j                  ||   d      }| j                  ||   d      }	| j                  ||   d      }
|||	t        j                  ||	      }|||	t        j                  ||	      }|	||t        j                  ||      }	| j                  |      ||   d<   | j                  |	      ||   d<   | j                  |      ||   d<   ||   d   |d   |<   ||   d   |d   |<   ||   d   |d   |<   |
$| j                  |
      ||   d<   ||   d   ||<   H t        |j                               }t	        |      }|r||d<   |S )N)r  r  r}  freeusedtotalrI  rJ  rK  r   debt)
r^  r  r(  r  r  r  r    r  r  r  )r^   r   balancesr  debtBalancer   r,  rK  rI  rJ  rL  debtBalanceArrayr  s                r`   safe_balancezExchange.safe_balance  s   99W&`aX]]_%q#e*% 	:A8D$$WT]G<E##GDM6:D##GDM6:D##GDM6:DD$44;K**465#44;K))%65#44;K))%6$($5$5d$;GDM&!$($5$5d$;GDM&!%)%6%6u%=GDM'"$+DM&$9GFOD!$+DM&$9GFOD!%,T]7%;GGT"(,(9(9$(?f%$+DM&$9D!)	:*   0 0 23%&)GFOrd   c                    | j                  | j                  |d            }| j                  |d      }| j                  |d      }| j                  |d      }| j                  | j                  |d            }| j                  | j                  |d            }| j                  |d      }	| j                  |d      }
| j                  |d	      }| j                  |d
      }|d u }|d u }|	d u }| j                  |d      }|d u }| j                  |d      d u }|
d u }|d u }|xs |}| j	                  |dg       }g }| j                  |d      d uxs | j                  |d      d uxs | j                  |d      d u}|s|s|r| j                  |d|      }| j                  |d      }|d uxr
 d|v xr d|v }|s| j                  ||      }n|}d}t        |t              }|rt        |      }|r|dkD  r|d   |d   d   |d<   |d	   |d   d	   |d	<   |d   |d   d   |d<   |d   |d   d   |d<   |rd}|rd}t        dt        |            D ]?  }||   }| j                  |d      } |r| t        j                  ||       }| j                  |d      }!|r|!t        j                  ||!      }|r| j                  |d      }
|r| j                  |d	      }| j                  |d      }"|r|"|	|"}	nt        |	|"      }	|s| j                  |d      }#|#Bt        dt        |#            D ](  }$|#|$   }%|j                  | j                  i |%             * 	| j                  |d      }%|%|j                  | j                  i |%             B |r| j                  r| j!                  |      n|}&t        |&      }'t        d|'      D ]@  }| j#                  |&|   d      |&|   d<   d|&|   v s&| j#                  |&|   d      |&|   d<   B |sU|'dk(  rP| j%                  |      }(| j#                  |(d      |(d<   d|(v r| j#                  |(d      |(d<   |&j                  |(       |&|d<   |r|'dk(  r|&d   |d<   |"||t        j                  ||      }n|dk(  r|}|$||t        j&                  ||      }n	|dk(  r||}|"||t        j&                  ||      }n|dk(  rd}| j)                  |dd      })| j+                  | j                  |dd            }*|_|]|[t        j,                  |d      rEt        j.                  ||*      }+|)rt        j0                  |+|      }nt        j0                  ||+      }|d uxs |d u},|rR|P|,rNd }-||}-n|}-t        j.                  ||*      }+|)rt        j0                  |+|-      }nt        j.                  |+|-      }| j                  |d      }.|d u xs t        j2                  |d      }/|/r|.dk(  r|}t        dt        |            D ]  }||   }0| j#                  |0d      |0d<   | j#                  |0d      |0d<   | j#                  |0d      |0d<   | j5                  |0di       }%| j#                  |%d      |%d<   d|%v r| j#                  |%d      |%d<   | j	                  |0dg       }1t        dt        |1            D ]  }$| j#                  |1|$   d      |1|$   d<    |1|0d<   |%|0d<    | j                  |d      }2| j                  |d       }3|2|s| j                  |d      dk(  rd!}2|3r
d"}2n|3|2d"k(  }3| j                  |d      }4| j                  |d#      }5| j                  |d$      }6|6| j7                  |4      }6| j9                  | j;                  |dd%            }7| j9                  | j                  |d            }8| j9                  | j                  |d            }9| j                  |i d| j                  |d      d&| j                  |d&      d|4d$|6d|
d| j                  |d      d	|d|	d#|5d| j9                  |      d| j9                  |      d| j9                  |      d| j9                  |      d| j9                  |      d| j9                  |      d|2d |3|| j                  |d'      |7|7|8|9|| j                  |d      d(      S ))Nr~   	remainingfilledr   averager   lastTradeTimestampr  r  rG  rS  rC  triggerPricestopLossPricetakeProfitPricer   r   r  r   r]   rZ  r  r  rater   closedr  Fr"  r  r  postOnlyIOCPOlastUpdateTimestampr}  	stopPriceclientOrderId
reduceOnly)r   ra  r_  rV  rX  rW  rG  rS  )r  r  r  r  ri  parse_tradesrV   r  r  r  r    r  r{   r  r  
reduceFeesreduce_fees_by_currencyr6  r   r  r   r   r   
string_mul
string_divstring_equalsr_  r  r  r  ):r^   rZ  r  r~   rR  rS  r   rT  r   lastTradeTimeTimestampr  r  rG  parseFilled	parseCostparseLastTradeTimeTimestamprS  parseFee	parseFeesparseSymbol	parseSideshouldParseFeesrC  r   isTriggerOrSLTpOrder	rawTrades
firstTradetradesAreParsedtradesLengthisArrayr   rF  tradeAmount	tradeCosttradeTimestamp	tradeFeesr  tradeFeereducedFeesreducedLengthfeeCopyr  r"  filledTimesContractSizecostPriceExistsmultiplyPrice	orderType
emptyPricer  	entryFeesr  r[  r  r^  r}  rV  rX  rW  s:                                                             r`   
safe_orderzExchange.safe_order  s
     0 0 AB$$UK8	!!%2v...!1!1%!CDt//w?@!%!2!25:N!O!!%2v.!!%2~T\	'='E#ooeU+4KOOE62d:	nDL	"/i~~eVR0!%!1!1%!HPT!T  "OY]YiYijo  rA  ZB  JN  ZN  !L  UY  Ue  Ue  fk  m~  U  GK  UK)x@I
 A6J *$ 6kVz=QkX\`jXjO"**9f="L .G"6{L1,?*&,Qi&9E(O=($*1If$5E&M=($*1If$5E&M;&"()G"4E$K FDq#f+. GA"1IE"&"2"25("CK"(?!(!3!3FK!H $ 0 0 ?I i&;&11$	B"!%!1!1%!B #//v>%)__UK%HN28R195C2589OQ_5`2&$(OOE6$B	$0%*1c)n%= G+4Q< $DKKH,E FG (,ue'DH'3 $DKKH,E F7G8 @D$66t<UYK,M1m, V)-)9)9+a.&)QAv&[^+-1-=-=k!nf-UKN6*V !!3**3/"&"2"27F"CW$&*&6&6w&GGFO""7+'E&M]a/*1~e>!i&; ++FI>8#>!i&; ++FI>8#(:!f&8#..vv>	8#	..E:,,T__V^UV-WX ?")9w?P?PQWY\?]*1*<*<V\*R'%001H$OG%007NOG #$.FE4E&,/ M % '&-&8&8&N#))*A=Q))*A=QOOE62	tmI(=(=eS(I
90Eq#f+& 	$A1IE"..uh?E(O!--eW=E'N ,,UF;E&M~~eUB7H#//&AHV!#'#3#3Hf#E ufb9I1c)n- N'+'7'7	!f'M	!V$N%E&M#E%L	$ &&um<??5*5'T-=-=eV-LPX-X#""d*H%%e[9	"//7LM##E:6||I.H((););E>S^)_`++D,<,<UDU,VW))$*:*:5/*RS{{5 #
$""5$/#
T--e_E#
 #
 	#

 f#
 D$$UF3#
 D#
 !"8#
 "#6#
 T&&u-#
 d''/#
 D%%d+#
 t((1#
 d''/#
 **95#
  ;!#
" ##
$ //%>%(.*??5%03#
  	rd   ordersc                 2   g }t        |t              rSt        dt        |            D ]:  }| j	                  ||   |      }| j                  ||      }	|j                  |	       < nt        |j                               }
t        dt        |
            D ]S  }|
|   }| j                  d|i||         }| j	                  ||      }| j                  ||      }	|j                  |	       U | j                  |d      }||d   nd }| j                  ||||      S )Nr   r   r  r  )
rV   r  r  r  rX  r  r  r(  r"  filter_by_symbol_since_limit)r^   r  r  r  r  r8  resultsr   r8  rZ  r/  r   
idExtendedparsedOrderr  s                  r`   parse_orderszExchange.parse_orders  s   , fd#1c&k* &))&)V<FF3u%&
 v{{}%C1c#h' &V![[$VBZ@
"..z6BK8u%& ,,w4&,&8!t00&%OOrd   rk   r  r   c                    |dk(  r|dk(  rt        | j                  dz         | j                  |   }| j                  |dd      }	d}
|	dk(  r|dk(  }
n|	d	k(  r|d
k(  }
n|	dk(  }
| j	                  |      }d}|
r*| j	                  |      }t        j                  ||      }d}nd}|d   sd}|dk(  rd}| j                  ||      }t        j                  ||      }|||   | j                  |      | j                  |      dS )a  
        calculates the presumptive fee that would be charged for an order
        :param str symbol: unified market symbol
        :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 on most exchanges, or number of contracts
        :param float price: the price for the order to be filled at, in units of the quote currency
        :param str takerOrMaker: 'taker' or 'maker'
        :param dict params:
        :returns dict: contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order
        r  rl   z calculateFee() - you have provided incompatible arguments - "market" type order can not be "maker". Change either the "type" or the "takerOrMaker" argument to calculate the fee.feeSiderC  Nr   sellgivebuyr  rh  r  rk   )r]   rA  rY  r   )r   r   r  r  r   r    re  r  )r^   r  r]   r  r~   r   takerOrMakerr8  r  r  useQuoter   r   priceStringrY  s                  r`   calculate_feezExchange.calculate_fee  s:    8 7#DGG  /c  %c  d  df%""69g>ev~Hu}H ')H$$V,//6K%%dK8DCCf~C8"L5!!$- s%%d+%%d+	
 	
rd   liquidationc                    | j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }||||t        j                  ||      }|||t        j                  ||      }| j                  |      |d<   | j                  |      |d<   | j                  |      |d<   | j                  |      |d<   | j                  |      |d<   |S )N	contractsr"  r   	baseValue
quoteValue)r  r    re  r  )r^   r  r  r  r"  r   r  r  s           r`   safe_liquidationzExchange.safe_liquidation  s   $$[+>	''?  g6$$[+>	%%k<@
I$9@X_d_p**9lCIY%:AR ++Iu=J#'#4#4Y#?K &*&7&7&EN##007G#'#4#4Y#?K $($5$5j$AL!rd   c                    | j                  |d      }| j                  |d      }| j                  |d      }|m| j                  |d      }|}|A| j                  |dd      }|rt        j                  d|      }t        j                  ||      }t        j                  ||      }| j                  |      \  }	}
|	|d<   |
|d	<   | j                  |      |d<   | j                  |      |d<   | j                  |      |d<   |S )
Nr~   r   r   r"  r  Fr  rS  rC  )r  r   r    rf  re  parsed_fee_and_feesr  )r^   rF  r  r~   r   r   r"  r  r  	resultFee
resultFeess              r`   
safe_tradezExchange.safe_trade/  s   !!%2  0v.<++FNCL!M'..EB$+$6$6sE$BM ' 2 2=, O%%mV<D $ 8 8 ?	: e"f++F3h**51g))$/frd   	containerc                    | j                  |d      }| j                  |d      }|d u}|d u}|xs |}|r~|r| j                  |      }|s|g}| j                  r| j	                  |      n|}t        |      }t        d|      D ]  }	| j                  ||	         ||	<    |}|dk(  r|d   }n|dk(  rd }|d d d}|g }||gS )NrS  rC  r   r   )r   rA  )r_  ri  parse_fee_numericrc  rd  r  r  )
r^   r  rS  rC  
feeDefinedfeesDefinedrp  r|  r}  r   s
             r`   r  zExchange.parsed_fee_and_feesE  s    nnY.~~i0_
$&%4,,S1u@D$66t<UYK,M1m, H!%!7!7A!GAHD!!!n!#; C <DT{rd   rS  c                 b    | j                  |d      |d<   d|v r| j                  |d      |d<   |S )Nr   rY  )r6  )r^   rS  s     r`   r  zExchange.parse_fee_numericf  s:    &&sF3FS=**37CK
rd   r7  providedValuec                 f    t        |      }t        d|      D ]  }||   }||k  s|c S  ||dz
     S )Nr   r   )r  r  )r^   r7  r  r  r   currents         r`   find_nearest_ceilingzExchange.find_nearest_ceilingl  sG    Sq&! 	A!fG'	 6A:rd   c                     i }t        |j                               }t        dt        |            D ]"  }||   }||   }t	        |t
              s|||<   $ |S r  )r  r(  r  r  rV   r"  )r^   r   reversedr(  r   r   r  s          r`   r  z&Exchange.invert_flat_string_dictionaryu  s]    DIIK q#d)$ 	&Aq'CIE%%"%		&
 rd   c                 L   i }t        dt        |            D ]  }||   }| j                  |d      }t        |      }|(| j                  |d      }| j                  |d      }|O||vri ||<   |dn|}	|	||   v r)t	        j
                  ||   |	   d   |      ||   |	   d<   ||d||   |	<   ||||   |	   d<    g }
t        |j                               }t        dt        |            D ]0  }t        ||   j                               }| j                  |
|      }
2 |
S )Nr   rA  rY  r   rx   )rA  r   )	r  r  r  r"  r    r  r  r  r)  )r^   rC  reducedr   rS  r,  feeCurrencyCoderY  r   rateKeyr  	feeValuesreducedFeeValuess                r`   rd  z Exchange.reduce_fees_by_currency  s~   \ q#d)$ 	IAq'C##C4D<?FO*''V4''V4<'72/1GO,!%"Dgo66@G@R@RSZ[jSklsStu{S|  C  ADGO,W5f= %) $9GO,W5 'DH09&A+	I, )*	q#i.) 	AA#IaL$7$7$9:&&v/?@F	A rd   c                    | j                  | j                  |d            }| j                  | j                  |d            }| j                  | j                  |d            }| j                  | j                  |d            }| j                  | j                  |d            }| j                  | j                  |d            }| j                  |d      }	| j                  |d      }
| j                  |d	      }|	%t        j                  | j                  |      |
      }	|||}n|||}|||t        j                  ||      }|vd
}|G| j                         r7| j                  |d      }| j                  |d      }|| j                  |      }t        j                  t        j                  ||      d|      }|D|B|@t        j                  |d      r*t        j                  t        j                  ||      d      }|.|,|*t        j                  t        j                  ||      d      }|||t        j                  ||      }| j                  |i d| j                  | j                  | j                  |d                  d| j                  |d      d| j                  | j                  | j                  |d                  d| j                  |d      d| j                  | j                  | j                  |d                  d| j                  | j                  | j                  |d                  d| j                  | j                  |            d| j                  | j                  |            d| j                  | j                  |            d| j                  |      d| j                  |      d| j                  |      d| j                  |	      d| j                  |
      d	| j                  |      d| j                  |d      d| j                  |d      d| j                  |d      i      S )Nopenr   r  changerj   rT  r  r  r     r   r   2r  100bid	bidVolumeask	askVolumehighlowpreviousClose
indexPrice	markPrice)r  r  r    rf  r  is_tick_precisionr_  r  r  r   re  r  r  r6  )r^   r>  r  r  r   r  r  rj   rT  r  r  r  r   r8  precisionPrices                  r`   safe_tickerzExchange.safe_ticker  sp   ~~d..vv>?t//@A~~d..vv>? 0 0 BC^^D$4$4V\$JK
..!1!1&)!DE/%%fl;
&&v}=<%%dnn[&A:ND5=El!2D4#3~ ++D$7	%$*@*@*B&*nnV[&IO%)%5%5ow%ON%1$($>$>~$N	!,,W-?-?d-KSR[\V%7d>NT[TeTefjloTp ++G,>,>vt,LeTJN!7d>N''(:(::t(LeTFLt/f6H%%dF3D {{6 $
4$$T^^D4D4DVU4S%TU$
))&+>$
 4$$T^^D4D4DVU4S%TU$
 ))&+>	$

 D%%dnnT5E5Eff5U&VW$
 4$$T^^D4D4DVU4S%TU$
 D%%dnnT&:;$
 T&&t~~e'<=$
 D%%dnnT&:;$
 d''/$
 $++J7$
 t((1$
 D%%d+$
 $++J7$
 4,,[9$
  T--foF!$
" $**6<@#$
$ ))&+>%$
  	rd   c                 2    t        | j                  dz         )Nzb fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate insteadrp  r^   r,  r~   r8  s       r`   fetch_borrow_ratezExchange.fetch_borrow_rate  s#    477  &J  J  K  	Krd   c                 2    t        | j                  dz         )Nz$ repayCrossMargin is not support yetrp  r  s       r`   repay_cross_marginzExchange.repay_cross_margin  rR  rd   c                 2    t        | j                  dz         )Nz' repayIsolatedMargin is not support yetrp  r^   r  r,  r~   r8  s        r`   repay_isolated_marginzExchange.repay_isolated_margin	  r  rd   c                 2    t        | j                  dz         )Nz% borrowCrossMargin is not support yetrp  r  s       r`   borrow_cross_marginzExchange.borrow_cross_margin  r  rd   c                 2    t        | j                  dz         )Nz( borrowIsolatedMargin is not support yetrp  r  s        r`   borrow_isolated_marginzExchange.borrow_isolated_margin  r  rd   c                 2    t        | j                  dz         )NzY borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin insteadrp  r^   r,  r~   r  r8  s        r`   borrow_marginzExchange.borrow_margin  s#    477  &A  A  B  	Brd   c                 2    t        | j                  dz         )NzV repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin insteadrp  r  s        r`   repay_marginzExchange.repay_margin  s    477%}}~~rd   1mc                 ^    d}| j                   d   rd}t        | j                  dz   |z         )Nrx   r  . If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see "build-ohlcv-bars" filez" fetchOHLCV() is not supported yetr  r   r   r^   r  r  r  r  r8  r  s          r`   fetch_ohlcvzExchange.fetch_ohlcv  s5    88M" rG477%IIGSTTrd   c                 ^    d}| j                   d   rd}t        | j                  dz   |z         )Nrx   r  r  zC fetchOHLCVWs() is not supported yet. Try using fetchOHLCV instead.r  r  s          r`   fetch_ohlcv_wszExchange.fetch_ohlcv_ws  s6    88O$ rG477%jjmttuurd   c                 2    t        | j                  dz         )Nz" watchOHLCV() is not supported yetrp  r  s         r`   watch_ohlcvzExchange.watch_ohlcv$  rJ  rd   r   c	                 8   g }	| j                  ||g       }
| j                  ||g       }| j                  ||g       }| j                  ||g       }| j                  ||g       }| j                  ||g       }t        dt        |
            D ]  }|	j                  |r| j	                  |
|      n| j                  |
|      | j                  ||      | j                  ||      | j                  ||      | j                  ||      | j                  ||      g        |	S r  )ri  r  r  r  r  r  r  )r^   r   r  r  r  r  r   rk  r  r  
timestampsopenshighslowsclosesvolumesr   s                    r`   convert_trading_view_to_ohlcvz&Exchange.convert_trading_view_to_ohlcv'  s   ^^FIr:
vtR0vtR0~~fc2.r2..4q#j/* 	AMM46!!*a0D<O<OPZ\]<^q)q)a(*+ 	 rd   c	                    i }	g |	|<   g |	|<   g |	|<   g |	|<   g |	|<   g |	|<   t        dt        |            D ]  }
|r||
   d   n| j                  ||
   d   dz        }|	|   }|j                  |       |	|   }|j                  ||
   d          |	|   }|j                  ||
   d          |	|   }|j                  ||
   d          |	|   }|j                  ||
   d          |	|   }|j                  ||
   d           |	S )Nr   rB  r   r  r  r     )r  r  rW  r  )r^   r   r  r  r  r  r   rk  r  r  r   r  resultTimestamp
resultOpen
resultHigh	resultLowresultCloseresultVolumes                     r`   convert_ohlcv_to_trading_viewz&Exchange.convert_ohlcv_to_trading_view:  s;   yttsuvq#f+& 	.A!#1):):6!9Q<$;N)OB$Y/O""2&JfQil+JfQil+sIVAYq\* -Kvay|,!&>Lq	!-	. rd   c                    d}| j                  | j                  |i       }| j                  |dd      }	 | j                  |dd      dury | j                  |dd      }	d }
d}d}||	k  r	  t        | |      i       }
d}	 |
}||j                  |      }|d	   }||j                  |      }|d   }|r>t        |t              r.| j                  |j                               }|r|S t        d
      |S # t        $ r}|d	z   }||	k(  r|Y d }~nd }~ww xY w|r||	k  r# t        $ r}| j                  dz   |z   dz   }Y d }~nd }~ww xY w|ry t        |      )Nrx   webApiMuteFailureTwebApiEnablewebApiRetriesr  r   Fr   z&could not parse the response into jsonrH  zx() failed to fetch correct data from website. Probably webpage markup has been changed, breaking the page custom parser.)r  r   r   r   rW   r   rV   r"  rZ  r+  r   r   )r^   r/  endpointMethodreturnAsJson
startRegexendRegexerrorMessager   muteOnFailurer#  r  retryshouldBreakr   rh  splitted_by_startsplitted_by_endjsoneds                     r`   fetch_web_endpointzExchange.fetch_web_endpointR  s   //$,,;w0CTJ#	o~~g~t<DH/2FJHEK*$ <wt^<R@H"&K G%$+MM*$=!+A.#")--"9)!,GS!99!M%&NOO) !  !AIE
* +   *$4  	o77S=61  5o  oL	ol++sN   D 
D )C2 =A'D %D 2	D;DD DD 	E'EEc                     ||S g }t        dt        |            D ]%  }|j                  | j                  ||                ' |S r  )r  r  r  	market_idr^   r  r  r   s       r`   
market_idszExchange.market_ids  sI    ?Nq#g,' 	6AMM$..45	6rd   c                     ||S g }t        dt        |            D ]%  }|j                  | j                  ||                ' |S r  )r  r  r  currency_idr^   r  r  r   s       r`   currency_idszExchange.currency_ids  sK    =Lq#e*% 	6AMM$**5845	6rd   c                     ||S g }t        dt        |            D ]%  }|j                  | j                  ||                ' |S r  )r  r  r  r  r  s       r`   markets_for_symbolszExchange.markets_for_symbols  sI    ?Nq#g,' 	3AMM$++gaj12	3rd   c                 l   ||st        | j                  dz         |S t        |      }|dk(  r|st        | j                  dz         |S g }d }d }	t        dt        |            D ]  }
| j	                  ||
         }|r1|/|d   |k7  r't        | j                  dz   |z   dz   |d   z   dz         |r"|	 |d   |	k7  rt        | j                  dz         |&|d   |k7  rt        | j                  d	z   |z   d
z         |d   }|d   s|d   }	| j                  |d||
         }|j                  |        |S )Nz' empty list of symbols is not supportedr   r]   z* symbols must be of the same type, either z or r  r  z? symbols must be of the same subType, either linear or inverse.z" symbols must be of the same type zT. If the type is incorrect you can change it in options or the params of the requestrh  r  )r   r   r  r  r  r   r  r  )r^   r  r]   
allowEmptysameTypeOnlysameSubTypeOnlysymbolsLengthr  r  isLinearSubTyper   r  r  s                r`   market_symbolszExchange.market_symbols  s   ?'2[([\\NGA'2[([\\N
q#g,' 	"A[[,F!7&>Z/$TWW/[%[^h%hkq%qtz  |B  uC  &C  FI  &I  J  JO$?(#6$TWW/p%pqqF6Nd$: +O!ORV!V  Zp  "p  q  qJ&>"("2%%fh
CFMM&!	" rd   c                     ||S g }t        dt        |            D ]%  }|j                  | j                  ||                ' |S r  )r  r  r  common_currency_coder  s       r`   market_codeszExchange.market_codes  sK    =Lq#e*% 	?AMM$33E!H=>	?rd   c           	          | j                  |      }g }t        dt        |            D ](  }|j                  | j	                  ||   |||             * |S r  )r	  r  r  r  ry  )r^   rj  ru  rv  rw  r  r   s          r`   parse_bids_askszExchange.parse_bids_asks  sW    --(q#g,' 	]AMM$,,WQZ9l[\	]rd   c           
          | j                  |||      }| j                  || j                  | j                  |d         d      | j                  | j                  |d         dd      d      S )Nasksr   bidsT)r  r  )r  r  r"  rl  )r^   r  r  r8  rl  s        r`   fetch_l2_order_bookzExchange.fetch_l2_order_book  sh    ))&%@	{{9LL	&0A!BAFLL	&0A!BAtL'
  	rd   c                     ||S g }t        dt        |            D ]1  }| j                  ||   d      }||k(  s|j                  ||          3 |S Nr   r  )r  r  r  r  )r^   objectsr  r  r   objectSymbols         r`   filter_by_symbolzExchange.filter_by_symbol  s`    >Nq#g,' 	*A++GAJALv%gaj)	* rd   c           	          t        |t              rh| j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS |S )Nr   r   r  r  r  r  )rV   r  r  r6  rt  s      r`   rs  zExchange.parse_ohlcv  s}    eT"!!%+  *  *  *  *  *  rd   networkCodecurrencyCodec                    |y| j                  | j                  di       }| j                  ||      }|R|}t        | j                  j                               }t        dt        |            D ]A  }||   }| j                  |d      }| j                  ||      }	| j                  |	d      }|A n n| j                  | j                  di       }
||
v r\|
|   }t        |j                               }t        dt        |            D ]%  }||   }||   }||k(  s| j                  ||      } nT nR| j                  | j                  |      }| j                  |d      }| j                  ||      }	| j                  |	d      }||}|S )a/  
 @ignore
        tries to convert the provided networkCode(which is expected to be an unified network code) to a network id. In order to achieve self, derived class needs to have 'options->networks' defined.
        :param str networkCode: unified network code
        :param str currencyCode: unified currency code, but self argument is not required by default, unless there is an exchange(like huobi) that needs an override of the method to be able to pass currencyCode argument additionally
        :returns str|None: exchange-specific network id
        Nr  r   r   r  )
r  r   r  r  r   r  r  r  r_  r(  )r^   r!  r"  networkIdsByCodes	networkIdr   r   rA  r  r  r  replacementObjectr(  r   r  s                  r`   network_code_to_idzExchange.network_code_to_id  s     OODLL*bI$$%6D	#!$//"8"8":;
q#j/2 A)!}H#~~h
CH"nnX{CG $ 0 0$ ?I , 26Ooqs1t.#AA(F|(T% 1 6 6 89D"1c$i0 ""1g 1# 6 K/(,(8(89JC(PI!"  $~~doo|LH#~~h
CH"nnX{CG $ 0 0$ ?I '	rd   r%  c                     |y| j                  | j                  di       }| j                  |||      }|G| j                  | j                  di       }||v r&| j                  ||i       }| j                  |||      }|S )aM  
 @ignore
        tries to convert the provided exchange-specific networkId to an unified network Code. In order to achieve self, derived class needs to have "options['networksById']" defined.
        :param str networkId: exchange specific network id/title, like: TRON, Trc-20, usdt-erc20, etc
        :param str|None currencyCode: unified currency code, but self argument is not required by default, unless there is an exchange(like huobi) that needs an override of the method to be able to pass currencyCode argument additionally
        :returns str|None: unified network code
        Nr  r  r_  r   r  )r^   r%  r"  networkCodesByIdsr!  r  r&  s          r`   network_id_to_codezExchange.network_id_to_code  s      NN4<<L&&'8)YO#-1^^DLLJjln-o*==$(NN3QS_ac$d!"../@+{[rd   c                 \    | j                  |dd      }|| j                  |ddg      }||gS )Nr!  r  r  r^  )r^   r8  networkCodeInParamss      r`   handle_network_code_and_paramsz'Exchange.handle_network_code_and_params%  s=    "00	R*YYvy'ABF#V,,rd   c                     d }| j                  | j                  di       }||v r||   }|S | j                  | j                  d      }||}|S )NdefaultNetworksdefaultNetworkr)  )r^   r"  defaultNetworkCoder1  r2  s        r`   default_network_codezExchange.default_network_code,  se    !..7H"M?*!0!> "! "--dll<LMN)%3"!!rd   c                 *    | j                  |||d      S r   select_network_key_from_networksr^   r"  r!  indexedNetworkEntriess       r`   )select_network_code_from_unified_networksz2Exchange.select_network_code_from_unified_networks9  s    44\;Pegkllrd   c                 *    | j                  |||d      S r  r6  r8  s       r`   #select_network_id_from_raw_networksz,Exchange.select_network_id_from_raw_networks<  s    44\;Peglmmrd   c                 4   d }t        |j                               }t        |      }|z|dk(  r!t        | j                  dz   |z   dz   |z         |r|n| j                  ||      }||v r|}|S t        | j                  dz   |z   dz   |z   dz   dj                  |      z         |dk(  rt        | j                  dz   |z         | j                  |      }	|r|	n| j                  |	|      }
|
|v r|
S t        | j                  dz   dj                  |      z         )	Nr   z - z' network did not return any result for z network was not found for z, use one of , z! - no networks were returned for zR - can not determine the default network, please pass param["network"] one from : )r  r(  r  r   r   r'  r   r4  )r^   r"  r!  r9  isIndexedByUnifiedNetworkCodechosenNetworkIdavailableNetworkIdsresponseNetworksLengthr%  r3  defaultNetworkIds              r`   r7  z)Exchange.select_network_key_from_networks?  s   "#8#=#=#?@!$%8!9"%*"477U?[#@Cl#lo{#{|| ,IKdNeNefqs  OA	 55&/O  'tww'BEb'beq'q  uD  (D  GK  GP  GP  Qd  Ge  (e  f  f%*"477-P#PS_#_`` &*%>%>|%L"9V#5\`\s\s  uG  IU  ]V #'<<++"477  .B  $B  EI  EN  EN  Ob  Ec  $c  d  drd   r  c                 L    | j                  |||      }| j                  ||      S r   )r  r  )r^   r  r  r  r]  r  s         r`   safe_number_2zExchange.safe_number_2Z  s)    "":tT:  **rd   rl  c	                    | j                  | j                  ||g       |||      }	| j                  | j                  ||g       |||      }
|| j                  |	dd      | j                  |
d      || j                  |      d dS )Nr   T)r  r  r  r  r}  r  )r  r  r"  r  )r^   rl  r  r  bidsKeyasksKeyru  rv  rw  r  r  s              r`   parse_order_bookzExchange.parse_order_book^  s    ##DOOIw$KXW`bno##DOOIw$KXW`bnoLLq$/LLq)"Y/
 	
rd   r  c                     g }t        dt        |            D ]&  }|j                  | j                  ||   |             ( | j	                  |d      }	| j                  |	||d|      S r  )r  r  r  rs  r"  r  )
r^   r   r  r  r  r  r  r  r   r  s
             r`   parse_ohlcvszExchange.parse_ohlcvsj  si    q#f+& 	@ANN4++F1Iv>?	@gq)))&%4HHrd   r  c                    | j                  |      }i }d}|t        |      }|d u xs |dk(  }t        |t              rt	        dt        |            D ]r  }||   }| j                  ||      }	| j                  |	d d d      }
|
d   }| j                  |
dd      }|sI|s| j                  ||      s^| j                  ||
      ||<   t |S t        |j                               }t	        dt        |            D ]e  }||   }||   }| j                  |d d d      }
|
d   }| j                  |
dd      }|s<|s| j                  ||      sQ| j                  ||
      ||<   g |S )Nr   rj  r  r!  F)r  r  rV   r  r  r  safe_marketr   r-  r_  r(  )r^   r  r  marketIdKeytiersr  	noSymbolsr   rS  r   r  r  r!  r(  marketIds                  r`   parse_leverage_tierszExchange.parse_leverage_tiersq  s   %%g.LM_=-1*<	h%1c(m, S{%%dK8))"dD&A)>>&*eDdmmFG.L$($D$DT6$RE&MS$  (D1c$i( S7)))(D$G)>>&*eDdmmFG.L$($D$DT6$RE&MS rd   c                 P   | j                   d   r|sd| j                  vr|| j                  |      }t        dt	        |            D ]6  }||   }| j                  | j                  |   ||         | j                  |<   8 | j                         | j                  d<   | j                  S )Nr  limitsLoadedr   )r  r   r0  r  r  r   r  r  )r^   r  r  r8  r  r   r  s          r`   load_trading_limitszExchange.load_trading_limits  s    88()n<44W=q#g,/ dA$QZF+/+;+;DLL<PRZ[aRb+cDLL(d 04/@/@/B^,||rd   c                    | j                  |d      }| j                  |d      }| j                  |d      }|C|A|?t        j                  t        j                  ||d      d      }| j                  |      |d<   | j                  |d      }| j                  |d      }d }|| j                  | j                  |      }||| j                  |d      }||d<   |S )NunrealisedPnlinitialMarginrj   r  r  r"  r  )r  r  r    re  rf  r  r6  r  )	r^   rb  unrealizedPnlStringinitialMarginStringrj   percentageStringr"  r  r  s	            r`   safe_positionzExchange.safe_position  s    "..xI"..xI __X|<
%8%DK^Kj&11'2D2DEXZmop2qsxy%)%6%67G%HH\"''.A!!(H5__T\\6:FF$6++FNCL'3H^$rd   	positionsc                    | j                  |      }| j                  |      }g }t        dt        |            D ]8  }| j	                  | j                  ||   d       |      }|j                  |       : | j                  |d|d      S )Nr   r  F)r  r	  r  r  r  rd  r  filter_by_array_positions)r^   r]  r  r8  r  r   rb  s          r`   parse_positionszExchange.parse_positions  s    %%g.MM),	q#i.) 	$A{{4#6#6y|T#JFSHMM(#	$ --fhOOrd   accountsc                     | j                  |      }g }t        dt        |            D ]7  }| j                  | j	                  ||         |      }|j                  |       9 |S r  )r	  r  r  r  rQ  r  )r^   ra  r8  r  r   r8   s         r`   parse_accountszExchange.parse_accounts  sa    ==*q#h-( 	#Akk$"4"4Xa["A6JGMM'"	# rd   r   c                 (   | j                  |      }g }t        dt        |            D ]8  }| j                  | j	                  ||   |      |      }|j                  |       : | j                  |dd      }||d   nd }	| j                  ||	||      S )Nr   r  r   r  )r	  r  r  r  rI  r  r%  r  )
r^   r   r  r  r  r8  r  r   rF  r  s
             r`   rb  zExchange.parse_trades  s    v&q#f+& 	!AKK 0 0F CVLEMM% 	! T:&,&8!t00NNrd   r   c                 &   | j                  |      }g }t        dt        |            D ]8  }| j                  | j	                  ||   |      |      }|j                  |       : | j                  |d      }||d   nd }	| j                  ||	||      S Nr   r  r,  )r	  r  r  r  rM  r  r"  filter_by_currency_since_limit)
r^   r   rA  r  r  r8  r  r   rK  r,  s
             r`   parse_transactionszExchange.parse_transactions  s    }}\2q#l+, 	'A++d&<&<\!_h&WY_`KMM+&	' fk2$,$8xt2264NNrd   	transfersc                 &   | j                  |      }g }t        dt        |            D ]8  }| j                  | j	                  ||   |      |      }|j                  |       : | j                  |d      }||d   nd }	| j                  ||	||      S rf  )r	  r  r  r  rO  r  r"  rg  )
r^   ri  rA  r  r  r8  r  r   r(  r,  s
             r`   parse_transferszExchange.parse_transfers  s    MM),	q#i.) 	$A{{4#6#6y|X#NPVWHMM(#	$ fk2$,$8xt2264NNrd   c                    g }| j                  |      }t        dt        |            D ]  }| j                  ||   |      }	t	        |	t
              r?t        dt        |	            D ]&  }
|j                  | j                  |	|
   |             ( g|j                  | j                  |	|              | j                  |d      }||d   nd }| j                  ||||      S rf  )
r	  r  r  rU  rV   r  r  r  r"  rg  )r^   rC  rA  r  r  r8  r  	arrayDatar   itemOrItemsr  r,  s               r`   parse_ledgerzExchange.parse_ledger  s    MM$'	q#i.) 	@A11)A,IK+t,q#k"23 GAMM$++k!nf"EFG dkk+v>?	@ fk2$,$8xt2264NNrd   c                 "    | j                         S r   )rn  r   s    r`   r  zExchange.nonce  s    ||~rd   c                     |S r   r   )r^   r   s     r`   r#  zExchange.set_headers  s    rd   c                 r    | j                  | j                  |      }|| j                  |      }||d   S |S Nr   )r_  r   r  )r^   r,  rA  s      r`   r  zExchange.currency_id  sA    >>$//48))$/HD>!rd   c                 6    | j                  |      }||d   S |S rs  )r  r^   r  r  s      r`   r  zExchange.market_id  s%    V$$<rd   c                 J    | j                  |      }| j                  |d|      S Nr  )r  r  ru  s      r`   r  zExchange.symbol   s%    V$&99rd   r8  	paramNamec                 X    | j                  |||      }|| j                  ||      }||gS r   )r  r^  r^   r8  rx  r  r  s        r`   handle_param_stringzExchange.handle_param_string  s6      LAYYvy1Fvrd   
paramName1
paramName2c                 ^    | j                  ||||      }|| j                  |||g      }||gS r   r-  r^   r8  r|  r}  r  r  s         r`   handle_param_string_2zExchange.handle_param_string_2
  s=    ""6:z<PYYv
J'?@Fvrd   c                 X    | j                  |||      }|| j                  ||      }||gS r   )r  r^  rz  s        r`   handle_param_integerzExchange.handle_param_integer  s6    !!&)\BYYvy1Fvrd   c                 ^    | j                  ||||      }|| j                  |||g      }||gS r   )r  r^  r  s         r`   handle_param_integer_2zExchange.handle_param_integer_2  s=    ##FJ
LQYYv
J'?@Fvrd   c                 X    | j                  |||      }|| j                  ||      }||gS r   )r   r^  rz  s        r`   handle_param_boolzExchange.handle_param_bool  s4    vy,?YYvy1Fvrd   c                 ^    | j                  ||||      }|| j                  |||g      }||gS r   rU  r^  r  s         r`   handle_param_bool_2zExchange.handle_param_bool_2"  s=      ZNYYv
J'?@Fvrd   rW  exchangeSpecificKey
isRequiredc                     d}| j                  |      \  }}|| j                  ||      ||<   ||gS |rt        | j                  dz         ||gS )a   
        :param dict params: - extra parameters
        :param dict request: - existing dictionary of request
        :param str exchangeSpecificKey: - the key for chain id to be set in request
        :param dict currencyCode: - (optional) existing dictionary of request
        :param boolean isRequired: - (optional) whether that param is required to be present
        :returns dict[]: - returns [request, params] where request is the modified request object and params is the modified params object
        Nz/ - "network" param is required for self request)r/  r'  r   r   )r^   r8  rW  r  r"  r  r!  s          r`   handle_request_networkzExchange.handle_request_network(  so     "AA&IV"+/+B+B;P\+]G'(    #DGG._$_``  rd   c                 h    | j                  ||      | j                  || j                  |            gS r   )r9  r^  r4  )r^   r  r8  s      r`   resolve_pathzExchange.resolve_path9  s5    f-IIfd11$78
 	
rd   c                     |}t        |t              s| j                  |      }g }t        dt	        |            D ]  }|j                  ||   |           |S r  )rV   r  r	  r  r  r  )r^   r  r   newArrayr  r   s         r`   get_list_from_object_valuesz$Exchange.get_list_from_object_values?  sX    '4(}}W-Hq#h-( 	-ANN8A;s+,	-rd   symbolWithActiveStatussymbolWithUnknownStatusc                 6   | j                   }|| j                  |d|      }|)| j                  d|dg d       | j                  |d|      }g }|r|j                  d       |r|j                  d        | j	                  |d|d      }| j                  |d      S )	Nr]   getSymbolsForMarketTyper  )r  r  quantoTr  Fr  )r  r  check_required_argumentr  filter_by_arrayr  )r^   r  r  r  r  filteredMarketsactiveStatusess          r`   get_symbols_for_market_typez$Exchange.get_symbols_for_market_typeH  s    ,,!"nn_fjQO(()BGYXwx"nn_iQO!!!$'"!!$'...Z_`//JJrd   c                    | j                  |      }||s|r| j                  ||      S |S g }t        dt        |            D ]/  }| j	                  ||   |   |      s|j                  ||          1 |r| j                  ||      S |S r  )r	  r  r  r  r-  r  )r^   r  r   r  indexedr  r   s          r`   r  zExchange.filter_by_arrayW  s    --(>}}Wc22q#g,' 	+A}}WQZ_f5wqz*	+ ==#..rd   c           	         | j                   r&| j                  |||||      }| j                  |       | j                         | _        | j                  ||||||      }	|	d   | _        |	d   | _        |	d   | _        d }
| j                  ||dd      \  }
}d }| j                  ||dd      \  }}t        d|
dz         D ]$  }	 | j                  |	d   |	d   |	d   |	d         c S  y # t        $ r}t        |t              rm||
k  rf| j                  rA| j!                  d	t#        |      z   d
z   |t#        d      z   z   dz   t#        |
      z   dz          ||dk7  r| j%                  |       n||Y d }~d }~ww xY w)Nr   rk  r.  maxRetriesOnFailurer   maxRetriesOnFailureDelayr   r/  zRequest failed with the error: z, retrying z of z...)r`  calculate_rate_limiter_costr  r  r  r  last_request_headerslast_request_bodylast_request_urlhandle_option_and_paramsr  rw  rW   rV   r   rR  r(  r"  r  )r^   r  r@  r/  r8  r   rk  r   r   rW  retries
retryDelayr   r   s                 r`   fetch2zExchange.fetch2i  s   33CvvVDMM$(,(9(9(;%))D#vvwE$+I$6!!( '77F[]^_
!::64Icefg
Fq'A+& 	Azz'%.'(2CWYEWY`agYhii	   
a17{<< HH%FQ%OR_%_cdgjklgmcm%nqw%wz}  F  {G  &G  JO  &O  P&2q JJz2G
s   C%%	E7.A?E22E7c           	      0    | j                  |||||||      S r   )r  )r^   r  r@  r/  r8  r   rk  r   s           r`   rW  zExchange.request  s    {{4ffgtVLLrd   c                     |r| j                  |      | _        n.| j                  r| j                  S | j                  |      | _        | j                  | j                  d      | _        | j                  S rs  )r  ra  r  accountsById)r^   r  r8  s      r`   load_accountszExchange.load_accounts  s[     //7DM}}}}$ $ 3 3F ; MM$-->}}rd   c           
         | j                  |      dz  }g }d}d}d}	d}
d}d}t        |      }t        ||      }t        d|      D ]  }||   }|d   }||k  rt	        t        j                  ||z              |z  }||k  r>t        |      }|d	z
  }|d
k(  s|| j                  ||   |   |      k\  r(|j                  ||d   |d   |d   |d   |d   d	g       t        ||   |   |d         ||   |<   t        ||   |	   |d         ||   |	<   |d   ||   |
<   | j                  ||   |   |d         ||   |<   | j                  ||   |   d	      ||   |<    |S )NrB  r   r  r  r  r  r  r  r   r   r   r~   )
r  r  rz   r  r  r  floorrf  r  r{   )r^   r   r  r  r  r  r   i_timestampi_highi_lowi_closei_volumei_countru  oldestr   rF  r  openingTimeohlcv_lengthcandles                        r`   build_ohlcvczExchange.build_ohlcvc  s    !!),t36{\5)q&! 	OA1IE{#BEzdjjb12R7KU"v;L!A%F"+&.:UWY1Z"Z'N'N'N'N(O  *-VF^F-CU7^)Tvv&(+F6N5,A5>(Rvu%*/.vw'+/88F6N84LeT\o+^vx(*.((6&>'3JA*Nvw'7	O8 rd   c                 N    | j                  |      }| j                  |||||      S r   )r  rK  )r^   r   r  r  r  r  r  s          r`   parse_trading_view_ohlcvz!Exchange.parse_trading_view_ohlcv  s+    33F;  E5IIrd   r   c                 .    | j                  ||d|||      S )Nr  edit_limit_orderr^   r   r  r~   r   r8  s         r`   edit_limit_buy_orderzExchange.edit_limit_buy_order  s    $$RvNNrd   c                 .    | j                  ||d|||      S )Nr  r  r  s         r`   edit_limit_sell_orderzExchange.edit_limit_sell_order  s    $$ROOrd   c           	      0    | j                  ||d||||      S Nr  )
edit_order)r^   r   r  r  r~   r   r8  s          r`   r  zExchange.edit_limit_order  s    r67D&%PPrd   c                 R    | j                  ||       | j                  ||||||      S r   )cancel_ordercreate_orderr^   r   r  r]   r  r~   r   r8  s           r`   r  zExchange.edit_order  s-    "f%  tVUFKKrd   c                 R    | j                  ||       | j                  ||||||      S r   )cancel_order_wscreate_order_wsr  s           r`   edit_order_wszExchange.edit_order_ws  s-    R(##FD$vNNrd   c                 2    t        | j                  dz         )Nz% fetchPosition() is not supported yetrp  r  s      r`   fetch_positionzExchange.fetch_position  r  rd   c                 2    t        | j                  dz         )Nz' fetchPositionWs() is not supported yetrp  r  s      r`   fetch_position_wszExchange.fetch_position_ws  r  rd   c                 2    t        | j                  dz         )Nz% watchPosition() is not supported yetrp  r  s      r`   watch_positionzExchange.watch_position  r  rd   c                 2    t        | j                  dz         )Nz& watchPositions() is not supported yetrp  r  s        r`   watch_positionszExchange.watch_positions  r  rd   c                 *    | j                  ||||      S r   )r  r  s        r`   watch_position_for_symbolsz#Exchange.watch_position_for_symbols  s    ##GUE6BBrd   c                 2    t        | j                  dz         a_  
        fetches all open positions for specific symbol, unlike fetchPositions(which is designed to work with multiple symbols) so self method might be preffered for one-market position, because of less rate-limit consumption and speed
        :param str symbol: unified market symbol
        :param dict params: extra parameters specific to the endpoint
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>` with maximum 3 items - possible one position for "one-way" mode, and possible two positions(long & short) for "two-way"(a.k.a. hedge) mode
        z/ fetchPositionsForSymbol() is not supported yetrp  r  s      r`   fetch_positions_for_symbolz#Exchange.fetch_positions_for_symbol       477%VVWWrd   c                 2    t        | j                  dz         r  rp  r  s      r`   fetch_positions_for_symbol_wsz&Exchange.fetch_positions_for_symbol_ws  r  rd   c                 2    t        | j                  dz         Nz& fetchPositions() is not supported yetrp  r  s      r`   fetch_positionszExchange.fetch_positions  r  rd   c                 2    t        | j                  dz         r  rp  r  s      r`   fetch_positions_wszExchange.fetch_positions_ws  r  rd   c                 2    t        | j                  dz         )Nz* fetchPositionsRisk() is not supported yetrp  r  s      r`   fetch_positions_riskzExchange.fetch_positions_risk  r1  rd   c                 2    t        | j                  dz         )Nz% fetchBidsAsks() is not supported yetrp  r  s      r`   fetch_bids_askszExchange.fetch_bids_asks  r  rd   c                 2    t        | j                  dz         )Nz+ fetchBorrowInterest() is not supported yetrp  )r^   r,  r  r  r  r8  s         r`   fetch_borrow_interestzExchange.fetch_borrow_interest  rE  rd   c                 2    t        | j                  dz         )Nz# fetchLedger() is not supported yetrp  r^   r,  r  r  r8  s        r`   fetch_ledgerzExchange.fetch_ledger  r  rd   c                 2    t        | j                  dz         )Nz( fetchLedgerEntry() is not supported yetrp  r^   r   r,  r8  s       r`   fetch_ledger_entryzExchange.fetch_ledger_entry  r  rd   c                     | j                  ||      }| j                  ||      }| j                  ||      }||g}||j                  |       |S r   )r6  r  r  )	r^   bidaskru  rv  rw  r   r~   	countOrIdr{  s	            r`   ry  zExchange.parse_bid_ask  sX      2!!&)4%%fl;	 MM)$rd   
currencyIdc                     |||S | j                   ,|| j                   v r| j                   |   | j                   |   S |}|| j                  |j                               }| j                  ||d d      S )N)r   r,  r   )r2  r  r  r  )r^   r  rA  r,  s       r`   r  zExchange.safe_currency  s    X%9O!!-J$BWBW4W^b^s^st~^  _L((44!,,Z-=-=-?@D++-
  	rd   rQ  	delimiterc                    | j                  ||d      }|#| j                  || j                  v rt| j                  |   }t        |      }|dk(  r|d   S |%|t        | j                  dz   |z   dz         |d   }t        dt        |            D ]  }||   }	|	|   s|	c S  n||dk7  r|j                  |      }
t        |
      }|dk(  rk| j                  |
d      |d	<   | j                  |
d      |d
<   | j                  |d	         |d<   | j                  |d
         |d<   |d   dz   |d   z   |d<   |S |S ||S |S )N)r  rQ  r   r   z- safeMarket() requires a fourth argument for zB to disambiguate between different markets with the same market idr]   rx   r  r  r  r  rC  /r  )	r+  r  r  r   r   r  r   r  safe_currency_code)r^   rQ  r  r  r  r  r  
numMarketsr   currentMarketr   partsLengths               r`   rM  zExchange.safe_market"  s   ++ -
  "".XASAS5S,,X6 \
?"1:%!)!>"3DGG>m4mpx4x  |@  5@  #A  A)/J"1c'l3 1(/
(4#001 &9? y1!%j!#'+'7'7q'AF8$(,(8(8(BF9%%)%<%<VH=M%NF6N&*&=&=fY>O&PF7O'-f~';fWo'MF8$!M!MMrd   c                    t        | j                  j                               }t        dt	        |            D ]E  }||   }| j                  |   st        | |      r%|rt        | j                  dz   |z   dz          y y)z
 @ignore
        :param boolean error: raise an error that a credential is required if True
        :returns boolean: True if all required credentials have been set, otherwise False or an error is thrown is param error=true
        r   z requires "z" credentialFT)r  rD  r(  r  r  r   r   r   )r^   r  r(  r   r   s        r`   check_required_credentialsz#Exchange.check_required_credentialsG  s     D,,1134q#d)$ 	!Aq'C'',WT35G-dgg.E.Kn.\]] 	! rd   c                     | j                   | j                  | j                         S t        | j                  dz         )NzB exchange.twofa has not been set for 2FA Two-Factor Authentication)r   r  r   r   r   s    r`   oathzExchange.oathW  s4    ::!99TZZ((*n noord   c                 2    t        | j                  dz         )Nz$ fetchBalance() is not supported yetrp  r  s     r`   fetch_balancezExchange.fetch_balance]  rR  rd   c                 2    t        | j                  dz         )Nz& fetchBalanceWs() is not supported yetrp  r  s     r`   fetch_balance_wszExchange.fetch_balance_ws`  r  rd   c                 2    t        | j                  dz         )Nz$ parseBalance() is not supported yetrp  )r^   r  s     r`   parse_balancezExchange.parse_balancec  rR  rd   c                 2    t        | j                  dz         )Nz$ watchBalance() is not supported yetrp  r  s     r`   watch_balancezExchange.watch_balancef  rR  rd   c                 .    | j                  |      }||   S r   )r	  )r^   partr8  r   s       r`   fetch_partial_balancezExchange.fetch_partial_balancei  s    $$V,t}rd   c                 &    | j                  d|      S )NrI  r
	  r  s     r`   fetch_free_balancezExchange.fetch_free_balancem      ))&&99rd   c                 &    | j                  d|      S )NrJ  r	  r  s     r`   fetch_used_balancezExchange.fetch_used_balancep  r	  rd   c                 &    | j                  d|      S )NrK  r	  r  s     r`   fetch_total_balancezExchange.fetch_total_balances  s    ))'6::rd   c                 2    t        | j                  dz         )Nz# fetchStatus() is not supported yetrp  r  s     r`   fetch_statuszExchange.fetch_statusv  r  rd   c                 v    | j                   d   st        | j                  dz         | j                  |g|      S )Nr  z+ fetchTransactionFee() is not supported yet)r  r   r   fetch_transaction_feesr  s      r`   fetch_transaction_feezExchange.fetch_transaction_feey  s9    xx./tww)VVWW**D66::rd   c                 2    t        | j                  dz         )Nz, fetchTransactionFees() is not supported yetrp  r  s      r`   r	  zExchange.fetch_transaction_fees~  r  rd   c                 2    t        | j                  dz         )Nz0 fetchDepositWithdrawFees() is not supported yetrp  r  s      r`   fetch_deposit_withdraw_feesz$Exchange.fetch_deposit_withdraw_fees  r  rd   c                     | j                   d   st        | j                  dz         | j                  |g|      }| j	                  ||      S )Nr  z/ fetchDepositWithdrawFee() is not supported yet)r  r   r   r	  r  )r^   r,  r8  rC  s       r`   fetch_deposit_withdraw_feez#Exchange.fetch_deposit_withdraw_fee  sI    xx23tww)ZZ[[//?tT**rd   c                 P    ||v r||   S t        | j                  dz   |z   dz         )NrH  z! does not have a value in mappingrp  )r^   r   mappings      r`   get_supported_mappingzExchange.get_supported_mapping  s1    '>3<tww}s25XXYYrd   c                     | j                          | j                  d   st        | j                  dz         | j	                  |      }| j                  ||      }|t        | j                  dz   |z         |S )Nr  z, fetchCrossBorrowRate() is not supported yetzI fetchCrossBorrowRate() could not find the borrow rate for currency code )r  r  r   r   rZ  r  r   )r^   r,  r8  borrowRatesrY  s        r`   fetch_cross_borrow_ratez Exchange.fetch_cross_borrow_rate  su    xx*+tww)WWXX33F;{D1<*u ux| |}}rd   c                     | j                          | j                  d   st        | j                  dz         | j	                  |      }| j                  ||      }|t        | j                  dz   |z         |S )Nr  z/ fetchIsolatedBorrowRate() is not supported yetzL fetchIsolatedBorrowRate() could not find the borrow rate for market symbol )r  r  r   r   r\  r_  r   )r^   r  r8  r!	  rY  s        r`   fetch_isolated_borrow_ratez#Exchange.fetch_isolated_borrow_rate  s    xx*+tww)ZZ[[66v>~~k62<*x x  |B  !B  C  Crd   
methodName
optionNamec                 d   d| j                  |      z   }| j                  |||      }|| j                  |||g      }||gS | j                  |d|      \  }}| j	                  | j
                  |      }|| j                  |||      }|| j                  | j
                  ||      }||n|}||gS )Nr[   callerMethodName)r   r  r^  r{  r  r   )r^   r8  r%	  r&	  r  defaultOptionNamer  exchangeWideMethodOptionss           r`   r  z!Exchange.handle_option_and_params  s    %
(CC!!&*6GHYYv
4E'FGF v "&!9!9&BTV`!aJ(,j(Q%(4))*CZQbc}))$,,
DUV#/ElEvrd   methodName1optionName1optionName2c                     d }| j                  |||      \  }}|| j                  ||      }||gS d }| j                  ||||      \  }}||gS r   )r  r^  )r^   r8  r+	  r,	  r-	  r  r  value2s           r`   handle_option_and_params_2z#Exchange.handle_option_and_params_2  sj    55fk;WvYYv{3F6?"66v{KYefrd   c                 N    | j                  i |||      }| j                  |d      S r  )r  r  )r^   r%	  r&	  r  r  s        r`   r$  zExchange.handle_option  s)    ++B
JUsA&&rd   c                 T   | j                  |dd      }|| j                  |ddg      }||gS ||d   |gS |||gS | j                  | j                  |      }|-t	        |t
              r||gS | j                  |dd      }|||gS | j                  | j                  ddd      }||gS )a  
 @ignore
 @param methodName the method calling handleMarketTypeAndParams
        :param Market market:
        :param dict params:
        :param str [params.type]: type assigned by user
        :param str [params.defaultType]: same.type
        :param str [defaultValue]: assigned programatically in the method calling handleMarketTypeAndParams
        :returns [str, dict]: the market type and params with type and defaultType omitted
        defaultTyper]   rh  )r  r^  r_  r   rV   r"  )	r^   r%	  r  r8  r  r]   methodOptionstypeFromMethodr3	  s	            r`   handle_market_type_and_paramsz&Exchange.handle_market_type_and_params  s     !!&-@YYvv'>?F&>!6NF++# &))t||Z@$--%v..!%!3!3M=RX!Y!-*F33((}ffUV$$rd   c                     d }| j                  |dd      }||}| j                  |ddg      }||gS ||d   rd}n|d   rd}|| j                  i |d|      }|d   }||gS )Nr  defaultSubTyper  r  r   )r  r^  r  )r^   r%	  r  r8  r  r  subTypeInParamsr  s           r`   handle_sub_type_and_paramsz#Exchange.handle_sub_type_and_params  s    ,,VY@PQ&%GYYv	3C'DEF    !(#&GI&'G66r:yR^_ )  rd   c                 *    | j                  ||d|      S )a  
 @ignore
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Array: the marginMode in lowercase by params["marginMode"], params["defaultMarginMode"] self.options["marginMode"] or self.options["defaultMarginMode"]
        r  r  )r^   r%	  r8  r  s       r`   handle_margin_mode_and_paramsz&Exchange.handle_margin_mode_and_params   s     ,,VZ|\\rd   c                 (    |y ||v r ||   |      y r   r   )r^   exactr  r  s       r`   throw_exactly_matched_exceptionz(Exchange.throw_exactly_matched_exception  s'    >U?%-(( rd   c                 B    | j                  ||      }| ||   |      y r   )find_broadly_matched_key)r^   broadr  r  broadKeys        r`   throw_broadly_matched_exceptionz(Exchange.throw_broadly_matched_exception  s0    00?!%/'**  rd   c                     t        |j                               }t        dt        |            D ]"  }||   }||j	                  |      dk\  s |c S  y r  )r  r(  r  r  rQ  )r^   rC	  r  r(  r   r   s         r`   rB	  z!Exchange.find_broadly_matched_key  sV    EJJL!q#d)$ 	Aq'C!;;s#q(J		
 rd   
statusCode
statusTextresponseHeadersresponseBodyc
                      y r   r   )
r^   rG	  rH	  r.  r/  rI	  rJ	  r  requestHeadersrequestBodys
             r`   rb  zExchange.handle_errors  s     rd   c                 (    | j                  |dd      S )Nr   r   )r  )r^   r@  r/  r  r8  r   s         r`   r  z$Exchange.calculate_rate_limiter_cost"  s    vvq11rd   c                 $   | j                   d   rj| j                          | j                  |      }|d   }| j                  |g|      }| j	                  ||      }|t        | j                  dz   |z         |S t        | j                  dz         )Nr  r  z, fetchTickers() could not find a ticker for z# fetchTicker() is not supported yet)r  r  r  fetch_tickersr_  r   r   r   r^   r  r8  r  r   r>  s         r`   fetch_tickerzExchange.fetch_ticker%  s    88N#[[(FH%F((&6:G^^GV4F~"477-[#[^d#deetww)NNOOrd   c                 $   | j                   d   rj| j                          | j                  |      }|d   }| j                  |g|      }| j	                  ||      }|t        | j                  dz   |z         |S t        | j                  dz         )Nr  r  z/ fetchMarkPrices() could not find a ticker for ' fetchMarkPrices() is not supported yet)r  r  r  fetch_mark_pricesr_  r   r   r   rQ	  s         r`   fetch_mark_pricezExchange.fetch_mark_price3  s    88%&[[(FH%F,,fXv>G^^GV4F~"477-^#^ag#ghhtww)RRSSrd   c                 $   | j                   d   rj| j                          | j                  |      }|d   }| j                  |g|      }| j	                  ||      }|t        | j                  dz   |z         |S t        | j                  dz         )Nr  r  z- fetchTickerWs() could not find a ticker for z% fetchTickerWs() is not supported yet)r  r  r  fetch_tickers_wsr_  r   r   r   rQ	  s         r`   fetch_ticker_wszExchange.fetch_ticker_wsA  s    88$%[[(FH%F++VHf=G^^GV4F~"477-\#\_e#efftww)PPQQrd   c                 2    t        | j                  dz         )Nz# watchTicker() is not supported yetrp  r  s      r`   watch_tickerzExchange.watch_tickerO  r  rd   c                 2    t        | j                  dz         Nz$ fetchTickers() is not supported yetrp  r  s      r`   rP	  zExchange.fetch_tickersR  rR  rd   c                 2    t        | j                  dz         )NrT	  rp  r  s      r`   rU	  zExchange.fetch_mark_pricesU  r  rd   c                 2    t        | j                  dz         r]	  rp  r  s      r`   rX	  zExchange.fetch_tickers_wsX  rR  rd   c                 2    t        | j                  dz         )Nz' fetchOrderBooks() is not supported yetrp  r  s       r`   fetch_order_bookszExchange.fetch_order_books[  r  rd   c                 2    t        | j                  dz         )Nz% watchBidsAsks() is not supported yetrp  r  s      r`   watch_bids_askszExchange.watch_bids_asks^  r  rd   c                 2    t        | j                  dz         )Nz$ watchTickers() is not supported yetrp  r  s      r`   watch_tickerszExchange.watch_tickersa  rR  rd   c                 2    t        | j                  dz         )Nz& unWatchTickers() is not supported yetrp  r  s      r`   un_watch_tickerszExchange.un_watch_tickersd  r  rd   c                 2    t        | j                  dz         )Nz" fetchOrder() is not supported yetrp  r^   r   r  r8  s       r`   fetch_orderzExchange.fetch_orderg  rJ  rd   c                 2    t        | j                  dz         )Nz$ fetchOrderWs() is not supported yetrp  ri	  s       r`   fetch_order_wszExchange.fetch_order_wsj  rR  rd   c                 2    | j                  |||      }|d   S )NrG  )rj	  )r^   r   r  r8  rZ  s        r`   fetch_order_statuszExchange.fetch_order_statusm  s"       VV4Xrd   c                 h    | j                  | j                  |d      | j                  |d      |      S Nr   r  )rj	  r  r^   rZ  r8  s      r`   fetch_unified_orderzExchange.fetch_unified_orders  s4     0 0 =t?O?OPUW_?`bhiird   c                 2    t        | j                  dz         )Nz# createOrder() is not supported yetrp  r^   r  r]   r  r~   r   r8  s          r`   r  zExchange.create_orderv  r  rd   fromCodetoCodec                 2    t        | j                  dz         )Nz* createConvertTrade() is not supported yetrp  )r^   r   ru	  rv	  r~   r8  s         r`   create_convert_tradezExchange.create_convert_tradey  r1  rd   c                 2    t        | j                  dz         )Nz) fetchConvertTrade() is not supported yetrp  r  s       r`   fetch_convert_tradezExchange.fetch_convert_trade|  rq  rd   c                 2    t        | j                  dz         )Nz0 fetchConvertTradeHistory() is not supported yetrp  r  s        r`   fetch_convert_trade_historyz$Exchange.fetch_convert_trade_history  r  rd   c                 2    t        | j                  dz         )Nz) fetchPositionMode() is not supported yetrp  r  s      r`   fetch_position_modezExchange.fetch_position_mode  rq  rd   c	                     |t        | j                  dz         ||d<   |||d<   | j                  d   r| j                  ||||||      S t	        | j                  dz         )  
        create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency, or number of contracts
        :param float [price]: the price for the order to be filled at, in units of the quote currency, ignored in market orders
        :param float trailingAmount: the quote amount to trail away from the current market price
        :param float [trailingTriggerPrice]: the price to activate a trailing order, default uses the price argument
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        z? createTrailingAmountOrder() requires a trailingAmount argumenttrailingAmounttrailingTriggerPricer  z1 createTrailingAmountOrder() is not supported yetr   r   r  r  r   	r^   r  r]   r  r~   r   r	  r	  r8  s	            r`   create_trailing_amount_orderz%Exchange.create_trailing_amount_order  sx     !#DGG.o$opp#1 +-AF)*88/0$$VT4OO477%XXYYrd   c	                     |t        | j                  dz         ||d<   |||d<   | j                  d   r| j                  ||||||      S t	        | j                  dz         )r	  zA createTrailingAmountOrderWs() requires a trailingAmount argumentr	  r	  r  z3 createTrailingAmountOrderWs() is not supported yetr   r   r  r  r   r	  s	            r`   create_trailing_amount_order_wsz(Exchange.create_trailing_amount_order_ws  sx     !#DGG.q$qrr#1 +-AF)*8812''dFE6RR477%ZZ[[rd   c	                     |t        | j                  dz         ||d<   |||d<   | j                  d   r| j                  ||||||      S t	        | j                  dz         )  
        create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency, or number of contracts
        :param float [price]: the price for the order to be filled at, in units of the quote currency, ignored in market orders
        :param float trailingPercent: the percent to trail away from the current market price
        :param float [trailingTriggerPrice]: the price to activate a trailing order, default uses the price argument
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        zA createTrailingPercentOrder() requires a trailingPercent argumenttrailingPercentr	  r  z2 createTrailingPercentOrder() is not supported yetr	  	r^   r  r]   r  r~   r   r	  r	  r8  s	            r`   create_trailing_percent_orderz&Exchange.create_trailing_percent_order  sx     "#DGG.q$qrr$3 !+-AF)*8801$$VT4OO477%YYZZrd   c	                     |t        | j                  dz         ||d<   |||d<   | j                  d   r| j                  ||||||      S t	        | j                  dz         )r	  zC createTrailingPercentOrderWs() requires a trailingPercent argumentr	  r	  r  z4 createTrailingPercentOrderWs() is not supported yetr	  r	  s	            r`    create_trailing_percent_order_wsz)Exchange.create_trailing_percent_order_ws  sx     "#DGG.s$stt$3 !+-AF)*8823''dFE6RR477%[[\\rd   r   c                     | j                   d   s| j                   d   r%| j                   d   r| j                  |d||d|      S t        | j                  dz         )  
        create a market order by providing the symbol, side and cost
        :param str symbol: unified symbol of the market to create an order in
        :param str side: 'buy' or 'sell'
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r  r  r  r  r   z1 createMarketOrderWithCost() is not supported yet)r  r  r   r   r^   r  r  r   r8  s        r`   create_market_order_with_costz&Exchange.create_market_order_with_cost  sd     88/0TXX>\5]bfbjbj  lK  cL$$VXtT1fMM477%XXYYrd   c                     | j                   d   s| j                  d   r| j                  |dd|d|      S t        | j                  dz         )a  
        create a market buy order by providing the symbol and cost
        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        !createMarketBuyOrderRequiresPricer  r  r  r   z4 createMarketBuyOrderWithCost() is not supported yetr   r  r  r   r   r^   r  r   r8  s       r`   !create_market_buy_order_with_costz*Exchange.create_market_buy_order_with_cost  sM     <<;<Ig@h$$VXudAvNN477%[[\\rd   c                     | j                   d   s| j                  d   r| j                  |dd|d|      S t        | j                  dz         )a  
        create a market sell order by providing the symbol and cost
        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        "createMarketSellOrderRequiresPricer  r  r  r   z5 createMarketSellOrderWithCost() is not supported yetr	  r	  s       r`   "create_market_sell_order_with_costz+Exchange.create_market_sell_order_with_cost  sM     <<<=JiAj$$VXvtQOO477%\\]]rd   c                     | j                   d   s| j                   d   r%| j                   d   r| j                  |d||d|      S t        | j                  dz         )r	  r  r  r  r  r   z3 createMarketOrderWithCostWs() is not supported yet)r  r  r   r   r	  s        r`    create_market_order_with_cost_wsz)Exchange.create_market_order_with_cost_ws  sd     8812txx@`7afjfnfn  pQ  gR''$aPP477%ZZ[[rd   rV  c                     |t        | j                  dz         ||d<   | j                  d   r| j                  ||||||      S t	        | j                  dz         )  
        create a trigger stop order(type 1)
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency or the number of contracts
        :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
        :param float triggerPrice: the price to trigger the stop order, in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        z6 createTriggerOrder() requires a triggerPrice argumentrV  r  z* createTriggerOrder() is not supported yetr	  r^   r  r]   r  r~   r   rV  r8  s           r`   create_trigger_orderzExchange.create_trigger_order  sf     #DGG.f$fgg!-~88()$$VT4OO477%QQRRrd   c                     |t        | j                  dz         ||d<   | j                  d   r| j                  ||||||      S t	        | j                  dz         )r	  z8 createTriggerOrderWs() requires a triggerPrice argumentrV  r  z, createTriggerOrderWs() is not supported yetr	  r	  s           r`   create_trigger_order_wsz Exchange.create_trigger_order_ws"  sf     #DGG.h$hii!-~88*+''dFE6RR477%SSTTrd   rW  c                     |t        | j                  dz         ||d<   | j                  d   r| j                  ||||||      S t	        | j                  dz         )  
        create a trigger stop loss order(type 2)
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency or the number of contracts
        :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
        :param float stopLossPrice: the price to trigger the stop loss order, in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        z8 createStopLossOrder() requires a stopLossPrice argumentrW  r  z+ createStopLossOrder() is not supported yetr	  r^   r  r]   r  r~   r   rW  r8  s           r`   create_stop_loss_orderzExchange.create_stop_loss_order5  sf      #DGG.h$hii"/88)*$$VT4OO477%RRSSrd   c                     |t        | j                  dz         ||d<   | j                  d   r| j                  ||||||      S t	        | j                  dz         )r	  z: createStopLossOrderWs() requires a stopLossPrice argumentrW  r  z- createStopLossOrderWs() is not supported yetr	  r	  s           r`   create_stop_loss_order_wsz"Exchange.create_stop_loss_order_wsH  sf      #DGG.j$jkk"/88+,''dFE6RR477%TTUUrd   rX  c                     |t        | j                  dz         ||d<   | j                  d   r| j                  ||||||      S t	        | j                  dz         )  
        create a trigger take profit order(type 2)
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency or the number of contracts
        :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
        :param float takeProfitPrice: the price to trigger the take profit order, in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        z< createTakeProfitOrder() requires a takeProfitPrice argumentrX  r  z- createTakeProfitOrder() is not supported yetr	  r^   r  r]   r  r~   r   rX  r8  s           r`   create_take_profit_orderz!Exchange.create_take_profit_order[  sg     "#DGG.l$lmm$3 !88+,$$VT4OO477%TTUUrd   c                     |t        | j                  dz         ||d<   | j                  d   r| j                  ||||||      S t	        | j                  dz         )r	  z> createTakeProfitOrderWs() requires a takeProfitPrice argumentrX  r  z/ createTakeProfitOrderWs() is not supported yetr	  r	  s           r`   create_take_profit_order_wsz$Exchange.create_take_profit_order_wsn  sg     "#DGG.n$noo$3 !88-.''dFE6RR477%VVWWrd   r  r  c	           
          | j                  ||||||||      }| j                  d   r| j                  ||||||      S t        | j                  dz         )  
        create an order with a stop loss or take profit attached(type 3)
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency or the number of contracts
        :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
        :param float [takeProfit]: the take profit price, in units of the quote currency
        :param float [stopLoss]: the stop loss price, in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.takeProfitType]: *not available on all exchanges* 'limit' or 'market'
        :param str [params.stopLossType]: *not available on all exchanges* 'limit' or 'market'
        :param str [params.takeProfitPriceType]: *not available on all exchanges* 'last', 'mark' or 'index'
        :param str [params.stopLossPriceType]: *not available on all exchanges* 'last', 'mark' or 'index'
        :param float [params.takeProfitLimitPrice]: *not available on all exchanges* limit price for a limit take profit order
        :param float [params.stopLossLimitPrice]: *not available on all exchanges* stop loss for a limit stop loss order
        :param float [params.takeProfitAmount]: *not available on all exchanges* the amount for a take profit
        :param float [params.stopLossAmount]: *not available on all exchanges* the amount for a stop loss
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r  z< createOrderWithTakeProfitAndStopLoss() is not supported yet)$set_take_profit_and_stop_loss_paramsr  r  r   r   	r^   r  r]   r  r~   r   r  r  r8  s	            r`   +create_order_with_take_profit_and_stop_lossz4Exchange.create_order_with_take_profit_and_stop_loss  sc    * ::64vW\^hjrtz{88:;$$VT4OO477%ccddrd   c	                    ||t        | j                  dz         |d|i|d<   |d|i|d<   | j                  |d      }	| j                  |d      }
| j                  |d      }| j                  |d      }| j                  |d	      }| j                  |d
      }| j                  |d      }| j                  |d      }|	|	|d   d<   |
|
|d   d<   || j                  |      |d   d<   || j                  |      |d   d<   |||d   d<   |||d   d<   || j                  |      |d   d<   || j                  |      |d   d<   | j	                  |g d      }|S )NzY createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argumentrV  r  r  takeProfitTypetakeProfitPriceTypetakeProfitLimitPricetakeProfitAmountstopLossTypestopLossPriceTypestopLossLimitPricestopLossAmountr]   	priceTyper   r~   )r	  r	  r	  r	  r	  r	  r	  r	  )r   r   r  r  r^  )r^   r  r]   r  r~   r   r  r  r8  r	  r	  r	  r	  r	  r	  r	  r	  s                    r`   r	  z-Exchange.set_take_profit_and_stop_loss_params  s   X%5#DGG  /J  %J  K  K!
$F<  "F: ))&2BC"..v7LM#//8NO++F4FG''? ,,V5HI!--f6JK))&2BC%+9F< (*0CF< -+,0,A,ABV,WF< )'-1-B-BCS-TF< *#)5F:v&(.?F:{+)*.*?*?@R*SF:w'%+/+@+@+PF:x(6  $F  Grd   c	           
          | j                  ||||||||      }| j                  d   r| j                  ||||||      S t        | j                  dz         )r	  r  z> createOrderWithTakeProfitAndStopLossWs() is not supported yet)r	  r  r  r   r   r	  s	            r`   .create_order_with_take_profit_and_stop_loss_wsz7Exchange.create_order_with_take_profit_and_stop_loss_ws  sc    * ::64vW\^hjrtz{88<=''dFE6RR477%eeffrd   c                 2    t        | j                  dz         )Nz$ createOrders() is not supported yetrp  r^   r  r8  s      r`   create_orderszExchange.create_orders  rR  rd   c                 2    t        | j                  dz         )Nz" editOrders() is not supported yetrp  r	  s      r`   edit_orderszExchange.edit_orders  rJ  rd   c                 2    t        | j                  dz         )Nz% createOrderWs() is not supported yetrp  rt	  s          r`   r  zExchange.create_order_ws  r  rd   c                 2    t        | j                  dz         )Nz# cancelOrder() is not supported yetrp  ri	  s       r`   r  zExchange.cancel_order  r  rd   c                 2    t        | j                  dz         )Nz% cancelOrderWs() is not supported yetrp  ri	  s       r`   r  zExchange.cancel_order_ws  r  rd   r/  c                 2    t        | j                  dz         )Nz& cancelOrdersWs() is not supported yetrp  )r^   r/  r  r8  s       r`   cancel_orders_wszExchange.cancel_orders_ws  r  rd   c                 2    t        | j                  dz         )Nz' cancelAllOrders() is not supported yetrp  r  s      r`   cancel_all_orderszExchange.cancel_all_orders  r  rd   rD  c                 2    t        | j                  dz         )Nz, cancelAllOrdersAfter() is not supported yetrp  )r^   rD  r8  s      r`   cancel_all_orders_afterz Exchange.cancel_all_orders_after  r  rd   c                 2    t        | j                  dz         )Nz. cancelOrdersForSymbols() is not supported yetrp  r	  s      r`   cancel_orders_for_symbolsz"Exchange.cancel_orders_for_symbols  r
  rd   c                 2    t        | j                  dz         )Nz) cancelAllOrdersWs() is not supported yetrp  r  s      r`   cancel_all_orders_wszExchange.cancel_all_orders_ws  rq  rd   c                 h    | j                  | j                  |d      | j                  |d      |      S rp	  )r  r  rq	  s      r`   cancel_unified_orderzExchange.cancel_unified_order  s4      !1!1%!>@P@PQVX`@acijjrd   c                     | j                   d   r'| j                   d   rt        | j                  dz         t        | j                  dz         )Nr  r  ze fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() insteadz# fetchOrders() is not supported yetr  r  s        r`   fetch_orderszExchange.fetch_orders  sQ    88%&4884G+Htww  *Q   Q  R  R477%JJKKrd   c                 2    t        | j                  dz         )Nz% fetchOrdersWs() is not supported yetrp  r  s        r`   fetch_orders_wszExchange.fetch_orders_ws  r  rd   c                 2    t        | j                  dz         )Nz( fetchOrderTrades() is not supported yetrp  )r^   r   r  r  r  r8  s         r`   fetch_order_tradeszExchange.fetch_order_trades  r  rd   c                 2    t        | j                  dz         )Nz# watchOrders() is not supported yetrp  r  s        r`   watch_orderszExchange.watch_orders  r  rd   c                     | j                   d   r'| j                  ||||      }| j                  |dd      S t        | j                  dz         )Nr  rG  r  z' fetchOpenOrders() is not supported yetr  r	  r  r   r   r^   r  r  r  r8  r  s         r`   fetch_open_orderszExchange.fetch_open_orders
  sL    88M"&&vueVDF>>&(F;;477%NNOOrd   c                     | j                   d   r'| j                  ||||      }| j                  |dd      S t        | j                  dz         )Nr  rG  r  z) fetchOpenOrdersWs() is not supported yetr  r	  r  r   r   r	  s         r`   fetch_open_orders_wszExchange.fetch_open_orders_ws  sL    88O$))&%GF>>&(F;;477%PPQQrd   c                     | j                   d   r'| j                  ||||      }| j                  |dd      S t        | j                  dz         )Nr  rG  rZ  z) fetchClosedOrders() is not supported yetr	  r	  s         r`   fetch_closed_orderszExchange.fetch_closed_orders  sL    88M"&&vueVDF>>&(H==477%PPQQrd   c                 2    t        | j                  dz         )Nz4 fetchCanceledAndClosedOrders() is not supported yetrp  r  s        r`    fetch_canceled_and_closed_ordersz)Exchange.fetch_canceled_and_closed_orders  s    477%[[\\rd   c                     | j                   d   r'| j                  ||||      }| j                  |dd      S t        | j                  dz         )Nr  rG  rZ  z+ fetchClosedOrdersWs() is not supported yetr	  r	  s         r`   fetch_closed_orders_wszExchange.fetch_closed_orders_ws  sL    88O$))&%GF>>&(H==477%RRSSrd   c                 2    t        | j                  dz         )Nz% fetchMyTrades() is not supported yetrp  r  s        r`   fetch_my_tradeszExchange.fetch_my_trades%  r  rd   c                 2    t        | j                  dz         )Nz+ fetchMyLiquidations() is not supported yetrp  r  s        r`   fetch_my_liquidationszExchange.fetch_my_liquidations(  rE  rd   c                 2    t        | j                  dz         )Nz) fetchLiquidations() is not supported yetrp  r  s        r`   fetch_liquidationszExchange.fetch_liquidations+  rq  rd   c                 2    t        | j                  dz         )Nz' fetchMyTradesWs() is not supported yetrp  r  s        r`   fetch_my_trades_wszExchange.fetch_my_trades_ws.  r  rd   c                 2    t        | j                  dz         )Nz% watchMyTrades() is not supported yetrp  r  s        r`   watch_my_tradeszExchange.watch_my_trades1  r  rd   c                 2    t        | j                  dz         )Nz# fetchGreeks() is not supported yetrp  r  s      r`   fetch_greekszExchange.fetch_greeks4  r  rd   c                 2    t        | j                  dz         )Nz( fetchOptionChain() is not supported yetrp  r  s      r`   fetch_option_chainzExchange.fetch_option_chain7  r  rd   c                 2    t        | j                  dz         )Nz# fetchOption() is not supported yetrp  r  s      r`   fetch_optionzExchange.fetch_option:  r  rd   c                 2    t        | j                  dz         )Nz) fetchConvertQuote() is not supported yetrp  )r^   ru	  rv	  r~   r8  s        r`   fetch_convert_quotezExchange.fetch_convert_quote=  rq  rd   c                 2    t        | j                  dz         )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 structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        z0 fetchDepositsWithdrawals() is not supported yetrp  r  s        r`   fetch_deposits_withdrawalsz#Exchange.fetch_deposits_withdrawals@  s     477%WWXXrd   c                 2    t        | j                  dz         )Nz% fetchDeposits() is not supported yetrp  r  s        r`   fetch_depositszExchange.fetch_depositsK  r  rd   c                 2    t        | j                  dz         )Nz( fetchWithdrawals() is not supported yetrp  r  s        r`   fetch_withdrawalszExchange.fetch_withdrawalsN  r  rd   c                 2    t        | j                  dz         )Nz' fetchDepositsWs() is not supported yetrp  r  s        r`   fetch_deposits_wszExchange.fetch_deposits_wsQ  r  rd   c                 2    t        | j                  dz         )Nz* fetchWithdrawalsWs() is not supported yetrp  r  s        r`   fetch_withdrawals_wszExchange.fetch_withdrawals_wsT  r1  rd   c                 2    t        | j                  dz         )Nz/ fetchFundingRateHistory() is not supported yetrp  r  s        r`   fetch_funding_rate_historyz#Exchange.fetch_funding_rate_historyW  r  rd   c                 2    t        | j                  dz         )Nz+ fetchFundingHistory() is not supported yetrp  r  s        r`   fetch_funding_historyzExchange.fetch_funding_historyZ  rE  rd   c                 2    t        | j                  dz         )Nz% closePosition() is not supported yetrp  )r^   r  r  r8  s       r`   close_positionzExchange.close_position]  r  rd   c                 2    t        | j                  dz         )Nz) closeAllPositions() is not supported yetrp  r  s     r`   close_all_positionszExchange.close_all_positions`  rq  rd   c                 2    t        | j                  dz         )Nz( fetchL3OrderBook() is not supported yet)r   r   r  s       r`   fetch_l3_order_bookzExchange.fetch_l3_order_bookc  s    #MMNNrd   c                 2    t        | j                  dz         )Nz& parseLastPrice() is not supported yetrp  )r^   r   r  s      r`   parse_last_pricezExchange.parse_last_pricef  r  rd   c                 
   | j                   d   rG| j                  |g|      }| j                  ||      }|t        | j                  dz   |z   dz         |S | j                   d   r| j                  |d      }| j                  |d      }| j                  ||      }|| j                  ||      S t        |j                               }| j                  |d      }| j                  ||      S t        | j                  dz         )Nr  z< fetchDepositAddress() could not find a deposit address for zc, make sure you have created a corresponding deposit address in your wallet on the exchange websiter  r  r   z+ fetchDepositAddress() is not supported yet)r  r  r  r   r   r  r^  r  r_  r  r(  r   )	r^   r,  r8  depositAddressesrC  r  addressStructuresr(  r   s	            r`   fetch_deposit_addresszExchange.fetch_deposit_addressi  s   88+,#;;TFFK!__-=tDN%$TWW/m%mpt%t  x]  &]  ^  ^%%XX67&&vy9GYYvy1F $ G Gf U"~~&7AA-2245&&tQ/~~&7==tww)VVWWrd   c                     d d d dS )N)rI  rJ  rK  r   r   s    r`   r8   zExchange.account~  s    
 	
rd   c                 X    | j                   s|S | j                  | j                  ||      S r   )substituteCommonCurrencyCodesr  rJ  r^   r,  s     r`   r  zExchange.common_currency_code  s+    11K 5 5tTBBrd   c                    | j                   t        | j                  dz         t        |t              r:|| j                   v r| j                   |   S || j
                  v r| j
                  |   S t        | j                  dz   |z         )Nz currencies not loadedz does not have currency code )r   r   r   rV   r"  r2  r
  s     r`   rA  zExchange.currency  s    ??"*B BCCdC t&t,,...,,T22DGG&EELMMrd   c                 4   | j                   t        | j                  dz         || j                   v r| j                   |   S || j                  v rZ| j                  |   }| j	                  | j
                  ddd      }t        dt        |            D ]  }||   }||   s|c S  |d   S |j                  d      s3|j                  d      s"|j                  d      s|j                  d	      r| j                  |      S t        | j                  d
z   |z         )Nz markets not loadedr3	  r8	  rh  r   z-Cz-PzC-zP-z does not have market symbol )r  r   r   r  r  r   r  r  endswithr|  create_expired_option_marketr   )r^   r  r  r3	  r   r  s         r`   r  zExchange.market  s   <<*? ?@@T\\!<<''t)))((0G,,T\\=JZ\bcK1c'l+ " +&!M" 1:ood#)>FDUDUVZD[agararswax44V<<"AAFJKKrd   c                 2    t        | j                  dz         )Nz1 createExpiredOptionMarket() is not supported yetrp  r  s     r`   r
  z%Exchange.create_expired_option_market  s    477%XXYYrd   checkBaseCoinexistingCurrenciesc                     g d}t        dt        |            D ]5  }||   }|j                  |      s|s y|j                  |d      }||v s5 y y)N)2L2S3L3S4L4S5L5SUPDOWNBULLBEARr   Trx   F)r  r  r
  r  )r^   r"  r
  r 
  leverageSuffixesr   leverageSuffixbaseCurrencyCodes           r`   is_leveraged_currencyzExchange.is_leveraged_currency  sl    

 q#./0 		$A-a0N$$^4$ (4';';NB'O$'+==#		$ rd   c                     |$t        |t              r| j                  ||      }d }|&| j                  |d      }|| j	                  |d      }||gS )Nr  )rV   r   r  r  r^  )r^   r  r8  s      r`   handle_withdraw_tag_and_paramsz'Exchange.handle_withdraw_tag_and_params  s[    O*S$"7[[f-FC;""651C651V}rd   c                 .    | j                  |d||||      S r  r  r^   r  r  r~   r   r8  s         r`   create_limit_orderzExchange.create_limit_order  s      $vNNrd   c                 .    | j                  |d||||      S r  r  r6
  s         r`   create_limit_order_wszExchange.create_limit_order_ws  s    ##FGT65&QQrd   c                 .    | j                  |d||||      S Nr  r5
  r6
  s         r`   create_market_orderzExchange.create_market_order  s      4OOrd   c                 .    | j                  |d||||      S r<
  r9
  r6
  s         r`   create_market_order_wszExchange.create_market_order_ws  s    ##FHdFE6RRrd   c                 .    | j                  |dd|||      S Nr  r  r5
  r^   r  r~   r   r8  s        r`   create_limit_buy_orderzExchange.create_limit_buy_order  s      %OOrd   c                 .    | j                  |dd|||      S rA
  r9
  rB
  s        r`   create_limit_buy_order_wsz"Exchange.create_limit_buy_order_ws  s    ##FGUFE6RRrd   c                 .    | j                  |dd|||      S Nr  r  r5
  rB
  s        r`   create_limit_sell_orderz Exchange.create_limit_sell_order  s      &&%PPrd   c                 .    | j                  |dd|||      S rG
  r9
  rB
  s        r`   create_limit_sell_order_wsz#Exchange.create_limit_sell_order_ws  s    ##FGVVUFSSrd   c                 .    | j                  |dd|d |      S Nr  r  r5
  r  s       r`   create_market_buy_orderz Exchange.create_market_buy_order  s      5&$OOrd   c                 .    | j                  |dd|d |      S rL
  r9
  r  s       r`   create_market_buy_order_wsz#Exchange.create_market_buy_order_ws  s    ##FHeVT6RRrd   c                 .    | j                  |dd|d |      S Nr  r  r5
  r  s       r`   create_market_sell_orderz!Exchange.create_market_sell_order  s      664PPrd   c                 .    | j                  |dd|d |      S rQ
  r9
  r  s       r`   create_market_sell_order_wsz$Exchange.create_market_sell_order_ws  s    ##FHffdFSSrd   c                     |y | j                  |      }| j                  |t        |d   d   | j                  | j                        S Nr   r   )r  r   r   rK  rL  )r^   r  r   r  s       r`   cost_to_precisionzExchange.cost_to_precision  sI    <V$((x9LW9UW[WiWikok{k{||rd   c                    |y | j                  |      }| j                  |t        |d   d   | j                  | j                        }|dk(  r9t        | j                  dz   |d   z   dz   | j                  |d   d         z         |S )Nr   r   r  z
 price of r  z1 must be greater than minimum price precision of )r  r   r   rK  rL  r   r   r   )r^   r  r   r  r  s        r`   price_to_precisionzExchange.price_to_precision  s    =V$**5%9LW9UW[WiWikok{k{|S=tww5x8HHK~~  BF  BW  BW  X^  _j  Xk  ls  Xt  Bu   u  v  vrd   c                    |y | j                  |      }| j                  |t        |d   d   | j                  | j                        }|dk(  r9t        | j                  dz   |d   z   dz   | j                  |d   d         z         |S )Nr   r~   r  z amount of r  z2 must be greater than minimum amount precision of )r  r   r   rK  rL  r   r   r   )r^   r  r~   r  r  s        r`   amount_to_precisionzExchange.amount_to_precision  s    >V$**68VK=PQY=Z\`\n\npt  qA  qA  BS=tww69II  MA   A  DH  DY  DY  Z`  al  Zm  nv  Zw  Dx   x  y  yrd   c                     |y | j                  |      }| j                  |t        |d   d   | j                  | j                        S rV
  )r  r   r   rK  rL  )r^   r  rS  r  s       r`   fee_to_precisionzExchange.fee_to_precision   sI    ;V$((eVK5H5QSWSeSegkgwgwxxrd   c                 t   | j                   |   }| j                  |d      }|9| j                  |di       }| j                  ||i       }| j                  |d|      }|| j                  |      S | j	                  | j
                  dt              }| j                  |||| j                  | j                        S )Nr   r  currencyToPrecisionRoundingMode)
r   r  r_  force_stringr  r   r   r   rK  rL  )	r^   r,  rS  r!  rA  r   r  networkItemroundingModes	            r`   currency_to_precisionzExchange.currency_to_precision  s    ??4(OOHk:	"~~h
B?H..;CK[)LI$$S)),,T\\;\^cdL,,S,	4K]K]_c_o_opprd   c                 H    t        |t              s| j                  |      S |S r   )rV   r"  r   r  s     r`   r`
  zExchange.force_string  s"    %%((//rd   c                 (    | j                   t        k(  S r   )rK  r   r   s    r`   r  zExchange.is_tick_precision  s    !!Y..rd   c                 (    | j                   t        k(  S r   )rK  r   r   s    r`   is_decimal_precisionzExchange.is_decimal_precision  s    !!^33rd   c                 (    | j                   t        k(  S r   )rK  r   r   s    r`   is_significant_precisionz!Exchange.is_significant_precision  s    !!%777rd   defaultNumberc                 J    | j                  ||      }| j                  ||      S r   )r  r  )r^   r_   r   rj
  r  s        r`   r6  zExchange.safe_number!  s'      c*  66rd   c                 J    | j                  ||      }| j                  ||      S r   )r  r  )r^   r_   r7  rj
  r  s        r`   safe_number_nzExchange.safe_number_n%  s'    ""3,  66rd   r   c                 j    |yt        |      }|dk(  ryd}t        d|dz
        D ]  }|dz   }	 |dz   S )z
 @ignore
        :param str precision: The number of digits to the right of the decimal
        :returns str: a string number equal to 1e-precision
        Nr   r  z0.r   r  )r  r  )r^   r   precisionNumberparsedPrecisionr   s        r`   parse_precisionzExchange.parse_precision)  sV     i.aq/A-. 	4A-3O	4$$rd   c                     |yt        j                  |d      r| j                  |      S t        j                  |      }t	        |      }d}t        d|dz
        D ]  }|dz   }	 |dz   S )a  
 @ignore
        handles positive & negative numbers too. parsePrecision() does not handle negative numbers, but self method handles
        :param str precision: The number of digits to the right of the decimal
        :returns str: a string number equal to 1e-precision
        Nr  r  r   r   )r    	string_gerq
  
string_absr  r  )r^   r   positivePrecisionStringpositivePrecisionrp
  r   s         r`   integer_precision_to_amountz$Exchange.integer_precision_to_amount9  s     Y,''	22&-&8&8&C# #$; <!O1/!34 8"1C"78"S((rd   c                     | j                  |      }| j                         }||z
  | j                  d<   | j                  d   S )NtimeDifference)r-  r  r   )r^   r8  
serverTimer  s       r`   load_time_differencezExchange.load_time_differenceL  sB    __V,
!!#).);%&||,--rd   c                 >    | j                  |d| j                  i      S )Nhostname)r9  r}
  )r^   r.  s     r`   implode_hostnamezExchange.implode_hostnameR  s    ""3T]](CDDrd   c                     | j                   d   rR| j                  |      }|d   st        | j                  dz         | j	                  |g      }| j                  ||      S t        | j                  dz         )Nr  r!  z: fetchMarketLeverageTiers() supports contract markets onlyz0 fetchMarketLeverageTiers() is not supported yet)r  r  r   r   ra  r  r   )r^   r  r8  r  rO  s        r`   fetch_market_leverage_tiersz$Exchange.fetch_market_leverage_tiersU  sr    88()[[(F*%*f fgg--vh7E??5&11tww)[[\\rd   c                     | j                   d   st        | j                  dz         | j                  |ddi      }| j	                  ||||||      S )Nr  z+ createPostOnlyOrder() is not supported yetr[  Tr  r   r   r  r  r^   r  r]   r  r~   r   r8  querys           r`   create_post_only_orderzExchange.create_post_only_order_  sT    xx-.tww)VVWWFZ$67  tVUEJJrd   c                     | j                   d   st        | j                  dz         | j                  |ddi      }| j	                  ||||||      S )Nr  z- createPostOnlyOrderWs() is not supported yetr[  Tr  r   r   r  r  r
  s           r`   create_post_only_order_wsz"Exchange.create_post_only_order_wse  sT    xx/0tww)XXYYFZ$67##FD$uMMrd   c                     | j                   d   st        | j                  dz         | j                  |ddi      }| j	                  ||||||      S )Nr  z- createReduceOnlyOrder() is not supported yetra  Tr
  r
  s           r`   create_reduce_only_orderz!Exchange.create_reduce_only_orderk  sT    xx/0tww)XXYYF\4$89  tVUEJJrd   c                     | j                   d   st        | j                  dz         | j                  |ddi      }| j	                  ||||||      S )Nr  z/ createReduceOnlyOrderWs() is not supported yetra  Tr
  r
  s           r`   create_reduce_only_order_wsz$Exchange.create_reduce_only_order_wsq  sT    xx12tww)ZZ[[F\4$89##FD$uMMrd   c                     | j                   d   st        | j                  dz         |t        | j                  dz         | j	                  |d|i      }| j                  ||||||      S )Nr  z' createStopOrder() is not supported yetz2 create_stop_order() requires a stopPrice argumentr_  )r  r   r   r   r  r  	r^   r  r]   r  r~   r   rV  r8  r
  s	            r`   create_stop_orderzExchange.create_stop_orderw  so    xx)*tww)RRSS#DGG.b$bccF[,$?@  tVUEJJrd   c                     | j                   d   st        | j                  dz         |t        | j                  dz         | j	                  |d|i      }| j                  ||||||      S )Nr  z) createStopOrderWs() is not supported yetz2 createStopOrderWs() requires a stopPrice argumentr_  )r  r   r   r   r  r  r
  s	            r`   create_stop_order_wszExchange.create_stop_order_ws  so    xx+,tww)TTUU#DGG.b$bccF[,$?@##FD$uMMrd   c                     | j                   d   st        | j                  dz         | j                  |d|i      }| j	                  |d||||      S )Nr  z, createStopLimitOrder() is not supported yetr_  r  r
  r^   r  r  r~   r   rV  r8  r
  s           r`   create_stop_limit_orderz Exchange.create_stop_limit_order  sT    xx./tww)WWXXF[,$?@  $uMMrd   c                     | j                   d   st        | j                  dz         | j                  |d|i      }| j	                  |d||||      S )Nr  z. createStopLimitOrderWs() is not supported yetr_  r  r
  r
  s           r`   create_stop_limit_order_wsz#Exchange.create_stop_limit_order_ws  sT    xx01tww)YYZZF[,$?@##FGT65%PPrd   c                     | j                   d   st        | j                  dz         | j                  |d|i      }| j	                  |d||d |      S )Nr  z- createStopMarketOrder() is not supported yetr_  r  r
  r^   r  r  r~   rV  r8  r
  s          r`   create_stop_market_orderz!Exchange.create_stop_market_order  sT    xx/0tww)XXYYF[,$?@  4uMMrd   c                     | j                   d   st        | j                  dz         | j                  |d|i      }| j	                  |d||d |      S )Nr  z/ createStopMarketOrderWs() is not supported yetr_  r  r
  r
  s          r`   create_stop_market_order_wsz$Exchange.create_stop_market_order_ws  sT    xx12tww)ZZ[[F[,$?@##FHdFD%PPrd   c                 0    | j                  ||      }|d   S )Nr,  )r  )r^   r  rA  s      r`   r  zExchange.safe_currency_code  s    %%j(;rd   c           	      0    | j                  |d|||d|      S )Nr  r  r  )r^   r  r  r  r  r  s         r`   r  z%Exchange.filter_by_symbol_since_limit  s"    //xPUWbdhiird   c           	      0    | j                  |d|||d|      S )NrA  r  r
  )r^   r  r,  r  r  r  s         r`   rg  z'Exchange.filter_by_currency_since_limit  s"    //z4PUWbdhiird   c                 T    | j                  |d|d      }| j                  |||d|      S )Nr  Fr  )r  r  )r^   r  r  r  r  r  r  s          r`   filter_by_symbols_since_limitz&Exchange.filter_by_symbols_since_limit  s1    %%eXwF))&%TRRrd   c                    g }t        |t              rPt        dt        |            D ]7  }| j	                  | j                  ||         |      }|j                  |       9 nt        |j                               }t        dt        |            D ]N  }||   }| j                  |      }	| j	                  | j                  ||   |	      |      }|j                  |       P | j                  |      }| j                  |d|      S r  )rV   r  r  r  r  r
  r  r(  rM  r  r  )
r^   
pricesDatar  r8  r  r   	priceData	marketIdsrQ  r  s
             r`   parse_last_priceszExchange.parse_last_prices  s    ( j$'1c*o. * KK(=(=jm(LfU	y)* Z__./I1c)n- *$Q<))(3 KK(=(=j>RTZ([]cd	y)	*
 %%g.##GXw??rd   c                    g }t        |t              rRt        dt        |            D ]9  }| j	                  ||         }| j                  ||      }|j                  |       ; nt        |j                               }t        dt        |            D ]P  }||   }	| j                  |	      }
| j	                  ||	   |
      }| j                  ||      }|j                  |       R | j                  |      }| j                  |d|      S r  )rV   r  r  r  r@  r  r  r(  rM  r  r  )r^   r   r  r8  r  r   parsedTickerr>  r
  rQ  r  r8  s               r`   parse_tickerszExchange.parse_tickers  s    . gt$1c'l+ '#00<\6:v&'
 W\\^,I1c)n- '$Q<))(3**78+<fEVV4v&' %%g.##GXw??rd   c                     g }t        dt        |            D ]7  }| j                  | j                  ||         |      }|j	                  |       9 || j                  |d|d      }|r| j                  |dd |      }|S )Nr   rA  F)r  r  r  rD  r  r  )r^   	addressesr  r  r8  r  r   r  s           r`   parse_deposit_addressesz Exchange.parse_deposit_addresses  s    q#i.) 	#Akk$"<"<Yq\"JFSGMM'"	# ))&*eUKF))&*dGLFrd   c                     g }t        dt        |            D ](  }||   }|j                  | j                  ||             * |S r  )r  r  r  rh  )r^   r  r  	interestsr   rows         r`   parse_borrow_interestszExchange.parse_borrow_interests  sO    	q#h-( 	FA1+CT77VDE	F rd   c                 2    t        | j                  dz         )Nz' parseBorrowRate() is not supported yetrp  )r^   r  rA  s      r`   parse_borrow_ratezExchange.parse_borrow_rate
  r  rd   c                     g }t        dt        |            D ])  }||   }| j                  |      }|j                  |       + | j	                  |d      }	| j                  |	|||      S )Nr   r  )r  r  r
  r  r"  rg  )
r^   r  r,  r  r  r  r   rS  
borrowRater  s
             r`   parse_borrow_rate_historyz"Exchange.parse_borrow_rate_history  so    q#h-( 	&AA;D//5JMM*%	& fk22264NNrd   c                     i }t        dt        |            D ]/  }||   }| j                  |      }| j                  |d      }|||<   1 |S r  )r  r  rj  r  )r^   r  r  r   rS  r
  r  s          r`   parse_isolated_borrow_ratesz$Exchange.parse_isolated_borrow_rates  s\    q#d)$ 	(A7D88>J%%j(;F'F6N		(
 rd   c                     g }t        dt        |            D ](  }||   }|j                  | j                  ||             * | j	                  |d      }|d n|d   }	| j                  ||	||      S Nr   r  r  )r  r  r  rf  r"  r  
r^   r  r  r  r  ratesr   r  r  r  s
             r`   parse_funding_rate_historiesz%Exchange.parse_funding_rate_histories  s~    q#h-( 	IAQKELL88GH	I e[1 .vh/?00NNrd   c                 4    | j                  ||||      }|d   S rw  )rM  )r^   rQ  r  r  r  s        r`   safe_symbolzExchange.safe_symbol(  s#    !!(FIzJhrd   r!  c                 2    t        | j                  dz         )Nz( parseFundingRate() is not supported yetrp  )r^   r!  r  s      r`   parse_funding_ratezExchange.parse_funding_rate,  r  rd   c                     i }t        dt        |            D ]   }||   }| j                  |      }|||d   <   " | j                  |d|      S r  )r  r  r
  r  )r^   r  r  r   r   r  r8  s          r`   parse_funding_rateszExchange.parse_funding_rates/  s`    q#h-( 	4AQKE,,U3F-3L)*	4 ##L(GDDrd   c                 2    t        | j                  dz         )Nz+ parseLongShortRatio() is not supported yetrp  r^  s      r`   parse_long_short_ratiozExchange.parse_long_short_ratio7  rE  rd   c                     g }t        dt        |            D ](  }||   }|j                  | j                  ||             * | j	                  |d      }|d n|d   }	| j                  ||	||      S r
  )r  r  r  r
  r"  r  r
  s
             r`   parse_long_short_ratio_historyz'Exchange.parse_long_short_ratio_history:  s~    q#h-( 	EAQKELL44UFCD	E e[1 .vh/?00NNrd   r  c                    | j                  |d      }|duxr ||v }|| j                  |d      }| j                  |g d      s|s|st        | j                  dz         |dk(  s|dk(  rd}||gS |dk(  s|d	k(  rd
}||gS )z^
 @ignore
        :returns [str, dict]: the trigger-direction value and omited params
        triggerDirectionN)r  r!  updownabovebelowzk createOrder() : trigger orders require params["triggerDirection"] to be either "ascending" or "descending"r
  r
  r  r
  r
  r!  )r  r^  r-  r   r   )r^   r8  r  r  r
  exchangeSpecificDefineds         r`   #handle_trigger_direction_and_paramsz,Exchange.handle_trigger_direction_and_paramsC  s    
  ++F4FG#6d#B"gI\`fIf'YYv'9:F }}-/jk  uL  U_#DGG  /\  %\  ]  ]t#'77'B* !&)) '+;w+F+ &))rd   c                 \    | j                  |dd      }|r| j                  |ddg      }||gS )Ntriggerstopr  )r^   r8  	isTriggers      r`   handle_trigger_and_paramsz"Exchange.handle_trigger_and_paramsX  s9    $$VY?	YYv	6':;F6""rd   c                 $    | j                  |      S r   )r
  r  s     r`   is_trigger_orderzExchange.is_trigger_order^  s    --f55rd   isMarketOrderc                     | j                  |d      }| j                  |ddd      }|dk(  }|dk(  }|dk(  }|xs |xs |}|r:|s|rt        | j                  dz   |z         |rt        | j                  d	z         y
y)z
 @ignore
        :param str type: Order type
        :param boolean exchangeSpecificParam: exchange specific postOnly
        :param dict [params]: exchange specific params
        :returns boolean: True if a post only order, False otherwise
        r  r[  	post_onlyFr\  FOKr]  2 postOnly orders cannot have timeInForce equal to ! market orders cannot be postOnlyT)r  rU  r   r   )	r^   r
  exchangeSpecificParamr8  r  r[  iocfoktimeInForcePostOnlys	            r`   is_post_onlyzExchange.is_post_onlyb  s     ,,V]C##FJUKU"U")T1K2K6Kc"477-a#ado#opp"477-P#PQQrd   exchangeSpecificPostOnlyOptionc                 P   | j                  |d      }| j                  |dd      }|dk(  }|dk(  }|dk(  }|xs |xs |}|rc|s|rt        | j                  dz   |z         |rt        | j                  dz         |r| j	                  |d      }| j	                  |d      }d	|gS d|gS )
z
 @ignore
        :param str type: Order type
        :param boolean exchangeSpecificBoolean: exchange specific postOnly
        :param dict [params]: exchange specific params
        :returns Array:
        r  r[  Fr\  r
  r]  r
  r
  T)r  r   r   r   r^  )	r^   r
  r
  r8  r  r[  r
  r
  pos	            r`   handle_post_onlyzExchange.handle_post_only{  s     ,,V]C>>&*e<U"U"D CrC%Cc"477-a#ado#opp"477-P#PQQ!YYv}=F6:6f~%vrd   c                 2    t        | j                  dz         )Nz' fetchLastPrices() is not supported yetrp  r  s      r`   fetch_last_priceszExchange.fetch_last_prices  r  rd   c                 2    t        | j                  dz         )Nz( fetchTradingFees() is not supported yetrp  r  s     r`   r  zExchange.fetch_trading_fees  r  rd   c                 2    t        | j                  dz         )Nz* fetchTradingFeesWs() is not supported yetrp  r  s     r`   fetch_trading_fees_wszExchange.fetch_trading_fees_ws  r1  rd   c                     | j                   d   st        | j                  dz         | j                  |      }| j	                  ||      S )Nr  z' fetchTradingFee() is not supported yet)r  r   r   r  r_  )r^   r  r8  rC  s       r`   fetch_trading_feezExchange.fetch_trading_fee  sE    xx*+tww)RRSS&&v.~~dF++rd   c                 2    t        | j                  dz         )Nz. fetchConvertCurrencies() is not supported yetrp  r  s     r`   fetch_convert_currenciesz!Exchange.fetch_convert_currencies  r
  rd   c                 2    t        | j                  dz         )Nz) parseOpenInterest() is not supported yetrp  )r^   interestr  s      r`   parse_open_interestzExchange.parse_open_interest  rq  rd   c                     i }t        dt        |            D ]   }||   }| j                  |      }|||d   <   " | j                  |d|      S r  )r  r  r
  r  )r^   r  r  r  r   r  r8  s          r`   parse_open_interestszExchange.parse_open_interests  s`    q#h-( 	.AQKE--e4F'-F6(#$	. ##FHg>>rd   c                     g }t        dt        |            D ]*  }||   }| j                  ||      }|j                  |       , | j	                  |d      }	| j                  |d      }
| j                  |	|
||      S r
  )r  r  r
  r  r"  r  r  )r^   r  r  r  r  r
  r   r  r
  r  r  s              r`   parse_open_interests_historyz%Exchange.parse_open_interests_history  s    	q#h-( 	'AQKE//v>HX&	' i5!!&(300NNrd   c                 ^   | j                   d   r| j                          | j                  |      }|d   }|d   st        | j                  dz         | j                  |g|      }| j                  ||      }|t        | j                  dz   |z         |S t        | j                  dz         )Nr  r  r!  z2 fetchFundingRate() supports contract markets onlyz) fetchFundingRate() returned no data for z( fetchFundingRate() is not supported yet)	r  r  r  r   r   rw  r  r   r   r^   r  r8  r  r
  rY  s         r`   fetch_funding_ratezExchange.fetch_funding_rate  s    88'([[(FH%F*%*^ ^__,,fXv>E??5&1D|"477-X#X[a#abbtww)SSTTrd   c                 ^   | j                   d   r| j                          | j                  |      }|d   }|d   st        | j                  dz         | j                  |g|      }| j                  ||      }|t        | j                  dz   |z         |S t        | j                  dz         )Nr  r  r!  z6 fetchFundingInterval() supports contract markets onlyz- fetchFundingInterval() returned no data for z, fetchFundingInterval() is not supported yet)	r  r  r  r   r   ry  r  r   r   r
  s         r`   fetch_funding_intervalzExchange.fetch_funding_interval  s    88+,[[(FH%F*%*b bcc00&6BE??5&1D|"477-\#\_e#efftww)WWXXrd   c           
          | j                   d   r)ddi}| j                  ||||| j                  ||            S t        | j                  dz         )aL  
        fetches historical mark price candlestick data containing the open, high, low, and close price 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 float[][]: A list of candles ordered, open, high, low, close, None
        r  r   markz& fetchMarkOHLCV() is not supported yetr  r  r  r   r   r^   r  r  r  r  r8  rW  s          r`   fetch_mark_ohlcvzExchange.fetch_mark_ohlcv  sZ     88$%G ##FIueT[[QXZ`Eabbtww)QQRRrd   c           
          | j                   d   r)ddi}| j                  ||||| j                  ||            S t        | j                  dz         )a>  
        fetches historical index price candlestick data containing the open, high, low, and close price 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 {} A list of candles ordered, open, high, low, close, None
        r  r   r   z' fetchIndexOHLCV() is not supported yetr
  r
  s          r`   fetch_index_ohlcvzExchange.fetch_index_ohlcv  sZ     88%&G ##FIueT[[QXZ`Eabbtww)RRSSrd   c           
          | j                   d   r)ddi}| j                  ||||| j                  ||            S t        | j                  dz         )aU  
        fetches historical premium index price candlestick data containing the open, high, low, and close price 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 float[][]: A list of candles ordered, open, high, low, close, None
        r  r   premiumIndexz. fetchPremiumIndexOHLCV() is not supported yetr
  r
  s          r`   fetch_premium_index_ohlcvz"Exchange.fetch_premium_index_ohlcv   sZ     88,-G ##FIueT[[QXZ`Eabbtww)YYZZrd   c                     | j                  |d      }|A| j                  | j                  d   |      }|t        | j                  dz   |z   dz         |S y)z
 @ignore
 Must add timeInForce to self.options to use self method
        :returns str: returns the exchange specific value for timeInForce
        r  Nz does not support timeInForce "r  )r  r  r   r   r   )r^   r8  r  exchangeValues       r`   handle_time_in_forcezExchange.handle_time_in_force  sg     ,,V]C" ,,T\\--H+VM$#DGG.O$OR]$]`c$cdd  rd   c                     | j                  | j                  di       } |j                         }||v r||   S || j                  v s|| j                  v r| j                  |      }|d   S |S )z
 @ignore
 Must add accountsByType to self.options to use self method
        :param str account: key for account name in self.options['accountsByType']
        :returns: the exchange specific account name or the isolated margin id for transfers
        accountsByTyper   )r_  r   r  r  r  r  )r^   r8   r  lowercaseAccountr  s        r`   convert_type_to_accountz Exchange.convert_type_to_account   ss     6FK(7==?~-!"233%7d6H6H+H[[)F$<Nrd   c                     t        |      }||dkD  rZ| j                  ||      sGdj                  |      }| j                  dz   |z   dz   |z   dz   }|dk7  r|d|z   d	z   z  }t	        |      yy)
ao  
 @ignore
        :param str methodName: the name of the method that the argument is being checked for
        :param str argument: the argument's actual value provided
        :param str argumentName: the name of the argument being checked(for logging purposes)
        :param str[] options: a list of options that the argument can be
        :returns None:
        Nr   r>  rH  z() requires a z	 argumentrx   z
, one of ())r  r-  r   r   r   )r^   r%	  argumentargumentNamer   optionsLengthmessageOptionsr  s           r`   r  z Exchange.check_required_argument1  s     G=1#4t}}XW^?_!YYw/Nggmj03CClRU``G#,~=CC#G,, @`#4rd   c                     |dk(  r |t        | j                  dz   |z   dz         |dk(  r!|t        | j                  dz   |z   dz         yy)z
 @ignore
        :param str symbol: unified symbol of the market
        :param str methodName: name of the method that requires a symbol
        :param str marginMode: is either 'isolated' or 'cross'
        r(  NrH  z1() requires a symbol argument for isolated marginr'  z1() cannot have a symbol argument for cross margin)r   r   )r^   r%	  r  r  s       r`   check_required_margin_argumentz'Exchange.check_required_margin_argumentB  sa     *$6>#DGGcMJ$>At$tuuG#&*<#DGGcMJ$>At$tuu +=#rd   c                 z   i }t        |t              }|}|st        |j                               }t        dt	        |            D ]s  }||   }|r|n||   }	|r| j                  |	|      n|}
| j                  |
      }| j                  |d      }|| j                  ||      s_| j                  |	|      ||<   u |S )a  
 @ignore
        :param object[]|dict response: unparsed response from the exchange
        :param str[]|None codes: the unified currency codes to fetch transactions fees for, returns all currencies when None
        :param str currencyIdKey: *should only be None when response is a dictionary* the object key that corresponds to the currency id
        :returns dict: objects with withdraw and deposit fees, indexed by currency codes
        r   r,  )	rV   r  r(  r  r  r  r  r-  parse_deposit_withdraw_fee)r^   r  r  currencyIdKeydepositWithdrawFeesrv  responseKeysr   r  r  r  rA  r,  s                r`   parse_deposit_withdraw_feesz$Exchange.parse_deposit_withdraw_feesN  s     !Xt,0Lq#l+, 	bA OE")xJHO))*mDUZJ))*5H##Hf5D4==u#=,0,K,KJX`,a#D)	b #"rd   c                 2    t        | j                  dz         )Nz/ parseDepositWithdrawFee() is not supported yetrp  )r^   rS  rA  s      r`   r  z#Exchange.parse_deposit_withdraw_feee  r  rd   c                     |d d dd d di dS )N)rS  rj   )r  rn   ro   r  r   )r^   r  s     r`   deposit_withdraw_feezExchange.deposit_withdraw_feeh  s,    "
 " 
 	
rd   c                 F   t        |d   j                               }t        |      }|dk(  r$|d   |d      d   |d<   |d   |d      d   |d<   |S | j                  |d      }t	        d|      D ]/  }||   }||k(  s|d   ||      d   |d<   |d   ||      d   |d<   1 |S )a?  
 @ignore
        Takes a depositWithdrawFee structure and assigns the default values for withdraw and deposit
        :param dict fee: A deposit withdraw fee structure
        :param dict currency: A currency structure, the response from self.currency()
        :returns dict: A deposit withdraw fee structure
        r  r   r   rn   ro   r,  )r  r(  r  r  r  )r^   rS  rA  networkKeysnumNetworksr"  r   r  s           r`   $assign_default_deposit_withdraw_feesz-Exchange.assign_default_deposit_withdraw_feesv  s     3z?//12+&!!*ok!n=jIC
O _[^<YGC	NJ''&9q+& 	LA!!nG,&"%j/+a."A*"MJ!$ZQ!@!KI		L
 
rd   c                 2    t        | j                  dz         )Nz# parseIncome() is not supported yetrp  r^  s      r`   parse_incomezExchange.parse_income  r  rd   c                     g }t        dt        |            D ]*  }||   }| j                  ||      }|j                  |       , | j	                  |d      }	| j                  |d      }
| j                  |	|
||      S )a  
 @ignore
        parses funding fee info from exchange response
        :param dict[] incomes: each item describes once instance of currency being received or paid
        :param dict market: ccxt market
        :param int [since]: when defined, the response items are filtered to only include items after self timestamp
        :param int [limit]: limits the number of items in the response
        :returns dict[]: an array of `funding history structures <https://docs.ccxt.com/#/?id=funding-history-structure>`
        r   r  r  )r  r  r!  r  r"  r  r  )r^   incomesr  r  r  r  r   r  r8  r  r  s              r`   parse_incomeszExchange.parse_incomes  s     q#g,' 	"AAJE&&uf5FMM&!	" fk2!!&(300NNrd   c                 R    |y | j                  |d      }| j                  |      }|S r  )r  r  )r^   r  firstMarketr  s       r`   get_market_from_symbolsz Exchange.get_market_from_symbols  s/    ?&&w2[)rd   c                     g }t        dt        |            D ]&  }|j                  | j                  ||   |             ( |S r  )r  r  r  ru  )r^   r   r  r  r  r  r  r   s           r`   parse_ws_ohlcvszExchange.parse_ws_ohlcvs  sE    q#f+& 	CANN4..vay&AB	Crd   c                 x    | j                   d   r| j                  ||||      S t        | j                  dz         )a8  
 @deprecated
        *DEPRECATED* use fetchDepositsWithdrawals instead
        :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 structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        r  z) fetchTransactions() is not supported yet)r  r	  r   r   r  s        r`   fetch_transactionszExchange.fetch_transactions  s=     88./224vNNtww)TTUUrd   c                 *    | j                  ||||      S )z[
 @ignore
        Typed wrapper for filterByArray that returns a list of positions
        r  r^   r  r   r  r  s        r`   r_  z"Exchange.filter_by_array_positions      
 ##GS&'BBrd   c                 *    | j                  ||||      S )z_
 @ignore
        Typed wrapper for filterByArray that returns a dictionary of tickers
        r-  r.  s        r`   filter_by_array_tickersz Exchange.filter_by_array_tickers  r/  rd   c                 $    i }i ||<   |||   |<   |S r   r   )r^   r  r  rC  r  s        r`   create_ohlcv_objectzExchange.create_ohlcv_object  s#    F!%FI
rd   maxEntriesPerRequestc                 T    d }| j                  ||d      \  }}|||k7  r|}|d}||gS )Nr4  rB  r<	  )r^   r/  r4  r8  newMaxEntriesPerRequests        r`   )handle_max_entries_per_request_and_paramsz2Exchange.handle_max_entries_per_request_and_params  sP    "&*.*G*GPVXn*o'#/6MQe6e#: '#' $f--rd   c                    d }| j                  ||dd      \  }}d }	| j                  ||dd      \  }	}d }
| j                  ||dd      \  }
}d }|}| j                  ||d|      \  }}d}g }d}| j                  |d	d
      }| j                  |||      \  }}|
dk(  r|t        | j                  dz         |}||k  r|dz  }	 |
dk(  r||dz
  |d<    t        | |      |d ||      }t        |      }| j                  rYd| j                  |      z   dz   |z   dz   | j                  |      z   }||d| j                  |      z   z  }| j                  |       |dk(  rnd}| j                  ||      }| j                  |d      }| j                  |dd      }|||k  rn t        | |      ||||      }t        |      }| j                  rYd| j                  |      z   dz   |z   dz   | j                  |      z   }||d| j                  |      z   z  }| j                  |       |dk(  rnMd}| j                  ||      }| j                  ||dz
        }| j                  |d      dz   }|||k\  rn||k  r|}|r| j                  |      }|dk(  rdnd}| j                  ||||      S # t        $ r}|dz  }||	kD  r|Y d }~Sd }~ww xY w)NpaginationCallsr  r#  r  paginationDirectionbackwardremoveRepeatedr   untilltillforwardzM pagination requires a since argument when paginationDirection set to forwardr   untilzDynamic pagination call  method  response length z timestamp r  r  )r  r  r7  r   r   r   r  rR  r   r(  r)  r  r  rW   #remove_repeated_elements_from_arrayr  )r^   r/  r  r  r  r8  r4  r<  maxCallsr#  r:  paginationTimestampremoveRepeatedOptioncallsr  errorsr@  r  responseLengthbackwardMessagefirstElementforwardMessager  r   uniqueResultsr   s                             r`   fetch_paginated_call_dynamicz%Exchange.fetch_paginated_call_dynamic  s   88IZ\^_&
!::66<YZ[
F"&*&C&CFFTiku&v#V"-'+'D'DVVUegu'v$f##FHf='+'U'UV\^rtz'{$f9,}'  3B  )B  C  C"'xQJE)&*4 +6*=*Aw4wtV4VTCWY_`H%(]N||*DtG\G\]bGc*cfp*psy*y  }P  +P  SW  Sh  Sh  iw  Sx  +x.:+}t?T?TUh?i/iiO1%*F!..vx@F#'??8Q#?L*.*=*=lKYZ*[')0Cu0L  5wtV4V=PRfhnoH%(]N||)CdF[F[\aFb)beo)orx)x  |O  *O  RV  Rg  Rg  hv  Rw  *w.:*md>S>STg>h.hhN0%*F!..vx@F??8^a5GHD*.*;*;D+*NQR*R')0Cu0LO xX  DDVLMl*a))-sKK  !J&G 's.   BJ) A J) B
J) *AJ) )	K2KKc                 "   d }| j                  ||dd      \  }}d}||k  r3	 |r|dk7  r t        | |      |||||      S  t        | |      ||||      S g S # t        $ r(}	t        |	t              r|	|dz  }||kD  r|	Y d }	~	nd }	~	ww xY w||k  ro=)Nr#  r  r   r  r   )r  r   rW   rV   r   )
r^   r/  r  r  r  r  r8  r#  rH  r   s
             r`   safe_deterministic_callz Exchange.safe_deterministic_call   s    
!::66<YZ[
F
"
+D!D0740E5RXYY0740vNN 	  a!23G!J&G '	 
"s   A A 	BBBc                 \   d }| j                  ||dd      \  }}| j                  |||      \  }}| j                         }	g }
| j                  |      dz  }||z  }|	||z  z
  dz
  }|t	        ||      }nt	        |d      }| j                  |dd      }|\t        t        j                  ||z
        |z        }||kD  r3t        | j                  dz   t        |      z   d	z   t        |      z         t        d
|      D ]L  }|||k\  r nC||	k\  r n<|
j                  | j                  ||||||             | j                  ||      dz
  }N |
}g }t        d
t!        |            D ]  }| j#                  |||         } | j%                  |      }|dk(  rd
nd}| j'                  ||||      S )Nr9  r  rB  r   l   82>r@  r>  z the number of required calls is greater than the max number of calls allowed, either increase the paginationCalls or decrease the since-until gap. Current paginationCalls limit is z required calls is r   r  r  )r  r7  r  r  r{   r  r  r  ceilr   r   r"  r  r  rP  rf  r  r)  rC  r  )r^   r/  r  r  r  r  r8  r4  rD  r  tasksr  stepcurrentSincer@  requiredCallsr   r  r  rM  r   s                        r`   "fetch_paginated_call_deterministicz+Exchange.fetch_paginated_call_deterministic2  s"   88IZ\^_&'+'U'UV\^rtz'{$f##%##I.5**(T/2Q6|U3L|];L##FGV<		55= :T ABMx'   ,c  "c  fi  jr  fs  "s  vK  "K  NQ  R_  N`  "`  a  aq(# 	<A!(=w&LL55fflThjsu{|}88L$7!;L	< q#g,' 	;A&&vwqz:F	;@@Hl*a))-sKKrd   c
                    d }
| j                  ||dd      \  }
}d }| j                  ||dd      \  }}| j                  ||	|      \  }	}d }d}d}g }| j                  |d      }| j                  |d      }||
k  r	 ||| j	                  |      |z   }|||<   d }|dk(  r t        | |      |      }nO|dk(  s|d	k(  r t        | |      ||      }n1|d
k(  r t        | |      ||||	|      }n t        | |      |||	|      }d}t        |      }| j                  rE|dn|}|dz   }dt        |      z   dz   |z   dz   t        |      z   dz   |z   }| j                  |       |dk(  rn| j                  ||      }| j                  ||dz
        }d }t        d|      D ]F  }||z
  dz
  }| j                  ||      }| j                  |d      }| j                  ||      }|D|} n |n&| j                  |d      }|||k  rn|dz  }||
k  r| j!                  |      }|dk(  rdnd}| j#                  ||||      S # t        $ r}|dz  }||kD  r|Y d }~Td }~ww xY w)Nr9  r  r#  r  r   r  r  getLeverageTiersPaginatedr  r  rx   r   zCursor pagination call rA  rB  z cursor r  r  r  )r  r7  r  r^  rW  r   r  rR  r"  r(  r)  r_  r  r  r  rW   sort_cursor_paginated_resultr  ) r^   r/  r  r  r  r8  cursorReceived
cursorSentcursorIncrementr4  rD  r#  cursorValuer   rH  r  r  r  rI  cursorString	iterationcursorMessager  r  r   r  r  cursorlastTimestampr   r  r   s                                    r`   fetch_paginated_call_cursorz$Exchange.fetch_paginated_call_cursorS  s"   88IZ\^_&
!::66<YZ[
F'+'U'UV\^rtz'{$f$$V[9	6;/(l+*&2&*&7&7&D&V)4F:&_,4wtV4V<H::fHX>X4wtV4VVDH994wtV4VYOceklH4wtV4VUDXZ`aH!$X<<*5*=2KL!"QI$=I$NQ[$[^d$dgz$z  ~A  BP  ~Q  %Q  T^  %^  am  %mMHH]+!Q&**68<~~h0BC"q.1 A*Q.2E NN8U;E>>%8D!__T>BF)&, & $ 1 1$ D ,1F
 FA[ (l\ 226:l*a))&%DD  !J&G 's,   <C)H; &A8H; H; 'H; ;	IIIc                 n   d }| j                  ||dd      \  }}d }	| j                  ||dd      \  }	}| j                  |||      \  }}d}
d}g }|
|k  r	 |
dz   ||<    t        | |      ||||      }d}t        |      }| j                  r9|
t        d      z   }d|z   dz   |z   d	z   t        |      z   }| j                  |       |dk(  rn| j                  ||      }|
dz  }
|
|k  r| j                  |      }|d
k(  rdnd}| j                  ||||      S # t        $ r}|dz  }||	kD  r|Y d }~Sd }~ww xY w)Nr9  r  r#  r  r   r   zIncremental pagination call rA  rB  r  r  )r  r7  r   r  rR  r"  r(  r)  rW   rZ  r  )r^   r/  r  r  r  r8  pageKeyr4  rD  r#  r   rH  r  r  rI  r`  incrementalMessager   r  r   s                       r`    fetch_paginated_call_incrementalz)Exchange.fetch_paginated_call_incremental  s   88IZ\^_&
!::66<YZ[
F'+'U'UV\^rtz'{$f(l"#a%w0740@TV\]!$X<<!"SVI)G))SV`)`ci)il)  CF  GU  CV  *V&HH/0!Q&**68<
 FA# (l$ 226:l*a))&%DD  !J&G 's   A4D 
D 	D4D//D4c                     | j                  |d      }|.d|v r| j                  |dd      S d|v r| j                  |dd      S |S )Nr   r  Tr   )r  r"  )r^   r  r  s      r`   rZ  z%Exchange.sort_cursor_paginated_result  sR    *e#||FK>>u}||FD$77rd   fallbackToTimestampc                     i }g }t        dt        |            D ]M  }||   }|r| j                  |g d      n| j                  |d      }|3||vs8d||<   |j	                  |       O t        |      }|dkD  r|S |S )Nr   )r   r  r   r   r   )r  r  r  r  r  )	r^   rx  rj  	uniqueDicuniqueResultr   r  	uniqValuevaluesLengths	            r`   rC  z,Exchange.remove_repeated_elements_from_array  s    	q#e*% 	+A!HEM`**52HIfjfvfvw|  C  gDI$i9.D'(	)$##E*	+ <(!rd   c                    i }t        dt        |            D ]  }||   }| j                  |d      }|h| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }	dt        |      z   dz   |	z   dz   |z   dz   |z   }|||vs|||<    t	        |j                               }
|
S )	Nr   r   r   r~   r  r  t_r   )r  r  r  r"  r  r  )r^   rx  rm  r   r  r   r   r~   r  r  r  s              r`   !remove_repeated_trades_from_arrayz*Exchange.remove_repeated_trades_from_array  s    q#e*% 	)A!HE!!%.Bz((8))%: ,,UK@	''v6C	N*S047#=EKfT~r\'9#(R 	) l))+,rd   c                     | j                  |dd      }|+| j                  ||z        ||<   | j                  |ddg      }||gS )Nr@  r>  )r  rW  r^  )r^   r   rW  r8  
multiplierr@  s         r`   handle_until_optionzExchange.handle_until_option  sU    ##FGV<,,UZ-?@GCLYYv'89F  rd   r
  c                 d   | j                  |d      }|| j                  |d      }| j                  ||| j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j	                  |d      d	      S )
Nr  r  r  openInterestAmountopenInterestValuer  r}  r  )r  r  r  rw  rx  r  r}  r  )r  r  r6  r  r  )r^   r
  r  r  s       r`   safe_open_interestzExchange.safe_open_interest  s    !!(H5>%%fh7F{{8**8\B++HmD"&"2"28=Q"R!%!1!1(<O!P**8[A((:>OOHf5	&
 	 		rd   c                 2    t        | j                  dz         )Nz( parseLiquidation() is not supported yetrp  )r^   r  r  s      r`   parse_liquidationzExchange.parse_liquidation  r  rd   r   c                     g }t        dt        |            D ]*  }||   }| j                  ||      }|j                  |       , | j	                  |d      }	| j                  |d      }
| j                  |	|
||      S )a  
 @ignore
        parses liquidation info from the exchange response
        :param dict[] liquidations: each item describes an instance of a liquidation event
        :param dict market: ccxt market
        :param int [since]: when defined, the response items are filtered to only include items after self timestamp
        :param int [limit]: limits the number of items in the response
        :returns dict[]: an array of `liquidation structures <https://docs.ccxt.com/#/?id=liquidation-structure>`
        r   r  r  )r  r  r{  r  r"  r  r  )r^   r   r  r  r  r  r   r  r8  r  r  s              r`   parse_liquidationszExchange.parse_liquidations  s     q#l+, 	"A OE++E6:FMM&!	" fk2!!&(300NNrd   greeksc                 2    t        | j                  dz         )Nz# parseGreeks() is not supported yetrp  )r^   r~  r  s      r`   parse_greekszExchange.parse_greeks  r  rd   chainc                 2    t        | j                  dz         )Nz# parseOption() is not supported yetrp  )r^   r  rA  r  s       r`   parse_optionzExchange.parse_option  r  rd   currencyKey	symbolKeyc                    i }t        dt        |            D ]i  }||   }| j                  ||      }| j                  |      }| j                  ||      }	| j	                  |	d d d      }
| j                  |||
      ||
d   <   k |S )Nr   rl  r  )r  r  r  r  rM  r  )r^   r  r  r  optionStructuresr   r  r  rA  rQ  r  s              r`   parse_option_chainzExchange.parse_option_chain
  s    q#h-( 	[AA;D))$<J))*5H''i8H%%hdHEF151B1B4SY1ZVH-.	[  rd   c                     i }|d}t        dt        |            D ]]  }||   }| j                  ||      }| j                  |d d |      }	|| j	                  |	d   |      sF| j                  ||	      ||	d   <   _ |S Nrj  r   r  )r  r  r  rM  r-  parse_margin_mode)
r^   r  r  r  r  marginModeStructuresr   r  rQ  r  s
             r`   parse_margin_modeszExchange.parse_margin_modes  s    !Jq#h-( 	^AA;D''i8H%%hdJGFDMM&2BG$L9=9O9OPTV\9]$VH%56	^ $#rd   c                 2    t        | j                  dz         )Nz' parseMarginMode() is not supported yetrp  )r^   r  r  s      r`   r  zExchange.parse_margin_mode!  r  rd   c                     i }|d}t        dt        |            D ]]  }||   }| j                  ||      }| j                  |d d |      }	|| j	                  |	d   |      sF| j                  ||	      ||	d   <   _ |S r  )r  r  r  rM  r-  parse_leverage)
r^   r  r  r  r  leverageStructuresr   r  rQ  r  s
             r`   parse_leverageszExchange.parse_leverages$  s    Jq#h-( 	YAA;D''i8H%%hdJGFDMM&2BG$L7;7J7J4QW7X"6(#34	Y "!rd   c                 2    t        | j                  dz         )Nz% parseLeverage() is not supported yetrp  )r^   r}   r  s      r`   r  zExchange.parse_leverage0  r  rd   conversionsfromCurrencyKeytoCurrencyKeyc                    | j                  |      }g }d }	d }
t        dt        |            D ]  }||   }| j                  ||      }| j                  ||      }|| j	                  |      }	|| j	                  |      }
| j                  | j                  ||	|
      |      }|j                  |        | j                  |d      }d }|| j	                  |      }|d   }|| j                  |||      S | j                  |d|      }| j                  |d|      }| j                  ||      }| j                  |||      S )Nr   r  r,  fromCurrency
toCurrency)r	  r  r  r  r  r  parse_conversionr  r"  r  r  r)  )r^   r  r,  r  r  r  r  r8  r  r  r  r   r  fromIdtoId
conversionr  rA  fromConversiontoConversionboths                        r`   parse_conversionszExchange.parse_conversions3  s\   mmK0
q#k*+ 		&ANE%%e_=F##E=9D!#11&9!//5
T%:%:5,PZ%[]cdJMM*%		& fk2))$/HF#D<--feUCCE~~flDA  >))$u==rd   r  r  r  c                 2    t        | j                  dz         )Nz' parseConversion() is not supported yetrp  )r^   r  r  r  s       r`   r  zExchange.parse_conversionN  r  rd   datec                 L    |dd }|dd }|dd }d|z   dz   |z   dz   |z   dz   }|S )Nr   r  r  r  20r  z
T00:00:00Zr   )r^   r  yearmonthdayreconstructedDates         r`   convert_expire_datezExchange.convert_expire_dateQ  sL    AayQq	1Qi 4K#-5;cALP  rd   c                     |dd }|dd }d }|dd }|dk(  rd}nW|dk(  rd}nO|d	k(  rd
}nG|dk(  rd}n?|dk(  rd}n7|dk(  rd}n/|dk(  rd}n'|dk(  rd}n|dk(  rd}n|dk(  rd}n|dk(  rd}n|dk(  rd}||z   |z   }|S )Nr   r  r  r  01JAN02FEB03MAR04APR05MAY06JUN07JUL08AUG09SEP10OCT11NOV12DECr   )r^   r  r  monthRawr  r  r  s          r`   %convert_expire_date_to_market_id_datez.Exchange.convert_expire_date_to_market_id_dateY  s    Aay!91QitEEEEEEEEEEEE%K$.  rd   c                     ddddddddd	d
ddd}t        |      dk(  rd|z   }|dd }|dd }| j                  ||      }|dd }||z   |z   }|S )Nr  r  r  r  r  r  r  r  r  r  r  r  )r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  )r  r  )r^   r  monthMapppingr  	monthNamer  r  r  s           r`   convert_market_id_expire_datez&Exchange.convert_market_id_expire_datez  s     
 t9>:DAay1I	  	:1Qi%K$.  rd   c                 ~    | j                   d   r| j                  |g|||      }|S t        | j                  dz         )  
        fetches the history of margin added or reduced from contract isolated positions
        :param str [symbol]: unified market symbol
        :param int [since]: timestamp in ms of the position
        :param int [limit]: the maximum amount of candles to fetch, default=1000
        :param dict params: extra parameters specific to the exchange api endpoint
        :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
        r  z, fetchPositionHistory() is not supported yet)r  fetch_positions_historyr   r   )r^   r  r  r  r8  r]  s         r`   fetch_position_historyzExchange.fetch_position_history  sD     88+,44fXueVTItww)WWXXrd   c                 2    t        | j                  dz         )r  z- fetchPositionsHistory() is not supported yetrp  r  s        r`   r  z Exchange.fetch_positions_history  s     477%TTUUrd   rC  c                 2    t        | j                  dz         )Nz/ parseMarginModification() is not supported yetrp  )r^   rC  r  s      r`   parse_margin_modificationz"Exchange.parse_margin_modification  r  rd   c                    g }t        dt        |            D ]f  }||   }| j                  ||      }| j                  |d d |      }	|| j	                  |	d   |      sF|j                  | j                  ||	             h |S r  )r  r  r  rM  r-  r  r  )
r^   r  r  r  r  marginModificationsr   r  rQ  r  s
             r`   parse_margin_modificationsz#Exchange.parse_margin_modifications  s     q#h-( 	YAA;D''i8H%%hdJGFDMM&2BG$L#**4+I+I$PV+WX	Y #"rd   c                 2    t        | j                  dz         )a*  
        fetches a transfer
        :param str id: transfer id
        :param [str] code: unified currency code
        :param dict params: extra parameters specific to the exchange api endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        z% fetchTransfer() is not supported yetrp  r  s       r`   fetch_transferzExchange.fetch_transfer  s     477%LLMMrd   c                 2    t        | j                  dz         )a  
        fetches a transfer
        :param str id: transfer id
        :param int [since]: timestamp in ms of the earliest transfer to fetch
        :param int [limit]: the maximum amount of transfers to fetch
        :param dict params: extra parameters specific to the exchange api endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        z& fetchTransfers() is not supported yetrp  r  s        r`   fetch_transferszExchange.fetch_transfers  s     477%MMNNrd   subHash	unsubHashc                 
   ||j                   v r|j                   |= ||j                   v r|j                   |= ||j                  v r-t        | j                  dz   |z         }|j	                  ||       |j                  d|       y )NrH  T)subscriptionsr  r   r   rejectresolve)r^   r  r  r  r  s        r`   clean_unsubscriptionzExchange.clean_unsubscription  sy    ,,,$$Y/f***$$W-fnn$$TWWs]W%<=EMM%)tY'rd   subscriptionc                    | j                  |d      }| j                  |dg       }t        |      }|dk(  r| j                  |dg       }t        dt        |            D ]\  }||   }| j                  |d      }| j                  |d      }	|| j                  v s;|	| j                  |   v sM| j                  |   |	= ^ y |dkD  rt        dt        |            D ]m  }||   }|dk(  r|| j
                  v s| j
                  |= *|dk(  r|| j                  v s>| j                  |= L|d	k(  sR|| j                  v sa| j                  |= o y |d
k(  r_t        | j                  j                               }
t        dt        |
            D ]#  }|
|   }|| j                  v s| j                  |= % y |dk(  r_t        | j                  j                               }t        dt        |            D ]#  }||   }|| j                  v s| j                  |= % y |d	k(  r_t        | j                  j                               }t        dt        |            D ]#  }||   }|| j                  v s| j                  |= % y y )Ntopicr  r   r  r   r   r   rl  r>  myTradesr  )r  ri  r  r  r   r   r   r   r  r  r(  r  )r^   r  r  r  r  symbolsAndTimeFramesr   symbolAndTimeFramer  r  r(  r   orderSymbolsorderSymboltickerSymbolstickerSymbols                   r`   clean_cachezExchange.clean_cache  sr     w7..y"=GG#'>>,@VXZ#[ 1c"678 ;%9!%<"))*<a@ ,,-?C	T[[( DKK$77 KK/	:; Q1c'l+ 
1 H$, KK/k)0 OOF3h&- LL0
1 
" DMM..01q#d), /Aq'Cdmm+ MM#./ ("#DKK$4$4$67q#l"34 5A".q/K"dkk1 KK45 (" $T\\%6%6%8 9q#m"45 7A#0#3L#t||3 LL67 #rd   r   )r=  NN)r   )   )r   )Fr   )F)z~()*!.')r  )r  T)rx   )rH  )md5r  )r  )r  NF)r3   )T)r   r   r  )NNNN)Nr  F)NNr  F)NNNr  F)r  r4  r  lr  rI  F)NN)NNTFF)Nr  r  r   r   r  )Nr  NNFr  )NNTTr  )r  r   r  )Nr  NN)FN)NNNF)NNN)r   (  rY   ra   rb   __doc__r   rU   r_  r&  ra  rb  rc  r`  r  rD  r   aiohttp_proxyssl_contextr   r   r   r   tcp_connectoraiohttp_socks_connectorsocks_proxy_sessionsrF  rX  validateClientSslr   rR  r  r  r  rE  r  rC  loaded_feesr/  r>  r@  parseJsonResponse	throttlerr  rl  r  r  r  rm  r  r  r  rn  r  r  r  ro  r  r  r  r   r!  r  r  r  r  r  r  
userAgentsr   r   r  r  rE  r}
  r   r   r   r   r   r   r   r   r   r  r2  r   r   r   r   r   r   r
   r	   r   r  r   r   r   r  triggerOrdersr   r  r   r   r   r   r   r   base_currenciesquote_currenciesr   r   r  ra  r]  rG  rD  r  r  r   rK  r   rL  r  r
  r8  r   r,   __annotations__handleContentTypeApplicationZiprc  r  lastRestPollTimestamprestRequestQueuerestPollerLoopIsRunningrateLimitTokensrateLimitMaxTokensrateLimitUpdateTimer[  r]  r_  r\  r^  r`  r  r  r  r  r  r  r  rJ  r   r!   r   r   r   r   r  r  staticmethodr  r$  r(  r4  r<  rw  rZ  rg  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r   r+  r   r  r   r  r  r  r  r  r"  r%  r)  r-  r0  r4  r9  rB  rJ  rT  rW  r[  r^  rb  rd  rf  rh  rl  ro  rq  ru  rn  r  rt  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r!  r/  r2  r:   r6  r9  r5   rl  rp  r:  ry  rT  rj  r	  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r[  r  r  r  r  r  ro  r  r  r  rc  r   r  r  r	  r  r  r  r  r  r  r  r   r#  r&  r(  r"  rJ  r\  rO   r   rP   r$   r@  rQ  rU  r   r   r\  r_  ra  rd  rg  ri  rn  rk  r|  r~  r  r+   rN  rO  rP  r  rQ  r  r  r/  rQ   r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r-   r  r  r  r   r  r'  r)  r+  r-  r0  r4  r9  r;  r=  r)   r@  r#   rD  rI  rM  rO  rQ  rU  rX  rZ  r\  r_  ra  rd  rf  rh  rj  rl  rn  rp  ru  rw  ry  r{  r}  r  r(  rn   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rW  r  r  r  r  r   r  r  r  r  r  r   r  r  r+  r  rG  rP  r  r  r  r  r  r  r  r  r  rd  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r
  r  r  r  r  r  r  rs  r'  r+  r/  r4  r:  r<  r7  rE  rI  r/   rK  rR  rU  r\  r`  rc  rb  rh  rk  ro  r  r#  r  r  r  r{  r  r  r  r  r  r  r  r  r  r  r  rW  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  ry  r  rM  r  r  r	  r	  r	  r	  r
	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r"	  r$	  r  r0	  r$  r6	  r:	  r=	  r@	  rE	  rB	  r  rb  r  rR	  rV	  rY	  r[	  rP	  rU	  rX	  ra	  rc	  re	  rg	  rj	  rl	  rn	  rr	  r  rx	  rz	  r|	  r~	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r(   r	  r	  r  r  r  r	  r	  r	  r.   r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r
  r
  r
  r
  r	
  r
  r
  r
  r
  r
  r"   r8   r  rA  r  r
  r1
  r3
  r7
  r:
  r=
  r?
  rC
  rE
  rH
  rJ
  rM
  rO
  rR
  rT
  rW
  rY
  r[
  r]
  rc
  r`
  r  rg
  ri
  r6  rm
  rq
  rw
  r{
  r~
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r  r  rg  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r  r
  r
  r
  r
  r
  r
  r
  r
  r
  r   r  r  r
  r  r  r  r  r  r  r!  r$  r'  r)  r+  r_  r1  r3  r7  rN  rP  rW  rd  rh  rZ  rC  rr  ru  ry  r{  r}  r  r  r  r*   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   rd   r`   rA   rA      s@   	BDIGI
CEOIGLMKIGM"FFGGGEJK 	
 	
D  $
 
	K CD
CI EHIIJJKJKIJGHHILN G C QJ
 GFeIGHFFH
CIJMEEMIJ 

 

 

 
F&}~ 	  	#	
 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#  	#!" 	##$ $##"""3N6 GLJFMNHFLFGLHOJG HIF  CH"MK$(!FC&+#J #O!" $ MNNRO 
 K13 AR ARFZ'  )%-~$@_
 	 	   _ _ Y Y Y Y ! !   S S Z Z ` ` a a g g g g b b v v \ \ ` `
   B B ) ) ) ) ! !   Z Z = = 
 
 W W
 @ @   ; ; ; ; ! ! 2 2     W W 
 
 
 
 > > 5 5   - - 	 	 j j Q Q   " "   1 1   5u R R +- J J H H.  > > 0 0       
 
 K K . . 	 	 " " ' ' ' '     ' ' * *   ' ' I I P P
 5 5 4 4 F F 1 1  @ 
 
 (/u       M M = = , , = = 4 4 '/B B B> q q ' ' Y Y 
 
,  * / /
     ; ; +
 +
Z D D 4 4 L L
 : :
 & & & & F F  0
6 #( 5> $& + ') 

  * 8B I IC\W  
    / / , , ) ) < </ F F  &!Ur  B?!@R&<=N @B 3 B @B 3 J~
# ~
@
	$y/ 	QU 	HI HY HVZ HA A$ A$y/ QU A A$ AHI HS HPT H$y/ QUVYQZ N) N3 NVZ[^V_ NGy GS	 G4G( (y (aj (  H (
C  83 +3 +3C +3Z1<jS 3 T&\ # 9 os 4O4< O OSV Odm O$Hf Hi Hdg Hwz H*. .6 %-U2VZhl c PS be  %' N 6:UW L3 Ls L# L 9=4XZ Nc N# NS N <@d[] R RS R R
 OSaenp \d3i \ \[^ \ ?CQU^` TC T T3 T
 RVdhqs ^c ^3 ^^a ^ 6:UW L3 Ls L# L 35 Nc N IM[_hj VS	 V# VUX V FH X49 X LP^bkm X49 XS XX[ X IM[_hj VS	 V# VUX V [_mqz| UDcO UTW Ugj U XZ WtDI W MQY[ YDI Yc Y JL [tCy [ 8<B VW V :>b Os O3 O =A Q# Qc Q 57 T T 59 Q' Q 8<B 	 :>b Os O3 O 79 Q# Q !# J 7;2 SG SN$ NL4 LL4 L LTh TK Kv KQT QX QNt Nx NMT MQt Qx QK Kv K /1 V 24 YY Y 7;2 SG SNt NV NXv XT$ T TXt XV XMD M& MMD M& MR$ R R/F / 6:" R7 R :>b Vw V 68 Q Q >@ R49 R JL 9tCy 9 [] IS I% Ic Ic I DHPR IS I% I# I 8: U3 U 9=R LS L# L 24 RS R 26b Ow O =A P Pc P =? J Je J @B MC M M =? J Je J DHPR TS TS T <@RVeix|  FH [S [C [_b [ru [ =Adaetx  BD 
]c 
] 
][^ 
]nq 
] >B" N# Ns N DF _s _ BFTXgktv Y# Yc Yad Y 79 R# R 7;2 SG S   G ,. T$"U : :i :s :
& y PS -"#xJ$s $ $c $L$ $B

&
v &
 &
Pa aFMD M^Pd% %be %w{ %
 D  DZ Zf Zx =Atbfoq &P6 &P6 &P &P\_ &PP jqy{ /
C /
s /
# /
u /
UZ /
bD & " f ,S BS U E JX6$ 6 6p BD Kc K5 K CE Ms ME M SU PC Ps PE P DF N NU N TV QS Q QU Q EIQS B# Bu Bc B DHPR  e S  26DW[df U# Uc UQT U 59tZ^gi vS v vTW v 26DW[df K# Kc KQT KDe4E &De4E 0+,Z' ' 7 g C <'  9 hq  =A # c  
 
4 
.c . .`C c (-" "mn6+ +i +y +

& 

# 

# 

  AJ 

  [d 

  xA 

I4< I IPS Icf Ivy I  IM IS 49 : 6:%PR 7 d . JNVX Pc PT#Y P :< tCy  @DRVeirt O49 Of OC O_b O PTbfuy  CE OtCy OH O\_ Oor O JN\`os|~ Oc Oh OVY Oil O 7;\`ik O8 O3 OVY O  :S :& S PS F  QT dg 6 c QT V  RU eh  3 d & c s bf !T !D !WZ !jm !  CG !"
	 Kc K3 Kos K  VZ KI $ '/uRX\jnwy  RU dg : (0bY]koxz M MSV Meh M $) 	*4; *3 *e *`e *XJSV Jfi J VZbd Os OC O Os O W[ce P PS P% PPS P cgoq Q3 Q Q9 Qe Q\_ Q `drv  @B LS L# LY Li LY\ Llo L cguy  CE O OS O	 O O\_ Oor O 24 NS N 57 P P ,0 NS N 26DW[df Ow Oc OQT O =Atbfoq C' C C\_ C >@ X X AC XC X 26b Ow O 59 O' O 7;2 SG S 26b Nw N 15DW[jnwy T# Tc TQT Tdg T (,$TZ\ L LC Ls L 7;2 QS Q Qi 	 en  x #C # #RU #jm #J p $& M ') OM $& M 24  )+ : )+ : *, ; #% L 79 ;# ;
 7;2 UG U <@ Y Y <> +s + 24 Z 9; C  >@  v 3 TW ,
  
 c 
 X[ 
 jm 
 ' ' ' OS[]lp % %V %B BFb_c !S !* EGUY ] ])+
  3 PS fj z} 
 MO 2 02 P3 P 46 Ts T 35 Rc R 02 L3 L 04B MW M 48 P P 37r M M 48dSU P P P 26b Nw N 04B MW M 37r O O 26b Kc K3 K 59 M Mc M 9=R S #  13 j gksu L3 Li Ly LRW L`c L W[ce Ss Sc S3 SPS S 8<B Rc R R 7;\`ik Y Y3 YVY Y 15R R# R w{  LP  gk  tv Z3 Zi Zy Zbg Zps Z, z~  OS  jn  wy \c \ \R[ \ej \sv \, x|  NR  im  vx [C [y [PY [ch [qt [, {  QU  lp  y{ ]s ]) ]S\ ]fk ]tw ], _a ZC Zy ZPU Z RT 
] 
]5 
] SU 
^ 
^E 
^ bd \s \) \SX \ os  IM  VX S3 Si Sy SZ_ Shk S  CF S& rv  LP  Y[ Uc U U) U]b Ukn U  FI U& qu  LP  Y[ TS T	 T T\a Tjm T  FI T& tx  OS  \^ V V9 VI V_d Vmp V  IL V& sw  PT  ]_ Vs V) V9 V^c Vlo V  JM V& vz  SW  `b X# XY Xi Xaf Xor X  MP X& FJ  ^b  tx  AC e# eY e^g eqv e  @C e  X[ e  nq e4 C  W[  mq  z| $3 $i $W` $jo $x{ $  QT $  gj $L IM  ae  w{  DF gS gPY gaj gty g  CF g  [^ g  qt g4 @B MD$6 M >@ K$|"4 K jnvx Nc N N) NUZ Ncf N 37r Ls LC L 6:" N# Ns N >B" ODI Os O /32 P P <> Us U SU W5H0I W 26b R3 R 24 k *.Dt\^ L3 Lc L L
 -1tRV_a Nc N NC N 9=4^bkm QS Q# QS QX[ Q *.Dt\^ L3 Lc L L /3TXac P P3 Pc P 26DW[df R3 Rc RQT R 154VZce R# RS RPS R >BPTcgpr ]s ]# ]]` ] 48dY]fh TS T TSV T -1tRV_a Nc N NC N 37TX\eg TC Ts TRU T <@d[] R RS R R 04$UYbd P PC Ps P -1tRV_a Nc N NC N 02 L3 L 46 Qs Q 02 L3 L MQY[ RC R Rc R 6:[_hj 	Ys 	Y# 	YUX 	Y ,0dQU^` NS N N3 N /3TXac Q Q3 Qc Q -1tRV_a Pc P PC P 04$UYbd S SC Ss S 8<$]ajl X XC XWZ X 37TX\eg TC Ts TRU T =A NS N	 N *, R =A O# Oc OOf O 79 X# X*
 
C C
NS NLS L"Z3 Z cg $ df O OI Ou OUZ O gi RC Ry R% RX] R ]aik P# PY P PVY P `dln SS S	 S5 SY\ S WY PS P% P P Z\ S SU S5 S XZ Qc Q5 Q Q [] T Te TE T JL Pc P5 P MO S Se S KM Qs QE Q NP T# Tu T} } # ys yq# q
/487I 7c 77 7d9o 7c 7% % )S )& +- .EC E ?A ]# ] qu} KS K	 K K\a Kjm K tx  AC N N9 NI N_d Nmp N sw  @B Ks K) K9 K^c Klo K vz  CE N# NY Ni Naf Nor N lp  FJ  SU K K9 KI KW\ Keh K  @C K os  IM  VX N3 Ni Ny NZ_ Nhk N  CF N ~@ Nc N NE NZ_ Not N AC Q QI Qu Q]b Qrw Q qs Ns N) NU Nbg N tv Q# QY QPU Qej Q S  H  j# jS j`c jjc jY\ jSDI SUX Shk S BFb !@T#Y !@F 9=R &@g &@P CGPT]_ 	 	v P PO OC OPS O O O\_ O C    3  cf  Q3 Q QEW ET4 T TO3 O^a O*s *gk **#6 OQ $ 2 ik d TX be 4 48 P P )+ Q ,. S 57 , , /1 WRF R?g ?O O\_ O 68 U U  :< YS Y  26DW[df Sc SQT S$ 8<$]ajl T TC TWZ T$ @DRVeirt [ [C [_b [$ +- " XZ -# -"
v 
vc 
vWZ 
v#7 #.X X
,L LO OC O&w d6l C SV fi y|  .2SW`b Vs V# VS VCi CCI C# #  bfnp . .[^ . GKY]lpy{  Z^  os CL3 CL CLSV CLfi CL  TW CLJ BFTXgk  C  LN c 3 c ad x{ $ MQ_crv  JN  WY  pt L Lc LY\ Llo L  DG LB FJQU]ajl  ~B  OS  ei  @D <E# <Es <E| KOVZbfoq{  W[ Es EC E>d "!s !4  QV QOtDz O6 OY\ Olo O&L4 L LL$ L( L6 L	 4< 	 c 	 ]` 	 
$4< 
$$s) 
$_b 
$  xB 
$PD P& P
"V 
"tCy 
"\_ 
"t~ 
"Nt NV N EIae  }A  PT  cg  pr >T#Y >c >[^ >vy >  JM >  ]` >6P4 Px P\d P! !!# !B!# !4 @DRV_a YS Y YC Y :>D_cln 	Vw 	Vc 	VY\ 	VXd XF X#4< #' #eh #  ~H # 37r N NC N +/TPT]_ 	OC 	Os 	O# 	O(C (C (-7 -7rd   )r  r  ccxt.base.errorsr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   ccxt.base.decimal_to_precisionr   r   r   r   r   r   r   r   r   r   ccxt.base.preciser    ccxt.base.typesr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   cryptography.hazmatr0   cryptography.hazmat.primitivesr1   )cryptography.hazmat.primitives.asymmetricr2   r3   ,cryptography.hazmat.primitives.serializationr4   ccxt.static_dependenciesr5   r6   axolotl_curve25519rl  ImportError!ccxt.static_dependencies.ethereumr7   r8    ccxt.static_dependencies.msgpackr:   ,ccxt.static_dependencies.starknet.ccxt_utilsr;   .ccxt.static_dependencies.starknet.hash.addressr<   /ccxt.static_dependencies.starknet.hash.selectorr=   ,ccxt.static_dependencies.starknet.hash.utilsr>   r?   2ccxt.static_dependencies.starknet.utils.typed_datar@   r)  apexpro.zklink_sdkr3  __all__r   r   r  r  r  r  r}  email.utilsrB   r  r  r  r  r9  r:  r  r  numbersrC   r2  requestsrD   requests.utilsrE   requests.exceptionsrF   rG   rH   rI   rJ   rd  sslrK   r  r   r  decimalrL   rM   wsgiref.handlersrN   urllib.parseparserA  typingrO   rP   rQ   JSONEncoderrS   r/  rA   r   rd   r`   <module>r$     s     + ) ) 0 + + 1 + ) . & ) . , ' ( 1 - @ L  L  L ; % ~  ~  ~  ~  ~
 ) 1 F M
 + +&
 2 5 2 \ J R ` ^+         !    	 
	     	  - C  C       - !  ^d&& ^i7v i7a  E   J:  		s6    G# G1 G> #G.-G.1G;:G;>HH