
    eis                       d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z" d dl#m$Z$ d dl%m&Z& d dl%m'Z' d dl%m(Z( d d	l%m)Z) d d
l%m*Z* d dl%m+Z+ d dl%m,Z, d dl%m-Z- d dl%m.Z. d dl%m/Z/ d dl%m0Z0 d dl%m1Z1 d dl%m2Z2 d dl%m3Z3 d dl4m5Z5 d dl6m7Z7  G d dee          Z8dS )    )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                       e Zd Zdef fdZd Zi fdee         fdZi fde	fdZ
i fdedefdZi fdedefdZdefd	Zi fdefd
Zi fdedefdZdi fdedefdZdndededefdZddi fdedededee         fdZdddi fdededefdZdndededefdZd ZdefdZ d Z!dndede"de#fdZ$dddi fdedededee#         fd Z%dddi fdedededee#         fd!Z&dddi fdedededee#         fd"Z'ddi fdedede(fd#Z)di fdedede*fd$Z+dnd%edede,fd&Z-i fdede,fd'Z.i fde/fd(Z0d)ddi fded*edededee1         f
d+Z2dndede1fd,Z3dddi fdedededee4         fd-Z5di fd.edefd/Z6dddi fd.edededefd0Z7dddi fdedededee4         fd1Z8di fd.edefd2Z9di fdefd3Z:di fd.edefd4Z;ddi fd.eded5e<d6e=d7e>d8e>fd9Z?di fded5e<d6e=d7e@d8e>f
d:ZAddi fdeBd;ed5e<d6e=d7e@d8e>d<efd=ZCdefd>ZDdnd?edede4fd@ZEdi fdee         deFfdAZGdnd<edeHfdBZIi fded7e@dCedDedeJf
dEZKdndFede"deJfdGZLdefdHZMdi fded7e@dIedJede#f
dKZNdi fdedeOfdLZPdddi fdededefdMZQdi fdedeeR         fdNZSi fdefdOZTdndPedefdQZUdndefdRZVdi fdefdSZWi fdefdTZXi fdedeYfdUZZdndedeYfdVZ[i fdede\fdWZ]dndXedede\fdYZ^i fded7e@de\fdZZ_i fded7e@de\fd[Z`i fdedeafd\Zbdnd]ededeafd^Zcdi fd]eddefd_Zedi fd`efdaZfdnde"fdbZgdi fded6e=de4fdcZhi df fdd	ZideddeedfedgedhediefdjZjdkdli ddfdmZk xZlS )ohitbtcreturnc                    |                      t          t          |                                           i ddddddgddd	d
di ddddddddddddddddddddddddddddddddddi ddd dd!dd"d d#d d$dd%dd&dd'dd(dd)dd*dd+dd,dd-d.d/dd0d i d1dd2dd3dd4dd5dd6dd7dd8dd9d d:dd;d.d<dd=dd>dd?dd@ddAdi dBddCddDddEddFddGddHddIddJddKddLddMddNddOddPddQddRdi dSddTddUddVddWddXddYd.dZdd[dd\dd]dd^dd_dd`ddaddbddcdddt          dedfdgdgdhdididhdjdkdldmgdndogdpdqdri dsdtdudtdvdtdwdtdxdtdydtdzdtd{dtd|dtd}dtd~dtddtddtddtddtddtddtdtdtdtdtdtdtdtdtdtdtdtdtdtdii ddddddddddddddddddddddddddddddddddi dddddddddddddddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddddiddddddddddddddddddddddhdddd|                     d          |                     d          |                     d          |                     d          g|                     d¦          |                     dæ          g|                     dĦ          |                     dŦ          g|                     dƦ          |                     dǦ          g|                     dȦ          |                     dɦ          g|                     dʦ          |                     d˦          g|                     d̦          |                     dͦ          g|                     dΦ          |                     d          g|                     dϦ          |                     dЦ          g|                     dѦ          |                     dЦ          gg
|                     d          |                     d          g|                     d¦          |                     dҦ          g|                     dĦ          |                     dæ          g|                     dƦ          |                     dæ          g|                     dȦ          |                     dŦ          g|                     dʦ          |                     dŦ          g|                     d̦          |                     dǦ          g|                     dΦ          |                     dӦ          g|                     dϦ          |                     dɦ          g|                     dѦ          |                     d˦          gg
dԜd՜iddddd dddd dddddלdddddddd؜d dddddddۜddddddܜdddddddݜd ddddddddddޜ	ddid	ddidddiddiddiddiddidddiddidddiddidddddddddddddd
di dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          d t          dt          dt          dt          dt          i dt          dt          dt          dt          d	t          d
t          dt           dt          dt          dt          dt          dt          dt          dt          dt"          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          d t          d!t          d"t          d#t          d$t          d%t          d&t          t          t          t          t          t          d'i d(d)d*d+d,d-i d.d/d0d.d+d1d*d+d2d2d3d4d,d5d6d6d7d7d8d8d9d9d:d:d;d;d<d<d=d=d>d>d?d?i d@dAdBdCdDdEdFdGdHdHdIdIdJdJdKdKdLdLdMdNdOdOdPdPdQdQdRdRdSdSdTdTdUdUi dVdVdWdWdXdXdYdYdZdZd[d[d\d\d]d]d^d^d_d_d`d`dadbdcdddededfdfdgdhdidii djdjdkdkdldldmdmdndndodpdqdqdrdsdtdtdududvdwdxdxdydydzdzd{d{d|d|d}d~i ddddddddddddddddddddddddddddddddddddidddddddiddi dddddddddddddddddddddddddddddddddddddddd          S (  Nidr4   nameHitBTC	countriesHK	rateLimitgDl
@version3has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withdrawprecisionModeurlszchttps://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feesr   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putr   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features)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   rK   createOrdersrt   r}   rz   r   rV   ru   extendsdefaultr   )r   rK   r}   rt   rz   rV   forDerivatives)linearinverse)r   rA   r   rC   rD   
timeframesM1M3M5M15M30H1H4D1D71M)
1m3m5m15m30m1h4h1d1wr   
exceptions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optionsERC20ETHTRC20)r6  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)rA   fundingrC   rD   
includeFee)defaultNetworkdefaultNetworksnetworksaccountsByTyper   commonCurrencies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rollingWindowSizeg     @@)deep_extendsuperr4   describer1   parse_numberr.   r#   r/   r%   r$   r)   r(   r+   r&   r*   r,   r0   )self	__class__s    W/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/hitbtc.pyr  zhitbtc.describe   s   fd 3 3 < < > > jA
(jA
HjA
 $jA
 jA
 sjA
  VVV $V 	V
 %V %V TV "4V tV  V 'V tV &tV (V 'V  (!V" "4#V 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 V 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 V 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 V 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 VjA
@ YAjA
B }AB 
 ==  ,F,S
 9_! CjA
