
    ei                       d Z ddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZmZ ddlmZmZmZ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! ddlm"Z"m#Z#m$Z$m%Z%m&Z&m'Z' ddl(m)Z*m+Z+ dd	l,m-Z-m.Z. dd
l/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5m6Z6 	 ddl7m8Z9 n# e:$ r dZ9Y nw xY wddgZ;	 ddl<m=Z= ddl>m?Z? n# e:$ r dZ=dZ?Y nw xY w G d de*          Z)dS )z4.5.46    N)AnyList)IntStrNumStrings)	Throttler)	BaseError	BadSymbol
BadRequestBadResponseExchangeErrorExchangeNotAvailableRequestTimeoutNotSupportedNullResponseInvalidAddressRateLimitExceededOperationFailed)ConstructorArgs	OrderType	OrderSideOrderRequestCancellationRequestOrder)ExchangeArgumentsRequired)inflategunzip)Client)Future)	OrderBookIndexedOrderBookCountedOrderBook)ProxyConnectorBaseExchanger   )PushDataV3ApiWrapper_pb2)MessageToDictc                   p    e Zd ZdZdddZdZdZi ZdZi fde	f fd	Z
d
 Zd ZdmdZdmdZd Zd Zej        dk    rd Zd Zd Zd Zd Zd ZdndZd Zdi fdZdi fdZdodZi fdZi fdZdddi fd Z di fd!Z!d" Z"d# Z#d$ Z$e%d%             Z&e%d&             Z'i dfd'Z(i dfd(Z)i dfd)Z*d* Z+d+ Z,d, Z-dpd-Z.dpd.Z/dmd/Z0d0 Z1d1 Z2d2 Z3di fd3Z4d4 Z5d5 Z6d6 Z7i fd7Z8ddi fd8e9d9e:d:e:fd;Z;ddi fd8e9d9e:d:e:fd<Z<ddi fd8e9d9e:d:e:fd=Z=ddi fd>e>e9         d9e:d:e:fd?Z?ddi fd8e9d9e:d:e:fd@Z@ddi fd>e>e9         d9e:d:e:fdAZAddi fd8e9d9e:d:e:fdBZBdi fd8eCfdCZDi fd8e9fdDZEddi fd>e>e9         d9e:d:e:fdEZFi fd>e>e9         fdFZGddi fd>e>e9         d9e:d:e:fdGZHddi fd>e>e9         d9e:d:e:fdHZIddi fdIe>e>e9                  d9e:d:e:fdJZJi fdIe>e>e9                  fdKZKdi fd>e>e9         d:e:fdLZLi fd>e>e9         fdMZMdi fd>eNfdNZOi fd8e9fdOZPi fd8e9fdPZQdi fd>eNfdQZRdi fdReNfdSZSdi fd8e9d:e:fdTZTdi fd8e9d:e:fdUZUi fd8e9fdVZVdi fd>eNfdWZWdi fdXZXdi fd8e9d:e:fdYZYi fd8e9fdZZZi fd[Z[di fd>eNfd\Z\i fd]Z]i fd^Z^di fd>eNfd_Z_di fd>eNfd`Z`di fd>eNfdaZai fd8e9fdbZbdi fd>eNfdcZcdi fd>eNfddZdi fd>e>e9         fdeZei fdfe9dgefdhe9die9fdjZgdi fdfe9dgefdke9dleCfdmZhi fdfe9fdnZidi fdoejd8eCfdpZki fd8e9fdqZldi fd>eNfdrZmdi fdsend8eCfdtZoi fd8e9dgeffduZpi fd8e9dgeffdvZqi fd8e9dgeffdwZrdi fd8e9dxeCfdyZsddddi fd8eCdxeCd9e:d:e:fdzZtddddi fd8eCd{eCd9eud:eufd|Zvdi fd}e9d8eCfd~Zwi fdfe9fdZxdddi fd8e9dxe9d9e:d:e:fdZyi fd8e9fdZzdi fd>eNfdZ{i fdZ|i fdZ}i fdfe9dgeffdZ~i fdfe9dgeffdZi fd8e9dfe9dgeffdZi fdfe9dgeffdZi fd8e9dfe9dgeffdZdi fdfe9dgefd8eCfdZdi fdfe9dgefd8eCfdZdddi fd8e9dxe9d9e:d:e:fdZdddi fd8e9dxe9d9e:d:e:fdZdddi fd8e9dxe9d9e:d:e:fdZdddi fd8e9dxe9d9e:d:e:fdZdddi fd8e9dxe9d9e:d:e:fdZdqdZdi fd8e9d:e:fdZddi fd>eNfdZddi ddi fdededefdZddi ddi fdededefdZdi fdZdi fde9d8e9dgefdeufdZdi fde9d8e9dgefdeufdZdi fde9d8e9dedgefdeuf
dZddi fde9d8e9d{ededgeudeufdZddi fde9d8e9d{ededgeudeufdZddi fde9d8e9d{ededgeudeufdZi fd8e9fdZi fd8e9fdZdi fd8eCfdZdddi fd>eNd9e:d:e:fdZdddi fd>eNd9e:d:e:fdZi fd8e9fdZi fd8e9fdZdi fd>eNfdZdi fd>eNfdZdi fd>eNfdZdi fd>eNfdZddddi fdfeCd8eCd9e:d:e:fdZdddi fdfeCd9e:d:e:fdZdi fde9dfeCfdZi fdZi fdZi fdZi fdZi fdZi fdZi fdZi fdZi fdfe9fdZdi fdReNfdZdi fdReNfdZi fdfe9fdZi fdfe9fdZi fd8e9fdZi fd8e9fdZi fd8e9fdÄZi fd8e9fdĄZi fd8e9fdńZdi fd>eNfdƄZdi fd>eNfdǄZdi fd>eNfdȄZdi fd>eNfdɄZdi fd>eNfdʄZddi fd>eNd:e:fd˄Zdi fd>eNfd̄Zdi fd>eNfd̈́Zdi fd>eNfd΄Zi fd8e9fdτZdi fde9d8eCfdЄZdi fde9d8eCfdфZdi fde9d8eCfd҄Zdi fde9d8eCfdӄZi fdԄZdi fd8e9d{ededgefdeuf
dՄZi fd8e9dedgefdeffdׄZdi fde9de9de9dgeufdڄZdi fde9dfeCfdۄZdddi fdfeCd9e:d:e:fd܄Zdi fd8eCfd݄Zi fd8e9fdބZdi fd>eNfd߄Zi fd8e9fdZdddi fd8e9d{ededgefdeudeudeufdZdddi fd8e9d{ededgefdeudeudeufdZdddi fd8e9d{ededgefdeudeudeufdZdddi fd8e9d{ededgefdeudeudeufdZi fd8e9dedeffdZi fd8e9deffdZi fd8e9deffdZi fd8e9dedeffdZddi fd8e9d{ededgefdeudeufdZddi fd8e9d{ededgefdeudeufdZddi fd8e9d{ededgefdeudeufdZddi fd8e9d{ededgefdeudeufdZddi fd8e9d{ededgefdeudeufdZddi fd8e9d{ededgefdeudeufdZdddi fd8e9d{ededgefdeudeudeufdZdddi fd8e9d{ededgefdeudeudeufdZi fde>e         fdZi fde>e         fdZi fde>e         fdZi fde>e         fdZdi fd8e9d{ededgefdeuf
dZdi fde9d8eCfd Zdi fde9d8eCfdZdi fde9d8eCfdZdi fde9d8eCfdZdi fde9d8eCfdZdi fde>e9         d8eCfdZdi fde>e9         d8eCfdZdi fde>e9         d8eCfd	Zdi fd8eCfd
Zdi fd8eCfdZdi fd8eCfdZi fde:fdZi fde>e         fdZdi fd8eCfdZi fdefdZdddi fd8eCd9e:d:e:fdZdddi fd8eCd9e:d:e:fdZdddi fde9d8eCd9e:d:e:fdZdddi fd8eCd9e:d:e:fdZdddi fd8eCd9e:d:e:fdZdddi fd8eCd9e:d:e:fdZdddi fd8eCd9e:d:e:fdZdddi fd8eCd9e:d:e:fdZdddi fd8eCd9e:d:e:fdZ dddi fd8eCd9e:d:e:fdZdddi fd8eCd9e:d:e:fdZdddi fd8eCd9e:d:e:fdZddi fd8e9d9e:d:e:fdZdddi fd8eCd9e:d:e:fd Zdddi fd8eCd9e:d:e:fd!Zi fd8e9fd"Zdi fd>eNfd#Zi fdfe9fd$Z	i fd8e9fd%Z
di fde9de9dgeufd&Zdddi fdfeCd9e:d:e:fd'Zdddi fdfeCd9e:d:e:fd(Zdddi fdfeCd9e:d:e:fd)Zdddi fdfeCd9e:d:e:fd*Zdddi fdfeCd9e:d:e:fd+Zdddi fd8eCd9e:d:e:fd,Zdddi fd8eCd9e:d:e:fd-Zdi fd8e9defd.Zi fd/Zdi fd8e9d:e:fd0Zi fdfe9fd1Zi fdfe9fd2Zi fd8e9dedgefdeffd3Zi fd8e9dedgefdeffd4Zdi fd8e9dedgefdeufd5Zdi fd8e9dedgefdeufd6Zi fd8e9dgefdeffd7Zi fd8e9dgefdeffd8Zi fd8e9dgefdeffd9Zi fd8e9dgefdeffd:Zi fd8e9dgeffd;Z i fd8e9dgeffd<Z!i fd8e9dgeffd=Z"i fd8e9dgeffd>Z#i fd?Z$i fd8e9fd@Z%di fd8e9d{ededgefdeuf
dAZ&di fd8e9d{ededgefdeuf
dBZ'di fd8e9d{ededgefdeuf
dCZ(di fd8e9d{ededgefdeuf
dDZ)ddi fd8e9d{ededgefdeudeufdEZ*ddi fd8e9d{ededgefdeudeufdFZ+i fd8e9dedgefdefdeff
dGZ,i fd8e9dedgefdefdeff
dHZ-i fd8e9dedgefdeffdIZ.i fd8e9dedgefdeffdJZ/i fdKe9fdLZ0di fd>eNfdMZ1i fdNZ2i fdOZ3i fd8e9fdPZ4i fdQZ5i fd8e9fdRZ6i fd8e9fdSZ7dddi fd8e9dxe9d9e:d:e:fdTZ8dddi fd8e9dxe9d9e:d:e:fdUZ9dddi fd8e9dxe9d9e:d:e:fdVZ:dddi fdfeCd9e:d:e:fdWZ;dddi ddfdXe9d8eCd9e:d:e:dYe:f
dZZ<ddddi fdXe9d8eCd9e:d:e:dxeCf
d[Z=ddddi dfdXe9d8eCd9e:d:e:dxeCf
d\Z>dddi ddddfdXe9d8eCfd]Z?dddi ddfdXe9d8eCfd^Z@ddi fd8e9d9e:d:e:fd_ZAd` ZBdddi fd>eNd9e:d:e:fdaZCdi fde9dfeCfdbZDdddi fdfeCd9e:d:e:fdcZEdi fd8e9dxe9fddZFi fd8e9fdeZGdi fd>eNfdfZHdi fdfe9dgefdke9dleCfdgZIdi fd8eCfdhZJi fde>e         fdiZKdddi fdje9d8eCd9e:d:e:fdkZLdi fd>eNfdlZM xZNS (r  r   F   i0u  )maxPingPongMisses	keepAliveNT   configc                    d|v r|d         | _         |                    d| j                  | _        |                    d| j                  | _        d|v| _        |                    dt          j                              | _        d | _        t          t          |                               |           d | _        d| _        d S )Nasyncio_loopaiohttp_trust_envverifysessioncafileF)r0   getr1   r2   own_sessioncertifiwherer4   	throttlersuperr   __init__markets_loadingreloading_markets)selfr.   	__class__s     ^/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/base/exchange.pyr;   zExchange.__init__O   s    V## &~ 6D!',?AW!X!Xjj4;77$F2jj7=??;;h&&v...#!&    c                 8   K   |                      |||||          S N)load_lighter_library_helper)r>   pathchainId
privateKeyapiKeyIndexaccountIndexs         r@   load_lighter_libraryzExchange.load_lighter_library[   s#      //gz;XdeeerA   c                     | j         S rC   )r0   r>   s    r@   get_event_loopzExchange.get_event_loop^   s      rA   c                 D    t          | j        | j                  | _        d S rC   )r	   tokenBucketr0   r9   r>   costs     r@   init_throttlerzExchange.init_throttlera   s    "4#3T5FGGrA   c                 <   K   |                      |           d {V S rC   )r9   rP   s     r@   throttlezExchange.throttled   s*      ^^D)))))))))rA   c                     | j         S rC   )r3   rL   s    r@   get_sessionzExchange.get_sessiong   s
    |rA   c                 j    | j         | j        $| j                            | j        dz              d S d S )Na>   requires to release all resources with an explicit call to the .close() coroutine. If you are using the exchange instance with async coroutines, add `await exchange.close()` to your code into a place when you're done with the exchange and don't need the exchange instance anymore (at the end of your async coroutine).)r3   socks_proxy_sessionsloggerwarningidrL   s    r@   __del__zExchange.__del__j   sT    <#t'@'LK  +k  !k  l  l  l  l  l (M'LrA   )      c                 2   K   |                                   | S rC   )openrL   s    r@   
__aenter__zExchange.__aenter__o   s      IIKKKKrA   c                 >   K   |                                   d {V  d S rC   )close)r>   exc_typeexctbs       r@   	__aexit__zExchange.__aexit__s   s,      **,,rA   c                    | j         Rt          j        dk    rt          j                    | _         nt          j                    | _         | j         | j        _        | j        | j	        rt          j        | j                  n| j	        | _        | j        rf|                     | j        dd          rJt          j                    }|j        r0|j        | j        k    r | j                            |j                   | j        rZ| j        Ut'          j        | j        | j         d          | _        t'          j        | j         | j        | j                  | _        d S d S d S )N)r]      )r4   include_OS_certificatesFT)sslloopenable_cleanup_closedrl   	connector	trust_env)r0   sysversion_infoasyncioget_running_looprM   r9   rl   ssl_contextr2   rk   create_default_contextr4   	safe_booloptionsget_default_verify_pathsload_verify_locationsr6   r3   aiohttpTCPConnectortcp_connectorClientSessionr1   )r>   os_default_pathss     r@   r`   zExchange.openv   sj   $6))$+$<$>$>!!$+$:$<$<!"&"3DN#QUQ\ms9MMMMbfbmD  [T^^DLB[]b%c%c [#&#?#A#A #* [/?/F$+/U/U$::BRBY:ZZZ 	I 4!(!5$:JQUQbz~!!!D"0d6GSWSequ  rH  I  I  IDLLL	I 	I 4 4rA   c                 N  K   |                                   d {V  | j        -| j        r| j                                         d {V  d | _        |                                  d {V  |                                  d {V  |                     | j                   d {V  d S rC   )ws_closer3   r6   rc   close_connectorclose_proxy_sessionssleeptimeout_on_exitrL   s    r@   rc   zExchange.close   s      mmoo<# +l((*********DL""$$$$$$$$$'')))))))))jj-...........rA   c                    K   | j         &| j                                          d {V  d | _         | j        (| j                                         d {V  d | _        d S d S rC   )r}   rc   aiohttp_socks_connectorrL   s    r@   r   zExchange.close_connector   s      )$**,,,,,,,,,!%D'3.44666666666+/D((( 43rA   c                    K   | j         8| j         D ]'}| j         |                                          d {V  (d | _         d S d S rC   )rX   rc   r>   urls     r@   r   zExchange.close_proxy_sessions   sf      $00 = =/4::<<<<<<<<<<(,D%%% 10rA   GETc                 
  K   |                      |          }|| _        |                     ||||          }|4|                    d| j        i           ||                     |          z   }d}d}|                     ||||          \  }	}
}|	r|	}nt|
r|
}no|r_t          t          | j	        dz             | j
        i | _
        || j
        vr|                                  |                     |          }n| j        r| j        }|dup|du}|                     ||           | j        ||	|
|t          | j	        dz             | j        r!|                     d| j	        ||d|d|           | j                            d||||           |}d	}d}|                                D ]r\  }}|                                }|d
k    rS|dk    rK|}d}t+          j                    }|                                D ]\  }}|                    ||           |} n ns|s|r|                                nd}n||= |                                  ||n| j        }t5          ||                                          }d}d}d}d}	  |t7          j        |d          ||| j        dz  |          4 d{V 	 }|                    d           d{V }|j        }i }|D ])}||v r||         dz   ||         z   ||<   ||         ||<   *|j         }|j!        }| "                    ||||||||          }| #                    |          }| j$        r|| _%        | j&        r|| _'        | j(        r|| _)        | j        r"|                     d| j	        |||d|d|	  	         |r!tU          |tV                    s| j,        r||d<   | j                            d|||||           ddd          d{V  n# 1 d{V swxY w Y   n# tZ          j.        $ r2}d/                    | j	        ||g          }ta          |          |d}~wtb          j2        j3        th          j3        f$ r2}d/                    | j	        ||g          }tk          |          |d}~wt*          j6        $ r2}d/                    | j	        ||g          }ta          |          |d}~wt*          j7        $ r2}d/                    | j	        ||g          }tq          |          |d}~ww xY w| 9                    |||||||||	  	         | :                    |||||           ||S | ;                    |          r|S |dk    s||S |j<        S )z3Perform a HTTP request and return decoded JSON dataNOriginzu - to use SOCKS proxy with ccxt, you need "aiohttp_socks" module that can be installed by "pip install aiohttp_socks"z9 you have set multiple proxies, please use one or anotherz
fetch Request:zRequestHeaders:zRequestBody:z%s %s, Request: %s %sFzcontent-typezmultipart/form-dataT)encoded  )dataheaderstimeoutproxyreplace)errorsz, z
fetch Response:zResponseHeaders:zResponseBody:responseHeadersz%s %s, Response: %s %s %s  )=prepare_request_headerslast_request_headerscheck_proxy_url_settingsupdateoriginurl_encoder_for_proxy_urlcheck_proxy_settingsSocksProxyConnectorr   r[   rX   r`   get_socks_proxy_sessionaiohttp_proxycheck_conflicting_proxiesverboselogrY   debugitemslowerr{   FormData	add_fieldencoder3   getattryarlURLr   textr   statusreasonon_rest_response
parse_jsonenableLastHttpResponselast_http_responseenableLastResponseHeaderslast_response_headersenableLastJsonResponselast_json_response
isinstancelistreturnResponseHeaderssocketgaierrorjoinr   
concurrentfuturesTimeoutErrorrs   r   ClientConnectionErrorClientErrorr   handle_errorshandle_http_status_codeis_text_responsecontent) r>   r   methodr   bodyrequest_headersproxyUrlfinal_proxyproxy_session	httpProxy
httpsProxy
socksProxyproxyAgentSetrequest_bodyhas_multipartcontent_type_keykvlkr   encoded_bodyfinal_sessionsession_methodhttp_responsehttp_status_codehttp_status_textjson_responseresponseraw_headersheaderedetailss                                    r@   fetchzExchange.fetch   s      66w??$3!00fgtLL""Hdk#:;;;T;;C@@@C,0,E,Ec6SZ\`,a,a)	:z 	-#KK 	-$KK 	-"*"47  .e  $e  f  f  f)1,.)$";;;		 88DDMM 	-,K#4/I:T3I&&}h??? *1EI^blbx  }G  }Stw)ddeee < 	yHH'&#?PRacqswxxx163NNN #))++ 	 	DAqB^##---'($$(M"+--D $

 - -1q!,,,,#'LEE $  	2,0:4;;===dLL   01		)6)B ??-	0%~dhsD&A&A&A+7.=/3|d/B,7	9 9 9 v v v v v v v v =E&.mm9m&E&E E E E E E E&.) > >F((*1&/D*@;vCV*V*5f*=#+? #+?  $ 5 56FHXZ]_egnp}  @O  Q]  !^  !^ $ > >. <.;D+1 918D.. <.;D+< WHH0$'63HXZlnu  xG  IV  W  W  W  ?M4)H)H ?TMg ?7>M"34!!"=vsL\^egtuuu9v v v v v v v v v v v v v v v v v v v v v v v v v v v<  	7 	7 	7hh566G&w//Q6"/1EF 	1 	1 	1hh566G ))q0, 	7 	7 	7hh566G&w//Q6" 	0 	0 	0hh566G((a/	0 	+-=sFGUbdq  tC  EQ  	R  	R  	R$$%57GfVcddd$    )) 	!  B-"7  sa   2P 8D&O0P 0
O::P =O:>P T-P??#T"-RT!-ST -TTc                 \   | j         i | _         || j         vr|                    d          }|s|n|                    dd          }t          j        || j        | j        d|r|nd           | _        t          j	        | j        | j        | j
                  | j         |<   | j         |         S )Nz
socks5h://z	socks5://T)rk   rl   rm   rdnsrn   )rX   
startswithr   r   from_urlru   r0   r   r{   r~   r1   )r>   r   reverse_dnssocks_proxy_selecteds       r@   r   z Exchange.get_socks_proxy_session)  s    %-(*D%d777$//==K5@#s::jFXFXYegrFsFs +>+G$$&&*$/9[[T, , ,D( 5<4ItO`lp  mI  UY  Uk  5l  5l  5lD%j1(44rA   c                 V  K   |s/| j         r(| j        s|                     | j                   S | j         S d }| j        d         du r$|                                  d {V }|| j        d<   |                     |           d {V }d| j        v r| j        d= |                     ||          S )NfetchCurrenciesTcachedCurrencies)marketsmarkets_by_idset_marketshasfetch_currenciesrx   fetch_markets)r>   reloadparams
currenciesr   s        r@   load_markets_helperzExchange.load_markets_helper:  s       	$| $) :++DL999|#
8%&$..#4466666666J/9DL+,**622222222--/0444rA   c                 J  K   |r| j         r| j        s6d| _         |                     ||          }t          j        |          | _        	 | j         d{V }nD# t          j        $ r}d| _         d| _        |d}~wt          $ r}d| _         d| _        |d}~ww xY wd| _         |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:
            This method is asynchronous.
            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.
        TNF)r=   r<   r   rs   ensure_futureCancelledError	Exception)r>   r   r   	coroutineresultr   s         r@   load_marketszExchange.load_marketsJ  s      *  	D41 	D$:N 	D%)D"00@@I#*#8#C#CD 		///////FF% 	 	 	%*D"#'D G 	 	 	%*D"#'D G	 "'s$   
