
    !:h$                       d dl mZ d dlmZ d dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lm Z  d d
lm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dlm(Z( d dlm)Z) d dlm*Z* d dlm+Z+ d dlm,Z, d dlm-Z- d dl.m/Z/ d dl.m0Z0 d dl1m2Z2  G d dee      Z3y)    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesCurrencyIntMarginModificationMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)OrderImmediatelyFillable)NotSupported)DDoSProtection)RateLimitExceeded)ExchangeNotAvailable)OnMaintenance)InvalidNonce)TRUNCATE)	TICK_SIZE)Precisec                       e Zd Zdef fdZd Zi fdZi fdefdZi fde	fdZ
i fdee   fdZdedefd	Zdefd
Zi fdefdZdi fdededefdZdNdededefdZi fdedefdZdddi fdedededee   fdZdNdedefdZdi fdefdZdi fdedefdZdNdedede fdZ!ddi fdedededee    fdZ"de#fdZ$dNdedede%fd Z&i fded!e'fd"Z(di fded#e)d$e*d%e'd&e+f
d'Z,di fd(ede#fd)Z-dddi fde#dededee%   fd*Z.dddi fde#dededee%   fd+Z/di fd(ede#fd,Z0di fde#fd-Z1dddi fde#dedefd.Z2dddi fd/e#dededee3   fd0Z4dddi fd/e#dededee3   fd1Z5dNd2Z6dNd3ed4e7de3fd5Z8di fd/ed%e'd6ede3fd7Z9dNd4e7fd8Z:di fd9efd:Z;dNd;Z<dddi fd/e#dededee=   fd<Z>i fd/ed%e'd=ed>ede=f
d?Z?di fd@ede#fdAZ@dNdeAfdBZBi fded%e'deAfdCZCdDdEi ddfdFZDd/eEdGedHedIedJedKefdLZFi fdMZG xZHS )Obitruereturnc                    | j                  t        t        |          i ddddddgddd	d
dddddi dd dddd
dddd
dd
dd
dd
dd
dd
dddddd
dd
dddd
d d
i d!dd"d
d#d
d$dd%dd&dd'dd(dd)dd*d
d+d
d,d
d-d
d.d
d/d
d0dd1d
i d2d
d3dd4d
d5dd6d
d7d8d9dd:d
d;d
d<d
d=d
d>d
d?d
d@d
dAd
dBd
dCd
i dDd
dEd
dFd
dGd
dHd
dId
dJd
dKd
dLd
dMd
dNd
dOddPd
dQd
dRd
dSd
dTdi dUddVd
dWd
dXd
dYddZd
d[d
d\dd]dd^d
d_d
d`d
dad
dbd
dcd
ddd
ded
i dfd
dgddhddiddjddkddld
dmd
dnd
dod
dpddqd
drddsd
dtd
dud
dvddd
d
dddwdxdydzd{d|d}d~dddd	dddddddddddgddddddddiidddddddgddgddggdddddddddddddddiddddddddddddddddiddddddiiiddddddddddiiddddddddddddddddddiddddddddddiiddddddddddddddddddiddddd
d| j	                  d      | j	                  d      ddddd| j	                  d      | j	                  d      | j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d«      | j	                  d      g| j	                  dë      | j	                  dī      gg
| j	                  d      | j	                  d      g| j	                  d      | j	                  dū      g| j	                  d      | j	                  dƫ      g| j	                  d      | j	                  dǫ      g| j	                  d      | j	                  dȫ      g| j	                  d      | j	                  dɫ      g| j	                  d      | j	                  dʫ      g| j	                  d      | j	                  d˫      g| j	                  d«      | j	                  d̫      g| j	                  dë      | j	                  d      gg
d͜dΜidddd| j	                  dЫ      | j	                  dȫ      | j	                  d      | j	                  dЫ      g| j	                  d      | j	                  dѫ      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  dҫ      g| j	                  d      | j	                  dҫ      g| j	                  d      | j	                  dҫ      g| j	                  d«      | j	                  dҫ      g| j	                  dë      | j	                  dҫ      gg
| j	                  d      | j	                  dȫ      g| j	                  d      | j	                  dɫ      g| j	                  d      | j	                  dӫ      g| j	                  d      | j	                  dԫ      g| j	                  d      | j	                  d      g| j	                  d      | j	                  dի      g| j	                  d      | j	                  d֫      g| j	                  d      | j	                  d׫      g| j	                  d«      | j	                  dث      g| j	                  dë      | j	                  d٫      gg
d͜dΜidڜddg dܢdd
t
        ddd
d
dddi ddddddddddddddddddddddddddddddddddi ddddd dddddddddddd	d
ddddddddddddddddi ddddddddddddddd d!d"d#d$d$d%d%d&d&d'd'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<ddydzd{d|d}d~dd=ddd>
d?d@dAdBdCdDdEdFdGdHdIdJdJdIdIdJdKdLdMdNdOidPt        dQd
d
dd d d
d
d dddd
dRd
d
d
ddd
ddSd d
ddTdTddUd
d
d
ddVd
d d
d
ddWd d
ddXddXd
d
ddYdZd[id\	d]d^id^ddd
d
d_dZd`id dad]dbid]dbidcd d dcdddei dft        dgt        dht        dit        djt        dkt        dlt        dmt        dnt        dot        dpt        dqt        drt        dst        dtt        dut        dvt         i dwt        dxt        dyt"        dzt$        d{t        d|t"        d}t"        d~t"        dt"        dt"        dt"        dt"        dt"        dt         dt"        dt"        dt"        i dt"        dt         dt"        dt"        dt"        dt&        dt        dt"        dt"        dt"        dt"        dt         dt         dt        dt        dt(        dt(        i dt        dt        dt        dt        dt        dt        dt        dt        dt        dt*        dt"        dt        dt        dt        dt        dt        t        t        t         dd      S (  Nidr.   nameBitrue	countriesSG	rateLimit  	certifiedFversionv1proThasCORSspotmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercloseAllPositionsclosePositioncreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeesfetchTransactionsfetchTransfersfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage)	setMarginsetMarginModesetPositionModetransferwithdraw
timeframes1m5m15m30m1H2H4H1D1W)	r   r   r   r   1h2h4h1d1wurlszOhttps://github.com/user-attachments/assets/67abe346-1273-461a-bd7c-42fa32907c8ezhttps://www.bitrue.com/apizhttps://fapi.bitrue.com/fapizhttps://fapi.bitrue.com/dapiz https://www.bitrue.com/kline-api)r>   fapidapiklinezhttps://www.bitrue.comzEhttps://www.bitrue.com/affiliate/landing?cn=600000&inviteCode=EZWETQEz;https://github.com/Bitrue-exchange/bitrue-official-api-docszhttps://www.bitrue.com/api-docsz;https://bitrue.zendesk.com/hc/en-001/articles/4405479952537)logoapiwwwreferraldocfeesr   publicget   )zpublic.jsonzpublic{currency}.jsond   i     
   )costbyLimit(   )r   noSymbol   )pingtimeexchangeInfodepthtradeshistoricalTrades	aggTradeszticker/24hrzticker/pricezticker/bookTickerzmarket/kline)order
