
    E#i                    `   S SK Jr  S SKJr  S SKrS SKJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr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/J0r0  S SK1J2r2   " S S\\5      r3g)    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesCurrencyDepositAddressIntLedgerEntryLeverageMarketNumOrder	OrderBook	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTradingFeesTransactionMarketInterfaceTransferEntry)List)ExchangeError)PermissionDenied)ArgumentsRequired)
BadRequest)	BadSymbol)OperationRejected)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)OperationFailed)RateLimitExceeded)	TICK_SIZE)Precisec                   j  ^  \ rS rSrS\4U 4S jjr0 4S jr0 4S\4S jjr0 4S\	4S jjr
S\S\4S jr0 4S\\   4S	 jjrS
\S\4S 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SgS\S
\S\4S jjrSSS0 4S\S\S\S\\   4S jjrSgS
\S\4S jjrS0 4S\S\4S jjrSgS\S
\S\4S jjr S0 4S\4S jjr!SgS
\4S jjr"S0 4S\4S jjr#S0 4S\S\4S jjr$S r%S0 4S\S\&4S  jjr'SgS
\S\(4S! jjr)SSS0 4S\*S\S\4S" jjr+SgS
\4S# jjr,0 4S\-4S$ jjr.S\-4S% jr/S0 4S\S&\0S'\1S(\2S)\34
S* jjr4S0 4S\S&\0S'\1S(\2S)\34
S+ jjr5S0 4S\S&\0S'\1S(\2S)\34
S, jjr6SgS-\S
\S\74S. jjr8S/\*4S0 jr9S1 r:S0 4S2\S\*4S3 jjr;S0 4S\*4S4 jjr<S0 4S5\\   S\*4S6 jjr=S0 4S2\S\*4S7 jjr>SSS0 4S\*S\S\S\\7   4S8 jjr?SSS0 4S\*S\S\S\\7   4S9 jjr@SSS0 4S\*S\S\S\\7   4S: jjrASSS0 4S\*S\S\4S; jjrB0 4S<\S(\2S=\S>\S\C4
S? jjrDSgS@\SA\S\C4SB jjrESSS0 4S<\*S\S\S\\F   4SC jjrGSgSD\SA\S\F4SE jjrHSF rI0 4S\J4SG jjrKSgS
\4SH jjrLSSS0 4S<\*S\S\S\\M   4SI jjrNSSS0 4S<\*S\S\S\\M   4SJ jjrOSK rPSgSL\SA\S\M4SM jjrQS/\*4SN jrR0 4S<\S\S4SO jjrTSgSA\S\S4SP jjrUS0 4S<\S(\2SQ\SR\*S\M4
SS jjrVS0 4ST\S\*4SU jjrWS0 4SV\XS\*4SW jjrY0 4S\S\Z4SX jjr[SgSV\S
\S\Z4SY jjr\S0 4S\S\\]   4SZ jjr^SgS[\S
\4S\ jjr_S]S^0 SS4S_ jr`S<\XS`\Sa\Sb\Sc\Sd\4Se jraSfrbU =rc$ )htoobit   returnc                 $
  > U R                  [        [        U ]  5       0 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_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_S0S_S1S_ESSS2.E_S3S4S5S5S6.S7S8S9/S:S;S<.S=S>._S?S@0 SASB_SCSB_SDSB_SESB_SFSB_SGSB_SHSB_SISB_SJSB_SKSB_SLSB_SMSN_SOSN_SPSB_SQSB_SRSB_SSSB_00 STSU_SVSB_SWSX_SYSX_SZSX_S[S\_S]S\_S^S\_S_SU_S`SU_SaSU_SbSB_ScSU_SdSB_SeSX_SfS\_SgSU_S\SUSUSUSh.ESXSXSXSiSBSBSBSBSiSjSBSBSBSk.SXSXS\S\S\S\SBSl.SmSB0Sn.S6._SoSpSqSrSsStSuSvSwSxSySzS{S|S}S~._S[        _S0 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[        _E0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[
        _S[
        _S[        _E0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[
        _S[
        _S[        _S[        _S[        _S[        _E0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[
        _S[        _E[        [        [        S.E0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S._S0 _SSSSS.0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_GS GS _GSGS_GSGSGSGSGSGSGSGS	GS
GSGS.
ESSGS.GS._GSSSSS SSSS SSSSGS.SSSSSSSGS.S GSGS0SGSGSGSSGS.SSSSGS.SGSSSSGS.SGSGSGSSSSGS.S GS.	GSS 0S S GS.S S GS.GS._5      $ (  Nidr/   nameToobit	countriesKYversionv1	rateLimit   	certifiedFproThasCORSspotmarginswapfutureoptioncancelAllOrderscancelOrdercancelOrderscreateOrderfetchBalancefetchBidsAsksfetchCurrenciesfetchDepositAddressfetchDepositsfetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchLastPricesfetchLedgerfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchStatusfetchTickers	fetchTimefetchTradesfetchWithdrawalssetMarginMode)transferwithdrawurlszOhttps://github.com/user-attachments/assets/0c7a97d5-182c-492e-b921-23540c868e0ezhttps://api.toobit.com)commonprivatezhttps://www.toobit.com/z1https://toobit-docs.github.io/apidocs/spot/v1/en/z6https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/z'https://www.toobit.com/en-US/r?i=IFFPy0g?)urldiscountzhttps://www.toobit.com/fee)logoapiwwwdocreferralfeesri   getzapi/v1/time   zapi/v1/pingzapi/v1/exchangeInfozquote/v1/depthzquote/v1/depth/mergedzquote/v1/tradeszquote/v1/klineszquote/v1/index/klineszquote/v1/markPrice/klineszquote/v1/markPricezquote/v1/indexzquote/v1/ticker/24hr(   zquote/v1/contract/ticker/24hrzquote/v1/ticker/pricezquote/v1/ticker/bookTickerzapi/v1/futures/fundingRatez!api/v1/futures/historyFundingRatezapi/v1/account   zapi/v1/account/checkApiKeyapi/v1/spot/ordergQ?api/v1/spot/openOrderszapi/v1/futures/openOrderszapi/v1/spot/tradeOrdersg33333 @zapi/v1/futures/historyOrderszapi/v1/account/tradeszapi/v1/account/balanceFlowzapi/v1/account/depositOrderszapi/v1/account/withdrawOrderszapi/v1/account/deposit/addresszapi/v1/subAccountzapi/v1/futures/accountLeverageapi/v1/futures/orderzapi/v1/futures/positionszapi/v1/futures/balance)zapi/v1/futures/userTradeszapi/v1/futures/balanceFlowzapi/v1/futures/commissionRatezapi/v1/futures/todayPnlgQ
@g
ףp=
@)zapi/v1/spot/orderTestrr   rt   zapi/v1/spot/batchOrderszapi/v1/subAccount/transferzapi/v1/account/withdrawzapi/v1/futures/marginTypezapi/v1/futures/leverageapi/v1/futures/batchOrdersz$api/v1/futures/position/trading-stopzapi/v1/futures/positionMarginzapi/v1/userDataStreamapi/v1/listenKey)rr   rt   rs   ru   zapi/v1/spot/cancelOrderByIdszapi/v1/futures/cancelOrderByIdsrv   rv   )rn   postdeleteput
timeframes1m3m5m15m30m1h2h4h6h8h12h1d1w1M)r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   precisionMode
exceptionsz-1000z-1001z-1002z-1003z-1004z-1006z-1007z-1014z-1015z-1016z-1020z-1021z-1022z-1100z-1101z-1102z-1103z-1104z-1105z-1106z-1111z-1112z-1114z-1115z-1116z-1117z-1118z-1119z-1120z-1121z-1125z-1127z-1128z-1130z-1132z-1133z-1134z-1135z-1136z-1137z-1138z-1139z-1140z-1141z-1142z-1143z-1144z-1145z-1146z-1147z-1193z-1194z-1195z-1196z-1197z-1198z-1199z-1200z-1201z-1202z-1203z-1206z-2010z-2011z-2013z-2014z-2015z-2016z-3050z-3101z-3102z-3103z-3105z-3107z-3108z-3109z-3110z-3116z-3117z-3120z-3124z-3125z-3126z-3127z-3128)z-3129z-3130z-3131zUnknown order sentzDuplicate order sentzMarket is closedz5Account has insufficient balance for requested actionz/Market orders are not supported for self symbolz0Iceberg orders are not supported for self symbolz2Stop loss orders are not supported for self symbolz8Stop loss limit orders are not supported for self symbolz4Take profit orders are not supported for self symbolz:Take profit limit orders are not supported for self symbolzQTY is zero or lesszIcebergQty exceeds QTYz'This action disabled is on self accountzUnsupported order combinationzOrder would trigger immediatelyz6Cancel order is invalid. Check origClOrdId and orderIdz&Order would immediately match and take)exactbroadcommonCurrenciesoptionsMAINFUTURES)r@   rB   BTCERC20ETHBEP20BSCTRC20TRXSOLMATICARBONEARBITRUMBASETONAVAXCDOGEXRPDOTADALTCAPTATOMALGONEARXLMSUIETCEOSWAVESICPONE)
r   r   r   r   r   r   r   r   r   r   )r   r   )defaultTypeaccountsByTypenetworksnetworksByIdfeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyRequiresPricemarketBuyByCostselfTradePreventioniceberglimiti  i )r   r   daysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   i  )r   r   r   r   r   r   r   )	sandboxrH   createOrdersrV   rU   rX   rW   rZ   fetchClosedOrdersr   )linearinverse)r@   forDerivativesrB   rC   )deep_extendsuperr/   describer,   r*   r!   r+   r#   r%   r'   r    r&   r)   r(   )self	__class__s    S/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/toobit.pyr   toobit.describe   s   fd < > A
(A
HA
 $A
 t	A

 A
 A
 4A
  %%% %% 	%
 %% %% "4% t% % t% %  % "4% &t%  %  *4!%" $T#%$ "4%%& "4'%( t)%* +%, !$-%.  /%0 d1%2 "43%4 d5%6 !$7%8 t9%: t;%< =%> T?%@ tA%B #DC%D  E%F ! I%A
\ i67 1GL
 E # 5]A
~  %q%q .q )!	
 0 *1 *1 0 4Q -a )! / 8 0 5a  5a!" <Q#,(!4a ,X 1(	
 4X 28 7 0 5a 7 8 9! ,Q 9!  /!" 3H#$ 1!%& 6>679:34-2 2:-5083;673456346>@H9:12,-" .6082:6>8@;C,- +Ae5-LA
X YA
x YyA
z Z_Z_Z -Z .	Z
 ZZ _Z _Z _Z .Z .Z .Z .Z .Z ZZ ZZ  Z!Z" Z#Z$ Z%Z& Z'Z( Z)Z* Z+Z, .-Z. Z/Z0 Z1Z2 Z3Z4 Z5Z6 \7Z8 \9Z: Z;Z< Z=Z> .?Z@ .AZB ZCZD ZEZF .GZH .IZJ .KZL .MZN .OZP .QZR .SZT .UZV .WZX \YZZ \[Z\ \]Z^ ._Z` .aZb _cZd _eZf .gZh .iZj .kZl .mZn .oZp .qZr .sZt .uZv .wZx .yZz .{Z| .}Z~ _Z@ _AZB \CZD -EZF -GZH ZIZL ]MZN .OZP .QZR ZSZT .UZV .WZX .YZZ .[Z\ .]Z^ ._Z` .aZb .cZd .eZf .gZh .iZj _kZl .mZn (.)sZv(-*L '(9 LM^	
 FGX GHY IJ[ OPa KL] QRc *: -.? >?O 4Z 67H  MN_!" =>O#yo{A
Z [A
\ %"%#5U 5 U	
 U 5 W j F 5 W F 5 5 5  5!" 5#$ #""    $  7> #$!I(]A
n	 $&+(,,0,1).+06:#'#'"&#(	( #($)$)27+0/4#()$, %)# ',!%$*%+*.& ',#($)*/	# ',!%#($)*/( ',!$$*%+#($)*/$ *.s:x #D# ##
 ##GGo	A
  	    c                 P   #    U R                  U5      I Sh  vN nSSSSUS.$  N7f)a5  
the latest known information on the availability of the exchange API

https://toobit-docs.github.io/apidocs/spot/v1/en/#test-connectivity

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
Nok)statusupdatedetarf   info)commonGetApiV1Pingr   paramsresponses      r   fetch_statustoobit.fetch_status  s8      0088
 	
 9s   &$&c                 d   #    U R                  U5      I Sh  vN nU R                  US5      $  N7f)a8  
fetches the current integer timestamp in milliseconds from the exchange server

https://toobit-docs.github.io/apidocs/spot/v1/en/#check-server-time

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int: the current integer timestamp in milliseconds from the exchange server
N
serverTime)commonGetApiV1Timesafe_integerr   s      r   
fetch_timetoobit.fetch_time  s4      0088   <88 9s   0.0c                    #    U R                  U5      I Sh  vN nX R                  S'   U R                  US/ 5      n0 n[        S[	        U5      5       H!  nX5   nU R                  U5      nUS   nXtU'   M#     U$  Nc7f)z
fetches all available currencies on an exchange
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
NexchangeInfocoinsr   code)commonGetApiV1ExchangeInfor   	safe_listrangelenparse_currency)	r   r   r   r   resulticoinparsedr   s	            r   fetch_currenciestoobit.fetch_currencies  s      88@@'/^$B x"5q#e*%A8D((.F&>D!4L	 &
 S As   A=A;A$A=rawCurrencyc                    U R                  US5      nU R                  U5      n0 nU R                  US5      n[        S[	        U5      5       H  nXV   nU R                  US5      nU R                  U5      n	UU	S U R                  US5      U R                  US5      S U R                  US5      S U R                  US5      S S	.U R                  US
5      U R                  US5      S	.S.US.
XI'   M     U R                  UUU R                  US5      S S U R                  US5      U R                  US5      S S S S S	.S S S	.S.UUS.5      $ )NcoinId
chainTypesr   	chainTypeallowDepositallowWithdrawwithdrawFeeminDepositQuantityminmaxminWithdrawQuantitymaxWithdrawQuantity)depositrb   )
r3   networkrA   r	  rb   activefee	precisionlimitsr   coinFullName)amountrb   )r3   r   r4   typer  r	  rb   r  r  r  r   r   )	safe_stringsafe_currency_coder   r   r   network_id_to_code	safe_boolsafe_numbersafe_currency_structure)
r   r   r3   r   r   rawNetworksj
rawNetwork	networkIdnetworkCodes
             r   r   toobit.parse_currencyS  s   k84&&r*nn[,?q#k*+A$J(([AI11)<K&>>*nE NN:G''
MB!  $//
<PQ# 
  $//
<QR#//
<QR!	 #'%H!	 ,2 ++$$[.A~~k>B{OD  
  	 !+-
  	r   c                   #    U R                  U R                  S5      nUb  SU R                  S'   OU R                  U5      I Sh  vN nU R                  US/ 5      nU R                  US/ 5      nU R	                  X45      n/ n[        S[        U5      5       H)  nXW   nU R                  U5      n	UR                  U	5        M+     U$  N7f)aJ  
retrieves data on all markets for toobit

https://toobit-docs.github.io/apidocs/spot/v1/en/#exchange-information
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#exchange-information

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
r   Nsymbols	contractsr   )		safe_dictr   r   r   array_concatr   r   parse_marketappend)
r   r   r   r  r   allr   r   marketr   s
             r   fetch_marketstoobit.fetch_markets  s      >>$,,?+/DLL(!<<VDDHB ..9b9NN8["=	3q#c(#AVF&&v.FMM&! $ S Es   AC
CBC
r&  c                    U R                  US5      nU R                  US5      nU R                  US5      nUR                  S5      nUS   nU R                  U5      nU R                  U5      nU R                  US5      n	U R                  U	5      n
U R                  US5      nUS:H  nU R                  US	/ 5      nU R	                  US
5      nU R                  US0 5      nU R                  US0 5      nU R                  US0 5      nUS-   U-   nSU;   nU R                  USS5      nU(       a  USU
-   -  nU R                  0 SU_SU_SU_SU_SU
_SU_SU_SU	_SU(       a  SOS_SU(       + _SS_SU_SS_S S_S!U_S"U_S#U(       a  U(       + OS _U(       a  UOS U R                  US5      S S S S U R                  US$5      U R                  US%5      S&.S S S'.U R                  US(5      U R                  US)5      S'.U R                  US*5      U R                  US+5      S'.U R                  US,5      S S'.S-.S US..
E5      $ )/Nsymbol	baseAsset
quoteAsset-r   marginTokenr   TRADINGfilters
filterTypePRICE_FILTERLOT_SIZEMIN_NOTIONAL/contractMultiplier	isInverser   :r3   basequotesettlebaseIdquoteIdsettleIdr  rB   r@   rA   FrC   rD   r  contractr   stepSizetickSize)r  pricer  minQtymaxQtyminPricemaxPriceminNotional)r   r  rB  cost)
r   contractSizeexpiryexpiryDatetimestrike
optionTyper  r  createdr   )	r  splitr  r   index_byr!  safe_bool_2safe_market_structurer  )r   r&  r3   r<  r=  	basePartsbaseIdCleanr9  r:  r>  r;  r   r  r0  filtersByTypepriceFilterlotSizeFilterminNotionalFilterr*  
isContractr   s                        r   r#  toobit.parse_market"  s   fh/!!&+6""6<8LL%	l&&{3''0##FM:((2!!&(3I%..B7g|<nn]NBG}j"E NN=."Me#*f4
""6;	BcFl"F)) 0+
"0+
f0+
 D0+
 U	0+

 f0+
 f0+
 w0+
 0+
 jFf0+
 
N0+
 e0+
 J0+
 e0+
 e0+
 f0+
  
!0+
" Z'kT#0+
$ #-w$ ,,V5IJ"**=*E))+zB  
  ++M8D++M8D
  ++KD++KD
  ++,=}M$ _0+
 0 0	r   Nr*  r   c                 "  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X%S'   U R                  U R                  XS5      5      I Sh  vN nU R	                  US5      nU R                  XdS   USS5      $  Nt N/7f)aD  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://toobit-docs.github.io/apidocs/spot/v1/en/#order-book
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#order-book

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nr*  r3   r   tba)load_marketsr&  commonGetQuoteV1Depthextendr   parse_order_book)r   r*  r   r   r&  requestr   	timestamps           r   fetch_order_booktoobit.fetch_order_bookj  s      !!!V$fTl
 $G33DKK4PQQ8 %%h4	$$Xh/?CQTUUI 	" Rs"   BBABB.BBsincec                    #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X6S'   U R                  U R                  Xd5      5      I Sh  vN nU R	                  XuX#5      $  N] N7f)a8  
get a list of the most recent trades for a particular symbol

https://toobit-docs.github.io/apidocs/spot/v1/en/#recent-trades-list
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#recent-trades-list

: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 number 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>`
Nr*  r3   r   )r_  r&  commonGetQuoteV1Tradesra  parse_trades)r   r*  rg  r   r   r&  rc  r   s           r   fetch_tradestoobit.fetch_trades  s      !!!V$fTl
 $G44T[[5QRR   5@@% 	" Ss"   A8A4AA8A6A86A8tradec                    U R                  USS5      nU R                  USS5      nU R                  USS5      nU R                  US5      nS nU R                  US5      nUc  U R                  US	5      n	U	b  U	(       + nUb  U(       a  S
nOSnOU(       a  SnOS
nU R                  US5      n
U R                  US5      nS nUb  U R	                  U
5      US.nU R                  US5      nS nUb  U(       a  SOSnU R                  S U5      nUS   nU R                  UUU R                  U5      UU R                  USS5      U R                  US5      S UUUS UUS.U5      $ )Nr\  timeprB  qqtyisBuyeribmmsellbuy	feeCoinId	feeAmount)currencyrH  isMakermakertakerr*  r3   vorderId)r   rd  datetimer*  r3   orderr  sider  rB  rH  takerOrMakerr  )safe_integer_2safe_string_2r  r  r  safe_market
safe_tradeiso8601)r   rm  r&  rd  priceStringamountStringrs  r  isBuyerMakerisBuyerTakerfeeCurrencyIdry  r  r{  r  r*  s                   r   parse_tradetoobit.parse_trade  s   T ''sF;	((W=))%e<..	2~~eU3>>%5L'#//#((<$$UK8	  33MB!C ..	2&-77L!!$/!"Y/$$UD#6%%eY7" ( 
  	r   r{   c                   #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  U R                  X"5      S.nUb  X7S'   U R	                  US5      nUb  U R                  US5      nXS'   Ub  XGS'   Sn	Sn
U R                  USS	5      u  pU
S
:X  a)  U R                  U R                  Xu5      5      I Sh  vN n	OWU
S:X  a)  U R                  U R                  Xu5      5      I Sh  vN n	O(U R                  U R                  Xu5      5      I Sh  vN n	U R                  XX#U5      $  GN# Nr NE N7f)a  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://toobit-docs.github.io/apidocs/spot/v1/en/#kline-candlestick-data
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#kline-candlestick-data

:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param int [since]: timestamp in ms of the earliest candle to fetch
:param int [limit]: the maximum amount of candles to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nr3   )r*  interval	startTimeuntilendTimer   rV   rB  indexmark)r_  r&  r  rz   r   omithandle_option_and_paramscommonGetQuoteV1IndexKlinesra  commonGetQuoteV1MarkPriceKlinescommonGetQuoteV1Klinesparse_ohlcvs)r   r*  	timeframerg  r   r   r&  rc  r  r   endpoints              r   fetch_ohlcvtoobit.fetch_ohlcv  sO     !!!V$Tl(()O
 #(K !!&'2YYvw/F!&I$G88wWw!==dkk'>Z[[H8 !AA$++gB^__H& "88W9UVVH$   9UKKi 	"$ \: `& WsF   ED9B2E	D<
.E8D>9(E!E "E<E>E Ec           
          U R                  U/ SQ5      U R                  U/ SQ5      U R                  U/ SQ5      U R                  U/ SQ5      U R                  U/ SQ5      U R                  U/ SQ5      /$ )N)r   ro  r\  )ro   openo)   highh)   lowl)   closec)rq   volumer~  )safe_integer_nsafe_number_n)r   ohlcvr&  s      r   parse_ohlcvtoobit.parse_ohlcv}  sq    '78u&67u&67uo6u&78u&89
 	
