
    E#is                       S SK Jr  S SKJr  S SKrS SKJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"  S SK#J$r$  S SK%J&r&  S SK%J'r'  S SK%J(r(  S S	K%J)r)  S S
K%J*r*  S SK%J+r+  S SK%J,r,  S SK%J-r-  S SK%J.r.  S SK%J/r/  S SK%J0r0  S SK%J1r1  S SK%J2r2  S SK%J3r3  S SK4J5r5  S SK6J7r7   " S S\\5      r8g)    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesCurrencyDepositAddressIntLeverage
MarginModeMarginModesMarginModificationMarketNumOrder	OrderBook	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRates
OrderBooksTradeTradingFeeInterfaceTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)RateLimitExceeded)ExchangeNotAvailable)OnMaintenance)	TICK_SIZE)Precisec                   T  ^  \ rS rSrS\4U 4S jjrS r0 4S\\   4S jjr	0 4S\
4S jjr0 4S\S\4S jjr0 4S\S\4S	 jjrS\4S
 jr0 4S\4S jjr0 4S\S\4S jjrS0 4S\S\4S jjrSpS\S\S\4S jjrSS0 4S\S\S\S\\   4S jjrSSS0 4S\S\S\4S jjrSpS\S\S\4S jjrS r S\4S jr!S r"SpS\S\#S\$4S  jjr%SSS0 4S\S\S\S\\$   4S! jjr&SSS0 4S\S\S\S\\$   4S" jjr'SSS0 4S\S\S\S\\$   4S# jjr(SS0 4S\S\S\)4S$ jjr*S0 4S\S\S\+4S% jjr,SpS&\S\S\-4S' jjr.0 4S\S\-4S( jjr/0 4S\04S) jjr1S*SS0 4S\S+\S\S\S\\2   4
