
    ei                       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"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)m0Z0 d dl)m1Z1 d dl)m2Z2 d dl)m3Z3 d dl)m4Z4 d dl)m5Z5 d dl)m6Z6 d dl)m7Z7 d dl)m8Z8 d dl)m9Z9 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)mAZA d dlBmCZC d dlDmEZE  G d  d!ee          ZFdS )"    )Exchange)ImplicitAPIN)!AccountAnyBalancesBool
CurrenciesCurrencyDepositAddressInt	LastPrice
LastPricesLedgerEntryLeverageLeverageTierLeverageTiersMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTradingFeeInterfaceTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountNotEnabled)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)OperationRejected)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)OrderImmediatelyFillable)OrderNotFillable)DuplicateOrderId)ContractUnavailable)NotSupported)OperationFailed)DDoSProtection)RateLimitExceeded)ExchangeNotAvailable)InvalidNonce)RequestTimeout)	TICK_SIZE)Precisec                   .    e Zd Zdef fdZi fdefdZi fdZi fdee	         fdZ
dede	fdZi fdefdZd	i fd
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dpdede	defdZdd	d	i fd
ededededee         f
dZdpde	defdZi fd
edefdZd	i fdedefdZdpde	defdZd	i fdede fdZ!dpde	de"fdZ#i fde$fdZ%de$fdZ&de$fdZ'i fdede(fd Z)dpd!e*de(fd"Z+d	d	d	i fdedededee,         fd#Z-d	d	d	i fdedededee,         fd$Z.d	i fded%e/d&ed'ede,f
d(Z0dpd!e*de,fd)Z1d* Z2i fded%e/d+ed,ede3f
d-Z4dpd!e*fd.Z5i fdee6         fd/Z7d0 Z8d1 Z9d2 Z:d3 Z;d	d	d	i fdedededee<         fd4Z=d5 Z>dpd6ed!e*de<fd7Z?d	i fd
ed8e@d9eAd%e/d:eBdeCfd;ZDi fd
ed<e/deCfd=ZEd	i fd
ed8e@d9eAd%e/d:eBdeCfd>ZFd	i fd
ed8e@d9eAd%e/d:eBdefd?ZGd	i fd
ed8e@d9eAd%e/d:eBdefd@ZHd	i fd
ed8e@d9eAd%e/d:eBdefdAZId	i fd
ed8e@d9eAd%e/d:eBdeCfdBZJi fdCeeK         fdDZLd	i fdEed
efdFZMd	i fd
efdGZNd	i fdHee         d
efdIZOd	i fdEed
edeCfdJZPd	d	d	i fd
edededeeC         fdKZQd	d	d	i fd
edededeeC         fdLZRd	d	d	i fd
edededeeC         fdMZSd	d	d	i fd
edededeeC         fdNZTdO ZUdpdPeVdQefdRZWdpdSede	deCfdTZXdU ZYdV ZZdW Z[dX Z\i fd
ede]fdYZ^d	i fdede_fdZZ`dpde	de]fd[Zad	d	d	i fd
ededefd\Zbd	i fdedeec         fd]Zdi fd
edeec         fd^Zedpd_ede	fd`Zfi fd
edegfdaZhdpdbede	degfdcZid	i fdbejd
efddZkd	i fdedelfdeZmdpde	deen         fdfZoi fd
edepfdgZqi fderfdhZsdpdiede	depfdjZtdkdli d	d	fdmZui fdPedefdnZvdo Zw xZxS )qhashkeyreturnc                 Z   |                      t          t          |                                           i ddddddgddd	d
dddddi dd ddddddddddddddddddddddddddddddd di d!dd"dd#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1di d2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAddBdi dCddDddEddFddGddHddIddJddKddLddMddNddOddPddQddRddSdi dTddUddVddWddXddYddZdd[dd\dd]dd^dd_dd`dadbddcdddddedi dfddgddhddiddjddkddlddmddnddoddpddqddrddsddtdduddvdi dwddxddyddzdd{dd|dd}dd~ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddii ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddiddddddddddddddd|                     d          |                     d          |                     d¦          |                     d          g|                     dæ          |                     dĦ          g|                     dŦ          |                     dƦ          g|                     dǦ          |                     dȦ          g|                     dɦ          |                     dʦ          g|                     d˦          |                     d̦          g|                     dͦ          |                     dΦ          g|                     dϦ          |                     dЦ          g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؜ddd|                     d٦          |                     dȦ          |                     d¦          |                     d٦          g|                     dæ          |                     dڦ          g|                     dŦ          |                     dۦ          g|                     dǦ          |                     dܦ          g|                     dɦ          |                     dݦ          g|                     d˦          |                     dަ          g|                     dͦ          |                     dߦ          g|                     dϦ          |                     dЦ          g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؜diddd di ddddddddddddddddddddddddddddddd di dddddddddddddddddddddddddddddddd ddddd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id	ddiddddddddddid dd d dddi d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 d0t          d1t          d2t          d3t
          d4t          d5t          d6t          d7t          d8t          d9t          d:t           d;t
          d<t"          d=t          d>t          d?t          d@t          i dAt          dBt
          dCt
          dDt
          dEt
          dFt
          dGt
          dHt          dIt          dJt$          dKt          dLt&          dMt(          dNt          dOt          dPt*          dQt          i dRt          dSt          dTt          dUt,          dVt          dWt.          dXt          dYt          dZt          d[t,          d\t,          d]t,          d^t.          d_t.          d`t,          dat0          dbt2          i dct,          ddt4          det          dft
          dgt
          dht          dit          djt          dkt
          dlt
          dmt          dnt
          dot
          dpt          dqt.          drt6          dst          i dtt          dut          dvt
          dwt
          dxt
          dyt
          dzt
          d{t
          d|t
          d}t.          d~t
          dt
          dt
          dt
          dt"          dt,          dt,          i dt,          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt.          dt.          dt
          dt          dt          i dt          dt          dt*          dt          dt,          dt          dt          dt*          dt          dt          dt*          dt"          dt
          dt          dt          dt
          dt
          i dt
          dt
          dt
          dt
          dt          dt          dt          dt
          dt
          dt
          dt
          dt          dt          dt          dt8          dt
          dt
          t          t
          t
          t.          t*          t.          t          t          t          t          t,          di ddt:                    S (  NidrB   namezHashKey Global	countriesBM	rateLimitd   versionv1	certifiedTprohasCORSspotmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelAllOrdersAftercancelOrdercancelOrderscancelWithdrawcloseAllPositionsclosePositioncreateConvertTradecreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrdercreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrder$createOrderWithTakeProfitAndStopLosscreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingAmountOrdercreateTrailingPercentOrdercreateTriggerOrderfetchAccountsfetchAllGreeksfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCanceledAndClosedOrdersfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLedgerfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersemulatedfetchMarketsfetchMarkOHLCVfetchMarkPricefetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrderfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsfetchTransfersfetchUnderlyingAssets)fetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginsandboxsetLeverage	setMarginsetMarginModesetPositionModetransferwithdraw
timeframes1m3m5m15m30m1h2h4h6h8h12h1d1w1M)r   r   r   r   r   r   r   r   r   r   r   r   r   r   urlszOhttps://github.com/user-attachments/assets/6dd6127b-cc19-4a13-9b29-a98d81f80e98zhttps://api-glb.hashkey.com)publicprivatez"https://api-glb.sim.hashkeydev.comzhttps://global.hashkey.com/z'https://hashkeyglobal-apidoc.readme.io/z`https://support.global.hashkey.com/hc/en-us/articles/13199900083612-HashKey-Global-Fee-StructurezChttps://global.hashkey.com/en-US/register/invite?invite_code=82FQUN)logoapitestwwwdocfeesreferralr   get      )zapi/v1/exchangeInfozquote/v1/depthzquote/v1/tradeszquote/v1/klineszquote/v1/ticker/24hrzquote/v1/ticker/pricezquote/v1/ticker/bookTickerzquote/v1/depth/mergedzquote/v1/markPricezquote/v1/indexzapi/v1/futures/fundingRatez!api/v1/futures/historyFundingRatezapi/v1/pingzapi/v1/timeapi/v1/spot/orderapi/v1/spot/openOrderszapi/v1/spot/tradeOrdersapi/v1/futures/leverageapi/v1/futures/orderzapi/v1/futures/openOrderszapi/v1/futures/userTradeszapi/v1/futures/positionszapi/v1/futures/historyOrderszapi/v1/futures/balancez&api/v1/futures/liquidationAssignStatuszapi/v1/futures/riskLimitzapi/v1/futures/commissionRatezapi/v1/futures/getBestOrderzapi/v1/account/vipInfozapi/v1/accountzapi/v1/account/trades)zapi/v1/account/typezapi/v1/account/checkApiKeyzapi/v1/account/balanceFlowz!api/v1/spot/subAccount/openOrdersz"api/v1/spot/subAccount/tradeOrderszapi/v1/subAccount/tradesz$api/v1/futures/subAccount/openOrdersz'api/v1/futures/subAccount/historyOrdersz$api/v1/futures/subAccount/userTradeszapi/v1/account/deposit/addresszapi/v1/account/depositOrderszapi/v1/account/withdrawOrders   )api/v1/userDataStreamzapi/v1/spot/orderTestr   zapi/v1.1/spot/orderapi/v1/spot/batchOrdersr   r   z$api/v1/futures/position/trading-stopapi/v1/futures/batchOrderszapi/v1/account/assetTransferzapi/v1/account/authAddresszapi/v1/account/withdrawr   )r   r   zapi/v1/spot/cancelOrderByIdsr   r   zapi/v1/futures/cancelOrderByIdsr   )r   postputdeleter   tradingz0.001201000000z0.000805000000z0.0007010000000z0.0006050000000z0.00040	200000000z0.00030	400000000z0.00010	800000000z0.00z0.00090z0.00085z0.00075z0.00065z0.00045z0.00035)makertaker)	tierBased
percentagefeeSider  r  tiersz0.00025z0.00016z0.00014z0.00012z0.000080z0.000060z0.000020z0.00050z0.00020)rQ   rS   options10000700011BTCERC20ETHAVAX
AvalancheCSOLSolanaMATICPolygonATOMCosmosDOTPolkadotLTCOPTIMISMOptimismARBArbitrumDOGEDogecoinTRC20TronZKSYNCzkSyncTONKLAYTNKlaytnMERLINCHAINzMerlin ChainBitcoinzAVAX C-ChainLitecoinBSC)r   r!  r$  z
BSC(BEP20)r&  )broker
recvWindowsandboxModenetworksnetworksByIddefaultNetworkfeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergmax        )r6  limitdaysBack	untilDayssymbolRequired)r6  triggerr?  rL  )r6  rI  rM  r?  rL  rI  )	r   rg   createOrdersr   r   r   r   r~   r   extendsdefault)r7  rC  i  )rM  rI  )rO  rg   r   forDerivatives)linearinverse)rP  rQ   rQ  rS   rT   commonCurrencies
exceptions000100020003010201030104020102020206020702090210021104010402z-1000z-1001z-100010z-100012z-1002z-1004z-1005z-1006z-1007z-1014z-1015z-1020z-1021z-1024z-1101z-1115z-1117z-1123z-1124z-1126z-1129z-1130z-1132z-1133z-1135z-1136z-1138z-1137z-1139z-1140z-1141z-1142z-1143z-1144z-1145z-1146z-1147z-1148z-1149z-1150z-1151z-1152z-1153z-1154z-1155z-1156z-1157z-1158z-1159z-1160z-1161z-1162z-1163z-1164z-1165z-1166z-1167z-1168z-1169z-1170z-1171z-1172z-1173z-1174z-1175z-1176z-1177z-1178z-1179z-1181z-1193z-1194z-1195z-1196z-1200z-1201z-1202z-1203z-1204z-1205z-1206z-1207z-1208z-1209z-2001z-2002z-2003z-2004z-2005z-2010z-2011z-2016z-2017z-2018z-2019z-2020z-2021z-2022z-2023z-2024z-2025z-2026z-2027z-2028z-2029z-2030z-2031z-2032z-2033z-2034z-2035z-2036z-2037z-2038z-2039z-2040z-2041z-2042z-2043z-2044z-2045z-2046z-2048z-2049z-2050z-2051z-2052z-2053z-2054z-2055z-2056z-2057z-3117z-3143z-3144z-3145z-4001z-4002)z-4003z-4004z-4005z-4006z-4007z-4008z-4009z-4010z-4011z-4012z-4013)exactbroadprecisionMode)deep_extendsuperrB   describeparse_numberr-   r(   r;   r)   r'   r3   r0   r.   r>   r2   r/   r=   r<   r4   r6   r5   r8   r9   r*   r7   r1   r,   r+   r:   r?   )self	__class__s    J/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/hashkey.pyrj  zhashkey.describe)   s   gt 4 4 = = ? ? c	B
)c	B
$c	B
 $c	B
 	c	B

 tc	B
 c	B
 4c	B
  DDD %D 	D
 %D %D UD $UD 'D D "4D 'D tD D !%D  $U!D"  #D D$ %e%D& ''D( /)D* $T+D, ,U-D. 0/D0 t1D2 73D4 (5D6 '7D8 &u9D: (;D< "4=D> (?D@ ,UADB -eCDD %dED D DF  GDH !%IDJ KDL &uMDN "5ODP +EQDR )%SDT #EUDV ,UWDX /YDZ &t[D\ #D]D^ $U_D` )%aDb $UcDd $UeDf +EgD D Dh 'iDj (kDl "4mDn &toDp (qDr 1%sDt  uDv +EwDx &uyDz '{D| (}D~ #DD@ *4ADB $TCDD uEDF "5GDH *5ID D DJ +EKDL )%MDN tODP  QDR !%SDT %dUDV $UWDX &uYDZ -e[D\ /]D^ "5_D` #EaDb +JcDd eDf !%gDh !%iDj "5kD D Dl &umDn +EoDp  qDr dsDt $UuDv +EwDx %eyDz !%{D| "4}D~ uD@ #EADB dCDD !$EDF uGDH #EIDJ  KDL 'MD D DN $UODP !$QDR *4SDT (UDV %eWDX )%YDZ )%[D\ t]D^ t_D` aDb TcDd teDf "4gDh #DiDj $UkDl !%mDn (oD Dp +0$( %$)', #"!&#(  GD D Dc	B
Z  [c	B
z i;< 
 CC  5@za {c	B
X /0*++,+,01126712./*+67=>'('( &+Q0! 21 21	
 / 4Q 4Q 3A 7 1! A! 3A 8 6q 1!  )!!" 0#$ 016767=>>?45@ACD@A:;899:;  @ 2312-./0343401@A67896734  0 ./23890167;<12 c: :'N NYc	B
v %)&*#(!%!2!28!<!<!%!2!28!<!< "&!2!23!7!79J9J89T9T U!%!2!29!=!=t?P?PQZ?[?[ \!%!2!29!=!=t?P?PQZ?[?[ \!%!2!2:!>!>@Q@QR[@\@\ ]!%!2!2:!>!>@Q@QR[@\@\ ]!%!2!2;!?!?ARARS\A]A] ^!%!2!2;!?!?ARARS\A]A] ^!%!2!2;!?!?ARARSYAZAZ [	& "&!2!23!7!79J9J89T9T U!%!2!29!=!=t?P?PQZ?[?[ \!%!2!29!=!=t?P?PQZ?[?[ \!%!2!2:!>!>@Q@QR[@\@\ ]!%!2!2:!>!>@Q@QR[@\@\ ]!%!2!2;!?!?ARARS\A]A] ^!%!2!2;!?!?ARARS\A]A] ^!%!2!2;!?!?ARARS\A]A] ^	&" " < &*&*#(!%!2!29!=!=!%!2!29!=!= "&!2!23!7!79J9J99U9U V!%!2!29!=!=t?P?PQZ?[?[ \!%!2!29!=!=t?P?PQZ?[?[ \!%!2!2:!>!>@Q@QR[@\@\ ]!%!2!2:!>!>@Q@QR\@]@] ^!%!2!2;!?!?ARARS]A^A^ _!%!2!2;!?!?ARARS]A^A^ _!%!2!2;!?!?ARARSYAZAZ [	& "&!2!23!7!79J9J99U9U V!%!2!29!=!=t?P?PQZ?[?[ \!%!2!29!=!=t?P?PQZ?[?[ \!%!2!2:!>!>@Q@QR[@\@\ ]!%!2!2:!>!>@Q@QR[@\@\ ]!%!2!2;!?!?ARARS\A]A] ^!%!2!2;!?!?ARARS\A]A] ^!%!2!2;!?!?ARARS\A]A] ^	&" " =; ;=wc	B
r	 '"$5U L 8	
 Y H : 5 
 : J V h 5 h  ">!$!5!u! 7! W	!
 !&! #F! e! f! ! w! 
! ! 5! ! !  #M!!" h#!$ %# "'&-! ! !0 #*]/ /s	c	B
R #&+(-,0,1).+06:#'#'"&#(	( ( #($)$)+/26/3#()$ $. r% ',!%$&%'*/& & ',#($)*/	# # ',!%#($)*/( ( $()-#c4 4l y  )(,/3$ $
 $(!$( (
# 
# "#3  $	  ## UN NSc	B
p qc	B
r eJe/e -e /	e
 /e ,e Me ,e Je Je Je Je Me -e Je  ]!e" ]#e e$ y%e& y'e( 0)e* Z+e, --e. ]/e0 ^1e2 \3e4 \5e6 .7e8 \9e: Z;e< 1=e> \?e@ \AeB \CeD \Ee e eF \GeH ZIeJ ZKeL ZMeN ZOeP ZQeR ZSeT \UeV \WeX 5YeZ \[e\ -]e^ -_e` ]aeb .ced \eef ^ge e eh ^iej \kel .men _oep .qer .set \uev \wex .yez _{e| _}e~ _e@ .AeB .CeD _EeF 0GeH ^Ie e eJ _KeL .MeN .OeP ZQeR ZSeT -UeV -WeX -YeZ Z[e\ Z]e^ -_e` Zaeb Zced \eef .geh -iej ]ke e el .men .oep Zqer Zset Zuev Zwex Zyez Z{e| Z}e~ .e@ ZAeB ZCeD ZEeF ZGeH 1IeJ _KeL _Me e eN _OeP ^QeR .SeT .UeV .WeX .YeZ .[e\ -]e^ -_e` -aeb .ced 0eef .geh .iej Zkel .men .oe e ep .qer .set \uev .wex _yez .{e| .}e~ \e@ ]AeB .CeD \EeF 1GeH ZIeJ .KeL .MeN ZOeP ZQe e eR ZSeT ZUeV ZWeX ZYeZ .[e\ .]e^ ._e` Zaeb Zced Zeef Zgeh -iej -kel -men ^oep Zqer Zse et /''.).--**,Ie e eL Oh hsc	B
D YEc	B
 c	 c	 c		    c                 X    |                      |          }|                     |d          S )a_  
        fetches the current integer timestamp in milliseconds from the exchange server

        https://hashkeyglobal-apidoc.readme.io/reference/check-server-time

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        
serverTime)publicGetApiV1Timesafe_integerrl  paramsresponses      rn  
fetch_timezhashkey.fetch_time  s/     **622   <888ro  c                 <    |                      |          }dddd|dS )aZ  
        the latest known information on the availability of the exchange API

        https://hashkeyglobal-apidoc.readme.io/reference/test-connectivity

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `status structure <https://docs.ccxt.com/?id=exchange-status-structure>`
        okN)statusupdatedetaurlinfo)publicGetApiV1Pingrt  s      rn  fetch_statuszhashkey.fetch_status  s7     **622
 
 
 	