r   r  c                   #    U R                  5       I Sh  vN   U R                  U5      nSnSn0 nUb<  U R                  US5      nU R                  U5      n[	        U5      nUS:X  a  US   US'   U R                  SXB5      u  p2SnUS:X  a)  U R                  U R                  XR5      5      I Sh  vN nO(U R                  U R                  XR5      5      I Sh  vN nU R                  XU5      $  N NA N7f)a\  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://toobit-docs.github.io/apidocs/spot/v1/en/#24hr-ticker-price-change-statistics
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#24hr-ticker-price-change-statistics

:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr   ro   r3   r*  r\   r@   )
r_  market_symbolsr  r&  r   handle_market_type_and_paramscommonGetQuoteV1Ticker24hrra  "commonGetQuoteV1ContractTicker24hrparse_tickers)	r   r  r   r  r&  rc  r*  lengthr   s	            r   fetch_tickerstoobit.fetch_tickers  s      !!!%%g.%%gq1F[[(F\F{$*4L!99.&Y6>!<<T[[=YZZH!DDT[[QXEabbH" !!(V<<C 	" [bs4   C6C0BC60C21(C6C4C62C64C6tickerc                 *   U R                  US5      nU R                  X25      nU R                  US5      nU R                  US5      nU R                  0 SUS   _SU_SU R	                  U5      _SU R                  US5      _S	U R                  US
5      _SS _SS _SS _SS _SS _SU R                  US5      _SU_SU_SS _SU R                  US5      _SU R                  US5      _SS _U R                  US5      U R                  US5      US.EU5      $ )Nsr\  r  r*  rd  r  r  r  r  r  bid	bidVolumeask	askVolumevwapr  r  r  lastpreviousClosechangepc
percentagepcpaverager~  qv)
baseVolumequoteVolumer   )r  r  r   safe_tickerr  )r   r  r&  marketIdrd  r  s         r   parse_tickertoobit.parse_ticker  s   ##FC0!!(3%%fc2	, !
fX&!
!
 Y/!
 D$$VS1	!

 4##FC0!
 4!
 !
 4!
 !
 D!
 D$$VS1!
 T!
 D!
 T!
 d&&vt4!
  $**659!!
