
    E#ir*                       S SK Jr  S SKJr  S SKrS SK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  S SKJr  S SKJr  S SKJr  S SKJ r   S S	KJ!r!  S S
KJ"r"  S SKJ#r#  S SKJ$r$  S SKJ%r%  S SKJ&r&  S SKJ'r'  S SKJ(r(  S SKJ)r)  S SKJ*r*  S SKJ+r+  S SKJ,r,  S SKJ-r-  S SKJ.r.  S SK/J0r0  S SK/J1r1  S SK2J3r3   " S S\\5      r4g)    )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                     ^  \ rS rSrS\4U 4S jjrS r0 4S jr0 4S\4S jjr	0 4S\
4S jjr0 4S\\   4S jjrS	\S\4S
 jrS\4S jr0 4S\4S jjrS0 4S\S\S\4S jjrSRS\S	\S\4S jjr0 4S\S\4S jjrSSS0 4S\S\S\S\S\\   4
S jjrSRS	\S\4S jjrS0 4S\4S jjrS0 4S\S\4S jjr SRS\S	\S\!4S jjr"SS0 4S\S\S\S\\!   4S jjr#S\$4S  jr%SRS!\S	\S\&4S" jjr'0 4S\S#\(4S$ jjr)S0 4S\S%\*S&\+S'\(S(\,4
S) jjr-S0 4S*\S\$4S+ jjr.SSS0 4S\$S\S\S\\&   4S, jjr/SSS0 4S\$S\S\S\\&   4S- jjr0S0 4S*\S\$4S. jjr1S0 4S\$4S/ jjr2SSS0 4S\$S\S\4S0 jjr3SSS0 4S1\$S\S\S\\4   4S2 jjr5SSS0 4S1\$S\S\S\\4   4S3 jjr6SRS4 jr7SRS5\S6\8S\44S7 jjr9S0 4S1\S'\(S8\S9\$S\44
S: jjr:SRS6\84S; jjr;S0 4S<\4S= jjr<SRS> jr=SSS0 4S1\$S\S\S\\>   4S? jjr?0 4S1\S'\(S@\SA\S\>4
SB jjr@S0 4SC\AS\$4SD jjrBSRS\C4SE jjrD0 4S\S'\(S\C4SF jjrESGSH0 SS4SI jrFS1\ASJ\SK\SL\SM\SN\4SO jrG0 4SP jrHSQrIU =rJ$ )Sbitrue#   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0 S2S
_S3S_S4S
_S5S_S6S
_S7S8_S9S_S:S
_S;S
_S<S
_S=S
_S>S
_S?S
_S@S
_SAS
_SBS
_SCS
_E0 SDS
_SES
_SFS
_SGS
_SHS
_SIS
_SJS
_SKS
_SLS
_SMS
_SNS
_SOS_SPS
_SQS
_SRS
_SSS
_STS_E0 SUS_SVS
_SWS
_SXS
_SYS_SZS
_S[S
_S\S_S]S_S^S
_S_S
_S`S
_SaS
_SbS
_ScS
_SdS
_SeS
_E0 SfS
_SgS_ShS_SiS_SjS_SkS_SlS
_SmS
_SnS
_SoS
_SpS_SqS
_SrS_SsS
_StS
_SuS
_SvS_ESS
S
SSSw.E_SxSySzS{S|S}S~SSSS.	_SSSSSSS.SSSS/SS._SSSSSS.00SSSSSSS/SS/SS//S.SSSSSS.SSSS.0SSSSSSSSS.SSS.SS0S.S.SSSS000S.SSSSSSSSS.00SSSSSSSSSS.SSSSSSS.S.0S.SSSSSSSSS.00SSSSSSSSSS.SSSSSSS.S.0S.S._SSS
SU R	                  S5      U R	                  S5      S.SSSSU R	                  S5      U R	                  S5      U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //
U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //
S.S.0SSSSU R	                  S5      U R	                  S5      U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //
U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //
S.S.0S._SSS/ SQ0SS
[
        SSS
S
SSS.0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 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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_GSGS_GSGS_E0 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$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/_GS0GS1_GS2GS3_EGS4GS5GS6GS7GS8GS9GS:GS;GS<GS=GS>GS?GS@.ESSySzS{S|S}S~SGSASSGSB.
GSCGSDGSEGSFGSGGSHGSIGSJGSK.GSL.GSMGSNGSNGSMGSMGSNGSO.GSP._GSQGSRGSS0_GST[        _GSUS
S
SS S S
S
S SSSS
GSV.S
S
S
SSS
SGSW.S S
SGSXGSXSGSY.S
S
S
SGSZ.S
S S
S
SGS[.S S
SGS\SGS\S
S
SGS].GS^GS_0GS`.	GSaGSb0GSbSSS
S
GSc.GS^GSd0S GSe.GSaGSf0GSaGSf0GSg.S S GSg.GSh._GSi0 GSj[        _GSk[        _GSl[        _GSm[        _GSn[        _GSo[        _GSp[        _GSq[        _GSr[        _GSs[        _GSt[        _GSu[        _GSv[        _GSw[        _GSx[        _GSy[        _GSz[         _0 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["        _GS["        _GS["        _E0 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[        _GS[(        _GS[(        _E0 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[        _GS[        _E[        [        [         GS.GS._5      $ (  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getgQ?)zpublic.jsonzpublic{currency}.json   d   i  g333333?  g333333@)costbyLimitg333333#@)r   noSymbol)pingtimeexchangeInfodepthtradeshistoricalTrades	aggTradeszticker/24hrzticker/pricezticker/bookTickerzmarket/kline      x   )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   rB   deliveryoptionstypes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XTZrS  rT  VECHAINWANCHAINXINFINrW  rX  rY  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?   rB   walletcontract)r?   rB   rA   fundingfundrl  )!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  )	sandboxrO   createOrdersr   r   r   r   r^   r   extendsdefault)r  r  r  r  i,  )r  rO   r   r^   forDerivatives)r  r  )r  r?   r  rA   rB   
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    S/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/bitrue.pyr  bitrue.describe%   s0   fd < > D
A
(D
A
HD
A
 $D
A
 	D
A

 D
A
 tD
A
 4D
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D
A
l 
mD
A
B i8::?	 0cQ5 VCD
A
n  !!/39=$# "(,(,0423#tsTWj[_adZe@f)g*.47-18<#/N045904$#" *+./-/+-,.:>4736	$ *+36%
 !('$!#J "! *C$$[4n !!(,(,-1)-*.*.$	# ",-./)*+,3423<=67	$ 34./*+)+1245%$#L !!(,(,-1)-*.*.$	# ",-./)*+,3423<=67	$ 34./*+)*1245%$#u~oD
A
l $!&"&!..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mD
A
L 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 %(&'$ *#WsMD
A
t {!uD
A
z Y{D
A
| $&+(,,0,0).+06:#'#'"&#(	( #($)$)26+//4#')$, %)&+!%$*%+*.& ',#($)*.	# ',!%#($)*.( $(&+!%$&,-%'#($)*.	*  #q;z y  )&*$(27+0	$  # *.# "#3 "#3 	 ##kY}D
A
p 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qD
A
 D
 D
	    c                 B    U R                  5       U R                  S   -
  $ )Nrt  )millisecondsr   )r  s    r  noncebitrue.nonce  s       "T\\2B%CCCr  c                    #    U R                  U5      I Sh  vN n[        UR                  5       5      n[        U5      nU(       a  SOSnUSSSUS.$  N;7f)a=  
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>`
Nmaintenanceok)statusupdatedetaurlinfo)spotV1PublicGetPinglistkeyslen)r  paramsresponser  
keysLengthformattedStatuss         r  fetch_statusbitrue.fetch_status  s\      11&99 HMMO$Y
+5-4%
 	
 :s   AA<Ac                 d   #    U R                  U5      I Sh  vN nU R                  US5      $  N7f)a@  
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
N
serverTime)spotV1PublicGetTimesafe_integer)r  r  r  s      r  
fetch_timebitrue.fetch_time  s4      11&99   <88 :s   0.0c                   #    U R                  U5      I Sh  vN n0 nU R                  US/ 5      n[        S[        U5      5       GH  nXE   nU R	                  US5      nU R	                  US5      nU R                  U5      n	U R                  US/ 5      n
0 n[        S[        U
5      5       H  nX   nU R	                  US5      nU R                  X5      nUUUU R                  US5      U R                  US	5      SU R                  US
5      SSU R                  US5      U R                  US5      S.0S.	X'   M     U R                  UUU	SUSSSUSSSSSSS.0S.5      X9'   GM!     U$  GNT7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coinsr   coincoinFulNamechainDetailchainenableDepositenableWithdrawwithdrawFeer   minWithdrawmaxWithdrawminmax)	r  r2   networkdepositr   activefee	precisionlimitscrypto)r2   r3   coder  r  r  r  r   rx  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currencyr2   r3   r  networkDetailsrx  jentry	networkIdr  s                   r  fetch_currenciesbitrue.fetch_currencies  s     99&AA^ x"5q#e*%AxH!!(F3B##Hm<D**2.D!^^HmRHNH1c.12&) ,,UG<	11)B!#&#~~e_E $u6F G"++E=A!%"#'#3#3E=#I#'#3#3E=#I%%!	 3(  77!  $ ##!9 FL7 &^ A Bs   E.E+EE.c                   #    / nSn/ SQnU R                  U R                  S5      nUb  U R                  USU5      nOU R                  U R                  SU5      n[        S[	        U5      5       H  nX6   nUS:X  a"  UR                  U R                  U5      5        M/  US:X  a"  UR                  U R                  U5      5        MW  US:X  a"  UR                  U R                  U5      5        M  [        U R                  S	-   U-   S
-   5      e   [        R                  " U6 I Sh  vN nU R                  U R                  US5      S/ 5      n	U R                  US5      n
U R                  US5      nU	nU R                  X5      nU R                  X5      nU R                  S   (       a  U R                  5       I Sh  vN   U R!                  U5      $  N N7f)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
Nr   r}   r   r   r?   r  r  z+ fetchMarkets() self.options fetchMarkets "z " is not a supported market typesymbolsr      ru  )	safe_dictr   r  r  r  appendr  fapiV1PublicGetContractsdapiV1PublicGetContractsr   r2   asynciogather
safe_valuearray_concatload_time_differenceparse_markets)r  r  promisesRawr   defaultTypesfetchMarketsOptionsr  
marketTypepromisesspotMarketsfutureMarketsdeliveryMarketsmarketss                r  fetch_marketsbitrue.fetch_marketsB  s     4"nnT\\>J*NN#6NE NN4<<NEq#e*%AJV#""4#C#CF#KLx'""4#@#@#HIy(""4#@#@#HI#DGG.[$[^h$h  lN  %N  O  O & !55oodooh&BIrR!4//(A6##G;##G=B <<12++---!!'**S 6P .s%   D#G%G&BG<G=GGr  c                    U R                  US5      nU R                  US5      nU R                  US5      nS nS nS nUc  SnOSnUS:H  nUS:H  nUS:g  nU R                  US5      n	U R                  US5      n
S nS nU(       aR  UR                  S	5      nU R                  US5      n	U R                  US
5      n
U(       a  U
nOU	nU R	                  U5      nU R	                  U	5      nU R	                  U
5      nUS-   U-   nUb  USU-   -  nU R                  US/ 5      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5      nU R                  US5      nU R                  USU5      nU R                  USU5      nU R                  US5      nU R                  US5      nUc  U R                  US5      nU R                  US5      nUc  U R                  US5      n0 SU_SU_SU_SU_SU_SU_S U	_S!U
_S"U_S#U_SUS:H  _S$S%_SU_S&S%_S'S%_S(US):H  _S*U_UUU R                  [        R                  " U5      5      S S S S U R                  U R                  U5      5      U R                  U R                  U5      5      S+.S S S,.U R                  US-5      US,.U R                  US.5      U R                  US/5      S,.US S,.S0.S US1.E$ )2Nsymbolsider?   rA   r   r   	baseAsset
quoteAsset-r  /:filters
filterTyper  PRICE_FILTERLOT_SIZEpricePrecisionquantityPrecision
priceScalevolumeScale
multipliermaxQtymaxValidOrderminValminOrderMoneyr2   lowercaseIdr   r   settlebaseIdquoteIdsettleIdr  r@   FrB   rC   r  TRADINGrl  )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_byr  r  r  r,   
string_absparse_precision)r  r  r2   r  r
  r  isLinear	isInverse
isContractr  r   r!  r  symbolSplitr   r   r	  r  filtersByTyper  priceFilteramountFilterdefaultPricePrecisiondefaultAmountPrecisionr  amountPrecisionr  maxQuantityminCosts                                r  parse_market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                    SU0nU R                  US5      nU R                  USS/ 5      n[        S[        U5      5       Hk  nXE   nU R	                  USS5      nU R                  U5      nU R                  5       n	U R	                  USS	5      U	S'   U R	                  US
S5      U	S'   XU'   Mm     X2S'   U R                  U5      US'   U R                  U5      $ )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  rK  rC  r  balance
currencyIdr  r   s
             r  parse_balancebitrue.parse_balance  s    ` H
 %%h=	$$Xz9bIq#h-(AkG++GWlKJ**:6DllnG"00&/RGFO"00(MRGFO"4L ) ({!\\)4z  ((r  c                   #    U R                  5       I Sh  vN   SnU R                  SSU5      u  p!SnU R                  SSU5      u  p1SnSnUS:X  ac  Ub3  US:X  a-  U R                  U5      I Sh  vN nU R	                  US0 5      nOHU R                  U5      I Sh  vN nU R	                  US0 5      nOU R                  U5      I Sh  vN nUnU R                  U5      $  N Ns NH N7f)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>`
NrV   rA   r  data)load_marketshandle_market_type_and_paramshandle_sub_type_and_paramsdapiV2PrivateGetAccountr  fapiV2PrivateGetAccountspotV1PrivateGetAccountrS  )r  r  r  subTyper  r  s         r  fetch_balancebitrue.fetch_balanceN  s     !!!99.$PVW99.$PVW6>"w)';!%!=!=f!EE&"=@ "&!=!=f!EE&"=@ "99&AAHF$ !!&))} 	" FB FB BsF   C*C"AC*0C$1,C*C&,C*
C(C*$C*&C*(C*Nr	  r  c                   #    U R                  5       I Sh  vN   U R                  U5      nSnUS   (       a|  SUS   0nUb  US:  a  SnX&S'   US   (       a)  U R                  U R                  Xc5      5      I Sh  vN nOUS   (       a(  U R	                  U R                  Xc5      5      I Sh  vN nOaUS	   (       a?  S
US   0nUb  US:  a  SnX&S'   U R                  U R                  Xc5      5      I Sh  vN nO[        U R                  S-   5      eU R                  USS5      nU R                  XQU5      nU R                  US5      US'   U$  GN; N N N`7f)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
NrA   contractNamer2   r   r  r  r  r?   r	  r   z0 fetchOrderBook only support spot & swap marketsr   lastUpdateIdr  )rW  r  fapiV1PublicGetDepthextenddapiV1PublicGetDepthspotV1PublicGetDepthr$   r2   safe_integer_2parse_order_bookr  )	r  r	  r  r  r  r  requestrK  	orderbooks	            r  fetch_order_bookbitrue.fetch_order_book  sf     !!!V$&>tG  3;E#( h!%!:!:4;;w;W!XX	"!%!:!:4;;w;W!XXF^&,G  4< E#( !66t{{77STTHtww)[[\\4 ''&.I	))(IF	!..xH	'm 	" YX UsH   EEA$E;E<2E.E/AE7E8AEEEEr   c           	         U R                  S U5      nU R                  USS5      nU R                  US5      nS nUS   (       a(  [        R                  " U R                  US5      S5      nOU R                  US5      nU R                  0 SU_S	U_S
U R                  U5      _SU R                  USS5      _SU R                  USS5      _SU R                  USS5      _SU R                  US5      _SU R                  USS5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU_SU_SS _SU R                  US 5      _S!U_S"S _U R                  US#S$5      U R                  US%5      US&.EU5      $ )'N	lastPricelastr   rA   rose100priceChangePercentr	  rK  rL  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_symbolrN  r  r,   
string_mulr  safe_tickerrO  )r  r   r  r	  ro  rK  r   s          r  parse_ticker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                 T  #    U R                  5       I Sh  vN   U R                  U5      nSnSnUS   (       ao  SUS   0nUS   (       a)  U R                  U R                  Xb5      5      I Sh  vN nO2US   (       a(  U R	                  U R                  Xb5      5      I Sh  vN nUnOeUS   (       aC  SUS   0nU R                  U R                  Xb5      5      I Sh  vN nU R                  US	0 5      nO[        U R                  S
-   5      eU R                  XS5      $  GN	 N N NH7f)a2  
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>`
NrA   ra  r2   r  r  r?   r	  r   z- fetchTicker only support spot & swap markets)
rW  r  fapiV1PublicGetTickerrd  dapiV1PublicGetTickerspotV1PublicGetTicker24hrr  r$   r2   r  r  r	  r  r  r  rV  ri  s          r  fetch_tickerbitrue.fetch_tickerC  s     !!!V$&>tG h!%!;!;DKK<X!YY	"!%!;!;DKK<X!YYDF^&,G ";;DKK<XYYH>>(Ar2Dtww)XXYYN   ..w 	" ZY ZsG   D(DAD(.D"/2D(!D$";D(D&AD("D($D(&D(r   	timeframesincec                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  U R                  S0 5      nSnSn	US   (       a  U R                  US0 5      n
US   U R	                  XS5      S.nUb  XKS'   US	   (       a)  U R                  U R                  X5      5      I Sh  vN nO2US
   (       a(  U R                  U R                  X5      5      I Sh  vN nUn	OUS   (       a  U R                  US0 5      nUS   U R	                  XS5      S.nUb  XKS'   U R                  US5      nUb  U R                  US5      nXS'   U R                  U R                  X5      5      I Sh  vN nU R                  US/ 5      n	O[        U R                  S-   5      eU R                  XX#U5      $  GN GN N NK7f)a  
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
Nr   rA   rB   r2   rc  )ra  intervalr  r  r  r?   r   )r	  scaleuntilfromIdxrV  z, fetchOHLCV only support spot & swap markets)rW  r  r  r   r  fapiV1PublicGetKlinesrd  dapiV1PublicGetKlinesr  omitspotV1PublicGetMarketKliner  r$   r2   parse_ohlcvs)r  r	  r  r  r  r  r  r   r  rV  timeframesFutureri  timeframesSpotr  s                 r  fetch_ohlcvbitrue.fetch_ohlcv  s     !!!V$^^DLL,C
&>#~~j(BG &t ,,-=&QG
  #( h!%!;!;DKK<X!YY	"!%!;!;DKK<X!YYDF^!^^JCN ,)).TJG
  #( %%fg6E 673%*	"!<<T[[=YZZH>>(FB7Dtww)WWXXB   yGGI 	" ZY [sH   G	F?BG	6G72G	)G*BG	;G<AG	G	G	G	c           
      
   U R                  US5      nUc  U R                  US5      nUU R                  USS5      U R                  USS5      U R                  USS5      U R                  US	S
5      U R                  USS5      /$ )Nr  idxor  hrs  lru  cr  vr  )safe_timestampr  safe_number_2)r  ohlcvr  rK  s       r  parse_ohlcvbitrue.parse_ohlcv  s    2 ''s3	))%7Iuc62uc62uc51uc73uc51
 	
r  r  c                   #    U R                  5       I Sh  vN   U R                  USS5      nU R                  US5      nU R                  U5      nSnUS   (       am  SUS   0nUS   (       a)  U R	                  U R                  Xb5      5      I Sh  vN nOUS   (       a(  U R                  U R                  Xb5      5      I Sh  vN nORUS	   (       a0  S
US   0nU R                  U R                  Xb5      5      I Sh  vN nO[        U R                  S-   5      e0 nXWUS   '   U R                  Xq5      $  GN  N Nv N>7f)a0  
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   rA   ra  r2   r  r  r?   r	  z/ fetchBidsAsks only support spot & swap markets)rW  market_symbolsr  r  r  rd  r  spotV1PublicGetTickerBookTickerr$   r2   parse_tickers)r  r  r  firstr  r  ri  rV  s           r  fetch_bids_asksbitrue.fetch_bids_asks  s7     !!!%%gtU;  !,U#&>tG h!%!;!;DKK<X!YY	"!%!;!;DKK<X!YYF^&,G "AA$++gB^__Htww)ZZ[[2 %VD\!!$00] 	" ZY
 `sF   D?D6A:D?D92D?D;9D?>D=?8D?9D?;D?=D?c                 0  #    U R                  5       I Sh  vN   U R                  U5      nSnSn0 nSnUb  U R                  US5      nU R                  U5      nUS   (       a  [	        U R
                  S-   5      eUS   (       a+  U R                  U R                  XR5      5      I Sh  vN nUnOu[	        U R
                  S-   5      eU R                  SSU5      u  pbUS:w  a  [	        U R
                  S-   5      eU R                  U R                  XR5      5      I Sh  vN nUn0 n	[        S[        U5      5       H=  n
U R                  XJ0 5      nU R                  U R                  US	5      5      nXUS
   '   M?     U R                  X5      $  GNy N Nt7f)as  
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   rA   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	  r2   )rW  r  r  r  r$   r2   r  rd  rX  r  r  r  safe_marketr  )r  r  r  r  rV  ri  r  r  r  tickersr  r   s               r  fetch_tickersbitrue.fetch_tickersB  s     !!!%%g.$$Wa0E[['Ff~"477-z#z{{!%!?!?G@\!]]"477-]#]^^==ndTZ[LDv~"477-j#jkk!;;DKK<XYYHDT q#d)$A^^DR0F%%d&6&6vx&HIF$*F4L! % !!'33I 	" ^ Zs6   FFBF)F*A5FF A0FFFtradec                    U R                  USS5      nU R                  US5      n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S	5      n	S n
U R	                  US
5      nU R	                  US5      nUb  U(       a  SOSn
Ub  U(       a  SOSn
S nSU;   a5  U R                  USS5      U R                  U R                  US5      5      S.nS nU R	                  US5      nUb  U(       a  SOSnU R                  UUU R                  U5      UU	US U
UUUS US.U5      $ )Nctimer   r$  qtyr	  ra  orderIdr2   tradeIdisBuyerMakerisBuyerr~  ry  
commissionr  commissionAssert)r   r  isMakerr   r   )r  rK  rL  r	  r2   r   r  r
  takerOrMakerr$  r#  r   r  )rg  r  rN  r  r  r  
safe_traderO  )r  r  r  rK  priceStringamountStringmarketIdr	  r  r2   r
  
buyerMakerr  r  r  r  s                   r  parse_tradebitrue.parse_trade  s}   b ''w?	&&ug6''u5%%eX~F!!(3""5)4tY7^^E>:
..	2!'6UD#5D5 **5,F 33D4D4DUL^4_`C ..	2&-77L"Y/( " 
  	r  c                 >  #    U R                  5       I Sh  vN   U R                  U5      nSnUS   (       a7  SUS   0nUb  X7S'   U R                  U R                  Xt5      5      I Sh  vN nO[	        U R
                  S-   5      eU R                  XeX#5      $  N N17f)a  
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	  r2   r  z& fetchTrades only support spot markets)rW  r  spotV1PublicGetTradesrd  r$   r2   parse_trades)r  r	  r  r  r  r  r  ri  s           r  fetch_tradesbitrue.fetch_trades  s      !!!V$&>&,G  #( !77G8TUUHtww)QQRR   5@@7 	" Vs"   BBAB)B*0BBr  c           
      >    SSSSSSSSSS.	nU R                  X!U5      $ )Nr  closedcanceled	cancelingrejectedexpired)	INITPENDING_CREATENEWPARTIALLY_FILLEDFILLEDCANCELEDPENDING_CANCELREJECTEDEXPIRED)r  )r  r  statusess      r  parse_order_statusbitrue.parse_order_status  s9    $ &")" 

 &99r  r   c                    U R                  U R                  USS5      5      nU R                  US5      nU R                  XB5      nU R                  US5      nS nS nSU;   a  U R	                  US5      nOfSU;   a  U R	                  US5      nOMSU;   aG  US:X  aA  [
        R                  " US	5      (       a  U R	                  US5      nOU R	                  US5      nU R                  US
5      n	U R                  US5      n
U R                  US5      nU R                  USS5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US/ 5      nU R                  US5      nU R                  US5      nUS:H  =(       d    US:H  =(       d    US:H  nUS:X  a  SnU R                  U R                  U R                  US5      5      5      nU R                  0 SU_SU_SU_SU_SU R                  U5      _SU_SU_SU_SU_SU_SU_SU
_S U_S!U_S"U_S#U	_S$U_S US US%.EU5      $ )&Nr  orderStatusr	  executedQtyr   transactTimerB  r  r   avgPricer$  origQtycummulativeQuoteQtycumQuoter  r  r
  fillsclientOrderIdr  limit_makerGTX	post_onlyr  	stopPricer  r2   rK  rL  lastTradeTimestamppostOnlyr  r#  r   r  filled)	remainingr  r  r   )r  rN  r  r  r  r,   	string_gtr.  r  r  	omit_zero
safe_orderrO  )r  r   r  r  r  r	  r  rK  r  r  r$  r#  r   r2   r  r
  r  r  r  r  r  s                        r  parse_orderbitrue.parse_order$  s   n ((););E8])[\##E84!!(3!!%7	!U?))%8Iu$))%@IU"$$VS1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                    #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSUS'   U R	                  USSUSU5      I Sh  vN $  NZ N7f)a  
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>`
NrA   z9 createMarketBuyOrderWithCost() supports swap orders onlyFro  r  ry  )rW  r  r$   r2   create_order)r  r	  r   r  r  s        r  !create_market_buy_order_with_cost(bitrue.create_market_buy_order_with_cost  sw      !!!V$f~tww)ddee6;23&&vxdFSSS 	"
 Ts"   A5A1AA5,A3-A53A5r  r
  r#  r$  c                   #    U R                  5       I Sh  vN   U R                  U5      nSnSn	UR                  5       n
UR                  5       U
S.nU
S:X  a/  Uc  [        U R                  S-   5      eU R                  X5      US'   US   (       Ga2  U
S:H  nU R                  US5      nU R                  USU5      nU(       a  S	US
'   OUS:X  a  SUS
'   OUS:X  a  SUS
'   US   US'   SnU R                  USSS5      u  pU(       a  US:X  a  U(       a  U R                  US5      nU R                  US5      nUc  Uc  [        U R                  S-   5      eU R                  U5      nU R                  U5      n[        R                  " UU5      nUb  UOUnU R                  UU5      US'   U R                  UU5      US'   O(U R                  U5      US'   U R                  U5      US'   SUS'   U R!                  USS5      nU(       a  SOSUS'   U R                  US S!5      nU R                  U5      US '   U R                  U/ S"Q5      nUS#   (       a)  U R#                  U R%                  X5      5      I Sh  vN nO2US$   (       a(  U R'                  U R%                  X5      5      I Sh  vN nU R)                  US%0 5      n	GO%US&   (       Ga  US   US''   U R+                  X5      US('   U R-                  US)   S*5      nU R/                  U
U5      (       d!  [        U R                  S+-   U-   S,-   U-   5      eU R1                  US-S.5      nUb  U R                  US-S./5      nUUS-'   U R!                  US/S05      nUb)  U R                  US/S0/5      nU R                  UU5      US0'   U R3                  U R%                  X5      5      I Sh  vN nUn	O[5        U R                  S1-   5      eU R7                  X5      $  GN GN GNV N97f)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$  rA   MARKETr  	POST_ONLYr  fokr  iocr  r2   ra  TrO   ro  ry  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#  r  r   positionType
reduceOnlyreduce_onlyCLOSEOPENr  r  1)r  r  r  r  r  r  rV  r?   r	  quantityr  
orderTypes z% is not a valid order type in market newClientOrderIdr  r  r  z- createOrder only support spot & swap markets)rW  r  upperr!   r2   price_to_precisionr.  is_post_onlyhandle_option_and_paramsr  r  number_to_stringr,   r  cost_to_precisionparse_to_numericrM  fapiV2PrivatePostOrderrd  dapiV2PrivatePostOrderr  amount_to_precisionr  in_arrayrN  spotV1PrivatePostOrderr$   r  )r  r	  r  r
  r#  r$  r  r  r  rV  uppercaseTyperi  isMarketr  r  ro  r   r  r  quoteAmountrequestAmountr  r  validOrderTypesr  r  s                             r  r  bitrue.create_order  s/    2 !!!V$

JJL!
 G#}"477-W#WXX#66vEGG&>>$0H00GK((4@H"-%"'%"'&,TlGN#04-8<8U8UV\^k  nQ  SW  9X5-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!%!<!<T[[=Y!ZZ	"!%!<!<T[[=Y!ZZ>>(FB7DF^^ &tGH"&":":6"JGJ"oofVnlKO==@@"477S=4#7:a#adj#jkk ..v7I?[M(6,>+PQ.;*+,,V^[QL'6NK+HI'+'>'>v|'T$!88W9UVVHDtww)XXYY, --A 	"j [Z  WsG   PO;I!P8O>92P+P,DP
P1P>PPPr2   c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nU R	                  USS5      nU R                  USS/5      nSnSn0 nUc  XS'   OUS   (       a  XXS'   OXXS'   US   (       a  US   US'   US	   (       a)  U R                  U R                  X5      5      I Sh  vN nO2US
   (       a(  U R                  U R                  X5      5      I Sh  vN nU R                  US0 5      nOYUS   (       a7  XS'   US   US'   U R                  U R                  X5      5      I Sh  vN nUnO[        U R                  S-   5      eU R                  Xt5      $  GNS N N N77f)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  rA   r2   ra  r  r  rV  r?   r	  z, fetchOrder only support spot & swap markets)r   r2   rW  r  rM  r  fapiV2PrivateGetOrderrd  dapiV2PrivateGetOrderr  spotV1PrivateGetOrderr$   r  	r  r2   r	  r  r  r*  r  rV  ri  s	            r  fetch_orderbitrue.fetch_order"  s     >#DGG.X$XYY!!!V$ --f6I?[6$7#IJ$!#If~+<(/@+,&>&,TlGN#h!%!;!;DKK<X!YY	"!%!;!;DKK<X!YY>>(FB7DF^!#I &tGH!77G8TUUHDtww)WWXXX --O 	"" ZY
 VsG   /FFBFF2FF	AFF1FF	FFc                 |  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   (       d  [	        U R                  S-   5      eSUS   0nUb  X&S'   Ub  X6S'   U R                  U R                  Xd5      5      I Sh  vN nU R                  XuX#5      $  N N7f)	a  
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>`
Nz/ fetchClosedOrders() requires a symbol argumentr?   z, fetchClosedOrders only support spot marketsr	  r2   	startTimer  )r   r2   rW  r  r$   spotV1PrivateGetAllOrdersrd  parse_orders)r  r	  r  r  r  r  ri  r  s           r  fetch_closed_ordersbitrue.fetch_closed_ordersy  s      >#DGG._$_``!!!V$f~tww)WWXXfTl
 #(K $G77G8TUU.   5@@M 	" Vs"   /B<B8A/B<!B:"B<:B<c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSnSn0 nUS   (       a  US   US'   US   (       a)  U R	                  U R                  X5      5      I Sh  vN nO2US   (       a(  U R                  U R                  X5      5      I Sh  vN nU R                  US/ 5      nOUUS	   (       a3  US   US
'   U R                  U R                  X5      5      I Sh  vN nUnO[        U R                  S-   5      eU R                  XuX#5      $  GN N N N87f)aV  
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 argumentrA   r2   ra  r  r  rV  r?   r	  z1 fetchOpenOrders only support spot & swap markets)r   r2   rW  r  fapiV2PrivateGetOpenOrdersrd  dapiV2PrivateGetOpenOrdersr  spotV1PrivateGetOpenOrdersr$   r4  	r  r	  r  r  r  r  r  rV  ri  s	            r  fetch_open_ordersbitrue.fetch_open_orders  s5     >#DGG.]$]^^!!!V$&>&,TlGN#h!%!@!@WA]!^^	"!%!@!@WA]!^^>>(FB7DF^ &tGH!<<T[[=YZZHDtww)\\]]^   u<<A 	" _^ [sG   /ED?AEE2E?E AEE2EEEEc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nU R	                  USS5      nU R                  USS/5      nSnSn0 nUc  XS'   OUS   (       a  XXS'   OXXS'   US   (       a  US   US'   US	   (       a)  U R                  U R                  X5      5      I Sh  vN nO2US
   (       a(  U R                  U R                  X5      5      I Sh  vN nU R                  US0 5      nOUUS   (       a3  US   US'   U R                  U R                  X5      5      I Sh  vN nUnO[        U R                  S-   5      eU R                  Xt5      $  GNO N N N77f)a  
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  rA   r2   ra  r  r  rV  r?   r	  z- cancelOrder only support spot & swap markets)r   r2   rW  r  rM  r  fapiV2PrivatePostCancelrd  dapiV2PrivatePostCancelr  spotV1PrivateDeleteOrderr$   r  r.  s	            r  cancel_orderbitrue.cancel_order 	  s     >#DGG.Y$YZZ!!!V$ --f6I?[6$7#IJ$!#If~+<(/@+,&>&,TlGN#h!%!=!=dkk'>Z![[	"!%!=!=dkk'>Z![[>>(FB7DF^ &tGH!::4;;w;WXXHDtww)XXYY* --_ 	"" \[ YsG   /F	F BF	F2F	FAF	F1F	F	F	F	c                   #    U R                  5       I Sh  vN   U R                  U5      nSnSnUS   (       a  SUS   0nUS   (       a)  U R                  U R                  Xb5      5      I Sh  vN nO2US   (       a(  U R	                  U R                  Xb5      5      I Sh  vN nU R                  US/ 5      nO[        U R                  S-   5      eU R                  XS5      $  N Nv NE7f)	a$  
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>`
NrA   ra  r2   r  r  rV  z, cancelAllOrders only support future markets)	rW  r  fapiV2PrivatePostAllOpenOrdersrd  dapiV2PrivatePostAllOpenOrdersr  r$   r2   r4  r  s          r  cancel_all_ordersbitrue.cancel_all_orders@	  s      !!!V$&>tG h!%!D!DT[[QXEa!bb	"!%!D!DT[[QXEa!bb>>(FB7Dtww)WWXX   ..1 	" cbs5   C)C#AC).C%/2C)!C'"AC)%C)'C)c                   #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eU R                  U5      nSnSn0 nUb  X(S'   Ub  US:  a  SnX8S'   US   (       a  US   US'   US	   (       a)  U R	                  U R                  X5      5      I Sh  vN nO2US
   (       a(  U R                  U R                  X5      5      I Sh  vN nU R                  US/ 5      nOUUS   (       a3  US   US'   U R                  U R                  X5      5      I Sh  vN nUnO[        U R                  S-   5      eU R                  XuX#5      $  GN? N N N87f)aE  
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 argumentr2  r   r  rA   r2   ra  r  r  rV  r?   r	  z/ fetchMyTrades only support spot & swap markets)rW  r   r2   r  fapiV2PrivateGetMyTradesrd  dapiV2PrivateGetMyTradesr  spotV2PrivateGetMyTradesr$   r  r;  s	            r  fetch_my_tradesbitrue.fetch_my_tradesf	  s]     !!!>#DGG.[$[\\V$#(K t|$G&>&,TlGN#h!%!>!>t{{7?[!\\	"!%!>!>t{{7?[!\\>>(FB7DF^ &tGH!::4;;w;WXXHDtww)ZZ[[\   u<<O 	"  ]\ YsG   EEBE"E#2EEAE#E$2EEEE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S.nUb  X&S'   Ub  X6S'   U R	                  U R                  Xd5      5      I Sh  vN nU R                  US/ 5      nU R                  XX#5      $  Nx N+7f)	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>`
Nz) fetchDeposits() requires a code argumentr2   r   r  r  r2  r  rV  )r   r2   rW  r  spotV1PrivateGetDepositHistoryrd  r  parse_transactions	r  r  r  r  r  r  ri  r  rV  s	            r  fetch_depositsbitrue.fetch_deposits	  s      <#DGG.Y$YZZ!!!==&TN
 #(K $G<<T[[=YZZJ ~~h3&&tuDDk 	" [s"   /B.B*AB. B,*B.,B.c                 ^  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nUS   SS.nUb  X&S'   Ub  X6S'   U R	                  U R                  Xd5      5      I Sh  vN nU R                  US/ 5      nU R                  X5      $  Nw N*7f)	a  
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>`
Nz, fetchWithdrawals() requires a code argumentr2   r   rP  r2  r  rV  )r   r2   rW  r  spotV1PrivateGetWithdrawHistoryrd  r  rR  rS  s	            r  fetch_withdrawalsbitrue.fetch_withdrawals
  s      <#DGG.\$\]]!!!==&TN
 #(K $G==dkk'>Z[[0 ~~h3&&t66Q 	" \s"   /B-B)AB- B+)B-+B-c                 b    SSS.SSSS.S.nU R                  X20 5      nU R                  XAU5      $ )Npendingr  )r   r  r  )r   56)r  
withdrawal)r  r  )r  r  r  statusesByTyper  s        r   parse_transaction_status_by_type'bitrue.parse_transaction_status_by_type9
  sK     
 
 
 >>.;&99r  transactionr  c                 >   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 nS nUbp  Ub5  UR                  S5      n	U R                  U	S5      nU R                  U	S5      nUb5  UR                  S5      n	U R                  U	S5      nU R                  U	S5      nU R                  US	5      n
U R                  US
5      nU R                  US5      nSU;   nSU;   nU(       d  U(       a  SOSnU R	                  U R                  US5      U5      nU R                  US5      nS nU R                  USS5      nUbH  UR                  S5      n	U R                  U	S5      nU R                  U	S5      nUb  UR                  5       nU R                  UU5      nU R                  US5      nS nUb  UUS.n0 SU_SU_S	U
_SU_SU R                  U5      _SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_S U_S!S US".E$ )#Nr2   
withdrawIdtagType	addressToaddressFrom_r   r   txid	createdAt	updatedAt	payAmountr  r^  r  r  r#  r	  r  r  )r  r   r  rK  rL  r  addresstagtagTotagFromr  r  r  F)internalcommentr  )	rN  r  r/  r  r`  r  r  r  rO  )r  rb  r  r2   re  rf  rg  ro  rp  partsri  rK  r  rl  r  r  r  r#  r  rR  r  r  feeCostr  s                           r  parse_transactionbitrue.parse_transactionH
  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  rm  rn  c                   #    U R                  XE5      u  pEU R                  U5        U R                  5       I Sh  vN   U R                  U5      nUS   UUS.nSnU R	                  U5      u  pUb  U R                  U5      US'   Ub  XGS'   U R                  U R                  Xu5      5      I Sh  vN n	U R                  U	S0 5      n
U R                  X5      $  N N*7f)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>`
Nr2   )r  r#  rf  	chainNamern  rV  )
handle_withdraw_tag_and_paramscheck_addressrW  r  handle_network_code_and_paramsnetwork_code_to_idspotV1PrivatePostWithdrawCommitrd  r  ru  )r  r  r#  rm  rn  r  r  ri  networkCoder  rV  s              r  r   bitrue.withdraw
  s      99#F7#!!!==&TN 
 "AA&I"#'#:#:;#GGK ? EN==dkk'>Z[[  ~~h3%%d55E 	"" \s"   8CCA4C/C0)CCc                    U R                  US/ 5      n[        U5      nUS S S.S S S.0 S.nUS:w  a  [        SU5       H  nX6   nU R                  US5      nU R                  US5      n	U R	                  X5      n
S S S.U R                  US5      SS.S	.US
   U
'   US:X  d  Me  U R                  US5      US   S'   SUS   S'   M     U$ )Nr  )r  r   )r  r   r  rx  r   r  r  r  F)r  r   rx  r   r   r  r   )r  r  r  r  r  r  )r  r  r  chainDetailschainDetailLengthr  r  r  r  currencyCoder~  s              r  parse_deposit_withdraw_fee!bitrue.parse_deposit_withdraw_fee
  s
    ~~c="=-"
 " 
 !1/0*o ,,['B	#//&A"55iN'+4@(,(8(8m(Tdi j3z";/ %)040@0@m0\F:&u-7<F:&|4 1 r  codesc                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US5      nU R                  XAS5      $  NA N*7f)aN  
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>`
Nr  r  )rW  r  r  parse_deposit_withdraw_fees)r  r  r  r  r  s        r  fetch_deposit_withdraw_fees"bitrue.fetch_deposit_withdraw_fees  sW      !!!99&AAx1//fEE 	"As   AAAA)AAc           
      8   U R                  US5      nS nS nUb5  UR                  S5      nU R                  US5      nU R                  US5      nU R                  US5      nUS UU R                  U5      U R                  US5      U R	                  US5      UUSS	.	$ )
NtransferType_to_r   r   r  r  r#  r  )	r  r2   rK  rL  r  r#  fromAccount	toAccountr  )r  r/  r  rO  r  )r  r   r  r  r  r  accountSplitrK  s           r  parse_transferbitrue.parse_transfer(  s      ''.A	#'--f5L**<;K((q9I%%h8	"Y/((6:&&x:&"

 
	
r  c                   #    U R                  5       I Sh  vN   U R                  USS5      nSU0nSnUb  U R                  U5      nUS   US'   Ub  X&S'   Ub  US:  a  SnX6S'   U R                  US	5      nUb  U R	                  US	5      nXS
'   U R                  U R                  Xd5      5      I Sh  vN n	U R                  U	S/ 5      n
U R                  XX#5      $  N N+7f)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>`
Nr  r  r2   
coinSymbol	beginTime   r  r  endTimerV  )	rW  rN  r  r  r  &fapiV2PrivateGetFuturesTransferHistoryrd  r  parse_transfers)r  r  r  r  r  r  ri  r  r  r  rV  s              r  fetch_transfersbitrue.fetch_transfersL  s
     !!!!!&&.AD
 }}T*H$,TNGL!#(K s{$G!!&'2YYvw/F!&IDDT[[QXEabb ~~h3##DEAAE 	"& cs"   C"CBC"4C 5*C" C"r  r  c                   #    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S-   U	-   S.n
U R                  U R                  X5      5      I Sh  vN nU R                  US0 5      nU R                  X5      $  N N*7f)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>`
Nrz  r2   r  )r  r#  r  rV  )	rW  r  r  r   r  currency_to_precision fapiV2PrivatePostFuturesTransferrd  r  )r  r  r#  r  r  r  r  accountTypesfromIdtoIdri  r  rV  s                r  r   bitrue.transfer  s      !!!==&~~dll4DbI!!,[IC"4.00>"VOd2

 >>t{{7?[\\ ~~h3""422' 	" ]s"   CCBC.C/)CCr  c                   #    Uc  [        U R                  S-   5      eUS:  d  US:  a  [        U R                  S-   5      eU R                  5       I Sh  vN   U R	                  U5      nSnUS   US.nUS   (       d  [        U R                  S	-   5      eUS
   (       a*  U R                  U R                  Xc5      5      I Sh  vN nU$ US   (       a(  U R                  U R                  Xc5      5      I Sh  vN nU$  N N< N
7f)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 125r2   )ra  r  rA   z& setLeverage only support swap marketsr  r  )	r   r2   r   rW  r  r$   fapiV2PrivatePostLevelEditrd  dapiV2PrivatePostLevelEdit)r  r  r	  r  r  r  ri  s          r  set_leveragebitrue.set_leverage  s      >#DGG.Y$YZZqLhnTWW'NNOO!!!V$"4L 
 f~tww)QQRR(!<<T[[=YZZH  I!<<T[[=YZZH 	" [Zs7   ADC?A.DD3D8D9DDDc                 "    UUS   S SS S S S S S S.
$ )Nr	  isolated)
r  r	  r  r  r#  totalr  r  rK  rL   )r  rV  r  s      r  parse_margin_modification bitrue.parse_margin_modification  s1     X&$
 	
r  c                   #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSnUS   U R	                  U5      S.nUS   (       a)  U R                  U R                  Xc5      5      I Sh  vN nO2US   (       a(  U R                  U R                  Xc5      5      I Sh  vN nU R                  XT5      $  N NJ N7f)aP  
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>`
NrA   z$ setMargin only support swap marketsr2   )ra  r#  r  r  )	rW  r  r$   r2   r  fapiV2PrivatePostPositionMarginrd  dapiV2PrivatePostPositionMarginr  )r  r	  r#  r  r  r  ri  s          r  
set_marginbitrue.set_margin  s      !!!V$f~tww)OOPP"4L++F3
 (!AA$++gB^__HI!AA$++gB^__H --h??) 	" `_s4   C#CA=C#C2C#C!C#C#!C#r   GETc                    U R                  US5      nU R                  US5      nU R                  US5      n	S n