ro  c                 :   i }|                      |                     ||                    }|                     |dg           }|                     |dg           }|                     ||          }|                     |          r|g}|                     |          S )ae  
        retrieves data on all markets for the exchange

        https://hashkeyglobal-apidoc.readme.io/reference/exchangeinfo

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.symbol]: the id of the market to fetch
        :returns dict[]: an array of objects representing market data
        symbols	contracts)publicGetApiV1ExchangeInfoextend	safe_listarray_concatis_emptyparse_markets)rl  ru  requestrv  spotMarketsswapMarketsmarketss          rn  fetch_marketszhashkey.fetch_markets  s     224;;w3O3OPP` nnXy"==nnX{B??##K====!! 	!jG!!'***ro  marketc                 
   |                      |d          }|                      |d          }|                     |          }|                      |d          }|                     |          }|                      |d          }d}d}	d}
d}|                    d	          }|                      |d
          }|dk    r$d}d}	d}
|                      |d          }|d|z   z  }|                     |          }|dz   |z   |z   }|                      |d          }|dk    }d }d }|                     |d          }||rd}d}nd}d}|                     |dg           }|                     |d          }|                     |di           }|                     |di           }|                     |di           }|                     |                      |d                    }|                      |d          }|                      |d          }|                      |d          }|                      |d          }d }d } |
r-t          j	        ||          }t          j	        ||          }t          j	        ||          }|                     |d          }!|!|                     |!d          }"t          |!          }#|                     |!|#d
z
            }$|                      |"d           }%|                      |$d           }&t          j        |%|&          r|&|%g\  }%}&|                     t          j	        d!|&                    }|                     t          j	        d!|%                    } |                     | j        d"          }'|	r|                     |'d          n|                     |'d          }(|                     i d#|d|d$|d%|d&|d'|d(|d)|d*|d|	d+|                     |d,          d|
d-dd.dd/|
d0|d1|i d2|                     |          d|d|d3|                     |(d3          d4|                     |(d4          d5|                     |(d5          d6|                     |(d6          d7|                      |(d7          d8d d9d d:d d;d d<|                     |          |                     |d=          d>d?|                     |          |                     |          d@|                     |dA          |                     |dB          d@|| d@|                     |          d d@dCdDd dE|          S )FNsymbol
quoteAssetmarginToken	baseAssetrQ   TF -r   	PERPETUALrS   
underlying:/rz  TRADINGrS  rR  filters
filterTypePRICE_FILTERLOT_SIZEMIN_NOTIONALmin_notionalcontractMultiplierstepSizeminQtymaxQty
riskLimitsr   initialMargin1r   rE   basequotebaseIdquoteIdactivetypesubTyperR   allowMarginrT   rU   contractsettlesettleIdcontractSizer  r  r  r  r  expiryexpiryDatetimestrike
optionType	precisiontickSize)amountpricelimitsminrE  minPricemaxPrice)r  r  r@  costcreatedr~  )safe_stringsafe_currency_codesplit	safe_boolr  index_by	safe_dict	omit_zeror@   
string_divlen	string_gtparse_to_intr   safe_market_structurerk  safe_number))rl  r  marketIdr  r  r  r  r  
marketTypeisSpotisSwapsuffixparts
secondPartr  r  rz  r  isLinearr  	isInversefiltersListr  priceFilteramountFilter
costFilterminCostStringcontractSizeStringamountPrecisionStringamountMinLimitStringamountMaxLimitStringminLeveragemaxLeverager  firstarrayLengthlastminInitialMarginmaxInitialMargintradingFeesr   s)                                            rn  parse_marketzhashkey.parse_marketw  s   d ##FH55""6<88''00##FM::((22!!&+66
s##%%eQ//
$$JFF%%fl;;FcHn$F&&v..e#f,!!&(339$NN6955	  # #"nnVY;;--\::nnWnbAA~~gz2>>^^G^R@@
t'7'7
N'S'STT!--f6JKK $ 0 0z J J#//hGG#//hGG 	[$+$67LN`$a$a!#*#56JL^#_#_ #*#56JL^#_#_ ==J%z155!*oo~~j+/BB#'#3#3E?#K#K #'#3#3D/#J#J $%57GHH ^:JL\9]6$&6"//0B3HX0Y0YZZ"//0B3HX0Y0YZZnnTY	::6<et~~k6222$..Q\^dBeBe)) 6+
(6+
f6+
 D6+
 U	6+

 f6+
 w6+
 f6+
 J6+
 w6+
 F6+
 dnnV];;6+
 F6+
 e6+
 e6+
 6+
  f!6+