" t#!
$ **637++FD9)!
* + 	r   c                 :  #    U R                  5       I Sh  vN   U R                  U5      n0 nUb-  [        U5      nUS:X  a  U R                  US   5      nUS   US'   U R	                  U R                  X25      5      I Sh  vN nU R                  Xa5      $  N N7f)a  
fetches the last price for multiple markets

https://toobit-docs.github.io/apidocs/spot/v1/en/#symbol-price-ticker
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#symbol-price-ticker

:param str[]|None symbols: unified symbols of the markets to fetch the last prices
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of lastprices structures
Nro   r   r3   r*  )r_  r  r   r&  commonGetQuoteV1TickerPricera  parse_last_pricesr   r  r   rc  r  r&  r   s          r   fetch_last_pricestoobit.fetch_last_prices  s      !!!%%g.\F{WQZ0$*4L!99$++g:VWW %%h88# 	" X"   BBA*BBBBc                     U R                  US5      nU R                  X25      nUS   S S U R                  US5      S US.$ )Nr  r*  rB  )r*  rd  r  rB  r  r   )r  r  safe_number_omit_zero)r   entryr&  r  s       r   parse_last_pricetoobit.parse_last_price  sR    ##E3/!!(3X&//w?
 	
r   c                 :  #    U R                  5       I Sh  vN   U R                  U5      n0 nUb-  [        U5      nUS:X  a  U R                  US   5      nUS   US'   U R	                  U R                  X25      5      I Sh  vN nU R                  Xa5      $  N N7f)a  
fetches the bid and ask price and volume for multiple markets

https://toobit-docs.github.io/apidocs/spot/v1/en/#symbol-order-book-ticker
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#symbol-order-book-ticker

:param str[] [symbols]: unified symbols of the markets to fetch the bids and asks for, all markets 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>`
Nro   r   r3   r*  )r_  r  r   r&   commonGetQuoteV1TickerBookTickerra  parse_bids_asks_customr  s          r   fetch_bids_askstoobit.fetch_bids_asks  s      !!!%%g.\F{WQZ0$*4L!>>t{{7?[\\ **8==) 	" ]r  c                     / n[        S[        U5      5       H8  nU R                  X   5      nU R                  Xc5      nUR	                  U5        M:     U R                  U5      nU R                  USU5      $ )Nr   r*  )r   r   parse_bid_ask_customra  r$  r  filter_by_array)r   tickersr  r   resultsr   parsedTickerr  s           r   r  toobit.parse_bids_asks_custom  so    q#g,'A44WZ@L[[6FNN6" ( %%g.##GXw??r   c           	          U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      US.$ )Nr\  r  r]  bqr^  aq)rd  r*  r  r  r  r  r   )r  r  )r   r  s     r   r  toobit.parse_bid_ask_custom%  so    ))&#6&&vs3##FC0))&$7##FC0))&$7
 	
r   c                 :  #    U R                  5       I Sh  vN   U R                  U5      n0 nUb-  [        U5      nUS:X  a  U R                  US   5      nUS   US'   U R	                  U R                  X25      5      I Sh  vN nU R                  Xa5      $  N N7f)a  
fetch the funding rate for multiple markets

https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#funding-rate

:param str[]|None symbols: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
Nro   r   r3   r*  )r_  r  r   r&   commonGetApiV1FuturesFundingRatera  parse_funding_ratesr  s          r   fetch_funding_ratestoobit.fetch_funding_rates0  s      !!!%%g.\F{WQZ0$*4L!>>t{{7?[\\ ''::# 	" ]r  c                     U R                  US5      nU R                  X25      nU R                  US5      nU R                  US5      n0 SU_SU_SS _SS _SS _SS _S	S _S
S _SS _SS _SS _SS _SS _SS _SU_SU_SU R	                  U5      _SS 0E$ )Nr*  ratenextFundingTimer   	markPrice
indexPriceinterestRateestimatedSettlePricerd  r  previousFundingRatenextFundingRatepreviousFundingTimestampnextFundingTimestamppreviousFundingDatetimenextFundingDatetimefundingRatefundingTimestampfundingDatetimer  )r  safe_symbolr  r   r  )r   r?  r&  r  r*  r  nextFundingRateTimestamps          r   parse_funding_ratetoobit.parse_funding_rateM  s3   ##Hh7!!(3**8V<#'#4#4X?P#Q 
H
f
 
 $	

 D
 #D
 
 
 "4
 t
 '
 #D
 &t
 "4
 ?
   8!
" t||,DE#
$ %
 	
r   c                 n  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXUSU5      I Sh  vN $ U R                  U5      nSUS   0nUb  X7S'   U R	                  U R                  Xt5      5      I Sh  vN nU R                  XX#5      $  N N_ N7f)	a  
fetches historical funding rate prices

https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#get-funding-rate-history

:param str symbol: unified symbol of the market to fetch the funding rate history for
:param int [since]: timestamp in ms of the earliest funding rate to fetch
:param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest funding rate to fetch
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
NFrN   paginater   r*  r3   r   )r_  r  "fetch_paginated_call_deterministicr&  'commonGetApiV1FuturesHistoryFundingRatera  parse_funding_rate_histories)	r   r*  rg  r   r   r  r&  rc  r   s	            r   fetch_funding_rate_history!toobit.fetch_funding_rate_historyg  s      !!!88AZ\fg@@AZ\bkprvx~V$fTl
 $GEEdkkRYFbcc 005PP+ 	" @ ds4   B5B/:B5B1AB5B3B51B53B5c                     U R                  US5      nU R                  US5      nUU R                  XB5      U R                  US5      UU R	                  U5      S.$ )N
settleTimer*  
settleRate)r   r*  r   rd  r  )r   r  r  r  r  )r   r?  r&  rd  r  s        r   parse_funding_rate_history!toobit.parse_funding_rate_history  s`    %%h=	##Hh7&&x8++HlC"Y/
 	
r   c                 .  #    U R                  5       I Sh  vN   SnSnU R                  SSU5      u  p1U R                  USS/5      (       a  U R                  5       I Sh  vN nOU R	                  5       I Sh  vN nU R                  U5      $  Nx N0 N7f)a  
query for balance and get the amount of funds available for trading or funds locked in orders

https://toobit-docs.github.io/apidocs/spot/v1/en/#account-information-user_data
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#futures-account-balance-user_data

:param dict [params]: extra parameters specific to the exchange API endpointinvalid
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
NrI   rB   rC   )r_  r  in_arrayprivateGetApiV1FuturesBalanceprivateGetApiV1Accountparse_balance)r   r   r   
marketTypes       r   fetch_balancetoobit.fetch_balance  s      !!!
!??PTV\]
==fh%788!??AAH "88::H  !!(++G 	"
 B ;s4   BBA	B B!B9B:BBBc                    US S S.nU R                  USU5      n[        S[        U5      5       H}  nX4   nU R                  U R	                  US5      5      nU R                  5       nU R                  USS5      US'   U R                  USS5      US'   U R	                  US	5      US
'   XrU'   M     U R                  U5      $ )N)r   rd  r  balancesr   assetfreeavailableBalancetotalbalancelockedused)r   r   r   r  r  accountr  safe_balance)r   r   r   r  r   r!  r   r$  s           r   r  toobit.parse_balance  s    

 >>(JAq#h-(AkG**4+;+;GW+MNDllnG"00&BTUGFO#11'7INGG"..wAGFO"4L )   ((r   r  r  r  rB  c                   #    U R                  5       I Sh  vN   U R                  U5      n0 nSn	US   (       a>  U R                  XX4XV5      u  pU R                  U R	                  X5      5      I Sh  vN n	O=U R                  XX4XV5      u  pU R                  U R	                  X5      5      I Sh  vN n	U R                  X5      $  N NU N7f)a  
create a trade order

https://toobit-docs.github.io/apidocs/spot/v1/en/#new-order-trade
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#new-order-trade

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market', '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>`
Nr@   )r_  r&  create_order_requestprivatePostApiV1SpotOrderra  create_contract_order_requestprivatePostApiV1FuturesOrderparse_order)
r   r*  r  r  r  rB  r   r&  rc  r   s
             r   create_ordertoobit.create_order  s      !!!V$&>"77dTYbOG!;;DKK<XYYH"@@t]bkOG!>>t{{7?[\\H0 11C 	" Z ]s4   CCAC2C3=C0C
1CC
Cc                    U R                  U5      nUS   nUUR                  5       S.n	Ub  U R                  X5      U	S'   S n
U R                  US5      u  pUS:X  a6  U
c  US:X  a  [	        U R
                  S-   5      eU R                  X5      U	S'   OU R                  X5      U	S'   S nU R                  US:H  S	U5      u  pU(       a  S
U	S'   X/$ UR                  5       U	S'   X/$ )Nr3   )r*  r  rB  rH  r&  rw  z; createOrder() requires params["cost"] for market buy orderquantityFLIMIT_MAKERr  )	r&  upperprice_to_precisionhandle_param_stringr"   r3   cost_to_precisionamount_to_precisionhandle_post_only)r   r*  r  r  r  rB  r   r&  r3   rc  rH  
isPostOnlys               r   r(  toobit.create_order_request	  s   V$D\JJL
 #66vEGG//?8|'2o(opp&*&<&<V&J
#"&":":6"JGJ
!22483CUFS
+GFO    #jjlGFO  r   c                    U R                  U5      nUS   U R                  X5      S.nS n	U R                  US5      u  pUS:X  a  U	(       a  SOSnOUS:X  a  U	(       a  SOS	nX8S
'   Ub  U R                  X5      US'   U R	                  USS/5      (       a(  UR                  5       US'   U R                  X5      US'   OUS:X  a
  SUS'   SUS'   S n
U R                  US:H  SU5      u  pU
(       a  SUS'   U R                  X5      nUS   nUS   nUb  XS'   U R                  US5      nU R                  US5      nSSS.nUb  U R                  US5      US'   U R                  US5      nUb  SUS'   U R                  UU5      US'   U R                  US 5      nUb  U R                  UUU5      US!'   U R                  US5      nUb  U R                  US5      US'   U R                  US5      nUb  SUS"'   U R                  UU5      US#'   U R                  US 5      nUb  U R                  UUU5      US$'   U R                  US5      nS%U;  a  U R                  5       US%'   X/$ )&Nr3   )r*  r0  
reduceOnlyrw  
SELL_CLOSEBUY_OPENrv  	BUY_CLOSE	SELL_OPENr  rB  r   LIMITr  r&  MARKET	priceTypeFr1  r   r   r  	stopPricestopLoss
takeProfit
MARK_PRICECONTRACT_PRICE)r  r  r   slOrderTypeslLimitPricer   slTriggerBytpOrderTypetpLimitPricetpTriggerBynewClientOrderId)r&  r6  handle_param_boolr3  r  r2  r7   handle_trigger_prices_and_paramsr!  
safe_valuer  r  uuid)r   r*  r  r  r  rB  r   r&  rc  r;  r8  valuesr   rD  rE  triggerPriceTypes
limitPricer   s                     r   r*  $toobit.create_contract_order_request#  s   V$Tl00@
 
!33FLI
5=#-<:DV^",;+D#66vEGG==122"jjlGFO#66vEGGX%GFO#+GK 
!22483CUFS
%2GM"66vFay##/K >>&*5^^FL9
 $
 "&//(N"KGJ7;J%)0&*.*A*A&**U'#//:LM+)-)9)9:KM]_o)p&YYvz2F!$(OOJ$OGL!W=J%)0&*.*A*A&**U'#//
<NO+)-)9)9:KM]_o)p&YYv|4F"f,*.))+G&'  r   r  c                    U R                  USS5      nU R                  US5      nU R                  XB5      nU R                  US5      nU R                  US5      nU R	                  U R                  US5      5      nUS:X  a  S nU R                  0 SU_S	U R                  US
5      _SU R                  US5      _SU_SU R                  U5      _SS _SU R                  US5      _SU R                  U R                  US5      5      _SUS   _SU R                  U5      _SU R                  US5      _SUS:H  _SU_SU R	                  U R                  US5      5      _SU_SU R	                  U R                  US5      5      _SU R                  US5      _U R                  US5      U R                  US5      S S S S S S S S.	EU5      $ )NtransactTimero  r*  r  r  rC  z0.0r   r3   r  clientOrderIdrd  r  lastTradeTimestamplastUpdateTimestamp
updateTimer   r   postOnlyr1  rB  r   rH  cumulativeQuoteQtyr  avgPriceorigQtyexecutedQty)	r  filled	remainingtradesr  r   r;  r   r   )
r  r  r  safe_string_lower	omit_zero
safe_orderr  r   parse_order_statusparse_order_type)r   r  r&  rd  r  rawTyperawSideLowerr   s           r   r,  toobit.parse_order_  sJ   v ''~vF	##E84!!(3""5&1--eV<~~d&6&6uk&JK5 L  
E 
$""5)4 
 T--e_E 
 	 

 Y/ 
 !$ 
 "4#4#4UL#I 
 d--d.>.>uh.OP 
 fX& 
 D))'2 
 4++E=A 
 M1 
 L 
 T^^D$4$4UG$DE 
 L 
  DNN4#3#3E;O#PQ! 
" t''z:# 
$ &&ui8&&um<5 
6 7 	r   r   c                 :    SSSSSSSS.nU R                  X!U5      $ )Nr  closedcanceled)PENDING_NEWNEWPARTIALLY_FILLEDFILLEDPENDING_CANCELCANCELEDREJECTEDr  r   r   statusess      r   rh  toobit.parse_order_status  s3    ! &(""
 &99r   c                 2    SSSS.nU R                  X!U5      $ )Nr&  r   )rA  r@  r1  rw  rx  s      r   ri  toobit.parse_order_type  s'    "

 &99r   r3   c                 l  #    0 nU R                  US5      c  XS'   SnUb  U R                  U5      nUS   US'   SnU R                  SXSS5      u  pcUS:X  a  [        U R                  S-   5      eSnUS	:X  a)  U R                  U R                  XC5      5      I Sh  vN nO(U R                  U R                  XC5      5      I Sh  vN nU R                  U R                  US
5      5      nUS:w  a0  [        U R                  S-   U-   S-   U R                  U5      -   5      eU R                  Xu5      $  N Nn7f)a  
cancels an open order

https://toobit-docs.github.io/apidocs/spot/v1/en/#cancel-order-trade
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#cancel-order-trade

:param str id: order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
rY  Nr  r3   r*  rF   nonezf cancelOrder() requires a symbol argument or the "defaultType" parameter to be set to "spot" or "swap"r@   r   r  z order z can not be canceled, )r  r&  r  r"   r3   privateDeleteApiV1SpotOrderra  privateDeleteApiV1FuturesOrderrh  r(   jsonr,  )	r   r3   r*  r   rc  r&  r  r   r   s	            r   cancel_ordertoobit.cancel_order  sI     FO4<!#I[[(F &tGH
!??v_ef
#DGG  /W  %W  X  X!==dkk'>Z[[H!@@WA]^^H(()9)9(H)MNV) 3b 8;S SVZV_V_`hVi ijj11 \^s%   BD4D0(D4D2A-D42D4c                   #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   SnU R                  SXBS5      u  pRUS:X  a  [        U R                  S-   5      eSnUS:X  a)  U R                  U R                  X25      5      I Sh  vN nO(U R                  U R                  X25      5      I Sh  vN nU R                  SU05      /$  N NC N7f)	a  
cancel all open orders in a market

https://toobit-docs.github.io/apidocs/spot/v1/en/#cancel-all-open-orders-trade
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#cancel-orders-trade

:param str symbol: unified symbol
: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>`
Nr3   r*  rE   r~  zj cancelAllOrders() requires a symbol argument or the "defaultType" parameter to be set to "spot" or "swap"r@   r   )	r_  r&  r  r"   r3    privateDeleteApiV1SpotOpenOrdersra  $privateDeleteApiV1FuturesBatchOrdersrg  )r   r*  r   rc  r&  r  r   s          r   cancel_all_orderstoobit.cancel_all_orders  s     !!![[(F &tGH
!??@QSYcij
#DGG  /[  %[  \  \!BB4;;wC_``H
 "FFt{{SZGcddH
 OO 
 	
+ 	" a
 es4   C#CBC#C(C#C!C#C#!C#idsc                    #    U R                  5       I Sh  vN   SR                  U5      nSU0nSnUb  U R                  U5      nSnU R                  SXcS5      u  psUS:X  a  [	        U R
                  S-   5      eSnUS:X  a)  U R                  U R                  XS5      5      I Sh  vN nO(U R                  U R                  XS5      5      I Sh  vN nU R                  US/ 5      n	U R                  X5      $  N NS N,7f)	a  
cancel multiple orders

https://toobit-docs.github.io/apidocs/spot/v1/en/#cancel-multiple-orders-trade
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#cancel-multiple-orders-trade

:param str[] ids: order ids
:param str [symbol]: unified market symbol
: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>`
N,r  rG   r~  zg cancelOrders() requires a symbol argument or the "defaultType" parameter to be set to "spot" or "swap"r@   r   )r_  joinr&  r  r"   r3   &privateDeleteApiV1SpotCancelOrderByIdsra  )privateDeleteApiV1FuturesCancelOrderByIdsr   parse_orders)
r   r  r*  r   	idsStringrc  r&  r  r   r   s
             r   cancel_orderstoobit.cancel_orders  s     !!!HHSM	9
 [[(F
!??PV`fg
#DGG  /X  %X  Y  Y!HHU\IeffH
 "KKDKKX_LhiiH" (B7  00K 	" g
 js4   C>C8BC>&C:'(C>C<)C>:C><C>c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   SU0nU R                  U5      nSnUS   (       a)  U R	                  U R                  XC5      5      I Sh  vN nO(U R                  U R                  XC5      5      I Sh  vN nU R                  Xe5      $  N N@ N7f)a  
fetches information on an order made by the user

https://toobit-docs.github.io/apidocs/spot/v1/en/#query-order-user_data
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#query-order-user_data

:param str id: the order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nz( fetchOrder() requires a symbol argumentr  r@   )r"   r3   r_  r&  privateGetApiV1SpotOrderra  privateGetApiV1FuturesOrderr,  )r   r3   r*  r   rc  r&  r   s          r   fetch_ordertoobit.fetch_orderN  s      >#DGG.X$XYY!!!r
 V$&>!::4;;w;WXXH!==dkk'>Z[[H: 11M 	" Y[s4   /B?B9AB?:B;;(B?#B=$B?;B?=B?c                   #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   Ub  X5S'   SnU R                  SXd5      u  ptSnUS:X  a)  U R                  U R	                  XT5      5      I Sh  vN nO(U R                  U R	                  XT5      5      I Sh  vN nU R                  XX#5      $  N NA N7f)aa  
fetches information on multiple orders made by the user

https://toobit-docs.github.io/apidocs/spot/v1/en/#current-open-orders-user_data
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#query-current-open-order-user_data

: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>`
Nr3   r*  r   rZ   r@   )r_  r&  r  privateGetApiV1SpotOpenOrdersra   privateGetApiV1FuturesOpenOrdersr  	r   r*  rg  r   r   rc  r&  r  r   s	            r   fetch_open_orderstoobit.fetch_open_orders  s      !!![[(F &tGH$G
!??v^
!??G@\]]H: "BB4;;wC_``H  5@@U 	" ^: as4   C	CA,C	C(C	,C-C	C	C	c                   #    U R                  5       I Sh  vN   0 nUb  X5S'   Ub  X%S'   U R                  SXT5      u  pTSnUb  U R                  U5      nUS   US'   SnU R                  SXd5      u  ptSnUS:X  a  U R	                  U5      I Sh  vN nO[        U R                  S	-   U-   S
-   5      eU R                  XX#5      $  N N77f)a  
fetches information on multiple orders made by the user

https://toobit-docs.github.io/apidocs/spot/v1/en/#all-orders-user_data

: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>`
Nr   r  r  r3   r*  rZ   r@   $ fetchOrders() is not supported for  markets)r_  handle_until_optionr&  r  privateGetApiV1SpotTradeOrdersr)   r3   r  r  s	            r   fetch_orderstoobit.fetch_orders  s      !!!$G#(K 229gN[[(F &tGH
!??v^
!@@IIH: tww)OOR\\_iijj  5@@[ 	" Js"   C	CA8C	C6C	C	c                   #    U R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   Ub  X%S'   U R                  SXT5      u  pTSnU R                  SXd5      u  ptSnUS:X  a  [	        U R
                  S-   U-   S	-   5      eU R                  U5      I Sh  vN n/ n	[        S
[        U5      5       H  n
U	R                  SX   05        M     U R                  XX#5      $  N NK7f)a  
fetches information on multiple closed orders made by the user

https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#query-history-orders-user_data

: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>`
Nr3   r*  r  r  r   r@   r  r  r   r   )r_  r&  r  r  r)   r3   #privateGetApiV1FuturesHistoryOrdersr   r   r$  r  )r   r*  rg  r   r   rc  r&  r  r   
ordersListr   s              r   fetch_closed_orderstoobit.fetch_closed_orders  s     !!![[(F &tGH#(K 229gN
!??@SU[d
tww)OOR\\_iijj!EEgNNH6 
q#h-(Ax56 )  UBB[ 	" Os#   C4C0BC4&C2'A
C42C4c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   0 nUb  X%S'   Ub  X5S'   U R                  U5      nUS   US'   SnU R	                  SXd5      u  ptU R                  SXT5      u  pTSnUS	:X  a)  U R                  U R                  XT5      5      I Sh  vN nOU R                  U5      I Sh  vN nU R                  XX#5      $  N N2 N7f)
ai  
fetch all trades made by the user

https://toobit-docs.github.io/apidocs/spot/v1/en/#account-trade-list-user_data
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#account-trade-list-user_data

: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 trade structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch trades for
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Nz+ fetchMyTrades() requires a symbol argumentr  r   r3   r*  rU   r  r@   )
r"   r3   r_  r&  r  r  privateGetApiV1AccountTradesra   privateGetApiV1FuturesUserTradesrj  r  s	            r   fetch_my_tradestoobit.fetch_my_trades4  s     >#DGG.[$[\\!!!#(K $GV$"4L
!??QW`
229gN!>>t{{7?[\\H6 "BB7KKH*   5@@{ 	" ]6 Ls4   /C+C%BC+4C'5C+C)C+'C+)C+r   fromAccount	toAccountc                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  U R                  S0 5      nU R	                  XsU5      nU R	                  XtU5      n	US   U R                  X5      UU	S.n
U R                  U R                  X5      5      I Sh  vN nU R                  X5      $  N N7f)a  
transfer currency internally between wallets on the same account

https://open.big.one/docs/spot_transfer.html#transfer-of-user

:param str code: unified currency code
:param float amount: amount to transfer
:param str fromAccount: 'spot', 'swap'
:param str toAccount: 'spot', 'swap'
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
Nr   r3   )r  r0  fromAccountTypetoAccountType)	r_  rz  r!  r   r  currency_to_precision"privatePostApiV1SubAccountTransferra  parse_transfer)r   r   r  r  r  r   rz  r   fromIdtoIdrc  r   s               r   ra   toobit.transfer  s      !!!==&6FK!!.{K9Ed^224@%!	
 @@WA]^^ ""866% 	" _s"   CB?BC)C*CCra   rz  c           
          US S S S S S S S S.	$ )N)	r   r3   rd  r  rz  r  r  r  r    )r   ra   rz  s      r   r  toobit.parse_transfer  s)     

 
	
r   c                   #    U R                  5       I Sh  vN   Sn0 nUb  U R                  U5      nUS   US'   Ub  X&S'   U R                  SXd5      u  pdUb  X6S'   SnU R                  SSU5      u  ptSnUS:X  a)  U R	                  U R                  Xd5      5      I Sh  vN nO(U R                  U R                  Xd5      5      I Sh  vN nU R                  XX#5      $  N NA N7f)	a  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

https://toobit-docs.github.io/apidocs/spot/v1/en/#get-account-transaction-history-list-user_data
https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#get-future-account-transaction-history-list-user_data

:param str [code]: unified currency code, default is None
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
:param int [limit]: max number of ledger entries to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: end time in ms
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
Nr3   r   r  r  r   rE   r@   )r_  rz  r  r  !privateGetApiV1AccountBalanceFlowra  !privateGetApiV1FuturesBalanceFlowparse_ledger)	r   r   rg  r   r   rz  rc  r  r   s	            r   fetch_ledgertoobit.fetch_ledger  s      !!!}}T*H&tnGFO#(K 229gN$G
!??@QSWY_`
!CCDKKPWD`aaH!CCDKKPWD`aaH&   UBBI 	" bas4   C%CBC%C! (C%C#	C%!C%#C%itemc                    U R                  US5      nU R                  X25      nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  [
        R                  " U5      5      nSnUR                  S5      (       a  SnU R                  UU R                  US5      UU R                  U5      US S S U R                  U R                  US	5      5      US
   US US S S.U5      $ )Nr   rN  r   r  inr-  outr3   flowTyper   )r   r3   rd  r  	directionr$  referenceIdreferenceAccountr  rz  r  beforeafterr   r  )r  safe_currencyr   r  parse_numberr-   
string_abs
startswithsafe_ledger_entryr  parse_ledger_type)	r   r  rz  
currencyIdrd  r  	amountRawr  r  s	            r   parse_ledger_entrytoobit.parse_ledger_entry  s   %%dH5
%%j;%%dI6	  w/$$T84	""7#5#5i#@A	$$I%%""4."Y/" $**4+;+;D*+MN ('
  ! 	r   c                 0    SSS.nU R                  X!U5      $ )Nra   rebate)USER_ACCOUNT_TRANSFERAIRDROPrw  )r   r  typess      r   r  toobit.parse_ledger_type	  s$    %/
 T22r   c                 X  #    U R                  5       I Sh  vN   SnSnSnU R                  SSU5      u  p1US:X  a  [        U R                  S-   U-   S-   5      eU R	                  USS/5      (       aq  SnU R                  US5      u  pQUc  [        U R                  S	-   5      eU R                  U5      nSUS
   0nU R                  U R                  Xa5      5      I Sh  vN n0 nUnU R                  US5      n	U R                  X5      nU R                  X5      n
