
    eiO*                       d dl mZ d dlmZ d dl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/m0Z0 d dl/m1Z1 d dl2m3Z3  G d dee          Z4dS )    )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dPd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dee         f
dZdPdedefdZdi fdefdZdi fdedefdZdPd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$dPd 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d0e#dededee3         fd1Z4dddi fd0e#dededee3         fd2Z5dPd3Z6dPd4ed5e7de3fd6Z8di fd0ed&e'd7ed8e#de3f
d9Z9dPd5e7fd:Z:di fd;efd<Z;dPd=Z<dddi fd0e#dededee=         fd>Z>i fd0ed&e'd?ed@ede=f
dAZ?di fdBe@de#fdCZAdPdeBfdDZCi fded&e'deBfdEZDdFdGi ddfdHZEd0e@dIedJedKedLedMefdNZFi fdOZG xZHS )Qbitruereturnc                 4   |                      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ddggdddddddddddiddddddddd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|                     d          |                     d          ddddd|                     d          |                     d          |                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d¦          g|                     dæ          |                     dĦ          g|                     dŦ          |                     d          g|                     dƦ          |                     dǦ          gg
|                     d          |                     d          g|                     d          |                     dȦ          g|                     d          |                     dɦ          g|                     d          |                     dʦ          g|                     d          |                     d˦          g|                     d          |                     d̦          g|                     d          |                     dͦ          g|                     dæ          |                     dΦ          g|                     dŦ          |                     dϦ          g|                     dƦ          |                     d          gg
dМdќidddd|                     dӦ          |                     d˦          |                     d          |                     dӦ          g|                     d          |                     dԦ          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d¦          g|                     d          |                     dզ          g|                     d          |                     dզ          g|                     dæ          |                     dզ          g|                     dŦ          |                     dզ          g|                     dƦ          |                     dզ          gg
|                     d          |                     d˦          g|                     d          |                     d̦          g|                     d          |                     d֦          g|                     d          |                     dצ          g|                     d          |                     d          g|                     d          |                     dئ          g|                     d          |                     d٦          g|                     dæ          |                     dڦ          g|                     dŦ          |                     dۦ          g|                     dƦ          |                     dܦ          gg
dМdќidݜdddg didd
t
          ddd