" #6+
 6+
$ D--.@AA%6+
& h'6+
( y)6+
* T%%dG44+6+
, T%%dG44-6+
. $..|<</6+
0 k::16+
2 t''i8836+
4 d56+
6 d76+
8 d96+
: $;6+
< ++,ABB))+zBB =6+
D ,,-ABB,,-ABB 
  ++KDD++KDD 
 '& 
  ,,];;  E6+
h ti6+
j Fk6+
 6+
 6 6 6	ro  c                 `   |                      |          }|                     |d          }i }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                     |d          }	i }
t          dt          |	                    D ]}|	|         }|                     |d          }|                     |          }|||                     |d          |                     | 	                    |                     |d                              d|                     |d	          d
ddd
| 
                    |d          | 
                    |d          |                     |d          d
|d	|
|<   |                     |d          }|dk    rdnd}|                     ||d
||                     |d          d
| 
                    |d          | 
                    |d          d
d
d
dd
d
dd|
|d          ||<   |S )a  
        fetches all available currencies on an exchange

        https://hashkeyglobal-apidoc.readme.io/reference/exchangeinfo

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        coinsr   coinId
chainTypes	chainTypeminWithdrawQuantitymaxWithdrawQuantityr  minDepositQuantityN)r   depositallowDepositallowWithdrawwithdrawFee)	rE   networkr  r  r  r   feer  r~  	tokenType
REAL_MONEYfiatcryptocoinFullName)r  r   )rE   coder  r  rF   r  r  r   r  r  r.  r~  )r  r  ranger  r  r  network_code_to_idr  rk  r  r  safe_currency_structure)rl  ru  rv  r  resulticurrecy
currencyIdr  r.  parsedNetworksjr  	networkIdnetworkCoderawTyper  s                    rn  fetch_currencieszhashkey.fetch_currencies~  s    226::x118 q#e**%% 6	 6	AAhG))'8<<J**:66D~~g|<<H#%N1c(mm,,  "1+ ,,WkBB	"55i@@#* $(#3#3G=R#S#S#'#4#4T^^DDTDTU\^sDtDt5u5u#v#v% %
 $(#3#3G=Q#R#R#'$ $	 	 ##~~g~FF $w H H++G]CC!%#%/ /{++( &&w<<G%5566HD77 !((.AA>>'>BB NN7ODD  $#   
  $#! !	 	 ++9 9  F4LL. ro  Nr  rI  c                 &   |                                   |                     |          }d|d         i}|||d<   |                     |                     ||                    }|                     |d          }|                     |||dd          S )aQ  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://hashkeyglobal-apidoc.readme.io/reference/get-order-book

        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return(maximum value is 200)
        :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
        r  rE   NrI  tba)load_marketsr  publicGetQuoteV1Depthr  rs  parse_order_book)rl  r  rI  ru  r  r  rv  	timestamps           rn  fetch_order_bookzhashkey.fetch_order_book  s     	V$$fTl
 $GG--dkk'6.J.JKK  %%h44	$$Xvy#sKKKro  sincec                     |                                   |                     |          }d|d         i}|||d<   |                     |                     ||                    }|                     ||||          S )aB  
        get the list of most recent trades for a particular symbol

        https://hashkeyglobal-apidoc.readme.io/reference/get-recent-trade-list

        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch(maximum value is 100)
        :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>`
        r  rE   NrI  )r  r  publicGetQuoteV1Tradesr  parse_trades)rl  r  r  rI  ru  r  r  rv  s           rn  fetch_tradeszhashkey.fetch_trades  s     	V$$fTl
 $GG..t{{7F/K/KLL   65%@@@ro  c                 N   d}|                                   i }d}||                     |          }d}|                     |||          \  }}|||d<   |||d<   d}	|                     ||d          \  }	}|	|	|d<   d}
|                     ||d          \  }
}d}|dk    r>||d	         |d
<   |
|
|d<   |                     |                     ||                    }n|dk    r|t          | j        dz   |z   dz             |d	         |d
<   |
/|
|d<   |                     |                     ||                    }nM| 	                    |                     ||                    }n#t          | j        dz   |z   dz   |z   dz             |                     ||||          S )a  
        fetch all trades made by the user

        https://hashkeyglobal-apidoc.readme.io/reference/get-account-trade-list
        https://hashkeyglobal-apidoc.readme.io/reference/query-futures-trades
        https://hashkeyglobal-apidoc.readme.io/reference/get-sub-account-user

        :param str symbol: *is mandatory for swap markets* unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: 'spot' or 'swap' - the type of the market to fetch trades for(default 'spot')
        :param int [params.until]: the latest time in ms to fetch trades for, only supports the last 30 days timeframe
        :param str [params.fromId]: srarting trade id
        :param str [params.toId]: ending trade id
        :param str [params.clientOrderId]: *spot markets only* filter trades by orderId
        :param str [params.accountId]: account id to fetch the orders from
        :returns Trade[]: a list of `trade structures <https://github.com/ccxt/ccxt/wiki/Manual#trade-structure>`
        r   NrQ   	startTimerI  untilendTime	accountIdrE   r  rS    .() requires a symbol argument for swap marketssubAccountId() is not supported for  type of markets)r  r  handle_market_type_and_paramshandle_option_and_paramsprivateGetApiV1AccountTradesr  r,   rE   *privateGetApiV1FuturesSubAccountUserTrades privateGetApiV1FuturesUserTradesr8   r  )rl  r  r  rI  ru  
methodNamer  r  r  r  r  rv  s               rn  fetch_my_tradeszhashkey.fetch_my_trades$  s   ( %
[[((F
!??
FTZ[[
F#(GK $GG55fj'RRv!&GI	 99&*kZZ	6!$*4L!$'0$88Wf9U9UVVHH< 6!!~'#
(BEu(uvvv &tGH$*3'JJ4;;W^`fKgKghh@@WV\A]A]^^* tw}z9<VVYccfxxyyy  65%@@@ro  tradec                 *   |                      |dd          }|                     |d          }|                     ||          }|                     |d          }|)|                     |                    d          d          }|                     |d          }||rdnd	}d }|                     |d
dg          }||rdnd}|                     |d          }	|	d}|	rd	nd}|                     |d          }
|                     |d          }|                     |d          }d }|,|                     |d          }
|                     |d          }|
+|                     |
          | 	                    |          d}| 
                    |                     |dd          ||                     |          |d         ||                     |dd          |                     |g d          d |d |                     |d          ||d|          S )Nr  timer  side_r   isBuyerbuysellisMakerisMarkerr  r  ibm
commissioncommissionAssetr  	feeCoinIdr  currencyrE   tradeIdpr  )qqtyquantityorderId)rE   r  datetimer  r/  r  r  r  takerOrMakerr  orderr  r~  )safe_integer_2r  safe_marketsafe_string_lowerr  r  safe_bool_nr  rk  r  
safe_tradesafe_string_2iso8601safe_string_n)rl  r,  r  r  r  r/  r1  rC  r4  isBuyerMakerfeeCostfeeCurrncyIdfeeInfor  s                 rn  parse_tradezhashkey.parse_trade  sW   l ''sF;;	##E844!!(F33%%eV44##DJJsOOQ77D..	22#/55D""59j*ABB&-:777L~~eU33#"L)466uD""5,77''/@AA....&&w66G++G[AAL))'22 33LAA C $$UD)<<"Y//X&''sG<<((0H0H0HII(%%eY77 
  
   	ro  r   	timeframec           	         d}|                                   d}|                     ||d          \  }}|r|                     d|||||d          S |                     |          }|                     | j        ||          }|d         |d}	|||	d<   |||	d	<   d}
|                     ||d
          \  }
}|
|
|	d<   |                     |                     |	|                    }|                     |||||          S )a  

        https://hashkeyglobal-apidoc.readme.io/reference/get-kline

        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :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 candle to fetch
        :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
        r   FpaginaterG  rE   )r  intervalNr  rI  r  r  )	r  r&  "fetch_paginated_call_deterministicr  r  r   publicGetQuoteV1Klinesr  parse_ohlcvs)rl  r  rR  r  rI  ru  r*  rT  r  r  r  rv  s               rn  fetch_ohlcvzhashkey.fetch_ohlcv  s;    "
88ZXX& 	x::<QVX]_hjprvwwwV$$$$T_iKK	Tl!
 
 #(GK $GG55fj'RRv!&GI..t{{7F/K/KLL"   69eUKKKro  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   r      r      r   )rs  r  )rl  ohlcvr  s      rn  parse_ohlcvzhashkey.parse_ohlcv(  s     eQ''UA&&UA&&UA&&UA&&UA&&
 	