A B'A77BBBc                    K   |s| j         t          j         k    r| j         S |                     | j         |                                  d {V           | _         | j         S rC   )loaded_feesr   deep_extend
fetch_fees)r>   r   s     r@   	load_feeszExchange.load_feesq  sh       	(8#777''++D,<DOODUDU>U>U>U>U>U>UVVrA   c                 :   K   |                      | j                  S rC   )to_arrayr   r>   r   s     r@   r   zExchange.fetch_marketsx  s      
 }}T\***rA   c                    K   | j         S rC   )r   r  s     r@   r   zExchange.fetch_currencies  s      
 rA   1mc                 D   K   |                      |||||           d {V S rC   )fetch_ohlcvcr>   symbol	timeframesincelimitr   s         r@   fetchOHLCVCzExchange.fetchOHLCVC  s4      &&vy%OOOOOOOOOrA   c                 >   K   |                      ||           d {V S rC   )fetch_tickersr>   symbolsr   s      r@   fetch_full_tickerszExchange.fetch_full_tickers  s.      ''888888888rA   c                 @   K   t          j        |dz             d {V S Nr   )rs   r   )r>   millisecondss     r@   r   zExchange.sleep  s-      ]<$#6777777777rA   c                 D   K   	  ||  d {V  d S # t           $ r Y d S w xY wrC   )r   )r>   r   argss      r@   spawn_asynczExchange.spawn_async  sQ      	&$- 	 	 	DD	s    
