
    i                       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 d dlmZ d dlmZ d dlmZ d dlmZ d d	lm Z  d d
lm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dlm(Z( d dlm)Z) d dlm*Z* d dlm+Z+ d dlm,Z, d dlm-Z- d dl.m/Z/ d dl.m0Z0 d dl1m2Z2  G d dee          Z3dS )    )Exchange)ImplicitAPIN)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 fdZdEdZd Zi fdZi fdZd Zi fde	fd	Z
i fdee         fd
Z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dEdedefdZi fdedefdZdddi fdedededee         fdZdEdedefdZdi fdefdZdi fdedefdZdEdede fdZ!ddi fdedededee          fdZ"d Z#dEdede$fdZ%i fdede&fd Z'di fded!e(d"e)d#e&d$e*f
d%Z+di fd&ede,fd'Z-dddi fde,dededee$         fd(Z.dddi fde,dededee$         fd)Z/di fd&ede,fd*Z0di fde,fd+Z1dddi fde,dedefd,Z2dddi fd-e,dededee3         fd.Z4dddi fd-e,dededee3         fd/Z5dEd0Z6dEd1e7de3fd2Z8di fd-ed#e&fd3Z9dEd1e7fd4Z:di fd5efd6Z;dEd7Z<dddi fd-e,dedefd8Z=i fd-ed#e&d9ed:ede>f
d;Z?di fd<ede,fd=Z@dEdeAfd>ZBi fded#e&deAfd?ZCd@dAi ddfdBZDdC ZEi fdDZF xZGS )Fbitruec                 b   |                      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
d0d
d1dd2di d3dd4dd5dd6dd7d
d8d
d9dd:dd;dd<dd=dd>d
d?d
d@d
dAd
dBddCddddddDdEdFdGdHdIdJdKdLdMdNdO	dPdQdRdSdTdUdVdWdXdYdZgd[d\d]d^d_d`d`daiid_d`d`d`d`dbd`gdcddgddeggdfd`ddd`d`dgdhd`didhd`didhd`djid`d`dddddddgdhd`d`d`dkdld`dmdnd`idodpdqd_drddiiidsd^d_d`d`d`d`d`d`dtiidqd`d`d`d`d`d`d`d`dud`d`d`d`d`d`dvdwidxd^d_d`d`d`d`d`d`dtiidqd`d`d`d`d`d`d`d`dud`d`d`d`d`d`dvdwidxdydzd_d
d|                     d{          |                     d{          d|d}d~d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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g ddd
ddd
d
ddddddddFdGdHdIdJdKdLddMdNd
dddddddddddddddddddddidt
          di 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           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          d t          dt          dt          dt(          dt           dt          dt          dt          dt          d	t          t          t          d
d          S (  Nidr-   nameBitrue	countriesSG	rateLimit  	certifiedFversionv1proThasCORSspotmarginswapfutureoptioncancelAllOrderscancelOrdercreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBidsAsksfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingRatefetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchMarginModefetchMarketsfetchMyTrades
fetchOHLCVfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionModefetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeesfetchTransactionsfetchTransfersfetchWithdrawals)setLeverage	setMargintransferwithdraw
timeframes1m5m15m30m1H2H4H1D1W)	rt   ru   rv   rw   1h2h4h1d1wurlszdhttps://user-images.githubusercontent.com/1294454/139516488-243a830d-05dd-446b-91c6-c1f18fe30c63.jpgzhttps://www.bitrue.com/apizhttps://fapi.bitrue.com/fapizhttps://fapi.bitrue.com/dapiz https://www.bitrue.com/kline-api)r<   fapidapiklinezhttps://www.bitrue.comzEhttps://www.bitrue.com/affiliate/landing?cn=600000&inviteCode=EZWETQEz;https://github.com/Bitrue-exchange/bitrue-official-api-docszhttps://www.bitrue.com/api-docsz;https://bitrue.zendesk.com/hc/en-001/articles/4405479952537)logoapiwwwreferraldocfeesr   publicget   )zpublic.jsonzpublic{currency}.jsond   i     
   )costbyLimit(   )r   noSymbol   )pingtimeexchangeInfodepthtradeshistoricalTrades	aggTradeszticker/24hrzticker/pricezticker/bookTickerzmarket/kline)order