XUS   '   U$  GN NH7f)aG  
fetch the trading fees for multiple markets

https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#user-trade-fee-rate-user_data

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
NfetchTradingFeesr@   z& fetchTradingFees(): does not support r  rB   rC   r*  z- fetchTradingFees requires a params["symbol"]r3   )r_  r  r)   r3   r  r4  r#   r&  $privateGetApiV1FuturesCommissionRatera  r  r  parse_trading_fee)r   r   r   r  r&  r*  rc  r   r  r  r  s              r   fetch_trading_feestoobit.fetch_trading_fees	  sL     !!!
!??@RTXZ`a
tww)QQT^^akkll]]:'9::F!55fhGNF~ +Z!Z[[[[(F&,G "FFt{{SZGcddH ##E84!!(3$$U3#&vh ? 	"  es#   D*D%CD*D( AD*(D*c                     U R                  US5      nUU R                  X25      U R                  US5      U R                  US5      S S S.$ )Nr*  closeMakerFeecloseTakerFee)r   r*  r|  r}  r  	tierBased)r  r  r  )r   datar&  r  s       r   r  toobit.parse_trading_fee8	  sU    ##D(3&&x8%%dO<%%dO<
 	
r   c                 D   #    U R                  SXX45      I Sh  vN $  N7f)a  
fetch all deposits made to an account

https://toobit-docs.github.io/apidocs/spot/v1/en/#deposit-history-user_data

: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 deposit 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>`
depositsN$fetch_deposits_or_withdrawals_helperr   r   rg  r   r   s        r   fetch_depositstoobit.fetch_depositsC	  s#      >>z4X]ffff     c                 D   #    U R                  SXX45      I Sh  vN $  N7f)a  
fetch all withdrawals made from an account