S, jjr3SpS\S\24S- jjr4SSS0 4S\S\S\S\\5   4S. jjr6S0 4S/\S\4S0 jjr7SSS0 4S/\S\S\S\4S1 jjr8SSS0 4S\S\S\S\\5   4S2 jjr9S0 4S/\S\4S3 jjr:S0 4S\4S4 jjr;S0 4S/\S\4S5 jjr<SS0 4S/\S\S6\=S7\>S8\?S9\?4S: jjr@S0 4S\S6\=S7\>S8\AS9\?4
S; jjrBSS0 4S\CS<\S6\=S7\>S8\AS9\?S=\4S> jjrDS\4S? jrESpS@\S\S\54SA jjrFS0 4S\\   S\G4SB jjrHSpS=\S\I4SC jjrJ0 4S\S8\ASD\SE\S\K4
SF jjrLSpSG\S\#S\K4SH jjrMS\4SI jrNS0 4S\S8\ASJ\SK\S\$4
SL jjrOS0 4S\S\P4SM jjrQSSS0 4S\S\S\4SN jjrRS0 4S\S\\S   4SO jjrT0 4S\4SP jjrUSpSQ\S\4SR jjrVSpS\4SS jjrWS0 4S\4ST jjrX0 4S\4SU jjrY0 4S\S\Z4SV jjr[SpS\S\Z4SW jjr\0 4S\S\]4SX jjr^SpSY\S\S\]4SZ jjr_0 4S\S8\AS\]4S[ jjr`0 4S\S8\AS\]4S\ jjra0 4S\S\b4S] jjrcSpS^\S\S\b4S_ jjrdS0 4S^\eS\4S` jjrfS0 4Sa\4Sb jjrgSpS\#4Sc jjrhS0 4S\S7\>S\54Sd jjri0 S4U 4Se jjrjS\eSf\Sg\Sh\Si\Sj\4Sk jrkSlSm0 SS4Sn jrlSormU =rn$ )qhitbtc   returnc                   > U R                  [        [        U ]  5       SSS/SS0 SS_SS	_S
S	_SS	_SS_SS_SS	_SS	_SS	_SS_SS	_SS	_SS	_SS	_SS	_SS	_SS	_0 SS	_SS_SS	_SS _SS _SS	_SS_S S_S!S	_S"S	_S#S_S$S_S%S	_S&S	_S'S(_S)S	_S*S _E0 S+S	_S,S	_S-S	_S.S_S/S	_S0S_S1S_S2S	_S3S _S4S_S5S(_S6S	_S7S_S8S	_S9S	_S:S_S;S_E0 S<S	_S=S	_S>S	_S?S_S@S	_SAS	_SBS	_SCS_SDS_SES	_SFS	_SGS	_SHS_SIS	_SJS	_SKS	_SLS	_E0 SMS_SNS	_SOS	_SPS	_SQS	_SRS	_SSS(_STS_SUS	_SVS	_SWS	_SXS	_SYS_SZS_S[S_S\S	_S]S	_E[        S^S_S_S`.SaSaS`.SbScSdSe/SfSg/Sh.Si0 SjSk_SlSk_SmSk_SnSk_SoSk_SpSk_SqSk_SrSk_SsSk_StSk_SuSk_SvSk_SwSk_SxSk_SySk_SzSk_S{Sk_SkSkSkSkSkSkSkSkSkSkSkSkSkS|.E00 S}S~_SS~_SS_SS_SS~_SS~_SS~_SS~_SS_SS_SS_SS_SS_SS~_SS~_SS~_SS~_0 SS~_SS~_SS~_SS_SS_SS_SS_SS~_SS~_SS~_SS~_SS~_SS~_SS~_SS_SS_SS_ESSSSSSSSS~S~S~S~S.E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS~_SS~_SS~_SS~0ESSSS.SSSSSSSSSSSS.SSSS.S.S`.SS	S	U R                  S5      U R                  S5      U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      //
U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      /U R                  S5      U R                  S5      //
S.S.0S	SS	S SSSS S	S	S	S	S.SSSSSSS	S.S S	SSSSS	S.S	SSSS	S.S	SSSSS	S.S S	SSSSSSSS	S.	SS0S.	SS0SSS	0SS0SS0SS0SS0S.SS0SS0S.SS0SS0S.S.SSSSSSSSSSS.
0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _0 S[        _S[        _S[        _S[        _S[        _S[        _S[         _S[        _GS [        _GS[        _GS[        _GS[        _GS[        _GS[        _GS["        _GS[        _GS[        _E0 GS	[        _GS
[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E[        [        [        [        [        GS.E0 GS.GSGSGSGS.0 GS GS!_GS"GS _GSGS#_GSGS_GS$GS$_GS%GS&_GSGS'_GS(GS(_GS)GS)_GS*GS*_GS+GS+_GS,GS,_GS-GS-_GS.GS._GS/GS/_GS0GS0_GS1GS1_0 GS2GS3_GS4GS5_GS6GS7_GS8GS9_GS:GS:_GS;GS;_GS<GS<_GS=GS=_GS>GS>_GS?GS@_GSAGSA_GSBGSB_GSCGSC_GSDGSD_GSEGSE_GSFGSF_GSGGSG_E0 GSHGSH_GSIGSI_GSJGSJ_GSKGSK_GSLGSL_GSMGSM_GSNGSN_GSOGSO_GSPGSP_GSQGSQ_GSRGSR_GSSGST_GSUGSV_GSWGSW_GSXGSX_GSYGSZ_GS[GS[_E0 GS\GS\_GS]GS]_GS^GS^_GS_GS__GS`GS`_GSaGSb_GScGSc_GSdGSe_GSfGSf_GSgGSg_GShGSi_GSjGSj_GSkGSk_GSlGSl_GSmGSm_GSnGSn_GSoGSp_E0 GSqGSq_GSrGSr_GSsGSs_GStGSt_GSuGSu_GSvGSv_GSwGSw_GSxGSy_GSzGSz_GS{GS|_GS}GS}_GS~GS~_GSGS_GSGS_GSGS_GSGS_GSGS_EGSGS0ESGSGSGSGS.GSS0GS.0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGSGSGS.EGS.5      $ (  Nr4   HitBTCHKgDl
@3CORSFspotTmarginswapfutureoption	addMargincancelAllOrderscancelOrderclosePositioncreateDepositAddresscreateOrdercreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrder	editOrderfetchAccountsfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeverageTiersfetchLiquidationsfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrderfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionsfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickersfetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsfetchVolatilityHistoryfetchWithdrawalsreduceMarginsandboxsetLeverage	setMarginsetMarginModesetPositionModetransferwithdrawzchttps://user-images.githubusercontent.com/1294454/27766555-8eaec20e-5edc-11e7-9c5b-6dc69fc42f5e.jpgz!https://api.demo.hitbtc.com/api/3)publicprivatezhttps://api.hitbtc.com/api/3zhttps://hitbtc.comz(https://hitbtc.com/?ref_id=5a5d39a65d466zhttps://api.hitbtc.comz=https://github.com/hitbtc-com/hitbtc-api/blob/master/APIv2.mdz"https://hitbtc.com/fees-and-limitszIhttps://support.hitbtc.com/hc/en-us/articles/115005148605-Fees-and-limits)logotestapiwwwreferraldocfeesgetzpublic/currency
   zpublic/currency/{currency}zpublic/symbolzpublic/symbol/{symbol}zpublic/tickerzpublic/ticker/{symbol}zpublic/price/ratezpublic/price/historyzpublic/price/tickerzpublic/price/ticker/{symbol}zpublic/tradeszpublic/trades/{symbol}zpublic/orderbookzpublic/orderbook/{symbol}zpublic/candleszpublic/candles/{symbol}zpublic/converted/candles)z!public/converted/candles/{symbol}zpublic/futures/infozpublic/futures/info/{symbol}zpublic/futures/history/fundingz'public/futures/history/funding/{symbol}z"public/futures/candles/index_pricez+public/futures/candles/index_price/{symbol}z!public/futures/candles/mark_pricez*public/futures/candles/mark_price/{symbol}z$public/futures/candles/premium_indexz-public/futures/candles/premium_index/{symbol}z$public/futures/candles/open_interestz-public/futures/candles/open_interest/{symbol}zspot/balance   zspot/balance/{currency}
spot/order   spot/order/{client_order_id}zspot/feezspot/fee/{symbol}zspot/history/orderzspot/history/tradezmargin/account margin/account/isolated/{symbol}zmargin/account/cross/{currency}margin/ordermargin/order/{client_order_id}zmargin/configzmargin/history/orderzmargin/history/tradezmargin/history/positionszmargin/history/clearingzfutures/balancezfutures/balance/{currency}zfutures/account!futures/account/isolated/{symbol}futures/orderfutures/order/{client_order_id}zfutures/configzfutures/feezfutures/fee/{symbol}zfutures/history/orderzfutures/history/tradezfutures/history/positionszfutures/history/clearingzwallet/balance   zwallet/balance/{currency}zwallet/crypto/address)z$wallet/crypto/address/recent-depositz%wallet/crypto/address/recent-withdrawz wallet/crypto/address/check-minezwallet/transactionszwallet/transactions/{tx_id}zwallet/crypto/fee/estimatezwallet/airdropszwallet/amount-lockszsub-accountsub-account/aclzsub-account/balance/{subAccID}z0sub-account/crypto/address/{subAccID}/{currency}zspot/order/listzmargin/order/listzfutures/order/listzwallet/crypto/withdrawzwallet/convertzwallet/transferzwallet/internal/withdrawz&wallet/crypto/check-offchain-availablezwallet/crypto/fees/estimatezwallet/airdrops/{id}/claimzsub-account/freezezsub-account/activatezsub-account/transferr   )r   r   r   )r   r   zmargin/positionz!margin/position/isolated/{symbol}r   r   zfutures/positionz'futures/position/{margin_mode}/{symbol}r   r   wallet/crypto/withdraw/{id})r   r   r   )r   postpatchdeleteputtradingz0.0009010z0.0007100z0.0006500z0.00051000z0.00035000z0.000210000z0.00012000050000z-0.0001100000z0.0008z0.0004)makertaker)	tierBased
percentager   r   tiers)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedselfTradePreventiontrailingleveragemarketBuyByCostmarketBuyRequiresPriceiceberg  i )r   limitdaysBack	untilDayssymbolRequired
marketType)r   triggerr   r   r   )r   r   r   r   r   r   )	r   r   r   daysBackCanceledr   r   r   r   r   r   )	r   rF   createOrdersro   rx   ru   r{   rQ   rp   extendsdefaultr   )r   rF   rx   ro   ru   rQ   forDerivatives)linearinverse)r   r<   r   r>   r?   M1M3M5M15M30H1H4D1D71M)
1m3m5m15m30m1h4h1d1wr   42950350460080010021003100410052001200220032010201120122020202220241000110021100222000120002200032000420005200062000720008200092001020011200122001420016200182003120032200332003420040200412004220043200442004520047200482004920080)2100121003210042200422008)exactbroadERC20ETHTRC20)r+  USDTBTCbtcOMNIethETCBEP20BSCTRXNEARDGBAEARADACHZABBCALGOAPTATOMAVAXCAVACAVAXXAVAXBSVBCHSVBEP2BNBCELOCKBCTXCDASHDCRDOGEdogeEGLDEOSETHWEVERFETFILFLOWGLMRGRINHBARHIVEHYDRAICPICXIOSTIOTAIOTXKAVAKLAYKIMKOMODOKMDKSMLSKLTCltcMINAMOVRNANONEOONEONTOPTIMISMOPPLCUMATICPOLYGONQTUMREIOASISROSERVNSCSCRTSOLSTEEMTHETAThetaTRUEVETVSYSWAVESWAXXCHXECNEMXEMXLMXMRxmrXRDXRPXTZXVGXYMZECZENZILwalletderivatives)r<   fundingr>   r?   
includeFee)defaultNetworkdefaultNetworksnetworksaccountsByTyper   AUTOCubeBCCBDPBidiPassBETz
DAO.CasinoBIT
BitRewardsBOXz	BOX TokenCPTCryptaurGETThemisGMTz	GMT TokenHSRHCIQzIQ.CashLNC
LinkerCoinPLAPlayChipPNTPentaSBTCzSuper BitcoinSTEPNSTXSTOX
TokenvilleMTL)TVXMTXPNT)idname	countries	rateLimitversionhasprecisionModeurlsr   r   features
timeframes
exceptionsoptionscommonCurrencies)deep_extendsuperr4   describer1   parse_numberr.   r#   r/   r%   r$   r)   r(   r+   r&   r*   r,   r0   )self	__class__s    S/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/hitbtc.pyr  hitbtc.describe   s1   fd < > VVV $V 	V
 %V %V TV "4V tV  V 'V tV &tV (V 'V  (!V" "4#V$ T%V&  'V( )V* +D+V, )$-V. $T/V0 '1V2 (3V4 "45V6 &t7V8 (9V: 1%;V<  =V> +D?V@ *:AVB +DCVD &tEVF #DGVH *4IVJ $TKVL uMVN "4OVP *5QVR +ESVT  UVV %dWVX $UYVZ ":[V\ #D]V^ +E_V` aVb !$cVd &ueVf +EgVh  iVj dkVl $TmVn +EoVp %dqVr !$sVt "4uVv uwVx #EyVz d{V| !$}V~ "4V@ uAVB #DCVD  EVF !$GVH )$IVJ )%KVL tMVN OVP tQVR "4SVT #DUVV $ZWVX )%YVZ #D[V\ ]V^ 4_V` taVb UcVd  eVf "5gVh DiVj DkVn '}AB
 == ,F,S
 9_!.  )24b ( 1"	
 ( 1" ,R / .r 7 ( 1" +B 4R )"  22!" 3B#$ >@/18::<CE>@GI=?FH@BIK@BIK=!F/&/12/ %a/ 7	/
 #B/ ,R/ -b/ -b/ )!/ ;A/ :1/ '/ 9!/ (/ //  /!/" 3B#/$ 22%/& *2'/( 5b)/* *1+/, <Q-/. (//0 :11/2 )"3/4 &r5/6 /7/8 09/: 0;/< 4R=/> 3B?/@ )"A/B 4RC/D 0E/F ACAC<>/17968+-/1')+-:<LN]/`$a)1 ' ,Q	
 ( -a 0 1" )" *2 3B A" 6r 5b -b  /!" /#$ *2%* 9::;;< '(89+,=>():;,-CD)*;<79 =>=>79o\G@D !%"&!..x8!..x8 "..s3T5F5Fx5PQ!..t4d6G6G6QR!..u5t7H7H7RS!..u5t7H7H7RS!..v68I8I(8ST!..v68I8I(8ST!..w79J9J89TU!..w79J9J39OP!..w79J9J99UV!..x8$:K:KI:VW" "..s3T5F5Fx5PQ!..t4d6G6G6QR!..u5t7H7H7RS!..u5t7H7H7RS!..v68I8I(8ST!..v68I8I(8ST!..w79J9J89TU!..w79J9J89TU!..w79J9J89TU!..x8$:K:KH:UV"!H  $&+(,,0,1).+06:#'#'"&#'	( #(/4$)$)+027#')$, %)&*!%$*%+*/&*& '+#($)*/&*# '+!%#($)*/&*( $(&*!%$*,-%+#($)*/&*
*  #y?B y  )$d$ %e# %e& %e( %e*#( "#3 "#3 	 "#3 "#3 	}fP 9,9=9 /9 /	9
 +9 =9 /9 ,9 /9 /9 I9 J9 J9 J9 J9  J!9" J#9$ J%9& L'9( Z)9* -+9, Z-9. ./90 ]192 ]394 ]596 ]798 ]99: ];9< \=9> \?9@ ]A9B ]C9D ]E9F ]G9H ]I9J ]K9L ]M9N ]O9P ]Q9R ]S9T ]U9V ]W9X ]Y9Z ][9\ -]9^ \_9` \a9b \c9d \e9f ]g9h +--**q9t w<| #* #$y5y Ey 5	y
 Uy 5y Uy Uy Fy 5y $y$ $%y( 5)y2 53y8 F9yB FCyH 5IyR FSyT VUyV VWyb 7cyd EeyB FCyH 5IyT FUy\ F]y` 5ayh Fiyv Fwy@ 5AyD FEyL FMyR 5SyT 5UyX FYyf Fgyl Fmyn Foyr Fsyz W{y| 5}y~ 5yB FCyD FEyF FGyJ FKyL EMyN eOyR 5SyX 5Yy\ 5]yh Fiyn Foyt Fuyx 5yyJ 5KyN 5OyP QyZ F[y` Yayl Fmyp 5qyv Vwy| 5}y@ $AyB FCyL 5MyR WSyZ W[yb Fcyl 5myr Fsyv Wwyx 5yy@ 5AyJ 5KyL 5MyR 5SyV 5Wy` 5ayb 5cyd 5eyf 5gyh 5iyj 5kyl 5myn 5oyv #')+	# !%MIT!!u! z! |	!
 |! {! z! x! {! t! i! |! z! w! !  !!" v#!$ #)!giA
 i i	    c                 "    U R                  5       $ N)milliseconds)r  s    r  noncehitbtc.nonce  s      ""r  c                   #    U R                  U5      I Sh  vN n/ n[        UR                  5       5      n[        S[	        U5      5       GH  nXE   nUR                  S5      (       a  M   U R                  X&5      nU R                  US5      nU R                  US5      n	US:H  n
US:H  nU R                  USS	5      nU=(       a    UnU	SLnU
=(       a    U(       + nS	nU R                  US
S5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      nU R                  U5      nSnSnUS-   U-   nSnSnSnSnU
(       aW  U R                  S5      nUnU R                  U5      nUSL=(       a    UU:H  nU(       + nUS-   U-   nU(       a  US-   U	-   nSnOSnU R                  US5      nU R                  US5      nU R                  U5      n U R                  U5      n!UR                  0 SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_SU_S S!_S"U
_S#U_UU R                  US$5      U R                  US%5      UU	SSSUU U!S&.U R                  S5      U R                  US'S(5      S).U SS).U!SS).U R                  [        R                   " UU5      5      SS).S*.SUS+.E5        GM     U$  GN7f),z
retrieves data on all markets for hitbtc

https://api.hitbtc.com/#symbols

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
Nr   _BQXtypeexpiryfuturesr<   margin_tradingFbase_currency
underlyingquote_currencyfee_currency/1:-r?   r>   quantity_increment	tick_sizer  symbolbasequotesettlebaseIdquoteIdsettleIdr=   r@   activeTcontractr   	take_rate	make_rate)amountpricemax_initial_leverager   minmax)r   r  r  cost)r   r   r   contractSizer  expiryDatetimestrike
optionTypefeeCurrency	precisionlimitscreatedinfo)publicGetPublicSymbollistkeysrangelenendswith
safe_valuesafe_stringsafe_integer	safe_boolsafe_string_2safe_currency_coder  appendsafe_numberr2   
string_mul)"r  paramsresponseresultidsir  marketr   r  r  r<   marginTradingr=   r?   r>   r@   r  r  feeCurrencyIdr  r  r  r  r  r  r  r  r   r   	lotString
stepStringlotsteps"                                     r  fetch_marketshitbtc.fetch_markets  s     33F;;> 8==?#q#c(#AB{{6""__X2F))&&9J&&vx8F"i/H&(D NN63CUKM+mFD(F+VDF''NF&&v/?@G ,,V^DM**62D++G4E11-@KHFCZ%'FDLFG#005(00: ,C5F?$*#.#c\F2F#D!D((1EFI))&+>J##I.C$$Z0DMM 3b3&3 3 	3
 &3 &3 73 H3 3 3 &3 3 &3 &3 $3  H!3" &#3$ #))&+>))&+> , "&"*!!  $005#//8NPQR!
  ##
  $#
  $001C1CIz1Z[#$  e3 3W $~ A <s   KKJ=Kc                 `  #    U R                  U5      I Sh  vN n0 n[        UR                  5       5      n[        S[	        U5      5       GHX  nXE   nU R                  U5      nX&   nU R                  US/ 5      n	0 n
[        S[	        U	5      5       H  nX   nU R                  USS5      nU R                  U5      nUb  UR                  5       OUnUUUSU R                  US5      U R                  US5      U R                  US5      U R                  US	5      S
SSS.0S.	X'   M     U R                  UUUU R                  US5      U R                  US5      U R                  US5      (       + U R                  US5      U R                  US5      U
SSSSS.0SS.5      X7'   GM[     U$  GN7f)z
fetches all available currencies on an exchange

https://api.hitbtc.com/#currencies

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
Nr   r  protocolnetwork
payout_feepayin_enabledpayout_enabledprecision_payoutr   r  )	r   r  r   r  feedepositr   r  r  precision_transfer	full_namedelistedr  )r   coder  r  r  r  r&  r   r  r%  r  r  )publicGetPublicCurrencyr  r  r  r  r  	safe_listr  network_id_to_codeupperr  r
  safe_currency_structurer  )r  r  r  r  