c                     fd}t                      | j                             ||           }|                    |           S )Nc                     |                                  }|)                    |                                            d S                     |           d S rC   )	exceptionresolver   reject)asyncio_futurer  futures     r@   callbackz Exchange.spawn.<locals>.callback  sV    &0022I ~446677777i(((((rA   )r!   r0   create_taskadd_done_callback)r>   r   r  r$  taskr#  s        @r@   spawnzExchange.spawn  s\    	) 	) 	) 	) 	)  ,,VVT];;x(((rA   c                      t          |           S rC   )r   r   s    r@   r   zExchange.inflate  s    t}}rA   c                      t          |           S rC   )r   r*  s    r@   r   zExchange.gunzip  s    d||rA   c                 "    t          ||          S rC   )r"   r>   snapshotdepths      r@   
order_bookzExchange.order_book  s    5)))rA   c                 "    t          ||          S rC   )r#   r-  s      r@   indexed_order_bookzExchange.indexed_order_book      %000rA   c                 "    t          ||          S rC   )r$   r-  s      r@   counted_order_bookzExchange.counted_order_book  r3  rA   c                 x   |                                   | j        pi | _        || j        vr| j        }| j        }| j        }| j        }|                     | j        di           }|                     | j	        t          | d          t          | dd           | j        t          | j        | j                  | j        |                     | j        dd          d|          }t!          ||||||          | j        |<   |                                 \  }}	}
|s|	r|r|n|	| j        |         _        | j        |         S )Nwsr   pingdecompressBinaryT)r   r8  r   rT   r0   r9  )r`   clientshandle_messageon_erroron_closeon_connected
safe_valuerx   extend	streamingr   r   r	   rO   r0   rw   r    check_ws_proxy_settingsr   )r>   r   
on_messager<  r=  r>  
ws_optionsrx   r   r   r   s              r@   clientzExchange.client  sE   		|)rdl"",J}H}H,LtR@@Jkk$.tU++fd33<%d&68IJJ $ 1$(NN4<ASUY$Z$Z3 3  G !'sJ(LZa b bDL040L0L0N0N-Iz: QZ Q7@*P))jS!'|C  rA   c                 <     | j         j        |dz  | j        |g|R  S r  )r0   
call_laterr(  )r>   r   r   r  s       r@   delayzExchange.delay  s+    +t +GdNDJVQUVVVVrA   c                 <    d}|rt          | j        dz             i S )NTz%.handle_message() not implemented yetr   r[   )r>   rE  messagealwayss       r@   r;  zExchange.handle_message  s+     	Rtw)PPQQQ	rA   c                                                        d}                     |          t          j        fd|D                       }g }|/|D ],}	|	j        vr!|                    |	           |pdj        |	<   -j                                        rj        n,t          j	        
                     j        |                    }
 fd}|r|
                    |           |S )Nr   c                 :    g | ]}                     |          S  )r#  ).0message_hashrE  s     r@   
<listcomp>z+Exchange.watch_multiple.<locals>.<listcomp>  s%    ]]]lfmmL99]]]rA   Tc                                          j        d          }                     |dd          r&fd}t          j         |                       d S d S )Nr7  rQ      c                  2  K   j         r                               d {V  	                                d {V  d S # t          $ r }                     |            Y d } ~ d S d } ~ wt
          $ r }                     |            Y d } ~ d S d } ~ ww xY wrC   enableRateLimitrT   sendConnectionErrorr<  r   r   rE  rQ   rK  r>   s    r@   send_messagez<Exchange.watch_multiple.<locals>.after.<locals>.send_message        + 4$ood333333333+$kk'22222222222* + + +*********$ + + +*********+#   A 
BA))B6BBr?  rx   rs   r   futrx   r[  rQ   rE  rK  r>   s      @r@   afterz&Exchange.watch_multiple.<locals>.after      oodlD99G??7FA66D 
6+ + + + + + + + %llnn55555
6 
6rA   )r`   rE  r!   racesubscriptionsappend	connecteddoners   r   connectr3   r&  )r>   r   message_hashesrK  subscribe_hashessubscriptionbackoff_delayr#  missing_subscriptionssubscribe_hashrf  ra  rE  s   `  `        @r@   watch_multiplezExchange.watch_multiple  s'   		S!!]]]]n]]]^^ "'"2 P P!)===)00@@@;G;O4F(8(.(8(=(=(?(? TF$$&v~~dlM'R'RSS 		6 	6 	6 	6 	6 	6 	6  ! 	/''...rA   c                 D                                       d}                     |          ||j        v rj        |         S                     |          }j                            |          }|s|pdj        |<    j        }	                                 \  }
}}|r                     |          }	j	        
                                rj	        n't          j                            |	|                    } fd}|s|                    |           |S )Nr   Tc                                          j        d          }                     |dd          r&fd}t          j         |                       d S d S )Nr7  rQ   rT  c                  2  K   j         r                               d {V  	                                d {V  d S # t          $ r }                     |            Y d } ~ d S d } ~ wt
          $ r }                     |            Y d } ~ d S d } ~ ww xY wrC   rV  rZ  s    r@   r[  z3Exchange.watch.<locals>.after.<locals>.send_message  r\  r]  r^  r_  s      @r@   ra  zExchange.watch.<locals>.after  rb  rA   )r`   rE  r   r#  rd  r5   r3   rB  r   rf  rg  rs   r   rh  r&  )r>   r   rQ  rK  rn  rk  rl  r#  
subscribedselected_sessionr   r   r   rf  ra  rE  s   `  `           @r@   watchzExchange.watch  sN   		S!!!lfn&D&D>,//|,,)--n==
 	H3?3G4F 0<,0,H,H,J,J)	:z 	H#;;JGG(.(8(=(=(?(? XF$$&v~~6F'V'VWW 		6 	6 	6 	6 	6 	6 	6   	/''...rA   c                     d S rC   rO  )r>   rE  rK  s      r@   r>  zExchange.on_connected,  s	     	rA   c                 r    |j         | j        v r&| j        |j                  j        r| j        |j         = d S d S d S rC   )r   r:  errorr>   rE  rx  s      r@   r<  zExchange.on_error1  sB    :%%$,vz*B*H%VZ((( &%%%rA   c                 R    |j         rd S |j        | j        v r| j        |j        = d S d S rC   )rx  r   r:  ry  s      r@   r=  zExchange.on_close5  s<    < 	-D zT\))L,,, *)rA   c                    K   | j         rkt          j        d | j                                         D             t          j                   d {V  | j                                         D ]}| j         |= d S d S )Nc                 Z    g | ](}t          j        |                                          )S rO  )rs   r%  rc   )rP  rE  s     r@   rR  z%Exchange.ws_close.<locals>.<listcomp>@  s+    hhh 3FLLNN C ChhhrA   )return_when)r:  rs   waitvaluesALL_COMPLETEDcopyr   s     r@   r   zExchange.ws_close>  s      < 	&,hhRVR^ReReRgRghhhv}  wL  M  M  M  M  M  M  M  M  M  M|((** & &L%%	& 	&& &rA   c                 T  K   || j         vr-|                    t          | j        dz             |           d S 	 |                     ddd          }d}| j         |         }||k     r|j        }	|                     |||           d {V }
|                     |
|	          }|dk    r_|                    |
           | 	                    ||	|d                     |	
                                 |                    ||           d S |dz  }||k     |                    t          | j        dz   t          |          z   dz             |           | j        |j        = d S # t          $ r@}|                    ||           |                     |||||           d {V  Y d }~d S d }~ww xY w)	Nz+ loadOrderBook() orderbook is not initiatedwatchOrderBook
maxRetriesr]   r   rT  z nonce is behind cache after z tries.)
orderbooksr!  r   r[   handle_optioncachefetch_order_bookget_cache_indexresethandle_deltasclearr   strr:  r   r
   load_order_book)r>   rE  messageHashr  r  r   r  triesstoredr  r0  indexr   s                r@   r  zExchange.load_order_bookD  s     ((MM-2_(_``bmnnnF	S++,<lANNJE_V,F*$$#'#8#8#O#OOOOOOO
,,Z??A::LL,,,&&vuUVV}===KKMMMNN6;777F
 *$$ MM-2Q(QTWXbTcTc(cfo(oppr}~~~VZ((( 	S 	S 	SMM![)))&&v{FE6RRRRRRRRRRRRRRR	Ss   C	E AE 
F''5F""F'c                 2    |dk    rdS t          |d          S )Nr   z0e-00g)format)r>   ns     r@   format_scientific_notation_ftxz'Exchange.format_scientific_notation_ftx]  s    667a~~rA   c                     t           st          | j        dz             t          j                    }|                    |           t          |          }|S )Nz^ requires protobuf to decode messages, please install it with `pip install "protobuf==5.29.5"`)r(   r   r[   r'   PushDataV3ApiWrapperParseFromString)r>   r   rK  dict_msgs       r@   decode_proto_msgzExchange.decode_proto_msgb  sf     	Ktw  *J   J  K  K  K*?AA%%% ))$ rA   c                 
   K   d S rC   rO  rL   s    r@   load_dydx_protoszExchange.load_dydx_protos{  s      rA   c                 4   K   t          | j        dz             )Nz% fetchAccounts() is not supported yetrJ  r  s     r@   fetch_accountszExchange.fetch_accounts        47%LLMMMrA   r  r  r  c                 4   K   t          | j        dz             )Nz# fetchTrades() is not supported yetrJ  r>   r  r  r  r   s        r@   fetch_tradeszExchange.fetch_trades        47%JJKKKrA   c                 4   K   t          | j        dz             )Nz% fetchTradesWs() is not supported yetrJ  r  s        r@   fetch_trades_wszExchange.fetch_trades_ws  r  rA   c                    K   | j         d         r|                     |g|||           d {V S t          | j        dz             )NwatchLiquidationsForSymbolsz) watchLiquidations() is not supported yet)r   watch_liquidations_for_symbolsr   r[   r  s        r@   watch_liquidationszExchange.watch_liquidations  s\      812 	]<<fXueU[\\\\\\\\\47%PPQQQrA   r  c                 4   K   t          | j        dz             )Nz3 watchLiquidationsForSymbols() is not supported yetrJ  r>   r  r  r  r   s        r@   r  z'Exchange.watch_liquidations_for_symbols        47%ZZ[[[rA   c                    K   | j         d         r|                     |g|||          S t          | j        dz             )NwatchMyLiquidationsForSymbolsz+ watchMyLiquidations() is not supported yet)r   !watch_my_liquidations_for_symbolsr   r[   r  s        r@   watch_my_liquidationszExchange.watch_my_liquidations  sJ      834 	Z996(E5RXYYY47%RRSSSrA   c                 4   K   t          | j        dz             )Nz5 watchMyLiquidationsForSymbols() is not supported yetrJ  r  s        r@   r  z*Exchange.watch_my_liquidations_for_symbols  s      47%\\]]]rA   c                 4   K   t          | j        dz             )Nz# watchTrades() is not supported yetrJ  r  s        r@   watch_tradeszExchange.watch_trades  r  rA   c                 4   K   t          | j        dz             )Nz% unWatchOrders() is not supported yetrJ  r>   r  r   s      r@   un_watch_orderszExchange.un_watch_orders  r  rA   c                 4   K   t          | j        dz             )Nz% unWatchTrades() is not supported yetrJ  r  s      r@   un_watch_tradeszExchange.un_watch_trades  r  rA   c                 4   K   t          | j        dz             )Nz- watchTradesForSymbols() is not supported yetrJ  r  s        r@   watch_trades_for_symbolsz!Exchange.watch_trades_for_symbols        47%TTUUUrA   c                 4   K   t          | j        dz             )Nz/ unWatchTradesForSymbols() is not supported yetrJ  r  s      r@   un_watch_trades_for_symbolsz$Exchange.un_watch_trades_for_symbols        47%VVWWWrA   c                 4   K   t          | j        dz             )Nz/ watchMyTradesForSymbols() is not supported yetrJ  r  s        r@   watch_my_trades_for_symbolsz$Exchange.watch_my_trades_for_symbols  r  rA   c                 4   K   t          | j        dz             )Nz- watchOrdersForSymbols() is not supported yetrJ  r  s        r@   watch_orders_for_symbolsz!Exchange.watch_orders_for_symbols  r  rA   symbolsAndTimeframesc                 4   K   t          | j        dz             )Nz, watchOHLCVForSymbols() is not supported yetrJ  )r>   r  r  r  r   s        r@   watch_ohlcv_for_symbolsz Exchange.watch_ohlcv_for_symbols        47%SSTTTrA   c                 4   K   t          | j        dz             )Nz. unWatchOHLCVForSymbols() is not supported yetrJ  )r>   r  r   s      r@   un_watch_ohlcv_for_symbolsz#Exchange.un_watch_ohlcv_for_symbols        47%UUVVVrA   c                 4   K   t          | j        dz             )Nz0 watchOrderBookForSymbols() is not supported yetrJ  r>   r  r  r   s       r@   watch_order_book_for_symbolsz%Exchange.watch_order_book_for_symbols        47%WWXXXrA   c                 4   K   t          | j        dz             )Nz2 unWatchOrderBookForSymbols() is not supported yetrJ  r  s      r@   un_watch_order_book_for_symbolsz(Exchange.un_watch_order_book_for_symbols        47%YYZZZrA   c                 4   K   t          | j        dz             )Nz( unWatchPositions() is not supported yetrJ  r  s      r@   un_watch_positionszExchange.un_watch_positions        47%OOPPPrA   c                 4   K   t          | j        dz             )Nz% unWatchTicker() is not supported yetrJ  r  s      r@   un_watch_tickerzExchange.un_watch_ticker  r  rA   c                 4   K   t          | j        dz             )Nz( unWatchMarkPrice() is not supported yetrJ  r  s      r@   un_watch_mark_pricezExchange.un_watch_mark_price  r  rA   c                 4   K   t          | j        dz             )Nz) unWatchMarkPrices() is not supported yetrJ  r  s      r@   un_watch_mark_priceszExchange.un_watch_mark_prices        47%PPQQQrA   codesc                 4   K   t          | j        dz             )Nz- fetchDepositAddresses() is not supported yetrJ  r>   r  r   s      r@   fetch_deposit_addressesz Exchange.fetch_deposit_addresses  r  rA   c                 4   K   t          | j        dz             )Nz& fetchOrderBook() is not supported yetrJ  r>   r  r  r   s       r@   r  zExchange.fetch_order_book        47%MMNNNrA   c                 4   K   t          | j        dz             )Nz( fetchOrderBookWs() is not supported yetrJ  r  s       r@   fetch_order_book_wszExchange.fetch_order_book_ws  r  rA   c                    K   | j         d         r3|                     |g|           d {V }|                     ||          S t          | j        dz             )NfetchMarginModesz' fetchMarginMode() is not supported yet)r   fetch_margin_modes	safe_dictr   r[   )r>   r  r   marginModess       r@   fetch_margin_modezExchange.fetch_margin_mode  sj      8&' 	T $ 7 7& I IIIIIIIK>>+v666tw)RRSSSrA   c                 4   K   t          | j        dz             )Nz( fetchMarginModes() is not supported yetrJ  r  s      r@   r  zExchange.fetch_margin_modes  r  rA   c                    K   |                      ddd          }t          d|          D ]E}	 |                     |||           d {V }|c S # t          $ r}|dz   |k    r|Y d }~>d }~ww xY wd S )Nr  r  r]   r   rT  )r  ranger  r   )r>   r  r  r   fetchSnapshotMaxRetriesi	orderBookr   s           r@   fetch_rest_order_book_safez#Exchange.fetch_rest_order_book_safe  s      "&"4"45E|UV"W"Wq122 	 	A"&"7"7v"N"NNNNNNN	       E555G 65555 ts   A
A-A((A-c                 4   K   t          | j        dz             )Nz& watchOrderBook() is not supported yetrJ  r  s       r@   watch_order_bookzExchange.watch_order_book	  r  rA   c                 4   K   t          | j        dz             )Nz( unWatchOrderBook() is not supported yetrJ  r  s      r@   un_watch_order_bookzExchange.un_watch_order_book  r  rA   c                 4   K   t          | j        dz             )Nz! fetchTime() is not supported yetrJ  r  s     r@   
fetch_timezExchange.fetch_time        47%HHIIIrA   c                 4   K   t          | j        dz             )Nz* fetchTradingLimits() is not supported yetrJ  r  s      r@   fetch_trading_limitszExchange.fetch_trading_limits        47%QQRRRrA   c                 4   K   t          | j        dz             )Nz- fetchCrossBorrowRates() is not supported yetrJ  r  s     r@   fetch_cross_borrow_ratesz!Exchange.fetch_cross_borrow_rates  r  rA   c                 4   K   t          | j        dz             )Nz0 fetchIsolatedBorrowRates() is not supported yetrJ  r  s     r@   fetch_isolated_borrow_ratesz$Exchange.fetch_isolated_borrow_rates  r  rA   c                 4   K   t          | j        dz             )Nz* fetchLeverageTiers() is not supported yetrJ  r  s      r@   fetch_leverage_tierszExchange.fetch_leverage_tiers  r  rA   c                 4   K   t          | j        dz             )Nz) fetchFundingRates() is not supported yetrJ  r  s      r@   fetch_funding_rateszExchange.fetch_funding_rates  r  rA   c                 4   K   t          | j        dz             )Nz- fetchFundingIntervals() is not supported yetrJ  r  s      r@   fetch_funding_intervalsz Exchange.fetch_funding_intervals!  r  rA   c                 4   K   t          | j        dz             )Nz( watchFundingRate() is not supported yetrJ  r  s      r@   watch_funding_ratezExchange.watch_funding_rate$  r  rA   c                 4   K   t          | j        dz             )Nz) watchFundingRates() is not supported yetrJ  r  s      r@   watch_funding_rateszExchange.watch_funding_rates'  r  rA   c                 4   K   t          | j        dz             )Nz+ unWatchFundingRates() is not supported yetrJ  r  s      r@   un_watch_funding_rateszExchange.un_watch_funding_rates*        47%RRSSSrA   c                 >   K   |                      ||           d {V S rC   )r
  r  s      r@   watch_funding_rates_for_symbolsz(Exchange.watch_funding_rates_for_symbols-  s.      --gv>>>>>>>>>rA   codeamountfromAccount	toAccountc                 4   K   t          | j        dz             )Nz  transfer() is not supported yetrJ  )r>   r  r  r  r  r   s         r@   transferzExchange.transfer0        47%GGHHHrA   addresstagc                 4   K   t          | j        dz             )Nz  withdraw() is not supported yetrJ  r>   r  r  r  r  r   s         r@   withdrawzExchange.withdraw3  r  rA   c                 4   K   t          | j        dz             )Nz, createDepositAddress() is not supported yetrJ  r>   r  r   s      r@   create_deposit_addresszExchange.create_deposit_address6  r  rA   leveragec                 4   K   t          | j        dz             )Nz# setLeverage() is not supported yetrJ  )r>   r  r  r   s       r@   set_leveragezExchange.set_leverage9  r  rA   c                    K   | j         d         r3|                     |g|           d {V }|                     ||          S t          | j        dz             )NfetchLeveragesz% fetchLeverage() is not supported yet)r   fetch_leveragesr  r   r[   )r>   r  r   	leveragess       r@   fetch_leveragezExchange.fetch_leverage<  sj      8$% 	R"22F8VDDDDDDDDI>>)V444tw)PPQQQrA   c                 4   K   t          | j        dz             )Nz& fetchLeverages() is not supported yetrJ  r  s      r@   r$  zExchange.fetch_leveragesC  r  rA   hedgedc                 4   K   t          | j        dz             )Nz' setPositionMode() is not supported yetrJ  )r>   r(  r  r   s       r@   set_position_modezExchange.set_position_modeF        47%NNOOOrA   c                 4   K   t          | j        dz             )Nz! addMargin() is not supported yetrJ  r>   r  r  r   s       r@   
add_marginzExchange.add_marginI  r  rA   c                 4   K   t          | j        dz             )Nz$ reduceMargin() is not supported yetrJ  r-  s       r@   reduce_marginzExchange.reduce_marginL        47%KKLLLrA   c                 4   K   t          | j        dz             )Nz! setMargin() is not supported yetrJ  r-  s       r@   
set_marginzExchange.set_marginO  r  rA   r  c                 4   K   t          | j        dz             )Nz+ fetchLongShortRatio() is not supported yetrJ  r>   r  r  r   s       r@   fetch_long_short_ratiozExchange.fetch_long_short_ratioR  r  rA   c                 4   K   t          | j        dz             )Nz2 fetchLongShortRatioHistory() is not supported yetrJ  r  s         r@   fetch_long_short_ratio_historyz'Exchange.fetch_long_short_ratio_historyU  r  rA   typec                 4   K   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 yetrJ  )r>   r  r9  r  r  r   s         r@   fetch_margin_adjustment_historyz(Exchange.fetch_margin_adjustment_historyX  s       47%[[\\\rA   
marginModec                 4   K   t          | j        dz             )Nz% setMarginMode() is not supported yetrJ  )r>   r<  r  r   s       r@   set_margin_modezExchange.set_margin_moded  r  rA   c                 4   K   t          | j        dz             )Nz6 fetchDepositAddressesByNetwork() is not supported yetrJ  r  s      r@   "fetch_deposit_addresses_by_networkz+Exchange.fetch_deposit_addresses_by_networkg  s      47%]]^^^rA   1hc                 4   K   t          | j        dz             )Nz0 fetchOpenInterestHistory() is not supported yetrJ  r  s         r@   fetch_open_interest_historyz$Exchange.fetch_open_interest_historyj  r  rA   c                    K   | j         d         r3|                     |g|           d {V }|                     ||          S t          | j        dz             )NfetchOpenInterestsz) fetchOpenInterest() is not supported yet)r   fetch_open_interestsr  r   r[   )r>   r  r   openInterestss       r@   fetch_open_interestzExchange.fetch_open_interestm  sj      8() 	V"&";";VHf"M"MMMMMMMM>>-888tw)TTUUUrA   c                 4   K   t          | j        dz             )Nz* fetchOpenInterests() is not supported yetrJ  r  s      r@   rF  zExchange.fetch_open_interestst  r  rA   c                 4   K   t          | j        dz             )Nz signIn() is not supported yetrJ  r  s     r@   sign_inzExchange.sign_inw  s      47%EEFFFrA   c                 4   K   t          | j        dz             )Nz+ fetchPaymentMethods() is not supported yetrJ  r  s     r@   fetch_payment_methodszExchange.fetch_payment_methodsz  r  rA   c                 4   K   t          | j        dz             )Nzb fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate insteadrJ  r>   r  r  r   s       r@   fetch_borrow_ratezExchange.fetch_borrow_rate}  s+      47  &J  J  K  K  	KrA   c                 4   K   t          | j        dz             )Nz$ repayCrossMargin is not support yetrJ  rO  s       r@   repay_cross_marginzExchange.repay_cross_margin  r1  rA   c                 4   K   t          | j        dz             )Nz' repayIsolatedMargin is not support yetrJ  r>   r  r  r  r   s        r@   repay_isolated_marginzExchange.repay_isolated_margin  r+  rA   c                 4   K   t          | j        dz             )Nz% borrowCrossMargin is not support yetrJ  rO  s       r@   borrow_cross_marginzExchange.borrow_cross_margin  r  rA   c                 4   K   t          | j        dz             )Nz( borrowIsolatedMargin is not support yetrJ  rT  s        r@   borrow_isolated_marginzExchange.borrow_isolated_margin  r  rA   c                 4   K   t          | j        dz             )NzY borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin insteadrJ  r>   r  r  r  r   s        r@   borrow_marginzExchange.borrow_margin  s+      47  &A  A  B  B  	BrA   c                 4   K   t          | j        dz             )NzV repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin insteadrJ  r[  s        r@   repay_marginzExchange.repay_margin  s      47%}}~~~rA   c                 \   K   d}| j         d         rd}t          | j        dz   |z             )Nr   fetchTrades. 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  r   rK  s          r@   fetch_ohlcvzExchange.fetch_ohlcv  s>      8M" 	r rG47%IIGSTTTrA   c                 4   K   t          | j        dz             )Nz& fetchSpotOHLCV() is not supported yetrJ  r  s         r@   fetch_spot_ohlcvzExchange.fetch_spot_ohlcv  r  rA   c                 4   K   t          | j        dz             )Nz* fetchContractOHLCV() is not supported yetrJ  r  s         r@   fetch_contract_ohlcvzExchange.fetch_contract_ohlcv  r  rA   c                 \   K   d}| j         d         rd}t          | j        dz   |z             )Nr   fetchTradesWsra  zC fetchOHLCVWs() is not supported yet. Try using fetchOHLCV instead.rb  rc  s          r@   fetch_ohlcv_wszExchange.fetch_ohlcv_ws  s?      8O$ 	r rG47%jjmttuuurA   c                 4   K   t          | j        dz             )Nz" watchOHLCV() is not supported yetrJ  r  s         r@   watch_ohlcvzExchange.watch_ohlcv        47%IIJJJrA   c                 (  K   d}|                      | j        |i           }|                     |dd          }	 |                     |dd          durd S |                      |dd          }	d }
d}d}||	k     rP	  t          | |          i            d {V }
d}n-# t          $ r}|d	z   }||	k    r|Y d }~nd }~ww xY w|rn||	k     P|
}||                    |          }|d	         }||                    |          }|d         }|rOt          |t                    r:|                     |	                                          }|r|S t          d
          |S # t          $ r}| j        dz   |z   dz   }Y d }~nd }~ww xY w|rd S t          |          )Nr   webApiMuteFailureTwebApiEnablewebApiRetries
   r   FrT  z&could not parse the response into jsonr   zx() failed to fetch correct data from website. Probably webpage markup has been changed, breaking the page custom parser.)r?  rx   rw   r   r   splitr   r  r   stripr   r[   )r>   r   endpointMethodreturnAsJson
startRegexendRegexerrorMessagerx   muteOnFailurer  r   retryshouldBreakr   r   splitted_by_startsplitted_by_endjsoneds                     r@   fetch_web_endpointzExchange.fetch_web_endpoint  s*     //$,;;w0CTJJ#	o~~g~t<<DHHt/2FFJHEK*$$ %BWT>%B%B2%F%FFFFFFFH"&K       !AIE
** +****    *$$ G%$+MM*$=$=!+A.#")--"9"9)!, GS!9!9 99 P!M%&NOOO 	o 	o 	o7S=61  5o  oLLLLLL	o 	,4l+++sN   E #E 8!B E 
B;$B61E 6B;;BE 	E 
E>$E99E>c           
      (  K   |                      |||           d {V }|                     ||                     |                     |d                   d          |                     |                     |d                   dd          d          S )Nasksr   bidsT)r  r  )r  r@  sort_by	aggregate)r>   r  r  r   	orderbooks        r@   fetch_l2_order_bookzExchange.fetch_l2_order_book  s      //vFFFFFFFF	{{9LL	&0A!B!BAFFLL	&0A!B!BAtLL'
 '
   	rA   c                 `  K   | j         d         r|s	d| j        vr|                     |           d {V }t          dt	          |                    D ]9}||         }|                     | j        |         ||                   | j        |<   :|                                 | j        d<   | j        S )NfetchTradingLimitslimitsLoadedr   )r   rx   r  r  lenr  r   r  )r>   r  r   r   r   r  r  s          r@   load_trading_limitszExchange.load_trading_limits  s      8() 	C Cn<<!%!:!:7!C!CCCCCCCq#g,,// d dA$QZF+/+;+;DL<PRZ[aRb+c+cDL((/3/@/@/B/B^,|rA   publicapir   r   c                   K   | j         r4|                     |||||          }|                     |           d {V  d }	|                     ||dd          \  }	}d }