https://toobit-docs.github.io/apidocs/spot/v1/en/#withdrawal-records-user_data

: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 withdrawal 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>`
withdrawalsNr  r  s        r   fetch_withdrawalstoobit.fetch_withdrawalsQ	  s#      >>}d[`iiiir  c                   #    U R                  5       I S h  vN   S n0 nUb  U R                  U5      nUS   US'   Ub  X7S'   U R                  SXu5      u  puUb  XGS'   S nUS:X  a)  U R                  U R	                  Xu5      5      I S h  vN nO.US:X  a(  U R                  U R	                  Xu5      5      I S h  vN nU R                  XX4U5      $  N NH N7f)Nr3   r   r  r  r   r  r  )r_  rz  r  #privateGetApiV1AccountDepositOrdersra  $privateGetApiV1AccountWithdrawOrdersparse_transactions)	r   r  r   rg  r   r   rz  rc  r   s	            r   r  +toobit.fetch_deposits_or_withdrawals_helper_	  s     !!!}}T*H&tnGFO#(K 229gN$G:!EEdkkRYFbccH, ]"!FFt{{SZGcddH8 &&x5PPA 	" d. es4   CCA1CC	.C7C8CCCtransactionc                    U R                  US5      nU R                  USS5      nU R                  XB5      nU R                  US5      nU R                  US5      nS nUb#  U R	                  U5      U R                  U5      S.nU R                  USS5      n	U R                  US	5      n
U R                  US
5      nU R                  US5      nSU;   nU(       a  SOSn0 SU_SU R                  US5      _SU R                  US5      _SU_SU R                  U5      _SS _S
S _SU_SU_SS _SU	_SU
_SU_SU R                  US5      _SU_SU R                  U R                  US5      5      _S S _US S S!.E$ )"Nro  r   r   r  feeCoinName)rH  rz  
addressTag
addressExtfromAddressTagaddressfromAddressarriveQuantity
withdrawalr	  r   r3   txidtxIdrd  r  r
  	addressToaddressFromtagtagTotagFromr  r  r0  rz  r   r   )r  commentinternal)r   r  r  r  r  r  r  parse_transaction_status)r   r  rz  rd  r  r   	feeStringfeeCoinr  r	  r
  r  r  