ro  c                    |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |di           }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://hashkeyglobal-apidoc.readme.io/reference/get-24hr-ticker-price-change

        :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>`
        r  rE   r   )r  r  publicGetQuoteV1Ticker24hrr  r  parse_ticker)rl  r  ru  r  r  rv  tickers          rn  fetch_tickerzhashkey.fetch_ticker?  s     	V$$fTl
 224;;w3O3OPP" !R00  000ro  r  c                     |                                   |                     |          }|                     |          }|                     ||          S )a$  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://hashkeyglobal-apidoc.readme.io/reference/get-24hr-ticker-price-change

        :param str[] [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>`
        )r  market_symbolsr`  parse_tickers)rl  r  ru  rv  s       rn  fetch_tickerszhashkey.fetch_tickersb  sR     	%%g..226::!!(G444ro  c                    |                      |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|          S )Nr  sr  cr  rB  highhlowlbidr  	bidVolumeaskr  	askVolumevwapopenocloser  previousClosechanger  averagevqv)
baseVolumequoteVolumer~  )rs  r  rF  safe_tickerrK  )rl  rb  r  r  r  r  r  s          rn  ra  zhashkey.parse_tickerq  s    %%fc22	##FC00!!(F33!,, !
f!
!
 Y//!
 D$$VS11	!

 4##FC00!
 4##FC00!
 !
 4##FC00!
 !
 D!
 D$$VS11!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **6377++FD99)!
 !
 !
* +  	ro  c                     |                                   |                     |          }i }|                     |                     ||                    }|                     ||          S )a  
        fetches the last price for multiple markets

        https://hashkeyglobal-apidoc.readme.io/reference/get-symbol-price-ticker

        :param str[] [symbols]: unified symbols of the markets to fetch the last prices
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.symbol]: the id of the market to fetch last price for
        :returns dict: a dictionary of lastprices structures
        )r  re  publicGetQuoteV1TickerPricer  parse_last_pricesrl  r  ru  r  rv  s        rn  fetch_last_priceszhashkey.fetch_last_prices  sg     	%%g..33DKK4P4PQQ %%h888ro  c                     |                      |d          }|                     ||          }|d         d d |                     |d          d |dS )Nri  r  r=  )r  r  rB  r  r/  r~  )r  rF  r  )rl  entryr  r  s       rn  parse_last_pricezhashkey.parse_last_price  sb    ##E3//!!(F33X&%%eS11
 
 	
ro  c                    |                                   i }d}d}|                     |d||          \  }}|dk    rA|                     |          }|                     |di           }|                     |          S |dk    r>|                     |                     ||                    }|                     |          S t          | j	        dz   |z   dz   |z   dz             )	a*  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://hashkeyglobal-apidoc.readme.io/reference/get-account-information

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.accountId]: account ID, for Master Key only
        :param str [params.type]: 'spot' or 'swap' - the type of the market to fetch balance for(default 'spot')
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        rt   rQ   NrS   r   r   r#  r$  )
r  r%  privateGetApiV1FuturesBalancer  parse_swap_balanceprivateGetApiV1Accountr  parse_balancer8   rE   )rl  ru  r  r*  r  rv  balances          rn  fetch_balancezhashkey.fetch_balance  s     	#

!??
DRXZdee
F99&AAH nnXq"55G**73336!!224;;w3O3OPPH" %%h///tw}z9<VVYccfxxyyyro  c                    d|i}|                      |dg           }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )	Nr~  balancesr   assettotalfreelockedused)r  r   r  r  r  accountsafe_balance)	rl  r  r  r  r  balanceEntryr  r  r  s	            rn  r  zhashkey.parse_balance  s    $ G
 >>':r::q#h--(( 	# 	#A#A;L)),@@J**:66DllnnG#//gFFGG"..|VDDGFO"..|XFFGFO"F4LL  (((ro  c                 v   |                      |d          }|                     |          }|                                 }|                      |d          |d<   |                      |d          }|                      |d          }t          j        ||          |d<   d|i}|||<   |                     |          S )Nr  r  r  positionMarginorderMarginr  r~  )r  r  r  r@   
string_addr  )rl  r  r  r  r  r  r  r  s           rn  r  zhashkey.parse_swap_balance  s     %%gw77
&&z22,,..++GY??))'3CDD&&w>>!,^[IIG
 t  (((ro  r  c                    |                                   |                     |          }d|d         i}d}|                     |          \  }}||                     |          }|                     ||          |d<   |                     |                     ||                    }|                     ||          }||d<   |S )a  
        fetch the deposit address for a currency associated with self account

        https://hashkeyglobal-apidoc.readme.io/reference/get-deposit-address

        :param str code: unified currency code(default is 'USDT')
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.network]: network for fetch deposit address(default is 'ETH')
        :returns dict: an `address structure <https://docs.ccxt.com/?id=address-structure>`
        coinrE   Nr  r  )r  r;  handle_network_code_and_paramsdefault_network_coder  $privateGetApiV1AccountDepositAddressr  parse_deposit_address)rl  r  ru  r;  r  r
  rv  depositAddresss           rn  fetch_deposit_addresszhashkey.fetch_deposit_address0  s     	==&&HTN
  "AA&IIV33D99K#66{DII<<T[[RX=Y=YZZ 33HhGG$/y!ro  r;  c                     |                      |d          }|                     |           |                      |d          }|dk    rd }||d         d ||dS )Naddress
addressExtr  r  )r~  r;  r  r  tag)r  check_address)rl  r  r;  r  r  s        rn  r  zhashkey.parse_deposit_addressV  ss     "">9==7###~|<<"99C" (
 
 	
ro  c                 d   d}|                                   i }d}| |                     |          }|d         |d<   |||d<   |||d<   d}|                     ||d          \  }}|||d<   |                     |                     ||                    }	|                     |	|||d	d
i          S )a  
        fetch all deposits made to an account

        https://hashkeyglobal-apidoc.readme.io/reference/get-deposit-history

        :param str code: unified currency code of the currency transferred
        :param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
        :param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch transfers for(default time now)
        :param int [params.fromId]: starting ID(To be released)
        :returns dict[]: a list of `transfer structures <https://docs.ccxt.com/?id=transfer-structure>`
        r   NrE   r  r  rI  r  r  r  r  )r  r;  r&  #privateGetApiV1AccountDepositOrdersr  parse_transactions
rl  r  r  rI  ru  r*  r  r;  r  rv  s
             rn  fetch_depositszhashkey.fetch_depositsp  s     %
!}}T**H&tnGFO#(GK $GG55fj'RRv!&GI;;DKKQW<X<XYY &&x5%&R[I\]]]ro  c                 d   d}|                                   i }d}| |                     |          }|d         |d<   |||d<   |||d<   d}|                     ||d          \  }}|||d<   |                     |                     ||                    }	|                     |	|||d	d
i          S )a  
        fetch all withdrawals made from an account

        https://hashkeyglobal-apidoc.readme.io/reference/withdrawal-records

        :param str code: unified currency code of the currency transferred
        :param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
        :param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch transfers for(default time now)
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        r   NrE   r  r  rI  r  r  r  
withdrawal)r  r;  r&  $privateGetApiV1AccountWithdrawOrdersr  r  r  s
             rn  fetch_withdrawalszhashkey.fetch_withdrawals  s     (
!}}T**H&tnGFO#(GK $GG55fj'RRv!&GI<<T[[RX=Y=YZZ, &&x5%&R^I_```ro  r  r  r  c                    |                      ||          \  }}|                                  |                     |          }|d         ||d}|||d<   d}|                     |          \  }}||                     |          |d<   |                     |                     ||                    }	|                     |	|          S )a  
        make a withdrawal

        https://hashkeyglobal-apidoc.readme.io/reference/withdraw

        :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
        :param str [params.network]: network for withdraw
        :param str [params.clientOrderId]: client order id
        :param str [params.platform]: the platform to withdraw to(hashkey, HashKey HK)
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        rE   )r  r  r@  Nr  r  )handle_withdraw_tag_and_paramsr  r;  r  r  privatePostApiV1AccountWithdrawr  parse_transaction)
rl  r  r  r  r  ru  r;  r  r
  rv  s
             rn  r   zhashkey.withdraw  s      99#vFFV==&&TN
 

 ?$'GL!"AA&IIV"#'#:#:;#G#GGK 77GV8T8TUU %%h999ro  c                    |                      |dd          }|                     |d          }|                     |d          }|6|                     |dd          }|rd}n|                     |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S )NrE   rA  r  rz  successFry  
addressUrltxIdr  r.  r@  r  r:  r~  txidr  rB  r  	addressToaddressFromr  tagTotagFromr  r  r;  r{  )internalcommentr  )rJ  r  r  r  rs  r  rK  parse_transaction_status)rl  transactionr;  rE   r  rz  r  r  r  r  r  r  r  rN  r  s                  rn  r  zhashkey.parse_transaction  s0   R T9=="";	::!!+x88>nn[)UCCG "!--k<HH
)!FV44V44&&tX66%%k6::	!!+z::"";66  C
K
"
 D
 	

 Y//
 t
 w
 
 4
 4
 T
 t
 D
 f
 
  d33F;;!
" t#
$ )
 
 
 	
ro  c                 N    ddddddddddddd}|                      |||          S )Npendingfailedry  	cancelled)r  2345678910
successfulr  r  rl  rz  statusess      rn  r  z hashkey.parse_transaction_statusR  sL    
 
 &&999ro  fromAccount	toAccountc                    |                                   |                     |          }|d         |                     ||          ||d}|                     |                     ||                    }|                     ||          S )a  
        transfer currency internally between wallets on the same account

        https://hashkeyglobal-apidoc.readme.io/reference/new-account-transfer

        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account id to transfer from
        :param str toAccount: account id to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.clientOrderId]: a unique id for the transfer
        :param str [params.remark]: a note for the transfer
        :returns dict: a `transfer structure <https://docs.ccxt.com/?id=transfer-structure>`
        rE   )r  r@  fromAccountIdtoAccountId)r  r;  currency_to_precision$privatePostApiV1AccountAssetTransferr  parse_transfer)	rl  r  r  r  r  ru  r;  r  rv  s	            rn  r   zhashkey.transferc  s     	==&&TN224@@($	
 
 <<T[[RX=Y=YZZ ""8X666ro  c           
      "   |                      |d          }|                     |d          }d }|                     |dd          }|rd}|                     |d          ||                     |          |                     ||          d d d ||d	S )Nr  rE   r  Fry  rA  )	rE   r  rB  r;  r  r  r  rz  r~  )rs  r  r  rK  r  )rl  r   r;  r  r  rz  r  s          rn  r  zhashkey.parse_transfer  s    %%h<<	%%h55
..9e<< 	F""8Y77"Y////
HEE

 

 
	
ro  c                     |                                   |                     |          }|                     ||          S )aj  
        fetch all the accounts associated with a profile

        https://hashkeyglobal-apidoc.readme.io/reference/query-sub-account

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `account structures <https://docs.ccxt.com/?id=account-structure>` indexed by the account type
        )r  privateGetApiV1AccountTypeparse_accountsrt  s      rn  fetch_accountszhashkey.fetch_accounts  sA     	226:: ""8V444ro  c                    |                      |d          }d}|dk    s|dk    rd}n|dk    s|dk    rd}|                     |                      |d	                    }|d
z   |z   }|                      |d          |d |dS )NaccountLabelr  zMain Trading AccountzMain Future AccountmainzSub Main Trading AccountzSub Main Future AccountsubaccountTyper   r  )rE   r  r  r~  )r  parse_account_type)rl  r  r  labelr  r  s         rn  parse_accountzhashkey.parse_account  s    ''@@111\EZ5Z5ZEE777<Kd;d;dE--d.>.>w.V.VWWs{[(""7K88	
 
 	
ro  c                 >    ddddd}|                      |||          S )Nzspot accountzswap accountzcustody accountzfiat account)r  r  r  r  r  rl  r  typess      rn  r  zhashkey.parse_account_type  s4    "	
 
 tT222ro  c                 <    dddd}|                      |||          S )Nr  r  r  )rQ   rS   custodyrs  r  s      rn  encode_account_typezhashkey.encode_account_type  s1    
 

   d333ro  c                 @    dddddd}|                      |||          S )Nr  r  51900904)r,  r  r   r  r   r  r  s      rn  encode_flow_typezhashkey.encode_flow_type  s7    
 
   d333ro  c                    d}|t          | j        dz   |z   dz             d}|                     ||d          \  }}|t          | j        dz   |z   dz             |                                  |                     |          }i }||d<   |||d<   ||d	<   d}	|                     ||d
          \  }	}|	|                     |	          |d
<   d}
|                     ||d          \  }
}|
|                     |
          |d<   |                     |                     ||                    }| 	                    ||||          S )a\  
        fetch the history of changes, actions done by the user or operations that altered the balance of the user

        https://hashkeyglobal-apidoc.readme.io/reference/get-account-transaction-list

        :param str [code]: unified currency code, default is None(not used)
        :param int [since]: timestamp in ms of the earliest ledger entry, default is None
        :param int [limit]: max number of ledger entries to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for
        :param int [params.flowType]: trade, fee, transfer, deposit, withdrawal
        :param int [params.accountType]: spot, swap, custody
        :returns dict: a `ledger structure <https://docs.ccxt.com/?id=ledger-entry-structure>`
        r   Nr   z() requires a since argumentr  z() requires an until argumentr  rI  r  flowTyper  )
r,   rE   r&  r  r;  r  r  !privateGetApiV1AccountBalanceFlowr  parse_ledger)rl  r  r  rI  ru  r*  r  r;  r  r  r  rv  s               rn  fetch_ledgerzhashkey.fetch_ledger  sy    #
=#DGcMJ$>A_$_```55fj'RRv=#DGcMJ$>A`$`aaa==&&$$GG"	88ZXX&"&"7"7"A"AGJ";;FJP]^^V"%)%=%=k%J%JGM"99$++gv:V:VWW&   8UEBBBro  c                 @    dddddd}|                      |||          S )Nr,  r  r   r  r   )r  r  r  r  r  r  r  s      rn  parse_ledger_entry_typezhashkey.parse_ledger_entry_type	  s7    
 
 tT222ro  itemc                    |                      |d          }|                      |d          }|                     |d          }|                     |                      |d                    }|                      |d          }|                     ||          }|                     ||          }|                      |d          }	|                     |	          }