openOrders	allOrdersaccountmyTradeszetf/net-value/{symbol}zwithdraw/historyzdeposit/history   )r   zwithdraw/commitr   )r   postdelete)r   privater   r   )r   r:   v2)r   r   	contractsr   tickerklines)r   r   r   r   leverageBracketcommissionRatefutures_transfer_historyforceOrdersHistory)positionMargin
level_editcancelr   allOpenOrdersfutures_transfer)r   r   )r:   r   )r>   r   r   r   z0.00098)feeSide	tierBased
percentagetakermakertradingquotez0.000400z0.00020002502500z0.0003507500z0.00032022500z0.00030050000z0.000270100000z0.000250200000z0.000220400000750000z0.000170z0.000160z0.000140z0.000120z0.000100z0.000080z0.000060z0.000040z0.000020)r   r   )r   r   r   r   r   tiersbasez0.000500z0.000450z0.000240z0.000050z	0.0000030z	-0.000050z	-0.000060z	-0.000070z	-0.000080z	-0.000090)r   rA   deliveryoptionsr>   linearinversev2PrivateGetMyTrades  r   FULL)marketlimitERC20ETHTRC20TRX	AETERNITY	AeternityAIONALGOAlgorandASKATOMAVAXCzAVAX C-ChainBCHBEP2BEP20BitcoinBRP20ADACardano
CASINOCOIN
CasinoCoinzCASINOCOIN-XRPLzCasinoCoin XRPL	CONTENTOS	ContentosDASHDashDECOINDecoinDFI	DeFiChainDGBDIVIDiviDOGEdogecoinEOSETCFILECOINFilecoinFREETONHBARHEDERAzHedera HashgraphHRC20ICONICPIGNISIgnisINTERNETCOMPUTERzInternet ComputerIOTAKAVAKSMLTCLiteCoinLUNALunaMATIC
MOBILECOINzMobile CoinMONACOINMonaCoinXMRMoneroNEMNEP5OMNIPACDOTPolkadotRAVEN	RavencoinSAFEXSafexSOLSOLANASongbirdzStellar LumensSymbolTezosthetaTHETAVeChainWanchainzXinFin NetworkXRPXRPLZIL)SGBXMLXYMXTZrR  rS  VECHAINWANCHAINXINFINrV  rW  rX  12H)
r   r   r   r   r   r   r   12hr   r   1min5min15min30minr   1day1week1month)r   r   r   r   r   r   r   1M)r>   rA   walletcontract)r>   rA   r@   fundingfundrk  )!createMarketBuyOrderRequiresPricer|   fetchMyTradesMethod#hasAlreadyAuthenticatedSuccessfullycurrencyToPrecisionRoundingMode
recvWindowtimeDifferenceadjustForTimeDifferenceparseOrderToPrecisionnewOrderRespTypenetworksdefaultTyper   accountsByTypecommonCurrenciesMIMz	MIM SwarmprecisionModefeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyRequiresPricemarketBuyByCostselfTradePreventionicebergi )r  r  daysBack	untilDayssymbolRequired)r  triggerr  r  )r  r  r  r  r  Z   )r  r  r  daysBackCanceledr  r  r  r  r  i  )	sandboxrN   createOrdersr   r   r   r   r]   r   extendsdefault)r  r  r  r  i,  )r  rN   r   r]   forDerivatives)r   r  )r  r>   r  r@   rA   
exceptionszSystem is under maintenance.zSystem abnormalityz/You are not authorized to execute self request.zAPI key does not existz Order would trigger immediately.z%Stop price would trigger immediately.z'Order would immediately match and take.z6Account has insufficient balance for requested action.z Rest API trading is not enabled.zYou don't have permission.zMarket is closed.z*Too many requests. Please try again later.z-1000z-1001z-1002z-1003z-1013z-1015z-1016z-1020z-1021z-1022z-1100z-1101z-1102z-1103z-1104z-1105z-1106z-1111z-1112z-1114z-1115z-1116z-1117z-1166z-1118z-1119z-1120z-1121z-1125z-1127z-1128z-1130z-1131z-1160z-1156z-2008z-2010z-2011z-2013z-2014-2015z-2017z-2019z-3005z-3006z-3008z-3010z-3015z-3022z-4028z-3020z-3041z-5013z-11008z-4051)zInsufficient account balancezhas no operation privilegeMAX_POSITION)exactbroad)deep_extendsuperr.   describeparse_numberr*   r+   r(   r   r   r   r#   r    r'   r%   r&   r!   r   r)   r   r"   r   )self	__class__s    E/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/bitrue.pyr  zbitrue.describe$   s9   fd < > @
A
(@
A
H@
A
 $@
A
 	@
A

 @
A
 t@
A
 4@
A
  lll %l 	l
 %l %l Ul $Ul 'l l "4l tl $Ul  l /l  ,U!l" 0#l$ t%l& 7'l( 9%)l* (+l, '-l. (/l0 "41l2 3l4  5l6 &u7l8 "59l: +E;l< )%=l> #E?l@ ,UAlB $TClD 'ElF (GlH "4IlJ &uKlL  MlN +EOlP *:QlR +DSlT &uUlV 'WlX (YlZ #E[l\ *5]l^ $U_l` ualb "5cld *5elf +Eglh )%ilj  kll !%mln %eolp $Uqlr &uslt -eulv /wlx "5ylz #E{l| +E}l~ l@ !%AlB "5ClD &uElF +EGlH  IlJ dKlL $UMlN +EOlP %eQlR "4SlT uUlV #EWlX dYlZ !$[l\ u]l^  _l` 'alb $Ucld !%elf (glh %eilj )%kll )%mln tolp tqlr slt Tulv twlx "5ylz #E{l| '}l~ $Ul@ !$AlB )%ClD #DElF GlH #EIlJ &uKlL tMlN "!&#(  Wl@
A
l 
m@
A
B i8::?	 0cQ5 VC@
A
b  !!/09:$# "()()0123#qCQR8VZ\^U_@`)a*+45-.89r/J9:0J>?Q5O01$#" *+./-.+,56B,G:;4534	$ *+34%
 !('$!#J "! *A$$[4n !!()()-.)**+*+$	# ",-./)*+,3423<=67	$ 34./*+)*1245%$#L !!()()-.)**+*+$	# ",-./)*+,3423<=67	$ 34./*+)*1245%$#u~c@
A
` $!&"&!..y9!..y9 #*%)&*!%!2!2:!>!%!2!2:!> "&!2!23!79J9J:9V W!%!2!25!94;L;LZ;X Y!%!2!26!:D<M<Mj<Y Z!%!2!26!:D<M<Mj<Y Z!%!2!27!;T=N=Nz=Z [!%!2!27!;T=N=Nz=Z [!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \& "&!2!23!79J9J:9V W!%!2!25!94;L;LZ;X Y!%!2!26!:D<M<Mj<Y Z!%!2!26!:D<M<Mj<Y Z!%!2!27!;T=N=Nz=Z [!%!2!27!;T=N=Nz=Z [!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPS>T U&"  "H #)%)&*!%!2!2:!>!%!2!2:!> "&!2!23!79J9J:9V W!%!2!25!94;L;LZ;X Y!%!2!26!:D<M<Mj<Y Z!%!2!26!:D<M<Mj<Y Z!%!2!27!;T=N=Nz=Z [!%!2!27!;T=N=Nz=Z [!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \!%!2!28!<d>O>OPZ>[ \& "&!2!23!79J9J:9V W!%!2!25!94;L;LZ;X Y!%!2!26!:D<M<Mj<Y Z!%!2!26!:D<M<Mk<Z [!%!2!27!;T=N=Ns=S T!%!2!27!;T=N=N{=[ \!%!2!28!<d>O>OP[>\ ]!%!2!28!<d>O>OP[>\ ]!%!2!28!<d>O>OP[>\ ]!%!2!28!<d>O>OP[>\ ]&"  "WNa@
A
@ 59! (>7<3;&"#+0).$#%@U@U@  @ F	@
 J@ 5@ F@ ^@ 5@ F@ W@ y@ W@ 9@ !,@  &'8!@"  #@$ F%@& h'@( ;)@* 5+@, F-@. J/@0 51@2 53@4 
5@6 y7@8 F9@: 0;@< W=@> F?@@ 5A@B WC@D '(;E@F FG@H FI@J 5K@L :M@N FO@P WQ@R !-S@T 
U@V 8W@X 5Y@Z F[@\ F]@^ 5_@` :a@b [c@d We@f 8g@h &+#"$$( *. " @B  & #"$$"""$"" %$&&"$%&	2 %(&'$ *#[uA@
A
l {!m@
A
r Ys@
A
t $&+(,,0,0).+06:#'#'"&#(	( #($)$)26+//4#')$, %)&+!%$*%+*.& ',#($)*.	# ',!%#($)*.( $(&+!%$&,-%'#($)*.	*  #q;z y  )&*$(27+0	$  # *.# "#3 "#3 	 ##kYu@
A
h D2MD(-D FGWD -.A	D
 78PD <=UD >?WD MN_D 78LD 12BD ()=D A.D 1D 1D 0D  .!D" \#D$ .%D& 1'D( Z)D* \+D, 0-D. Z/D0 Z1D2 Z3D4 Z5D6 Z7D8 Z9D: Z;D< Z=D> \?D@ ZADB ZCDD ZEDF ZGDH \IDJ ZKDL ZMDN ZODP YQDR 0SDT ZUDV ZWDX ZYDZ Z[D\ \]D^ \_D` 0aDb ]cDd ]eDf ]gDh 0iDj 0kDl .mDn .oDp .qDr .sDt .uDv ]wDx ]yDz -{D| Z}D~ .D@ .ADB .CDD /EDF .GDL 5F2B$0MKi@
A
 @
 @
	    c                 B    | j                         | j                  d   z
  S )Nrs  )millisecondsr   )r  s    r  noncezbitrue.nonce  s       "T\\2B%CCCr  c                     | j                  |      }t        |j                               }t        |      }|rdnd}|ddd|dS )ae  
        the latest known information on the availability of the exchange API

        https://github.com/Bitrue-exchange/Spot-official-api-docs#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>`
        maintenanceokN)statusupdatedetaurlinfo)spotV1PublicGetPinglistkeyslen)r  paramsresponser  
keysLengthformattedStatuss         r  fetch_statuszbitrue.fetch_status  sQ     ++F3 HMMO$Y
+5-4%
 	
r  c                 H    | j                  |      }| j                  |d      S )ah  
        fetches the current integer timestamp in milliseconds from the exchange server

        https://github.com/Bitrue-exchange/Spot-official-api-docs#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
        