|                     ||dd          \  }
}|                                 | _        |                     ||||||          }|d         | _        |d         | _        |d         | _	        t          d|	dz             D ]}	 |                     |d         |d         |d         |d                    d {V c S # t          $ r}t          |t                    r||	k     r~| j        rS|dz   }|                     d	t#          |          z   d
z   t#          |          z   dz   t#          |	          z   dz              |
!|
dk    r|                     |
           d {V  n||Y d }~d }~ww xY wd S )NmaxRetriesOnFailurer   maxRetriesOnFailureDelayr   r   r   rT  r   zRequest failed with the error: z, retrying z of z...)rW  calculate_rate_limiter_costrT   handle_option_and_paramsr  lastRestRequestTimestampsignr   last_request_bodylast_request_urlr  r   r   r   r   r   r   r  r   )r>   rE   r  r   r   r   r   r.   rQ   retries
retryDelayrequestr  r   r  s                  r@   fetch2zExchange.fetch2  sY      	&33CvvVVD--%%%%%%%%%77F[]^__
!::64Icefgg
F(,(9(9(;(;%))D#vvwEE$+I$6!!( 'q'A+&& 	 	A!ZZ8I7S\K]_fgm_nooooooooooo   a11 
7{{< N$%EE HH%FQ%OR_%_befkblbl%lou%ux{  }D  yE  yE  &E  HM  &M  N  N  N&2q"&**Z"8"88888888G ts   (5D  
G*BGGc           	      H   K   |                      |||||||           d {V S rC   )r  )r>   rE   r  r   r   r   r   r.   s           r@   r  zExchange.request  s6      [[sFFGT6RRRRRRRRRrA   c                    K   |r!|                      |           d {V | _        n.| j        r| j        S |                      |           d {V | _        |                     | j        d          | _        | j        S )Nr[   )r  accountsindex_byaccountsById)r>   r   r   s      r@   load_accountszExchange.load_accounts  s       	B"&"5"5f"="=======DMM} B}$&*&9&9&&A&A A A A A A A MM$->>}rA   r[   pricec                 F   K   |                      ||d|||           d {V S )Nbuyedit_limit_orderr>   r[   r  r  r  r   s         r@   edit_limit_buy_orderzExchange.edit_limit_buy_order  s6      **2vufeVTTTTTTTTTrA   c                 F   K   |                      ||d|||           d {V S )Nsellr  r  s         r@   edit_limit_sell_orderzExchange.edit_limit_sell_order  s6      **2vvvufUUUUUUUUUrA   sidec           	      H   K   |                      ||d||||           d {V S Nr  )
edit_order)r>   r[   r  r  r  r  r   s          r@   r  zExchange.edit_limit_order  s6      __R$vVVVVVVVVVrA   c                 ~   K   |                      ||           d {V  |                     ||||||           d {V S rC   )cancel_ordercreate_orderr>   r[   r  r9  r  r  r  r   s           r@   r  zExchange.edit_order  s^      F+++++++++&&vtT65&QQQQQQQQQrA   clientOrderIdc           	      x   K   |                      |d|i          }|                     d||||||           d {V S )Nr  r   )r@  r  )	r>   r  r  r9  r  r  r  r   extendedParamss	            r@   edit_order_with_client_order_idz(Exchange.edit_order_with_client_order_id  sN      Vo}-MNN__RtVUN[[[[[[[[[rA   c                 ~   K   |                      ||           d {V  |                     ||||||           d {V S rC   )cancel_order_wscreate_order_wsr  s           r@   edit_order_wszExchange.edit_order_ws"  s^      ""2v.........))&$feVTTTTTTTTTrA   c                 4   K   t          | j        dz             )Nz% fetchPosition() is not supported yetrJ  r  s      r@   fetch_positionzExchange.fetch_position&  r  rA   c                 4   K   t          | j        dz             )Nz' fetchPositionWs() is not supported yetrJ  r  s      r@   fetch_position_wszExchange.fetch_position_ws)  r+  rA   c                 4   K   t          | j        dz             )Nz% watchPosition() is not supported yetrJ  r  s      r@   watch_positionzExchange.watch_position,  r  rA   c                 4   K   t          | j        dz             )Nz& watchPositions() is not supported yetrJ  r  s        r@   watch_positionszExchange.watch_positions/  r  rA   c                 B   K   |                      ||||           d {V S rC   )r  r  s        r@   watch_position_for_symbolsz#Exchange.watch_position_for_symbols2  s2      ))'5%HHHHHHHHHrA   c                 4   K   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 yetrJ  r  s      r@   fetch_positions_for_symbolz#Exchange.fetch_positions_for_symbol5         47%VVWWWrA   c                 4   K   t          | j        dz             r  rJ  r  s      r@   fetch_positions_for_symbol_wsz&Exchange.fetch_positions_for_symbol_ws>  r  rA   c                 4   K   t          | j        dz             Nz& fetchPositions() is not supported yetrJ  r  s      r@   fetch_positionszExchange.fetch_positionsG  r  rA   c                 4   K   t          | j        dz             r  rJ  r  s      r@   fetch_positions_wszExchange.fetch_positions_wsJ  r  rA   c                 4   K   t          | j        dz             )Nz* fetchPositionsRisk() is not supported yetrJ  r  s      r@   fetch_positions_riskzExchange.fetch_positions_riskM  r  rA   c                 4   K   t          | j        dz             )Nz% fetchBidsAsks() is not supported yetrJ  r  s      r@   fetch_bids_askszExchange.fetch_bids_asksP  r  rA   c                 4   K   t          | j        dz             )Nz+ fetchBorrowInterest() is not supported yetrJ  )r>   r  r  r  r  r   s         r@   fetch_borrow_interestzExchange.fetch_borrow_interestS  r  rA   c                 4   K   t          | j        dz             )Nz# fetchLedger() is not supported yetrJ  r>   r  r  r  r   s        r@   fetch_ledgerzExchange.fetch_ledgerV  r  rA   c                 4   K   t          | j        dz             )Nz( fetchLedgerEntry() is not supported yetrJ  r>   r[   r  r   s       r@   fetch_ledger_entryzExchange.fetch_ledger_entryY  r  rA   c                 4   K   t          | j        dz             )Nz$ fetchBalance() is not supported yetrJ  r  s     r@   fetch_balancezExchange.fetch_balance\  r1  rA   c                 4   K   t          | j        dz             )Nz& fetchBalanceWs() is not supported yetrJ  r  s     r@   fetch_balance_wszExchange.fetch_balance_ws_  r  rA   c                 4   K   t          | j        dz             )Nz$ watchBalance() is not supported yetrJ  r  s     r@   watch_balancezExchange.watch_balanceb  r1  rA   c                 L   K   |                      |           d {V }||         S rC   )r  )r>   partr   balances       r@   fetch_partial_balancezExchange.fetch_partial_balancee  s5      **622222222t}rA   c                 >   K   |                      d|           d {V S )Nfreer  r  s     r@   fetch_free_balancezExchange.fetch_free_balancei  .      //?????????rA   c                 >   K   |                      d|           d {V S )Nusedr  r  s     r@   fetch_used_balancezExchange.fetch_used_balancel  r  rA   c                 >   K   |                      d|           d {V S )Ntotalr  r  s     r@   fetch_total_balancezExchange.fetch_total_balanceo  s.      //@@@@@@@@@rA   c                 4   K   t          | j        dz             )Nz# fetchStatus() is not supported yetrJ  r  s     r@   fetch_statuszExchange.fetch_statusr  r  rA   c                    K   | j         d         st          | j        dz             |                     |g|           d {V S )NfetchTransactionFeesz+ fetchTransactionFee() is not supported yet)r   r   r[   fetch_transaction_feesr  s      r@   fetch_transaction_feezExchange.fetch_transaction_feeu  sW      x./ 	Xtw)VVWWW00$@@@@@@@@@rA   c                 4   K   t          | j        dz             )Nz, fetchTransactionFees() is not supported yetrJ  r  s      r@   r  zExchange.fetch_transaction_feesz  r  rA   c                 4   K   t          | j        dz             )Nz0 fetchDepositWithdrawFees() is not supported yetrJ  r  s      r@   fetch_deposit_withdraw_feesz$Exchange.fetch_deposit_withdraw_fees}  r  rA   c                    K   | j         d         st          | j        dz             |                     |g|           d {V }|                     ||          S )NfetchDepositWithdrawFeesz/ fetchDepositWithdrawFee() is not supported yet)r   r   r[   r  r?  )r>   r  r   feess       r@   fetch_deposit_withdraw_feez#Exchange.fetch_deposit_withdraw_fee  sj      x23 	\tw)ZZ[[[55tffEEEEEEEEtT***rA   c                    K   |                                   d {V  | j        d         st          | j        dz             |                     |           d {V }|                     ||          }|t          | j        dz   |z             |S )NfetchBorrowRatesz, fetchCrossBorrowRate() is not supported yetzI fetchCrossBorrowRate() could not find the borrow rate for currency code )r   r   r   r[   r  r?  r   )r>   r  r   borrowRatesrates        r@   fetch_cross_borrow_ratez Exchange.fetch_cross_borrow_rate  s      !!!!!!!!!x*+ 	Ytw)WWXXX 99&AAAAAAAA{D11<*u ux| |}}}rA   c                    K   |                                   d {V  | j        d         st          | j        dz             |                     |           d {V }|                     ||          }|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  r   r  r  s        r@   fetch_isolated_borrow_ratez#Exchange.fetch_isolated_borrow_rate  s      !!!!!!!!!x*+ 	\tw)ZZ[[[ <<VDDDDDDDD~~k622<*x x  |B  !B  C  C  CrA   c                 ^  K   | j         d         r|                                  d {V  |                     |          }|d         }|                     |g|           d {V }|                     ||          }|t          | j        dz   |z             |S t          | j        dz             )NfetchTickersr  z, fetchTickers() could not find a ticker for z# fetchTicker() is not supported yet)r   r   marketr  r  r   r[   r   r>   r  r   r	  tickerstickers         r@   fetch_tickerzExchange.fetch_ticker  s      8N# 	P##%%%%%%%%%[[((FH%F ..x@@@@@@@@G^^GV44F~"47-[#[^d#deeetw)NNOOOrA   c                 ^  K   | j         d         r|                                  d {V  |                     |          }|d         }|                     |g|           d {V }|                     ||          }|t          | j        dz   |z             |S t          | j        dz             )NfetchMarkPricesr  z/ fetchMarkPrices() could not find a ticker for ' fetchMarkPrices() is not supported yet)r   r   r	  fetch_mark_pricesr  r   r[   r   r
  s         r@   fetch_mark_pricezExchange.fetch_mark_price  s      8%& 	T##%%%%%%%%%[[((FH%F 22F8VDDDDDDDDG^^GV44F~"47-^#^ag#ghhhtw)RRSSSrA   c                 ^  K   | j         d         r|                                  d {V  |                     |          }|d         }|                     |g|           d {V }|                     ||          }|t          | j        dz   |z             |S t          | j        dz             )NfetchTickersWsr  z- fetchTickerWs() could not find a ticker for z% fetchTickerWs() is not supported yet)r   r   r	  fetch_tickers_wsr  r   r[   r   r
  s         r@   fetch_ticker_wszExchange.fetch_ticker_ws  s      8$% 	R##%%%%%%%%%[[((FH%F 116(FCCCCCCCCG^^GV44F~"47-\#\_e#effftw)PPQQQrA   c                 4   K   t          | j        dz             )Nz# watchTicker() is not supported yetrJ  r  s      r@   watch_tickerzExchange.watch_ticker  r  rA   c                 4   K   t          | j        dz             )Nz$ fetchTickers() is not supported yetrJ  r  s      r@   r  zExchange.fetch_tickers  r1  rA   c                 4   K   t          | j        dz             )Nz( fetchSpotTickers() is not supported yetrJ  r  s      r@   fetch_spot_tickerszExchange.fetch_spot_tickers  r  rA   c                 4   K   t          | j        dz             )Nz, fetchContractTickers() is not supported yetrJ  r  s      r@   fetch_contract_tickerszExchange.fetch_contract_tickers  r  rA   c                 4   K   t          | j        dz             )Nr  rJ  r  s      r@   r  zExchange.fetch_mark_prices  r+  rA   c                 4   K   t          | j        dz             )Nz& fetchTickersWs() is not supported yetrJ  r  s      r@   r  zExchange.fetch_tickers_ws  r  rA   c                 4   K   t          | j        dz             )Nz' fetchOrderBooks() is not supported yetrJ  r  s       r@   fetch_order_bookszExchange.fetch_order_books  r+  rA   c                 4   K   t          | j        dz             )Nz% watchBidsAsks() is not supported yetrJ  r  s      r@   watch_bids_askszExchange.watch_bids_asks  r  rA   c                 4   K   t          | j        dz             )Nz$ watchTickers() is not supported yetrJ  r  s      r@   watch_tickerszExchange.watch_tickers  r1  rA   c                 4   K   t          | j        dz             )Nz& unWatchTickers() is not supported yetrJ  r  s      r@   un_watch_tickerszExchange.un_watch_tickers  r  rA   c                 4   K   t          | j        dz             )Nz* unWatchFundingRate() is not supported yetrJ  r  s      r@   un_watch_funding_ratezExchange.un_watch_funding_rate  r  rA   c                 4   K   t          | j        dz             )Nz" fetchOrder() is not supported yetrJ  r>   r[   r  r   s       r@   fetch_orderzExchange.fetch_order  rn  rA   c                 p   K   |                      |d|i          }|                     d||           d{V S a{  
        create a market order by providing the symbol, side and cost
        :param str clientOrderId: client order Id
        :param str symbol: unified symbol of the market to create an order in
        :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   N)r@  r,  r>   r  r  r   r  s        r@    fetch_order_with_client_order_idz)Exchange.fetch_order_with_client_order_id  sJ       Vo}-MNN%%b&.AAAAAAAAArA   c                 4   K   t          | j        dz             )Nz$ fetchOrderWs() is not supported yetrJ  r+  s       r@   fetch_order_wszExchange.fetch_order_ws  r1  rA   c                 P   K   |                      |||           d {V }|d         S )Nr   )r,  )r>   r[   r  r   orders        r@   fetch_order_statuszExchange.fetch_order_status  s;       &&r66::::::::XrA   c                    K   |                      |                     |d          |                     |d          |           d {V S Nr[   r  )r,  safe_stringr>   r4  r   s      r@   fetch_unified_orderzExchange.fetch_unified_order  sS      %%d&6&6ud&C&CTEUEUV[]eEfEfhnooooooooorA   c                 4   K   t          | j        dz             )Nz# createOrder() is not supported yetrJ  r>   r  r9  r  r  r  r   s          r@   r  zExchange.create_order  r  rA   durationc                 4   K   t          | j        dz             )Nz' createTwapOrder() is not supported yetrJ  )r>   r  r  r  r=  r   s         r@   create_twap_orderzExchange.create_twap_order  r+  rA   fromCodetoCodec                 4   K   t          | j        dz             )Nz* createConvertTrade() is not supported yetrJ  )r>   r[   r@  rA  r  r   s         r@   create_convert_tradezExchange.create_convert_trade  r  rA   c                 4   K   t          | j        dz             )Nz) fetchConvertTrade() is not supported yetrJ  r  s       r@   fetch_convert_tradezExchange.fetch_convert_trade  r  rA   c                 4   K   t          | j        dz             )Nz0 fetchConvertTradeHistory() is not supported yetrJ  r  s        r@   fetch_convert_trade_historyz$Exchange.fetch_convert_trade_history  r  rA   c                 4   K   t          | j        dz             )Nz) fetchPositionMode() is not supported yetrJ  r  s      r@   fetch_position_modezExchange.fetch_position_mode  r  rA   c                 4   K   t          | j        dz             )Nz$ fetchADLRank() is not supported yetrJ  r  s      r@   fetch_adl_rankzExchange.fetch_adl_rank  r1  rA   c                 4   K   t          | j        dz             )N- fetchPositionsADLRank() is not supported yetrJ  r  s      r@   fetch_positions_adl_rankz!Exchange.fetch_positions_adl_rank  r  rA   c                 ^  K   | j         d         r|                                  d {V  |                     |          }|d         }|                     |g|           d {V }|                     |d          }|t          | j        dz   |z             |S t          | j        dz             )NfetchPositionsADLRankr  r   z3 fetchPositionsADLRank() could not find a rank for rM  )r   r   r	  rN  r  r   r[   r   )r>   r  r   r	  ranksranks         r@   fetch_position_adl_rankz Exchange.fetch_position_adl_rank  s      8+, 	Z##%%%%%%%%%[[((FH%F77&IIIIIIIIE>>%++D|"47-b#bek#kllltw)XXYYYrA   trailingAmounttrailingTriggerPricec	                    K   |t          | j        dz             ||d<   |||d<   | j        d         r |                     ||||||           d{V 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>`
        Nz? createTrailingAmountOrder() requires a trailingAmount argumentrT  rU  createTrailingAmountOrderz1 createTrailingAmountOrder() is not supported yetr   r[   r   r  r   	r>   r  r9  r  r  r  rT  rU  r   s	            r@   create_trailing_amount_orderz%Exchange.create_trailing_amount_order%  s       !#DG.o$oppp#1 +-AF)*8/0 	V**64vufUUUUUUUUU47%XXYYYrA   c	                    K   |t          | j        dz             ||d<   |||d<   | j        d         r |                     ||||||           d{V S t	          | j        dz             )rW  NzA createTrailingAmountOrderWs() requires a trailingAmount argumentrT  rU  createTrailingAmountOrderWsz3 createTrailingAmountOrderWs() is not supported yetr   r[   r   r  r   rZ  s	            r@   create_trailing_amount_order_wsz(Exchange.create_trailing_amount_order_ws;  s       !#DG.q$qrrr#1 +-AF)*812 	Y--fdD&%QWXXXXXXXXX47%ZZ[[[rA   trailingPercentc	                    K   |t          | j        dz             ||d<   |||d<   | j        d         r |                     ||||||           d{V 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>`
        NzA createTrailingPercentOrder() requires a trailingPercent argumentr`  rU  createTrailingPercentOrderz2 createTrailingPercentOrder() is not supported yetrY  	r>   r  r9  r  r  r  r`  rU  r   s	            r@   create_trailing_percent_orderz&Exchange.create_trailing_percent_orderQ  s       "#DG.q$qrrr$3 !+-AF)*801 	V**64vufUUUUUUUUU47%YYZZZrA   c	                    K   |t          | j        dz             ||d<   |||d<   | j        d         r |                     ||||||           d{V S t	          | j        dz             )rb  NzC createTrailingPercentOrderWs() requires a trailingPercent argumentr`  rU  createTrailingPercentOrderWsz4 createTrailingPercentOrderWs() is not supported yetr^  rd  s	            r@    create_trailing_percent_order_wsz)Exchange.create_trailing_percent_order_wsg  s       "#DG.s$sttt$3 !+-AF)*823 	Y--fdD&%QWXXXXXXXXX47%[[\\\rA   rQ   c                    K   | j         d         s| j         d         r-| j         d         r |                     |d||d|           d{V 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>`
        createMarketOrderWithCostcreateMarketBuyOrderWithCostcreateMarketSellOrderWithCostr	  rT  Nz1 createMarketOrderWithCost() is not supported yet)r   r  r   r[   r>   r  r  rQ   r   s        r@   create_market_order_with_costz&Exchange.create_market_order_with_cost}  s       8/0 	TTX>\5] 	Tbfbj  lK  cL 	T**68T4FSSSSSSSSS47%XXYYYrA   c                    K   | j         d         s| j        d         r |                     |dd|d|           d{V 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>`
        !createMarketBuyOrderRequiresPricerl  r	  r  rT  Nz4 createMarketBuyOrderWithCost() is not supported yetrx   r   r  r   r[   r>   r  rQ   r   s       r@   !create_market_buy_order_with_costz*Exchange.create_market_buy_order_with_cost  so       <;< 	UIg@h 	U**68UD!VTTTTTTTTT47%[[\\\rA   c                    K   | j         d         s| j        d         r |                     |dd|d|           d{V 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>`
        "createMarketSellOrderRequiresPricerm  r	  r  rT  Nz5 createMarketSellOrderWithCost() is not supported yetrr  rs  s       r@   "create_market_sell_order_with_costz+Exchange.create_market_sell_order_with_cost  so       <<= 	VJiAj 	V**68VT1fUUUUUUUUU47%\\]]]rA   c                    K   | j         d         s| j         d         r-| j         d         r |                     |d||d|           d{V S t          | j        dz             )rj  createMarketOrderWithCostWscreateMarketBuyOrderWithCostWscreateMarketSellOrderWithCostWsr	  rT  Nz3 createMarketOrderWithCostWs() is not supported yet)r   r  r   r[   rn  s        r@    create_market_order_with_cost_wsz)Exchange.create_market_order_with_cost_ws  s       812 	Wtx@`7a 	Wfjfn  pQ  gR 	W--fhdAvVVVVVVVVV47%ZZ[[[rA   triggerPricec                    K   |t          | j        dz             ||d<   | j        d         r |                     ||||||           d{V 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>`
        Nz6 createTriggerOrder() requires a triggerPrice argumentr}  createTriggerOrderz* createTriggerOrder() is not supported yetrY  r>   r  r9  r  r  r  r}  r   s           r@   create_trigger_orderzExchange.create_trigger_order  s       #DG.f$fggg!-~8() 	V**64vufUUUUUUUUU47%QQRRRrA   c                    K   |t          | j        dz             ||d<   | j        d         r |                     ||||||           d{V S t	          | j        dz             )r  Nz8 createTriggerOrderWs() requires a triggerPrice argumentr}  createTriggerOrderWsz, createTriggerOrderWs() is not supported yetr^  r  s           r@   create_trigger_order_wsz Exchange.create_trigger_order_ws  s       #DG.h$hiii!-~8*+ 	Y--fdD&%QWXXXXXXXXX47%SSTTTrA   stopLossPricec                    K   |t          | j        dz             ||d<   | j        d         r |                     ||||||           d{V 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>`
        Nz8 createStopLossOrder() requires a stopLossPrice argumentr  createStopLossOrderz+ createStopLossOrder() is not supported yetrY  r>   r  r9  r  r  r  r  r   s           r@   create_stop_loss_orderzExchange.create_stop_loss_order  s        #DG.h$hiii"/8)* 	V**64vufUUUUUUUUU47%RRSSSrA   c                    K   |t          | j        dz             ||d<   | j        d         r |                     ||||||           d{V S t	          | j        dz             )r  Nz: createStopLossOrderWs() requires a stopLossPrice argumentr  createStopLossOrderWsz- createStopLossOrderWs() is not supported yetr^  r  s           r@   create_stop_loss_order_wsz"Exchange.create_stop_loss_order_ws  s        #DG.j$jkkk"/8+, 	Y--fdD&%QWXXXXXXXXX47%TTUUUrA   takeProfitPricec                    K   |t          | j        dz             ||d<   | j        d         r |                     ||||||           d{V 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>`
        Nz< createTakeProfitOrder() requires a takeProfitPrice argumentr  createTakeProfitOrderz- createTakeProfitOrder() is not supported yetrY  r>   r  r9  r  r  r  r  r   s           r@   create_take_profit_orderz!Exchange.create_take_profit_order  s       "#DG.l$lmmm$3 !8+, 	V**64vufUUUUUUUUU47%TTUUUrA   c                    K   |t          | j        dz             ||d<   | j        d         r |                     ||||||           d{V S t	          | j        dz             )r  Nz> createTakeProfitOrderWs() requires a takeProfitPrice argumentr  createTakeProfitOrderWsz/ createTakeProfitOrderWs() is not supported yetr^  r  s           r@   create_take_profit_order_wsz$Exchange.create_take_profit_order_ws  s       "#DG.n$nooo$3 !8-. 	Y--fdD&%QWXXXXXXXXX47%VVWWWrA   
takeProfitstopLossc	           
         K   |                      ||||||||          }| j        d         r |                     ||||||           d{V 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>`
        $createOrderWithTakeProfitAndStopLossNz< createOrderWithTakeProfitAndStopLoss() is not supported yet)$set_take_profit_and_stop_loss_paramsr   r  r   r[   	r>   r  r9  r  r  r  r  r  r   s	            r@   +create_order_with_take_profit_and_stop_lossz4Exchange.create_order_with_take_profit_and_stop_loss!  s      * ::64vW\^hjrtz{{8:; 	V**64vufUUUUUUUUU47%ccdddrA   c	           
         K   |                      ||||||||          }| j        d         r |                     ||||||           d{V S t          | j        dz             )r  &createOrderWithTakeProfitAndStopLossWsNz> 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;  s      * ::64vW\^hjrtz{{8<= 	Y--fdD&%QWXXXXXXXXX47%eefffrA   ordersc                 4   K   t          | j        dz             )Nz$ createOrders() is not supported yetrJ  r>   r  r   s      r@   create_orderszExchange.create_ordersU  r1  rA   c                 4   K   t          | j        dz             )Nz( createSpotOrders() is not supported yetrJ  r  s      r@   create_spot_orderszExchange.create_spot_ordersX  r  rA   c                 4   K   t          | j        dz             )Nz, createContractOrders() is not supported yetrJ  r  s      r@   create_contract_orderszExchange.create_contract_orders[  r  rA   c                 4   K   t          | j        dz             )Nz" editOrders() is not supported yetrJ  r  s      r@   edit_orderszExchange.edit_orders^  rn  rA   c                 4   K   t          | j        dz             )Nz% createOrderWs() is not supported yetrJ  r<  s          r@   r  zExchange.create_order_wsa  r  rA   c                 4   K   t          | j        dz             )Nz# cancelOrder() is not supported yetrJ  r+  s       r@   r  zExchange.cancel_orderd  r  rA   c                 4   K   t          | j        dz             )Nz' cancelSpotOrder() is not supported yetrJ  r+  s       r@   cancel_spot_orderzExchange.cancel_spot_orderg  r+  rA   c                 4   K   t          | j        dz             )Nz+ cancelContractOrder() is not supported yetrJ  r+  s       r@   cancel_contract_orderzExchange.cancel_contract_orderj  r  rA   c                 p   K   |                      |d|i          }|                     d||           d{V S r.  )r@  r  r/  s        r@   !cancel_order_with_client_order_idz*Exchange.cancel_order_with_client_order_idm  sJ       Vo}-MNN&&r6>BBBBBBBBBrA   c                 4   K   t          | j        dz             )Nz% cancelOrderWs() is not supported yetrJ  r+  s       r@   r  zExchange.cancel_order_wsx  r  rA   idsc                 4   K   t          | j        dz             )Nz$ cancelOrders() is not supported yetrJ  r>   r  r  r   s       r@   cancel_orderszExchange.cancel_orders{  r1  rA   clientOrderIdsc                 p   K   |                      |d|i          }|                     g ||           d{V S )a  
        create a market order by providing the symbol, side and cost
        :param str[] clientOrderIds: client order Ids
        :param str symbol: unified symbol of the market to create an order in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        r  N)r@  r  )r>   r  r  r   r  s        r@   #cancel_orders_with_client_order_idsz,Exchange.cancel_orders_with_client_order_ids~  sK       V.>-OPP''FNCCCCCCCCCrA   c                 4   K   t          | j        dz             )Nz& cancelOrdersWs() is not supported yetrJ  r  s       r@   cancel_orders_wszExchange.cancel_orders_ws  r  rA   c                 4   K   t          | j        dz             )Nz' cancelAllOrders() is not supported yetrJ  r  s      r@   cancel_all_orderszExchange.cancel_all_orders  r+  rA   c                 4   K   t          | j        dz             )Nz+ cancelAllSpotOrders() is not supported yetrJ  r  s      r@   cancel_all_spot_orderszExchange.cancel_all_spot_orders  r  rA   c                 4   K   t          | j        dz             )Nz/ cancelAllContractOrders() is not supported yetrJ  r  s      r@   cancel_all_contract_ordersz#Exchange.cancel_all_contract_orders  r  rA   r   c                 4   K   t          | j        dz             )Nz, cancelAllOrdersAfter() is not supported yetrJ  )r>   r   r   s      r@   cancel_all_orders_afterz Exchange.cancel_all_orders_after  r  rA   c                 4   K   t          | j        dz             )Nz. cancelOrdersForSymbols() is not supported yetrJ  r  s      r@   cancel_orders_for_symbolsz"Exchange.cancel_orders_for_symbols  r  rA   c                 4   K   t          | j        dz             )Nz) cancelAllOrdersWs() is not supported yetrJ  r  s      r@   cancel_all_orders_wszExchange.cancel_all_orders_ws  r  rA   r4  c                    K   |                      |                     |d          |                     |d          |          S r7  )r  r8  r9  s      r@   cancel_unified_orderzExchange.cancel_unified_order  sA        !1!1%!>!>@P@PQVX`@a@acijjjrA   c                    K   | j         d         r$| j         d         rt          | j        dz             t          | j        dz             )NfetchOpenOrdersfetchClosedOrdersze fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() insteadz# fetchOrders() is not supported yetrb  r  s        r@   fetch_orderszExchange.fetch_orders  sb      8%& 	R484G+H 	Rtw  *Q   Q  R  R  R47%JJKKKrA   c                 4   K   t          | j        dz             )Nz% fetchOrdersWs() is not supported yetrJ  r  s        r@   fetch_orders_wszExchange.fetch_orders_ws  r  rA   c                 4   K   t          | j        dz             )Nz( fetchOrderTrades() is not supported yetrJ  )r>   r[   r  r  r  r   s         r@   fetch_order_tradeszExchange.fetch_order_trades  r  rA   c                 4   K   t          | j        dz             )Nz# watchOrders() is not supported yetrJ  r  s        r@   watch_orderszExchange.watch_orders  r  rA   c                    K   | j         d         r5|                     ||||           d {V }|                     |dd          S t          | j        dz             )NfetchOrdersr   r`   z' fetchOpenOrders() is not supported yetr   r  	filter_byr   r[   r>   r  r  r  r   r  s         r@   fetch_open_orderszExchange.fetch_open_orders  sl      8M" 	<,,VUE6JJJJJJJJF>>&(F;;;47%NNOOOrA   c                    K   | j         d         r5|                     ||||           d {V }|                     |dd          S t          | j        dz             )NfetchOrdersWsr   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      8O$ 	<//ufMMMMMMMMF>>&(F;;;47%PPQQQrA   c                    K   | j         d         r5|                     ||||           d {V }|                     |dd          S t          | j        dz             )Nr  r   closedz) fetchClosedOrders() is not supported yetr  r  s         r@   fetch_closed_orderszExchange.fetch_closed_orders  sl      8M" 	>,,VUE6JJJJJJJJF>>&(H===47%PPQQQrA   c                 4   K   t          | j        dz             )Nz+ fetchCanceledOrders() is not supported yetrJ  r  s        r@   fetch_canceled_orderszExchange.fetch_canceled_orders  r  rA   c                 4   K   t          | j        dz             )Nz4 fetchCanceledAndClosedOrders() is not supported yetrJ  r  s        r@    fetch_canceled_and_closed_ordersz)Exchange.fetch_canceled_and_closed_orders  s      47%[[\\\rA   c                    K   | j         d         r5|                     ||||           d {V }|                     |dd          S t          | j        dz             )Nr  r   r  z+ fetchClosedOrdersWs() is not supported yetr  r  s         r@   fetch_closed_orders_wszExchange.fetch_closed_orders_ws  sl      8O$ 	>//ufMMMMMMMMF>>&(H===47%RRSSSrA   c                 4   K   t          | j        dz             )Nz% fetchMyTrades() is not supported yetrJ  r  s        r@   fetch_my_tradeszExchange.fetch_my_trades  r  rA   c                 4   K   t          | j        dz             )Nz+ fetchMyLiquidations() is not supported yetrJ  r  s        r@   fetch_my_liquidationszExchange.fetch_my_liquidations  r  rA   c                 4   K   t          | j        dz             )Nz) fetchLiquidations() is not supported yetrJ  r  s        r@   fetch_liquidationszExchange.fetch_liquidations  r  rA   c                 4   K   t          | j        dz             )Nz' fetchMyTradesWs() is not supported yetrJ  r  s        r@   fetch_my_trades_wszExchange.fetch_my_trades_ws  r+  rA   c                 4   K   t          | j        dz             )Nz% watchMyTrades() is not supported yetrJ  r  s        r@   watch_my_tradeszExchange.watch_my_trades  r  rA   c                 4   K   t          | j        dz             )Nz# fetchGreeks() is not supported yetrJ  r  s      r@   fetch_greekszExchange.fetch_greeks  r  rA   c                 4   K   t          | j        dz             )Nz& fetchAllGreeks() is not supported yetrJ  r  s      r@   fetch_all_greekszExchange.fetch_all_greeks  r  rA   c                 4   K   t          | j        dz             )Nz( fetchOptionChain() is not supported yetrJ  r  s      r@   fetch_option_chainzExchange.fetch_option_chain  r  rA   c                 4   K   t          | j        dz             )Nz# fetchOption() is not supported yetrJ  r  s      r@   fetch_optionzExchange.fetch_option  r  rA   c                 4   K   t          | j        dz             )Nz) fetchConvertQuote() is not supported yetrJ  )r>   r@  rA  r  r   s        r@   fetch_convert_quotezExchange.fetch_convert_quote  r  rA   c                 4   K   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 yetrJ  r  s        r@   fetch_deposits_withdrawalsz#Exchange.fetch_deposits_withdrawals  s       47%WWXXXrA   c                 4   K   t          | j        dz             )Nz% fetchDeposits() is not supported yetrJ  r  s        r@   fetch_depositszExchange.fetch_deposits  r  rA   c                 4   K   t          | j        dz             )Nz( fetchWithdrawals() is not supported yetrJ  r  s        r@   fetch_withdrawalszExchange.fetch_withdrawals  r  rA   c                 4   K   t          | j        dz             )Nz' fetchDepositsWs() is not supported yetrJ  r  s        r@   fetch_deposits_wszExchange.fetch_deposits_ws  r+  rA   c                 4   K   t          | j        dz             )Nz* fetchWithdrawalsWs() is not supported yetrJ  r  s        r@   fetch_withdrawals_wszExchange.fetch_withdrawals_ws  r  rA   c                 4   K   t          | j        dz             )Nz/ fetchFundingRateHistory() is not supported yetrJ  r  s        r@   fetch_funding_rate_historyz#Exchange.fetch_funding_rate_history  r  rA   c                 4   K   t          | j        dz             )Nz+ fetchFundingHistory() is not supported yetrJ  r  s        r@   fetch_funding_historyzExchange.fetch_funding_history  r  rA   c                 4   K   t          | j        dz             )Nz% closePosition() is not supported yetrJ  )r>   r  r  r   s       r@   close_positionzExchange.close_position  r  rA   c                 4   K   t          | j        dz             )Nz) closeAllPositions() is not supported yetrJ  r  s     r@   close_all_positionszExchange.close_all_positions  r  rA   c                 4   K   t          | j        dz             )Nz( fetchL3OrderBook() is not supported yet)r   r[   r  s       r@   fetch_l3_order_bookzExchange.fetch_l3_order_book  s      #MMNNNrA   c                 j  K   | j         d         rT|                     |g|           d {V }|                     ||          }|t          | j        dz   |z   dz             |S | j         d         r|                     |d          }|                     |d          }|                     ||           d {V }||                     ||          S t          |
                                          }|                     |d          }|                     ||          S t          | j        dz             )NfetchDepositAddressesz< fetchDepositAddress() could not find a deposit address for zc, make sure you have created a corresponding deposit address in your wallet on the exchange websitefetchDepositAddressesByNetworknetworkr   z+ fetchDepositAddress() is not supported yet)r   r  r?  r   r[   r8  omitr@  r  r   keysr   )	r>   r  r   depositAddressesdepositAddressr  addressStructuresr  keys	            r@   fetch_deposit_addresszExchange.fetch_deposit_address  sj     8+, 	X%)%A%A4&&%Q%QQQQQQQ!__-=tDDN%$TW/m%mpt%t  x]  &]  ^  ^  ^%%X67 	X&&vy99GYYvy11F&*&M&MdTZ&[&[ [ [ [ [ [ ["~~&7AAA-224455&&tQ//~~&7===tw)VVWWWrA   c                 4   K   t          | j        dz             )Nz3 fetchContractDepositAddress() is not supported yetrJ  r  s      r@   fetch_contract_deposit_addressz'Exchange.fetch_contract_deposit_address&  r  rA   c                 F   K   |                      |d||||           d {V S r  r  r>   r  r  r  r  r   s         r@   create_limit_orderzExchange.create_limit_order)  s6      &&vwfeVTTTTTTTTTrA   c                 F   K   |                      |d||||           d {V S r  r  r!  s         r@   create_limit_order_wszExchange.create_limit_order_ws,  s7      ))&'4PVWWWWWWWWWrA   c                 F   K   |                      |d||||           d {V S Nr	  r   r!  s         r@   create_market_orderzExchange.create_market_order/  s6      &&vxvufUUUUUUUUUrA   c                 F   K   |                      |d||||           d {V S r'  r$  r!  s         r@   create_market_order_wszExchange.create_market_order_ws2  s7      ))&(D&%QWXXXXXXXXXrA   c                 F   K   |                      |dd|||           d {V S Nr  r  r   r>   r  r  r  r   s        r@   create_limit_buy_orderzExchange.create_limit_buy_order5  s6      &&vwvufUUUUUUUUUrA   c                 F   K   |                      |dd|||           d {V S r,  r$  r-  s        r@   create_limit_buy_order_wsz"Exchange.create_limit_buy_order_ws8  s7      ))&'5&%QWXXXXXXXXXrA   c                 F   K   |                      |dd|||           d {V S Nr  r  r   r-  s        r@   create_limit_sell_orderz Exchange.create_limit_sell_order;  s6      &&vwvVVVVVVVVVrA   c                 F   K   |                      |dd|||           d {V S r2  r$  r-  s        r@   create_limit_sell_order_wsz#Exchange.create_limit_sell_order_ws>  s7      ))&'665RXYYYYYYYYYrA   c                 F   K   |                      |dd|d |           d {V S Nr	  r  r   r-  s       r@   create_market_buy_orderz Exchange.create_market_buy_orderA  s6      &&vxfUUUUUUUUUrA   c                 F   K   |                      |dd|d |           d {V S r7  r$  r-  s       r@   create_market_buy_order_wsz#Exchange.create_market_buy_order_wsD  s7      ))&(E64QWXXXXXXXXXrA   c                 F   K   |                      |dd|d |           d {V S Nr	  r  r   r-  s       r@   create_market_sell_orderz!Exchange.create_market_sell_orderG  s6      &&vxvVVVVVVVVVrA   c                 F   K   |                      |dd|d |           d {V S r<  r$  r-  s       r@   create_market_sell_order_wsz$Exchange.create_market_sell_order_wsJ  s7      ))&(FFDRXYYYYYYYYYrA   c                    K   |                      |           d {V }|                                 }||z
  | j        d<   | j        d         S )NtimeDifference)r  r  rx   )r>   r   
serverTimera  s       r@   load_time_differencezExchange.load_time_differenceM  sZ      ??622222222
!!##).);%&|,--rA   c                   K   | j         d         rf|                     |          }|d         st          | j        dz             |                     |g           d {V }|                     ||          S t          | j        dz             )NfetchLeverageTierscontractz: fetchMarketLeverageTiers() supports contract markets onlyz0 fetchMarketLeverageTiers() is not supported yet)r   r	  r   r[   r  r?  r   )r>   r  r   r	  tierss        r@   fetch_market_leverage_tiersz$Exchange.fetch_market_leverage_tiersS  s      8() 	][[((F*% h*f fggg33VH========E??5&111tw)[[\\\rA   c                    K   | j         d         st          | j        dz             |                     |ddi          }|                     ||||||           d {V S )NcreatePostOnlyOrderz+ createPostOnlyOrder() is not supported yetpostOnlyTr   r   r[   r@  r  r>   r  r9  r  r  r  r   querys           r@   create_post_only_orderzExchange.create_post_only_order]  su      x-. 	Xtw)VVWWWFZ$677&&vtT65%PPPPPPPPPrA   c                    K   | j         d         st          | j        dz             |                     |ddi          }|                     ||||||           d {V S )NcreatePostOnlyOrderWsz- createPostOnlyOrderWs() is not supported yetrK  Tr   r   r[   r@  r  rM  s           r@   create_post_only_order_wsz"Exchange.create_post_only_order_wsc  su      x/0 	Ztw)XXYYYFZ$677))&$feUSSSSSSSSSrA   c                    K   | j         d         st          | j        dz             |                     |ddi          }|                     ||||||           d {V S )NcreateReduceOnlyOrderz- createReduceOnlyOrder() is not supported yet
reduceOnlyTrL  rM  s           r@   create_reduce_only_orderz!Exchange.create_reduce_only_orderi  su      x/0 	Ztw)XXYYYF\4$899&&vtT65%PPPPPPPPPrA   c                    K   | j         d         st          | j        dz             |                     |ddi          }|                     ||||||           d {V S )NcreateReduceOnlyOrderWsz/ createReduceOnlyOrderWs() is not supported yetrV  TrR  rM  s           r@   create_reduce_only_order_wsz$Exchange.create_reduce_only_order_wso  su      x12 	\tw)ZZ[[[F\4$899))&$feUSSSSSSSSSrA   c                    K   | j         d         st          | j        dz             |t          | j        dz             |                     |d|i          }|                     ||||||           d {V S )NcreateStopOrderz' createStopOrder() is not supported yetz2 create_stop_order() requires a stopPrice argument	stopPrice)r   r   r[   r   r@  r  	r>   r  r9  r  r  r  r}  r   rN  s	            r@   create_stop_orderzExchange.create_stop_orderu  s      x)* 	Ttw)RRSSS#DG.b$bcccF[,$?@@&&vtT65%PPPPPPPPPrA   c                    K   | j         d         st          | j        dz             |t          | j        dz             |                     |d|i          }|                     ||||||           d {V S )NcreateStopOrderWsz) 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}  s      x+, 	Vtw)TTUUU#DG.b$bcccF[,$?@@))&$feUSSSSSSSSSrA   c                    K   | j         d         st          | j        dz             |                     |d|i          }|                     |d||||           d {V S )NcreateStopLimitOrderz, createStopLimitOrder() is not supported yetr]  r  rL  r>   r  r  r  r  r}  r   rN  s           r@   create_stop_limit_orderz Exchange.create_stop_limit_order  su      x./ 	Ytw)WWXXXF[,$?@@&&vwfeUSSSSSSSSSrA   c                    K   | j         d         st          | j        dz             |                     |d|i          }|                     |d||||           d {V S )NcreateStopLimitOrderWsz. createStopLimitOrderWs() is not supported yetr]  r  rR  re  s           r@   create_stop_limit_order_wsz#Exchange.create_stop_limit_order_ws  sv      x01 	[tw)YYZZZF[,$?@@))&'4PUVVVVVVVVVrA   c                    K   | j         d         st          | j        dz             |                     |d|i          }|                     |d||d |           d {V S )NcreateStopMarketOrderz- createStopMarketOrder() is not supported yetr]  r	  rL  r>   r  r  r  r}  r   rN  s          r@   create_stop_market_orderz!Exchange.create_stop_market_order  su      x/0 	Ztw)XXYYYF[,$?@@&&vxvtUSSSSSSSSSrA   c                    K   | j         d         st          | j        dz             |                     |d|i          }|                     |d||d |           d {V S )NcreateStopMarketOrderWsz/ createStopMarketOrderWs() is not supported yetr]  r	  rR  rl  s          r@   create_stop_market_order_wsz$Exchange.create_stop_market_order_ws  sv      x12 	\tw)ZZ[[[F[,$?@@))&(D&$PUVVVVVVVVVrA   namec                 4   K   t          | j        dz             )Nz( createSubAccount() is not supported yetrJ  )r>   rq  r   s      r@   create_sub_accountzExchange.create_sub_account  r  rA   c                 4   K   t          | j        dz             )Nz' fetchLastPrices() is not supported yetrJ  r  s      r@   fetch_last_priceszExchange.fetch_last_prices  r+  rA   c                 4   K   t          | j        dz             )Nz( fetchTradingFees() is not supported yetrJ  r  s     r@   fetch_trading_feeszExchange.fetch_trading_fees  r  rA   c                 4   K   t          | j        dz             )Nz* fetchTradingFeesWs() is not supported yetrJ  r  s     r@   fetch_trading_fees_wszExchange.fetch_trading_fees_ws  r  rA   c                    K   | j         d         st          | j        dz             |                     |           d {V }|                     ||          S )NfetchTradingFeesz' fetchTradingFee() is not supported yet)r   r   r[   rw  r  )r>   r  r   r  s       r@   fetch_trading_feezExchange.fetch_trading_fee  sf      x*+ 	Ttw)RRSSS,,V44444444~~dF+++rA   c                 4   K   t          | j        dz             )Nz. fetchConvertCurrencies() is not supported yetrJ  r  s     r@   fetch_convert_currenciesz!Exchange.fetch_convert_currencies  r  rA   c                   K   | j         d         r|                                  d {V  |                     |          }|d         }|d         st          | j        dz             |                     |g|           d {V }|                     ||          }|t          | j        dz   |z             |S t          | j        dz             )NfetchFundingRatesr  rF  z2 fetchFundingRate() supports contract markets onlyz) fetchFundingRate() returned no data for z( fetchFundingRate() is not supported yet)	r   r   r	  r   r[   r  r?  r   r   r>   r  r   r	  ratesr  s         r@   fetch_funding_ratezExchange.fetch_funding_rate  s      8'( 	U##%%%%%%%%%[[((FH%F*% `*^ ^___22F8VDDDDDDDDE??5&11D|"47-X#X[a#abbbtw)SSTTTrA   c                   K   | j         d         r|                                  d {V  |                     |          }|d         }|d         st          | j        dz             |                     |g|           d {V }|                     ||          }|t          | j        dz   |z             |S t          | j        dz             )NfetchFundingIntervalsr  rF  z6 fetchFundingInterval() supports contract markets onlyz- fetchFundingInterval() returned no data for z, fetchFundingInterval() is not supported yet)	r   r   r	  r   r[   r  r?  r   r   r  s         r@   fetch_funding_intervalzExchange.fetch_funding_interval  s      8+, 	Y##%%%%%%%%%[[((FH%F*% d*b bccc66xHHHHHHHHE??5&11D|"47-\#\_e#effftw)WWXXXrA   c           
         K   | j         d         r7ddi}|                     |||||                     ||                     d{V 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
        fetchMarkOHLCVr  markNz& fetchMarkOHLCV() is not supported yetr   rd  r@  r   r[   r>   r  r  r  r  r   r  s          r@   fetch_mark_ohlcvzExchange.fetch_mark_ohlcv  s{       8$% 	SG ))&)UE4;;W^`fKgKghhhhhhhhhtw)QQRRRrA   c           
         K   | j         d         r7ddi}|                     |||||                     ||                     d{V 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
        fetchIndexOHLCVr  r  Nz' fetchIndexOHLCV() is not supported yetr  r  s          r@   fetch_index_ohlcvzExchange.fetch_index_ohlcv  s{       8%& 	TG ))&)UE4;;W^`fKgKghhhhhhhhhtw)RRSSSrA   c           
         K   | j         d         r7ddi}|                     |||||                     ||                     d{V 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
        fetchPremiumIndexOHLCVr  premiumIndexNz. fetchPremiumIndexOHLCV() is not supported yetr  r  s          r@   fetch_premium_index_ohlcvz"Exchange.fetch_premium_index_ohlcv  s{       8,- 	[G ))&)UE4;;W^`fKgKghhhhhhhhhtw)YYZZZrA   c                    K   | j         d         r|                     ||||           d{V S t          | j        dz             )a6  
 @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>`
        fetchDepositsWithdrawalsNz) fetchTransactions() is not supported yet)r   r  r   r[   r  s        r@   fetch_transactionszExchange.fetch_transactions  s[       8./ 	V88ueVTTTTTTTTTtw)TTUUUrA   r   maxEntriesPerRequestc                   K   d }|                      ||dd          \  }}d }	|                      ||dd          \  }	}d }
|                      ||dd          \  }
}d }|}|                      ||d|          \  }}d}g }d}|                     |g d	          }|                     |||          \  }}|
d
k    r|t          | j        dz             |}||k     r7|dz  }	 |
dk    r||dz
  |d<    t          | |          |d ||           d {V }t          |          }| j        rid|                     |          z   dz   |z   dz   |                     |          z   }||d|                     |          z   z  }| 	                    |           |dk    rnwd}| 
                    ||          }|                     |d          }|                     |dd          }|||k    rn(n t          | |          ||||           d {V }t          |          }| j        rid|                     |          z   dz   |z   dz   |                     |          z   }||d|                     |          z   z  }| 	                    |           |dk    rnd}| 
                    ||          }|                     ||dz
            }|                     |d          dz   }|||k    rn,n$# t          $ r}|dz  }||	k    r|Y d }~nd }~ww xY w||k     7|}|r|                     |          }|dk    rdnd}|                     ||          }|                     ||||          S )NpaginationCallsrs  r  r]   paginationDirectionbackwardremoveRepeatedr   )untiluntilltillforwardzM pagination requires a since argument when paginationDirection set to forwardrT  r  zDynamic pagination call  method  response length z timestamp 	timestamp
fetchOHLCV)r  safe_integer_n)handle_max_entries_per_request_and_paramsr   r[   r   r  r   number_to_stringr   array_concatr?  safe_integer_2safe_integerr   #remove_repeated_elements_from_arrayr  filter_by_since_limit)r>   r   r  r  r  r   r  r  maxCallsr  r  paginationTimestampremoveRepeatedOptioncallsr   r   r  r   responseLengthbackwardMessagefirstElementforwardMessagelastr   uniqueResultsr  	sortedRess                              r@   fetch_paginated_call_dynamicz%Exchange.fetch_paginated_call_dynamic  s     88IZ\^__&
!::66<YZ[[
F"&*&C&CFFTiku&v&v#V"-'+'D'DVVUegu'v'v$f##F,G,G,GHH'+'U'UV\^rtz'{'{$f9,,}'  3B  )B  C  C  C"'xQJE)&*44 +6*=*Aw%:WT6%:%:64I]_e%f%fffffffH%(]]N| 2*DtG\G\]bGcGc*cfp*psy*y  }P  +P  SW  Sh  Sh  iw  Sx  Sx  +x.:+}t?T?TUh?i?i/iiO111%**F!..vx@@F#'??8Q#?#?L*.*=*=lKYZ*[*[')0Cu0L0L &;WT6%:%:6CVXlnt%u%uuuuuuuH%(]]N| 1)CdF[F[\aFbFb)beo)orx)x  |O  *O  RV  Rg  Rg  hv  Rw  Rw  *w.:*md>S>STg>h>h.hhN000%**F!..vx@@F??8^a5GHHD*.*;*;D+*N*NQR*R')0Cu0L0L   !J&&G '&&&&Q xX  	M DDVLLMl**aaLL44	)))UE3GGGs.   B8K% AK% (B(K% AK% %
L/LLc                 r  K   d }|                      ||dd          \  }}d}||k    r	 |r)|dk    r# t          | |          |||||           d {V S  t          | |          ||||           d {V S # t          $ r.}	t          |	t                    r|	|dz  }||k    r|	Y d }	~	nd }	~	ww xY w||k    g S )Nr  r]   r   fetchFundingRateHistoryrT  )r  r   r   r   r   )
r>   r   r  r  r  r  r   r  r   r   s
             r@   safe_deterministic_callz Exchange.safe_deterministic_call]  s0     
!::66<YZ[[
F
""
 U+D!D!D!6v!6!6vy%QVX^!_!________!6v!6!6vueV!T!TTTTTTTT   a!233 G!J&&G '&&&&	 
"" 	s   *A6 !A6 6
B. $B))B.c                   K   d }|                      ||dd          \  }}|                     |||          \  }}|                                 }	g }
|                     |          dz  }||z  }|	||z  z
  dz
  }|t	          ||          }nt	          |d          }|                     |dd          }|gt          t          j        ||z
            |z            }||k    r:t          | j
        dz   t          |          z   d	z   t          |          z             t          d
|          D ]Z}|||k    r nO||	k    r nG|
                    |                     ||||||                     |                     ||          dz
  }[t!          j        |
  d {V }g }t          d
t%          |                    D ]}|                     |||                   }|                     |          }|dk    rd
nd}|                     ||||          S )Nr  rs  r   rT  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  r  r  parse_timeframemaxr  intmathceilr   r[   r  r  re  r  sumrs   gatherr  r  r  r  )r>   r   r  r  r  r  r   r  r  currenttaskstimestepcurrentSincer  requiredCallsr  resultsr   r  r  s                        r@   "fetch_paginated_call_deterministicz+Exchange.fetch_paginated_call_deterministico  s     88IZ\^__&'+'U'UV\^rtz'{'{$f##%%##I..5**(T/2Q6|U33LL|];;L##FGV<<	55= : :T ABBMx''   ,c  "c  fi  jr  fs  fs  "s  vK  "K  NQ  R_  N`  N`  "`  a  a  aq(## 	< 	<A!(=(=w&&LL55fflThjsu{||}}}88L$77!;LL.......q#g,,'' 	; 	;A&&vwqz::FF@@HHl**aa))-sKKKrA   c
                   K   d }
|                      ||dd          \  }
}d }|                      ||dd          \  }}|                     ||	|          \  }	}d }d}d}g }|                     |d          }|                     |d          }||
k     r	 |||                     |          |z   }|||<   d }|dk    r  t          | |          |           d {V }ny|dk    s|d	k    r! t          | |          ||           d {V }nL|d
k    r$ t          | |          ||||	|           d {V }n" t          | |          |||	|           d {V }d}t          |          }| j        rQ|dn|}|dz   }dt          |          z   dz   |z   dz   t          |          z   dz   |z   }| 	                    |           |dk    rn| 
                    ||          }|                     ||dz
            }d }t          d|          D ]R}||z
  dz
  }|                     ||          }|                     |d          }|                     ||          }||} nS|nP|                     |d          }|||k     rn1n$# t          $ r}|dz  }||k    r|Y d }~nd }~ww xY w|dz  }||