isWithdrawr  s                  r   parse_transactiontoobit.parse_transaction	  s   R %%k6:	''VXF
&&z<$$[%8	"";> )))4 33G<C "";lK"";0@A$$[)<	&&{MB&+5
)|y
K
$"";5
 D$$[&9
 	

 Y/
 t
 t
 
 ;
 4
 U
 w
 D
 d&&{J?
 
  d33D4D4D[RZ4[\!
" t#
$ )
 	
r   c                 4    SSSSS.nU R                  X!U5      $ )Npendingfailedr   )212113rw  rx  s      r   r  toobit.parse_transaction_status	  s*    	
 &99r   c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      u  pVUc  [	        U R
                  S-   5      eU R                  U5      US'   U R                  U R                  XF5      5      I Sh  vN nU R                  Xs5      $  N N7f)a_  
fetch the deposit address for a currency associated with self account

https://toobit-docs.github.io/apidocs/spot/v1/en/#deposit-address-user_data

: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>`
Nr   r3   z5 fetchDepositAddress() : param["network"] is requiredr   )	r_  rz  handle_network_code_and_paramsra  r"   r3   network_code_to_id$privateGetApiV1AccountDepositAddressparse_deposit_address)r   r   r   rz  rc  r  paramsOmittedr   s           r   fetch_deposit_addresstoobit.fetch_deposit_address	  s      !!!==&HTN
 &*%H%HU\Ie%f"#DGG.e$eff#66{CBB4;;wCfgg ))(==+ 	" hs"   CB=BC'B?(C?Cc                     U R                  US5      nU R                  U5        UU R                  US5      S UU R                  US5      S.$ )Nr   r   r  )r   rz  r
  r   r  )r  check_address)r   depositAddressrz  r   s       r   r  toobit.parse_deposit_address
  sU    "">9=7#"((6:##NLA
 	
r   r   r  c                   #    U R                  U5        SnU R                  U5      u  peUc  [        U R                  S-   5      eU R	                  5       I Sh  vN   U R                  U5      nUS   UU R                  US   U5      US.nUb  XHS'   U R                  U R                  X5      5      I Sh  vN n	U R                  X5      $  Nr N7f)a  
make a withdrawal

https://toobit-docs.github.io/apidocs/spot/v1/en/#withdraw-user_data

:param str code: unified currency code
:param float amount: the amount to withdraw
:param str address: the address to withdraw to
:param str tag: a memo for the transaction
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nz* withdraw() : param["network"] is requiredr3   r   )r   r   r0  r
  r  )
r$  r  r"   r3   r_  rz  r  privatePostApiV1AccountWithdrawra  r  )
r   r   r  r   r  r   r  rz  rc  r   s
             r   rb   toobit.withdraw(
  s      	7#"AA&I#DGG.Z$Z[[!!!==&TN228F3CVL"	
 ?$'L!==dkk'>Z[[ %%h99) 	" \s%   ACC
AC4C5CCr   c                 `  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   S:w  a  [	        U R                  S-   5      eUR                  5       nUS   US.nU R                  U R                  XS5      5      I Sh  vN nU$  Nx N7f)aI  
set margin mode to 'cross' or 'isolated'

https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#change-margin-type-trade

:param str marginMode: 'cross' or 'isolated'
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: response from the exchange
Nz+ setMarginMode() requires a symbol argumentr  rB   z- setMarginMode() supports swap contracts onlyr3   )r*  
marginType)r"   r3   r_  r&  r$   r2  !privatePostApiV1FuturesMarginTypera  )r   r   r*  r   r&  rc  r   s          r   set_margin_modetoobit.set_margin_modeP
  s      >#DGG.[$[\\!!!V$&>V#DGG&UUVV%%'