serverTime)spotV1PublicGetTimesafe_integer)r  r  r  s      r  
fetch_timezbitrue.fetch_time  s)     ++F3   <88r  c                    | j                  |      }i }| j                  |dg       }t        dt        |            D ]   }||   }| j	                  |d      }| j	                  |d      }| j                  |      }	| j                  |dg       }
i }t        dt        |
            D ]  }|
|   }| j	                  |d      }| j                  ||	      }|||| j                  |d      | j                  |d      d	| j                  |d
      d	d| j                  |d      | j                  |d      did	||<    | j                  |||	d	|d	d	d	|d	d	ddd	d	did      ||	<   # |S )z
        fetches all available currencies on an exchange
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        coinsr   coincoinFulNamechainDetailchainenableDepositenableWithdrawNwithdrawFeer   minWithdrawmaxWithdrawminmax)	r  r1   networkdepositr   activefee	precisionlimitscrypto)r1   r2   coder  r  r  r  r   rw  r  r   typer  )
spotV1PublicGetExchangeInfo	safe_listranger  safe_stringsafe_currency_codenetwork_id_to_code	safe_boolsafe_numbersafe_currency_structure)r  r  r  resultr  icurrencyr1   r2   r  networkDetailsrw  jentry	networkIdr  s                   r  fetch_currencieszbitrue.fetch_currencies  s    33F;^ x"5q#e*% .	AQxH!!(F3B##Hm<D**2.D!^^HmRHNH1c.12 &q) ,,UG<	11)TB!#&#~~e_E $u6F G"++E=A!%"#'#3#3E=#I#'#3#3E=#I%%!	(  77!  $ ##!9 F4L7.	^ r  c                    g }| j                  | j                  dg d      }t        dt        |            D ]  }||   }|dk(  r!|j	                  | j                  |             .|dk(  r!|j	                  | j                  |             T|dk(  r!|j	                  | j                  |             zt        | j                  dz   |z   dz          |}| j                  | j                  |d      d	g       }| j                  |d
      }| j                  |d      }	|}
| j                  |
|      }
| j                  |
|	      }
| j                  d   r| j                          | j                  |
      S )a  
        retrieves data on all markets for bitrue

        https://github.com/Bitrue-exchange/Spot-official-api-docs#exchangeInfo_endpoint
        https://www.bitrue.com/api-docs#current-open-contract
        https://www.bitrue.com/api_docs_includes_file/delivery.html#current-open-contract

        :param dict [params]: extra parameters specific to the exchange api endpoint
        :returns dict[]: an array of objects representing market data
        r|   r   r   r>   r   r  z+ fetchMarkets() self.options fetchMarkets "z " is not a supported market typesymbolsr   r   rt  )
safe_valuer   r  r  appendr  fapiV1PublicGetContractsdapiV1PublicGetContractsr   r1   array_concatload_time_differenceparse_markets)r  r  promisesRawr|   r  
marketTypepromisesspotMarketsfutureMarketsdeliveryMarketsmarketss              r  fetch_marketszbitrue.fetch_markets=  sq    t||^Ebcq#l+, 		OA%aJV#""4#C#CF#KLx'""4#@#@#HIy(""4#@#@#HI#DGG.[$[^h$h  lN  %N  O  O		O oodooh&BIrR!4//(A6##G];##G_=B <<12%%'!!'**r  r  c                    | j                  |d      }| j                  |d      }| j                  |d      }d }d }d }|d}nd}|dk(  }|dk(  }|dk7  }| j                  |d      }	| j                  |d      }
d }d }|rM|j                  d	      }| j                  |d      }	| j                  |d
      }
|r|
}n|	}| j	                  |      }| j	                  |	      }| j	                  |
      }|dz   |z   }||d|z   z  }| j                  |dg       }| j                  |d      }| j                  |d      }| j                  |di       }| j                  |di       }| j                  |d      }| j                  |d      }| j                  |d|      }| j                  |d|      }| j                  |d      }| j                  |d      }|| j                  |d      }| j                  |d      }|| j                  |d      }i d|d|d|d|d|d|d |	d!|
d"|d#|d|dk(  d$d%d|d&d%d'd%d(|d)k(  d*|||| j                  t        j                  |            d d d d | j                  | j                  |            | j                  | j                  |            d+d d d,| j                  |d-      |d,| j                  |d.      | j                  |d/      d,|d d,d0d |d1S )2Nsymbolsider>   r@   r   r   	baseAsset
quoteAsset-r   /:filters
filterTyper  PRICE_FILTERLOT_SIZEpricePrecisionquantityPrecision
priceScalevolumeScale
multipliermaxQtymaxValidOrderminValminOrderMoneyr1   lowercaseIdr   r   settlebaseIdquoteIdsettleIdr  r?   FrA   rB   r  TRADINGrk  )amountpricer  minQtyminPricemaxPrice)r  r  r  r   )r   r  contractSizeexpiryexpiryDatetimestrike
optionTyper  r  createdr  )r  safe_string_lowerr  splitr  r  index_by	safe_dictr  r  r,   
string_absparse_precision)r  r  r1   r  r  r  isLinear	isInverse
isContractr  r  r  r  symbolSplitr   r   r  r  filtersByTyper  priceFilteramountFilterdefaultPricePrecisiondefaultAmountPrecisionr  amountPrecisionr  maxQuantityminCosts                                r  parse_marketzbitrue.parse_market  s   fh/,,VX>  0	<DD	HIfn
!!&+6""6<8((3-K%%k15F&&{A6G"!,,X6F&&v.''0e#cFl"F..B7g|<!!&(3nn]NBG~~mZD $ 0 09I J!%!1!1&:M!N))+|EZ[**<H^_%%fl;
&&|X>**6?CK""<:?&&v?G1
"1
;1
 f1
 D	1

 U1
 f1
 f1
 w1
 1
 D1
 TV^1
 e1
 J1
 e1
 e1
  v*!1
" 
#1
$   --g.@.@.LM"++D,@,@,QR**4+?+?+OP  
  ++L(C&
  ++KD++KD
 #$ a1
 1	
r  c                    d|i}| j                  |d      }| j                  |ddg       }t        dt        |            D ]l  }||   }| j	                  |dd      }| j                  |      }| j                         }	| j	                  |dd	      |	d<   | j	                  |d
d      |	d<   |	||<   n ||d<   | j                  |      |d<   | j                  |      S )Nr  
updateTimebalancesr   r   asset
marginCoinfreeaccountNormallockedaccountLockused	timestampdatetime)	r  safe_value_2r  r  safe_string_2r  r   iso8601safe_balance)
r  r  r  r>  r6  r  balance
currencyIdr  r   s
             r  parse_balancezbitrue.parse_balance  s    ` H
 %%h=	$$Xz9bIq#h-( 	#AqkG++GWlKJ**:6DllnG"00&/RGFO"00(MRGFO"F4L	# ({!\\)4z  ((r  c                 ~   | j                          d}| j                  dd|      \  }}d}| j                  dd|      \  }}d}d}|dk(  rQ|*|dk(  r%| j                  |      }| j	                  |di       }n8| j                  |      }| j	                  |di       }n| j                  |      }|}| j                  |      S )a  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://github.com/Bitrue-exchange/Spot-official-api-docs#account-information-user_data
        https://www.bitrue.com/api-docs#account-information-v2-user_data-hmac-sha256
        https://www.bitrue.com/api_docs_includes_file/delivery.html#account-information-v2-user_data-hmac-sha256

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: 'future', 'delivery', 'spot', 'swap'
        :param str [params.subType]: 'linear', 'inverse'
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        NrU   r@   r  data)load_marketshandle_market_type_and_paramshandle_sub_type_and_paramsdapiV2PrivateGetAccountr$  fapiV2PrivateGetAccountspotV1PrivateGetAccountrF  )r  r  r  subTyper  r  s         r  fetch_balancezbitrue.fetch_balanceB  s     	99.$PVWf99.$PVW6>"w)';77?&"=@  77?&"=@ 33F;HF$ !!&))r  Nr  r  c                 :   | j                          | j                  |      }d}|d   rcd|d   i}||dkD  rd}||d<   |d   r"| j                  | j                  ||            }n{|d   rv| j	                  | j                  ||            }nT|d	   r7d
|d   i}||dkD  rd}||d<   | j                  | j                  ||            }nt        | j                  dz         | j                  |dd      }| j                  |||      }| j                  |d      |d<   |S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://github.com/Bitrue-exchange/Spot-official-api-docs#order-book
        https://www.bitrue.com/api-docs#order-book
        https://www.bitrue.com/api_docs_includes_file/delivery.html#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@   contractNamer1   r   r  r   r  r>   r  r7   z0 fetchOrderBook only support spot & swap marketsr   lastUpdateIdr  )rI  r  fapiV1PublicGetDepthextenddapiV1PublicGetDepthspotV1PublicGetDepthr$   r1   safe_integer_2parse_order_bookr  )	r  r  r  r  r  r  requestr>  	orderbooks	            r  fetch_order_bookzbitrue.fetch_order_book  sJ    	V$&>tG  3;E#( h44T[[&5QR	"44T[[&5QRF^&,G  4< E#( 00Wf1MNHtww)[[\\4 ''&.I	))(FIF	!..xH	'r  r   c           	         | j                  d |      }| j                  |dd      }| j                  |d      }d }|d   r't        j                  | j                  |d      d      }n| j                  |d      }| j                  i d|d	|d
| j                  |      d| j                  |dd      d| j                  |dd      d| j                  |dd      d| j                  |d      d| j                  |dd      d| j                  |d      d| j                  |d      d| j                  |d      d|d|dd d| j                  |d       d!|d"d | j                  |d#d$      | j                  |d%      |d&|      S )'N	lastPricelastr   r@   rose100priceChangePercentr  r>  r?  high	highPricelowlowPricebidbidPricebuy	bidVolumebidQtyaskaskPricesell	askVolumeaskQtyvwapweightedAvgPriceopen	openPriceclosepreviousClosechangepriceChanger   averagevolumevolquoteVolume)
baseVolumer|  r  )safe_symbolrA  r  r,   
string_mulr  safe_tickerrB  )r  r   r  r  r_  r>  r   s          r  parse_tickerzbitrue.parse_ticker  s   H !!$/!!&+v>%%ff5	
&> ++D,<,<VV,LeTJ))&2FGJ !
f!
!
 Y/!
 D&&v{FC	!

 4%%fj%@!
 4%%fj%@!
 ))&(;!
 4%%fj&A!
 ))&(;!
 D$$V-?@!
 D$$V[9!
 T!
 D!
 T!
 d&&v}=!
  *!!
" t#!
$ ,,VXuE++FMB)!
* + 	r  c                    | j                          | j                  |      }d}d}|d   rWd|d   i}|d   r"| j                  | j                  ||            }n&|d   r!| j	                  | j                  ||            }|}nY|d   r<d|d   i}| j                  | j                  ||            }| j                  |d	i       }nt        | j                  d
z         | j                  ||      S )ar  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://github.com/Bitrue-exchange/Spot-official-api-docs#24hr-ticker-price-change-statistics
        https://www.bitrue.com/api-docs#ticker
        https://www.bitrue.com/api_docs_includes_file/delivery.html#ticker

        :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>`
        Nr@   rR  r1   r   r  r>   r  r   z- fetchTicker only support spot & swap markets)