d}|	                    d          d	k    r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 )NrE   r  r  flowTypeValuer  rx  inr  r   outr  ry  r~  r  rB  r  	directionreferenceIdreferenceAccountr  r;  r  r  beforeafterrz  r  )	r  rs  r  r  safe_currencyrk  findsafe_ledger_entryrK  )rl  r  r;  rE   r  r  r  r  r  amountStringr  r  afterStringr  rz  s                  rn  parse_ledger_entryzhashkey.parse_ledger_entry	  s     dD))""455%%dI66	++D,<,<T?,S,STT%%dF33
&&z8<<%%j(;;''h77""<00	S!!Q&&I&&tW55!!+..%% '
D'
"'
 '
 Y//	'

 w'
 '
 4'
 '
 D'
 '
 d'
 f'
 d'
 U'
 f'
  4!'
" #  	ro  r  r/  r  c                 "   |                                   |                     |          }|d         r|                     ||||||          S |d         r|                     ||||||          S t	          | j        dz   |d         z   dz             )a7  
        create a trade order

        https://hashkeyglobal-apidoc.readme.io/reference/test-new-order
        https://hashkeyglobal-apidoc.readme.io/reference/create-order
        https://hashkeyglobal-apidoc.readme.io/reference/create-new-futures-order

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or 'LIMIT_MAKER' for spot, 'market' or 'limit' or 'STOP' for swap
        :param str side: 'buy' or 'sell'
        :param float amount: how much of you want to trade in units of the base currency
        :param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
        :param boolean [params.test]: *spot markets only* whether to use the test endpoint or not, default is False
        :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" or "IOC" or "PO" for spot, 'GTC' or 'FOK' or 'IOC' or 'LIMIT_MAKER' or 'PO' for swap
        :param str [params.clientOrderId]: a unique id for the order - is mandatory for swap
        :param float [params.triggerPrice]: *swap markets only* The price at which a trigger order is triggered at
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        rQ   rS   z$ createOrder() is not supported for r  r$  )r  r  create_spot_ordercreate_swap_orderr8   rE   rl  r  r  r/  r  r  ru  r  s           rn  create_orderzhashkey.create_orderQ	  s    , 	V$$&> 	w))&$feVTTTF^ 	w))&$feVTTTtw)OORXY_R``cuuvvvro  r  c                     |                                   |                     |          }|d         st          | j        dz             d|i}|                     |dd|d|                     ||                    S )a  
        create a market buy order by providing the symbol and cost
        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        rQ   zB createMarketBuyOrderWithCost() is supported for spot markets onlyr  r  r2  N)r  r  r8   rE   r  r  )rl  r  r  ru  r  reqs         rn  !create_market_buy_order_with_costz)hashkey.create_market_buy_order_with_costp	  s     	V$$f~ 	otw)mmnnnD
   5$dkkRUW]F^F^___ro  c                 x   |                      |dd          }|t          | j        dz             |                                  |                     |          }|dk    o|dk    }	|                     |d          }
|	s|
t          | j        dz             |                     ||||||          }i }|                     |d	          }|r,|                     |d	          }| 	                    |          }n/|	r|
| 
                    |          }n|                     |          }|                     ||          S )
a  
        create a trade order on spot market

        https://hashkeyglobal-apidoc.readme.io/reference/test-new-order
        https://hashkeyglobal-apidoc.readme.io/reference/create-order

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or 'LIMIT_MAKER'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of you want to trade in units of the base currency
        :param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.cost]: *market buy only* the quote quantity that can be used alternative for the amount
        :param bool [params.test]: whether to use the test endpoint or not, default is False
        :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', or 'PO'
        :param str [params.clientOrderId]: a unique id for the order
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        	stopPricer7  Nz2 trigger orders are not supported for spot marketsr  r2  r  zF createOrder() supports cost parameter for spot market buy orders onlyr   )rJ  r8   rE   r  r  r  create_spot_order_requestr  omitprivatePostApiV1SpotOrderTestprivatePostApiV11SpotOrderprivatePostApiV1SpotOrderparse_order)rl  r  r  r/  r  r  ru  r7  r  isMarketBuyr  r  rv  r   s                 rn  r  zhashkey.create_spot_order	  s\   ( ))&+~NN#tw)]]^^^V$$x'<dem// 	s$"2tw)qqrrr66vtT6SXZ`aa~~ff-- 	?YYvv..F99'BBHH 	?dl66w??HH* 55g>>Hv &111ro  c                     |                      |          }|d         r|                     ||||||          S |d         r|                     ||||||          S t          | j        dz   dz   |d         z   dz             )NrQ   rS   r   *createOrderRequest() is not supported for r  r$  )r  r  create_swap_order_requestr8   rE   r  s           rn  create_order_requestzhashkey.create_order_request	  s    V$$&> 	C11&$feU[\\\F^ 	C11&$feU[\\\tw}/[[^dek^ll  pB   B  C  C  Cro  c                 >   |                      |          }|                                }|d         |                                |d}||                     ||          |d<   d}	|                     |d          \  }	}|	|                     ||	          |d<   ||                     ||          |d<   |dk    }
d}|                     |
|d	k    |          \  }}|r|d
k    rd	|d<   d}|                     |d          \  }}|||d<   |                     ||          S )a  
 @ignore
        helper function to build request
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or 'LIMIT_MAKER'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of you want to trade in units of the base currency
        :param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.cost]: *market buy only* the quote quantity that can be used alternative for the amount
        :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", or "PO"
        :param str [params.clientOrderId]: a unique id for the order
        :returns dict: request to be sent to the exchange
        rE   )r  r/  r  Nr@  r  r  MARKETFLIMIT_MAKERLIMITr  clientOrderIdnewClientOrderId)r  upperamount_to_precisionhandle_param_stringcost_to_precisionprice_to_precisionhandle_post_onlyr  )rl  r  r  r/  r  r  ru  r  r  r  isMarketOrderpostOnlyr%  s                rn  r  z!hashkey.create_spot_order_request 
  sQ     V$$zz||TlJJLL
 

 "&":":66"J"JGJ//??f"&"8"8"F"FGJ#66vuEEGG(00@UW]^^& 	,+GFO! $ 8 8 Q Qv$)6F%&{{7F+++ro  c                    |                      |          }|d         d|                     ||          d}|dk    }	|	rd|d<   ||                     ||          |d<   d	|d<   d
}
|                     |d|
          \  }
}d}|
rd}|                                |z   |d<   d}|                     |d          \  }}d
}|                     |	|dk    |          \  }}|rd}|||d<   |                     |d          }||                                 |d<   |                     |d          }|4|                     ||          |d<   d|d<   | 	                    |d          }| 
                    ||          S )a"  
 @ignore
        helper function to build request
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or 'STOP'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of you want to trade in units of the base currency
        :param float [price]: the price that 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 bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately
        :param bool [params.reduceOnly]: True or False whether the order is reduce only
        :param float [params.triggerPrice]: The price at which a trigger order is triggered at
        :param str [params.timeInForce]: 'GTC', 'FOK', 'IOC', 'LIMIT_MAKER' or 'PO'
        :param str [params.clientOrderId]: a unique id for the order
        :returns dict: request to be sent to the exchange
        rE   r$  )r  r  r@  r  r"  	priceTypeNr  INPUTF
reduceOnly_OPEN_CLOSEr/  r=  r#  r%  r7  r  STOPr  )r  r(  r+  handle_param_boolr'  r)  r,  r  uuidr  r  )rl  r  r  r/  r  r  ru  r  r  r-  r2  r  r=  r.  r%  r7  s                   rn  r  z!hashkey.create_swap_order_request*
  s   " V$$Tl00@@
 

 ( 	,#+GK #66vuEEGG#*GK 
!33FL*UU
F 	F**,,/"66v}MMV00}@\^dee& 	('K"%0GM"((AA '+yy{{GO$''??##'#:#:6<#P#PGK $GFOYYv~66F{{7F+++ro  c                    |                                   |                     |          }|                     ||||||          }|                     |                     ||                    }	|                     |	|          S )a  
        create a trade order on swap market

        https://hashkeyglobal-apidoc.readme.io/reference/create-new-futures-order

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or 'STOP'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of you want to trade in units of the base currency
        :param float [price]: the price that 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 bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately
        :param bool [params.reduceOnly]: True or False whether the order is reduce only
        :param float [params.triggerPrice]: The price at which a trigger order is triggered at
        :param str [params.timeInForce]: 'GTC', 'FOK', 'IOC', 'LIMIT_MAKER' or 'PO'
        :param str [params.clientOrderId]: a unique id for the order
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        )r  r  r  privatePostApiV1FuturesOrderr  r  )
rl  r  r  r/  r  r  ru  r  r  rv  s
             rn  r  zhashkey.create_swap_order_
  s~    & 	V$$00tVUTZ[[44T[[&5Q5QRR, &111ro  ordersc           	         |                                   g }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |d          }|                     |d          }	|                     |d          }
|                     |di           }|                     ||||	|
|          }|                     |d          }||                                 |d<   |                    |           |d         }|                     |d          }| 	                    |          }d
|i}d	}|d         r*| 
                    |                     ||                    }nX|d         r*|                     |                     ||                    }n&t          | j        dz   dz   |d         z   dz             |                     |dg           }g }t          dt          |                    D ]E}|                     ||i           }|                     |di           }|                    |           F|                     |          S )aT  
        create a list of trade orders(all orders should be of the same symbol)

        https://hashkeyglobal-apidoc.readme.io/reference/create-multiple-orders
        https://hashkeyglobal-apidoc.readme.io/reference/batch-create-new-futures-order

        :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
        :param dict [params]: extra parameters specific to the api endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        r   r  r  r/  r  r  ru  r%  Nr:  rQ   rS   r   r  r$  r  rD  )r  r   r  r  r  r  r   r7  appendr  privatePostApiV1SpotBatchOrdersr  "privatePostApiV1FuturesBatchOrdersr8   rE   r  parse_orders)rl  r:  ru  ordersRequestsr  rawOrderr  r  r/  r  r  orderParamsorderRequestr%  
firstOrderfirstSymbolr  r  rv  r  responseOrdersresponseEntryresponseOrders                          rn  create_orderszhashkey.create_orders
  s    	q#f++&& 	0 	0AayH%%h99F##Hf55D##Hf55D%%h99F$$Xw77E..8R@@K44VT4QVXcddL ,,\?KKM$04		_-!!,////#A&