Tl$
 ??G@\]]  	" ^s"   /B.B*A1B.#B,$B.,B.r   c                    #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   US.nU R	                  U R                  XS5      5      I Sh  vN nU$  NG N7f)aK  
set the level of leverage for a market

https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#change-initial-leverage-trade

:param float leverage: the rate of leverage
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: response from the exchange
Nz) setLeverage() requires a symbol argumentr3   )r*  r   )r"   r3   r_  r&  privatePostApiV1FuturesLeveragera  )r   r   r*  r   r&  rc  r   s          r   set_leveragetoobit.set_leveragel
  s      >#DGG.Y$YZZ!!!V$Tl 
 ==dkk'>Z[[  	" \s"   /A=A9A A=2A;3A=;A=c                 
  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R                  Xc5      $  Nh N*7f)aa  
fetch the set leverage for a market

https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#get-the-leverage-multiple-and-position-mode-user_data

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
Nr*  r3   r  )r_  r&  %privateGetApiV1FuturesAccountLeveragera  r!  parse_leverage)r   r*  r   r&  rc  r   r  s          r   fetch_leveragetoobit.fetch_leverage
  s      !!!V$fTl
 CCDKKPWD`aa ~~h3""400! 	"
 bs!   BA??BB)BBc                     U R                  US5      nU R                  US5      nU R                  US5      nUS:X  a  SOSnUU R                  X25      UUUS.$ )Nr*  r   r+  crossedcrossisolated)r   r*  r   longLeverageshortLeverage)r  r   r  )r   r   r&  r  leverageValuer+  r   s          r   r5  toobit.parse_leverage
  sj    ##Hh7))(J?%%h=
!+y!8Wz
&&x8$)*
 	
r   c                 p  #    U R                  5       I Sh  vN   0 nSnUbW  [        U5      nUS:  a  [        U R                  S-   5      eU R	                  US5      nUb  U R                  U5      nUS   US'   U R                  U R                  X25      5      I Sh  vN nU R                  Xq5      $  N N7f)aU  
fetch all open positions

https://toobit-docs.github.io/apidocs/usdt_swap/v1/en/#query-position-user_data

:param str[]|None symbols: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
Nro   zX fetchPositions() only accepts an array with a single symbol or without symbols argumentr   r3   r*  )	r_  r   r#   r3   r  r&  privateGetApiV1FuturesPositionsra  parse_positions)r   r  r   rc  r&  r  firstSymbolr   s           r   fetch_positionstoobit.fetch_positions
  s      !!!\Fz   ,F  "F  G  G**7A6K&[1$*4L!==dkk'>Z[[0 ##H66G 	" \s"   B6B2BB6B4B64B6positionc                 T   U R                  US5      nU R                  X25      nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  0 SU_SU R                  US5      _SUS   _SU R                  US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U_SU R                  U5      _SS _SS _SS _SS _SS _SS _U R                  US5      S US S S S S.E5      $ )Nr*  r  rF  r   r   r3   
entryPricer_  r  	lastPricenotionalpositionValue
collateralunrealizedPnlunrealizedPnLr   rI  rd  r  r   maintenanceMarginmaintenanceMarginPercentagerA   )initialMargininitialMarginPercentager   liquidationPricemarginRatior   r  )r  r  re  r   safe_positionr  )r   rF  r&  r  r  r0  r   s          r   parse_positiontoobit.parse_position
  s   ##Hh7!!(3%%h7##Hj9$$Xz:!! #
H#
$""8T2#
 fX&#
 $**8Z@	#

 ))(K@#
 ))(K@#
 ((?C#
 $#
 T--hH#
 D#
 **84#
 D#
 #
 #
 d#
   !#
" *4##
$ "--hA'+  $1#
  	r   publicGETc                    U R                   S   U   S-   U R                  X5      -   nUS:H  nUS:H  n	0 n
U R                  X@R                  U5      5      nUS:w  a'  U(       d  U(       a  USU R	                  U5      -   -  nGOLU R                  5         U R                  5       nU R                  U R                  SS5      U
S'   [        U5      U
S	'   U R                  X5      nS
nU(       d  U	(       aJ  [        U[        5      (       d  U R	                  U5      nO4U R	                  U
5      nU R                  U5      nOU R	                  U5      nUnUb  Xo-   nU R                  U R                  U5      U R                  U R                   5      ["        R$                  S5      nUS
:w  a  USU-   -  nUSU-   -  nOUSU-   -  nSU R&                  SS.nXsXeS.$ )Nri   r5  POSTDELETEre   ?
recvWindow5000rd   hexz&signature=CCXTz!application/x-www-form-urlencoded)ReferrerzX-BB-APIKEYzContent-Type)rf   methodbodyheaders)rc   implode_paramsr  extract_params	urlencodecheck_required_credentialsmillisecondsr  r   strra  
isinstancelistr  hmacencodesecrethashlibsha256apiKey)r   pathri   rd  r   rf  re  rf   isPostisDelete
extraQueryqueryrd  queryExtendedqueryStringpayload	signatures                    r   signtoobit.sign
  s   iis#c)D,?,?,MM6!X%
		&"5"5d";<)3!666C++-))+I'+'7'7lTZ'[J|$&))nJ{# KK:MK!&$//>>-8D"&.."<K99U+D"nn];!G.		$++g"6DKK8PRYR`R`bghIb }y88s[((	11"#{{ CG
 dOOr   reasonrf   rd  rf  re  c
                 0   Uc  g U R                  US5      n
U R                  US5      nU
(       ag  U
S:w  aa  U
S:w  a[  U R                  S-   U-   nU R                  U R                  S   X5        U R	                  U R                  S   X5        [        U5      eg )Nr   msg2000 r   r   )r  r3   throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr    )r   r   r  rf   rd  rf  re  r   requestHeadersrequestBody	errorCodemessagefeedbacks                r   handle_errorstoobit.handle_errors*  s    $$Xv6	""8U3e+	S0@ww}t+H001I9_001I7]))r   r  )N)d__name__
__module____qualname____firstlineno__r   r   r   r
   r   r   r   dictr   r   r   r   r'  r   r#  rl  r   re  r   rk  r  rn  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,  rh  ri  r  r  r  r  r  r  r  r  r   ra   r  r   r  r  r  r   r  r  r   r  r  r  r  r  r	   r!  r  rb   r-  intr1  r   r6  r5  r   rD  rV  r~  r  __static_attributes____classcell__)r   s   @r   r/   r/      sG   @# @D )+ 
$ ') 9S 9" -/ O: Ob4$ 48 4l *, W_0E WrF4 FF FP @DB 0VS 0V 0VS\ 0Vd <@d[] A AS A Abfglbm ABZ Zv Z Zx 8<$]ajl bL bLC bLWZ bLquvzq{ bLH
 
4 
 6:" ,=7 ,= ,=\4  6 8 :>b 9w 9<

f 

 8<B >W >B BFb @w @U\ @	
 <@ ; ;| ;:
6 
[ 
4 >BPTcgpr #Qs #Q# #Q]` #QJ	
6 	
 *, -, -,^) )" mqy{ 02 02I 02Y 02X] 02fi 02d os{} !3 !i !y !Z_ !hk !4 x|  EG :!C :!y :!PY :!ch :!qt :!x^ ^v ^ ^@