d
dddi dddddddddddddddddddddddddddddddddd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/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@ddydzd{d|d}d~ddAdddB
dCdDdEdFdGdHdIdJdKdLdMdNdNdMdMdNdOdPdQdRdSidTt          dUd
d
dd d d
d
d dddd
dVd
d
d
ddd
ddWd d
ddXdXddYd
d
d
ddZd
d d
d
dd[d d
dd\dd\d
d
dd]d^d_id`	dadbidbddd
d
dcd^ddid dedadfidadfidgd d dgdhdii djt          dkt          dlt          dmt          dnt          dot          dpt          dqt          drt          dst          dtt          dut          dvt          dwt          dxt          dyt          dzt           i d{t          d|t          d}t"          d~t$          dt          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(          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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   rA   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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    W/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/bitrue.pyr  zbitrue.describe%   s   fd 3 3 < < > > 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 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 l 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 l 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 l 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 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 lN "!&#(  Wl l 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)g*.47-18<#/N/N045904$ $#" *+./-/+-,.:>4736	$ 	$ *+36% %
 !('$ $!# #J "! *C$$[4 4n !!(,(,-1)-*.*.$ $	# ",-./)*+,3423<=67	$ 	$ 34./*+)+1245% %$ $# #L !!(,(,-1)-*.*.$ $	# ",-./)*+,3423<=67	$ 	$ 34./*+)*1245% %$ $# #u~ ~oD
A
l $!&"&!..y99!..y99  #*%)&*!%!2!2:!>!>!%!2!2:!>!> "&!2!23!7!79J9J:9V9V W!%!2!25!9!94;L;LZ;X;X Y!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!27!;!;T=N=Nz=Z=Z [!%!2!27!;!;T=N=Nz=Z=Z [!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \& "&!2!23!7!79J9J:9V9V W!%!2!25!9!94;L;LZ;X;X Y!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!27!;!;T=N=Nz=Z=Z [!%!2!27!;!;T=N=Nz=Z=Z [!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPS>T>T U&" "     "H #)%)&*!%!2!2:!>!>!%!2!2:!>!> "&!2!23!7!79J9J:9V9V W!%!2!25!9!94;L;LZ;X;X Y!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!27!;!;T=N=Nz=Z=Z [!%!2!27!;!;T=N=Nz=Z=Z [!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \!%!2!28!<!<d>O>OPZ>[>[ \& "&!2!23!7!79J9J:9V9V W!%!2!25!9!94;L;LZ;X;X Y!%!2!26!:!:D<M<Mj<Y<Y Z!%!2!26!:!:D<M<Mk<Z<Z [!%!2!27!;!;T=N=Ns=S=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 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 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 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$ .%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 D 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 D 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 DL 5F2B$0 MK KqD
A
 D
 D
 D
	    c                 F    |                                  | j        d         z
  S )Nrs  )millisecondsr   )r  s    r  noncezbitrue.nonce  s!      ""T\2B%CCCr  c                    K   |                      |           d{V }t          |                                          }t          |          }|rdnd}|ddd|dS )ac  
        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_statuszbitrue.fetch_status  s{       11&99999999 HMMOO$$YY
+5?--4%
 
 	
r  c                 h   K   |                      |           d{V }|                     |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
        N
serverTime)spotV1PublicGetTimesafe_integer)r  r  r  s      r  
fetch_timezbitrue.fetch_time  sE       11&99999999   <888r  c                 h  K   |                      |           d{V }i }|                     |dg           }t          dt          |                    D ]\}||         }|                     |d          }|                     |d          }|                     |          }	|                     |dg           }
i }t          dt          |
                    D ]}|
|         }|                     |d          }|                     ||	          }||||                     |d          |                     |d	          d|                     |d
          dd|                     |d          |                     |d          did	||<   | 	                    |||	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
        Ncoinsr   coincoinFulNamechainDetailchainenableDepositenableWithdraw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      99&AAAAAAAA^ x"55q#e**%% .	 .	AQxH!!(F33B##Hm<<D**2..D!^^HmRHHNH1c.1122  &q) ,,UG<<	11)TBB!#&#~~e_EE $u6F G G"++E=AA!%"#'#3#3E=#I#I#'#3#3E=#I#I% %% %!!   77!  $ ##! !9 9  F4LL( r  c                   K   g }d}g d}|                      | j        d          }||                     |d|          }n|                     | j        d|          }t          dt	          |                    D ]}||         }|dk    r)|                    |                     |                     9|dk    r)|                    |                     |                     h|dk    r)|                    |                     |                     t          | j
        d	z   |z   d
z             t          j        |  d{V }|                     |                     |d          dg           }	|                     |d          }
|                     |d          }|	}|                     ||
          }|                     ||          }| j        d         r|                                  d{V  |                     |          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
        Nr   r|   r   r   r>   r   r  z+ fetchMarkets() self.options fetchMarkets "z " is not a supported market typesymbolsr      rt  )	safe_dictr   r  r  r  appendr  fapiV1PublicGetContractsdapiV1PublicGetContractsr   r1   asynciogather
safe_valuearray_concatload_time_differenceparse_markets)r  r  promisesRawr   defaultTypesfetchMarketsOptionsr  
marketTypepromisesspotMarketsfutureMarketsdeliveryMarketsmarketss                r  fetch_marketszbitrue.fetch_marketsB  s7      444"nnT\>JJ*NN#6NNEE NN4<NNEq#e**%% 		O 		OAqJV##""4#C#CF#K#KLLLLx''""4#@#@#H#HIIIIy((""4#@#@#H#HIIII#DG.[$[^h$h  lN  %N  O  O  O 5555555oodooh&B&BIrRR!44//(A66##G];;##G_==B <12 	.++---------!!'***r  r  c                    |                      |d          }|                     |d          }|                     |d          }d }d }d }|d}nd}|dk    }|dk    }|dk    }|                      |d          }	|                      |d          }
d }d }|r]|                    d	          }|                      |d          }	|                      |d
          }
|r|
}n|	}|                     |          }|                     |	          }|                     |
          }|dz   |z   }||d|z   z  }|                     |dg           }|                     |d          }|                      |d          }|                     |di           }|                     |di           }|                      |d          }|                      |d          }|                      |d|          }|                      |d|          }|                      |d          }|                     |d          }||                     |d          }|                     |d          }||                     |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*|||| 	                    t          j        |                    d d d d | 	                    |                     |                    | 	                    |                     |                    d+d d d,|                     |d-          |d,|                     |d.          |                     |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_byr  r  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0	<DDD	HIfn
!!&+66""6<88 	7((3--K%%k155F&&{A66G ""!,,X66F&&v..''00e#cFl"F..B77g|<<!!&(33nn]NBGG~~mZDD $ 0 09I J J!%!1!1&:M!N!N))+|EZ[[**<H^__%%fl;;
&&|X>>**6?C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.LMM"++D,@,@,Q,QRR**4+?+?+O+OPP    
  ++L(CC& 
  ++KDD++KDD 
 #  $ a1
 1
 1
 1	
r  c                    d|i}|                      |d          }|                     |ddg           }t          dt          |                    D ]}||         }|                     |dd          }|                     |          }|                                 }	|                     |dd	          |	d<   |                     |d
d          |	d<   |	||<   ||d<   |                     |          |d<   |                     |          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  rC  r;  r  balance
currencyIdr  r   s
             r  parse_balancezbitrue.parse_balance  s   ` H
 %%h==	$$Xz9bIIq#h--(( 	# 	#AqkG++GWlKKJ**:66DllnnG"00&/RRGFO"00(MRRGFO"F4LL'{!\\)44z  (((r  c                   K   |                                   d{V  d}|                     dd|          \  }}d}|                     dd|          \  }}d}d}|dk    rn|9|dk    r3|                     |           d{V }|                     |di           }nP|                     |           d{V }|                     |di           }n|                     |           d{V }|}|                     |          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spotV1PrivateGetAccountrK  )r  r  r  subTyper  r  s         r  fetch_balancezbitrue.fetch_balanceN  sO      !!!!!!!!!99.$PVWWf99.$PVWW6>>"w)';';!%!=!=f!E!EEEEEEE&"==@ "&!=!=f!E!EEEEEEE&"==@ "99&AAAAAAAAHF$ !!&)))r  Nr  r  c                   K   |                                   d{V  |                     |          }d}|d         rd|d         i}||dk    rd}||d<   |d         r0|                     |                     ||                     d{V }n|d         r/|                     |                     ||                     d{V }nh|d	         rId
|d         i}||dk    rd}||d<   |                     |                     ||                     d{V }nt          | j        dz             |                     |dd          }| 	                    |||          }| 
                    |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  r   z0 fetchOrderBook only support spot & swap marketsr   lastUpdateIdr  )rN  r  fapiV1PublicGetDepthextenddapiV1PublicGetDepthspotV1PublicGetDepthr$   r1   safe_integer_2parse_order_bookr  )	r  r  r  r  r  r  requestrC  	orderbooks	            r  fetch_order_bookzbitrue.fetch_order_book  s      !!!!!!!!!V$$&> 	]tG  3;;E#( h Y!%!:!:4;;wPV;W;W!X!XXXXXXX	" Y!%!:!:4;;wPV;W;W!X!XXXXXXXF^ 
	]&,G  4<< E#( !66t{{7F7S7STTTTTTTTHHtw)[[\\\4 ''&.II	))(FIFF	!..xHH	'r  r   c           	         |                      d |          }|                     |dd          }|                     |d          }d }|d         r*t          j        |                     |d          d          }n|                     |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$          |                     |d%          |d&|          S )'N	lastPricelastr   r@   rose100priceChangePercentr  rC  rD  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_symbolrF  r  r,   