l  )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@ @mjA
n !%"&!..x88!..x88 "..s33T5F5Fx5P5PQ!..t44d6G6G6Q6QR!..u55t7H7H7R7RS!..u55t7H7H7R7RS!..v668I8I(8S8ST!..v668I8I(8S8ST!..w779J9J89T9TU!..w779J9J39O9OP!..w779J9J99U9UV!..x88$:K:KI:V:VW" "..s33T5F5Fx5P5PQ!..t44d6G6G6Q6QR!..u55t7H7H7R7RS!..u55t7H7H7R7RS!..v668I8I(8S8ST!..v668I8I(8S8ST!..w779J9J89T9TU!..w779J9J89T9TU!..w779J9J89T9TU!..x88$:K:KH:U:UV"  !ojA
r #&+(,,0,1).+06:#'#'"&#'	( ( #(/4$)$)+027#')$ $, %)&*!%$*%+*/&*& & '+#($)*/&*# # '+!%#($)*/&*( ( $(&*!%$*,-%+#($)*/&*
* 
*  #y? ?B y  )$d$ %e# %e& %e( %e*# #( "#3 "#3 	  "#3 "#3 	 }f fsjA
@  AjA
X 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 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 9 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 9h +--**q9 9 9t w< <YjA
R ") #$ $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 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 y 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 y 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 y 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 yn 5oy yv #')+	# # !%MI ISjA
f  !!u! z! |	!
 |! {! z! x! {! t! i! |! z! w! !  !!" v#!$ #)! ! !gjA
R  SjA
 j j j	    c                 *    |                                  S N)milliseconds)r  s    r  noncezhitbtc.nonce  s      """r  c                 .  K   |                      |           d{V }g }t          |                                          }t          dt	          |                    D ]}||         }|                    d          r!|                     ||          }|                     |d          }|                     |d          }	|dk    }
|dk    }| 	                    |dd	          }|o|}|	du}|
o| }d	}| 
                    |d
d          }|                     |d          }|                     |d          }|                     |          }|                     |          }|                     |          }d}d}|dz   |z   }d}d}d}d}|
rP|                     d          }|}|                     |          }|duo||k    }| }|dz   |z   }|r|dz   |	z   }d}nd}|                     |d          }|                     |d          }|                     |          } |                     |          }!|                    i d|d|d|d|d|d|d|d|d|d|d|d|d|d|d d!d"|
d#|||                     |d$          |                     |d%          ||	ddd|| |!d&|                     d          |                     |d'd(          d)| dd)|!dd)|                     t          j        ||                    dd)d*d|d+           |S ),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futuresrA   margin_tradingFbase_currency
underlyingquote_currencyfee_currency/1:-rD   rC   quantity_increment	tick_sizer7   symbolbasequotesettlebaseIdquoteIdsettleIdrB   rE   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ir7   marketr   r  r  rA   marginTradingrB   rD   rC   rE   r  r  feeCurrencyIdr  r  r  r  r  r  r  r  r   r   	lotString
stepStringlotsteps"                                     r  fetch_marketszhitbtc.fetch_markets  so      33F;;;;;;;;> 8==??##q#c((## ^	 ^	AQB{{6"" __Xr22F))&&99J&&vx88F"i/H&(D NN63CUKKM+mFD(F+VDF''NNF&&v/?@@G ,,V^DDM**622D++G44E11-@@KHFCZ%'FDLFG "#0055(00:: ,C5F?$*#. "#c\F2F#DD!D((1EFFI))&+>>J##I..C$$Z0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5#//8NPQRR! !
  ## 
  $# 
  $001CIz1Z1Z[[#  $  e3 3 3 3 3 3 3h r  c                   K   |                      |           d{V }i }t          |                                          }t          dt	          |                    D ]}||         }|                     |          }||         }|                     |dg           }	i }
t          dt	          |	                    D ]}|	|         }|                     |dd          }|                     |          }||	                                n|}|||d| 
                    |d          |                     |d          |                     |d          | 
                    |d	          d
dddid	|
|<   |                     |||| 
                    |d          |                     |d          |                     |d           |                     |d          |                     |d          |
dddddidd          ||<   |S )a  
        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  r7   r  r  feedepositr   r  r  precision_transfer	full_namedelistedr  )r  coder7   r  r8   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_currencieszhitbtc.fetch_currencies  sS      55f========V (--//**
q#j//** -	 -	A#AJ**:66DZ(E..
B??KH1c+..//  (^
 ..z:yQQ	"55i@@6A6Mk//111TX&#*"++JEE#~~j/JJ $z;K L L!%!1!1*>P!Q!Q"#'#'% %) )%%   77 !--e5IJJ((<<"nnUJ???>>%AA NN52BCC$##  #9 9  F4LL& r  r'  c                 `  K   |                                   d{V  |                     |          }d|d         i}|                     |d          }|T|dk    rN|                     | j        d          }|                     ||          }|||d<   |                     |d          }|                     |                     ||                     d{V }|                     |d          }	| 	                    |	          |                     |d          |                     |d          d|d	S )
a}  
        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currencyr7   r  r8  r  address
payment_id)r7  r8  tagr  r  )
load_marketsr7  safe_string_upperr  r4  r  omitprivatePostWalletCryptoAddressextendr
  )
r  r'  r  r7  requestr  r  parsedNetworkr  r.  s
             r  create_deposit_addresszhitbtc.create_deposit_address   sV      !!!!!!!!!==&&
 ((;;dfnnt|Z@@H ,,Xw??M(&3
#YYvy11F<<T[[RX=Y=YZZZZZZZZ %%h
;;
//
;;'')<<##Hl;;
 
 	
r  c                   K   |                                   d{V  |                     |          }d|d         i}|                     |d          }|T|dk    rN|                     | j        d          }|                     ||          }|||d<   |                     |d          }|                     |                     ||                     d{V }|                     |d          }	|                     |	d          }
|                     |	d          }|                     |	d	          }| 	                    |          }||d|
|d
S )at  
        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>`
        Nr7  r7   r  r8  r  r   r8  r9  )r  r7  r  r8  r:  )
r;  r7  r<  r  r4  r  r=  privateGetWalletCryptoAddressr?  r
  )r  r'  r  r7  r@  r  r  rA  r  firstAddressr8  r.  r:  
parsedCodes                 r  fetch_deposit_addresszhitbtc.fetch_deposit_address#  sx      !!!!!!!!!==&&
 ((;;dfnnt|Z@@H ,,Xw??M(&3
#YYvy11F;;DKKQW<X<XYYYYYYYY x33""<;;%%lJ??
|\::,,Z88
"
 
 	
r  c                 p   d|i}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )Nr  r   r7  	availablefreereservedused)r  r  r  r
  accountsafe_balance)r  r  r  r  r/  r.  r'  rM  s           r  parse_balancezhitbtc.parse_balanceJ  s    )q#h--(( 	# 	#AQKE))%<<J**:66DllnnG"..ukBBGFO"..ujAAGFO"F4LL  (((r  c                 ^  K   |                      |dd          }|                     |dg          }|                     | j        di           }|                     |||          }d}|dk    r|                     |           d{V }n|dk    r|                     |           d{V }np|dk    r|                     |           d{V }nNt          |	                                          }t          | j        dz   d                    |          z             |                     |          S )	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  rA   r  Nr  r  z. fetchBalance() type parameter must be one of , )safe_string_lowerr=  r  r4  r  privateGetWalletBalanceprivateGetSpotBalanceprivateGetFuturesBalancer   r  r(   r7   joinrO  )r  r  r  r  rM  r  r  s          r  fetch_balancezhitbtc.fetch_balanceV  sX      %%fff==6F8,,7GLL"">4>>h!99&AAAAAAAAHH!77????????HH%%!::6BBBBBBBBHH++--..DTW'WWZ^ZcZcdhZiZiijjj !!(+++r  r  c                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     ||          S )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  r7   )r;  r  publicGetPublicTickerSymbolr?  parse_tickerr  r  r  r  r@  r  s         r  fetch_tickerzhitbtc.fetch_ticker|  s       !!!!!!!!!V$$fTl
 99$++gv:V:VWWWWWWWW   6222r  Nsymbolsc                 h  K   |                                   d{V  |                     |          }i }|/|                     |          }d                    |          }||d<   |                     |                     ||                     d{V }i }t          |                                          }t          dt          |                    D ]H}	||	         }
| 
                    |
          }|d         }||
         }|                     ||          ||<   I|                     |d|          S )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,r]  r   r  )r;  market_symbols
market_idsrV  publicGetPublicTickerr?  r   r  r  r  safe_marketrZ  filter_by_array_tickers)r  r]  r  r@  	marketIds	delimitedr  r  r  r  marketIdr  r  r/  s                 r  fetch_tickerszhitbtc.fetch_tickers  sG      !!!!!!!!!%%g..00I++I!*GI33DKK4P4PQQQQQQQQ  HMMOO$$q#d))$$ 	> 	>AAwH%%h//FH%FX&E!..uf==F6NN++FHgFFFr  tickerr  c                 x   |                      |d                   }|                     d |          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     i d|d|d|                     |          d|                     |d          d	|                     |d	          d
|                     |d
          dd d|                     |d          dd dd d|d|d|dd dd dd dd |||d|          S )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  ri  r  rk  r  r|  r}  rn  ro  s	            r  rZ  zhitbtc.parse_ticker  s    NN6+#677	!!$//%%fh77
&&v~>>//// !
f!
!
 Y//!
 D$$VV44	!

 4##FE22!
 4##FE22!
 !
 4##FE22!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
 !
 !
* +  	r  sincer   c                   K   |                                   d{V  d}i }|t          |d          |d<   |||d<   d}|P|                     |          }|d         |d<   |                     |                     ||                     d{V }n/|                     |                     ||                     d{V }||                     ||          S g }t          |                                          }	t          dt          |	                    D ]S}
|	|
         }|                     |          }||         }|                     ||          }|                     ||          }T|S )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   fromr7   r  r   )r;  r  r  publicGetPublicTradesSymbolr?  publicGetPublicTradesparse_tradesr   r  r  r  array_concat)r  r  r  r   r  r  r@  r  tradesre  r  rg  marketInner	rawTradesparseds                  r  fetch_tradeszhitbtc.fetch_trades  s      !!!!!!!!!"5$//GG#GFO[[((F &tGH!==dkk'SY>Z>Z[[[[[[[[HH!77GV8T8TUUUUUUUUH$$Xv666))	q#i..)) 	7 	7A |H++h//K *I&&y+>>F&&vv66FFr  c                 J  K   |                                   d{V  d}i }| |                     |          }|d         |d<   |||d<   |||d<   d}d}d}	|                     d||          \  }}|                     d|          \  }}|                     |ddg          }|0|                     |                     ||                     d{V }	n|d	k    r0|                     |                     ||                     d{V }	n|d
k    r0|                     |                     ||                     d{V }	nM|dk    r0|                     |                     ||                     d{V }	nt          | j
        dz             |                     |	|||          S )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>`
        Nr7   r  r   r  rt   r   rB   rA   rC   z- fetchMyTrades() not support self market typer;  r  handle_market_type_and_paramshandle_margin_mode_and_paramsr=  privateGetMarginHistoryTrader?  privateGetSpotHistoryTradeprivateGetFuturesHistoryTrader-   r7   r  
r  r  r  r   r  r  r@  r   r   r  s
             r  fetch_my_tradeszhitbtc.fetch_my_trades  s
       !!!!!!!!![[((F &tGH$GG#GFO

!??QWY_``
F!??QWXX
F6L(#;<<!!>>t{{7TZ?[?[\\\\\\\\HHV##!%!@!@WV\A]A]!^!^^^^^^^v%%!%!C!CDKKPWY_D`D`!a!aaaaaaax''!%!B!B4;;wX^C_C_!`!```````"47-\#\]]]  65%@@@r  tradec                    |                      |d                   }|                     |d          }|                     ||          }|d         }d }|                     |d          }|                     |d          }||rdnd}	nd}	|G|                     |di           }
|                     |
d          }|                     |          }||d}|                     |d	d
          }|                     |d          }|                     |dd          }|                     |d          }|                     |d          }|                     |||||                     |          |d ||	||d |d|          S )Nrk  r  r"  r   r   r  r  )r  r7  clientOrderIdclient_order_idr  quantityqtysider7   )r  r7   orderrk  rp  r  r  r  takerOrMakerr  r  r  r"  )r~  r  rc  r  r
  r	  
safe_trader  )r  r  r  rk  rg  r  r"  feeCostStringr   r  r  r  feeCurrencyCodeorderIdpriceStringamountStringr  r7   s                     r  parse_tradezhitbtc.parse_tradeD  s   r NN5#566	##E844!!(F33!((66w//&+877LL"L$??66266D**4@@K"55kBBO%+ C $$UO=NOO&&ug66))%UCCv..eT**"Y//( " 
  
   	r  c                 \  K   |                                   d {V  d|i}d }| |                     |          }|d         |d<   ||                     |          |d<   |||d<   |                     |                     ||                     d {V }|                     |||||          S )Ntypesr7   r-  r  r   )r;  r7  r  privateGetWalletTransactionsr?  parse_transactions)	r  r  r'  r  r   r  r@  r7  r  s	            r  fetch_transactions_helperz hitbtc.fetch_transactions_helper  s      !!!!!!!!!U
 }}T**H$,TNGL!"ll511GFO$GG::4;;wPV;W;WXXXXXXXX2 &&x5%PPPr  statusc                 @    dddddd}|                      |||          S )Npendingfailedok)CREATEDPENDINGFAILEDROLLED_BACKSUCCESSr  r  r  statusess      r  parse_transaction_statuszhitbtc.parse_transaction_status  s7      #
 
 &&999r  c                 :    ddd}|                      |||          S )Nr#  
withdrawal)DEPOSITWITHDRAWr  )r  r  r  s      r  parse_transaction_typezhitbtc.parse_transaction_type  s.     $
 
 tT222r  transactionr7  c                 0   |                      |dd          }|                     |                     |d                    }|                     |                     |d                    }|                     |                     |d                    }|                     |                     |d                    }|                     |di           }|                     |d          }	|                     |	          }
|                     |d	          }|                     |d
          }|}|                     |d          }|}|                     |d          }|                     |d          }|                     |d          }|                     |d          }|dk    }d d d d}|                     |d          }|
|
|d<   ||d<   i d|d|d|d|d|
dd d|d|d|d|                     |          d
|d|d|d|dd d|d|d ||dS ) Noperation_idr7   
created_at
updated_atr  r  nativer7  hashr8  r9  sendersr   r  subtypeOFFCHAIN)r7  r  rater"  r  r  txidr  rk  rp  addressFrom	addressTor:  tagFromtagToupdated)commentinternalr"  )	r	  r~  r  r  r  r  r
  r  r  )r  r  r7  r7   rk  r  r  r  r  r.  r'  txhashr8  r  r:  r  senderr  r  subTyper  r"  feeCosts                          r  parse_transactionzhitbtc.parse_transaction  s   B ^TBBNN4#3#3K#N#NOO	..!1!1+|!L!LMM**4+;+;K+P+PQQ..t/?/?X/V/VWWh;;%%fj99
&&z22!!&&11""6955	v|4433&&vq11!!&(33"";	::j( 
 

 ""6511"C
O!CK
K
"
 F
 D	

 
 t
 f
 f
 
 Y//
 w
 ;
 
 3
 t
  U!
" w#
$  )
 
 
 	
r  c                 D   K   |                      d||||           d{V S )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_withdrawalsz!hitbtc.fetch_deposits_withdrawals6  s9       334FeUZ\bcccccccccr  c                 D   K   |                      d||||           d{V S )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_depositszhitbtc.fetch_depositsD  s7       33ItUESYZZZZZZZZZr  c                 D   K   |                      d||||           d{V S )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_withdrawalszhitbtc.fetch_withdrawalsR  s7       33JeUTZ[[[[[[[[[r  c                 r  K   |                                   d{V  i }|-|                     |          }d                    |          |d<   |||d<   |                     |                     ||                     d{V }i }t          |                                          }t          dt          |                    D ]r}	||	         }
||
         }| 	                    |
          }| 
                    |                     |d                    }|                     ||
         ||dd          ||<   s|S )	aX  
        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
        Nr_  r]  depthr   rk  rs  ru  )r;  ra  rV  publicGetPublicOrderbookr?  r   r  r  r  r  r~  r  parse_order_book)r  r]  r   r  r@  marketIdsInnerr  r  re  r  rg  	orderbookr  rk  s                 r  fetch_order_bookszhitbtc.fetch_order_books`  sP      !!!!!!!!!!__W55N!$.!9!9GI$GG66t{{7F7S7STTTTTTTT))	q#i..)) 	h 	hA |H *I%%h//Ft'7'7	;'O'OPPI!228H3EvyZ_afggF6NNr  c                 h  K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     |                     |d                    }|                     |||dd          S )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  r7   r  rk  rs  ru  )r;  r  publicGetPublicOrderbookSymbolr?  r~  r  r  )r  r  r   r  r  r@  r  rk  s           r  fetch_order_bookzhitbtc.fetch_order_book}  s       !!!!!!!!!V$$fTl
 $GG<<T[[RX=Y=YZZZZZZZZNN4#3#3Hk#J#JKK	$$Xvy%OOOr  r"  c                     |                      |d          }|                      |d          }|                     |d          }|                     ||          }||||d d dS )Nr  r  r  )r  r  r   r   r   r   )r  r  r  )r  r"  r  r   r   rg  r  s          r  parse_trading_feezhitbtc.parse_trading_fee  sy       k22  k22##C22!!(F33
 
 	
r  c                   K   |                                   d{V  |                     |          }d|d         i}d}|d         dk    r0|                     |                     ||                     d{V }nS|d         dk    r0|                     |                     ||                     d{V }nt          | j        dz             |                     ||          S )a  
        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  r7   r  rA   rC   z/ fetchTradingFee() not support self market type)r;  r  privateGetSpotFeeSymbolr?  privateGetFuturesFeeSymbolr-   r7   r  r[  s         r  fetch_trading_feezhitbtc.fetch_trading_fee  s      !!!!!!!!!V$$fTl
 &>V##!99$++gv:V:VWWWWWWWWHHF^v%%!<<T[[RX=Y=YZZZZZZZZHHtw)ZZ[[[ %%h777r  c                   K   |                                   d{V  |                     dd|          \  }}d}|dk    r|                     |           d{V }n9|dk    r|                     |           d{V }nt	          | j        dz             i }t          dt          |                    D ]*}|                     ||                   }|d         }|||<   +|S )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   rA   rC   z0 fetchTradingFees() not support self market typer   r  )	r;  r  privateGetSpotFeeprivateGetFuturesFeer-   r7   r  r  r  )	r  r  r   queryr  r  r  r"  r  s	            r  fetch_trading_feeszhitbtc.fetch_trading_fees  s       !!!!!!!!! >>?QSWY_``
E!33E::::::::HH6!!!66u========HHtw)[[\\\ q#h--(( 	! 	!A((!55C]F F6NNr  r   	timeframec           	        K   |                                   d{V  d}|                     |dd          \  }}|r!|                     d|||||d           d{V S |                     |          }|d         |                     | j        ||          d}||                     |          |d<   |                     d	||          \  }}|t          |d          |d
<   |                     |d          }	| 	                    |d          }d}
|	dk    r0| 
                    |                     ||                     d{V }
n|	dk    r0|                     |                     ||                     d{V }
ne|	dk    r0|                     |                     ||                     d{V }
n/|                     |                     ||                     d{V }
|                     |
||||          S )ap  
        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
        NFru   paginater   r7   )r  periodr  untilr   r  markindexpremiumIndex)r;  handle_option_and_params"fetch_paginated_call_deterministicr  r  r   r  handle_until_optionr  r=  ,publicGetPublicFuturesCandlesMarkPriceSymbolr?  -publicGetPublicFuturesCandlesIndexPriceSymbol/publicGetPublicFuturesCandlesPremiumIndexSymbolpublicGetPublicCandlesSymbolparse_ohlcvs)r  r  r  r  r   r  r  r  r@  r  r  s              r  fetch_ohlcvzhitbtc.fetch_ohlcv  sc     $ !!!!!!!!!88zZZ& 	~@@vW\^cenpvx|}}}}}}}}}V$$Tl&&t	9MM
 
 "ll511GFO227GVLL"5$//GG  1167++F??!NNt{{[bdjOkOkllllllllHHg!OOPTP[P[\cekPlPlmmmmmmmmHHn$$!QQRVR]R]^egmRnRnooooooooHH!>>t{{7TZ?[?[\\\\\\\\H8   69eUKKKr  c           	      (   |                      |                     |d                    |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nrk  rn  r  r  rx  rl  )r~  r  r  )r  ohlcvr  s      r  parse_ohlcvzhitbtc.parse_ohlcv3  s    2 NN4++E;??@@UF++UE**UE**UG,,UH--
 	
r  c                   K   |                                   d{V  d}i }| |                     |          }|d         |d<   ||                     |          |d<   |||d<   d}d}|                     d||          \  }}|                     d|          \  }}|                     |ddg          }d}	|0|                     |                     ||                     d{V }	n|d	k    r0|                     |                     ||                     d{V }	n|d
k    r0| 	                    |                     ||                     d{V }	nM|dk    r0|                     |                     ||                     d{V }	nt          | j        dz             |                     |	|||          }
|                     |
dddgd          S )a5  
        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>`
        Nr7   r  r  r   rV   r   rB   rA   rC   z1 fetchClosedOrders() not support self market typer  closedcanceledF)r;  r  r  r  r  r=  privateGetMarginHistoryOrderr?  privateGetSpotHistoryOrderprivateGetFuturesHistoryOrderr-   r7   parse_ordersfilter_by_array)r  r  r  r   r  r  r@  r   r   r  r  s              r  fetch_closed_orderszhitbtc.fetch_closed_ordersT  s6       !!!!!!!!![[((F &tGH"ll511GFO$GG

!??@SU[]cdd
F!??@SU[\\
F6L(#;<<!!>>t{{7TZ?[?[\\\\\\\\HHV##!%!@!@WV\A]A]!^!^^^^^^^v%%!%!C!CDKKPWY_D`D`!a!aaaaaaax''!%!B!B4;;wX^C_C_!`!```````"47-`#`aaa""8VUEBB##FHx6LeTTTr  r7   c                 D  K   |                                   d{V  d}||                     |          }d|i}d}d}|                     d||          \  }}|                     d|          \  }}|                     |ddg          }d}|0|                     |                     ||                     d{V }n|dk    r0|                     |                     ||                     d{V }n|dk    r0|                     |                     ||                     d{V }nM|dk    r0|                     |                     ||                     d{V }nt          | j
        dz             |                     |d	          }	|                     |	|          S )
a  
        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  r}   r   rB   rA   rC   z* fetchOrder() not support self market typer   )r;  r  r  r  r=  r  r?  r  r  r-   r7   	safe_dictparse_order)
r  r7   r  r  r  r@  r   r   r  r  s
             r  fetch_orderzhitbtc.fetch_order  s      !!!!!!!!![[((Fr
 

!??fV\]]
F!??fUU
F6L(#;<<!!>>t{{7TZ?[?[\\\\\\\\HHV##!%!@!@WV\A]A]!^!^^^^^^^v%%!%!C!CDKKPWY_D`D`!a!aaaaaaax''!%!B!B4;;wX^C_C_!`!```````"47-Y#YZZZ( x++v...r  c                   K   |                                   d{V  d}||                     |          }d|i}d}d}	|                     d||          \  }}|                     d|          \  }	}|                     |ddg          }d}
|	0|                     |                     ||                     d{V }
n|dk    r0|                     |                     ||                     d{V }
n|dk    r0|                     |                     ||                     d{V }
nM|dk    r0|                     |                     ||                     d{V }
nt          | j
        dz             |                     |
|||          S )	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   rB   rA   rC   z0 fetchOrderTrades() not support self market typer  )r  r7   r  r  r   r  r  r@  r   r   r  s              r  fetch_order_tradeszhitbtc.fetch_order_trades  s     " !!!!!!!!![[((F
 

!??@RTZ\bcc
F!??@RTZ[[
F6L(#;<<!!>>t{{7TZ?[?[\\\\\\\\HHV##!%!@!@WV\A]A]!^!^^^^^^^v%%!%!C!CDKKPWY_D`D`!a!aaaaaaax''!%!B!B4;;wX^C_C_!`!```````"47-_#_```N   65%@@@r  c                 .  K   |                                   d{V  d}i }| |                     |          }|d         |d<   d}d}|                     d||          \  }}|                     d|          \  }}|                     |ddg          }d}	|0|                     |                     ||                     d{V }	n|dk    r0|                     |                     ||                     d{V }	n|dk    r0|                     |                     ||                     d{V }	nM|dk    r0|                     |                     ||                     d{V }	nt          | j
        d	z             |                     |	|||          S )
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>`
        Nr7   r  rz   r   rB   rA   rC   z/ fetchOpenOrders() not support self market type)r;  r  r  r  r=  privateGetMarginOrderr?  privateGetSpotOrderprivateGetFuturesOrderr-   r7   r  r  s
             r  fetch_open_orderszhitbtc.fetch_open_orders  s       !!!!!!!!![[((F &tGH

!??@QSY[abb
F!??@QSYZZ
F6L(#;<<!!77GV8T8TUUUUUUUUHHV##!%!9!9$++gv:V:V!W!WWWWWWWv%%!%!<!<T[[RX=Y=Y!Z!ZZZZZZZx''!%!;!;DKKQW<X<X!Y!YYYYYYY"47-^#^___(   65%@@@r  c                   K   |                                   d{V  d}||                     |          }d|i}d}d}|                     d||          \  }}|                     d|          \  }}|                     |ddg          }d}|0|                     |                     ||                     d{V }n|dk    r0|                     |                     ||                     d{V }n|dk    r0|                     |                     ||                     d{V }nM|dk    r0|                     |                     ||                     d{V }nt          | j
        dz             |                     ||          S )	a  
        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  ry   r   rB   rA   rC   z. fetchOpenOrder() not support self market type)r;  r  r  r  r=  "privateGetMarginOrderClientOrderIdr?   privateGetSpotOrderClientOrderId#privateGetFuturesOrderClientOrderIdr-   r7   r  	r  r7   r  r  r  r@  r   r   r  s	            r  fetch_open_orderzhitbtc.fetch_open_orderL  s      !!!!!!!!![[((Fr
 

!??@PRXZ`aa
F!??@PRXYY
F6L(#;<<!!DDT[[QXZ`EaEabbbbbbbbHHV##!%!F!Ft{{SZ\bGcGc!d!dddddddv%%!%!I!I$++V]_eJfJf!g!gggggggx''!%!H!HU\^dIeIe!f!fffffff"47-]#]^^^&111r  c                 *  K   |                                   d{V  d}i }| |                     |          }|d         |d<   d}d}|                     d||          \  }}|                     d|          \  }}|                     |ddg          }d}|0|                     |                     ||                     d{V }n|dk    r0|                     |                     ||                     d{V }n|dk    r0|                     |                     ||                     d{V }nM|dk    r0|                     |                     ||                     d{V }nt          | j
        d	z             |                     ||          S )
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>`
        Nr7   r  rG   r   rB   rA   rC   z/ cancelAllOrders() not support self market type)r;  r  r  r  r=  privateDeleteMarginOrderr?  privateDeleteSpotOrderprivateDeleteFuturesOrderr-   r7   r  r  r  r  r  r@  r   r   r  s           r  cancel_all_orderszhitbtc.cancel_all_ordersu  s      !!!!!!!!![[((F &tGH

!??@QSY[abb
F!??@QSYZZ
F6L(#;<<!!::4;;wPV;W;WXXXXXXXXHHV##!%!<!<T[[RX=Y=Y!Z!ZZZZZZZv%%!%!?!?GU[@\@\!]!]]]]]]]x''!%!>!>t{{7TZ?[?[!\!\\\\\\\"47-^#^___  6222r  c                   K   |                                   d{V  d}d|i}||                     |          }d}d}|                     d||          \  }}|                     d|          \  }}|                     |ddg          }d}|0|                     |                     ||                     d{V }n|dk    r0|                     |                     ||                     d{V }n|dk    r0|                     |                     ||                     d{V }nM|dk    r0|                     |                     ||                     d{V }nt          | j
        dz             |                     ||          S )	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  rH   r   rB   rA   rC   z+ cancelOrder() not support self market type)r;  r  r  r  r=  %privateDeleteMarginOrderClientOrderIdr?  #privateDeleteSpotOrderClientOrderId&privateDeleteFuturesOrderClientOrderIdr-   r7   r  r!  s	            r  cancel_orderzhitbtc.cancel_order  s      !!!!!!!!!r
 [[((F

!??vW]^^
F!??vVV
F6L(#;<<!!GGT[]cHdHdeeeeeeeeHHV##!%!I!I$++V]_eJfJf!g!gggggggv%%!%!L!LT[[Y`bhMiMi!j!jjjjjjjx''!%!K!KDKKX_agLhLh!i!iiiiiii"47-Z#Z[[[&111r  r  r  r  r  c                   K   |                                   d {V  d }||                     ||          d}	|dk    s|dk    r2|t          | j        dz             |                     ||          |	d<   ||                     |          }d }
d }|                     d||          \  }
}|                     d|          \  }}|                     |ddg          }d }|0| 	                    | 
                    |	|                     d {V }n|
d	k    r0|                     | 
                    |	|                     d {V }n|
d
k    r0|                     | 
                    |	|                     d {V }nM|
dk    r0| 	                    | 
                    |	|                     d {V }nt          | j        dz             |                     ||          S )N)r  r  r   	stopLimitz' editOrder() limit order requires pricer  rQ   r   rB   rA   rC   z) editOrder() not support self market type)r;  amount_to_precisionr#   r7   price_to_precisionr  r  r  r=  $privatePatchMarginOrderClientOrderIdr?  "privatePatchSpotOrderClientOrderId%privatePatchFuturesOrderClientOrderIdr-   r  )r  r7   r  r  r  r  r  r  r  r@  r   r   r  s                r  
edit_orderzhitbtc.edit_order  s?     !!!!!!!!!!00@@
 
 GOO!4!4}#DG.W$WXXX#66vuEEGG[[((F

!??VU[\\
F!??VTT
F6L(#;<<!!FFt{{SZ\bGcGcddddddddHHV##!%!H!HU\^dIeIe!f!fffffffv%%!%!K!KDKKX_agLhLh!i!iiiiiiix''!%!J!J4;;W^`fKgKg!h!hhhhhhh"47-X#XYYY&111r  c           
      ~  K   |                                   d{V  |                     |          }d}d}	|                     d||          \  }	}d}
|                     d|          \  }
}|                     ||	|||||
|          \  }}d}|	dk    r0|                     |                     ||                     d{V }ng|	dk    s|
0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }| 	                    ||          S )a  
        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>`
        NrK   rC   rB   )
r;  r  r  r  create_order_requestprivatePostFuturesOrderr?  privatePostMarginOrderprivatePostSpotOrderr  )r  r  r  r  r  r  r  r  r@  r   r   r  s               r  create_orderzhitbtc.create_order  s     * !!!!!!!!!V$$
!??vW]^^
F
!??vVV
F33FJdTZ\acmouvv!99$++gv:V:VWWWWWWWWHHH$$**@!88Wf9U9UVVVVVVVVHH!66t{{7F7S7STTTTTTTTH&111r  r   r   c	                    |dk    }	|                      |d          }
|                     |d          }|                     |g d          }|                     |dk    d |          }|||                     |d         |          |d         d}|
;|d	         d
k    r/|d	         dk    r#t          | j        dz   |d	         z   dz             |
du r|
|d<   |rd|d<   |||d<   |	s|dk    s|dk    r8|t          | j        dz             |                     |d         |          |d<   |dk    r/|                     |d          }|t          | j        dz             |3|                     |d         |          |d<   |	rd|d	<   n;|dk    rd|d	<   n/|dk    s|dk    s|dk    s|dk    rt          | j        dz             | 	                    |g d          }|d
k    r	|d}||d<   ||gS ) Nr   
reduceOnlyr   )r   	stopPrice
stop_pricer  r  r7   )r  r  r  r  r  rC   rB   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_forcer/  takeProfitLimitz9 createOrder() requires a price argument for limit ordersr  r   expire_timez@ createOrder() requires an expire_time parameter for a GTD orderr?  
stopMarkettakeProfitMarketzU createOrder() requires a triggerPrice parameter for stop-loss and take-profit orders)r   r   r>  r?  r=  postOnlycrossmargin_mode)
r  r  safe_number_nis_post_onlyr0  r+   r7   r#   r1  r=  )r  r  r   r  r  r  r  r   r  isLimitr=  r   r   
isPostOnlyr@  
expireTimes                   r  r7  zhitbtc.create_order_request	  s   7?__V\::
&&v}==))&2]2]2]^^&&tx'7vFF
001A6JJTl	
 
" !v&((vf~/I/I"47-_#_bhiobp#p  t@  $@  A  A  A%/GM" 	(#'GK "'2GO$ 	Pt{**8I0I0I}#DG.i$ijjj#66vh7GOOGG5  ))&-@@J!#DG.p$pqqq#$($;$;F8<Ll$[$[GL! /"-!!".k!!t|';';IZAZAZ`dhz`z`z  +B  !B  C  C  C6#w#w#wxx!$
%/GM"  r  c                 B    ddddddd}|                      |||          S )Nrn  r	  r
  r  )new	suspendedpartiallyFilledfilledr
  expiredr  r  s      r  parse_order_statuszhitbtc.parse_order_statusC	  s:    %"
 
 &&999r  r  c                 N   |                      |d          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }	|                     |	          }
|                      |d          }d }||	k    r|                     |          }|                      |d	          }|                     |                      |d
                    }|                      |d          }|                     ||          }|d         }|                     |d          }|                      |d          }|                     |d          }|                     i d|d|d|d|
d|                     |
          d|d|d|d|d|d|d|d|d|d|                     |d          d|dd d |||d |                      |d          d d d|          S )Nr  r  r  r  r  price_averager  r  quantity_cumulativer  r  rA  rB  r  r  r7   r  rk  rp  lastTradeTimestamplastUpdateTimestampr  r   rG  r=  r@  rS  	remainingr?  )r  r  r{  r  r"  r   r   r   )r  r~  rU  rc  r  
safe_orderr  )r  r  r  r7   r  r  r  r  r{  r  rk  r  rY  rS  r  rg  r  rG  r   r  s                       r  r  zhitbtc.parse_orderN	  s   D e%677 v..v..!!%44  00""5/::""5,77NN7++	""5,77!g!%!8!8!!%)>??(()9)9%)J)JKK##E844!!(F33!??5+66&&uo>>OOE844	  
E 
" 
 R 
 	 

 Y// 
 !"4 
 "#5 
 f 
 U 
 f 
 D 
 D 
 ; 
  
 $//%?? 
  f! 
" # 
$  ,,ULAA#!3 
  
  
4 5  	r  c                   K   |                                   d{V  d}|0|                     |          }|                     |d                   }d}|                     d||          \  }}d}|dk    r|                     |           d{V }n9|dk    r|                     |           d{V }nt          | j        dz             |                     |dg           }| 	                    ||d          S )	a  
        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   rm   rB   rC   z; fetchMarginModes() supports swap contracts and margin onlyconfigr  )
r;  r`  r  r  privateGetMarginConfigprivateGetFuturesConfigr)   r7   r)  parse_margin_modes)r  r]  r  r  r   r  r^  s          r  fetch_margin_modeszhitbtc.fetch_margin_modes	  s3      !!!!!!!!!))'22G[[,,F
!??@QSY[abb
F!!!88@@@@@@@@HH$ 6!!!99&AAAAAAAAHH& DG&ccddd(B77&&vwAAAr  c                     |                      |d          }||                     ||          |                     |d          dS )Nr  rI  )r  r  r   )r  r  rR  )r  r   r  rg  s       r  parse_margin_modezhitbtc.parse_margin_mode
  sO    ##J99&&x8800]KK
 
 	
r  fromAccount	toAccountc                 R  K   |                                   d{V  |                     |          }|                     ||          }|                     | j        di           }|                                }|                                }|                     |||          }	|                     |||          }
|	|
k    rt          | j        dz             |d         ||	|
d}| 	                    | 
                    ||                     d{V }|                     ||          S )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 accountr7   )r7  r  sourcedestination)r;  r7  currency_to_precisionr  r4  lowerr  r(   r7   privatePostWalletTransferr?  parse_transfer)r  r'  r  re  rf  r  r7  requestAmountr  fromIdtoIdr@  r  s                r  r   zhitbtc.transfer	
  s@      !!!!!!!!!==&&224@@7GLL!''))OO%%	!!.+{KK	9EET>>TW'ssttt #	
 
 77GV8T8TUUUUUUUU ""8X666r  r   c           
      j    |                      |d          d d |                     d |          d d d d |d	S )Nr   )	r7   rk  rp  r7  r  re  rf  r  r  )r  r
  )r  r   r7  s      r  rm  zhitbtc.parse_transfer/
  sN     ""8Q////h??

 

 
	
r  c                   K   |                                   d {V  |dk    rt          | j        dz             |                     | j        di           }|                                }|                                }|                     ||          }|                     ||          }||k    rt          | j        dz             ||Nt          |	                                          }t          | j        dz   d                    |          z             |||                     ||          d}|                     |                     ||                     d {V }	d|	iS )	Nr8  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 rQ  )from_currencyto_currencyr  r  )r;  r#   r7   r  r4  r+  r  r(   r   r  r'   rV  rj  privatePostWalletConvertr?  )
r  r'  r  fromNetwork	toNetworkr  r  r  r@  r  s
             r  convert_currency_networkzhitbtc.convert_currency_networkC
  s     !!!!!!!!!6>>*b bccc??4<R@@!''))OO%%	&&x==$$Xy99	)##TW'aabbbY%6((D#DG  /^  %^  ae  aj  aj  ko  ap  ap  %p  q  q  q($00v>>
 

 66t{{7F7S7STTTTTTTT H
 	
r  r8  r:  c                   K   |                      ||          \  }}|                                  d{V  |                     |           |                     |          }|d         ||d}|||d<   |                     | j        di           }|                     |d          }	|	9|dk    r3|                     ||	          }
|
|
|d<   |                     |d          }|                     | j        d	i           }| 	                    |d
d          }|rd|d<   | 
                    |                     ||                     d{V }|                     ||          S )a  
        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>`
        Nr7   )r7  r  r8  r9  r  r  r8  network_coder   r  FTinclude_fee)handle_withdraw_tag_and_paramsr;  check_addressr7  r  r4  r<  r  r=  r  privatePostWalletCryptoWithdrawr?  r  )r  r'  r  r8  r:  r  r7  r@  r  r  rA  withdrawOptionsr  r  s                 r  r   zhitbtc.withdraw\
  s      99#vFFV!!!!!!!!!7###==&& 
 

 ?$'GL!??4<R@@((;;dfnn ,,Xw??M(*7'YYvy11F//$,
BGG^^O\5II
 	*%)GM"==dkk'SY>Z>Z[[[[[[[[ %%h999r  c                 X  K   |                                   d{V  d}i }|]|                     |          }|                     |d                   }|                     |          }d                    |          |d<   d}|                     d||          \  }}|dk    rt          | j        dz   |z   dz             |                     | 	                    ||                     d{V }t          |                                          }i }	t          dt          |                    D ]f}
|                     ||
          }|                     ||          }|                     |          }|d	         }|                     ||          }||	|<   g|                     |	d	|          S )
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   r_  r]  re   rC   z& fetchFundingRates() does not support z marketsr  )r;  r`  r  ra  rV  r  r-   r7   publicGetPublicFuturesInfor?  r   r  r  r  r  r  parse_funding_rater  )r  r]  r  r  r@  queryMarketIdsr  r  re  fundingRatesr  rg  rawFundingRater  r  fundingRates                   r  fetch_funding_rateszhitbtc.fetch_funding_rates
  s      !!!!!!!!!))'22G[[,,F!__W55N!$.!9!9GI99:MvW]^^f6>>tw)QQTXX[eefff88Wf9U9UVVVVVVVV$ ))	q#i..)) 	/ 	/A''	155H!__Xx@@N++h//K *F11.+NNK#.L  ##L(GDDDr  c           
      (  K   |                                   d{V  d}|                     |dd          \  }}|r!|                     d|||d|d           d{V S d}i }|                     d||          \  }}|(|                     |          }|d         }|d	         |d
<   |||d<   |||d<   |                     |                     ||                     d{V }t          |                                          }	g }
t          dt          |	                    D ]}|	|         }|                     |          }||         }t          dt          |                    D ]}||         }|                     |d                   }|                     |d          }|                     |d          }|
                    ||||                     |          |d           |                     |
d          }|                     ||||          S )a  

        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>`
        NFrd   r  8hr   r  r  r7   r]  r  r   r   funding_raterk  )r  r  r  rk  rp  )r;  r  r  r  r  $publicGetPublicFuturesHistoryFundingr?  r   r  r  r  rc  r  r  r  r  r~  sort_byfilter_by_symbol_since_limit)r  r  r  r   r  r  r  r@  r  	contractsratesr  rg  r  fundingRateDatar1  r/  symbolInnerr  rp  sorteds                        r  fetch_funding_rate_historyz!hitbtc.fetch_funding_rate_history
  s      !!!!!!!!!88AZ\fgg& 	F@@AZ\bdikprvx~  AE  F  F  F  F  F  F  F  F  F
 227GVLL[[((FH%F!'GI#GFO$GGBB4;;wX^C_C_````````  ))	q#i..)) 	 	A |H**844K&x0O1c/2233  '*"..{8/DEE"..unEE++E;??!)#.!%!9!9 (      e[1100NNNr  c                   K   |                                   d{V  i }d}d}|                     dd|          \  }}|dk    rd}|                     d|          \  }}|                     |ddg          }d}|0|                     |                     ||                     d{V }n|dk    r0|                     |                     ||                     d{V }nM|dk    r0|                     |                     ||                     d{V }nt          | j        dz             g }t          dt          |                    D ]0}|                    |                     ||                              1|S )	a|  
        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   rA   rC   r   rB   z. fetchPositions() not support self market typer   )r;  r  r  r=  privateGetMarginAccountr?  privateGetFuturesAccountr-   r7   r  r  r  parse_position)	r  r]  r  r@  r   r   r  r  r  s	            r  fetch_positionszhitbtc.fetch_positions  s      !!!!!!!!!

!??@PRVX^__
FJ!??@PRXYY
F6L(#;<<!!99$++gv:V:VWWWWWWWWHHV##!%!>!>t{{7TZ?[?[!\!\\\\\\\x''!%!=!=dkk'SY>Z>Z![![[[[[[["47-]#]^^^B q#h--(( 	< 	<AMM$--hqk::;;;;r  c                   K   |                                   d{V  |                     |          }d|d         i}d}d}|                     dd|          \  }}|                     d|          \  }}|                     |ddg          }d}|0|                     |                     ||                     d{V }n|dk    r0|                     |                     ||                     d{V }nM|dk    r0|                     |                     ||                     d{V }nt          | j	        dz             | 
                    ||          S )	a  
        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  r7   r   r   rB   rC   z- fetchPosition() not support self market type)r;  r  r  r  r=  %privateGetMarginAccountIsolatedSymbolr?  &privateGetFuturesAccountIsolatedSymbolr-   r7   r  r'  s           r  fetch_positionzhitbtc.fetch_positionJ  s      !!!!!!!!!V$$fTl
 

!??QUW]^^
F!??QWXX
F6L(#;<<!!GGT[]cHdHdeeeeeeeeHHV##!%!L!LT[[Y`bhMiMi!j!jjjjjjjx''!%!K!KDKKX_agLhLh!i!iiiiiii"47-\#\]]]B ""8V444r  positionc                 |   |                      |d          }|                     |d          }|                      |d          }|                     |dg           }d }d }d }	t          dt	          |                    D ]L}
||
         }|                     |d          }|                     |d          }|                     |d          }	M|                     |d	g           }d }t          dt	          |                    D ] }
||
         }|                     |d
          }!|                      |d          }|                     ||          }|d         }|                     i d|dd d|dd d|d|d|d|dd dd d|	dd dd dd dd dd d|                     |          |d d d |d d |d d d d          S )Nr  r   r  	positionsr   price_liquidationprice_entryr  r-  margin_balancer  r  r7   notionalr   
marginTypeliquidationPrice
entryPriceunrealizedPnlr   r  r  	markPrice	lastPricer  r   rk  )rp  rZ  maintenanceMarginmaintenanceMarginPercentage
collateralinitialMargininitialMarginPercentager   marginRatior   r   )r  r  r  r  r  rc  safe_positionr~  )r  r  r  r   r   rp  r  r  r  r  r  r/  r-  r  rg  r  s                   r  r  zhitbtc.parse_position  s   B %%h77
##Hj99##Hl;;OOHk2>>	
	q#i..)) 	< 	<AaLE#//7JKK))%??J((
;;II__X|R@@

q#j//** 	C 	CAqME))%1ABBJJ##Hh77!!(F33!!! #
H#
$#
 f#
 	#

 *#
 *#
  0#
 *#
 T#
 $#
 #
 D#
 #
 #
 D#
  d!#
" 11##
$ !#'!%+/$!'+ !#9#
 #
 #
   	r  c           	          |                      |d          }|                     |d          }|                     |                     d |          d ||                     |          ||d|          S )Nrk  open_interest)r  openInterestAmountopenInterestValuerk  rp  r  )r  r  safe_open_interestr  r~  )r  interestr  rp  values        r  parse_open_interestzhitbtc.parse_open_interest  s      ##Hk::  ?;;&&&&tV44"&!&11 (
 (
   	r  c                 t  K   |                                   d{V  i }|                     |          }d}|-|                     |          }d                    |          |d<   |                     |                     ||                     d{V }g }t          |                                          }t          dt          |                    D ]N}||         }	| 
                    |	          }
|                    |                     ||	         |
                     O|                     |d|          S )ae  
        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>`
        Nr_  r]  r   r  )r;  r`  ra  rV  r  r?  r   r  r  r  rc  r  r  r  )r  r]  r  r@  re  r  resultsmarketsr  rg  r  s              r  fetch_open_interestszhitbtc.fetch_open_interests  sD      !!!!!!!!!%%g..	00I!$)!4!4GI88Wf9U9UVVVVVVVV$ x}}''q#g,,'' 	V 	VAqzH**844KNN433HX4FTTUUUU##GXw???r  c                 @  K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d         i}|                     |                     ||                     d{V }|                     ||          S )aX  
        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:
        NrC   z1 fetchOpenInterest() supports swap contracts onlyr  r7   )r;  r  r)   r7    publicGetPublicFuturesInfoSymbolr?  r  r[  s         r  fetch_open_interestzhitbtc.fetch_open_interest'  s       !!!!!!!!!V$$f~ 	[DG&YYZZZfTl
 >>t{{7TZ?[?[\\\\\\\\  ''&999r  c                 @  K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d         i}|                     |                     ||                     d{V }|                     ||          S )aJ  
        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>`
        NrC   z0 fetchFundingRate() supports swap contracts onlyr  r7   )r;  r  r)   r7   r  r?  r  r[  s         r  fetch_funding_ratezhitbtc.fetch_funding_rateJ  s       !!!!!!!!!V$$f~ 	ZDG&XXYYYfTl
 >>t{{7TZ?[?[\\\\\\\\  &&x888r  c                    |                      |d          }|                      |d          }i d|d|                     d |          d|                     |d          d|                     |d          d	|                     |d
          dd d|                     |          d|d|                     |d          d|                     |          d|d|                     |d          dd dd dd dd dd dd iS )Nnext_funding_timerk  r  r  r  
mark_price
indexPriceindex_priceinterestRateinterest_rateestimatedSettlePricerp  r  r  fundingTimestampfundingDatetimenextFundingRateindicative_funding_ratenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimeinterval)r  r  r  r~  )r  r  r  fundingDateTimerp  s        r  r  zhitbtc.parse_funding_ratem  s     **85HII##Hk::
H
d&&tV44
 ))(LAA
 $**8]CC	

 D,,XGG
 #D
 11
 
 4++HnEE
  ? ?
 
 t//:STT
 #D
 "4
 "4
  '!
" &t#
$ %
 
 	
r  c                 n  K   |                                   d {V  |                     |          }|                     |d          }|d         r|t          | j        dz             |                     |          }|dk    r|                     ||          }nd}|d         |d}|||d<   d }	d }
|                     d||          \  }	}|                     d|          \  }
}d }|	dk    r0| 	                    | 
                    ||                     d {V }nY|	dk    s|	d	k    s|
d
k    r0|                     | 
                    ||                     d {V }nt          | j        dz             | 
                    |                     ||          |                     |          |d          S )Nr   rC   zD modifyMarginHelper() requires a leverage parameter for swap marketsr   r7   )r  r  modifyMarginHelperrB   rA   isolatedz2 modifyMarginHelper() not support self market type)r  r  )r;  r  r  r'   r7   number_to_stringr0  r  r  &privatePutFuturesAccountIsolatedSymbolr?  %privatePutMarginAccountIsolatedSymbolr-   parse_margin_modificationr  )r  r  r  r  r  r  r   stringAmountr@  r   r   r  s               r  modify_margin_helperzhitbtc.modify_margin_helper  s     !!!!!!!!!V$$##FJ77&> 	z'2x(xyyy,,V443--flCCFFFTl$
 
 "*GJ

!??@TV\^dee
F!??@TV\]]
F!HHU\^dIeIeffffffffHHH$$**>*>JR\D\D\!GGT[]cHdHdeeeeeeeeHHtw)]]^^^& {{499(FKK''//N
 N
   	r  datac                     |                      |dg           }|                      |d          }|                     |d          }||d         d dd d |                     |d          d |                     |          |d
S )Nr-  r   r  r  r  r'  )
r  r  r  r   r  totalr'  r  rk  rp  )r  r  r~  )r  r  r  r-  currencyInforp  s         r  r  z hitbtc.parse_margin_modification  s    * __T<<<
z155##D,77X&$$$\6::11 
 
 	
r  c                    K   |                      |          dk    rt          | j        dz             |                     ||d|           d{V S )a  
        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=margin-structure>`
        r   zc reduceMargin() on hitbtc requires the amount to be 0 and that will remove the entire margin amountreduceN)r  r(   r7   r  r  r  r  r  s       r  reduce_marginzhitbtc.reduce_margin  sr         ((C//TW  (M  M  N  N  N..vvxPPPPPPPPPr  c                 B   K   |                      ||d|           d{V S )a  
        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=margin-structure>`
        addN)r  r  s       r  
add_marginzhitbtc.add_margin  s4       ..vvufMMMMMMMMMr  c                   K   |                                   d{V  |                     |          }d|d         i}d}|                     d|          \  }}|                     |ddg          }d}|0|                     |                     ||                     d{V }n|d         dk    r0|                     |                     ||                     d{V }n|d         d	k    r0|                     |                     ||                     d{V }nS|d         dk    r0|                     |                     ||                     d{V }nt          | j        d
z             | 	                    ||          S )am  
        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  r7   rj   r   rB   r  rA   rC   z- fetchLeverage() not support self market type)
r;  r  r  r=  r  r?  r  r-   r7   parse_leverage)r  r  r  r  r@  r   r  s          r  fetch_leveragezhitbtc.fetch_leverage  s      !!!!!!!!!V$$fTl
 
!??QWXX
F6L(#;<<!!GGT[]cHdHdeeeeeeeeHHf~''!%!K!KDKKX_agLhLh!i!iiiiiii6))!%!L!LT[[Y`bhMiMi!j!jjjjjjj8++!%!K!KDKKX_agLhLh!i!iiiiiii"47-\#\]]]> ""8V444r  r   c                     |                      |d          }|                     |d          }||                     ||          |                     |d          ||dS )Nr  r   r  )r  r  r   longLeverageshortLeverage)r  r  r  rR  )r  r   r  rg  leverageValues        r  r  zhitbtc.parse_leverageR  sj    ##Hh77))(J??&&x88006BB)*
 
 	
r  c                   K   |t          | j        dz             |                                  d{V  |d         t          | j        dz             |                     |          }|                     |d          }|                     |d         d         dd          }|d	         d
k    rt          | j        dz             |dk     s||k    r-t          | j        dz   t          |          z   dz   |z             |d         t          |          | 	                    ||          d}| 
                    |                     ||                     d{V S )ae  
        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  rC   z+ setLeverage() supports swap contracts onlyr   z0 setLeverage() leverage should be between 1 and z for r7   )r  r   r  )r'   r7   r;  r  r  r  r)   r(   strr0  r  r?  )r  r   r  r  r  r  maxLeverager@  s           r  set_leveragezhitbtc.set_leverage]  s      >#DG.Y$YZZZ!!!!!!!!!"#+#DG  /[  %[  \  \  \V$$!!&*:;;''x(8(DeRPP&>V##DG&SSTTTqLLh44TW'YY\_`k\l\llovvy  A  A  ATlH"66vvFF
 
 @@WV\A]A]^^^^^^^^^r  codesc                    K   |                                   d{V  |                     |           d{V }|                     ||          S )aR  
        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  r  r  r  s       r  fetch_deposit_withdraw_feesz"hitbtc.fetch_deposit_withdraw_fees|  si       !!!!!!!!!55f========4 //%@@@r  c                    |                      |dg           }|                     |          }t          dt          |                    D ]}||         }|                     |d          }|                     |          }||                                nd }|                     |d          }	|                      |d          }
|	|	dnd d}|
du r||d	<   |d d dd
|d         |<   |S )Nr  r   r  r  r   F)r"  r   Tr   )r   r#  )r  deposit_withdraw_feer  r  r  r*  r+  r  )r  r"  r7  r  r  r1  networkEntryr3  r4  withdrawFee	isDefaultwithdrawResults               r  parse_deposit_withdraw_feez!hitbtc.parse_deposit_withdraw_fee  s%   0 ??3
B77**3//q#h--(( 	 	A#A;L((yAAI11)<<K2=2I+++---PTK**<FFKi@@I"(3(?eed$ $N D  %3z"*"& / /F:{++ r  c                 <  K   |                                   d{V  d}|                     d|d          \  }}|                     |          }|d         |d}|                     |                     ||                     d{V }|                     ||          S )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>`
        NrI   rH  r7   )r  rI  )r;  r  r  ,privateDeleteFuturesPositionMarginModeSymbolr?  r  )r  r  r  r  r   r  r@  r  s           r  close_positionzhitbtc.close_position  s       !!!!!!!!!
!??QWY`aa
FV$$Tl%
 
 JJ4;;W^`fKgKghhhhhhhh  &111r  c                     |                      | j        d          }|                     |dd          }d}t          t          |                               |||          \  }}||dk    s|du rd}||gS )aR  
 @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
        defaultTyperB   FNTr  )r  r4  r  r  r4   r  )r  
methodNamer  defaultValuer  isMarginr   r  s          r  r  z$hitbtc.handle_margin_mode_and_params  s     &&t|]CC>>&(E::
"6400NNz[acopp
Fx''X-=-='
F##r  reasonurlmethodheadersbodyc
                 P   |                      |d          }
|                     |
d          }|w| j        dz   |z   }|                     |
dd          }|                     | j        d         ||           |                     | j        d         ||           t          |          d S )Nerrorr'   messagedescriptionr2  r3  )r  r  r7   r	  throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr#   )r  r'  r  r	  r
  r  r  r  requestHeadersrequestBodyr  	errorCodefeedbackr  s                 r  handle_errorszhitbtc.handle_errors
  s    " '22$$UF33	 w}t+H((	=IIG001I9V^___001I7T\]]])))tr  r   r  c                    |                      ||                     |                    }|                     ||          }| j        d         |         dz   |z   }	d }
t	          |                                          }t          |          }ddi}|dk    r |rd|                     |          z   }
|	|
z   }	n|                     |          }|dk    r| 	                                 t          |                                           }|d|z   g}|dk    r|
|                    |
           n|                    |           |                    |           d	                    |          }|                     |                     |          |                     | j                  t"          j        d
          }| j        dz   |z   dz   |z   }|                     |          }d|z   |d<   |	|||dS )Nr   r  zContent-Typezapplication/jsonr  ?r   z/api/3/ hexr  zHS256 Authorization)r	  r
  r  r  )r=  extract_paramsimplode_paramsr   r   r  r  	urlencodejsoncheck_required_credentialsr  r  r  rV  hmacencodesecrethashlibsha256apiKeystring_to_base64)r  pathr   r
  r  r  r  r  implodedPathr	  
getRequestr  queryLengthrk  payloadpayloadString	signaturesecondPayloadencodeds                      r  signzhitbtc.sign%  s   		&$"5"5d";";<<**488is#c)L8
EJJLL!!$ii.
 U?? ' 4>>%#8#88
J&99V$$D)++---DJJLL))Iy<78G)NN:...t$$$NN9%%%GGG,,M		$++m"<"<dkk$+>V>VX_XfhmnnI K#-	9C?)KM++M::G'/''9GO$fdwOOOr  r  )m__name__
__module____qualname__r   r  r  r"   r   r  r   r5  r  r	   rB  rG  r   rO  rW  r   r\  r   r   rh  dictrZ  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  r  r  r"  r(  r-  r   r   r   r5  floatr;  objectr7  rU  r  r   rb  r   rd  r!   r   rm  rx  r   r   r  r  r   r  r  r  r  r  r  r   r  r  r   r  r  r  r  r   r  r  intr  r  r  r  r  r  r3  __classcell__)r  s   @r  r4   r4      sj       k# k k k k k kZ# # # *, I IV I I I IV -/ d d: d d d dL >@ !
 !
 !
N !
 !
 !
 !
F =? %
 %
 %
> %
 %
 %
 %
N
) 
) 
) 
) 
) *, $, $, $, $, $, $,L 68 3 3 3F 3 3 3 3> 6:" )G )G7 )G )G )G )G )GV) )4 ) )6 ) ) ) )V <@d[] $ $ $S $ $bfglbm $ $ $ $L 37TX\eg +A +AC +As +ARU +A +A +A +AZc c cv c c c c cJ&Q &Q &QP:s : : : :3 3 3R
 R
T R
X R
Q\ R
 R
 R
 R
h <@daenp d dS d d[^ duy  {F  vG d d d d 04$UYbd [ [ [C [s [imnyiz [ [ [ [ 37TX\eg \ \C \s \RU \lpq|l} \ \ \ \ :>DY[  w c `j    : @DB P PS P PS\ P P P P,
 
T 
6 
EX 
 
 
 
* ;= 8 8c 8AT 8 8 8 8> /1 ! ![ ! ! ! !F ?CQUdhqs GL GL GL GL3 GL^a GLx|  ~B  yC GL GL GL GLR
 
 
4 
 
 
 
B 7;\`ik ,U ,U ,U3 ,UVY ,Uptuzp{ ,U ,U ,U ,U\ 8<B ;/ ;/C ;/ ;/ ;/ ;/ ;/z ?CQUdhqs OA OA3 OA OA3 OA^a OA OA OA OAb 59tZ^gi :A :Ac :A :ATW :Anrsxny :A :A :A :Ax =A '2 '2 '2c '2 '2 '2 '2R 59 %3 %3c %3 %3 %3 %3N 9=R '2 '2S '2# '2 '2 '2 '2R fjx|  FH 2 23 2 29 2I 2_b 2ru 2 2 2 2@ mqy{ $2 $2 $2I $2Y $2X] $2fi $2 $2 $2 $2L CG  [_  hj 6! 6!6 6!s 6!) 6![d 6!ns 6!| 6!  UX 6! 6! 6! 6!p	: 	: 	: 	: 	:s s sv s s s s sj =A <B <BS	 <BP[ <B <B <B <B|
 
D 
* 
 
 
 
 ac $7 $73 $7 $7C $7TW $7gt $7 $7 $7 $7L
 
t 
x 
= 
 
 
 
(
3 
 
 
 
2 QU]_ ): ):3 ): ): ):# ):do ): ): ): ):V <@ 1E 1E 1E| 1E 1E 1E 1Ef >BPTcgpr IO IOs IO# IO]` IO IO IO IOV 8<B C CW C4PX> C C C CJ 8: A5 A53 A5 A5 A5 A5FR Rt RV R R R Rh F    6 =A )@ )@' )@ )@ )@ )@V =? !: !: !: !: !: !:F <> !9 !9s !9+ !9 !9 !9 !9F%
 %
6 %
[ %
 %
 %
 %
N LN 4 4 4Rd 4 4 4 4l#
 #
d #
F #
N` #
 #
 #
 #
J FH Q Q# Qu QL^ Q Q Q Q$ CE N Ns NE NI[ N N N N  8: ?5 ?53 ?5h ?5 ?5 ?5 ?5B	
 	
t 	
V 	
x 	
 	
 	
 	
 ?C2 _ _3 _ _ _ _ _> BFb %A %Aw %A %A %A %AN. . . . . .` CGr %2 %23 %2i %2V[ %2 %2 %2 %2N @BPT $ $ $ $ $ $ # s  c TX `c    6 &eBSW P P P P P P P Pr  r4   )9 ccxt.async_support.base.exchanger   ccxt.abstract.hitbtcr   r&  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  <module>rD     s$   6 5 5 5 5 5 , , , , , ,  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V       * * * * * * 0 0 0 0 0 0 - - - - - - - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) . . . . . . 1 1 1 1 1 1 * * * * * * 4 4 4 4 4 4 % % % % % %g8P g8P g8P g8P g8PX{ g8P g8P g8P g8P g8Pr  