US:X  a  US:X  d  US:X  a(  UR                  S5      S:  a  U R                  S   U   n
OU R                  S   U   S-   U-   n
U
S-   U R                  X5      -   n
U R	                  X@R                  U5      5      nU	S	:X  Gag  U R                  5         U R                  U R                  S
S5      nUS:X  d  US:X  a  U R                  U R                  U R                  5       US.U5      5      nU R                  U R                  U5      U R                  U R                  5      [        R                   5      nUSU-   -  nSU R"                  0nUS:X  d  US:X  a
  U
SU-   -  n
GOUnSUS'   GO[%        U R                  5       5      nS nUS:X  a  SnOUS:X  a  SnUS-   U-   S-   U-   nX-   U-   nUS:X  a  ['        UR)                  5       5      n[+        U5      nUS:  a  USU R                  U5      -   -  nU R                  U R                  U5      U R                  U R                  5      [        R                   5      nU R"                  UUS.nU
SU R                  U5      -   -  n
OU R                  S
U0U5      nU R-                  U5      nUU-  nU R                  U R                  U5      U R                  U R                  5      [        R                   5      nSU R"                  UUS.nOU(       a  U
SU R                  U5      -   -  n
XXeS.$ )Nr   r   r  r   r   r  	listenKeyr  r   rs  r  r?   )rK  rs  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   	urlencoderd  r  hmacencodesecrethashlibsha256apiKeystrr  r  r  json)r  pathr   r  r  r  r  r  r:   accessr  rs  query	signaturerK  signPathsignMessager  r  s                      r  signbitrue.sign  sB   Q'""3*!!#q)EMg0dfnS^I_cdId))E"4(C))E"4(3.8CCi$--d;;6#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dOOr  reasonr  r  r  r  c
                    US:X  d  US:X  a0  [        U R                  S-   [        U5      -   S-   U-   S-   U-   5      eUS:  a  UR                  S5      S:  a  [	        U R                  S-   U-   5      eUR                  S5      S:  a  [	        U R                  S	-   U-   5      eUR                  S
5      S:  a  [	        U R                  S-   U-   5      eUc  g U R                  USS5      n
U
(       d3  U R                  US5      nS nUb   [        R                  " U5      nUb  UnU R                  US5      nUb^  U R                  U R                  S   XR                  S-   U-   5        U R                  U R                  S   XR                  S-   U-   5        U R                  US5      nUb  US:X  d  [        R                  " US5      (       a  g US:X  a/  U R                  S   (       a  [        U R                  S-   U-   5      eU R                  S-   U-   nU R                  U R                  S   UU5        [!        U5      eU
(       d  [!        U R                  S-   U-   5      eg ! [         a  nS n S nAGNWS nAff = f)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  rq  z temporary banned: )r%   r2   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_errorsbitrue.handle_errors>  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1I7T[T[^aTadkTkl001I7T[T[^aTadkTkl  62 7#8#8#D#D  dll3X&Y$TWW/D%Dt%KLLww}t+H001I5RZ[))# 4555 ! )$(M)s   	I$ $
I;.I66I;c                     SU;   a  SU;  a  US   $ SU;   a?  SU;   a9  US   nUS   n[        S[        U5      5       H  nXx   n	XiS   ::  d  M  U	S   s  $    U R                  USS5      $ )Nr   r	  r   r  r   r   r   )r  r  r  )
r  r   r  r  r  configr  r   r  r  s
             r  calculate_rate_limiter_cost"bitrue.calculate_rate_limiter_costr  s    & 8v+=*%%6!6(97OEY'G1c'l+
!H$ 8O , vvq11r  r  )N)K__name__
__module____qualname____firstlineno__r   r  r  r  r	   r  r   r  r   r   r  dictr?  r   rS  r^  r  r   rk  r   r  r  r  r  r  r   r  r   r  r   r  r  r   r  r   r  floatr  r   r   r   r  r/  r5  r<  rB  rG  rM  r   rT  rX  r`  r   ru  r   r  r  r  r   r  r   intr  r
   r  r  r  r  r  __static_attributes____classcell__)r  s   @r  r.   r.   #   sr   E
# E
ND )+ 
4 ') 9S 9" -/ f: fP *, g+V g+Ra
4 a
F a
F>) >)@ *, k* k*Z @DB CS C CS\ CJA4 A A6 AF 68 G/ G/F G/R ?CQUdhqs SH SH SH3 SH^a SHx|  ~B  yC SHj#
 #
4 #
J 8<B :1W :1x 6:" P47 P4 P4dW Wv W Wr <@d[] 'A 'AS 'A 'Abfglbm 'AR: :n nv n n` XZ Tc T T& mqy{ y. y.I y.Y y.X] y.fi y.v 8<B U.C U. U.n 7;\`ik 4A 4A3 4AVY 4Aptuzp{ 4Al 59tZ^gi O=c O= O=TW O=nrsxny O=b 9=R >.S >.# >.@ 59 $/c $/L 37TX\eg T=C T=s T=RU T=l 04$UYbd CE CEC CEs CEimnyiz CEJ 37TX\eg 67C 67s 67RU 67lpq|l} 67p:v
T v
X v
Q\ v
p QU]_ 163 16 16 16# 16do 16f$ $L BFb Fw F"
H 154VZce 1B# 1BS 1BPS 1Bjno|j} 1Bf ac !33 !3 !3C !3TW !3gt !3F ?C2 3  >
>P 
. CE  @s  @E  @I[  @D &eBSW BPH2# 2s 2 2c 2TX 2`c 2h MO 
2 
2r  r.   )5 ccxt.async_support.base.exchanger   ccxt.abstract.bitruer   r  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    6 ,    P  P  P  P  P  P  * 0 - - . ' & . ) * 5 ) + . 1 * ) 3 4 %Y12X{ Y12r  