string_mulr  safe_tickerrG  )r  r   r  r  rd  rC  r   s          r  parse_tickerzbitrue.parse_ticker   s]   H !!$//!!&+v>>%%ff55	
&> 	H +D,<,<VV,L,LeTTJJ))&2FGGJ !
f!
!
 Y//!
 D&&v{FCC	!

 4%%fj%@@!
 4%%fj%@@!
 ))&(;;!
 4%%fj&AA!
 ))&(;;!
 D$$V-?@@!
 D$$V[99!
 T!
 D!
 T!
 d&&v}==!
  *!!
" t#!
$ ,,VXuEE++FMBB)!
 !
 !
* +  	r  c                   K   |                                   d{V  |                     |          }d}d}|d         r|d|d         i}|d         r0|                     |                     ||                     d{V }n7|d         r/|                     |                     ||                     d{V }|}np|d         rQd|d         i}|                     |                     ||                     d{V }|                     |d	i           }nt          | j        d
z             | 	                    ||          S )ap  
        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@   rW  r1   r   r  r>   r  r   z- fetchTicker only support spot & swap markets)
rN  r  fapiV1PublicGetTickerrZ  dapiV1PublicGetTickerspotV1PublicGetTicker24hrr  r$   r1   r  r  r  r  r  r  rM  r_  s          r  fetch_tickerzbitrue.fetch_tickerC  s      !!!!!!!!!V$$&> 	ZtG h Z!%!;!;DKKQW<X<X!Y!YYYYYYY	" Z!%!;!;DKKQW<X<X!Y!YYYYYYYDDF^ 	Z&,G ";;DKKQW<X<XYYYYYYYYH>>(Ar22DDtw)XXYYYN   v...r  r   	timeframesincec                   K   |                                   d{V  |                     |          }|                     | j        di           }d}d}	|d         r|                     |di           }
|d         |                     |
|d          d}|||d<   |d	         r0|                     |                     ||                     d{V }n7|d
         r/|                     |                     ||                     d{V }|}	n|d         r|                     |di           }|d         |                     ||d          d}|||d<   |                     |d          }|| 	                    |d          }||d<   | 
                    |                     ||                     d{V }|                     |dg           }	nt          | j        dz             |                     |	||||          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
        Nr   r@   rA   r1   rb  )rW  intervalr  r   r  r>   r   )r  scaleuntilfromIdxrM  z, fetchOHLCV only support spot & swap markets)rN  r  r  r   r  fapiV1PublicGetKlinesrZ  dapiV1PublicGetKlinesr  omitspotV1PublicGetMarketKliner  r$   r1   parse_ohlcvs)r  r  r  r  r  r  r  r   r  rM  timeframesFuturer_  timeframesSpotr  s                 r  fetch_ohlcvzbitrue.fetch_ohlcv  s]      !!!!!!!!!V$$^^DL,CC
&> 	Y#~~j(BGG &t ,,-=y&QQ G
  #( h Z!%!;!;DKKQW<X<X!Y!YYYYYYY	" Z!%!;!;DKKQW<X<X!Y!YYYYYYYDDF^ 	Y!^^JCCN ,)).)TJJ G
  #( %%fg66E 6733%*	"!<<T[[RX=Y=YZZZZZZZZH>>(FB77DDtw)WWXXXB   vy%GGGr  c           
      @   |                      |d          }||                     |d          }||                     |dd          |                     |dd          |                     |dd          |                     |d	d
          |                     |dd          gS )Nr  idxorx  hrh  lrj  crz  vr  )safe_timestampr  safe_number_2)r  ohlcvr  rC  s       r  parse_ohlcvzbitrue.parse_ohlcv  s    2 ''s33	))%77Iuc622uc622uc511uc733uc511
 	
r  r  c                   K   |                                   d{V  |                     |dd          }|                     |d          }|                     |          }d}|d         rzd|d         i}|d         r0|                     |                     ||                     d{V }n|d         r/|                     |                     ||                     d{V }nY|d	         r:d
|d         i}|                     |                     ||                     d{V }nt          | j	        dz             i }|||d         <   | 
                    ||          S )an  
        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@   rW  r1   r   r  r>   r  z/ fetchBidsAsks only support spot & swap markets)rN  market_symbolsr  r  r  rZ  r  spotV1PublicGetTickerBookTickerr$   r1   parse_tickers)r  r  r  firstr  r  r_  rM  s           r  fetch_bids_askszbitrue.fetch_bids_asks  s      !!!!!!!!!%%gtU;;  !,,U##&> 	\tG h Z!%!;!;DKKQW<X<X!Y!YYYYYYY	" Z!%!;!;DKKQW<X<X!Y!YYYYYYYF^ 	\&,G "AA$++gW]B^B^________HHtw)ZZ[[[2 %VD\!!$000r  c                   K   |                                   d{V  |                     |          }d}d}i }d}||                     |d          }|                     |          }|d         rt	          | j        dz             |d         r2|                     |                     ||                     d{V }|}nt	          | j        dz             |                     dd|          \  }}|dk    rt	          | j        dz             |                     |                     ||                     d{V }|}i }	t          dt          |                    D ]M}
|                     ||
i           }|                     |                     |d	                    }||	|d
         <   N|                     |	|          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   )rN  r  r  r  r$   r1   r  rZ  rO  r  r  r  safe_marketr  )r  r  r  r  rM  r_  r  r  r  tickersr  r   s               r  fetch_tickerszbitrue.fetch_tickersB  s      !!!!!!!!!%%g..$$Wa00E[[''Ff~ _"47-z#z{{{ _!%!?!?GU[@\@\!]!]]]]]]]"47-]#]^^^==ndTZ[[LD&v~~"47-j#jkkk!;;DKKQW<X<XYYYYYYYYHDT q#d))$$ 	+ 	+A^^D!R00F%%d&6&6vx&H&HIIF$*GF4L!!!!'7333r  tradec                    |                      |dd          }|                     |d          }|                     |d          }|                     |dd          }|                     ||          }|                     |d          }|                     |dd	          }	d }
|                     |d
          }|                     |d          }||rdnd}