openOrders	allOrdersaccountmyTradeszetf/net-value/{symbol}zwithdraw/historyzdeposit/history   )r   zwithdraw/commitr   )r   postdelete)r   privater   r   )r   r8   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   )r8   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   r?   deliveryoptionsr<   linearinversev2PrivateGetMyTrades  r   FULL)marketlimitETHTRX)ERC20TRC2012H)
rt   ru   rv   rw   r}   r~   r   12hr   r   1min5min15min30minr}   1day1week1month)rt   ru   rv   rw   r}   r   r   1M)r<   r?   walletcontract)r<   r?   r>   fundingfundr   )!createMarketBuyOrderRequiresPricer\   fetchMyTradesMethod#hasAlreadyAuthenticatedSuccessfully
recvWindowtimeDifferenceadjustForTimeDifferenceparseOrderToPrecisionnewOrderRespTypenetworksdefaultTypers   accountsByTypecommonCurrenciesMIMz	MIM SwarmprecisionMode
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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   )self	__class__s    _/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/bitrue.pyr   zbitrue.describe%   s   fd 3 3 < < > > tA
(tA
HtA
 $tA
 	tA

 tA
 ttA
 4tA
  888 %8 	8
 %8 %8 "48 t8 /8 ,U8 08 t8 '8 (8 "48  !8"  #8 8$ +E%8& )%'8( $T)8* '+8, (-8. "4/80 &u182  384 +E586 *:788 +D98: #E;8< *5=8> +E?8@ "5A8B C8D  E8 8 8F dG8H "4I8J dK8L !$M8N uO8P $UQ8R tS8T tU8V W8X TY8Z t[8\ "5]8^ #E_8` 'a8b $Uc8d !$e8f #Dg8 8h  $!  o8 8 8tA
D 
 
EtA
Z ~8::?	  0cQ5 V [tA
z  !!/09:$ $# "()()0123#qCQR8VZ\^U_@`)a)a*+45-.89r/J/J9:0J0J>?Q5O5O01$ $#" *+./-.+,56B,G,G:;4534	$ 	$ *+34% %
 !('$ $!# #J "! *A$$[4 4n !!()()-.)**+*+$ $	# ",-./)*+,3423<=67	$ 	$ 34./*+)*1245% %$ $# #L !!()()-.)**+*+$ $	# ",-./)*+,3423<=67	$ 	$ 34./*+)*1245% %$ $# #u~ ~{tA
x $!&"&!..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ytA
X	 59! ! ! (>7<&"#+0).$#% %
 #"   & #"$$"""$""  %$&&"$%&	 	 2 %(&'$ *# #_7 7Y	tA
H {!ItA
N YOtA
R 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 3C$0 MJ JStA
 t t t	    Nc                     |                      | j        |         d          9|                     |t          | j        |         d         | j        | j                  S |                     |          S )N	precision)
safe_value
currenciesdecimal_to_precisionr)   r   paddingModenumber_to_string)r   codefeenetworkCodes       r   currency_to_precisionzbitrue.currency_to_precision  so    ??4?40+>>J,,S(DOD<QR]<^`d`rtx  uE  F  F  F((---r   c                 F    |                                  | j        d         z
  S )Nr   )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 )ai  
        the latest known information on the availability of the exchange API
        :see: 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 )al  
        fetches the current integer timestamp in milliseconds from the exchange server
        :see: 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                    |                                 }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"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/d0d0d1d1d2d2d3d3d4d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdE}|                     ||||          S )FN	AeternityAIONAlgorandASKATOMzAVAX C-ChainbchBCHBEP2BEP20BitcoinBRP20CardanoADA
CasinoCoinzCasinoCoin XRPL	ContentosDashDecoin	DeFiChainDGBDividogecoinDOGEEOSr   ETCFilecoinFREETONHBARzHedera HashgraphHRC20ICONICPIgniszInternet ComputerIOTAKAVAKSMLiteCoinLunaMATICzMobile CoinMonaCoinMoneroNEMNEP5OMNIPACPolkadot	RavencoinSafexSOLANASOLSongbirdStellar LumensSymbolXTZthetaTHETAr   VeChainVECHAINWanchainXinFin NetworkXRPXRPLZIL)rS  rT  rU  TezosrW  rX  r   rY  rZ  r[  r\  r]  r^  r_  )uppersafe_string_2)r   	networkIduppercaseNetworkIdnetworksByIds       r   safe_networkzbitrue.safe_network  sN   &__..B
B
FB
 
B
 5	B

 FB
 NB
 5B
 5B
 FB
 WB
 yB
 WB
 uB
 ,B
 0B
  !B
" F#B
 B