&&z8<<[))n
 &> C	C;;DKKQW<X<XYYHH8 F^ &	C>>t{{7TZ?[?[\\HHJ tw}/[[^dek^ll  pB   B  C  C  C(B77q#f++&& 	1 	1A NN61b99M NN='2FFM!!-0000  000ro  rE   c                    d}|                      ||           |                                  i }|                     |d          }|||d<   d}||                     |          }d}|                     ||||          \  }}d}	|dk    r*|                     |                     ||                    }	n|dk    r`d}
|                     |||
          \  }
}|
rd|d	<   nd
|d	<   ||d         |d<   |                     |                     ||                    }	n#t          | j
        dz   |z   dz   |z   dz             |                     |	          S )ax  
        cancels an open order

        https://hashkeyglobal-apidoc.readme.io/reference/cancel-order
        https://hashkeyglobal-apidoc.readme.io/reference/cancel-futures-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.type]: 'spot' or 'swap' - the type of the market to fetch entry for(default 'spot')
        :param str [params.clientOrderId]: a unique id for the order that can be used alternative for the id
        :param bool [params.trigger]: *swap markets only* True for canceling a trigger order(default False)
        :param bool [params.stop]: *swap markets only* an alternative for trigger param
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        r\   r%  NrA  rQ   rS   Fr5  r  r$  rE   r  r   r#  r$  )check_type_paramr  r  r  r%  privateDeleteApiV1SpotOrderr   handle_trigger_option_and_paramsprivateDeleteApiV1FuturesOrderr8   rE   r  rl  rE   r  ru  r*  r  r%  r  r  rv  	isTriggers              rn  cancel_orderzhashkey.cancel_order
  s     #
j&111((AA !#GI[[((F
!??
FTZ\fgg
F77GV8T8TUUHH" 6!!I $ E EfjZc d dIv *"(")!$*4L!::4;;wPV;W;WXXHH2 tw}z9<VVYccfxxyyy)))ro  c                 <   d}|t          | j        dz   |z   dz             |                                  |                     |          }d|d         i}|                     |d          }|||d<   d}|d         r*|                     |                     ||                    }n[|d	         r*|                     |                     ||                    }n)t          | j        dz   |z   d
z   |d         z   dz             | 	                    |          }||d<   |gS )a  
        cancel all open orders

        https://hashkeyglobal-apidoc.readme.io/reference/cancel-all-open-orders
        https://hashkeyglobal-apidoc.readme.io/reference/batch-cancel-futures-order

        :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.side]: 'buy' or 'sell'
        :returns dict: response from exchange
        rZ   Nr   z() requires a symbol argumentr  rE   r/  rQ   rS   r#  r  r$  r~  )
r,   rE   r  r  r   privateDeleteApiV1SpotOpenOrdersr  $privateDeleteApiV1FuturesBatchOrdersr8   
safe_order)	rl  r  ru  r*  r  r  r/  rv  rD  s	            rn  cancel_all_orderszhashkey.cancel_all_ordersN  sC    '
>#DGcMJ$>A`$`aaaV$$fTl
 //"GFO&> 	~<<T[[RX=Y=YZZHH F^ 	~@@WV\A]A]^^HH
 tw}z9<VVY_`fYggj||}}})) fwro  idsc                    d}|                                   i }d                    |          }||d<   d}||                     |          }d}|                     ||||          \  }}d}	|dk    r)|                     |                     |                    }	nR|dk    r)|                     |                     |                    }	n#t          | j        dz   |z   dz   |z   d	z             | 	                    |	          }
|	|
d
<   |
gS )ak  
        cancel multiple orders

        https://hashkeyglobal-apidoc.readme.io/reference/cancel-multiple-orders
        https://hashkeyglobal-apidoc.readme.io/reference/batch-cancel-futures-order-by-order-id

        :param str[] ids: order ids
        :param str [symbol]: unified market symbol(not used by hashkey)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: 'spot' or 'swap' - the type of the market to fetch entry for(default 'spot')
        :returns dict: an list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        r]   ,rW  NrQ   rS   r   r#  r$  r~  )
r  joinr  r%  &privateDeleteApiV1SpotCancelOrderByIdsr  )privateDeleteApiV1FuturesCancelOrderByIdsr8   rE   rU  )rl  rW  r  ru  r*  r  orderIdsr  r  rv  rD  s              rn  cancel_orderszhashkey.cancel_ordersw  s%    $
88C==![[((F
!??
FTZ\fgg
FBB4;;wCWCWXXHH 6!!EEdkkRYFZFZ[[HHtw}z9<VVYccfxxyyy)) fwro  c                    d}|                      ||           |                                  i }d}|                     |d          \  }}|||d<   d}||                     |          }d}|                     ||||          \  }}d}	|dk    r1|||d<   |                     |                     ||                    }	nv|dk    rMd}
|                     |||
          \  }
}|
rd	|d
<   |                     |                     ||                    }	n#t          | j
        dz   |z   dz   |z   dz             |                     |	          S )a  
        fetches information on an order made by the user

        https://hashkeyglobal-apidoc.readme.io/reference/query-order
        https://hashkeyglobal-apidoc.readme.io/reference/get-futures-order

        :param str id: the order id
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: 'spot' or 'swap' - the type of the market to fetch entry for(default 'spot')
        :param str [params.clientOrderId]: a unique id for the order that can be used alternative for the id
        :param str [params.accountId]: *spot markets only* account id to fetch the order from
        :param bool [params.trigger]: *swap markets only* True for fetching a trigger order(default False)
        :param bool [params.stop]: *swap markets only* an alternative for trigger param
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        r   Nr%  rA  rQ   origClientOrderIdrS   Fr5  r  r   r#  r$  )rK  r  r)  r  r%  privateGetApiV1SpotOrderr  rM  privateGetApiV1FuturesOrderr8   rE   r  rO  s              rn  fetch_orderzhashkey.fetch_order  s   " "
j&111! $ 8 8 Q Qv !#GI[[((F
!??
FTZ\fgg
F(/<+,44T[[&5Q5QRRHH< 6!!I $ E EfjZc d dIv )"(77GV8T8TUUHH2 tw}z9<VVYccfxxyyy)))ro  c                    d}|                      ||           |                                  d}||                     |          }d}|                     ||||          \  }}|                     d|i|          }|dk    r|                     ||||          S |dk    r|                     ||||          S t          | j        dz   |z   dz   |z   dz             )	a  
        fetch all unfilled currently open orders

        https://hashkeyglobal-apidoc.readme.io/reference/get-current-open-orders
        https://hashkeyglobal-apidoc.readme.io/reference/get-sub-account-open-orders
        https://hashkeyglobal-apidoc.readme.io/reference/sub
        https://hashkeyglobal-apidoc.readme.io/reference/query-open-futures-orders

        :param str [symbol]: unified market symbol of the market orders were made in - is mandatory for swap markets
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve - default 500, maximum 1000
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: 'spot' or 'swap' - the type of the market to fetch entries for(default 'spot')
        :param str [params.orderId]: *spot markets only* the id of the order to fetch
        :param str [params.side]: *spot markets only* 'buy' or 'sell' - the side of the orders to fetch
        :param str [params.fromOrderId]: *swap markets only* the id of the order to start from
        :param bool [params.trigger]: *swap markets only* True for fetching trigger orders(default False)
        :param bool [params.stop]: *swap markets only* an alternative for trigger param
        :param str [params.accountId]: account id to fetch the orders from
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        r   NrQ   r*  rS   r   r#  r$  )	rK  r  r  r%  r  fetch_open_spot_ordersfetch_open_swap_ordersr8   rE   )rl  r  r  rI  ru  r*  r  r  s           rn  fetch_open_orderszhashkey.fetch_open_orders   s    , '
j&111[[((F
!??
FTZ\fgg
FlJ7@@..vueVLLL6!!..vueVLLLtw}z9<VVYccfxxyyyro  c                    |                                   d}|                     |d|          \  }}d}i }d}d}	|                     ||d          \  }	}|	/|	|d<   |                     |                     ||                    }nR| |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     ||||          S )	a  
 @ignore
        fetch all unfilled currently open orders for spot markets

        https://hashkeyglobal-apidoc.readme.io/reference/get-current-open-orders
        https://hashkeyglobal-apidoc.readme.io/reference/sub

        :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 - default 500, maximum 1000
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.orderId]: the id of the order to fetch
        :param str [params.side]: 'buy' or 'sell' - the side of the orders to fetch
        :param str [params.accountId]: account id to fetch the orders from
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        fetchOpenSpotOrdersr*  Nr  r"  rE   r  rI  )r  r)  r&  'privateGetApiV1SpotSubAccountOpenOrdersr  r  privateGetApiV1SpotOpenOrdersr?  )
rl  r  r  rI  ru  r*  r  r  rv  r  s
             rn  re  zhashkey.fetch_open_spot_orders&  s   " 	*
!55flJWW
F	 99&*kZZ	6 &/GN#CCDKKPWY_D`D`aaHH!V,,$*4L! #( 99$++gv:V:VWWH:   65%@@@ro  c                 6   d}|                      |d|          \  }}|t          | j        dz   |z   dz             |                     |          }d|d         i}d}|                     |||          \  }}|rd	|d
<   nd|d
<   |||d<   d}	d}
|                     ||d          \  }
}|
/|
|d<   |                     |                     ||                    }	n)|                     |                     ||                    }	| 	                    |	|||          S )a  
 @ignore
        fetch all unfilled currently open orders for swap markets

        https://hashkeyglobal-apidoc.readme.io/reference/query-open-futures-orders
        https://hashkeyglobal-apidoc.readme.io/reference/get-sub-account-open-orders

        :param str symbol: *is mandatory* 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 - maximum 500
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.fromOrderId]: the id of the order to start from
        :param bool [params.trigger]: True for fetching trigger orders(default False)
        :param bool [params.stop]: an alternative for trigger param
        :param str [params.accountId]: account id to fetch the orders from
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        fetchOpenSwapOrdersr*  Nr   z4() requires a symbol argument for swap market ordersr  rE   Fr5  r  r$  rI  r  r"  )
r)  r,   rE   r  rM  r&  *privateGetApiV1FuturesSubAccountOpenOrdersr   privateGetApiV1FuturesOpenOrdersr?  )rl  r  r  rI  ru  r*  r  r  rP  rv  r  s              rn  rf  zhashkey.fetch_open_swap_ordersg  sT   $ +
!55flJWW
F>#DGcMJ$>Aw$wxxxV$$fTl
 	 AA&*V_``	6 	&$GFOO%GFO$GG	 99&*kZZ	6 &/GN#FFt{{SZ\bGcGcddHH<<T[[RX=Y=YZZHX   65%@@@ro  c                    d}|                      ||           |                                  i }|||d<   |||d<   d}|                     ||d          \  }}|||d<   d}|                     ||d          \  }}d}	||                     |          }	d}
|                     ||	||
          \  }
}d}|
dk    r>|	|	d	         |d
<   |||d<   |                     |                     ||                    }n|
dk    r|t          | j        dz   |z   dz             |	d	         |d
<   d}| 	                    |||          \  }}|rd|d<   nd|d<   |/||d<   | 
                    |                     ||                    }nM|                     |                     ||                    }n#t          | j        dz   |z   dz   |
z   dz             |                     ||	||          S )a  
        fetches information on multiple canceled and closed orders made by the user

        https://hashkeyglobal-apidoc.readme.io/reference/get-all-orders
        https://hashkeyglobal-apidoc.readme.io/reference/query-futures-history-orders
        https://hashkeyglobal-apidoc.readme.io/reference/get-sub-account-history-orders

        :param str symbol: *is mandatory for swap markets* 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 - default 500, maximum 1000
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for - only supports the last 90 days timeframe
        :param str [params.type]: 'spot' or 'swap' - the type of the market to fetch entries for(default 'spot')
        :param str [params.orderId]: *spot markets only* the id of the order to fetch
        :param str [params.side]: *spot markets only* 'buy' or 'sell' - the side of the orders to fetch
        :param str [params.fromOrderId]: *swap markets only* the id of the order to start from
        :param bool [params.trigger]: *swap markets only* the id of the order to start from True for fetching trigger orders(default False)
        :param bool [params.stop]: *swap markets only* the id of the order to start from an alternative for trigger param
        :param str [params.accountId]: account id to fetch the orders from
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        r{   NrI  r  r  r  r  rQ   rE   r  rS   r   r!  Fr5  r  r$  r"  r#  r$  )rK  r  r&  r  r%  privateGetApiV1SpotTradeOrdersr  r,   rE   rM  -privateGetApiV1FuturesSubAccountHistoryOrders#privateGetApiV1FuturesHistoryOrdersr8   r?  )rl  r  r  rI  ru  r*  r  r  r  r  r  rv  rP  s                rn   fetch_canceled_and_closed_ordersz(hashkey.fetch_canceled_and_closed_orders  s^   , 4
j&111$GG#(GK 55fj'RRv!&GI	 99&*kZZ	6[[((F
!??
FTZ\fgg
F!$*4L!$'0$::4;;wPV;W;WXXHH< 6!!~'#
(BEu(uvvv &tGHI $ E EfjZc d dIv *"(")$*3'MMdkkZaciNjNjkkCCDKKPWY_D`D`aa6 tw}z9<VVYccfxxyyy  65%@@@ro  c                     |                      |d          }|/|dk    r+|dk    r't          | j        dz   |z   dz   |z   dz             d S d S d S )Nr  rQ   rS   r   z() type parameter can not be "z". It should define the type of the market("spot" or "swap"). To define the type of an order use the trigger parameter(True for trigger orders))r  r-   rE   )rl  r*  ru  
paramsTypes       rn  rK  zhashkey.check_type_param7  s     %%ff55
"v)=)=JRXDXDXTWs]Z7:ZZ]gg  k|  |  }  }  } #")=)=DXDXro  ru  r*  c                 F    |}|                      ||dd|          \  }}||gS )NstoprM  )handle_option_and_params_2)rl  ru  r*  defaultValuerP  s        rn  rM  z(hashkey.handle_trigger_option_and_params?  s5     	 ;;FJPVXaclmm	66""ro  rD  c                    |                      |d          }|                     ||          }|                     |dd          }|                      |d          }|                      |d          }|                      |d          }|dk    rd}|                     |                      |d	                    }|d
k    r|d}nd}|                      |d          }	d }
|                     ||	          \  }}	}
|                     |                      |d                    }||}|                     |d          }d }|                     |          \  }}|                      |d          }|dk    r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%|          S )&Nr  transactTimer.  rz  r  r0  r"  r  r  r5  rI  r=  avgPricer/  feeCoinr  rE   rA  r%  rB  r  lastTradeTimestamplastUpdateTimestamp
updateTimery  r  origQtyfilledexecutedQty	remainingr7  r  cumulativeQuoteQtycummulativeQuoteQty	feeAmount)r;  r  )r;  r:  r  tradesr  r2  r.  r~  )r  rF  rE  r  ,parse_order_type_time_in_force_and_post_onlyrG   parse_order_side_and_reduce_onlyrU  rK  rs  parse_order_statusrJ  r  )rl  rD  r  r  r  rz  r  r0  r  r=  r.  ry  r/  r2  rO  s                  rn  r  zhashkey.parse_orderD  s   \ ##E844!!(F33''~vFF	!!%22v..$$UK88	  Dt//w??@@6>>}&&um<<&*&W&WX\^i&j&j#k8..!1!1%!D!DEE=E%%eV44
@@FFj''y992L  
$""5)44 
T--e_EE 
 Y// 
 	 

 !$ 
 "4#4#4UL#I#I 
 d--f55 
 fX& 
 D 
 ; 
 D 
 U 
 w 
 dnnT%5%5eY%G%GHH 
 d&&um<< 
  ! 
" DNN4+;+;E;+O+OPP# 
$  $!NN4#5#5e=QSh#i#ijj 33LAA..)9)9%)M)MNN  % 9 
  
  
: ;  	ro  c                     |                     d          }|d         }d }|                     |d          }||dk    rd}n|dk    rd}||gS )Nr0  r   r   rt  Frv  T)r  r  )rl  unparsedr  r/  r2  r  s         rn  r  z(hashkey.parse_order_side_and_reduce_only  si    s##Qx
%%eQ//
!V##"

''!
j!!ro  c           
      H    dddddddddd	}|                      |||          S )Nrt  canceledclosedrejected)	NEWPARTIALLY_FILLEDPARTIALLY_CANCELEDFILLEDCANCELEDORDER_CANCELEDPENDING_CANCELREJECTED	ORDER_NEWr  r  s      rn  r  zhashkey.parse_order_status  sC     &","(("

 

 &&999ro  c                 l    d }|dk    rd}n|dk    s|dk    rd}d}|                      |          }|||gS )Nr#  TMAKERr4  )parse_order_type)rl  r  r=  r.  s       rn  r  z4hashkey.parse_order_type_time_in_force_and_post_only  sX    =  HH]**w0F0FHK$$T**k8,,ro  c                 >    ddddd}|                      |||          S )Nr  rI  )r"  r$  r#  MARKET_OF_BASEr  r  s      rn  r  zhashkey.parse_order_type  s4    "&	
 
 tT222ro  c                 :   |                                   |                     |          }|d         |                                 d}|                     |                     ||                    }|                     |di           }|                     ||          S )ao  
        fetch the current funding rate

        https://hashkeyglobal-apidoc.readme.io/reference/get-futures-funding-rate

        :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>`
        rE   )r  r  r   )r  r  milliseconds publicGetApiV1FuturesFundingRater  r  parse_funding_rate)rl  r  ru  r  r  rv  rates          rn  fetch_funding_ratezhashkey.fetch_funding_rate  s     	V$$Tl**,,
 
 88Wf9U9UVV ~~h2..&&tV444ro  c                     |                                   |                     |          }d|                                 i}|                     |                     ||                    }|                     ||          S )a  
        fetch the funding rate for multiple markets

        https://hashkeyglobal-apidoc.readme.io/reference/get-futures-funding-rate

        :param str[]|None symbols: list of unified market symbols
        :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-rates-structure>`, indexed by market symbols
        r  )r  re  r  r  r  parse_funding_ratesr  s        rn  fetch_funding_rateszhashkey.fetch_funding_rates1  s|     	%%g..**,,
 88Wf9U9UVV ''':::ro  c                 Z   |                      |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 iS )Nr  rS   r  nextSettleTimer~  	markPrice
indexPriceinterestRateestimatedSettlePricer  rB  fundingRatefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimerU  )r  rF  r  rs  rK  )rl  r  r  r  r  r  s         rn  r  zhashkey.parse_funding_rateI  sT    ##Hh77!!(FD&AA&&x88,,X7GHH
H
fX&
 
 $	

 D
 #D
 
 
 ;
 
 t
 t
 #$4
 "4<<0@#A#A
 "4
  '!
" &t#
$ %
 
 	
ro  c           
         |                                   |t          | j        dz             |                     |          }d|d         i}|||d<   |                     |                     ||                    }g }t          dt          |                    D ]}	||	         }
|                     |
d          }|	                    |
| 
                    |                     |
d          |dd          |                     |
d	          ||                     |          d
           |                     |d          }|                     |||          S )a*  
        fetches historical funding rate prices

        https://hashkeyglobal-apidoc.readme.io/reference/get-futures-history-funding-rate

        :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.fromId]: the id of the entry to start from
        :param int [params.endId]: the id of the entry to end with
        :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/?id=funding-rate-history-structure>`
        Nz5 fetchFundingRateHistory() requires a symbol argumentr  rE   rI  r   