||rdnd}
d }d|v rA|                     |dd          |                     |                     |d                    d}d }|                     |d          }||rdnd}|                     |||                     |          ||	|d |
|||d |d|          S )Nctimer   r  qtyr  rW  orderIdr1   tradeIdisBuyerMakerisBuyerrs  rn  
commissionr  commissionAssert)r   r  isMakerr   r   )r  rC  rD  r  r1   r   r  r  takerOrMakerr  r  r   r  )r]  r  rF  r  r  r  
safe_traderG  )r  r  r  rC  priceStringamountStringmarketIdr  r  r1   r  
buyerMakerr  r  r  r  s                   r  parse_tradezbitrue.parse_trade  s   b ''w??	&&ug66''u55%%eX~FF!!(F33""5)44tY77^^E>::
..	22!'266UD#/55D5  **5,FF 33D4D4DUL^4_4_`` C ..	22&-:777L"Y//( " 
  
   	r  c                 X  K   |                                   d{V  |                     |          }d}|d         rAd|d         i}|||d<   |                     |                     ||                     d{V }nt	          | j        dz             |                     ||||          S )a2  
        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)rN  r  spotV1PublicGetTradesrZ  r$   r1   parse_trades)r  r  r  r  r  r  r  r_  s           r  fetch_tradeszbitrue.fetch_trades  s       !!!!!!!!!V$$&> 		S&,G  #( !77GV8T8TUUUUUUUUHHtw)QQRRR   65%@@@r  r  c           
      H    dddddddddd	}|                      |||          S )Nrx  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  sC    $ &")" 

 

 &&999r  r   c                    |                      |                     |dd                    }|                     |d          }|                     ||          }|                     |d          }d }d }d|v r|                     |d          }ngd|v r|                     |d          }nLd|v rH|dk    rBt          j        |d	          r|                     |d          }n|                     |d          }|                     |d
          }	|                     |d          }
|                     |d          }|                     |dd          }|                     |d          }|                     |d          }|                     |d          }|                     |dg           }|                     |d          }|                     |d          }|dk    p|dk    p|dk    }|dk    rd}| 	                    | 
                    |                     |d                              }|                     i d|d|d|d|d|                     |          d|d|d|d|d|d|d|
d |d!|d"|d#|	d$|d |d |d%|          S )&Nr  orderStatusr  executedQtyr   transactTimer:  rx  r   avgPricer  origQtycummulativeQuoteQtycumQuoter  r  r  fillsclientOrderIdr  limit_makerGTX	post_onlyr  	stopPricer  r1   rC  rD  lastTradeTimestamppostOnlyr  r  r   r~  filled)	remainingr  r  r   )r  rF  r  r  r  r,   	string_gtr'  r  r  	omit_zero
safe_orderrG  )r  r   r  r  r  r  r  rC  r  r~  r  r  r   r1   r  r  r  r  r  r  r  s                        r  parse_orderzbitrue.parse_order$  sX   n ((););E8])[)[\\##E844!!(F33!!%77	!U??))%88IIu$$))%@@IIU""$VS11 G)-):):5,)O)O&& $ 1 1% F FI""5*55  00!!%33 !!%)>
KKeY//%%eV44%%eV44ugr22((@@&&um<<M)]{e/C]Q\I\=  D((8H8HP[8\8\)])]^^  
E 
" 
 ] 
 	 

 Y// 
 !"4 
 f 
 D 
 ; 
  
 D 
 U 
 L 
 f 
 D 
  w! 