rI  r  fapiV1PublicGetTickerrU  dapiV1PublicGetTickerspotV1PublicGetTicker24hrr$  r$   r1   r  r  r  r  r  r  rH  rZ  s          r  fetch_tickerzbitrue.fetch_ticker7  s     	V$&>tG h55dkk'66RS	"55dkk'66RSDF^&,G 55dkk'66RSH>>(Ar2Dtww)XXYYN   v..r  r   sincec                     | j                          | j                  |      }| j                  | j                  di       }d}d}	|d   r| j                  |di       }
|d   | j	                  |
|d      d}|||d<   |d	   r"| j                  | j                  ||            }n&|d
   r!| j                  | j                  ||            }|}	n|d   r| j                  |di       }|d   | j	                  ||d      d}|||d<   | j                  |d      }|| j                  |d      }||d<   | j                  | j                  ||            }| j                  |dg       }	nt        | j                  dz         | j                  |	||||      S )aT  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://www.bitrue.com/api_docs_includes_file/spot/index.html#kline-data
        https://www.bitrue.com/api_docs_includes_file/futures/index.html#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
        :param int [params.until]: the latest time in ms to fetch transfers for
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r   Nr@   rA   r1   rb  )rR  intervalr  r   r  r>   r   )r  scaleuntilfromIdxrH  z, fetchOHLCV only support spot & swap markets)rI  r  r$  r   r  fapiV1PublicGetKlinesrU  dapiV1PublicGetKlinesr  omitspotV1PublicGetMarketKliner  r$   r1   parse_ohlcvs)r  r  	timeframer  r  r  r  r   r  rH  timeframesFuturerZ  timeframesSpotr  s                 r  fetch_ohlcvzbitrue.fetch_ohlcv  s    	V$^^DLL,C
&>#~~j(BG &t ,,-=y&QG
  #( h55dkk'66RS	"55dkk'66RSDF^!^^JCN ,)).)TJG
  #( %%fg6E 673%*	"66t{{7F7STH>>(FB7Dtww)WWXXB   vy%GGr  c           
         | j                  |d      }|| j                  |d      }|| j                  |dd      | j                  |dd      | j                  |dd      | j                  |d	d
      | j                  |dd      gS )Nr  idxors  hrc  lre  cru  vr{  )safe_timestampr  safe_number_2)r  ohlcvr  r>  s       r  parse_ohlcvzbitrue.parse_ohlcv  s    2 ''s3	))%7Iuc62uc62uc51uc73uc51
 	
r  r  c                 
   | j                          | j                  |dd      }| j                  |d      }| j                  |      }d}|d   rUd|d   i}|d   r"| j	                  | j                  ||            }nm|d   rh| j                  | j                  ||            }nF|d	   r)d
|d   i}| j                  | j                  ||            }nt        | j                  dz         i }|||d   <   | j                  ||      S )ap  
        fetches the bid and ask price and volume for multiple markets

        https://github.com/Bitrue-exchange/Spot-official-api-docs#symbol-order-book-ticker
        https://www.bitrue.com/api-docs#ticker
        https://www.bitrue.com/api_docs_includes_file/delivery.html#ticker

        :param str[]|None 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>`
        NFr   r@   rR  r1   r   r  r>   r  z/ fetchBidsAsks only support spot & swap markets)rI  market_symbolsr  r  r  rU  r  spotV1PublicGetTickerBookTickerr$   r1   parse_tickers)r  r  r  firstr  r  rZ  rH  s           r  fetch_bids_askszbitrue.fetch_bids_asks  s    	%%gtU;  !,U#&>tG h55dkk'66RS	"55dkk'66RSF^&,G ;;DKKQW<XYHtww)ZZ[[2 %VD\!!$00r  c                    | j                          | j                  |      }d}d}i }d}|| j                  |d      }| j                  |      }|d   rt	        | j
                  dz         |d   r$| j                  | j                  ||            }|}nnt	        | j
                  dz         | j                  dd|      \  }}|dk7  rt	        | j
                  dz         | j                  | j                  ||            }|}i }	t        dt        |            D ]>  }
| j                  ||
i       }| j                  | j                  |d	            }||	|d
   <   @ | j                  |	|      S )a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://github.com/Bitrue-exchange/Spot-official-api-docs#24hr-ticker-price-change-statistics
        https://www.bitrue.com/api-docs#ticker
        https://www.bitrue.com/api_docs_includes_file/delivery.html#ticker

        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   r@   zK fetchTickers does not support swap markets, please use fetchTicker insteadr>   z. fetchTickers only support spot & swap marketsr   z; fetchTickers only support spot when symbols are not provedr  r1   )rI  r  r  r  r$   r1   r  rU  rJ  r  r  r$  safe_marketr  )r  r  r  r  rH  rZ  r  r  r  tickersr  r   s               r  fetch_tickerszbitrue.fetch_tickers6  s{    	%%g.$$Wa0E[['Ff~"477-z#z{{99$++gv:VW"477-]#]^^==ndTZ[LD&v~"477-j#jkk55dkk'66RSHDT q#d)$ 	+A^^D!R0F%%d&6&6vx&HIF$*GF4L!	+ !!'733r  tradec                 |   | j                  |dd      }| j                  |d      }| j                  |d      }| j                  |dd      }| j                  ||      }| j                  |d      }| j                  |dd	      }	d }
| j	                  |d
      }| j	                  |d      }||rdnd}
||rdnd}
d }d|v r5| j                  |dd      | j                  | j                  |d            d}d }| j	                  |d      }||rdnd}| j                  ||| j                  |      ||	|d |
|||d |d|      S )Nctimer   r  qtyr  rR  orderIdr1   tradeIdisBuyerMakerisBuyerrn  ri  
commissionr  commissionAssert)r   r  isMakerr   r   )r  r>  r?  r  r1   r   r  r  takerOrMakerr  r  r   r  )rX  r  rA  r~  r  r  
safe_traderB  )r  r  r  r>  priceStringamountStringmarketIdr  r  r1   r  
buyerMakerr  r  r  r  s                   r  parse_tradezbitrue.parse_trade  s   b ''w?	&&ug6''u5%%eX~F!!(F3""5)4tY7^^E>:
..	2!'6UD#5D5 **5,F 33D4D4DUL^4_`C ..	2&-77L"Y/( " 
  	r  c                 
   | j                          | j                  |      }d}|d   r0d|d   i}|||d<   | j                  | j                  ||            }nt	        | j
                  dz         | j                  ||||      S )a4  
        get the list of most recent trades for a particular symbol

        https://github.com/Bitrue-exchange/Spot-official-api-docs#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 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>`
        Nr>   r  r1   r  z& fetchTrades only support spot markets)rI  r  spotV1PublicGetTradesrU  r$   r1   parse_trades)r  r  r  r  r  r  r  rZ  s           r  fetch_tradeszbitrue.fetch_trades  s     	V$&>&,G  #( 11$++gv2NOHtww)QQRR   65%@@r  r  c           
      @    dddddddddd	}| j                  |||      S )Nrs  closedcanceled	cancelingrejectedexpired)	INITPENDING_CREATENEWPARTIALLY_FILLEDFILLEDCANCELEDPENDING_CANCELREJECTEDEXPIRED)r  )r  r  statusess      r  parse_order_statuszbitrue.parse_order_status
  s;    $ &")" 

 &&99r  r   c                 T   | j                  | j                  |dd            }| j                  |d      }| j                  ||      }| j                  |d      }d }d }d|v r| j	                  |d      }n[d|v r| j	                  |d      }nDd|v r@|dk(  r;t        j                  |d	      r| j	                  |d      }n| j	                  |d      }| j                  |d
      }	| j                  |d      }