settleTimerS   
settleRate)r~  r  r  r  rB  r  )r  r,   rE   r  'publicGetApiV1FuturesHistoryFundingRater  r   r  rs  r<  safe_symbolr  r  rK  sort_byfilter_by_since_limit)rl  r  r  rI  ru  r  r  rv  ratesr  r  r  sorteds                rn  fetch_funding_rate_historyz"hashkey.fetch_funding_rate_historyj  sm    	>#DG.e$efffV$$fTl
 $GG??GU[@\@\]] q#h--(( 		 		AQKE))%>>ILL**4+;+;E8+L+LfVZ\bcc#//|DD& LL33      e[11))&%???ro  c                 4   d}|t          | j        dz   |z   dz             t          |          }|dk    rt          | j        dz   |z   dz             |                                  |                     |d         |                     ddi|                    S )	a3  
        fetch open positions for a market

        https://hashkeyglobal-apidoc.readme.io/reference/get-futures-positions

        fetch all open positions
        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.side]: 'LONG' or 'SHORT' - the direction of the position(if not provided, positions for both sides will be returned)
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/?id=position-structure>`
        r   Nr   z;() requires a symbol argument with one single market symbolr   zH() is supported for a symbol argument with one single market symbol onlyr   r*  )r,   rE   r  r8   r  fetch_positions_for_symbolr  )rl  r  ru  r*  symbolsLengths        rn  fetch_positionszhashkey.fetch_positions  s     &
O#DGcMJ$>A~$~LLM!!"47S=:#=  AK  $K  L  L  L..wqz4;;VfGgio;p;pqqqro  c                 j   |                                   |                     |          }d}|                     |d|          \  }}|d         st          | j        dz   |z   dz             d|d         i}|                     |                     ||                    }|                     ||g          S )a=  
        fetch open positions for a single market

        https://hashkeyglobal-apidoc.readme.io/reference/get-futures-positions

        fetch all open positions for specific symbol
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.side]: 'LONG' or 'SHORT' - the direction of the position(if not provided, positions for both sides will be returned)
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/?id=position-structure>`
        r   r*  rS   r   z() supports swap markets onlyr  rE   )r  r  r)  r8   rE   privateGetApiV1FuturesPositionsr  parse_positions)rl  r  ru  r  r*  r  rv  s          rn  r  z"hashkey.fetch_positions_for_symbol  s     	V$$$
!55flJWW
Ff~ 	]tw}z9<[[\\\fTl
 77GV8T8TUU, ##Hvh777ro  positionc                    |                      |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 |                     |d          d d d |                     |d          d d d |d          S )Nr  rE   r  rB  r  r  r  r/  notionalpositionValuer@  unrealizedPnlunrealizedPnLrealizedPnlrealizedPnL
collateral
entryPricer}  r  liquidationPricer6  crossr>  T	minMarginrR   	lastPrice)maintenanceMarginmaintenanceMarginPercentager  initialMarginPercentagemarginRatior  r  r:  r;  r  r~  )r  rF  safe_positionr  rG  rs  )rl  r  r  r  r  s        rn  parse_positionzhashkey.parse_position  s   ##Hh77!!(F33!!! #
f#
$#
 #
 	#

 ))(J??#
 D#
 D**8V<<#
 ((?CC#
 ))(J??#
 T--hHH#
 4++HmDD#
 $#
 $**8Z@@#
 #
  0 0;M N N#
  '!#
" d##
$ "&!1!1(K!H!H+/!--hAA'+#'))(K@@!#9#
 #
 #
   	ro  c                    |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |di           }|                     ||          S )ap  
        fetch the set leverage for a market

        https://hashkeyglobal-apidoc.readme.io/reference/query-futures-leverage-trade

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `leverage structure <https://docs.ccxt.com/?id=leverage-structure>`
        r  rE   r   )r  r  privateGetApiV1FuturesLeverager  r  parse_leverage)rl  r  ru  r  r  rv  r@  s          rn  fetch_leveragezhashkey.fetch_leverage  s     	V$$fTl
 66t{{7F7S7STT >>(Ar22""8V444ro  r@  c                 v    |                      |d          }|                     |d          }||d         |||dS )N