$ h%B
& 'B
( 5)B
* F+B
, -B
. 5/B
0 W1B
2 53B
4 
5B
6 y7B
8 F9B
:  2;B
< W=B
> F?B
@ 5AB
B WCB
D  !4EB
 B
 B
F FGB
H FIB
J 5KB
L 
MB
N FOB
P WQB
R =SB
T 
UB
V hWB
X 5YB
Z F[B
\ F]B
^ 5_B
` 
aB
b cB
d WeB
f egB
 B
h #.  ".CB
 B
 B
F !!,	;MyYYYr   returnc                   K   |                      |           d{V }i }|                     |dg           }t          dt          |                    D ]0}||         }|                     |d          }|                     |d          }|                     |          }	d}
d}d}d}d}|                     |dg           }i }t          dt          |                    D ]Q}||         }|                     |d          }|                     ||	          }|                     |d          }|r|n|
}
|                     |d	          }|r|n|}|                     |d
          }|||nt          j        ||          }|                     |d          }|||nt          j        ||          }|                     |d          }|||nt          j	        ||          }||||||o|| 
                    |          dd| 
                    |          | 
                    |          did	||<   S|||	d||
o||
||| 
                    |          d| 
                    |          | 
                    |          did||	<   2|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withdrawFeeminWithdrawmaxWithdrawrr   minmax)	r  r/   networkdepositrr   activer  r   limits)r/   r0   r  r   r  rx  rw  rr   r   r  ry  )spotV1PublicGetExchangeInfor   ranger  safe_stringsafe_currency_codenetwork_id_to_coder+   
string_min
string_maxr   )r   r  r  resultri  icurrencyr/   r0   r  rw  rr   minWithdrawStringmaxWithdrawStringminWithdrawFeeStringnetworkDetailsr   jentryrc  rv  rn  ro  networkWithdrawFeeStringnetworkMinWithdrawStringnetworkMaxWithdrawStrings                             r   fetch_currencieszbitrue.fetch_currenciesT  s_      99&AAAAAAAA^ '266q#e**%% ?	 ?	AQxH!!(F33B##Hm<<D**2..DGH $ $#' !__X}bIINH1c.1122    &q) ,,UG<<	11)TBB $ G G,9G--!%8H!I!I.<K>>8+/+;+;E=+Q+Q(+7H\Hd+C+Ckrk}  W  Ym  ln  ln(+/+;+;E=+Q+Q(+7EVE^(@(@elew  yQ  Sd  fe  fe%+/+;+;E=+Q+Q(+7EVE^(@(@elew  yQ  Sd  fe  fe%!#&, .+>,,-EFF!%"#'#4#45M#N#N#'#4#45M#N#N% %% %!!" ! !.h"$$(()=>> #001BCC#001BCC! ! F4LL& r   c                   K   g }|                      | j        dg 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
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#exchangeInfo_endpoint
        :see: https://www.bitrue.com/api-docs#current-open-contract
        :see: https://www.bitrue.com/api_docs_includes_file/delivery.html#current-open-contract
        :param dict [params]: extra parameters specific to the exchange api endpoint
        :returns dict[]: an array of objects representing market data
        r\   r   r   r<   r   r   z+ fetchMarkets() self.options fetchMarkets "z " is not a supported market typeNsymbolsr   r   r   )r   r   r{  r  appendrz  fapiV1PublicGetContractsdapiV1PublicGetContractsr   r/   asynciogatherarray_concatload_time_differenceparse_markets)r   r  promisesRawr\   r  
marketTypepromisesspotMarketsfutureMarketsdeliveryMarketsmarketss              r   fetch_marketszbitrue.fetch_markets  s      t|^EbEbEbccq#l++,, 		O 		OA%a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   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minOrderMoneyr/   lowercaseIdr   r   settlebaseIdquoteIdsettleIdtyper=   Fr?   r@   rx  TRADINGr   )amountpricers  minQtyminPricemaxPrice)leverager  r  r   )r   r   contractSizeexpiryexpiryDatetimestrike
optionTyper   ry  createdr  )r|  safe_string_lowerr   splitr}  r   index_bysafe_numberr   r+   
string_absparse_precision)r   r   r/   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//&)R88g|<<!!&(33oom^RHH}j"EE $ 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  rb  r}  r   iso8601safe_balance)
r   r  r  r  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
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#account-information-user_data
        :see: https://www.bitrue.com/api-docs#account-information-v2-user_data-hmac-sha256
        :see: 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>`
        NrJ   r>   r   data)load_marketshandle_market_type_and_paramshandle_sub_type_and_paramsdapiV2PrivateGetAccountr   fapiV2PrivateGetAccountspotV1PrivateGetAccountr  )r   r  r  subTyper  r  s         r   fetch_balancezbitrue.fetch_balance  sO      !!!!!!!!!99.$PVWWf99.$PVWW6>>"w)';';!%!=!=f!E!EEEEEEE62>>@ "&!=!=f!E!EEEEEEE62>>@ "99&AAAAAAAAHF$ !!&)))r   r  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<   |S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#order-book
        :see: https://www.bitrue.com/api-docs#order-book
        :see: 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>   contractNamer/   r   r   r   r   r<   r  r5   z0 fetchOrderBook only support spot & swap marketsr   lastUpdateIdr  )