| j                  |d      }| j                  |dd      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |dg       }| j                  |d      }| j                  |d      }|dk(  xs |dk(  xs |dk(  }|dk(  rd}| j                  | j                  | j                  |d                  }| j                  i d|d|d|d|d| j                  |      d|d|d|d|d|d|d|
d |d!|d"|d#|	d$|d |d |d%|      S )&Nr  orderStatusr  executedQtyr   transactTimer5  rs  r   avgPricer  origQtycummulativeQuoteQtycumQuoter  r  r  fillsclientOrderIdr  limit_makerGTX	post_onlyr  	stopPricer  r1   r>  r?  lastTradeTimestamppostOnlyr  r  r   ry  filled)	remainingr  r  r   )r  rA  r  r~  r  r,   	string_gtr!  r  r  	omit_zero
safe_orderrB  )r  r   r  r  r  r  r  r>  r  ry  r  r  r   r1   r  r  r  r  r  r  r  s                        r  parse_orderzbitrue.parse_order  s   n ((););E8])[\##E84!!(F3!!%7	!U?))%8Iu$))%@IU"$$VS1)-):):5,)O& $ 1 1% FI""5*5  0!!%3 !!%)>
KeY/%%eV4%%eV4ugr2((@&&um<M)]{e/C]Q\I\= D((8H8HP[8\)]^  
E 
" 
 ] 
 	 

 Y/ 
 !"4 
 f 
 D 
 ; 
  
 D 
 U 
 L 
 f 
 D 
  w! 
" f# 
$ + 
, - 	r  r   c                     | j                          | j                  |      }|d   st        | j                  dz         d|d<   | j	                  |dd|d|      S )aD  
        create a market buy order by providing the symbol and cost

        https://www.bitrue.com/api-docs#new-order-trade-hmac-sha256
        https://www.bitrue.com/api_docs_includes_file/delivery.html#new-order-trade-hmac-sha256

        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r@   z9 createMarketBuyOrderWithCost() supports swap orders onlyFrn  r  ri  N)rI  r  r$   r1   create_order)r  r  r   r  r  s        r  !create_market_buy_order_with_costz(bitrue.create_market_buy_order_with_cost  s`     	V$f~tww)ddee6;23  5$fMMr  r  r  r  r  c                 N   | j                          | j                  |      }d}d}	|j                         }
|j                         |
d}|
dk(  r/|t        | j                  dz         | j                  ||      |d<   |d   r |
dk(  }| j                  |d      }| j                  |d|      }|rd	|d
<   n|dk(  rd|d
<   n
|dk(  rd|d
<   |d   |d<   d}| j                  |ddd      \  }}|r|dk(  r|r| j                  |d      }| j                  |d      }||t        | j                  dz         | j                  |      }| j                  |      }t        j                  ||      }||n|}| j                  ||      |d<   | j                  ||      |d<   n(| j                  |      |d<   | j                  |      |d<   d|d<   | j!                  |dd      }|rdnd|d<   | j                  |d d!      }| j                  |      |d <   | j                  |g d"      }|d#   r"| j#                  | j%                  ||            }n&|d$   r!| j'                  | j%                  ||            }| j)                  |d%i       }	n|d&   r|d   |d'<   | j+                  ||      |d(<   | j-                  |d)   d*      }| j/                  |
|      s!t        | j                  d+z   |z   d,z   |z         | j1                  |d-d.      }|| j                  |d-d.g      }||d-<   | j!                  |d/d0      }|)| j                  |d/d0g      }| j                  ||      |d0<   | j3                  | j%                  ||            }|}	nt5        | j                  d1z         | j7                  |	|      S )2a(  
        create a trade order

        https://www.bitrue.com/api_docs_includes_file/spot/index.html#new-order-trade
        https://www.bitrue.com/api_docs_includes_file/futures/index.html#new-order-trade-hmac-sha256

        :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
        :param float [params.triggerPrice]: *spot only* the price at which a trigger order is triggered at
        :param str [params.clientOrderId]: a unique id for the order, automatically generated if not sent
        :param decimal [params.leverage]: in future order, the leverage value of the order should consistent with the user contract configuration, default is 1
        :param str [params.timeInForce]: 'fok', 'ioc' or 'po'
        :param bool [params.postOnly]: default False
        :param bool [params.reduceOnly]: default False
 EXCHANGE SPECIFIC PARAMETERS
        :param decimal [params.icebergQty]:
        :param long [params.recvWindow]:
        :param float [params.cost]: *swap market buy only* the quote quantity that can be used alternative for the amount
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        N)r  r  LIMITz( createOrder() requires a price argumentr  r@   MARKETr  	POST_ONLYr  fokr  iocr~  r1   rR  TrN   rn  ri  r   a   createOrder() requires the price argument with swap market buy orders to calculate total order cost(amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options["createMarketBuyOrderRequiresPrice"] = False to supply the cost in the amount argument(the exchange-specific behaviour)r  rz  r   positionType
reduceOnlyreduce_onlyCLOSEOPENrs  r  1)r  r  r  r  r   r  rH  r>   r  quantityr  
orderTypes z% is not a valid order type in market newClientOrderIdr  r  r  z- createOrder only support spot & swap markets)rI  r  upperr!   r1   price_to_precisionr!  is_post_onlyhandle_option_and_paramsr  r  number_to_stringr,   r  cost_to_precisionparse_to_numericr@  fapiV2PrivatePostOrderrU  dapiV2PrivatePostOrderr$  amount_to_precisionr  in_arrayrA  spotV1PrivatePostOrderr$   r  )r  r  r  r  r  r  r  r  r  rH  uppercaseTyperZ  isMarketr  r  rn  r   r  r  quoteAmountrequestAmountr  r  validOrderTypesr  r  s                             r  r  zbitrue.create_order  s   2 	V$

JJL!
 G#}"477-W#WXX#66vuEGG&>$0H00GK((4@H"-%"'%"'&,TlGN#04-8<8U8UV\^k  nQ  SW  9X5-vTU]0Q''7662=T\&tww  2R  (R  S  S#'#8#8#@L"&"7"7">K")"4"4\;"OK-1-=DKM(,(>(>v}(UGH%(,(>(>v}(UGH%$($9$9&$A!$($9$9&$A!&'GN#**6<OJ)3gGFO''
C@H"&"7"7"AGJYYv'_`Fh66t{{7F7ST	"66t{{7F7ST>>(FB7DF^ &tGH"&":":66"JGJ"oofVnlKO==@"477S=4#7:a#adj#jkk ..v7I?[M(6,>+PQ.;*+,,V^[QL'6NK+HI'+'>'>v|'T$224;;w3OPHDtww)XXYY, f--r  r1   c                    |t        | j                  dz         | j                          | j                  |      }| j	                  |dd      }| j                  |ddg      }d}d}i }|||d<   n|d   r||d<   n||d<   |d   ri|d   |d<   |d	   r"| j                  | j                  ||            }n&|d
   r!| j                  | j                  ||            }| j                  |di       }nN|d   r1||d<   |d   |d<   | j                  | j                  ||            }|}nt        | j                  dz         | j                  ||      S )a,  
        fetches information on an order made by the user

        https://www.bitrue.com/api_docs_includes_file/spot/index.html#query-order-user_data
        https://www.bitrue.com/api_docs_includes_file/futures/index.html#query-order-user_data-hmac-sha256

        :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 argumentorigClientOrderIdr  r  r@   r1   rR  r   r  rH  r>   r  z, fetchOrder only support spot & swap markets)r   r1   rI  r  r@  r  fapiV2PrivateGetOrderrU  dapiV2PrivateGetOrderr$  spotV1PrivateGetOrderr$   r  	r  r1   r  r  r  r  r  rH  rZ  s	            r  fetch_orderzbitrue.fetch_order  sv    >#DGG.X$XYYV$ --f6I?[6$7#IJ$!#GIf~+<(/@+,&>&,TlGN#h55dkk'66RS	"55dkk'66RS>>(FB7DF^!#GI &tGH11$++gv2NOHDtww)WWXXX f--r  c                 F   |t        | j                  dz         | j                          | j                  |      }|d   st	        | j                  dz         d|d   i}|||d<   |||d<   | j                  | j                  ||            }| j                  ||||      S )aQ  
        fetches information on multiple closed orders made by the user

        https://www.bitrue.com/api_docs_includes_file/spot/index.html#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>`
        z/ fetchClosedOrders() requires a symbol argumentr>   z, fetchClosedOrders only support spot marketsr  r1   	startTimer  )r   r1   rI  r  r$   spotV1PrivateGetAllOrdersrU  parse_orders)r  r  r  r  r  r  rZ  r  s           r  fetch_closed_orderszbitrue.fetch_closed_ordersm  s     >#DGG._$_``V$f~tww)WWXXfTl
 #(GK $GG11$++gv2NO.   65%@@r  c                    |t        | j                  dz         | j                          | j                  |      }d}d}i }|d   ri|d   |d<   |d   r"| j	                  | j                  ||            }n&|d   r!| j                  | j                  ||            }| j                  |dg       }nI|d	   r,|d   |d