: 
:: 9=R  2S  2#  2D 59 $
c $
L AER 11tCy 11# 11f 8<B 42C 42 42l 59tZ^gi 7Ac 7A 7ATW 7Anrsxny 7Ar 04$UYbd 9A 9AC 9As 9Aimnsit 9Av 7;\`ik :C :C3 :CVY :Cptuzp{ :Cx 37TX\eg MAC MAs MARU MA^ ac 73 7 7C 7TW 7gt 7B
t 
x 
= 
& .2SW`b 2Cs 2C# 2CS 2Cgklwgx 2Cht x ; 83 /1 ([ (T	
f 	
 04$UYbd g gC gs gimnyiz g 37TX\eg jC js jRU jlpq|l} jAQFO
T O
X O
Q\ O
b:s : =? > >> >B	
h 	
R` 	
 QU]_ &:3 &: &: &:# &:do &:P DHPR  S 8 ?C2 3  2 8: 13 1h 18
t 
V 
x 
 8<B -7W -74PX> -7^t V B &eBSW *PX
# 
s 
 
c 
TX 
`c 
 
r   r/   )4 ccxt.async_support.base.exchanger   ccxt.abstract.toobitr   rr  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   ccxt.base.decimal_to_precisionr,   ccxt.base.preciser-   r/   r  r   r   <module>r     sw    6 ,  f  f  f  f  f  f  f  * - . ' & . . ) * ) , . 4 %Y,X{ Y,r   