r  r   fapiV1PublicGetDepthextenddapiV1PublicGetDepthspotV1PublicGetDepthr#   r/   r   parse_order_book)	r   r  r   r  r   r  requestr  	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 %%h77	))(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  r  r  high	highPricelowlowPricebidbidPricebuy	bidVolumebidQtyaskaskPricesell	askVolumeaskQtyvwapweightedAvgPriceopen	openPriceclosepreviousClosechangepriceChanger   averagevolumevolquoteVolume)
baseVolumer!  r  )safe_symbolrb  r   r+   
string_mulr|  safe_tickerr  )r   r   r   r  r  r  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 )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#24hr-ticker-price-change-statistics
        :see: https://www.bitrue.com/api-docs#ticker
        :see: 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>   r  r/   r   r   r<   r  r   z- fetchTicker only support spot & swap markets)
r  r   fapiV1PublicGetTickerr  dapiV1PublicGetTickerspotV1PublicGetTicker24hrr   r#   r/   r&  r   r  r  r   r  r  r  s          r   fetch_tickerzbitrue.fetch_ticker  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??8Q33DDtw)XXYYYN   v...r   rt   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{V }|                     |dg           }	nt          | j
        dz             |                     |	||||          S )aJ  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#kline-data
        :see: https://www.bitrue.com/api-docs#kline-candlestick-data
        :see: https://www.bitrue.com/api_docs_includes_file/delivery.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
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        Nrs   r>   r?   r/   r   )r  intervalr   r   r   r<   rt   )r  scalefromIdxr  z, fetchOHLCV only support spot & swap markets)r  r   r   r   r|  fapiV1PublicGetKlinesr  dapiV1PublicGetKlinesspotV1PublicGetMarketKliner#   r/   parse_ohlcvs)r   r  	timeframer-  r   r  r   rs   r  r  timeframesFuturer  timeframesSpots                r   fetch_ohlcvzbitrue.fetch_ohlcv  s5      !!!!!!!!!V$$__T\<DD
&> 	Y#z8RHH &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!__ZDDN ,)).)TJJ G
  #(  %*	"!<<T[[RX=Y=YZZZZZZZZH??8VR88DD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or  hr  lr
  cr  vr   )safe_timestampr   safe_number_2)r   ohlcvr   r  s       r   parse_ohlcvzbitrue.parse_ohlcvY  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 )a  
        fetches the bid and ask price and volume for multiple markets
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#symbol-order-book-ticker
        :see: https://www.bitrue.com/api-docs#ticker
        :see: 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>   r  r/   r   r   r<   r  z/ fetchBidsAsks only support spot & swap markets)r  market_symbolsr|  r   r(  r  r)  spotV1PublicGetTickerBookTickerr#   r/   parse_tickers)r   r  r  firstr   r  r  r  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
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#24hr-ticker-price-change-statistics
        :see: https://www.bitrue.com/api-docs#ticker
        :see: 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 marketsrf   z; fetchTickers only support spot when symbols are not provedr  r/   )r  rF  r|  r   r#   r/   r*  r  r  r{  r  r   rH  )r   r  r  r  r  r  r  rI  r   tickersr  r   s               r   fetch_tickerszbitrue.fetch_tickers  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__T1b11F[[!B!BCCF$*GF4L!!!!'7333r   c                    |                      |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  r  orderIdr/   tradeIdisBuyerMakerisBuyerr  r  