currenciesr  
currencyIdr*  entryrawNetworksr  j
rawNetwork	networkIdnetworkCodes                  r  fetch_currencieshitbtc.fetch_currencies  s     55f==V (--/*
q#j/*A#J**:6D(E..
B?KH1c+./(^
 ..z:yQ	"55i@6A6Mk//1TX&#*"++JE#~~j/J $z;K L!%!1!1*>P!Q"#'#'%)% 0*  77 !--e5IJ((<"nnUJ??>>%A NN52BC$## #9 FL7 +\ w >s   F.F+FF.r*  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  US5      nUbL  US:X  aF  U R                  U R                  S5      nU R                  Xe5      nUb  XtS'   U R                  US5      nU R                  U R                  XB5      5      I Sh  vN nU R                  US5      n	U R                  U	5      U R                  US5      U R                  US5      SUS	.$  N NO7f)
aO  
create a currency deposit address

https://api.hitbtc.com/#generate-deposit-crypto-address

:param str code: unified currency code of the currency for the deposit address
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
Ncurrencyr  r   r-  r  address
payment_id)r;  r<  tagr   r   )
load_marketsr;  safe_string_upperr  r  r  omitprivatePostWalletCryptoAddressextendr  )
r  r*  r  r;  requestr   r  parsedNetworkr  r1  s
             r  create_deposit_addresshitbtc.create_deposit_address  s     !!!==&
 ((;dfnt||Z@H ,,X?M(&3
#YYvy1F<<T[[=YZZ %%h
;
//
;'')<##Hl;
 	
# 	" [s#   D	DB D	7D8AD	D	c                 H  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  US5      nUbL  US:X  aF  U R                  U R                  S5      nU R                  Xe5      nUb  XtS'   U R                  US5      nU R                  U R                  XB5      5      I Sh  vN nU R                  US5      n	U R                  U	S5      n
U R                  U	S5      nU R                  U	S	5      nU R                  U5      nUUSU
US
.$  GN Nh7f)aF  
fetch the deposit address for a currency associated with self account

https://api.hitbtc.com/#get-deposit-crypto-address

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
Nr;  r  r   r-  r  r   r<  r=  )r   r;  r   r<  r>  )
r?  r;  r@  r  r  r  rA  privateGetWalletCryptoAddressrC  r  )r  r*  r  r;  rD  r   r  rE  r  firstAddressr<  r1  r>  
parsedCodes                 r  fetch_deposit_addresshitbtc.fetch_deposit_address"  s1     !!!==&
 ((;dfnt||Z@H ,,X?M(&3
#YYvy1F;;DKK<XYY x3""<;%%lJ?
|\:,,Z8
"
 	
+ 	" Zs#   D"DB D"7D 8A&D" D"c                 .   SU0n[        S[        U5      5       Hh  nX   nU R                  US5      nU R                  U5      nU R	                  5       nU R                  US5      US'   U R                  US5      US'   XrU'   Mj     U R                  U5      $ )Nr   r   r;  	availablefreereservedused)r  r  r  r  accountsafe_balance)r  r  r  r  r2  r1  r*  rS  s           r  parse_balancehitbtc.parse_balanceI  s    )q#h-(AKE))%<J**:6DllnG"..ukBGFO"..ujAGFO"4L )   ((r  c                 ,  #    U R                  USS5      nU R                  US/5      nU R                  U R                  S0 5      nU R	                  X2U5      nSnUS:X  a  U R                  U5      I Sh  vN nOUS:X  a  U R                  U5      I Sh  vN nOcUS:X  a  U R                  U5      I Sh  vN nOC[        UR                  5       5      n[        U R                  S-   SR                  U5      -   5      eU R                  U5      $  N N{ N]7f)	a  
query for balance and get the amount of funds available for trading or funds locked in orders

https://api.hitbtc.com/#wallet-balance
https://api.hitbtc.com/#get-spot-trading-balance
https://api.hitbtc.com/#get-trading-balance

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
r  r<   r  Nr  r  z. fetchBalance() type parameter must be one of , )safe_string_lowerrA  r  r  r  privateGetWalletBalanceprivateGetSpotBalanceprivateGetFuturesBalancer  r  r(   r  joinrU  )r  r  r  r  rS  r  r  s          r  fetch_balancehitbtc.fetch_balanceU  s     %%fff=6F8,7GL"">>h!99&AAH!77??H%!::6BBH++-.DTWW'WWZ^ZcZcdhZiijj !!(++' B?Bs7   A2D4D5DDD4D5ADDDr  c                    #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  XS5      $  NU N7f)a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://api.hitbtc.com/#tickers

: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  publicGetPublicTickerSymbolrC  parse_tickerr  r  r  r  rD  r  s         r  fetch_tickerhitbtc.fetch_ticker{  ss      !!!V$fTl
 99$++g:VWW   22' 	"
 Xs!   A0A,?A0A.A0.A0Nsymbolsc                    #    U R                  5       I Sh  vN   U R                  U5      n0 nUb&  U R                  U5      nSR                  U5      nXSS'   U R	                  U R                  X25      5      I Sh  vN n0 n[        UR                  5       5      n[        S[        U5      5       H4  n	X   n
U R                  U
5      nUS   nXj   nU R                  X5      X|'   M6     U R                  USU5      $  N N7f)a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://api.hitbtc.com/#tickers

: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>`
N,rf  r   r  )r?  market_symbols
market_idsr]  publicGetPublicTickerrC  r  r  r  r  safe_marketrb  filter_by_array_tickers)r  rf  r  rD  	marketIds	delimitedr  r  r  r  marketIdr  r  r2  s                 r  fetch_tickershitbtc.fetch_tickers  s      !!!%%g.0I+I!*I33DKK4PQQ  HMMO$q#d)$AwH%%h/FH%F&E!..u=FN % ++FHgFF? 	" Rs#   C>C:A#C>:C<;B C><C>tickerr  c                    U R                  US   5      nU R                  S U5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  0 SU_SU_SU R	                  U5      _SU R                  US5      _S	U R                  US	5      _S
U R                  US
5      _SS _SU R                  US5      _SS _SS _SU_SU_SU_SS _SS _SS _SS _UUUS.EU5      $ )N	timestampvolumevolume_quoteopenlastr  datetimehighlowbid	bidVolumeask	askVolumevwapclosepreviousClosechanger   average)
baseVolumequoteVolumer   )	parse8601safe_symbolr  safe_tickeriso8601)	r  rs  r  ru  r  r  r  rx  ry  s	            r  rb  hitbtc.parse_ticker  s    NN6+#67	!!$/%%fh7
&&v~>// !
f!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##FE2!
 !
 4##FE2!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
* + 	r  sincer   c                 p  #    U R                  5       I Sh  vN   Sn0 nUb  [        US5      US'   Ub  X&S'   SnUbB  U R                  U5      nUS   US'   U R                  U R	                  Xd5      5      I Sh  vN nO(U R                  U R	                  Xd5      5      I Sh  vN nUb  U R                  Xu5      $ / n[        UR                  5       5      n	[        S[        U	5      5       H>  n
X   nU R                  U5      nX{   nU R                  X5      nU R                  X5      nM@     U$  GN N N7f)a  
get the list of most recent trades for a particular symbol

https://api.hitbtc.com/#trades

: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   fromr  r  r   )r?  r  r  publicGetPublicTradesSymbolrC  publicGetPublicTradesparse_tradesr  r  r  r  array_concat)r  r  r  r   r  r  rD  r  tradesrn  r  rp  marketInner	rawTradesparseds                  r  fetch_tradeshitbtc.fetch_trades  s9     !!!"5$/GG#FO[[(F &tGH!==dkk'>Z[[H!77G8TUUH$$X66)	q#i.)A |H++h/K *I&&y>F&&v6F * 1 	" \Us5   D6D/A"D69D2:(D6"D4#BD62D64D6c                   #    U R                  5       I Sh  vN   Sn0 nUb  U R                  U5      nUS   US'   Ub  X6S'   Ub  X&S'   SnSnSn	U R                  SXT5      u  ptU R                  SU5      u  pU R	                  USS/5      nUb)  U R                  U R                  Xd5      5      I Sh  vN n	OUS	:X  a)  U R                  U R                  Xd5      5      I Sh  vN n	OvUS
:X  a)  U R                  U R                  Xd5      5      I Sh  vN n	OGUS:X  a)  U R                  U R                  Xd5      5      I Sh  vN n	O[        U R                  S-   5      eU R                  XX#5      $  GNX N N Ne N87f)a  
fetch all trades made by the user

https://api.hitbtc.com/#spot-trades-history
https://api.hitbtc.com/#futures-trades-history
https://api.hitbtc.com/#margin-trades-history

: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
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported
:param bool [params.margin]: True for fetching margin trades
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Nr  r  r   r  ro   r   r=   r<   r>   z- fetchMyTrades() not support self market typer?  r  handle_market_type_and_paramshandle_margin_mode_and_paramsrA  privateGetMarginHistoryTraderC  privateGetSpotHistoryTradeprivateGetFuturesHistoryTrader-   r  r  
r  r  r  r   r  r  rD  r   r   r  s
             r  fetch_my_tradeshitbtc.fetch_my_trades  s~      !!![[(F &tGH$G#FO

!??QW`
!??QWX
6L(#;<!!>>t{{7?[\\HV#!%!@!@WA]!^^v%!%!C!CDKKPWD`!aax'!%!B!B4;;wC_!``"477-\#\]]  5@@7 	"" ] _a`sX   E9E.BE91E12.E9 E3!.E9E5.E9>E7?0E91E93E95E97E9tradec                 z   U R                  US   5      nU R                  US5      nU R                  XB5      nUS   nS nU R                  US5      nU R                  US5      nUb  U(       a  SOSn	OSn	Ub;  U R                  US0 5      n
U R                  U
S5      nU R	                  U5      nUUS.nU R                  US	S
5      nU R                  US5      nU R                  USS5      nU R                  US5      nU R                  US5      nU R                  UUUUU R                  U5      US UU	UUS US.U5      $ )Nru  r  r%  r   r   r   r  )r  r;  clientOrderIdclient_order_idr  quantityqtysider  )r   r  orderru  rz  r  r  r  takerOrMakerr  r  r  r%  )r  r  rl  r  r  r  
safe_trader  )r  r  r  ru  rp  r  r%  feeCostStringr   r  r   r  feeCurrencyCodeorderIdpriceStringamountStringr  r  s                     r  parse_tradehitbtc.parse_tradeC  sr   r NN5#56	##E84!!(3!((6w/&+7L"L$??6626D**4@K"55kBO%+C $$UO=NO&&ug6))%UCv.eT*"Y/( " 
  	r  c                 8  #    U R                  5       I S h  vN   SU0nS nUb  U R                  U5      nUS   US'   Ub  U R                  U5      US'   Ub  XFS'   U R                  U R	                  Xe5      5      I S h  vN nU R                  XX4U5      $  N N7f)Ntypesr  r0  r  r   )r?  r;  r  privateGetWalletTransactionsrC  parse_transactions)	r  r  r*  r  r   r  rD  r;  r  s	            r  fetch_transactions_helper hitbtc.fetch_transactions_helper  s     !!!U
 }}T*H$,TNGL!"ll51GFO$G::4;;w;WXX2 &&x5PPK 	" Ys"   BBA'B>B?BBstatusc                 6    SSSSSS.nU R                  X!U5      $ )Npendingfailedok)CREATEDPENDINGFAILEDROLLED_BACKSUCCESSr  r  r  statusess      r  parse_transaction_statushitbtc.parse_transaction_status  s-      #
 &99r  c                 0    SSS.nU R                  X!U5      $ )Nr&  
withdrawal)DEPOSITWITHDRAWr  )r  r  r  s      r  parse_transaction_typehitbtc.parse_transaction_type  s$     $
 T22r  transactionr;  c                    U R                  USS5      nU R                  U R                  US5      5      nU R                  U R                  US5      5      nU R                  U R                  US5      5      nU R	                  U R                  US5      5      nU R                  US0 5      nU R                  US5      n	U R                  U	5      n
U R                  US	5      nU R                  US
5      nUnU R                  US5      nUnU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nUS:H  nS S S S.nU R                  US5      nUb
  U
US'   UUS'   0 SU_SU_SU_SU_SU
_SS _SU_SU_SU_SU R                  U5      _S
U_SU_SU_SU_SS _SU_SU_S UUS.E$ ) Noperation_idr  
created_at
updated_atr  r  nativer;  hashr<  r=  sendersr   r  subtypeOFFCHAIN)r;  r  rater%  r  r   txidr   ru  rz  addressFrom	addressTor>  tagFromtagToupdated)commentinternalr%  )	r  r  r  r  r  r  r  r  r  )r  r  r;  r  ru  r  r  r  r  r1  r*  txhashr<  r  r>  r  senderr  r  subTyper  r%  feeCosts                          r  parse_transactionhitbtc.parse_transaction  sv   B ^TBNN4#3#3K#NO	..!1!1+|!LM**4+;+;K+PQ..t/?/?X/VWh;%%fj9
&&z2!!&&1""695	v|43&&vq1!!&(3"";	:j( 

 ""651"C
O!CK
K
"
 F
 D	

 
 t
 f
 f
 
 Y/
 w
 ;
 
 3
 t
  U!
" w#
$  )
 	
r  c                 D   #    U R                  SXX45      I Sh  vN $  N7f)a  
fetch history of deposits and withdrawals

https://api.hitbtc.com/#get-transactions-history

:param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
:param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
:param int [limit]: max number of deposit/withdrawals to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
zDEPOSIT,WITHDRAWNr  r  r*  r  r   r  s        r  fetch_deposits_withdrawals!hitbtc.fetch_deposits_withdrawals5  s$      334FUZcccc     c                 D   #    U R                  SXX45      I Sh  vN $  N7f)a  
fetch all deposits made to an account

https://api.hitbtc.com/#get-transactions-history

: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>`
r  Nr  r  s        r  fetch_depositshitbtc.fetch_depositsC  s"      33ItEZZZZr  c                 D   #    U R                  SXX45      I Sh  vN $  N7f)a  
fetch all withdrawals made from an account

https://api.hitbtc.com/#get-transactions-history

: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>`
r  Nr  r  s        r  fetch_withdrawalshitbtc.fetch_withdrawalsQ  s"      33JU[[[[r  c                 
  #    U R                  5       I Sh  vN   0 nUb%  U R                  U5      nSR                  U5      US'   Ub  X$S'   U R                  U R	                  XC5      5      I Sh  vN n0 n[        UR                  5       5      n[        S[        U5      5       HU  n	X   n
Xj   nU R                  U
5      nU R                  U R                  US5      5      nU R                  Xj   XSS5      X|'   MW     U$  N N7f)	a"  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data for multiple markets

https://api.hitbtc.com/#order-books

:param str[] [symbols]: list of unified market symbols, all symbols fetched if None, default is None
:param int [limit]: max number of entries per orderbook to return, default is None
: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 symbol
Nrh  rf  depthr   ru  r}  r  )r?  rj  r]  publicGetPublicOrderbookrC  r  r  r  r  r  r  r  parse_order_book)r  rf  r   r  rD  marketIdsInnerr  r  rn  r  rp  	orderbookr  ru  s                 r  fetch_order_bookshitbtc.fetch_order_books_  s     !!!!__W5N!$.!9GI$G66t{{77STT)	q#i.)A |H *I%%h/Ft'7'7	;'OPI!2283EvZ_afgFN * ! 	" Us#   DC?AD/D0BDDc                 :  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X%S'   U R                  U R                  XS5      5      I Sh  vN nU R	                  U R                  US5      5      nU R                  XaUSS5      $  N N;7f)a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://api.hitbtc.com/#order-books

: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  r  r  ru  r}  r  )r?  r  publicGetPublicOrderbookSymbolrC  r  r  r  )r  r  r   r  r  rD  r  ru  s           r  fetch_order_bookhitbtc.fetch_order_book|  s      !!!V$fTl
 $G<<T[[=YZZNN4#3#3Hk#JK	$$Xy%OO 	" [s"   BBABB:BBr%  c                     U R                  US5      nU R                  US5      nU R                  US5      nU R                  XR5      nUUUUS S S.$ )Nr  r  r  )r   r  r   r   r   r   )r  r  r  )r  r%  r  r   r   rp  r  s          r  parse_trading_feehitbtc.parse_trading_fee  sf       k2  k2##C2!!(3
 	
r  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnUS   S:X  a)  U R                  U R                  XB5      5      I Sh  vN nOJUS   S:X  a)  U R	                  U R                  XB5      5      I Sh  vN nO[        U R                  S-   5      eU R                  XS5      $  N Nb N27f)aJ  
fetch the trading fees for a market

https://api.hitbtc.com/#get-trading-commission
https://api.hitbtc.com/#get-trading-commission-2

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
Nr  r  r  r<   r>   z/ fetchTradingFee() not support self market type)r?  r  privateGetSpotFeeSymbolrC  privateGetFuturesFeeSymbolr-   r  r  rc  s         r  fetch_trading_feehitbtc.fetch_trading_fee  s      !!!V$fTl
 &>V#!99$++g:VWWHF^v%!<<T[[=YZZHtww)ZZ[[ %%h77% 	" XZs4   CCA
C!C"1CC/CCCc                   #    U R                  5       I Sh  vN   U R                  SSU5      u  p#SnUS:X  a  U R                  U5      I Sh  vN nO8US:X  a  U R                  U5      I Sh  vN nO[	        U R
                  S-   5      e0 n[        S[        U5      5       H  nU R                  XF   5      nUS   nXuU'   M!     U$  N N{ N]7f)a\  
fetch the trading fees for multiple markets

https://api.hitbtc.com/#get-all-trading-commissions
https://api.hitbtc.com/#get-all-trading-commissions-2

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
Nr   r<   r>   z0 fetchTradingFees() not support self market typer   r  )	r?  r  privateGetSpotFeeprivateGetFuturesFeer-   r  r  r  r  )	r  r  r   queryr  r  r  r%  r  s	            r  fetch_trading_feeshitbtc.fetch_trading_fees  s      !!! >>?QSWY_`
!33E::H6!!66u==Htww)[[\\ q#h-(A((5C]F 6N ) / 	" ;=s4   CC5CCC,C
-ACC
Cr   	timeframec           	        #    U R                  5       I Sh  vN   SnU R                  USS5      u  peU(       a  U R                  SXXBUS5      I Sh  vN $ U R                  U5      nUS   U R	                  U R
                  X"5      S.nUb  U R                  U5      US'   U R                  S	X5      u  pUb  [        US5      US
'   U R	                  US5      n	U R                  US5      nSn
U	S:X  a)  U R                  U R                  X5      5      I Sh  vN n
OU	S:X  a)  U R                  U R                  X5      5      I Sh  vN n
OWU	S:X  a)  U R                  U R                  X5      5      I Sh  vN n
O(U R                  U R                  X5      5      I Sh  vN n
U R                  XX#U5      $  GN GNf N Nw NJ N#7f)a   
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://api.hitbtc.com/#candles
https://api.hitbtc.com/#futures-index-price-candles
https://api.hitbtc.com/#futures-mark-price-candles
https://api.hitbtc.com/#futures-premium-index-candles

: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]: timestamp in ms of the latest funding rate
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns int[][]: A list of candles ordered, open, high, low, close, volume
NFrp   paginater   r  )r  periodr  untilr   r  markindexpremiumIndex)r?  handle_option_and_params"fetch_paginated_call_deterministicr  r  r  r  handle_until_optionr  rA  ,publicGetPublicFuturesCandlesMarkPriceSymbolrC  -publicGetPublicFuturesCandlesIndexPriceSymbol/publicGetPublicFuturesCandlesPremiumIndexSymbolpublicGetPublicCandlesSymbolparse_ohlcvs)r  r  r  r  r   r  r  r  rD  r  r  s              r  fetch_ohlcvhitbtc.fetch_ohlcv  s    $ !!!88zZ@@v^cpvx|}}}V$Tl&&t	M
 "ll51GFO227GL"5$/GG  167+F?!NNt{{[bOkllHg!OOPTP[P[\cPlmmHn$!QQRVR]R]^eRnooH!>>t{{7?[\\H8   9UKKk 	" ~ mmo\sj   GF4:GF7CGF:.GF<.G3F>4(GG G7G:G<G>G Gc           	          U R                  U R                  US5      5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )Nru  rx  r  r  r  rv  )r  r  r  )r  ohlcvr  s      r  parse_ohlcvhitbtc.parse_ohlcv2  sw    2 NN4++E;?@UF+UE*UE*UG,UH-
 	
r  c                 B  #    U R                  5       I Sh  vN   Sn0 nUb  U R                  U5      nUS   US'   Ub  U R                  U5      US'   Ub  X6S'   SnSnU R                  SXT5      u  ptU R	                  SU5      u  pU R                  USS/5      nSn	Ub)  U R                  U R                  Xd5      5      I Sh  vN n	OUS	:X  a)  U R                  U R                  Xd5      5      I Sh  vN n	OvUS
:X  a)  U R                  U R                  Xd5      5      I Sh  vN n	OGUS:X  a)  U R                  U R                  Xd5      5      I Sh  vN n	O[        U R                  S-   5      eU R                  XX#5      n
U R                  U
SSS/S5      $  GN~ N N N{ NN7f)a  
fetches information on multiple closed orders made by the user

https://api.hitbtc.com/#spot-orders-history
https://api.hitbtc.com/#futures-orders-history
https://api.hitbtc.com/#margin-orders-history

: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
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported
:param bool [params.margin]: True for fetching margin orders
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r  r  r   rQ   r   r=   r<   r>   z1 fetchClosedOrders() not support self market typer  closedcanceledF)r?  r  r  r  r  rA  privateGetMarginHistoryOrderrC  privateGetSpotHistoryOrderprivateGetFuturesHistoryOrderr-   r  parse_ordersfilter_by_array)r  r  r  r   r  r  rD  r   r   r  r  s              r  fetch_closed_ordershitbtc.fetch_closed_ordersS  s      !!![[(F &tGH"ll51GFO$G

!??@SU[d
!??@SU[\
6L(#;<!!>>t{{7?[\\HV#!%!@!@WA]!^^v%!%!C!CDKKPWD`!aax'!%!B!B4;;wC_!``"477-`#`aa""8UB##FHx6LeTT9 	"" ] _a`sY   FFB*FF.F0F1.FF .FFAFFFFFr  c                   #    U R                  5       I Sh  vN   SnUb  U R                  U5      nSU0nSnSnU R                  SXC5      u  pcU R                  SU5      u  psU R	                  USS/5      nSnUb)  U R                  U R                  XS5      5      I Sh  vN nOUS:X  a)  U R                  U R                  XS5      5      I Sh  vN nOvUS:X  a)  U R                  U R                  XS5      5      I Sh  vN nOGUS:X  a)  U R                  U R                  XS5      5      I Sh  vN nO[        U R                  S-   5      eU R                  US	5      n	U R                  X5      $  GNU N N Nv NI7f)
aK  
fetches information on an order made by the user

https://api.hitbtc.com/#spot-orders-history
https://api.hitbtc.com/#futures-orders-history
https://api.hitbtc.com/#margin-orders-history

: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
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported
:param bool [params.margin]: True for fetching a margin order
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  rx   r   r=   r<   r>   z* fetchOrder() not support self market typer   )r?  r  r  r  rA  r(  rC  r)  r*  r-   r  	safe_dictparse_order)
r  r  r  r  r  rD  r   r   r  r  s
             r  fetch_orderhitbtc.fetch_order  sm     !!![[(Fr
 

!??f]
!??fU
6L(#;<!!>>t{{7?[\\HV#!%!@!@WA]!^^v%!%!C!CDKKPWD`!aax'!%!B!B4;;wC_!``"477-Y#YZZ( x+..Y 	" ] _a`sY   E6E+BE6E..E6E0.E6;E2<.E6*E4+AE6.E60E62E64E6c                   #    U R                  5       I Sh  vN   SnUb  U R                  U5      nSU0nSnSn	U R                  SXe5      u  pU R                  SU5      u  pU R	                  USS/5      nSn
U	b)  U R                  U R                  Xu5      5      I Sh  vN n
OUS:X  a)  U R                  U R                  Xu5      5      I Sh  vN n
OvUS:X  a)  U R                  U R                  Xu5      5      I Sh  vN n
OGUS:X  a)  U R                  U R                  Xu5      5      I Sh  vN n
O[        U R                  S-   5      eU R                  XX45      $  GND N N Ne N87f)	a  
fetch all the trades made from a single order

https://api.hitbtc.com/#spot-trades-history
https://api.hitbtc.com/#futures-trades-history
https://api.hitbtc.com/#margin-trades-history

:param str id: order id
: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 to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported
:param bool [params.margin]: True for fetching margin trades
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Norder_idr|   r   r=   r<   r>   z0 fetchOrderTrades() not support self market typer  )r  r  r  r  r   r  r  rD  r   r   r  s              r  fetch_order_tradeshitbtc.fetch_order_trades  sd    " !!![[(F
 

!??@RTZc
!??@RTZ[
6L(#;<!!>>t{{7?[\\HV#!%!@!@WA]!^^v%!%!C!CDKKPWD`!aax'!%!B!B4;;wC_!``"477-_#_``N   5@@} 	" ] _a`sX   E%EBE%E.E%E.E%;E!<.E%*E#+0E%E%E%!E%#E%c                   #    U R                  5       I Sh  vN   Sn0 nUb  U R                  U5      nUS   US'   SnSnU R                  SXT5      u  ptU R                  SU5      u  pU R	                  USS/5      nSn	Ub)  U R                  U R                  Xd5      5      I Sh  vN n	OUS:X  a)  U R                  U R                  Xd5      5      I Sh  vN n	OvUS:X  a)  U R                  U R                  Xd5      5      I Sh  vN n	OGUS:X  a)  U R                  U R                  Xd5      5      I Sh  vN n	O[        U R                  S	-   5      eU R                  XX#5      $  GNJ N N Ne N87f)
a  
fetch all unfilled currently open orders

https://api.hitbtc.com/#get-all-active-spot-orders
https://api.hitbtc.com/#get-active-futures-orders
https://api.hitbtc.com/#get-active-margin-orders

: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 orders structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported
:param bool [params.margin]: True for fetching open margin orders
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r  ru   r   r=   r<   r>   z/ fetchOpenOrders() not support self market type)r?  r  r  r  rA  privateGetMarginOrderrC  privateGetSpotOrderprivateGetFuturesOrderr-   r  r+  r  s
             r  fetch_open_ordershitbtc.fetch_open_orders  sg      !!![[(F &tGH

!??@QSYb
!??@QSYZ
6L(#;<!!77G8TUUHV#!%!9!9$++g:V!WWv%!%!<!<T[[=Y!ZZx'!%!;!;DKK<X!YY"477-^#^__(   5@@U 	" V XZYsX   E+E BE+#E#$.E+E%.E+E'.E+0E)10E+#E+%E+'E+)E+c                   #    U R                  5       I Sh  vN   SnUb  U R                  U5      nSU0nSnSnU R                  SXC5      u  pcU R                  SU5      u  psU R	                  USS/5      nSnUb)  U R                  U R                  XS5      5      I Sh  vN nOUS:X  a)  U R                  U R                  XS5      5      I Sh  vN nOvUS:X  a)  U R                  U R                  XS5      5      I Sh  vN nOGUS:X  a)  U R                  U R                  XS5      5      I Sh  vN nO[        U R                  S-   5      eU R                  X5      $  GNC N N Nd N77f)	a9  
fetch an open order by it's id

https://api.hitbtc.com/#get-active-spot-order
https://api.hitbtc.com/#get-active-futures-order
https://api.hitbtc.com/#get-active-margin-order

:param str id: order id
:param str symbol: unified market symbol, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported
:param bool [params.margin]: True for fetching an open margin order
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  rt   r   r=   r<   r>   z. fetchOpenOrder() not support self market type)r?  r  r  r  rA  "privateGetMarginOrderClientOrderIdrC   privateGetSpotOrderClientOrderId#privateGetFuturesOrderClientOrderIdr-   r  r1  	r  r  r  r  r  rD  r   r   r  s	            r  fetch_open_orderhitbtc.fetch_open_orderK  sa     !!![[(Fr
 

!??@PRXa
!??@PRXY
6L(#;<!!DDT[[QXEabbHV#!%!F!Ft{{SZGc!ddv%!%!I!I$++V]Jf!ggx'!%!H!HU\Ie!ff"477-]#]^^111 	" c egfX   E$EBE$E.E$E.E$;E <.E$*E"+/E$E$E$ E$"E$c                   #    U R                  5       I Sh  vN   Sn0 nUb  U R                  U5      nUS   US'   SnSnU R                  SX25      u  pRU R                  SU5      u  pbU R	                  USS/5      nSnUb)  U R                  U R                  XB5      5      I Sh  vN nOUS:X  a)  U R                  U R                  XB5      5      I Sh  vN nOvUS:X  a)  U R                  U R                  XB5      5      I Sh  vN nOGUS:X  a)  U R                  U R                  XB5      5      I Sh  vN nO[        U R                  S	-   5      eU R                  Xs5      $  GNI N N Nd N77f)
a[  
cancel all open orders

https://api.hitbtc.com/#cancel-all-spot-orders
https://api.hitbtc.com/#cancel-futures-orders
https://api.hitbtc.com/#cancel-all-margin-orders

:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported
:param bool [params.margin]: True for canceling margin orders
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r  rB   r   r=   r<   r>   z/ cancelAllOrders() not support self market type)r?  r  r  r  rA  privateDeleteMarginOrderrC  privateDeleteSpotOrderprivateDeleteFuturesOrderr-   r  r+  r  r  r  r  rD  r   r   r  s           r  cancel_all_ordershitbtc.cancel_all_orderst  sb     !!![[(F &tGH

!??@QSYb
!??@QSYZ
6L(#;<!!::4;;w;WXXHV#!%!<!<T[[=Y!ZZv%!%!?!?G@\!]]x'!%!>!>t{{7?[!\\"477-^#^__  22/ 	" Y []\sX   E*EBE*#E"$.E*E$.E*E&.E*0E(1/E*"E*$E*&E*(E*c                   #    U R                  5       I Sh  vN   SnSU0nUb  U R                  U5      nSnSnU R                  SXC5      u  pcU R                  SU5      u  psU R	                  USS/5      nSnUb)  U R                  U R                  XS5      5      I Sh  vN nOUS:X  a)  U R                  U R                  XS5      5      I Sh  vN nOvUS:X  a)  U R                  U R                  XS5      5      I Sh  vN nOGUS:X  a)  U R                  U R                  XS5      5      I Sh  vN nO[        U R                  S-   5      eU R                  X5      $  GNC N N Nd N77f)	a+  
cancels an open order

https://api.hitbtc.com/#cancel-spot-order
https://api.hitbtc.com/#cancel-futures-order
https://api.hitbtc.com/#cancel-margin-order

: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
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported
:param bool [params.margin]: True for canceling a margin order
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  rC   r   r=   r<   r>   z+ cancelOrder() not support self market type)r?  r  r  r  rA  %privateDeleteMarginOrderClientOrderIdrC  #privateDeleteSpotOrderClientOrderId&privateDeleteFuturesOrderClientOrderIdr-   r  r1  rB  s	            r  cancel_orderhitbtc.cancel_order  s]     !!!r
 [[(F

!??v^
!??vV
6L(#;<!!GGT[HdeeHV#!%!I!I$++V]Jf!ggv%!%!L!LT[[Y`Mi!jjx'!%!K!KDKKX_Lh!ii"477-Z#Z[[111 	" f hjirE  r  r  r  r  c                 b  #    U R                  5       I S h  vN   S nUU R                  X%5      S.n	US:X  d  US:X  a/  Uc  [        U R                  S-   5      eU R	                  X&5      U	S'   Ub  U R                  U5      nS n
S nU R                  SX5      u  pU R                  SU5      u  pU R                  USS/5      nS nUb)  U R                  U R                  X5      5      I S h  vN nOU
S	:X  a)  U R                  U R                  X5      5      I S h  vN nOvU
S
:X  a)  U R                  U R                  X5      5      I S h  vN nOGU
S:X  a)  U R                  U R                  X5      5      I S h  vN nO[        U R                  S-   5      eU R                  X5      $  GN N N Nd N77f)N)r  r  r   	stopLimitz' editOrder() limit order requires pricer  rL   r   r=   r<   r>   z) editOrder() not support self market type)r?  amount_to_precisionr#   r  price_to_precisionr  r  r  rA  $privatePatchMarginOrderClientOrderIdrC  "privatePatchSpotOrderClientOrderId%privatePatchFuturesOrderClientOrderIdr-   r1  )r  r  r  r  r  r  r  r  r  rD  r   r   r  s                r  
edit_orderhitbtc.edit_order  s    !!!!00@
 GO!4}#DGG.W$WXX#66vEGG[[(F

!??V\
!??VT
6L(#;<!!FFt{{SZGcddHV#!%!H!HU\Ie!ffv%!%!K!KDKKX_Lh!iix'!%!J!J4;;W^Kg!hh"477-X#XYY11; 	"& e gihsX   F/F$CF/(F').F/F).F/F+.F/5F-6/F/'F/)F/+F/-F/c           
      ,  #    U R                  5       I Sh  vN   U R                  U5      nSnSn	U R                  SXv5      u  pSn
U R                  SU5      u  pU R	                  XyX#XEX5      u  pSnU	S:X  a)  U R                  U R                  X5      5      I Sh  vN nOZU	S:X  d  U
b)  U R                  U R                  X5      5      I Sh  vN nO(U R                  U R                  X5      5      I Sh  vN nU R                  X5      $  N Nr NB N7f)ax  
create a trade order

https://api.hitbtc.com/#create-new-spot-order
https://api.hitbtc.com/#create-margin-order
https://api.hitbtc.com/#create-futures-order

: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 str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported for spot-margin, swap supports both, default is 'cross'
:param bool [params.margin]: True for creating a margin order
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
:param bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately
:param str [params.timeInForce]: "GTC", "IOC", "FOK", "Day", "GTD"
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NrF   r>   r=   )
r?  r  r  r  create_order_requestprivatePostFuturesOrderrC  privatePostMarginOrderprivatePostSpotOrderr1  )r  r  r  r  r  r  r  r  rD  r   r   r  s               r  create_orderhitbtc.create_order  s
    * !!!V$
!??v^

!??vV
33FTZcmv!99$++g:VWWHH$**@!88W9UVVH!66t{{77STTH11 	" XVTsF   DDBDD1DD(D6D7DDDDr   r   c	                    US:H  n	U R                  US5      n
U R                  US5      nU R                  U/ SQ5      nU R                  US:H  S U5      nUUU R	                  US   U5      US   S.nU
b3  US	   S
:w  a*  US	   S:w  a!  [        U R                  S-   US	   -   S-   5      eU
SL a  XS'   U(       a  SUS'   Ub  XS'   U	(       d  US:X  d  US:X  a3  Uc  [        U R                  S-   5      eU R                  US   U5      US'   US:X  a-  U R                  US5      nUc  [        U R                  S-   5      eUb1  U R                  US   U5      US'   U	(       a  SUS	'   O<US:X  a  SUS	'   O0US:X  d  US:X  d  US:X  d  US:X  a  [        U R                  S-   5      eU R                  U/ SQ5      nUS
:X  a	  Uc  SnX~S'   X/$ ) Nr   
reduceOnlyr   )r   	stopPrice
stop_pricer  r  r  )r  r  r  r  r  r>   r=   z0 createOrder() does not support reduce_only for zJ orders, reduce_only orders are supported for swap and margin markets onlyTreduce_only	post_onlytime_in_forcerT  takeProfitLimitz9 createOrder() requires a price argument for limit ordersr  r   expire_timez@ createOrder() requires an expire_time parameter for a GTD orderrf  
stopMarkettakeProfitMarketzU createOrder() requires a triggerPrice parameter for stop-loss and take-profit orders)r   r   re  rf  rd  postOnlycrossmargin_mode)
r  r  safe_number_nis_post_onlyrU  r+   r  r#   rV  rA  )r  r  r   r  r  r  r  r   r  isLimitrd  r   r   
isPostOnlyrD  
expireTimes                   r  r]  hitbtc.create_order_request
	  s3   7?__V\:
&&v}=))&2]^&&tx'7vF
001A6JTl	
" !v&(vf~/I"477-_#_bhiobp#p  t@  $@  A  A%/M"#'GK "'2O$t{*8I0I}#DGG.i$ijj#66vh7GOGG5 ))&-@J!#DGG.p$pqq#$($;$;F8<Ll$[GL!"-!".k!t|';IZAZ`dhz`z  +B  !B  C  C6#wx!$
%/M"  r  c                 8    SSSSSSS.nU R                  X!U5      $ )Nrx  r&  r'  r  )new	suspendedpartiallyFilledfilledr'  expiredr  r  s      r  parse_order_statushitbtc.parse_order_statusB	  s0    %"
 &99r  r  c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  U	5      n
U R                  US5      nS nX:w  a  U R                  U5      nU R                  US	5      nU R                  U R                  US
5      5      nU R                  US5      nU R                  X5      nUS   nU R	                  US5      nU R                  US5      nU R	                  US5      nU R                  0 SU_SU_SU_SU
_SU R                  U
5      _SU_SU_SU_SU_SU_SU_SU_SU_SU_SU R	                  US5      _SU_SS _S UUUS U R                  US5      S S S.EU5      $ )Nr  r  r  r  r  price_averager  r  quantity_cumulativer  r  rh  ri  r  r   r  r  ru  rz  lastTradeTimestamplastUpdateTimestampr  r   rn  rd  rg  r{  	remainingrf  )r  r  r  r  r%  r   r   r   )r  r  r}  rl  r  
safe_orderr  )r  r  r  r  r  r  r  r  r  r  ru  r  r  r{  r  rp  r  rn  r   r  s                       r  r1  hitbtc.parse_orderM	  st   D e%67 v.v.!!%4  0""5/:""5,7NN7+	""5,7!!%!8!!%)>?(()9)9%)JK##E84!!(3!??5+6&&uo>OOE84	  
E 
" 
 R 
 	 

 Y/ 
 !"4 
 "#5 
 f 
 U 
 f 
 D 
 D 
 ; 
  
 $//%? 
  f! 
" # 
$  ,,ULA#!3 
4 5 	r  c                   #    U R                  5       I Sh  vN   SnUb%  U R                  U5      nU R                  US   5      nSnU R                  SX25      u  pBSnUS:X  a  U R	                  U5      I Sh  vN nO8US:X  a  U R                  U5      I Sh  vN nO[        U R                  S-   5      eU R                  US/ 5      nU R                  XaS5      $  N Nd NF7f)	ar  
fetches margin mode of the user

https://api.hitbtc.com/#get-margin-position-parameters
https://api.hitbtc.com/#get-futures-position-parameters

:param str[] symbols: unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `margin mode structures <https://docs.ccxt.com/#/?id=margin-mode-structure>`
Nr   rh   r=   r>   z; fetchMarginModes() supports swap contracts and margin onlyconfigr  )
r?  ri  r  r  privateGetMarginConfigprivateGetFuturesConfigr)   r  r,  parse_margin_modes)r  rf  r  r  r   r  r  s          r  fetch_margin_modeshitbtc.fetch_margin_modes	  s      !!!))'2G[[,F
!??@QSYb
!!88@@H$ 6!!99&AAH& DGG&ccdd(B7&&vAAc 	" A& Bs5   C CA C 7C8C CAC C C c                 p    U R                  US5      nUU R                  X25      U R                  US5      S.$ )Nr  rp  )r   r  r   )r  r  rY  )r  r   r  rp  s       r  parse_margin_modehitbtc.parse_margin_mode 
  s?    ##J9&&x800]K
 	
r  fromAccount	toAccountc                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  X5      nU R                  U R                  S0 5      nUR                  5       nUR                  5       nU R                  XU5      n	U R                  XU5      n
X:X  a  [        U R                  S-   5      eUS   UU	U
S.nU R                  U R                  X5      5      I Sh  vN nU R                  X5      $  N N7f)a  
transfer currency internally between wallets on the same account

https://api.hitbtc.com/#transfer-between-wallet-and-exchange

: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://docs.ccxt.com/#/?id=transfer-structure>`
Nr  zJ transfer() fromAccount and toAccount arguments cannot be the same accountr  )r;  r  sourcedestination)r?  r;  currency_to_precisionr  r  lowerr  r(   r  privatePostWalletTransferrC  parse_transfer)r  r*  r  r  r  r  r;  requestAmountr  fromIdtoIdrD  r  s                r  r   hitbtc.transfer
  s      !!!==&224@7GL!'')OO%	!!.{K9E>TWW'sstt #	
 77G8TUU ""866- 	"  Vs"   DC>CD(D )D Dr   c           
      Z    U R                  US5      S S U R                  S U5      S S S S US.	$ )Nr   )	r  ru  rz  r;  r  r  r  r  r   )r  r  )r  r   r;  s      r  r  hitbtc.parse_transfer.
  sC     ""8Q///h?

 
	
r  c                   #    U R                  5       I S h  vN   US:w  a  [        U R                  S-   5      eU R                  U R                  S0 5      nUR                  5       nUR                  5       nU R                  Xc5      nU R                  Xd5      nX4:X  a  [        U R                  S-   5      eUb  UcC  [        UR                  5       5      n[        U R                  S-   SR                  U5      -   5      eUUU R                  X5      S.nU R                  U R                  X5      5      I S h  vN n	SU	0$  GN) N7f)	Nr-  z6 convertCurrencyNetwork() only supports USDT currentlyr  z8 convertCurrencyNetwork() fromNetwork cannot be the samezm convertCurrencyNetwork() requires a fromNetwork parameter and a toNetwork parameter, supported networks are rX  )from_currencyto_currencyr  r   )r?  r#   r  r  r  r.  r  r(   r  r  r'   r]  r  privatePostWalletConvertrC  )
r  r*  r  fromNetwork	toNetworkr  r  r  rD  r  s
             r  convert_currency_networkhitbtc.convert_currency_networkB
  sX    !!!6>*b bcc??4<<R@!'')OO%	&&x=$$X9	#TWW'aabbY%6(D#DGG  /^  %^  ae  aj  aj  ko  ap  %p  q  q($00>

 66t{{77STT H
 	
) 	"$ Us"   ED?DE6E7	EEr<  r>  c                 |  #    U R                  XE5      u  pEU R                  5       I Sh  vN   U R                  U5        U R                  U5      nUS   UUS.nUb  XGS'   U R	                  U R
                  S0 5      nU R                  US5      n	U	b0  US:X  a*  U R                  X5      n
U
b  XS'   U R                  US5      nU R	                  U R
                  S	0 5      nU R                  US
S5      nU(       a  SUS'   U R                  U R                  Xu5      5      I Sh  vN nU R                  X5      $  GN N7f)ay  
make a withdrawal

https://api.hitbtc.com/#withdraw-crypto

: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  )r;  r  r<  r=  r  r   r-  network_coder   r  FTinclude_fee)handle_withdraw_tag_and_paramsr?  check_addressr;  r  r  r@  r  rA  r
  privatePostWalletCryptoWithdrawrC  r  )r  r*  r  r<  r>  r  r;  rD  r  r   rE  withdrawOptionsr  r  s                 r  r   hitbtc.withdraw[
  s;     99#F!!!7#==& 

 ?$'L!??4<<R@((;dfn ,,X?M(*7'YYvy1F//$,,
BG^^O\5I
%)GM"==dkk'>Z[[ %%h997 	"* \s"   'D<D7C7D<!D:"D<:D<c                   #    U R                  5       I Sh  vN   Sn0 nUbJ  U R                  U5      nU R                  US   5      nU R                  U5      nSR	                  U5      US'   SnU R                  SX25      u  pbUS:w  a  [        U R                  S-   U-   S-   5      eU R                  U R                  XB5      5      I Sh  vN n[        UR                  5       5      n0 n	[        S[        U5      5       HP  n
U R                  X5      nU R                  X{5      nU R                  U5      nUS	   nU R!                  X5      nXU'   MR     U R#                  U	S	U5      $  GNO N7f)
a  
fetches funding rates for multiple markets

https://api.hitbtc.com/#futures-info

:param str[] symbols: unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
Nr   rh  rf  r`   r>   z& fetchFundingRates() does not support z marketsr  )r?  ri  r  rj  r]  r  r-   r  publicGetPublicFuturesInforC  r  r  r  r  r  r  parse_funding_rater,  )r  rf  r  r  rD  queryMarketIdsr  r  rn  fundingRatesr  rp  rawFundingRater  r  fundingRates                   r  fetch_funding_rateshitbtc.fetch_funding_rates
  sg     !!!))'2G[[,F!__W5N!$.!9GI99:Mv^6>tww)QQTXX[eeff88W9UVV$ )	q#i.)A''	5H!__X@N++h/K *F11.NK#.  * ##L(GDDO 	" Ws#   E*E%B2E*	E(
BE*(E*c           
        #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXUSUS5      I Sh  vN $ Sn0 nU R                  SXt5      u  ptUb  U R	                  U5      nUS   nUS	   US
'   Ub  X'S'   Ub  X7S'   U R                  U R                  Xt5      5      I Sh  vN n[        UR                  5       5      n	/ n
[        S[        U	5      5       H  nX   nU R                  U5      nX   n[        S[        U5      5       He  nX   nU R                  US   5      nU R                  US5      nU R                  US5      nU
R                  UUUU R!                  U5      US.5        Mg     M     U R#                  U
S5      nU R%                  UXU5      $  GN GNj N7f)ak  

https://api.hitbtc.com/#funding-history

fetches historical funding rate prices
:param str symbol: unified symbol of the market to fetch the funding rate history for
:param int [since]: timestamp in ms of the earliest funding rate to fetch
:param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest funding rate
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
NFr_   r  8hr   r  r  r  rf  r  r   r   funding_rateru  )r   r  r  ru  rz  )r?  r  r  r  r  $publicGetPublicFuturesHistoryFundingrC  r  r  r  r  rl  r  r  r  r  r  sort_byfilter_by_symbol_since_limit)r  r  r  r   r  r  r  rD  r  	contractsratesr  rp  r  fundingRateDatar4  r2  symbolInnerr  rz  sorteds                        r  fetch_funding_rate_history!hitbtc.fetch_funding_rate_history
  s     !!!88AZ\fg@@AZ\bkprvx~  AE  F  F  F
 227GL[[(FH%F!'GI#FO$GBB4;;wC_``  )	q#i.)A |H**84K&0O1c/23'*"..{8/DE"..unE++E;?!)#.!%!9 (  4	 *  e[100NNw 	" F( as5   GF9;GF<A.GF?C8G<G?Gc                   #    U R                  5       I Sh  vN   0 nSnSnU R                  SSU5      u  pBUS:X  a  SnU R                  SU5      u  pRU R                  USS/5      nSnUb)  U R	                  U R                  X25      5      I Sh  vN nOvUS:X  a)  U R                  U R                  X25      5      I Sh  vN nOGUS:X  a)  U R	                  U R                  X25      5      I Sh  vN nO[        U R                  S-   5      e/ n[        S[        U5      5       H%  nUR                  U R                  Xh   5      5        M'     U$  GN6 N N Nf7f)	a6  
fetch all open positions

https://api.hitbtc.com/#get-futures-margin-accounts
https://api.hitbtc.com/#get-all-margin-accounts

:param str[]|None symbols: not used by hitbtc fetchPositions()
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported, defaults to spot-margin endpoint if self is set
:param bool [params.margin]: True for fetching spot-margin positions
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nr~   r<   r>   r   r=   z. fetchPositions() not support self market typer   )r?  r  r  rA  privateGetMarginAccountrC  privateGetFuturesAccountr-   r  r  r  r  parse_position)	r  rf  r  rD  r   r   r  r  r  s	            r  fetch_positionshitbtc.fetch_positions  sO     !!!

!??@PRVX^_
J!??@PRXY
6L(#;<!!99$++g:VWWHV#!%!>!>t{{7?[!\\x'!%!=!=dkk'>Z![["477-]#]^^B q#h-(AMM$--hk:; )m 	" X ][sG   EEA7EE.E=E>.E,E-A EEEEc                 h  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnSnU R                  SSU5      u  pRU R                  SU5      u  pbU R	                  USS/5      nSnUb)  U R                  U R                  XB5      5      I Sh  vN nOvUS:X  a)  U R                  U R                  XB5      5      I Sh  vN nOGUS:X  a)  U R                  U R                  XB5      5      I Sh  vN nO[        U R                  S-   5      eU R                  Xs5      $  GN N Nb N57f)	al  
fetch data on a single open contract trade position

https://api.hitbtc.com/#get-futures-margin-account
https://api.hitbtc.com/#get-isolated-margin-account

:param str symbol: unified market symbol of the market the position is held in, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported, defaults to spot-margin endpoint if self is set
:param bool [params.margin]: True for fetching a spot-margin position
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nr  r  r}   r   r=   r>   z- fetchPosition() not support self market type)r?  r  r  r  rA  %privateGetMarginAccountIsolatedSymbolrC  &privateGetFuturesAccountIsolatedSymbolr-   r  r  rJ  s           r  fetch_positionhitbtc.fetch_positionI  s7     !!!V$fTl
 

!??QUW]^
!??QWX
6L(#;<!!GGT[HdeeHV#!%!L!LT[[Y`Mi!jjx'!%!K!KDKKX_Lh!ii"477-\#\]]B ""844i 	" f kisF   D2D)BD2D,.D2D..D2:D0;/D2,D2.D20D2positionc                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  US/ 5      nS nS nS n	[        S[	        U5      5       H=  n
Xj   nU R                  US5      nU R                  US5      nU R                  US5      n	M?     U R                  US	/ 5      nS n[        S[	        U5      5       H  n
X   nU R                  US
5      nM     U R                  US5      nU R                  X5      nUS   nU R                  0 SU_SS _SU_SS _SU_SU_SU_SU_SS _SS _SU	_SS _SS _SS _SS _SS _SU R                  U5      _US S S US S US S S S.E5      $ )Nr  r   r  	positionsr   price_liquidationprice_entryr  r0  margin_balancer  r   r  notionalr   
marginTypeliquidationPrice
entryPriceunrealizedPnlr   r  r  	markPrice	lastPricer  r   ru  )rz  r  maintenanceMarginmaintenanceMarginPercentage
collateralinitialMargininitialMarginPercentager   marginRatior   r   )r  r  r  r  r  rl  safe_positionr  )r  r  r  r   r   rz  r  r  r  r  r  r2  r0  r  rp  r  s                   r  r  hitbtc.parse_position  s9   B %%h7
##Hj9##Hl;OOHk2>	
	q#i.)ALE#//7JK))%?J((
;I	 *
 __X|R@

q#j/*AME))%1ABJ + ##Hh7!!(3!!! #
H#
$#
 f#
 	#

 *#
 *#
  0#
 *#
 T#
 $#
 #
 D#
 #
 #
 D#
  d!#
" 1##
$ !#'!%+/$!'+ !#9#
  	r  c           	          U R                  US5      nU R                  US5      nU R                  U R                  S U5      S UU R	                  U5      UUS.U5      $ )Nru  open_interest)r  openInterestAmountopenInterestValueru  rz  r   )r  r  safe_open_interestr  r  )r  interestr  rz  values        r  parse_open_interesthitbtc.parse_open_interest  sm      ##Hk:  ?;&&&&tV4"&!&1 (
  	r  c                   #    U R                  5       I Sh  vN   0 nU R                  U5      nSnUb%  U R                  U5      nSR                  U5      US'   U R	                  U R                  X25      5      I Sh  vN n/ n[        UR                  5       5      n[        S[        U5      5       H;  nXx   n	U R                  U	5      n
UR                  U R                  XY   U
5      5        M=     U R                  USU5      $  N N7f)a7  
Retrieves the open interest for a list of symbols

https://api.hitbtc.com/#futures-info

:param str[] [symbols]: a list of unified CCXT market symbols
:param dict [params]: exchange specific parameters
:returns dict[]: a list of `open interest structures <https://docs.ccxt.com/#/?id=open-interest-structure>`
Nrh  rf  r   r  )r?  ri  rj  r]  r  rC  r  r  r  r  rl  r  r  r,  )r  rf  r  rD  rn  r  resultsmarketsr  rp  r  s              r  fetch_open_interestshitbtc.fetch_open_interests  s      !!!%%g.	0I!$)!4GI88W9UVV$ x}}'q#g,'AzH**84KNN433H4FTU ( ##GXw??? 	" Ws#   DDA$D;D<BDDc                 (  #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSUS   0nU R	                  U R                  XB5      5      I Sh  vN nU R                  XS5      $  Nw N7f)a*  
Retrieves the open interest of a derivative trading pair

https://api.hitbtc.com/#futures-info

:param str symbol: Unified CCXT market symbol
:param dict [params]: exchange specific parameters
:returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=interest-history-structure:
Nr>   z1 fetchOpenInterest() supports swap contracts onlyr  r  )r?  r  r)   r   publicGetPublicFuturesInfoSymbolrC  r  rc  s         r  fetch_open_interesthitbtc.fetch_open_interest&  s      !!!V$f~DGG&YYZZfTl
 >>t{{7?[\\  ''99/ 	" ]"   BBA!B8B9BBc                 (  #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSUS   0nU R	                  U R                  XB5      5      I Sh  vN nU R                  XS5      $  Nw N7f)a  
fetch the current funding rate

https://api.hitbtc.com/#futures-info

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
Nr>   z0 fetchFundingRate() supports swap contracts onlyr  r  )r?  r  r)   r  r  rC  r  rc  s         r  fetch_funding_ratehitbtc.fetch_funding_rateI  s      !!!V$f~DGG&XXYYfTl
 >>t{{7?[\\  &&x88/ 	" ]r  c                    U R                  US5      nU R                  US5      n0 SU_SU R                  S U5      _SU R                  US5      _SU R                  US5      _S	U R                  US
5      _SS _SU R                  U5      _SU_SU R                  US5      _SU R                  U5      _SU_SU R                  US5      _SS _SS _SS _SS _SS _SS 0E$ )Nnext_funding_timeru  r   r  r  
mark_price
indexPriceindex_priceinterestRateinterest_rateestimatedSettlePricerz  r  r  fundingTimestampfundingDatetimenextFundingRateindicative_funding_ratenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimeinterval)r  r  r  r  )r  r  r  fundingDateTimerz  s        r  r  hitbtc.parse_funding_ratel  sh     **85HI##Hk:
H
d&&tV4
 ))(LA
 $**8]C	

 D,,XG
 #D
 1
 
 4++HnE
  ?
 
 t//:ST
 #D
 "4
 "4
  '!
" &t#
$ %
 	
r  c                   #    U R                  5       I S h  vN   U R                  U5      nU R                  US5      nUS   (       a  Uc  [        U R                  S-   5      eU R                  U5      nUS:w  a  U R                  X5      nOSnUS   US.nUb  XhS'   S n	S n
U R                  SXT5      u  pU R                  SU5      u  pS nU	S:X  a)  U R                  U R                  X5      5      I S h  vN nOSU	S:X  d  U	S	:X  d  U
S
:X  a)  U R                  U R                  X5      5      I S h  vN nO[        U R                  S-   5      eU R                  U R                  X5      U R                  U5      US.5      $  GNj N NU7f)Nr   r>   zD modifyMarginHelper() requires a leverage parameter for swap marketsr   r  )r  r  modifyMarginHelperr=   r<   isolatedz2 modifyMarginHelper() not support self market type)r  r  )r?  r  r  r'   r  number_to_stringrU  r  r  &privatePutFuturesAccountIsolatedSymbolrC  %privatePutMarginAccountIsolatedSymbolr-   parse_margin_modificationr  )r  r  r  r  r  r  r   stringAmountrD  r   r   r  s               r  modify_margin_helperhitbtc.modify_margin_helper  s    !!!V$##FJ7&>'2x(xyy,,V43--fCFFTl$
 "*J

!??@TV\e
!??@TV\]
!HHU\IeffHH$**>JR\D\!GGT[HdeeHtww)]]^^& {{499(K''/N
  	a 	"2 ges5   FF CF4F5:F/F0AFFFdatac                     U R                  US/ 5      nU R                  US5      nU R                  US5      nUUS   S SS S U R                  US5      S U R                  U5      US.
$ )Nr0  r   r  r  r  r*  )
r   r  r  r   r  totalr*  r  ru  rz  )r  r  r  )r  r  r  r0  currencyInforz  s         r  r   hitbtc.parse_margin_modification  s{    * __T<<
z15##D,7X&$$$\6:1 
 	
r  c                    #    U R                  U5      S:w  a  [        U R                  S-   5      eU R                  XSU5      I Sh  vN $  N7f)aT  
remove margin from a position

https://api.hitbtc.com/#create-update-margin-account-2
https://api.hitbtc.com/#create-update-margin-account

:param str symbol: unified market symbol
:param float amount: the amount of margin to remove
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported, defaults to the spot-margin endpoint if self is set
:param bool [params.margin]: True for reducing spot-margin
:returns dict: a `margin structure <https://docs.ccxt.com/#/?id=reduce-margin-structure>`
r   zc reduceMargin() on hitbtc requires the amount to be 0 and that will remove the entire margin amountreduceN)r  r(   r  r  r  r  r  r  s       r  reduce_marginhitbtc.reduce_margin  sV        (C/TWW  (M  M  N  N..vxPPPPs   AAAAc                 D   #    U R                  XSU5      I Sh  vN $  N7f)a5  
add margin

https://api.hitbtc.com/#create-update-margin-account-2
https://api.hitbtc.com/#create-update-margin-account

:param str symbol: unified market symbol
:param float amount: amount of margin to add
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported, defaults to the spot-margin endpoint if self is set
:param bool [params.margin]: True for adding spot-margin
:returns dict: a `margin structure <https://docs.ccxt.com/#/?id=add-margin-structure>`
addN)r  r!  s       r  
add_marginhitbtc.add_margin   s"      ..vufMMMMr  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnU R                  SU5      u  pRU R                  USS/5      nSnUb)  U R	                  U R                  XB5      5      I Sh  vN nOUS   S:X  a)  U R	                  U R                  XB5      5      I Sh  vN nO|US   S	:X  a)  U R                  U R                  XB5      5      I Sh  vN nOJUS   S:X  a)  U R	                  U R                  XB5      5      I Sh  vN nO[        U R                  S
-   5      eU R                  Xc5      $  GN4 N N Ng N77f)a'  
fetch the set leverage for a market

https://api.hitbtc.com/#get-futures-margin-account
https://api.hitbtc.com/#get-isolated-margin-account

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'cross' or 'isolated' only 'isolated' is supported, defaults to the spot-margin endpoint if self is set
:param bool [params.margin]: True for fetching spot-margin leverage
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
Nr  r  re   r   r=   r  r<   r>   z- fetchLeverage() not support self market type)
r?  r  r  rA  r  rC  r  r-   r  parse_leverage)r  r  r  r  rD  r   r  s          r  fetch_leveragehitbtc.fetch_leverage  sL     !!!V$fTl
 
!??QWX
6L(#;<!!GGT[HdeeHf~'!%!K!KDKKX_Lh!ii6)!%!L!LT[[Y`Mi!jj8+!%!K!KDKKX_Lh!ii"477-\#\]]> ""844e 	" f jjisX   EE
A.EE1E7E81E)E*1EE/EEEEEr   c                     U R                  US5      nU R                  US5      nUU R                  X25      U R                  US5      UUS.$ )Nr  r   r  )r   r  r   longLeverageshortLeverage)r  r	  r  rY  )r  r   r  rp  leverageValues        r  r)  hitbtc.parse_leverageQ  sW    ##Hh7))(J?&&x8006B)*
 	
r  c                 j  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   US   c  [        U R                  S-   5      eU R                  U5      nU R	                  US5      nU R                  US   S   SS5      nUS	   S
:w  a  [        U R                  S-   5      eUS:  d  X:  a*  [        U R                  S-   [        U5      -   S-   U-   5      eUS   [        U5      U R                  X%5      S.nU R                  U R                  Xs5      5      I Sh  vN $  N N7f)a-  
set the level of leverage for a market

https://api.hitbtc.com/#create-update-margin-account-2

: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  zj setLeverage() requires a margin_balance parameter that will transfer margin to the specified trading pairr  r   r  2   r  r>   z+ setLeverage() supports swap contracts onlyr   z0 setLeverage() leverage should be between 1 and z for r  )r  r   r  )r'   r  r?  r  r  r	  r)   r(   strrU  r  rC  )r  r   r  r  r  r  maxLeveragerD  s           r  set_leveragehitbtc.set_leverage\  sL     >#DGG.Y$YZZ!!!"#+#DGG  /[  %[  \  \V$!!&*:;''x(8(DeRP&>V#DGG&SSTTqLh4TWW'YY\_`k\llovvy  A  ATlH"66vF
 @@WA]^^^! 	"  _s"   /D3D/C8D3*D1+D31D3codesc                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  X15      $  N. N7f)a$  
fetch deposit and withdraw fees

https://api.hitbtc.com/#currencies

: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 `fees structures <https://docs.ccxt.com/#/?id=fee-structure>`
N)r?  r+  parse_deposit_withdraw_fees)r  r7  r  r  s       r  fetch_deposit_withdraw_fees"hitbtc.fetch_deposit_withdraw_fees{  sG      !!!55f==4 //@@7 	"=s   A	AA	AA	A	c                    U R                  US/ 5      nU R                  U5      n[        S[        U5      5       H  nX5   nU R	                  US5      nU R                  U5      nUb  UR                  5       OS nU R                  US5      n	U R                  US5      n
U	U	b  SOS S.nU
SL a  XS	'   US S S.S
.US   U'   M     U$ )Nr  r   r   r!  r   F)r%  r   Tr   )r   r&  )r  deposit_withdraw_feer  r  r  r-  r.  r  )r  r%  r;  r  r  r4  networkEntryr6  r7  withdrawFee	isDefaultwithdrawResults               r  parse_deposit_withdraw_fee!hitbtc.parse_deposit_withdraw_fee  s    0 ??3
B7**3/q#h-(A#;L((yAI11)<K2=2I+++-PTK**<FKi@I"(3(?ed$N D %3z"*"&/F:{+ )( r  c                   #    U R                  5       I Sh  vN   SnU R                  SUS5      u  pCU R                  U5      nUS   US.nU R                  U R	                  Xc5      5      I Sh  vN nU R                  Xu5      $  Nm N7f)a  
closes open positions for a market

https://api.hitbtc.com/#close-all-futures-margin-positions

:param str symbol: unified ccxt market symbol
:param str side: 'buy' or 'sell'
:param dict [params]: extra parameters specific to the okx api endpoint
:param str [params.symbol]: *required* unified market symbol
:param str [params.marginMode]: 'cross' or 'isolated', default is 'cross'
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NrD   ro  r  )r  rp  )r?  r  r  ,privateDeleteFuturesPositionMarginModeSymbolrC  r1  )r  r  r  r  r   r  rD  r  s           r  close_positionhitbtc.close_position  s      !!!
!??QWY`a
V$Tl%
 JJ4;;W^Kghh  111 	" is"   BBAB.B/BBc                    > U R                  U R                  S5      nU R                  USS5      nSn[        [        U ]  XU5      u  pbUc  US:X  d  USL a  SnXb/$ )aM  
@ignore
       marginMode specified by params["marginMode"], self.options["marginMode"], self.options["defaultMarginMode"], params["margin"] = True or self.options["defaultType"] = 'margin'
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :returns Array: the marginMode in lowercase
       defaultTyper=   FNTr  )r  r  r
  r  r4   r  )r  
methodNamer  defaultValuerI  isMarginr   r  s          r  r  $hitbtc.handle_margin_mode_and_params  sl     &&t||]C>>&(E:
"64Nzcop
x'X-='
##r  reasonurlmethodheadersbodyc
                 .   U R                  US5      n
U R                  U
S5      nUbn  U R                  S-   U-   nU R                  U
SS5      nU R	                  U R
                  S   X5        U R                  U R
                  S   X5        [        U5      eg )Nerrorr*   messagedescriptionr(  r)  )r  r  r  r  throw_exactly_matched_exceptionr  throw_broadly_matched_exceptionr#   )r  r*  rN  rO  rP  rQ  rR  r  requestHeadersrequestBodyrT  	errorCodefeedbackrV  s                 r  handle_errorshitbtc.handle_errors	  s    " '2$$UF3	 ww}t+H((	=IG001I9_001I7]))r  r   r  c                 ^   U R                  X@R                  U5      5      nU R                  X5      nU R                  S   U   S-   U-   n	S n
[	        UR                  5       5      n[        U5      nSS0nUS:X  a   U(       a  SU R                  U5      -   n
X-   n	OU R                  U5      nUS:X  a  U R                  5         [        U R                  5       5      nUSU-   /nUS:X  a  U
b  UR                  U
5        OUR                  U5        UR                  U5        S	R                  U5      nU R                  U R                  U5      U R                  U R                   5      ["        R$                  S
5      nU R&                  S-   U-   S-   U-   nU R)                  U5      nSU-   US'   XXeS.$ )Nr   r  zContent-Typezapplication/jsonr  ?r   z/api/3/ hexr  zHS256 Authorization)rO  rP  rR  rQ  )rA  extract_paramsimplode_paramsr  r  r  r  	urlencodejsoncheck_required_credentialsr3  r  r  r]  hmacencodesecrethashlibsha256apiKeystring_to_base64)r  pathr   rP  r  rQ  rR  r  implodedPathrO  
getRequestr  queryLengthru  payloadpayloadString	signaturesecondPayloadencodeds                      r  signhitbtc.sign$  s   		&"5"5d";<**48iis#c)L8
EJJL!$i.
 U? 4>>%#88
&99V$D)++-DJJL)Iy<78G)NN:.t$NN9%GGG,M		$++m"<dkk$++>VX_XfXfhmnI KK#-	9C?)KM++M:G'/''9GO$dOOr   r  )o__name__
__module____qualname____firstlineno__r   r  r  r"   r   r  r   r8  r3  r	   rF  rL  r   rU  r^  r   rd  r   r   rq  dictrb  r
   r   r  r   r  r  r  r  r  r   r    r  r  r  r  r   r  r   r  r   r  r  r   r  r  r  r#  r   r-  r2  r6  r<  rC  rK  rQ  r   r   r   rZ  floatra  objectr]  r}  r1  r   r  r   r  r!   r   r  r  r   r   r  r  r   r  r  r  r  r  r  r   r  r  r   r  r  r"  r&  r   r*  r)  intr5  r:  rB  rF  r  r^  rz  __static_attributes____classcell__)r  s   @r  r4   r4      s   j# jX# *, IV IV -/ d: dL >@ !
 !
N !
F =? %
 %
> %
N
) 
) *, $, $,L 68 3 3F 3> 6:" )G7 )G )GV)4 ) )6 )V <@d[] $ $S $ $bfglbm $L 37TX\eg +AC +As +ARU +AZc cv c cJ&QP:s :3R
T R
X R
Q\ R
h <@daenp dS d d[^ duy  {F  vG d 04$UYbd [ [C [s [imnyiz [ 37TX\eg \C \s \RU \lpq|l} \ :>DY[ w c `j : @DB PS P PS\ P,
T 
6 
EX 
* ;= 8c 8AT 8> /1 ![ !F ?CQUdhqs GL GL GL3 GL^a GLx|  ~B  yC GLR
 
4 
B 7;\`ik ,U ,U3 ,UVY ,Uptuzp{ ,U\ 8<B ;/C ;/ ;/z ?CQUdhqs OA3 OA OA3 OA^a OAb 59tZ^gi :Ac :A :ATW :Anrsxny :Ax =A '2 '2c '2R 59 %3c %3N 9=R '2S '2# '2R fjx|  FH 23 2 29 2I 2_b 2ru 2@ mqy{ $2 $2I $2Y $2X] $2fi $2L CG  [_  hj 6!6 6!s 6!) 6![d 6!ns 6!| 6!  UX 6!p	: 	:s sv s sj =A <BS	 <BP[ <B|
D 
* 
 ac $73 $7 $7C $7TW $7gt $7L
t 
x 
= 
(
3 
2 QU]_ ):3 ): ): ):# ):do ):V <@ 1E 1E| 1Ef >BPTcgpr IOs IO# IO]` IOV 8<B CW C4PX> CJ 8: A53 A5FRt RV RhF 6 =A )@' )@V =? !: !:F <> !9s !9+ !9F%
6 %
[ %
N LN 4 4Rd 4l#
d #
F #
N` #
J FH Q# Qu QL^ Q$ CE Ns NE NI[ N  8: ?53 ?5h ?5B	
t 	
V 	
x 	
 ?C2 _3 _ _> BFb %Aw %AN. .` CGr %23 %2i %2V[ %2N @BPT $ # s  c TX `c 6 &eBSW P Pr  r4   )9 ccxt.async_support.base.exchanger   ccxt.abstract.hitbtcr   rm  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   typingr"   ccxt.base.errorsr#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   ccxt.base.decimal_to_precisionr1   ccxt.base.preciser2   r4   r|  r  r  <module>r     s    6 ,  V  V  V  V  V  V  V  V  * 0 - - . ' & . ) * ) . 1 * 4 %f8PX{ f8Pr  