<   | j                  | j                  ||            }|}nt        | j                  dz         | j                  ||||      S )a  
        fetch all unfilled currently open orders

        https://www.bitrue.com/api_docs_includes_file/spot/index.html#current-open-orders-user_data
        https://www.bitrue.com/api_docs_includes_file/futures/index.html#cancel-all-open-orders-trade-hmac-sha256

        :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 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>`
        Nz- fetchOpenOrders() requires a symbol argumentr@   r1   rR  r   r  rH  r>   r  z1 fetchOpenOrders only support spot & swap markets)r   r1   rI  r  fapiV2PrivateGetOpenOrdersrU  dapiV2PrivateGetOpenOrdersr  spotV1PrivateGetOpenOrdersr$   r  	r  r  r  r  r  r  r  rH  rZ  s	            r  fetch_open_orderszbitrue.fetch_open_orders  s    >#DGG.]$]^^V$&>&,TlGN#h::4;;wPV;WX	"::4;;wPV;WX>>(FB7DF^ &tGH66t{{7F7STHDtww)\\]]^   vue<<r  c                    |t        | j                  dz         | j                          | j                  |      }| j	                  |dd      }| j                  |ddg      }d}d}i }|||d<   n|d   r||d<   n||d<   |d   ri|d   |d<   |d	   r"| j                  | j                  ||            }n&|d
   r!| j                  | j                  ||            }| j                  |di       }nI|d   r,|d   |d<   | j                  | j                  ||            }|}nt        | j                  dz         | j                  ||      S )aE  
        cancels an open order

        https://github.com/Bitrue-exchange/Spot-official-api-docs#cancel-order-trade
        https://www.bitrue.com/api-docs#cancel-order-trade-hmac-sha256
        https://www.bitrue.com/api_docs_includes_file/delivery.html#cancel-order-trade-hmac-sha256

        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz) cancelOrder() requires a symbol argumentr  r  r  r@   r1   rR  r   r  rH  r>   r  z- cancelOrder only support spot & swap markets)r   r1   rI  r  r@  r  fapiV2PrivatePostCancelrU  dapiV2PrivatePostCancelr$  spotV1PrivateDeleteOrderr$   r  r  s	            r  cancel_orderzbitrue.cancel_order  sk    >#DGG.Y$YZZV$ --f6I?[6$7#IJ$!#GIf~+<(/@+,&>&,TlGN#h77GV8TU	"77GV8TU>>(FB7DF^ &tGH44T[[&5QRHDtww)XXYY* f--r  c                 z   | j                          | j                  |      }d}d}|d   rhd|d   i}|d   r"| j                  | j                  ||            }n&|d   r!| j	                  | j                  ||            }| j                  |dg       }nt        | j                  dz         | j                  ||      S )	ad  
        cancel all open orders in a market

        https://www.bitrue.com/api-docs#cancel-all-open-orders-trade-hmac-sha256
        https://www.bitrue.com/api_docs_includes_file/delivery.html#cancel-all-open-orders-trade-hmac-sha256

        :param str symbol: unified market symbol of the market to cancel orders in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
        :returns dict[]: a list of `order structures <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
        Nr@   rR  r1   r   r  rH  z, cancelAllOrders only support future markets)	rI  r  fapiV2PrivatePostAllOpenOrdersrU  dapiV2PrivatePostAllOpenOrdersr  r$   r1   r  r  s          r  cancel_all_orderszbitrue.cancel_all_orders4	  s     	V$&>tG h>>t{{7TZ?[\	">>t{{7TZ?[\>>(FB7Dtww)WWXX   v..r  c                 D   | j                          |t        | j                  dz         | j                  |      }d}d}i }|||d<   ||dkD  rd}||d<   |d   ri|d   |d<   |d	   r"| j	                  | j                  ||            }n&|d
   r!| j                  | j                  ||            }| j                  |dg       }nI|d   r,|d   |d<   | j                  | j                  ||            }|}nt        | j                  dz         | j                  ||||      S )a  
        fetch all trades made by the user

        https://www.bitrue.com/api_docs_includes_file/spot/index.html#account-trade-list-user_data
        https://www.bitrue.com/api_docs_includes_file/futures/index.html#account-trade-list-user_data-hmac-sha256

        :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>`
        Nz+ fetchMyTrades() requires a symbol argumentr  r7   r  r@   r1   rR  r   r  rH  r>   r  z/ fetchMyTrades only support spot & swap markets)rI  r   r1   r  fapiV2PrivateGetMyTradesrU  dapiV2PrivateGetMyTradesr  spotV2PrivateGetMyTradesr$   r  r  s	            r  fetch_my_tradeszbitrue.fetch_my_tradesZ	  sD    	>#DGG.[$[\\V$#(GK t|$GG&>&,TlGN#h88Wf9UV	"88Wf9UV>>(FB7DF^ &tGH44T[[&5QRHDtww)ZZ[[\   vue<<r  r  c                 4   |t        | j                  dz         | j                          | j                  |      }|d   dd}|||d<   |||d<   | j	                  | j                  ||            }| j                  |dg       }| j                  ||||      S )a*  
        fetch all deposits made to an account

        https://github.com/Bitrue-exchange/Spot-official-api-docs#deposit-history--withdraw_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 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>`
        z) fetchDeposits() requires a code argumentr1   r   r  r  r  r  rH  )r   r1   rI  r  spotV1PrivateGetDepositHistoryrU  r  parse_transactions	r  r  r  r  r  r  rZ  r  rH  s	            r  fetch_depositszbitrue.fetch_deposits	  s     <#DGG.Y$YZZ==&TN
 #(GK $GG66t{{7F7STJ ~~h3&&tXueDDr  c                 0   |t        | j                  dz         | j                          | j                  |      }|d   dd}|||d<   |||d<   | j	                  | j                  ||            }| j                  |dg       }| j                  ||      S )a6  
        fetch all withdrawals made from an account

        https://github.com/Bitrue-exchange/Spot-official-api-docs#withdraw-history--withdraw_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 withdrawals structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        z, fetchWithdrawals() requires a code argumentr1   r   r.  r  r  rH  )r   r1   rI  r  spotV1PrivateGetWithdrawHistoryrU  r  r0  r1  s	            r  fetch_withdrawalszbitrue.fetch_withdrawals	  s     <#DGG.\$\]]==&TN
 #(GK $GG77GV8TU0 ~~h3&&tX66r  c                 f    dddddddd}| j                  ||i       }| j                  |||      S )Npendingr  )r   r  r  )r   56)r  