commissionr  commissionAssert)r   r  isMakerr   r   )r  r  r  r  r/   r   r  r  takerOrMakerr  r  r   r  )safe_integer_2r|  rb  r#  r   r}  
safe_trader  )r   trader   r  priceStringamountStringmarketIdr  rQ  r/   r  
buyerMakerrT  r  rX  rW  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__UN;;
//%33!'266UD#/55D5  **5,FF 33D4D4DUL^4_4_`` C //%33&-:777L"Y//( " 
  
   	r   c                 X  K   |                                   d{V  |                     |          }d}|d         rAd|d         i}|||d<   |                     |                     ||                     d{V }nt	          | j        dz             |                     ||||          S )a8  
        get the list of most recent trades for a particular symbol
        :see: 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  r/   r   z& fetchTrades only support spot markets)r  r   spotV1PublicGetTradesr  r#   r/   parse_trades)r   r  r-  r   r  r   r  r  s           r   fetch_tradeszbitrue.fetch_tradesa  s       !!!!!!!!!V$$&> 		S&,G  #( !77GV8T8TUUUUUUUUHHtw)QQRRR   65%@@@r   c           
      H    dddddddddd	}|                      |||          S )Nr  closedcanceled	cancelingrejectedexpired)	INITPENDING_CREATENEWPARTIALLY_FILLEDFILLEDCANCELEDPENDING_CANCELREJECTEDEXPIRED)r|  )r   r  statusess      r   parse_order_statuszbitrue.parse_order_status  sC    $ &")" 

 

 &&999r   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  r  r   avgPricer  origQtycummulativeQuoteQtycumQuoterQ  r  r  fillsclientOrderIdtimeInForcelimit_makerGTX	post_onlyr   	stopPricer  r/   r  r  lastTradeTimestamppostOnlytriggerPricer  r   r  )filled	remainingr  r  r   )ru  rb  r|  r#  r   r+   	string_gtr  r   r   	omit_zero
safe_orderr  )r   r   r   r  r^  r  r  r  r  r  r  r  r   r/   r  r  r~  r  r  r  stopPriceStringr  s                         r   parse_orderzbitrue.parse_order  s_   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w33((@@&&um<<M)]{e/C]Q\I\=  D**5+>>%%dnn_&E&EFF	  
E 
" 
 ] 
 	 

 Y// 
 !"4 
 f 
 D 
 ; 
  
 D 
 U 
  
 I 
 f 
  D! 