" f# 
$ + 
  
  
, -  	r  r   c                    K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d<   |                     |dd|d|           d{V S )aB  
        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>`
        Nr@   z9 createMarketBuyOrderWithCost() supports swap orders onlyFrn  r  rn  )rN  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~ 	ftw)ddeee6;23&&vxdFSSSSSSSSSr  r  r  r  r  c                   K   |                                   d{V  |                     |          }d}d}	|                                }
|                                |
d}|
dk    r2|t          | j        dz             |                     ||          |d<   |d         rg|
dk    }|                     |d          }|                     |d|          }|rd	|d
<   n|dk    rd|d
<   n|dk    rd|d
<   |d         |d<   d}|                     |ddd          \  }}|r|dk    r|r| 	                    |d          }| 
                    |d          }||t          | j        dz             |                     |          }|                     |          }t          j        ||          }||n|}|                     ||          |d<   |                     ||          |d<   n0|                     |          |d<   |                     |          |d<   d|d<   |                     |dd          }|rdnd|d<   | 	                    |d d!          }|                     |          |d <   | 
                    |g d"          }|d#         r0|                     |                     ||                     d{V }n7|d$         r/|                     |                     ||                     d{V }|                     |d%i           }	nH|d&         r(|d         |d'<   |                     ||          |d(<   |                     |d)         d*          }|                     |
|          s t          | j        d+z   |z   d,z   |z             |                     |d-d.          }|| 
                    |d-d.g          }||d-<   |                     |d/d0          }|1| 
                    |d/d0g          }|                     ||          |d0<   |                     |                     ||                     d{V }|}	nt5          | j        d1z             |                     |	|          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   rW  TrN   rn  rn  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OPENrx  r  1)r  r  r  r  r   r  rM  r>   r  quantityr  
orderTypes z% is not a valid order type in market newClientOrderIdr  r  r  z- createOrder only support spot & swap markets)rN  r  upperr!   r1   price_to_precisionr'  is_post_onlyhandle_option_and_paramsr  r  number_to_stringr,   r  cost_to_precisionparse_to_numericrE  fapiV2PrivatePostOrderrZ  dapiV2PrivatePostOrderr  amount_to_precisionr  in_arrayrF  spotV1PrivatePostOrderr$   r  )r  r  r  r  r  r  r  r  r  rM  uppercaseTyper_  isMarketr  r  rn  r   r  r  quoteAmountrequestAmountr  r  validOrderTypesr  r  s                             r  r  zbitrue.create_order  s(     2 !!!!!!!!!V$$

JJLL!
 
 G##}"47-W#WXXX#66vuEEGG&> 8	Z$0H00GGK((4@@H ("-%%"'%%"'&,TlGN#04-8<8U8UV\^k  nQ  SW  9X  9X5-v BTU]]0Q]''776622=T\&tw  2R  (R  S  S  S#'#8#8#@#@L"&"7"7">">K")"4\;"O"OK-1-=DDKM(,(>(>v}(U(UGH%(,(>(>v}(U(UGH%%$($9$9&$A$A!$($9$9&$A$A!&'GN#**6<OOJ)3?ggGFO''
C@@H"&"7"7"A"AGJYYv'_'_'_``Fh [!%!<!<T[[RX=Y=Y!Z!ZZZZZZZ	" [!%!<!<T[[RX=Y=Y!Z!ZZZZZZZ>>(FB77DDF^ 	Z &tGH"&":":66"J"JGJ"oofVnlKKO==@@ l"47S=4#7:a#adj#jkkk ..v7I?[[M(6,>+PQQ.;*+,,V^[QQL'6NK+HII'+'>'>v|'T'T$!88Wf9U9UVVVVVVVVHDDtw)XXYYY, f---r  r1   c                 X  K   |t          | j        dz             |                                  d{V  |                     |          }|                     |dd          }|                     |ddg          }d}d}i }|||d<   n|d         r||d<   n||d<   |d         r|d         |d<   |d	         r0|                     |                     ||                     d{V }n7|d
         r/|                     |                     ||                     d{V }| 	                    |di           }na|d         rB||d<   |d         |d<   | 
                    |                     ||                     d{V }|}nt          | j        dz             |                     ||          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   rW  r   r  rM  r>   r  z, fetchOrder only support spot & swap markets)r   r1   rN  r  rE  r  fapiV2PrivateGetOrderrZ  dapiV2PrivateGetOrderr  spotV1PrivateGetOrderr$   r  	r  r1   r  r  r  r  r  rM  r_  s	            r  fetch_orderzbitrue.fetch_order"  s      >#DG.X$XYYY!!!!!!!!!V$$ --f6I?[[6$7#IJJ$!#GIf~ A+<((/@+,&> 	Y&,TlGN#h Z!%!;!;DKKQW<X<X!Y!YYYYYYY	" Z!%!;!;DKKQW<X<X!Y!YYYYYYY>>(FB77DDF^ 	Y!#GI &tGH!77GV8T8TUUUUUUUUHDDtw)WWXXXX f---r  c                   K   |t          | j        dz             |                                  d{V  |                     |          }|d         st	          | j        dz             d|d         i}|||d<   |||d<   |                     |                     ||                     d{V }|                     ||||          S )	aO  
        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  r1   	startTimer  )r   r1   rN  r  r$   spotV1PrivateGetAllOrdersrZ  parse_orders)r  r  r  r  r  r  r_  r  s           r  fetch_closed_orderszbitrue.fetch_closed_ordersy  s       >#DG._$_```!!!!!!!!!V$$f~ 	Ytw)WWXXXfTl
 #(GK $GG77GV8T8TUUUUUUUU.   65%@@@r  c                   K   |t          | j        dz             |                                  d{V  |                     |          }d}d}i }|d         r|d         |d<   |d         r0|                     |                     ||                     d{V }n7|d         r/|                     |                     ||                     d{V }|                     |dg           }n\|d	         r=|d         |d