withdrawal)r$  r  )r  r  r  statusesByTyper  s        r   parse_transaction_status_by_typez'bitrue.parse_transaction_status_by_type-
  sO     
 
 
 >>.$;&&99r  transactionr  c                    | j                  |dd      }| j                  |d      }| j                  |d      }| j                  |d      }d }d }|n|5|j                  d      }	| j                  |	d      }| j                  |	d      }|5|j                  d      }	| j                  |	d      }| j                  |	d      }| j                  |d	      }
| j                  |d
      }| j                  |d      }d|v }d|v }|s|rdnd}| j	                  | j                  |d      |      }| j                  |d      }d }| j                  |dd      }|G|j                  d      }	| j                  |	d      }| j                  |	d      }||j                         }| j                  ||      }| j                  |d      }d }|||d}i d|d|d	|
d|d| j                  |      d|d|d|d|d|d|d|d|d|d|d|d |d!d |d"S )#Nr1   
withdrawIdtagType	addressToaddressFrom_r   r   txid	createdAt	updatedAt	payAmountr  r:  r  r  r  r  r  r  )r  r   r  r>  r?  r  addresstagtagTotagFromr  r  r  F)internalcommentr  )	rA  r  r"  r  r<  r  r  r  rB  )r  r=  r  r1   r@  rA  rB  rJ  rK  partsrD  r>  r  rG  r  r  r  r  r  rE  r  r  feeCostr  s                           r  parse_transactionzbitrue.parse_transaction<
  s   z T<@"";	:$$[+>	&&{MB$!, ,,UA6	((2&#))#."..ua8**5!4V4%%k;?	##K= K/	K' )U|66t7G7GU]7^`de!!+x8''XvF
!$$S)E))%3J((2I$#//+&&z8<"";6#W5C
K
"
 D
 	

 Y/
 w
 y
 
 ;
 5
 U
 w
 D
 f
 
  f!
" w#
$ )
 	
r  rH  c                    | j                  ||      \  }}| j                  |       | j                          | j                  |      }|d   ||d}d}| j	                  |      \  }}|| j                  |      |d<   |||d<   | j                  | j                  ||            }	| j                  |	di       }
| j                  |
|      S )a  
        make a withdrawal

        https://github.com/Bitrue-exchange/Spot-official-api-docs#withdraw-commit--withdraw_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:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        r1   )r  r  rA  N	chainNamerI  rH  )
handle_withdraw_tag_and_paramscheck_addressrI  r  handle_network_code_and_paramsnetwork_code_to_idspotV1PrivatePostWithdrawCommitrU  r$  rP  )r  r  r  rH  rI  r  r  rZ  networkCoder  rH  s              r  r   zbitrue.withdraw
  s     99#vFV7#==&TN 
 "AA&IV"#'#:#:;#GGK ? GEN77GV8TU  ~~h3%%dH55r  c                    | j                  |dg       }t        |      }|d d dd d di d}|dk7  rt        d|      D ]  }||   }| j                  |d      }| j                  |d      }	| j	                  ||	      }
d d d| j                  |d      ddd	|d
   |
<   |dk(  se| j                  |d      |d   d<   d|d   d<    |S )Nr  )r  r   )r  r   r  rw  r   r  r  r  F)r  r   rw  r   r   r  r   )r  r  r  r  r  r  )r  r  r  chainDetailschainDetailLengthr  r  r  r  currencyCoderX  s              r  parse_deposit_withdraw_feez!bitrue.parse_deposit_withdraw_fee
  s    ~~c="=-"
 " 
 !1/0 =*1o ,,['B	#//&A"55iN'+4@(,(8(8m(Tdi j3z";/ %)040@0@m0\F:&u-7<F:&|4= r  codesc                     | j                          | j                  |      }| j                  |d      }| j                  ||d      S )a~  
        fetch deposit and withdraw fees

        https://github.com/Bitrue-exchange/Spot-official-api-docs#exchangeInfo_endpoint

        :param str[]|None codes: list of unified currency codes
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
        r  r  )rI  r  r  parse_deposit_withdraw_fees)r  r^  r  r  r  s        r  fetch_deposit_withdraw_feesz"bitrue.fetch_deposit_withdraw_fees  sE     	33F;x1//ufEEr  c           
      6   | j                  |d      }d }d }|5|j                  d      }| j                  |d      }| j                  |d      }| j                  |d      }|d || j                  |      | j                  |d      | j	                  |d      ||dd		S )
NtransferType_to_r   r   r  r  r  r  )	r  r1   r>  r?  r  r  fromAccount	toAccountr  )r  r"  r  rB  r  )r  r   r  rc  re  rf  accountSplitr>  s           r  parse_transferzbitrue.parse_transfer  s      ''.A	#'--f5L**<;K((q9I%%h8	"Y/((6:&&x:&"

 
	
r  c                    | j                          | j                  |dd      }d|i}d}|| j                  |      }|d   |d<   |||d<   ||dkD  rd}||d<   | j                  |d	      }|| j	                  |d	      }||d
<   | j                  | j                  ||            }	| j                  |	dg       }
| j                  |
|||      S )a  
        fetch a history of internal transfers made on an account

        https://www.bitrue.com/api-docs#get-future-account-transfer-history-list-user_data-hmac-sha256
        https://www.bitrue.com/api_docs_includes_file/delivery.html#get-future-account-transfer-history-list-user_data-hmac-sha256

        :param str code: unified currency code of the currency transferred
        :param int [since]: the earliest time in ms to fetch transfers for
        :param int [limit]: the maximum number of transfers 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 transfers for
        :param str [params.type]: transfer type wallet_to_contract or contract_to_wallet
        :returns dict[]: a list of `transfer structures <https://github.com/ccxt/ccxt/wiki/Manual#transfer-structure>`
        r  rc  Nr1   
coinSymbol	beginTime   r  r  endTimerH  )	rI  rA  r  r  r  &fapiV2PrivateGetFuturesTransferHistoryrU  r  parse_transfers)r  r  r  r  r  r  rZ  r  r  r  rH  s              r  fetch_transferszbitrue.fetch_transfers@  s     	!!&&.AD
 }}T*H$,TNGL!#(GK s{$GG!!&'2YYvw/F!&GI>>t{{7TZ?[\ ~~h3##D(E5AAr  re  rf  c                    | j                          | j                  |      }| j                  | j                  di       }| j	                  |||      }| j	                  |||      }	|d   | j                  ||      |dz   |	z   d}
| j                  | j                  |
|            }| j                  |di       }| j                  ||      S )a  
        transfer currency internally between wallets on the same account

        https://www.bitrue.com/api-docs#new-future-account-transfer-user_data-hmac-sha256
        https://www.bitrue.com/api_docs_includes_file/delivery.html#user-commission-rate-user_data-hmac-sha256

        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from
        :param str toAccount: account to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://github.com/ccxt/ccxt/wiki/Manual#transfer-structure>`
        ry  r1   rd  )rj  r  rc  rH  )	rI  r  r$  r   r  currency_to_precision fapiV2PrivatePostFuturesTransferrU  rh  )r  r  r  re  rf  r  r  accountTypesfromIdtoIdrZ  r  rH  s                r  r   zbitrue.transfers  s     	==&~~dll4DbI!!,[IiC"4.00v>"VOd2

 88Wf9UV ~~h3""422r  r  c                    |t        | j                  dz         |dk  s|dkD  rt        | j                  dz         | j                          | j	                  |      }d}|d   |d}|d   st        | j                  d	z         |d
   r#| j                  | j                  ||            }|S |d   r!| j                  | j                  ||            }|S )a  
        set the level of leverage for a market

        https://www.bitrue.com/api-docs#change-initial-leverage-trade-hmac-sha256
        https://www.bitrue.com/api_docs_includes_file/delivery.html#change-initial-leverage-trade-hmac-sha256

        :param float leverage: the rate of leverage
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        Nz) setLeverage() requires a symbol argumentr   }   z% leverage should be between 1 and 125r1   )rR  r  r@   z& setLeverage only support swap marketsr   r  )	r   r1   r   rI  r  r$   fapiV2PrivatePostLevelEditrU  dapiV2PrivatePostLevelEdit)r  r  r  r  r  r  rZ  s          r  set_leveragezbitrue.set_leverage  s     >#DGG.Y$YZZqLhnTWW'NNOOV$"4L 
 f~tww)QQRR(66t{{7F7STH  I66t{{7F7STHr  c                 "    ||d   d dd d d d d d d
S )Nr  isolated)
r  r  r  r  r  totalr  r  r>  r?   )r  rH  r  s      r  parse_margin_modificationz bitrue.parse_margin_modification  s1     X&$
 	
r  c                 n   | j                          | j                  |      }|d   st        | j                  dz         d}|d   | j	                  |      d}|d   r"| j                  | j                  ||            }n&|d   r!| j                  | j                  ||            }| j                  ||      S )a  
        Either adds or reduces margin in an isolated position in order to set the margin to a specific value

        https://www.bitrue.com/api-docs#modify-isolated-position-margin-trade-hmac-sha256
        https://www.bitrue.com/api_docs_includes_file/delivery.html#modify-isolated-position-margin-trade-hmac-sha256

        :param str symbol: unified market symbol of the market to set margin in
        :param float amount: the amount to set the margin to
        :param dict [params]: parameters specific to the exchange API endpoint
        :returns dict: A `margin structure <https://github.com/ccxt/ccxt/wiki/Manual#add-margin-structure>`
        r@   z$ setMargin only support swap marketsNr1   )rR  r  r   r  )	rI  r  r$   r1   r  fapiV2PrivatePostPositionMarginrU  dapiV2PrivatePostPositionMarginr  )r  r  r  r  r  r  rZ  s          r  