k     |                     |          }|dk    rdnd}|                     ||||          S )Nr  rs  r  r]   r   r  fetchAccountsgetLeverageTiersPaginatedfetchPositionsfetchOpenInterestHistoryr   rT  zCursor pagination call r  r  z cursor infor  r  )r  r  r8  r  parse_to_intr   r  r   r  r   r  r  r  r?  r  r   sort_cursor_paginated_resultr  ) r>   r   r  r  r  r   cursorReceived
cursorSentcursorIncrementr  r  r  cursorValuer  r   r   r  r   r  cursorString	iterationcursorMessager  jr  entryr  cursorlastTimestampr   sortedr  s                                    r@   fetch_paginated_call_cursorz$Exchange.fetch_paginated_call_cursor  s     88IZ\^__&
!::66<YZ[[
F'+'U'UV\^rtz'{'{$f$$V[99	6;//(ll+*&2&*&7&7&D&D&V)4F:&_,,%:WT6%:%:6%B%BBBBBBBHH:::fHX>X>X%:WT6%:%:66%J%JJJJJJJHH999%:WT6%:%:69eUikq%r%rrrrrrrHH%:WT6%:%:65J^`f%g%gggggggH!$X< ,*5*=22KL!"QI$=I$NQ[$[^d$dgz$z  ~A  BP  ~Q  ~Q  %Q  T^  %^  am  %mMHH]+++!Q&&**68<<~~h0BCC"q.11  A*Q.2E NN8U;;E>>%88D!__T>BBF)&, * & $ 1 1$ D D ,1F1F   !J&&G '&&&& FA[ (ll\ 226::l**aa))&%DDDs&   D1I< BI< I< <
JJJc                   K   d }|                      ||dd          \  }}d }	|                      ||dd          \  }	}|                     |||          \  }}d}
d}g }|
|k     r	 |
dz   ||<    t          | |          ||||           d {V }d}t          |          }| j        rE|
t          d          z   }d|z   dz   |z   d	z   t          |          z   }|                     |           |dk    rnF|                     ||          }n$# t          $ r}|dz  }||	k    r|Y d }~nd }~ww xY w|
dz  }
|
|k     | 	                    |          }|d
k    rdnd}| 
                    ||||          S )Nr  rs  r  r]   r   rT  zIncremental pagination call r  r  r  r  )r  r  r   r  r   r  r   r  r   r  r  )r>   r   r  r  r  r   pageKeyr  r  r  r  r   r   r   r  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(ll"#a%w!6v!6!6vuFZ\b!c!ccccccc!$X< 1!"SVVI)G))SV`)`ci)il)  CF  GU  CV  CV  *V&HH/000!Q&&**68<<   !J&&G '&&&& FA# (ll$ 226::l**aa))&%DDDs   $BD	 2D	 	