" w# 
$ - 
  
  
. /  	r   r   c                    K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d<   |                     |dd|d|           d{V S )aN  
        create a market buy order by providing the symbol and cost
        :see: https://www.bitrue.com/api-docs#new-order-trade-hmac-sha256
        :see: 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 onlyFr   r   r  )r  r   r#   r/   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t3          | j        d1z             |                     |	|          S )2a  
        create a trade order
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#recent-trades-list
        :see: https://www.bitrue.com/api-docs#new-order-trade-hmac-sha256
        :see: 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 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 fullfilled, 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  fokFOKiocIOCr/   r  TrF   r   r  r   a   createOrder() requires the price argument with swap market buy orders to calculate total order cost(amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options["createMarketBuyOrderRequiresPrice"] = False to supply the cost in the amount argument(the exchange-specific behaviour)r  r  r   positionType
reduceOnlyreduce_onlyCLOSEOPENr  r  1)r  r  r  r  r   r   r  r<   r  quantityr  
orderTypes z% is not a valid order type in market newClientOrderIdr  r  r  z- createOrder only support spot & swap markets)r  r   ra  r    r/   price_to_precisionr  is_post_onlyhandle_option_and_paramsr|  omitr  r+   r$  cost_to_precisionparse_to_numericr  fapiV2PrivatePostOrderr  dapiV2PrivatePostOrderr   amount_to_precisionin_arrayrb  spotV1PrivatePostOrderr#   r  )r   r  r  r  r  r  r  r   r  r  uppercaseTyper  isMarketr  r  r   r   r]  r\  quoteAmountrequestAmountr  r  validOrderTypesr  r  s                             r   r  zbitrue.create_order  s(     0 !!!!!!!!!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??8VR88DD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.;*+))&.+NNI$6NK+HII'+'>'>vy'Q'Q$!88Wf9U9UVVVVVVVVHDDtw)XXYYY, f---r   r/   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 )aY  
        fetches information on an order made by the user
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#query-order-user_data
        :see: https://www.bitrue.com/api-docs#query-order-user_data-hmac-sha256
        :see: https://www.bitrue.com/api_docs_includes_file/delivery.html#query-order-user_data-hmac-sha256
        :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  rQ  r>   r/   r  r   r   r  r<   r  z, fetchOrder only support spot & swap markets)r   r/   r  r   r  r  fapiV2PrivateGetOrderr  dapiV2PrivateGetOrderr   spotV1PrivateGetOrderr#   r  	r   r/   r  r  r   r  r  r  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??8VR88DD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 )	aQ  
        fetches information on multiple closed orders made by the user
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#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  r/   	startTimer   )r   r/   r  r   r#   spotV1PrivateGetAllOrdersr  parse_orders)r   r  r-  r   r  r   r  r  s           r   fetch_closed_orderszbitrue.fetch_closed_orders  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
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#current-open-orders-user_data
        :see: https://www.bitrue.com/api-docs#current-all-open-orders-user_data-hmac-sha256
        :see: https://www.bitrue.com/api_docs_includes_file/delivery.html#current-all-open-orders-user_data-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>   r/   r  r   r   r  r<   r  z1 fetchOpenOrders only support spot & swap markets)r   r/   r  r   fapiV2PrivateGetOpenOrdersr  dapiV2PrivateGetOpenOrdersr   spotV1PrivateGetOpenOrdersr#   r  	r   r  r-  r   r  r   r  r  r  s	            r   fetch_open_orderszbitrue.fetch_open_orders  s      >#DG.]$]^^^!!!!!!!!!V$$&> 	^&,TlGN#h _!%!@!@WV\A]A]!^!^^^^^^^	" _!%!@!@WV\A]A]!^!^^^^^^^??8VR88DD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 )aU  
        cancels an open order
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#cancel-order-trade
        :see: https://www.bitrue.com/api-docs#cancel-order-trade-hmac-sha256
        :see: 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  rQ  r>   r/   r  r   r   r  r<   r  z- cancelOrder only support spot & swap markets)r   r/   r  r   r  r  fapiV2PrivatePostCancelr  dapiV2PrivatePostCancelr   spotV1PrivateDeleteOrderr#   r  r  s	            r   cancel_orderzbitrue.cancel_orderl  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![![[[[[[[??8VR88DD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 )	an  
        cancel all open orders in a market
        :see: https://www.bitrue.com/api-docs#cancel-all-open-orders-trade-hmac-sha256
        :see: 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>   r  r/   r   r   r  z, cancelAllOrders only support future markets)	r  r   fapiV2PrivatePostAllOpenOrdersr  dapiV2PrivatePostAllOpenOrdersr   r#   r/   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??8VR88DD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
        :see: https://github.com/Bitrue-exchange/Spot-official-api-docs#account-trade-list-user_data
        :see: https://www.bitrue.com/api-docs#account-trade-list-user_data-hmac-sha256
        :see: https://www.bitrue.com/api_docs_includes_file/delivery.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  r5   r   r>   r/   r  r   r   r  r<   r  z/ fetchMyTrades only support spot & swap markets)r  r   r/   r   fapiV2PrivateGetMyTradesr  dapiV2PrivateGetMyTradesr   spotV2PrivateGetMyTradesr#   rc  r  s	            r   fetch_my_tradeszbitrue.fetch_my_trades  s      !!!!!!!!!>#DG.[$[\\\V$$#(GK t||$GG&> 	\&,TlGN#h ]!%!>!>t{{7TZ?[?[!\!\\\\\\\	" ]!%!>!>t{{7TZ?[?[!\!\\\\\\\??8VR88DD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
        :see: 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 argumentr/   r   rj  r  r  r   r  )r   r/   r  r  spotV1PrivateGetDepositHistoryr  	safe_listparse_transactions	r   r  r-  r   r  r  r  r  r  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 )	a:  
        fetch all withdrawals made from an account
        :see: 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 argumentr/   r   r  r  r   r  )r   r/   r  r  spotV1PrivateGetWithdrawHistoryr  r  r  r  s	            r   fetch_withdrawalszbitrue.fetch_withdrawalsf	  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  rg  )r   56)rw  
withdrawal)r   r|  )r   r  r  statusesByTypert  s        r    parse_transaction_status_by_typez'bitrue.parse_transaction_status_by_type	  sd      
  

 

 ??>4<<&&999r   r  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 )#Nr/   