<   |                     |                     ||                     d{V }|}nt          | j        dz             | 
                    ||||          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   rW  r   r  rM  r>   r  z1 fetchOpenOrders only support spot & swap markets)r   r1   rN  r  fapiV2PrivateGetOpenOrdersrZ  dapiV2PrivateGetOpenOrdersr  spotV1PrivateGetOpenOrdersr$   r  	r  r  r  r  r  r  r  rM  r_  s	            r  fetch_open_orderszbitrue.fetch_open_orders  s      >#DG.]$]^^^!!!!!!!!!V$$&> 	^&,TlGN#h _!%!@!@WV\A]A]!^!^^^^^^^	" _!%!@!@WV\A]A]!^!^^^^^^^>>(FB77DDF^ 	^ &tGH!<<T[[RX=Y=YZZZZZZZZHDDtw)\\]]]^   vue<<<r  c                 N  K   |t          | j        dz             |                                  d{V  |                     |          }|                     |dd          }|                     |ddg          }d}d}i }|||d<   n|d         r||d<   n||d<   |d         r|d         |d<   |d	         r0|                     |                     ||                     d{V }n7|d
         r/|                     |                     ||                     d{V }| 	                    |di           }n\|d         r=|d         |d<   | 
                    |                     ||                     d{V }|}nt          | j        dz             |                     ||          S )aC  
        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   rW  r   r  rM  r>   r  z- cancelOrder only support spot & swap markets)r   r1   rN  r  rE  r  fapiV2PrivatePostCancelrZ  dapiV2PrivatePostCancelr  spotV1PrivateDeleteOrderr$   r  r  s	            r  cancel_orderzbitrue.cancel_order 	  s      >#DG.Y$YZZZ!!!!!!!!!V$$ --f6I?[[6$7#IJJ$!#GIf~ A+<((/@+,&> 	Z&,TlGN#h \!%!=!=dkk'SY>Z>Z![![[[[[[[	" \!%!=!=dkk'SY>Z>Z![![[[[[[[>>(FB77DDF^ 	Z &tGH!::4;;wPV;W;WXXXXXXXXHDDtw)XXYYY* f---r  c                   K   |                                   d{V  |                     |          }d}d}|d         rd|d         i}|d         r0|                     |                     ||                     d{V }n7|d         r/|                     |                     ||                     d{V }|                     |dg           }nt          | j        dz             |                     ||          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@   rW  r1   r   r  rM  z, cancelAllOrders only support future markets)	rN  r  fapiV2PrivatePostAllOpenOrdersrZ  dapiV2PrivatePostAllOpenOrdersr  r$   r1   r  r  s          r  cancel_all_orderszbitrue.cancel_all_orders@	  s3      !!!!!!!!!V$$&> 
	YtG h c!%!D!DT[[QXZ`EaEa!b!bbbbbbb	" c!%!D!DT[[QXZ`EaEa!b!bbbbbbb>>(FB77DDtw)WWXXX   v...r  c                   K   |                                   d{V  |t          | j        dz             |                     |          }d}d}i }|||d<   ||dk    rd}||d<   |d         r|d         |d<   |d	         r0|                     |                     ||                     d{V }n7|d
         r/|                     |                     ||                     d{V }|                     |dg           }n\|d         r=|d         |d<   |                     |                     ||                     d{V }|}nt          | j        dz             | 
                    ||||          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  r   r  r@   r1   rW  r   r  rM  r>   r  z/ fetchMyTrades only support spot & swap markets)rN  r   r1   r  fapiV2PrivateGetMyTradesrZ  dapiV2PrivateGetMyTradesr  spotV2PrivateGetMyTradesr$   r  r"  s	            r  fetch_my_tradeszbitrue.fetch_my_tradesf	  s      !!!!!!!!!>#DG.[$[\\\V$$#(GK t||$GG&> 	\&,TlGN#h ]!%!>!>t{{7TZ?[?[!\!\\\\\\\	" ]!%!>!>t{{7TZ?[?[!\!\\\\\\\>>(FB77DDF^ 	\ &tGH!::4;;wPV;W;WXXXXXXXXHDDtw)ZZ[[[\   vue<<<r  r  c                   K   |t          | j        dz             |                                  d{V  |                     |          }|d         dd}|||d<   |||d<   |                     |                     ||                     d{V }|                     |dg           }|                     ||||          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>`
        Nz) fetchDeposits() requires a code argumentr1   r   r  r  r  r  rM  )r   r1   rN  r  spotV1PrivateGetDepositHistoryrZ  r  parse_transactions	r  r  r  r  r  r  r_  r  rM  s	            r  fetch_depositszbitrue.fetch_deposits	  s       <#DG.Y$YZZZ!!!!!!!!!==&&TN
 
 #(GK $GG<<T[[RX=Y=YZZZZZZZZJ ~~h33&&tXueDDDr  c                   K   |t          | j        dz             |                                  d{V  |                     |          }|d         dd}|||d<   |||d<   |                     |                     ||                     d{V }|                     |dg           }|                     ||          S )	a4  
        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 argumentr1   r   r3  r  r  rM  )r   r1   rN  r  spotV1PrivateGetWithdrawHistoryrZ  r  r5  r6  s	            r  fetch_withdrawalszbitrue.fetch_withdrawals
  s       <#DG.\$\]]]!!!!!!!!!==&&TN
 
 #(GK $GG==dkk'SY>Z>Z[[[[[[[[0 ~~h33&&tX666r  c                 v    dddddddd}|                      ||i           }|                     |||          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_type9
  sd      
  
 
 
 
 >>.$;;&&999r  transactionr  c                    |                      |dd          }|                     |d          }|                     |d          }|                     |d          }d }d }||A|                    d          }	|                     |	d          }|                     |	d          }|A|                    d          }	|                     |	d          }|                     |	d          }|                     |d	          }
|                     |d
          }|                     |d          }d|v }d|v }|s|rdnd}|                     |                     |d          |          }|                     |d          }d }|                      |dd          }|W|                    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"S )#Nr1   
withdrawIdtagType	addressToaddressFrom_r   r   txid	createdAt	updatedAt	payAmountr  r?  r  r  r  r  r  r  )r  r   r  rC  rD  r  addresstagtagTotagFromr  r  r  F)internalcommentr  )	rF  r  r(  r  rA  r  r  r  rG  )r  rB  r  r1   rE  rF  rG  rO  rP  partsrI  rC  r  rL  r  r  r  r  r  rJ  r  r  feeCostr  s                           r  parse_transactionzbitrue.parse_transactionH
  s?   z T<@@"";	::$$[+>>	&&{MBB$!,, ,,UA66	((22&#))#.."..ua88**5!44V44%%k;??	##K== K/	K' )BUB||66t7G7GU]7^7^`dee!!+x88''XvFF
!$$S))E))%33J((22I$#//++&&z8<<"";66#W55C
K
"
 D
 	

 Y//
 w
 y
 
 ;
 5
 U
 w
 D
 f
 
  f!
" w#
$ )
 
 
 	
r  rM  rN  c                   K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }|d         ||d}d}|                     |          \  }}||                     |          |d<   |||d<   |                     |                     ||                     d{V }	|                     |	di           }
| 	                    |
|          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>`
        Nr1   )r  r  rF  	chainNamerN  rM  )
handle_withdraw_tag_and_paramscheck_addressrN  r  handle_network_code_and_paramsnetwork_code_to_idspotV1PrivatePostWithdrawCommitrZ  r  rU  )r  r  r  rM  rN  r  r  r_  networkCoder  rM  s              r  r   zbitrue.withdraw
  s/      99#vFFV7###!!!!!!!!!==&&TN 
 
 "AA&IIV"#'#:#:;#G#GGK ? GEN==dkk'SY>Z>Z[[[[[[[[  ~~h33%%dH555r  c                    |                      |dg           }t          |          }|d d dd d di d}|dk    rt          d|          D ]}||         }|                     |d          }|                     |d          }	|                     ||	          }
d d d|                     |d          ddd	|d
         |
<   |dk    r*|                     |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  currencyCoder]  s              r  parse_deposit_withdraw_feez!bitrue.parse_deposit_withdraw_fee
  sJ    ~~c="==--" 
 "  
 
 !!1/00 = =*1o ,,['BB	#//&AA"55iNN'+4@@(,(8(8m(T(Tdi j j3 3z";/ %))040@0@m0\0\F:&u-7<F:&|4r  codesc                    K   |                                   d{V  |                     |           d{V }|                     |d          }|                     ||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>`
        Nr  r  )rN  r  r  parse_deposit_withdraw_fees)r  rc  r  r  r  s        r  fetch_deposit_withdraw_feesz"bitrue.fetch_deposit_withdraw_fees  s|       !!!!!!!!!99&AAAAAAAAx11//ufEEEr  c           
      v   |                      |d          }d }d }|A|                    d          }|                      |d          }|                      |d          }|                     |d          }|d ||                     |          |                      |d          |                     |d          ||dd		S )