D*D%%D*c                    K   | j         d         r!|                     |g|||           d{V }|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>`
        fetchPositionsHistoryNz, fetchPositionHistory() is not supported yet)r   fetch_positions_historyr   r[   )r>   r  r  r  r   	positionss         r@   fetch_position_historyzExchange.fetch_position_history  sc       8+, 	Y"::F8UESYZZZZZZZZItw)WWXXXrA   c                 ~   K   t          j        |                                 |                                 g  d {V  d S rC   )rs   r  r   rK  rL   s    r@   load_markets_and_sign_inz!Exchange.load_markets_and_sign_in  sD      nt0022DLLNNCDDDDDDDDDDrA   c                 4   K   t          | j        dz             )r  z- fetchPositionsHistory() is not supported yetrJ  r  s        r@   r  z Exchange.fetch_positions_history  s       47%TTUUUrA   c                 4   K   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 yetrJ  r  s       r@   fetch_transferzExchange.fetch_transfer
	  s       47%LLMMMrA   c                 4   K   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 yetrJ  r  s        r@   fetch_transferszExchange.fetch_transfers	  s       47%MMNNNrA   c                 4   K   t          | j        dz             )a  
        watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        z$ unWatchOHLCV() is not supported yetrJ  r5  s       r@   un_watch_ohlcvzExchange.un_watch_ohlcv	  s       47%KKLLLrA   c                 4   K   t          | j        dz             )a:  
        watches a mark price for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/?id=ticker-structure>`
        z& watchMarkPrice() is not supported yetrJ  r  s      r@   watch_mark_pricezExchange.watch_mark_price)	         47%MMNNNrA   c                 4   K   t          | j        dz             )a9  
        watches the mark price for all markets
        :param str[] symbols: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/?id=ticker-structure>`
        z' watchMarkPrices() is not supported yetrJ  r  s      r@   watch_mark_priceszExchange.watch_mark_prices2	         47%NNOOOrA   c                 4   K   t          | j        dz             )a  
        make a withdrawal
        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the bitvavo api endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        z" withdrawWs() is not supported yetrJ  r  s         r@   withdraw_wszExchange.withdraw_ws;	  s       47%IIJJJrA   c                 4   K   t          | j        dz             )aU  
        unWatches information on multiple trades made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        z' unWatchMyTrades() is not supported yetrJ  r  s      r@   un_watch_my_tradeszExchange.un_watch_my_tradesG	  r  rA   c                 4   K   t          | j        dz             )a  
        create a list of trade orders
        :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        z& createOrdersWs() is not supported yetrJ  r  s      r@   create_orders_wszExchange.create_orders_wsP	  r  rA   r   c                 4   K   t          | j        dz             )a  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        z- fetchOrdersByStatusWs() is not supported yetrJ  )r>   r   r  r  r  r   s         r@   fetch_orders_by_status_wsz"Exchange.fetch_orders_by_status_wsY	  s       47%TTUUUrA   c                 4   K   t          | j        dz             )a7  
        unWatches best bid & ask for symbols
        :param str[] symbols: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/?id=ticker-structure>`
        z' unWatchBidsAsks() is not supported yetrJ  r  s      r@   un_watch_bids_askszExchange.un_watch_bids_asksc	  r  rA   rC   )r   NN)F)NNN)NN(O  __name__