withdrawIdtagType	addressToaddressFrom_r   r   txid	createdAt	updatedAt	payAmountrO  r  rw  r  r  r  rj  r  )r  r   r  r  r  rv  addresstagtagTotagFromr  r  r  F)internalcommentr  )	rb  r|  r  r   r  r  ra  r}  r  )r   transactionr  r/   r  r  r  r  r  partsr  r  r  r  rO  r  r  r  rv  r  rc  r  feeCostr  s                           r   parse_transactionzbitrue.parse_transaction	  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   c                   K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }|d         ||d}d}|                     |          \  }}||                     |          |d<   |||d<   |                     |                     ||                     d{V }	|                     |	di           }
| 	                    |
|          S )a  
        make a withdrawal
        :see: 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>`
        Nr/   )rj  r  r  	chainNamer  r  )
handle_withdraw_tag_and_paramscheck_addressr  r  handle_network_code_and_paramsnetwork_code_to_idspotV1PrivatePostWithdrawCommitr  	safe_dictr  )r   r  r  r  r  r  r  r  r  r  r  s              r   rr   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 )Nrl  )r  r   )r  rr   rw  r   r   rm  r  rp  F)rw  rr   r   r   rr   r  r   )r   r  r{  r|  r~  r  )r   r  r  chainDetailschainDetailLengthr  r  rl  rc  currencyCoder  s              r   parse_deposit_withdraw_feez!bitrue.parse_deposit_withdraw_feeT
  sJ    sM2>>--" 
 "  
 
 !!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
        :see: 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>`
        Nri  rj  )r  rz  r  parse_deposit_withdraw_fees)r   r  r  r  ri  s        r   fetch_deposit_withdraw_feesz"bitrue.fetch_deposit_withdraw_feesz
  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   rO  r  r  r  )	r  r/   r  r  r  r  fromAccount	toAccountr  )r|  r  r   r  r  )r   rq   r  r  r  r  accountSplitr  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
        :see: https://www.bitrue.com/api-docs#get-future-account-transfer-history-list-user_data-hmac-sha256
        :see: https://www.bitrue.com/api_docs_includes_file/delivery.html#get-future-account-transfer-history-list-user_data-hmac-sha256
        :param str code: unified currency code of the currency transferred
        :param int [since]: the earliest time in ms to fetch transfers for
        :param int [limit]: the maximum number of transfers structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch transfers for
        :param str [params.type]: transfer type wallet_to_contract or contract_to_wallet
        :returns dict[]: a list of `transfer structures <https://github.com/ccxt/ccxt/wiki/Manual#transfer-structure>`
        Nr  r  r/   
coinSymbol	beginTime   r   untilendTimer  )	r  rb  r  r   r  &fapiV2PrivateGetFuturesTransferHistoryr  r  parse_transfers)r   r  r-  r   r  r  r  r  r  r  r  s              r   fetch_transferszbitrue.fetch_transfers
  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   r  r  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
        :see: https://www.bitrue.com/api-docs#new-future-account-transfer-user_data-hmac-sha256
        :see: 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>`
        Nr   r/   r  )r  r  r  r  )
r  r  r   r   r|  r   fapiV2PrivatePostFuturesTransferr  r   r  )r   r  r  r  r  r  r  accountTypesfromIdtoIdr  r  r  s                r   rq   zbitrue.transfer
  s      !!!!!!!!!==&&t|5ErJJ!!,[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
        :see: https://www.bitrue.com/api-docs#change-initial-leverage-trade-hmac-sha256
        :see: 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 125r/   )r  r  r>   z& setLeverage only support swap marketsr   r   )	r   r/   r   r  r   r#   fapiV2PrivatePostLevelEditr  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  
marginModer  totalr  r  r  r   )r   r  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
        :see: https://www.bitrue.com/api-docs#modify-isolated-position-margin-trade-hmac-sha256
        :see: 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 marketsr/   )r  r  r   r   )	r  r   r#   r/   r  fapiV2PrivatePostPositionMarginr  dapiV2PrivatePostPositionMarginr)  )r   r  r  r  r   r  r  s          r   
set_marginzbitrue.set_margin1  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k    r|dk    r| j        d         |         }
n| j        d         |         dz   |z   }
|
dz   |                     ||          z   }
|                     ||                     |                    }|	dk    rP|                                  |                     | j        dd	          }|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<   n}t#          | 
                                          }d }|dk    rd}n|dk    rd}|dz   |z   dz   |z   }||z   |z   }|dk    rs|                     |                     |          |                     | j                  t          j                  }| j        ||d}|
d|                     |          z   z  }
n| 	                    d|i|          }|                     |          }|t%          j        |          z   }|                     |                     |          |                     | j                  t          j                  }d| j        ||d}n|r|
d|                     |          z   z  }
|
|||dS )Nr   r   r   r   r   r  r   r   r   r<   )r  r   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)r2  r3  r4  r5  )r  methodbodyheaders)r|  r   implode_paramsr  extract_paramscheck_required_credentialsr   r   	urlencoder  r  hmacencodesecrethashlibsha256apiKeystrjsondumps)r   pathr   r6  r  r8  r7  r  r7   accessr  r   query	signaturer  signPathsignMessages                    r   signzbitrue.signQ  sq   Q''""3**!!#q))5==W//)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?? $		$++k*B*BDKKPTP[D\D\^e^l m mI'+{%.#, G
 3!7!777CC KK$j) E  99U++D"-
40@0@"@K $		$++k*B*BDKKPTP[D\D\^e^l m mI(:'+{%.#,	 GG  4sT^^F3333fdwOOOr   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   r   z temporary banned: )r$   r/   rC  findr    	safe_boolr|  rD  loads	Exceptionthrow_exactly_matched_exceptionr   throw_broadly_matched_exceptionr+   string_equalsr   r   )r   r  reasonr  r6  r8  r7  r  requestHeadersrequestBodyrN  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   r6  rF  r  configr   r   r  r  s
             r   calculate_rate_limiter_costz"bitrue.calculate_rate_limiter_cost  s    &  8v+=+=*%%6!!6(9(97OEY'G1c'll++ $ $
E!H$$ 8OOO %vvq111r   )N)H__name__
__module____qualname__r   r  r  r  r!  rf  r   r  r   r
   r  r  r   r  r  rC  r   r   r  r   r&  r,  r  r9  rD  r   rJ  r   rM  r   r`  rd  ru  r   r  floatr  r   r   r   r  r   r  r  r  r  r  r  r   r  r  r  r   r  rr   r  r	  r  r  r   rq   r#  r	   r)  r-  rL  ra  rd  __classcell__)r   s   @r   r-   r-   #   s       u u u u un. . . .D D D )+ 
 
 
 