NtransferType_to_r   r   r  r  r  r  )	r  r1   rC  rD  r  r  fromAccount	toAccountr  )r  r(  r  rG  r  )r  r   r  rh  rj  rk  accountSplitrC  s           r  parse_transferzbitrue.parse_transfer(  s      ''.AA	#'--f55L**<;;K((q99I%%h88	"Y//((6::&&x::&"

 

 
	
r  c                   K   |                                   d{V  |                     |dd          }d|i}d}| |                     |          }|d         |d<   |||d<   ||dk    rd}||d<   |                     |d	          }||                     |d	          }||d
<   |                     |                     ||                     d{V }	|                     |	dg           }
|                     |
|||          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>`
        Nr  rh  r1   
coinSymbol	beginTime   r  r  endTimerM  )	rN  rF  r  r  r  &fapiV2PrivateGetFuturesTransferHistoryrZ  r  parse_transfers)r  r  r  r  r  r  r_  r  r  r  rM  s              r  fetch_transferszbitrue.fetch_transfersL  sG      !!!!!!!!!!!&&.AAD
 }}T**H$,TNGL!#(GK s{{$GG!!&'22YYvw//F!&GIDDT[[QXZ`EaEabbbbbbbb ~~h33##D(E5AAAr  rj  rk  c                   K   |                                   d{V  |                     |          }|                     | j        di           }|                     |||          }|                     |||          }	|d         |                     ||          |dz   |	z   d}
|                     |                     |
|                     d{V }|                     |di           }|                     ||          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>`
        Nry  r1   ri  )ro  r  rh  rM  )	rN  r  r  r   r  currency_to_precision fapiV2PrivatePostFuturesTransferrZ  rm  )r  r  r  rj  rk  r  r  accountTypesfromIdtoIdr_  r  rM  s                r  r   zbitrue.transfer  s      !!!!!!!!!==&&~~dl4DbII!!,[IIiCC"4.00v>>"VOd2
 

 >>t{{7TZ?[?[\\\\\\\\ ~~h33""4222r  r  c                   K   |t          | j        dz             |dk     s|dk    rt          | j        dz             |                                  d{V  |                     |          }d}|d         |d}|d         st          | j        d	z             |d
         r0|                     |                     ||                     d{V }n7|d         r/|                     |                     ||                     d{V }|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   )rW  r  r@   z& setLeverage only support swap marketsr   r  )	r   r1   r   rN  r  r$   fapiV2PrivatePostLevelEditrZ  dapiV2PrivatePostLevelEdit)r  r  r  r  r  r  r_  s          r  set_leveragezbitrue.set_leverage  sJ      >#DG.Y$YZZZqLLhnnTW'NNOOO!!!!!!!!!V$$"4L 
 
 f~ 	Stw)QQRRR( 	[!<<T[[RX=Y=YZZZZZZZZHHI 	[!<<T[[RX=Y=YZZZZZZZZHr  c                 (    ||d         d dd d d d d d d
S )Nr  isolated)
r  r  r  r  r  totalr  r  rC  rD   )r  rM  r  s      r  parse_margin_modificationz bitrue.parse_margin_modification  s6     X&$
 
 	
r  c                   K   |                                   d{V  |                     |          }|d         st          | j        dz             d}|d         |                     |          d}|d         r0|                     |                     ||                     d{V }n7|d         r/|                     |                     ||                     d{V }|                     ||          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>`
        Nr@   z$ setMargin only support swap marketsr1   )rW  r  r   r  )	rN  r  r$   r1   r  fapiV2PrivatePostPositionMarginrZ  dapiV2PrivatePostPositionMarginr  )r  r  r  r  r  r  r_  s          r  
set_marginzbitrue.set_margin  s)      !!!!!!!!!V$$f~ 	Qtw)OOPPP"4L++F33
 
 ( 	`!AA$++gW]B^B^________HHI 	`!AA$++gW]B^B^________H --h???r  r   GETc                 D   |                      |d          }|                      |d          }|                      |d          }	d }
|dk    r|dk    s|dk    r-|                    d          dk    r| j        d         |         }
n| j        d         |         dz   |z   }
|
dz   |                     ||          z   }
|                     ||                     |                    }|	d	k    r|                                  |                     | j        d
d          }|dk    s|dk    r| 	                    | 
                    |                                 |d|                    }|                     |                     |          |                     | j                  t          j                  }|d|z   z  }d| j        i}|dk    s|dk    r
|
d|z   z  }
n|}d|d<   nt%          |                                           }d }|dk    rd}n|dk    rd}|dz   |z   dz   |z   }||z   |z   }|dk    rt'          |                                          }t+          |          }|dk    r|d| 	                    |          z   z  }|                     |                     |          |                     | j                  t          j                  }| j        ||d}|
d| 	                    |          z   z  }
n| 
                    d