marginTyper@  r  )r~  r  r6  longLeverageshortLeverage)rG  r  )rl  r@  r  r6  leverageValues        rn  r  zhashkey.parse_leverage  sO    ++HlCC
((:>>X&$)*
 
 	
ro  c                 "   |t          | j        dz             |                                  d|i}|                     |          }|d         |d<   |                     |                     ||                    }|                     ||          S )a}  
        set the level of leverage for a market

        https://hashkeyglobal-apidoc.readme.io/reference/change-futures-leverage-trade

        :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@  rE   r  )r,   rE   r  r  privatePostApiV1FuturesLeverager  r  )rl  r@  r  ru  r  r  rv  s          rn  set_leveragezhashkey.set_leverage(  s     >#DG.Y$YZZZ
 V$$"4L77GV8T8TUU ""8V444ro  c                     |                                   |                     |          }|                     |dg           }|                     |          }|                     ||d          S )a  
        retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes

        https://hashkeyglobal-apidoc.readme.io/reference/exchangeinfo

        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/?id=leverage-tiers-structure>`, indexed by market symbols
        r  r  )r  r  r  re  parse_leverage_tiers)rl  r  ru  rv  datas        rn  fetch_leverage_tierszhashkey.fetch_leverage_tiersE  si     	226::~~hR88%%g..((wAAAro  c                 @   |                      |dg           }|                     |d          }|                     ||          }g }t          dt	          |                    D ]}||         }|                     |d          }|                    |                     |d          |                     ||          |d         d |                     |d          |                     |d          | 	                    t          j        d	|                    |d
           |S )Nr  r  r   r  r   r  r@  maintMarginr  )tierr  r;  minNotionalmaxNotionalmaintenanceMarginRater  r~  )r  r  rF  r   r  r<  sumr  r  rk  r@   r  )	rl  r~  r  r  r  r	  r  r  initialMarginRates	            rn  parse_market_leverage_tiersz#hashkey.parse_market_leverage_tiersV  s(   \ ^^D,;;
##D(33!!(F33q#j//** 	 	Aa=D $ 0 0 G GLLA**8V<<"8,##//jAA)-)9)9$)N)N#001CCIZ1[1[\\	 	 	 	 	 	 ro  c                    |                                   |                     |          }d}d}|d         r+|                     |          }|                     ||          S |d         rG|                     |                     d|d         i|                    }|                     ||          S t          | j        dz   |z   dz   |d	         z   d
z             )a  
        fetch the trading fees for a market

        https://developers.binance.com/docs/wallet/asset/trade-fee  # spot
        https://hashkeyglobal-apidoc.readme.io/reference/get-futures-commission-rate-request-weight  # swap

        :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>`
        r   NrQ   rS   r  rE   r   r#  r  r$  )	r  r  fetch_trading_feesr  $privateGetApiV1FuturesCommissionRater  parse_trading_feer8   rE   )rl  r  ru  r  r*  rv  s         rn  fetch_trading_feezhashkey.fetch_trading_fee  s     	V$$&
&> 	~..v66H>>(F333F^ 	~@@hX^_cXdMegmAnAnooH))(F;;; tw}z9<VVY_`fYggj||}}}ro  c                 8   |                                   |                     |          }|                     |dg           }i }t          dt	          |                    D ]9}|                     ||i           }|                     |          }|||d         <   :|S )ak  
        *for spot markets only* fetch the trading fees for multiple markets

        https://developers.binance.com/docs/wallet/asset/trade-fee

        :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
        r  r   r  )r  privateGetApiV1AccountVipInfor  r   r  r  r  )rl  ru  rv  r  r  r  r  	parsedFees           rn  r  zhashkey.fetch_trading_fees  s     	55f==. ~~h33q#d))$$ 	4 	4A..q"--C..s33I*3F9X&''ro  r  c                     |                      |d          }|                     ||          }||d         |                     |dd          |                     |dd          dddS )Nr  openMakerFeeactualMakerRateopenTakerFeeactualTakerRateT)r~  r  r  r  r  r  )r  rF  safe_number_2)rl  r  r  r  s       rn  r  zhashkey.parse_trading_fee   sz    , ##C22!!(F33X&''^=NOO''^=NOO
 
 	
ro  r   GETc                    | j         d         |         dz   |z   }d }|dk    r|                                  |                                 }	d|	i}
|                     | j        d          }|||
d<   | j        dd}d }|dk    r|d	k    s|d
k    rd|d<   |                     |                     |d                    }|                     | 	                    | 
                    |
                    | 	                    | j                  t          j                  }| 
                    |                     |
d|i                    }|d|z   z  }n|                     |
|          }|                     | 	                    | 
                    |                    | 	                    | j                  t          j                  }||d<   | 
                    |          }|dk    r	|d|z   z  }n|}|                     | j        dd          |d<   ||d<   n0|                     |          }t#          |          dk    r|d|z   z  }||||dS )Nr   r  r   r  r,  z!application/x-www-form-urlencoded)zX-HK-APIKEYContent-TypePOSTr   r   zapplication/jsonr  r:  	signature?r  r+  r  zINPUT-SOURCEbroker_signr   )r}  methodbodyheaders)r   check_required_credentialsr  rs  r
  apiKeyjsonr  hmacencodecustom_urlencodesecrethashlibsha256r  r  	urlencoder  )rl  pathr   r  ru  r  r  r}  queryr  additionalParamsr,  r	  totalParamss                 rn  signzhashkey.sign!  s{   is#c)D0)++---))++IY  **4<FFJ%1; .#{ C G "I&  0I(I(ItWsOsOs*<'yy!A!ABB IIdkk$2G2GHX2Y2Y&Z&Z\`\g\ghlhs\t\tv}  wE  F  F	--dkk:J[ZcLd.e.effsU{""kk*:FCC IIdkk$2G2G2T2T&U&UW[WbWbcgcnWoWoqxq  A  A	+4K(--k::U??3;&CC D&*&6&6t|X}&]&]GN#%.GM""NN6**E5zzQsU{"fdwOOOro  c                 \    |                      |          }|                    dd          }|S )Nz%2CrY  )r  replace)rl  ru  r  s      rn  r  zhashkey.custom_urlencodeI  s+    ''s++ro  c
                 L   |d S d}
|                      |dd           }|                     |dd           }|dk    r|                     |dg           }t          dt	          |                    D ]L}|                     ||          }|                     |d          }|dk    rd}
|                      |d          }M|dk    s|
r`| j        dz   |z   }|                     | j        d         ||           | 	                    | j        d	         ||           t          |          d S )
NFr  r   r  T   r   rf  re  )r  rs  r  r   r  r  rE   throw_broadly_matched_exceptionrU  throw_exactly_matched_exceptionr'   )rl  r  reasonr}  r  r  r  rv  requestHeadersrequestBodyerrorInArrayresponseCodeStringresponseCodeIntegerr  r  r  entryCodeIntegerfeedbacks                     rn  handle_errorszhashkey.handle_errorsN  sE   4!--hEE"//&$GG!##^^Hh;;F1c&kk** I Ivq11#'#4#4UF#C#C #q((#'L)-)9)9%)H)H&CKKLKw}t+H001IK]_ghhh001IK]_ghhh)))tro  )N)y__name__
__module____qualname__r   rj  r   rw  r  r&   r   r  dictr  r	   r  strr   r  r!   r  r   r+  rQ  listrY  r^  r   rc  r   r   rg  ra  r   r  r   r  r   r  r  r  r   r  r
   r  r$   r  r  floatr   r  r  r%   r   r  r   r  r  r  r  r  r   r  r  r  r   r   r   r   r  r  r  r   r  r  r  r   rI  rQ  rV  r^  rc  rg  re  rf  rt  rK  objectrM  r  r  r  r  r  r   r  r    r  r  r  r   r  r  r  r   r  r  intr  r   r  r   r  r"   r  r#   r  r  r  r  r,  __classcell__)rm  s   @rn  rB   rB   '   sh       d	# d	 d	 d	 d	 d	 d	L !# 9 9s 9 9 9 9" #% 
 
 
 
* $& @+ @+$v, @+ @+ @+ @+DE4 EF E E E EN ') ^ ^Z ^ ^ ^ ^@ :>b #L #Ls #L3 #LY #L #L #L #LJ 6:UW A A3 As A# A\`af\g A A A AB -1tRV_a hA hAc hA hAC hA hA hA hATb b bv b b b b bH 9=4^bkm 4L 4L# 4L# 4LS 4LX[ 4Lrvw{r| 4L 4L 4L 4Ll
 
 
4 
 
 
 
. 02 !1 !13 !1f !1 !1 !1 !1F 04B 5 5W 57 5 5 5 5) )6 )V ) ) ) )V 48 9 9 9z 9 9 9 94

 

f 

	 

 

 

 

 $& 4z 4z( 4z 4z 4z 4zl) ) ) ) )@)X ) ) ) )0 79 $ $# $^ $ $ $ $L
 
h 
R` 
 
 
 
4 *.Dt\^ ,^ ,^3 ,^c ,^ ,^cghsct ,^ ,^ ,^ ,^\ -1tRV_a 2a 2ac 2a 2aC 2afjkvfw 2a 2a 2a 2ah KOWY ': ':S ':% ':# ':C ':^i ': ': ': ':RU
 U
x U
; U
 U
 U
 U
n: : :" []  7  7S  7%  7c  7c  7an  7  7  7  7D
 
 
 
 
 
& %' 5 54= 5 5 5 50
 
 
 3 3 34 4 44 4 4 (,$TZ\ 8C 8C 8CC 8Cs 8Caefqar 8C 8C 8C 8Ct3 3 30 0t 0x 0; 0 0 0 0d gksu w w3 wi wy wRW w`c wz w w w w> RT ` ` `5 `X] ` ` ` `" lpxz t2 t2 t29 t2I t2W\ t2eh t2  @E t2 t2 t2 t2l os{} C C3 Ci Cy CZ_ Chk C  CG C C C C tx  AC (, (, (,9 (,I (,_d (,mp (,  HL (, (, (, (,T tx  AC 3, 3, 3,9 3,I 3,_d 3,mp 3,  HL 3, 3, 3, 3,j lpxz ,2 ,2 ,29 ,2I ,2W\ ,2eh ,2  @E ,2 ,2 ,2 ,2\ @B k1 k1D$6 k1 k1 k1 k1Z 37r R* R*s R*C R* R* R* R*h /32 ' ' ' ' ' 'R ;?r & &c &C & & & &P 26b _* _*c _*3 _*U _* _* _* _*B /3TXac $z $z $z3 $zc $zhlmrhs $z $z $z $zL 48dY]fh ?A ?AS ?A ?ASV ?Amqrwmx ?A ?A ?A ?AB 48dY]fh UA UAS UA UASV UAmqrwmx UA UA UA UAn >BPTcgpr wA wAs wA# wA]` wAw{  }B  xC wA wA wA wAr} } }# #v #3 # # # #
e e ev e e e e eN
" 
" 
": : :- - -3 3 3 68 5 5 5K 5 5 5 52 6:" ; ;7 ; ; ; ; ;0
 
6 
[ 
 
 
 
B 8<$]ajl /@ /@ /@C /@WZ /@ /@ /@ /@b 26b r rw rT(^ r r r r, >@ +8 +8 +8DN +8 +8 +8 +8Z! !t !V ! ! ! !F 24 5 5S 5 5 5 5 58	
 	
t 	
V 	
x 	
 	
 	
 	
 9=R 5 5S 5# 5 5 5 5: 7;2 B BG B- B B B B"_ _ _$|J\ _ _ _ _B 57 ~ ~ ~;N ~ ~ ~ ~@ )+ ' '{ ' ' ' 'R
 
T 
6 
EX 
 
 
 
B &eBSW &P &P &P &PP /1  t S    
      ro  rB   )Gccxt.base.exchanger   ccxt.abstract.hashkeyr   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!   r"   r#   r$   r%   typingr&   ccxt.base.errorsr'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   ccxt.base.decimal_to_precisionr?   ccxt.base.preciser@   rB    ro  rn  <module>r?     s   ( ' ' ' ' ' - - - - - -  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {  {       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . . . . . . . + + + + + + ) ) ) ) ) ) * * * * * * 5 5 5 5 5 5 - - - - - - - - - - - - 0 0 0 0 0 0 ) ) ) ) ) ) , , , , , , + + + + + + . . . . . . 1 1 1 1 1 1 ) ) ) ) ) ) + + + + + + 4 4 4 4 4 4 % % % % % %z@ z@ z@ z@ z@h z@ z@ z@ z@ z@ro  