__module____qualname__synchronousrA  r8  
newUpdatesr:  r   r   r;   rJ   rM   rR   rT   rV   r\   rq   rr   ra   rg   r`   rc   r   r   r   r   r   r   r  r   r   r  r  r   r  r(  staticmethodr   r   r0  r2  r5  rE  rH  r;  ro  ru  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  floatr  r  r  r  r!  r&  r$  boolr*  r.  r0  r3  r6  r8  r   r;  r>  r@  rC  rH  rF  rK  rM  rP  rR  rU  rW  rY  r\  r^  rd  rf  rh  rk  rm  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,  r0  r2  r5  r:  r  r?  rC  rE  rG  rI  rK  rN  rS  r[  r_  re  rh  ro  rt  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  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  r3  r5  r8  r:  r=  r?  rC  rH  rO  rS  rW  rZ  r_  rb  rf  ri  rm  rp  rs  ru  rw  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  r  r  __classcell__)r?   s   @r@   r   r   D   s@       K I DJGO13 
' 
' 
' 
' 
' 
' 
' 
'f f f! ! !H H H H* * * *  l l l 6!!	 	 		 	 	I I I*/ / /0 0 0- - -D  D  D  D L5 5 5" 05R 5 5 5 5  ).b % % % %N        *, + + + + -/     37d$WY P P P P 04B 9 9 9 98 8 8  
 
 
   \   \ #%D * * * * +-D 1 1 1 1 +-D 1 1 1 1! ! !6W W W  % % % %N) ) ) )V   
) ) )- - -& & & HLTV S S S S2  
  2  T +- N N N N <@d[] L L LS L L L L L ?CQU^` N NC N N3 N N N N BFTXac R Rs R3 Rc R R R R
 UYgktv \ \DI \c \ad \ \ \ \ EIW[df T T# Tc TQT T T T T
 X\jnwy ^ ^tCy ^QT ^dg ^ ^ ^ ^ <@d[] L L LS L L L L L 37r N NC N N N N 9; N NC N N N N OSaenp V Vd3i V V[^ V V V V LN X Xc X X X X RVdhqs X Xc X3 X^a X X X X OSaenp V Vd3i V V[^ V V V V aesw  AC U U$tCy/ UZ] Ump U U U U ^` W WT$s)_ W W W W SW_a Y Y$s) YC Y Y Y Y PR [ [T#Y [ [ [ [ ;?r Q Q Q Q Q Q 9; N NC N N N N =? Q Q Q Q Q Q =A R R' R R R R >B" V V7 V V V V @DB O OS O O O O O CGr Q Q QC Q Q Q Q ;= T Tc T T T T ;?r Q Q Q Q Q Q >B" 	 	 	 	 @DB O OS O O O O O =? Q Q Q Q Q Q ') J J J J =A S S' S S S S 57 V V V V 8: Y Y Y Y =A S S' S S S S <@ R R R R R R @DB V VW V V V V <> Q Qs Q Q Q Q <@ R R R R R R ?C2 T TG T T T T PR ? ?T#Y ? ? ? ? ac I I3 I IC ITW I I I I QU]_ I I3 I I I# I I I I >@ U U U U U U ?C2 L L3 L L L L L 8: R R3 R R R R 8<B O OW O O O O CGr P Pd PC P P P P CE J Js JE J J J J FH M M# Mu M M M M CE J Js JE J J J J JNVX T T3 T3 T T T T BFX\ko  C  LN [ [3 [RU [eh [x{ [ [ [ [ CGTXgkz~  HJ 
] 
]C 
]c 
]ad 
]tw 
] 
] 
] 
] DHPR N N NS N N N N JL _ _S _ _ _ _ OSaetx  BD Y Y Y Y[^ Ynq Y Y Y Y =? V V V V V V =A S S' S S S S $& G G G G 24 T T T T HJ K KC K K K K K IK M MS M% M M M M Y[ P P# PS P% P P P P JL N Nc N5 N N N N Z\ Q Q3 Qc Q5 Q Q Q Q KOWY B B BU BC B B B B JNVX  s E 3     ?CQUdhqs U U U U3 U^a U U U U DHVZimvx O OS OS OPS Ocf O O O O HLZ^mqz| S S S STW Sgj S S S S BFTXgktv v v3 v3 vc vad v v v v ?CQUdhqs K K K K3 K^a K K K K+, +, +, +,Z CGr   C     <@VX       -5U2^bpt}  c X[ jm    < .6eB_cqu  A S Ss SY\ Skn S S S S */r 	 	 	 	 \`hj U US U# Uu UUX U U U U ]aik V Vc V3 V VVY V V V V imuw W W Wc W WTY Wbe W W W W fjx|  FH R R3 R R9 RI R_b Rru R R R R FJ  Y]  fh \ \3 \PS \[d \lu \  @C \  SV \ \ \ \ im{  IK U Uc U3 Ui Uy Ube Uux U U U U 8: N N3 N N N N ;= P Pc P P P P 26b N N3 N N N N 8<$]ajl O OW OC OWZ O O O O CGUYhluw I I Is Ibe I I I I DF X Xs X X X X GI X X# X X X X 8<B O OW O O O O ;?r O O O O O O =A S S' S S S S 8<B N NW N N N N 7;$]apt} T T TC TWZ Tjm T T T T .2SW`b L Ls L# LS L L L L =A Q Q3 Qc Q Q Q Q *, M M M M -/ O O O O *, M M M M 8:     /1 @ @ @ @ /1 @ @ @ @ 02 A A A A )+ L L L L =? A A A A A A
 =A U U' U U U U BFb Y Yw Y Y Y Y BD + +S + + + + ?A  #     DF  s     68 P P P P P P :< T TS T T T T 9; R RC R R R R 68 L L L L L L 6:" M M7 M M M M ;?r Q Q Q Q Q Q ?C2 U UG U U U U :>b P Pw P P P P 9=R O Og O O O O :>DY[ P Pw Pc P P P P 8<B N NW N N N N 6:" M M7 M M M M 9=R O Og O O O O ?A S S# S S S S 8<B K KC K K K K K X\df 	B 	BC 	BQT 	B 	B 	B 	B ;?r M Ms MC M M M M ?C2  3      79 p p p p mqy{ L L LI LY LX] Lfi L L L L ln P Pc P PE P]b P P P P ]aik S SS SC S SVY S S S S >B" R RC Rs R R R R =Atbfoq Y Yc Y Y\_ Y Y Y Y 7;2 R R R R R R 8: M M3 M M M M AER V Vg V V V V AC Z ZC Z Z Z Z }A  Y]  {  HJ Z Z ZI ZU^ Zhm Zvy Z  SV Z  ux Z Z Z Z, @D  \`  ~B  KM \ \C \y \Xa \kp \y| \  VY \  x{ \ \ \ \, ~B  [_  }A  JL [ [# [Y [V_ [in [wz [  UX [  wz [ [ [ [, AE  ^b  @D  MO ] ]S ]	 ]Yb ]lq ]z} ]  X[ ]  z} ] ] ] ], eg Z Z# ZY ZV[ Z Z Z Z XZ 
] 
]c 
] 
] 
] 
] 
] Y[ 
^ 
^s 
^% 
^ 
^ 
^ 
^ hj \ \S \	 \Y^ \ \ \ \ uy  OS  \^ S S SI SY S`e Snq S  IL S S S S& x|  RV  _a U UC Uy UPY Uch Uqt U  LO U U U U& w{  RV  _a T T3 Ti Ty Tbg Tps T  LO T T T T& z~  UY  bd V Vc V VR[ Vej Vsv V  OR V V V V& y}  VZ  ce V VS V	 VQZ Vdi Vru V  PS V V V V& |@  Y]  fh X X X9 XT] Xgl Xux X  SV X X X X& LP  dh  z~  GI e e eS\ edm ew| e  FI e  ^a e  tw e e e e4 OS  gk  }A  JL g g3 gV_ ggp gz g  IL g  ad g  wz g g g g4 FH M M$|*< M M M M KM Q QtL/A Q Q Q Q OQ U U43E U U U U DF K K\(: K K K K pt|~ N NC Ny N	 N[` Nil N N N N 9=R L LS L# L L L L >B" P P# Ps P P P P BFb T Tc T3 T T T T Y]eg 	C 	CS 	CRU 	C 	C 	C 	C <@ N N NS N N N N AER M MtCy M# M M M M bfnp 	D 	DS	 	D[^ 	D 	D 	D 	D DHPR O O$s) OS O O O O 59 P Pc P P P P :>b T T3 T T T T >B" X Xs X X X X BD U US U U U U Y[ W Wd;N6O W W W W 8<B R R R R R R ?A k k k k k k 04$UYbd L L LC Ls L L L L
 37TX\eg N NC Ns NRU N N N N ?CQUdhqs Q Q3 Q Q3 Q^a Q Q Q Q 04$UYbd L L LC Ls L L L L 59tZ^gi P Pc P PTW P P P P 8<$]ajl R R RC RWZ R R R R 7;\`ik R R R3 RVY R R R R 9=4^bkm T T# TS TX[ T T T T DHVZimvx ] ]S ]PS ]cf ] ] ] ] :>D_cln T T3 Tc TY\ T T T T 37TX\eg N NC Ns NRU N N N N 9=4^bkm T T# TS TX[ T T T T BFTXac R Rs R3 Rc R R R R 6:[_hj P Ps P# PUX P P P P 37TX\eg N NC Ns NRU N N N N 68 L L L L L L 9=R O Og O O O O :< Q QS Q Q Q Q 68 L L L L L L SW_a R R# Rs RC R R R R <@daenp 	Y 	YS 	Y 	Y[^ 	Y 	Y 	Y 	Y 04$UYbd N N NC Ns N N N N 37TX\eg Q QC Qs QRU Q Q Q Q 37TX\eg P PC Ps PRU P P P P 6:[_hj S Ss S# SUX S S S S >BPTcgpr X Xs X# X]` X X X X 9=4^bkm T T# TS TX[ T T T T CGr N N3 Ni N N N N 02 R R R R CGr O O OC O O O O =? X X X X X X* FH \ \ \ \ \ \ jl U Us U) UU U[` U U U U mo X X# XY XPU X^c X X X X cgoq V V V9 Ve V\_ V V V V fjrt Y Y3 Yi YQV Y_b Y Y Y Y ]_ V V3 V Ve V V V V `b Y Yc Y5 YQV Y Y Y Y ^` W WC W Wu W W W W ac Z Zs ZE ZRW Z Z Z Z PR V VC V V V V V SU Y Ys YE Y Y Y Y QS W WS W% W W W W TV Z Z ZU Z Z Z Z 13 . . . . EG ] ] ] ] ] ] w{  DF Q Q3 Qi Qy Qbg Qps Q Q Q Q z~  GI T Tc T TR[ Tej Tsv T T T T y}  FH Q QS Q	 QQZ Qdi Qru Q Q Q Q |@  IK T T T9 TT] Tgl Tux T T T T rv  LP  Y[ Q Qc Q Q) Q]b Qkn Q  FI Q Q Q Q uy  OS  \^ T T TI TY T`e Tnq T  IL T T T T DF T TC Ty TRW T`e Tuz T T T T GI W Ws W) WUZ Wch Wx} W W W W wy T TS T	 TSX Thm T T T T z| W W W9 WV[ Wkp W W W W :< Q QS Q Q Q Q :>b P Pw P P P P /1 Q Q Q Q 24 S S S S ;= , ,c , , , , 57 W W W W <> U Us U U U U  @B Y Y3 Y Y Y Y  DHVZimvx S SS SS SPS Scf S S S S$ EIW[jnwy T Tc Tc TQT Tdg T T T T$ MQ_crv  @B [ [c [c [Y\ [lo [ [ [ [$ 48dY]fh V VS V VSV V V V V MQ_crv  @B  `d  uy DH DH DHc DHY\ DHlo DH  Z] DH DH DH DHL HLZ^mq  EI  RT  C  TW gj   B    $ SWeix|  PT  ]_  vz L Ls LC L_b Lru L  JM L L L LB LPW[cgpr  DH  UY  ko  FJ <E <E <ES <E <E <E <E| QU\`hluw  BF  ]a E ES E# E E E E> FJX\eg Y Y3 Ys YRU Y Y Y YE E E @DRVeirt 	V 	VW 	VC 	V_b 	V 	V 	V 	V 9=R N Ns N# N N N N 154VZce 	O 	O# 	OS 	OPS 	O 	O 	O 	O BFb M M3 M3 M M M M :< O OS O O O O :>b P Pw P P P P TX`b 