set_marginzbitrue.set_margin  s     	V$f~tww)OOPP"4L++F3
 (;;DKKQW<XYHI;;DKKQW<XYH --h??r  r   GETc                    | j                  |d      }| j                  |d      }| j                  |d      }	d }
|dk(  r|dk(  s|dk(  r'|j                  d      dk\  r| j                  d   |   }
n| j                  d   |   dz   |z   }
|
dz   | j                  ||      z   }
| j	                  || j                  |            }|	d	k(  r`| j                          | j                  | j                  d
d      }|dk(  s|dk(  r| j                  | j                  | j                         |d|            }| j                  | j                  |      | j                  | j                        t        j                         }|d|z   z  }d| j"                  i}|dk(  s|dk(  r
|
d|z   z  }
n|}d|d<   nt%        | j                               }d }|dk(  rd}n|dk(  rd}|dz   |z   dz   |z   }||z   |z   }|dk(  rt'        |j)                               }t+        |      }|dkD  r|d| j                  |      z   z  }| j                  | j                  |      | j                  | j                        t        j                         }| j"                  ||d}|
d| j                  |      z   z  }
n| j                  d
|i|      }| j-                  |      }||z  }| j                  | j                  |      | j                  | j                        t        j                         }d| j"                  ||d}n|r|
d| j                  |      z   z  }
|
|||dS )Nr   r   r   r   r   rs  	listenKeyr  r   rr  r  r>   )r>  rr  z&signature=zX-MBX-APIKEYr  DELETE?z!application/x-www-form-urlencodedContent-Typer   z/fapir   z/dapi)X-CH-APIKEY	X-CH-SIGNX-CH-TSzapplication/json)r  r  r  r  )r  methodbodyheaders)r  findr   implode_paramsr  extract_paramscheck_required_credentialsr  r   	urlencoderU  r  hmacencodesecrethashlibsha256apiKeystrr  r  r  json)r  pathr   r  r  r  r  r  r9   accessr  rr  query	signaturer>  signPathsignMessager  r  s                      r  signzbitrue.sign  sL   Q'""3*!!#q)EMg0dfnS^I_cdId))E"4(C))E"4(3.8CCi$--dF;;64#6#6t#<=Y++-**4<<tLJv~t{{!%",4 (  !IIdkk%&8$++dkk:RT[TbTbc	+i77"DKK eO8);3;&C D.QGN+

-	6>&HV^&H#c>G3c9D@'&08;U?.D!$TJ!A~#sT^^F-C'CC $		$++k*BDKKPTP[P[D\^e^l^l mI'+{{%.#,G
 3!777C KK$j)E  99U+D4'K $		$++k*BDKKPTP[P[D\^e^l^l mI(:'+{{%.#,	G sT^^F333fdwOOr  reasonr  r  r  r  c
                    |dk(  s|dk(  r0t        | j                  dz   t        |      z   dz   |z   dz   |z         |dk\  r|j                  d      dk\  rt	        | j                  dz   |z         |j                  d      dk\  rt	        | j                  d	z   |z         |j                  d
      dk\  rt	        | j                  dz   |z         |y | j                  |dd      }
|
s0| j                  |d      }d }|	 t        j                  |      }||}| j                  |d      }|`| j                  | j                  d   || j                  dz   |z          | j                  | j                  d   || j                  dz   |z          | j                  |d      }||dk(  st        j                  |d      ry |dk(  r*| j                  d   rt        | j                  dz   |z         | j                  dz   |z   }| j                  | j                  d   ||       t!        |      |
st!        | j                  dz   |z         y # t        $ r}d }Y d }~Cd }~ww xY w)Ni  i  r  i  zPrice * QTY is zero or lessr   z- order cost = amount * price is zero or less r  z5 order amount should be evenly divisible by lot size r  z order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid float value in general, use self.price_to_precision(symbol, amount) successTmsgr  r  r  200r   r  rp  z temporary banned: )r%   r1   r  r  r!   r  r  r  loads	Exceptionthrow_exactly_matched_exceptionr  throw_broadly_matched_exceptionr,   string_equalsr   r   )r  r  r  r  r  r  r  r  requestHeadersrequestBodyr  messageInnerparsedMessageemessageerrorfeedbacks                    r  handle_errorszbitrue.handle_errors2  s   CKTS[ 3T!:S!@6!IC!ORV!VWW 3;yy671<"477-\#\_c#cddyy$)"477-d#dgk#kllyy(A-"477  .g  $g  jn  $n  o  o ..9d;++He<L M')$(JJ|$<M !,,H""8U3001I7TXT[T[^aTadkTkl001I7TXT[T[^aTadkTkl  62 7#8#8#D  dll3X&Y$TWW/D%Dt%KLLww}t+H001I5RZ[))# 4555 ! )$(M)s   <I 	IIIc                     d|v r	d|vr|d   S d|v r<d|v r8|d   }|d   }t        dt        |            D ]  }||   }	||	d   k  s|	d   c S  | j                  |dd      S )Nr   r  r   r  r   r   r   )r  r  r  )
r  r   r  r  r  configr  r   r  r  s
             r  calculate_rate_limiter_costz"bitrue.calculate_rate_limiter_costf  s    & 8v+=*%%6!6(97OEY'G1c'l+ $
E!H$ 8O$ vvq11r  )N)I__name__
__module____qualname__r   r  r  r  r	   r  r   r  r   r   r  dictr3  r   rF  rP  r  r   r\  r   r  r  r  r  r  r   r  r   r  r   r  r  r   r  r   r  floatr  r   r   r   r  r  r  r  r#  r'  r,  r   r2  r5  r<  r   rP  r   r]  ra  rh  r   rp  r   r{  r
   r  r  r  intr  r  __classcell__)r  s   @r  r.   r.   "   sE   A
# A
FD #% 
4 !# 9s 9" ') fZ fP $& `+$v, `+Da
4 a
F a
F>) >)@ $& k*( k*Z :>b Cs C3 CY CJA4 A A6 AF 02 G/3 G/f G/R 26DW[df SH# SHc SHQT SHkoptku SHj#
 #
4 #
J 26b :1w :1x 04B P4W P47 P4dW Wv W Wr 6:UW 'A3 'As 'A# 'A\`af\g 'AR: :n nv n n` RT N N5 N& gksu y.3 y.i y.y y.RW y.`c y.v 26b U.c U.3 U.n 154VZce 4A# 4AS 4APS 4Ajnotju 4Al /3TXac O= O=3 O=c O=hlmrhs O=b 37r >.s >.C >.@ /32 $/ $/L -1tRV_a T=c T= T=C T=l *.Dt\^ CE3 CEc CE CEcghsct CEJ -1tRV_a 67c 67 67C 67fjkvfw 67p:v
T v
X v
Q\ v
p DHPR 16S 16% 16# 16Wb 16f$ $L <@ F F"
H +/TPT]_ 1BC 1Bs 1B# 1Bdhivdw 1Bf [] !3S !3% !3c !3c !3an !3F 9=R S # >
>P 
. =?  @  @e  @CU  @D &eBSW BPH2# 2s 2 2c 2TX 2`c 2h MO 
2r  r.   )4ccxt.base.exchanger   ccxt.abstract.bitruer   r  r  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#   r$   r%   r&   r'   r(   r)   ccxt.base.decimal_to_precisionr*   r+   ccxt.base.preciser,   r.   r  r  r  <module>r     s    ( ,   P  P  P  P  P  P  * 0 - - . ' & . ) * 5 ) + . 1 * ) 3 4 %N12X{ N12r  