|i|          }|                     |          }||z  }|                     |                     |          |                     | j                  t          j                  }d| j        ||d}n|r|
d| 	                    |          z   z  }
|
|||dS )Nr   r   r  r   r   rx  	listenKeyr  r   rr  r  r>   )rC  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   	urlencoderZ  r  hmacencodesecrethashlibsha256apiKeystrr  r  r  json)r  pathr   r  r  r  r  r  r9   accessr  rr  query	signaturerC  signPathsignMessager  r  s                      r  signzbitrue.sign  s   Q''""3**!!#q))EMMg00dfnnS^I_I_cdIdId)E"4(CC)E"4(3.8CCi$--dF;;;64#6#6t#<#<==Y++---**4<tLLJv~~t{{!%",4 4 ( (   !IIdkk%&8&8$++dk:R:RT[Tbcc	+i77"DK eOO8););3;&CC D.QGN++

--	6>>&HHV^^&H#c>G3c9D@'&08;U??..D!$TJ!A~~#sT^^F-C-C'CC $		$++k*B*BDKKPTP[D\D\^e^l m mI'+{%.#, G
 3!7!777CC KK$j) E  99U++D4'K $		$++k*B*BDKKPTP[D\D\^e^l m mI(:'+{%.#,	 GG  4sT^^F3333fdwOOOr  reasonr  r  r  r  c
                    |dk    s|dk    r3t          | j        dz   t          |          z   dz   |z   dz   |z             |dk    r|                    d          dk    rt	          | j        dz   |z             |                    d          dk    rt	          | j        d	z   |z             |                    d
          dk    rt	          | j        dz   |z             |d S |                     |dd          }
|
sM|                     |d          }d }|3	 t          j        |          }n# t          $ r}d }Y d }~nd }~ww xY w||}|                     |d          }|Z| 
                    | j        d         || j        dz   |z              |                     | j        d         || j        dz   |z              |                     |d          }||dk    st          j        |d          rd S |dk    r'| j        d         rt          | j        dz   |z             | j        dz   |z   }| 
                    | j        d         ||           t!          |          |
st!          | j        dz   |z             d S )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_errors>  s   CKKTS[[ 3T!:S!@6!IC!ORV!VWWW 3;;yy6771<<"47-\#\_c#cdddyy$$))"47-d#dgk#klllyy((A--"47  .g  $g  jn  $n  o  o  o4 ..9d;; 
	-++He<<L M')$(J|$<$<MM  ) ) )$(MMMMMM) !,,H""8U33001I7TXT[^aTadkTklll001I7TXT[^aTadkTklll  622 7#8#D#Dt   dl3X&Y $TW/D%Dt%KLLLw}t+H001I5RZ[[[))) 	6# 4555ts   D, ,
E6D==Ec                     d|v rd|vr|d         S d|v rRd|v rN|d         }|d         }t          dt          |                    D ] }||         }	||	d         k    r
|	d         c S !|                     |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_costr  s    &  8v+=+=*%%6!!6(9(97OEY'G1c'll++ $ $
E!H$$ 8OOO %vvq111r  )N)I__name__
__module____qualname__r   r  r  r  r	   r  r   r  r   r   r   dictr8  r   rK  rU  r  r   ra  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,  r1  r   r7  r:  rA  r   rU  r   rb  rf  rm  r   ru  r   intr  r
   r  r  r  r  r  __classcell__)r  s   @r  r.   r.   #   s7	       E
# E
 E
 E
 E
 E
 E
ND D D )+ 
 
 
 
4 ') 9 9S 9 9 9 9" -/ f f: f f f fP *, g+ g+V g+ g+ g+ g+Ra
4 a
F a
 a
 a
 a
F>) >) >) >) >)@ *, k* k* k* k* k* k*Z @DB C CS C CS\ C C C CJA A4 A A6 A A A AF 68 G/ G/ G/F G/ G/ G/ G/R ?CQUdhqs SH SH SH SH3 SH^a SHx|  ~B  yC SH SH SH SHj#
 #
 #
4 #
 #
 #
 #
J 8<B :1 :1W :1 :1 :1 :1x 6:" P4 P47 P4 P4 P4 P4 P4dW W Wv W W W W Wr <@d[] 'A 'A 'AS 'A 'Abfglbm 'A 'A 'A 'AR: : : : :n n nv n n n n n` XZ T Tc T T T T T& mqy{ y. y. y.I y.Y y.X] y.fi y. y. y. y.v 8<B U. U.C U. U. U. U. U.n 7;\`ik 4A 4A 4A3 4AVY 4Aptuzp{ 4A 4A 4A 4Al 59tZ^gi O= O=c O= O=TW O=nrsxny O= O= O= O=b 9=R >. >.S >.# >. >. >. >.@ 59 $/ $/c $/ $/ $/ $/L 37TX\eg T= T=C T=s T=RU T= T= T= T=l 04$UYbd CE CE CEC CEs CEimnyiz CE CE CE CEJ 37TX\eg 67 67C 67s 67RU 67lpq|l} 67 67 67 67p: : : :v
 v
T v
X v
Q\ v
 v
 v
 v
p QU]_ 16 163 16 16 16# 16do 16 16 16 16f$ $ $ $ $ $L BFb F Fw F F F F"
 "
 "
 "
H 154VZce 1B 1B# 1BS 1BPS 1Bjno|j} 1B 1B 1B 1Bf ac !3 !33 !3 !3C !3TW !3gt !3 !3 !3 !3F ?C2  3     >
 
>P 
 
 
 
. CE  @  @s  @E  @I[  @  @  @  @D &eBSW BP BP BP BPH2# 2s 2 2c 2TX 2`c 2 2 2 2h MO 
2 
2 
2 
2 
2 
2 
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 5 5 5 5 5 , , , , , ,    P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P       * * * * * * 0 0 0 0 0 0 - - - - - - - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * 5 5 5 5 5 5 ) ) ) ) ) ) + + + + + + . . . . . . 1 1 1 1 1 1 * * * * * * ) ) ) ) ) ) 3 3 3 3 3 3 4 4 4 4 4 4 % % % % % %Y12 Y12 Y12 Y12 Y12X{ Y12 Y12 Y12 Y12 Y12r  