K 
Kc 
K5 
K3 
KS 
K 
K 
K 
K 6:" P Ps P P P P IK O OT,-? O O O O JN\`os|~ V Vc V3 VVY Vil V V V V ;?r P P P P P P P P P PrA   )@__version__rs   concurrent.futuresr   r   r7   r{   rk   rq   r   r  typingr   r   ccxt.base.typesr   r   r   r   !ccxt.async_support.base.throttlerr	   ccxt.base.errorsr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ccxt.base.exchanger   r&   r   $ccxt.async_support.base.ws.functionsr   r   !ccxt.async_support.base.ws.clientr    !ccxt.async_support.base.ws.futurer!   %ccxt.async_support.base.ws.order_bookr"   r#   r$   aiohttp_socksr%   r   ImportError__all__ccxt.protobuf.mexcr'   google.protobuf.json_formatr(   rO  rA   r@   <module>r     s  
          



 



           2 2 2 2 2 2 2 2 2 2 2 2 8 7 7 7 7 7 P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P k k k k k k k k k k k k k k k k K J J J J J J J A @ @ @ @ @ @ @ 4 4 4 4 4 4 4 4 4 4 4 4 _ _ _ _ _ _ _ _ _ _
CCCCCCC    ;;;;;;9999999   #MMMf$P f$P f$P f$P f$P| f$P f$P f$P f$P f$Ps$   B B%$B%-B: :	CC