0 ') 9 9 9 9EZ EZ EZN -/ w w: w w w wr *, ^+ ^+V ^+ ^+ ^+ ^+@a
f a
 a
 a
 a
F>) >) >) >) >)@ *, i* i* i* i* i* i*V @DB A AS A AS\ A A A AFA A6 AV A A A AF 68 E/ E/ E/F E/ E/ E/ E/N 8<$]ajl OH OH OHC OHWZ OHquvzq{ OH OH OH OHb#
 #
 #
4 #
 #
 #
 #
J 8<B 81 81W 81 81 81 81t 6:" N4 N47 N4 N4 N4 N4 N4`W W W5 W W W Wr <@d[] %A %A %AS %A %Abfglbm %A %A %A %AN: : :p p p5 p p p pd XZ T Tc T T T T T" mqy{ x. x. x.I x.Y x.X] x.fi x. x. x. x.t 8<B S. S.C S. S. S. S. S.j 7;\`ik 2A 2A 2A3 2AVY 2Aptuzp{ 2A 2A 2A 2Ah 59tZ^gi N= N=c N= N=TW N=nrsxny N= N= N= N=` 9=R <. <.S <.# <. <. <. <.| 59 "/ "/c "/ "/ "/ "/H 37TX\eg S= S=C S=s S=RU S= S= S= S=j 04$UYbd AE AE AEC AEs AEimnyiz AE AE AE AEF 37TX\eg 47 47C 47s 47RU 47lpq|l} 47 47 47 47l: : : :v
 v
x v
; v
 v
 v
 v
p EIQS /6 /63 /6 /6 /6 /6 /6b$ $ $ $ $ $L BFb F Fw F F F F"
 "
 "
 "
H 154VZce /B /B# /BS /BPS /B /B /B /Bb ac 3 33 3 3C 3TW 3gt 3 3 3 3B ?C2  3     :
 
>P 
 
 
 
. CE @ @s @E @I[ @ @ @ @@ &eBSW >P >P >P >P@2 2 2h MO 
2 
2 
2 
2 
2 
2 
2 
2r   r-   )4 ccxt.async_support.base.exchanger   ccxt.abstract.bitruer   r  r@  rD  ccxt.base.typesr   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>rq     s   6 5 5 5 5 5 , , , , , ,    K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K  K       * * * * * * 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 % % % % % %l.2 l.2 l.2 l.2 l.2X{ l.2 l.2 l.2 l.2 l.2r   