
    E#i+                    0   S SK Jr  S SKJr  S SKJrJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJ r   S SKJ!r!  S SKJ"r"  S SKJ#r#  S SKJ$r$  S SKJ%r%  S SK&J'r'  S SK(J)r)   " S S\\5      r*g)    )Exchange)ImplicitAPI)AnyBalances
CurrenciesCurrencyDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeeInterfaceTransaction)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)RateLimitExceeded)ExchangeNotAvailable)	TICK_SIZE)Precisec                     ^  \ rS rSrS\4U 4S jjr0 4S\4S jjr0 4S\\	   4S jjr
0 4S\4S jjrSSS0 4S\S	\S
\S\\   4S jjrSSS0 4S\S	\S
\S\\   4S jjrS rSCS\S\S\4S jjrS0 4S\S\4S jjr0 4S\S\4S jjrS0 4S\S
\S\4S jjrSS0 4S\S	\S
\S\\   4S jjrSSS0 4S\S\S	\S
\S\\   4
S jjr S\!4S jr"0 4S\!4S jjr#S0 4S\S\$S\%S\&S\'4
S  jjr(SS0 4S!\S\S\$S\%S\'S\'4S" jjr)S0 4S!\S\4S# jjr*S0 4S$\\   S\4S% jjr+S0 4S!\S\4S& jjr,SSS0 4S\S	\S
\S\\-   4S' jjr.SSS0 4S\S	\S
\S\\-   4S( jjr/SSS0 4S\S	\S
\4S) jjr0SCS*\S+\	S\14S, jjr20 4S\S\14S- jjr3S+\S\	4S. jr4S\S\4S/ jr5SCS0\S+\	S\4S1 jjr6SCS2\S+\	S\4S3 jjr7SCS+\	S\4S4 jjr8SCS5\S+\	S\-4S6 jjr90 4S\S\:4S7 jjr;SCS\S\:4S8 jjr<S9S:0 SS4S; jr=S<\>S=\S>\S?\S@\4
SA jr?SBr@U =rA$ )Dtimex   returnc                  4  > U R                  [        [        U ]  5       SSS/SS0 SS _SS_S	S
_SS
_SS
_SS
_SS
_SS
_SS
_SS
_SS_SS_SS
_SS
_SS_SS
_SS
_0 SS
_SS
_SS_SS
_SS_SS
_SS
_S S
_S!S
_S"S
_S#S
_S$S_S%S
_S&S
_S'S_S(S
_S)S_E0 S*S
_S+S
_S,S_S-S
_S.S
_S/S
_S0S
_S1S
_S2S
_S3S
_S4S
_S5S
_S6S
_S7S
_S8S
_S9S
_S:S
_E0 S;S
_S<S
_S=S
_S>S
_S?S
_S@S
_SAS
_SBS_SCS
_SDS
_SES
_SFS
_SGS
_SHS_SIS_SJS
_SKS
_E0 SLS
_SMS_SNS
_SOS
_SPS_SQS_SRS
_SSS
_STS
_SUS
_SVS
_SWS
_SXS
_SYS
_SZS
_S[S_S\S_ESSSS
S
S
SS
S
S
S
S
S
S
S].ES^S_S`SaSbScSdSeSfSgShSi.SjSkSl0SmSnSoSp.Sq// SrQSs.St/ SuQ0St/ SvQ0/ SwQ/ SxQSs.St/ SyQ0SzS{// SxQSs.St/ S|Q0StS}/0/ S~QSS/SS/SS/S.St/ SQ0S.
[        0 S[
        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[
        _S[        _S[        _[        [        [        [
        [        S.ES[        0S.SSS0SS0SS0SS0SS0SSS.S
S
S
S
S S
S
S SSS
SS.S
S
S
S
S
S
S
S.S S
SSSS
S.S
S
S
S
S.S
SS
S
S
S.S S
SSSSS
S
S
S.SS 0S.	S S S.S S S.S.S.5      $ )Nr'   TimeXAUv1i  CORSspotTmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelOrdercancelOrderscloseAllPositionsclosePositioncreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrder	editOrderfetchAllGreeksfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricefetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickers)	fetchTimefetchTradesfetchTradingFeefetchUnderlyingAssetsfetchVolatilityHistoryfetchWithdrawalfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModeI1I5I15I30H1H2H4H6H12D1W1)1m5m15m30m1h2h4h6h12h1d1wzchttps://user-images.githubusercontent.com/1294454/70423869-6839ab00-1a7f-11ea-8f94-13ae72c31115.jpgrestz%https://plasma-relay-backend.timex.iozhttps://timex.ioz;https://plasma-relay-backend.timex.io/swagger-ui/index.htmlz+https://timex.io/?refcode=1x27vNkTbP1uwkCck)logoapiwwwdocreferralme) zid/{id}zid/{id}/remove)getpostr   )credentialszcredentials/h/{hash}zcredentials/k/{key}zcredentials/mezcredentials/me/addresszdeposit-addresseszdeposit-addresses/h/{hash})orderszorders/detailszorders/export/csvtradesztrades/export/csv)za/{address}i/{id}
s/{symbol})performpreparezremove/performzs/{symbol}/remove/preparezs/{symbol}/update/performzs/{symbol}/update/prepare)deposits	transferswithdrawalsr   r   )candles
currenciesmarkets	orderbookzorderbook/rawzorderbook/v2tickersr   address)balancesfeesr   r   zorders/json)r   r   putdelete)confighistorysymbol_infotime)
addressbookcustodyr   r   managerr   public
statisticstradingtradingview014000400140024003400440054006400743004100440050015002400401)403404429500503Insufficient)exactbroadi3periodr   sorttimestamp,asccreatedAt,asc)expireInr   r   rn   rs   rJ   defaultSortdefaultSortOrders)IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergd   i )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r  )r   r  r  r   r     )r   r  r  daysBackCanceledr  r  r   r  r  )	sandboxr<   createOrdersrn   rv   rs   fetchOrdersrJ   ro   )linearinverse)r/   r1   r2   )idname	countriesversion	rateLimithas
timeframesurlsr   precisionMode
exceptionsoptionsfeatures)deep_extendsuperr'   describer$   r   r!   r   r   r   r   r    r   r"   r#   )self	__class__s    D/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/timex.pyr  timex.describe   sw   eT ; =ddd %d 	d
 %d %d Ud $Ud 'd d td d $Ud  d td  (!d" '#d$ (%d& "5'd( T)d* !%+d, -d. &u/d0 "51d2 +E3d4 )%5d6 #E7d8 ,U9d: $T;d< '=d> (?d@ "4AdB CdD &tEdF (GdH 1%IdJ  KdL &uMdN 'OdP (QdR #ESdT *5UdV $UWdX uYdZ "5[d\ *5]d^ +E_d` )%adb  cdd !%edf %egdh $Uidj &ukdl -emdn /odp "5qdr #Esdt +Eudv wdx !%ydz !%{d| "5}d~ &ud@ +EAdB  CdD dEdF $UGdH +EIdJ %eKdL "4MdN uOdP #EQdR dSdT !$UdV  WdX 'YdZ $U[d\ !%]d^ *5_d` (adb %ecdd )%edf )%gdh tidj kdl "##').*/#($( %$)',$"!&#(GdL  ~C *TI 		   
  
    !$  	 ! !%
 !%
 !%(   Oo` ' J J	
 - / / J J J , / M L M  :!" .#$ ,(,(/-2 #$53< %d! O  O" O$ O&  /%4%,  %&+(-,1,0).+06: $(#'"'#'	( #($)$)+027/4#(+$. %)&+!$$*%+*/& ',#($)*/	# ',!$#($)*/( $(&+!$$*,-%+#($)*/	*  #s<| ##
 ##EFG	j@
 j j	    c                 L    U R                  U5      nU R                  U5      S-  $ )z
fetches the current integer timestamp in milliseconds from the exchange server
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int: the current integer timestamp in milliseconds from the exchange server
  )tradingviewGetTimeparse_to_intr  paramsresponses      r!  
fetch_timetimex.fetch_time  s,     **62   *T11r#  c                 F    U R                  U5      nU R                  U5      $ )a  
retrieves data on all markets for timex

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/listMarkets

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
)publicGetMarketsparse_marketsr(  s      r!  fetch_marketstimex.fetch_markets  s'     ((0, !!(++r#  c                 F    U R                  U5      nU R                  U5      $ )a!  
fetches all available currencies on an exchange

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/listCurrencies

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
)publicGetCurrenciesparse_currenciesr(  s      r!  fetch_currenciestimex.fetch_currencies  s'     ++F34 $$X..r#  Ncodesincer  c                    U R                  US5      nU R                  US5      nUc  [        U R                  S-   5      eSU0nU R	                  U R                  Xd5      5      nU R                  U5      nU R                  XxX#5      $ )a  
fetch all deposits made to an account

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Manager/getDeposits

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch deposits for
:param int [limit]: the maximum number of deposits structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
r   . fetchDeposits() requires an address parameter)safe_stringomitr   r  managerGetDepositsextendsafe_currencyparse_transactions	r  r7  r8  r  r)  r   requestr*  currencys	            r!  fetch_depositstimex.fetch_deposits  s     ""69569-?#DGG.^$^__w
 **4;;w+GH %%d+&&x5HHr#  c                    U R                  US5      nU R                  US5      nUc  [        U R                  S-   5      eSU0nU R	                  U R                  Xd5      5      nU R                  U5      nU R                  XxX#5      $ )a  
fetch all withdrawals made to an account

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Manager/getWithdraws

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch withdrawals for
:param int [limit]: the maximum number of transaction structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
r   r:  )r;  r<  r   r  managerGetWithdrawalsr>  r?  r@  rA  s	            r!  fetch_withdrawalstimex.fetch_withdrawals  s     ""69569-?#DGG.^$^__w
 --dkk'.JK %%d+&&x5HHr#  c                     U R                   n[        S[        U5      5       H5  nX#   nU R                  US0 5      nU R	                  US5      nXa:X  d  M3  Us  $    g )Nr   infor   )r   rangelen
safe_valuer;  )r  r   r   irC  rK  as          r!  get_currency_by_addresstimex.get_currency_by_address   sZ    __
q#j/*A!}H??8VR8D  y1A| + r#  transactionrC  c                    U R                  US5      nU R                  USS5      nU R                  U5      n0 SU_SU R                  US5      _SU R                  US5      _SU R                  U5      _SU_S	S _S
S _SU R                  US5      _SU R                  US5      _SS _SS _SS _SS _SU R                  US5      _SU R	                  S U5      _SS_SS _S S S S.E$ )N	timestamptokenr   rK  r  transferHashtxiddatetimenetworkr   	addressTotoaddressFromfromtagtagTotagFromtypeamountvaluerC  statusokupdated)internalcommentfee)r;  rQ  	parse8601safe_numbersafe_currency_code)r  rS  rC  rY  currencyAddressss        r!  parse_transactiontimex.parse_transaction*  su    ##K=++K"E//0@A
K
$"";?
 D$$[&9
 1	

 
 t
 t
 ))+t<
 4++K@
 4
 T
 t
 D
 d&&{G<
 //h?
  d!
" t#
$ )
 	
r#  symbolsc                     U R                  5         U R                  U R                  S   SS5      nSU R                  U   0nU R	                  U R                  XB5      5      nU R                  XQ5      $ )a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/listTickers

:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
r   r   r   )load_marketsr;  r  r  publicGetTickersr>  parse_tickers)r  rq  r)  r   rB  r*  s         r!  fetch_tickerstimex.fetch_tickersO  sp     	!!$,,~">$Odoof-
 ((W)EF$ !!(44r#  symbolc                 4   U R                  5         U R                  U5      nU R                  U R                  S   SS5      nUS   U R                  U   S.nU R                  U R                  XR5      5      nU R                  US5      nU R                  Xs5      $ )a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/listTickers

:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
r   r   r   r  marketr   r   )	rs  r{  r;  r  r  rt  r>  	safe_dictparse_ticker)r  rx  r)  r{  r   rB  r*  tickers           r!  fetch_tickertimex.fetch_tickerr  s     	V$!!$,,~">$OTloof-
 ((W)EF$ !,  00r#  c           	         U R                  5         U R                  U5      nSUS   0nUb  X%S'   U R                  U R                  XS5      5      nU R	                  U R                  US5      5      nU R                  XaUSSSS5      $ )	a,  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/orderbookV2

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
r{  r  r  rU  bidaskpricebaseTokenAmount)rs  r{  publicGetOrderbookV2r>  rk  r;  parse_order_book)r  rx  r  r)  r{  rB  r*  rU  s           r!  fetch_order_booktimex.fetch_order_book  s     	V$fTl
 $G,,T[[-IJ2 NN4#3#3Hk#JK	$$Xy%PWYjkkr#  c                    U R                  5         U R                  U5      nU R                  U R                  S0 5      nU R                  USS5      nU R	                  USU5      nU R                  US5      n	US   US.n
Ub  U R                  U5      U
S'   Ub  X:S'   U R                  U R                  X5      5      nU R                  XX#5      $ )a  
get the list of most recent trades for a particular symbol

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/listTrades

:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch
:param int [limit]: the maximum amount of trades to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
r   r   r   r  )r{  r   r^  size)
rs  r{  rN  r  r;  r<  iso8601publicGetTradesr>  parse_trades)r  rx  r8  r  r)  r{  r  r   r   queryrB  r*  s               r!  fetch_tradestimex.fetch_trades  s     	V$//$,,rBoogvG<		&&)
 Tl 	
 "ll51GFO#FO''G(CD   5@@r#  r   	timeframec           	      f   U R                  5         U R                  U5      nUS   U R                  U R                  X"5      S.nU R	                  U5      nU R                  US5      n	Uc  SnUbf  U R                  U5      US'   U	c:  U R                  U R                  X0R                  US5      U-  S-  5      5      US'   OU R                  U	5      US'   OU	bC  U R                  U	5      US'   XR                  US5      U-  S-  -
  n
U R                  U
5      US'   OSU R                  5       nU R                  U5      US'   U R                  XR                  US5      U-  S-  -
  S-
  5      US'   U R                  US5      nU R                  U R                  Xu5      5      nU R                  XX#U5      $ )a  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/listCandles

:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param int [since]: timestamp in ms of the earliest candle to fetch
:param int [limit]: the maximum amount of candles to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest candle to fetch
:returns int[][]: A list of candles ordered, open, high, low, close, volume
r  rz  untilr%  r^  r	  till)rs  r{  r;  r  parse_timeframesafe_integerr  summillisecondsr<  publicGetCandlesr>  parse_ohlcvs)r  rx  r  r8  r  r)  r{  rB  durationr  fromTimestampnowr*  s                r!  fetch_ohlcvtimex.fetch_ohlcv  s    	V$Tl&&t	M

 ''	2!!&'2=E"ll51GFO}"&,,txxxxq?QT\?\_c?c/d"e"&,,u"5"ll51GFO!HHUA$6$AD$HHM"ll=9GFO##%C"ll3/GFO"ll3%1Ch1NQU1U+UXY+YZGFO67+((W)EF   9UKKr#  c                 2   US S S.n[        S[        U5      5       Hh  nX   nU R                  US5      nU R                  U5      nU R	                  5       nU R                  US5      US'   U R                  US5      US'   XrU'   Mj     U R                  U5      $ )N)rK  rU  rY  r   rC  totalBalancetotallockedBalanceused)rL  rM  r;  rm  accountsafe_balance)r  r*  resultrO  balance
currencyIdr7  r  s           r!  parse_balancetimex.parse_balance,  s    

 q#h-(AkG))':>J**:6DllnG#//HGG"..wHGFO"4L )   ((r#  c                 f    U R                  5         U R                  U5      nU R                  U5      $ )ak  
query for balance and get the amount of funds available for trading or funds locked in orders

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Trading/getBalances

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
)rs  tradingGetBalancesr  r(  s      r!  fetch_balancetimex.fetch_balance<  s3     	**62 !!(++r#  rb  siderc  r  c                    U R                  5         U R                  U5      nUR                  5       nUR                  5       n	U R                  USS5      n
U
(       a  Sn	U R	                  US/5      nUS   U R                  X5      UU	S.nUnU	S:X  d  U	S:X  a  U R                  X5      US'   U R                  U R                  S5      nU R                  US	5      nU R                  USU5      nUb  XS	'   O&Ub  XS'   O[        U R                  S
-   U-   S-   5      eU R	                  US	S/5      nOSUS'   U R                  U R                  X5      5      nU R                  US/ 5      nU R                  US0 5      nU R                  UU5      $ )a  
create a trade order

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Trading/createOrder

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
postOnlyF	POST_ONLYr  )rx  quantityr  
orderTypesLIMITr  r   
expireTimezD createOrder() method requires a expireTime or expireIn param for a z: order, you can also set the expireIn exchange-wide optionr   r   )rs  r{  upper	safe_boolr<  amount_to_precisionprice_to_precisionr  r  rN  r   r  tradingPostOrdersr>  r|  parse_order)r  rx  rb  r  rc  r  r)  r{  uppercaseSideuppercaseTyper  rB  r  defaultExpireInr  r   r*  r   orders                      r!  create_ordertimex.create_orderR  s    	V$



>>&*e<'MYYv
|4FTl00@!'	
 W$-;*F#66vEGG"//jIO>Jvz?KH%(2%%&.
#"477-s#svz#z  ~z  $z  {  {IIf|Z&@AE GG))$++g*EF, 8R8vq"-v..r#  r  c                    U R                  5         U R                  U5      nSU0n	Ub  U R                  X%5      U	S'   Ub  U R                  X&5      U	S'   U R	                  U R                  X5      5      n
SU
;   a9  U R                  U
S/ 5      nU R                  US5      nU R                  UU
S.5      $ U R                  U
S/ 5      nU R                  US0 5      nU R                  US0 5      nU R                  X5      $ )	Nr  r  r  unchangedOrdersr   )r  rK  changedOrdersnewOrder)rs  r{  r  r  tradingPutOrdersr>  rN  r;  
safe_orderr|  r  )r  r  rx  rb  r  rc  r  r)  r{  rB  r*  orderIdsorderIdr   
firstOrderr  s                   r!  
edit_ordertimex.edit_order  s   V$"
 "&":":6"JGJ#66vEGG((W)EF4 (x1BBGH&&x3G?? $   ?B?__VQ3
z:r:..r#  c                 l    U R                  5         U R                  U/X#5      nU R                  US5      $ )al  
cancels an open order

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Trading/deleteOrders

:param str id: order id
:param str symbol: not used by timex cancelOrder()
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
r   )rs  cancel_ordersr|  )r  r  rx  r)  r   s        r!  cancel_ordertimex.cancel_order  s5     	##RD&9~~fa((r#  idsc           	         U R                  5         SU0nU R                  U R                  XC5      5      nU R                  US/ 5      nU R                  US/ 5      n/ n[	        S[        U5      5       H7  n	U R                  Xi   S5      n
UR                  U R                  U
5      5        M9     [	        S[        U5      5       H+  n	UR                  U R                  Xy   Xy   SS.5      5        M-     U$ )a  
cancel multiple orders

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Trading/deleteOrders

:param str[] ids: order ids
:param str symbol: unified market symbol, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
r  r  r  r   r  	unchanged)rK  r  re  )
rs  tradingDeleteOrdersr>  	safe_listrL  rM  r|  appendr  r  )r  r  rx  r)  rB  r*  r  r  r   rO  r  s              r!  r  timex.cancel_orders  s     	#
 ++DKK,HI4 x"E..3DbIq#m,-A~~m&6
CHMM$**845 . q#o./AMM$//'*%(%+   0 r#  c                     U R                  5         SU0nU R                  U5      nU R                  US0 5      nU R                  US/ 5      nU R	                  U R                  USU05      5      $ )a  
fetches information on an order made by the user

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/History/getOrderDetails

:param str id: order id
:param str symbol: not used by timex fetchOrder
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
	orderHashr  r   )rs  historyGetOrdersDetailsrN  r  r  r>  )r  r  rx  r)  rB  r*  r  r   s           r!  fetch_ordertimex.fetch_order  sv     	
 //8D '26(B7EHf3E FGGr#  c                    U R                  5         U R                  U R                  S0 5      nU R                  USS5      nU R                  USU5      nU R	                  US5      nSU0n	Sn
Ub  U R                  U5      n
U
S   U	S'   Ub  X9S'   U R                  U R                  X5      5      nU R                  US/ 5      nU R                  XX#5      $ )	a  
fetch all unfilled currently open orders

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Trading/getOpenOrders

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch open orders for
:param int [limit]: the maximum number of  open orders structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
rs   r   r   Nr  rx  r  r   )
rs  rN  r  r;  r<  r{  tradingGetOrdersr>  r  parse_ordersr  rx  r8  r  r)  r  r   r   r  rB  r{  r*  r   s                r!  fetch_open_orderstimex.fetch_open_ordersE  s     	//$,,0A2FoogvG<		&&) D

 [[(F &tGH#FO((W)DE, (B7  >>r#  c                    U R                  5         U R                  U R                  S0 5      nU R                  USS5      nU R                  USU5      nU R	                  US5      nUSS.n	Sn
Ub  U R                  U5      n
U
S   U	S'   Ub  U R                  U5      U	S	'   Ub  X9S
'   U R                  U R                  X5      5      nU R                  US/ 5      nU R                  XX#5      $ )a$  
fetches information on multiple closed orders made by the user

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/History/getOrders

:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
rJ   r   r   BUY)r   r  Nr  rx  r^  r  r   )rs  rN  r  r;  r<  r{  r  historyGetOrdersr>  r  r  r  s                r!  fetch_closed_orderstimex.fetch_closed_ordersz  s     	//$,,0CRHoogvG<		&&) 	
 [[(F &tGH"ll51GFO#FO((W)DE, (B7  >>r#  c                    U R                  5         U R                  U R                  S0 5      nU R                  USS5      nU R                  USU5      nU R	                  US5      nSU0n	Sn
Ub  U R                  U5      n
U
S   U	S'   Ub  U R                  U5      U	S'   Ub  X9S'   U R                  U R                  X5      5      nU R                  US	/ 5      nU R                  XX#5      $ )
a  
fetch all trades made by the user

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/History/getTrades_1

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
rn   r   r   Nr  rx  r^  r  r   )rs  rN  r  r;  r<  r{  r  historyGetTradesr>  r  r  )r  rx  r8  r  r)  r  r   r   r  rB  r{  r*  r   s                r!  fetch_my_tradestimex.fetch_my_trades  s     	//$,,DoogvG<		&&) D
 [[(F &tGH"ll51GFO#FO((W)DE& (B7  >>r#  rj  r{  c                 z    U R                  US5      nU R                  US5      nUU R                  X25      UUS S S.$ )Nr{  rj  )rK  rx  makertaker
percentage	tierBased)r;  rl  safe_symbol)r  rj  r{  marketIdrates        r!  parse_trading_feetimex.parse_trading_fee  sO     ##C2U+&&x8
 	
r#  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US0 5      nU R                  Xc5      $ )aN  
fetch the trading fees for a market

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Trading/getFees

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
r   r  r   )rs  r{  tradingGetFeesr>  rN  r  )r  rx  r)  r{  rB  r*  r  s          r!  fetch_trading_feetimex.fetch_trading_fee  sn     	V$vd|
 &&t{{7'CD 1b1%%f55r#  c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      nU R                  US5      nU R                  US5      n	[        R                  " X5      n
U R                  US5      nU R                  US5      n0 S	U_SUS
-   U-   _SU_SU_SS _SU_SU_SS _SS_SS_SS_SS_SS_SS_SU(       + _SS_SS _S U R                  US5      U R                  US5      S S S S S U R                  US5      U R                  US5      S.S S S.U R                  U
5      S S.U R                  U5      S S.US S.S .S US!.E$ )"Nlockedrx  baseCurrencyquoteCurrencyquantityIncrementbaseMinSizetickSizequoteMinSizer  /basequotesettlebaseIdquoteIdsettleIdrb  r/   Tr0   Fr1   r2   r3   activecontractr  takerFeemakerFee)rc  r  minmax)r   rc  r  cost)r  r  r  contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedrK  )rN  r;  rm  r%   
string_maxrl  parse_number)r  r{  r  r  r	  r
  r  r  amountIncrementminBase	minAmountpriceIncrementminCosts                r!  parse_markettimex.parse_market  sW   ( 2fh/!!&.9""6?;&&v.''0**63FG""6=9&&@	))&*=""6>:2
"2
dSj5(2
 D2
 U	2

 d2
 f2
 w2
 2
 F2
 D2
 e2
 E2
 e2
 e2
 &j2
  !2
" d#2
$ %%fj9%%fj9 "**63FG))&*=  
  ,,Y7
  ,,^<
 #$ c2
 2	
r#  c                    U R                  US5      nU R                  U5      nU R                  US5      nU R                  US5      nS nUbh  Ube  [        U5      nXu-
  nUS:  a"  USU n	XH* S  n
U R	                  U	S-   U
-   5      nO.Sn
[        SU* 5       H  nU
S-  n
M
     U R	                  X-   5      nU R                  UUUS U R                  US5      U R                  US5      U R                  US	5      U R                  US
5      UU R	                  U R                  U R                  US5      5      5      S S S.S S S.S.0 S.5      $ )Nrx  withdrawalFeetradeDecimalsr   .r   r  r  depositEnabledwithdrawalEnableddecimalsr  )withdrawrc  )r  r7  rK  rb  r  r  depositr,  rj  r  r  networks)	r;  rm  r  rM  r  rL  safe_currency_structurer  parse_precision)r  rC  r  r7  	feeStringr'  rj  feeStringLendotIndexwholefractionrO  s               r!  parse_currencytimex.parse_currencyo  s}   L h1&&r*$$X?	))(OD!(Ay>L#3H!|!!H-$YZ0''h(>?q8),AOH -''(<=++$$Xv6nnXx8~~h0@Ax1DE**4+?+?@P@PQY[e@f+gh$(6"&t4 -
  	r#  r~  c           	      H   U R                  US5      nU R                  X2S5      nU R                  U R                  US5      5      nU R                  US5      nU R                  US5      nU R                  0 SU_SU_SU_SU R	                  U5      _S	U R                  US	5      _S
U R                  US
5      _SU R                  US5      _SS _SU R                  US5      _SS _SS _SU_SU_SU_SS _SS _SS _S U R                  US5      U R                  US5      S.EU5      $ )Nr{  r  rU  lastopenrx  rK  rY  highlowr  	bidVolumer  	askVolumevwapclosepreviousClosechanger  volumevolumeQuote)average
baseVolumequoteVolume)r;  r  rk  safe_tickerr  )r  r~  r{  r  rx  rU  r9  r:  s           r!  r}  timex.parse_ticker  s     ##FH5!!(C8NN4#3#3FK#HI	// !
f!
F!
 !
 Y/	!

 D$$VV4!
 4##FE2!
 4##FE2!
 !
 4##FE2!
 !
 D!
 D!
 T!
 D!
 T!
  d!!
" $#!
$ **68<++FMB)!
* + 	r#  tradec                    U R                  US5      nU R                  X25      nU R                  U R                  US5      5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      n	U R                  [        R
                  " Xg5      5      n
U R                  US5      nU R                  USS5      nU R                  US5      nS nUb  U R                  XS	-   5      nS nU R                  US
5      nU R                  U R                  US5      5      nUb  UUS.nU R                  UUUU R                  U5      UUS UUU	U
UUS.5      $ )Nrx  rU  r  r  r  	directionr  makerOrTakerOrderIdrj  feeToken)r  rC  )rK  r  rU  rY  rx  r  rb  r  r  rc  r  takerOrMakerrj  )r;  r  rk  r  r%   
string_mulsafe_string_lower_2safe_string_lowerrl  rm  
safe_trader  )r  rJ  r{  r  rx  rU  priceStringamountStringr  rc  r  r  r  rP  r  rj  feeCostfeeCurrencys                     r!  parse_tradetimex.parse_trade  s   8 ##E84!!(3NN4#3#3E;#GH	&&ug6''z:!!+.""<0  !3!3K!NOeT*''{FC--e^D#&&uY.FGG""5%0--d.>.>uj.QR'C "Y/( 
  	r#  c           	          U R                  U R                  US5      5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )NrU  r:  r;  r<  r@  rC  )rk  r;  rl  )r  ohlcvr{  s      r!  parse_ohlcvtimex.parse_ohlcv'  sw     NN4++E;?@UF+UF+UE*UG,UH-
 	
r#  r  c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  Xb5      nU R                  U R                  US5      5      nU R                  US5      n	U R                  US5      n
U R                  US5      nU R	                  U R                  US	5      5      n[
        R                  " X5      (       a  S
nOUb  SnOSnU R                  US/ 5      nU R                  US5      nU R                  0 SU_SU_SU_SU_SU R                  U5      _SS _SU_SU_SS _SS _SU_SU	_SS _SU
_SS _SS _SU_S US US.EU5      $ )Nr  rb  r  rx  	createdAtr  r  filledQuantitycancelledQuantityclosedcanceledr:  r   clientOrderIdrK  rU  rY  lastTradeTimestampr   r  r   rc  r  rE  filled)	remainingre  rj  r   )
r;  rS  r  rk  	omit_zeror%   string_equalsrN  r  r  )r  r  r{  r  rb  r  r  rx  rU  r  rc  rg  canceledQuantityre  	rawTradesre  s                   r!  r  timex.parse_order<  s   * eT*%%eV4%%eV4##E84!!(3NN4#3#3E;#GH	  0!!%4!!%)9:>>$*:*:5BU*VW  00F)FFOOE8R8	((@  
E 
" 
 ] 
 	 

 Y/ 
 !$ 
 f 
 D 
 4 
  
 D 
 U 
 D 
 f 
 D 
  t! 
" f# 
$ + 
, - 	r#  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US0 5      nU R                  Xc5      $ )a  
fetch the deposit address for a currency associated with self account, does not accept params["network"]

https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Currency/selectCurrencyBySymbol

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
rx  r7  rC  )rs  rC  currenciesGetSSymbolr>  r|  parse_deposit_address)r  r7  r)  rC  rB  r*  datas          r!  fetch_deposit_addresstimex.fetch_deposit_address|  so     	==&hv&
 ,,T[[-IJ$ ~~h
B7))$99r#  c                 t    U R                  US5      nUU R                  X25      S U R                  US5      S S.$ )Nrx  r   )rK  rC  rZ  r   r_  )r;  rm  )r  depositAddressrC  r  s       r!  rp  timex.parse_deposit_address  sG     %%nh?
"//
E''	B
 	
r#  r   GETc                    U R                  U5      nU R                  X5      nU R                  XG5      nU R                  S   S   S-   U-   S-   U-   nU(       a  USU R	                  U5      -   -  nUS:w  aJ  US:w  aD  U R                  5         U R                  U R                  S-   U R                  -   5      n	SU	-   n
S	U
0nXXeS
.$ )Nr   r   r  ?r   r   :zBasic authorization)urlmethodbodyheaders)	extract_paramsimplode_paramsr<  r  urlencode_with_array_repeatcheck_required_credentialsstring_to_base64apiKeysecret)r  pathr   r}  r)  r  r~  paramsToExtractr|  authr  s              r!  sign
timex.sign  s    --d3""4063iiv&,s2S84?399&AAAC(?sm3++-((s):T[[)HID_F&/GdOOr#  
statusCode
statusTextr|  r}  responseHeadersc
                    Uc  g US:  a  U R                   S-   U-   n
U R                  US5      nUc  UnU R                  USS5      nU R                  USS5      nU R                  U R                  S   X5        U R                  U R                  S	   X5        U R                  U R                  S	   X5        [        U
5      eg )
Ni   errorr7  re  messagedebugMessager   r   )r  rN  safe_string_2throw_broadly_matched_exceptionr  throw_exactly_matched_exceptionr   )r  r  r  r|  r}  r  responseBodyr*  requestHeadersrequestBodyfeedbackr  r7  r  s                 r!  handle_errorstimex.handle_errors  s    
 ww}|3HOOHg6E} %%eVX>D((	>JG001I7]001I4Z001I7]))r#   )N)B__name__
__module____qualname____firstlineno__r   r  r
   r+  r   r   r0  r   r5  r   r   rD  rH  rQ  dictr   ro  r   r   rv  strr   r  r   r  r   r  listr  r   r  r  r   r   floatr   r  r  r  r  r  r   r  r  r  r   r  r  r#  r6  r}  rY  r]  r  r	   rr  rp  r  intr  __static_attributes____classcell__)r   s   @r!  r'   r'      sx   k# kZ !# 
2s 
2 $& ,$v, ,B ') #/Z #/J *.Dt\^ !I3 !Ic !I !Icghsct !IF -1tRV_a !Ic !I !IC !Ifjkvfw !IF#
T #
X #
Q\ #
J 04B !5W !57 !5F 02 $13 $1f $1L :>b ,ls ,l3 ,lY ,l\ 6:UW ,A3 ,As ,A# ,A\`af\g ,A\ 9=4^bkm 6L# 6L# 6LS 6LX[ 6Lrvw{r| 6Lp) )  $& ,( ,, gksu F/3 F/i F/y F/RW F/`c F/P `drv  @B ./S ./# ./Y ./i ./Y\ ./lo ./` 37r )s )C ) ;?r 5c 5C 5n 26b 3Hc 3H3 3Hj /3TXac 3? 3?3 3?c 3?hlmrhs 3?j 154VZce 7?# 7?S 7?PS 7?jnotju 7?r -1tRV_a :?c :? :?C :?x
T 
6 
EX 
$ 57 6 6;N 66Q
4 Q
F Q
fHt H HT*4 * *6 *X@ @v @ @D
 
4 
*> >v > >@ 79 ":# ":^ ":H
h 
R` 
0 &eBSW P  3 PS fj  r#  r'   N)+ccxt.base.exchanger   ccxt.abstract.timexr   ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r   r    r!   r"   r#   ccxt.base.decimal_to_precisionr$   ccxt.base.preciser%   r'   r  r#  r!  <module>r     sk    ( + R  R  R  R  R  R  * 0 - . ' . ) * ) . 1 4 %Hk r#  