
    E#iJ                       S SK Jr  S SKJr  S SKrS SKJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&  S SK'J(r(  S SK)J*r*  S SK)J+r+  S SK)J,r,  S S	K)J-r-  S S
K)J.r.  S SK)J/r/  S SK)J0r0  S SK)J1r1  S SK)J2r2  S SK)J3r3  S SK)J4r4  S SK)J5r5  S SK)J6r6  S SK)J7r7  S SK)J8r8  S SK)J9r9  S SK)J:r:  S SK)J;r;  S SK)J<r<  S SK)J=r=  S SK)J>r>  S SK)J?r?  S SK)J@r@  S SK)JArA  S SKBJCrC  S SKDJErE   " S  S!\\5      rFg)"    )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                     ^  \ rS rSrS\4U 4S jjr0 4S\4S jjr0 4S jr0 4S\	\
   4S jjrS\S\
4S jr0 4S\4S	 jjrS
0 4S\S\S\4S jjrS
S
0 4S\S\S\S\	\   4S jjrS
S
S
0 4S\S\S\4S jjrSrS\S\
S\4S jjrSS
S
0 4S\S\S\S\S\	\   4
S jjrSrS\
S\4S jjr0 4S\S\4S jjrS
0 4S\S\4S jjrSrS\
S\4S jjr S
0 4S\S\!4S jjr"SrS\
S\#4S jjr$0 4S\%4S jjr&S\%4S jr'S\%4S jr(0 4S \S\)4S! jjr*SrS"\+S\)4S# jjr,S
S
S
0 4S \S\S\S\	\-   4S$ jjr.S
S
S
0 4S \S\S\S\	\-   4S% jjr/S
0 4S \S&\0S'\S(\S\-4
S) jjr1SrS"\+S\-4S* jjr2S+ r30 4S \S&\0S,\S-\S\44
S. jjr5SrS"\+4S/ jjr60 4S\	\7   4S0 jjr8S1 r9S2 r:S3 r;S4 r<S
S
S
0 4S \S\S\S\	\=   4S5 jjr>S6 r?SrS7\S"\+S\=4S8 jjr@S
0 4S\S9\AS:\BS&\0S;\CS\D4S< jjrE0 4S\S=\0S\D4S> jjrFS
0 4S\S9\AS:\BS&\0S;\CS\D4S? jjrGS
0 4S\S9\AS:\BS&\0S;\CS\4S@ jjrHS
0 4S\S9\AS:\BS&\0S;\CS\4SA jjrIS
0 4S\S9\AS:\BS&\0S;\CS\4SB jjrJS
0 4S\S9\AS:\BS&\0S;\CS\D4SC jjrK0 4SD\	\L   4SE jjrMS
0 4SF\S\4SG jjrNS
0 4S\4SH jjrOS
0 4SI\	\   S\4SJ jjrPS
0 4SF\S\S\D4SK jjrQS
S
S
0 4S\S\S\S\	\D   4SL jjrRS
S
S
0 4S\S\S\S\	\D   4SM jjrSS
S
S
0 4S\S\S\S\	\D   4SN jjrTS
S
S
0 4S\S\S\S\	\D   4SO jjrUSP rVSrSQ\WSR\4SS jjrXSrST\S\
S\D4SU jjrYSV rZSW r[SX r\SY r]0 4S\S\^4SZ jjr_S
0 4S\S\`4S[ jjraSrS\
S\^4S\ jjrbS
S
S
0 4S\S\S\4S] jjrcS
0 4S\S\	\d   4S^ jjre0 4S\S\	\d   4S_ jjrfSrS`\S\
4Sa jjrg0 4S\S\h4Sb jjriSrSc\S\
S\h4Sd jjrjS
0 4Sc\kS\4Se jjrlS
0 4S\S\m4Sf jjrnSrS\
S\	\o   4Sg jjrp0 4S\S\q4Sh jjrr0 4S\s4Si jjrtSrSj\S\
S\q4Sk jjruSlSm0 S
S
4Sn jrv0 4SQ\S\4So jjrwSp rxSqryU =rz$ )shashkey'   returnc                   > U R                  [        [        U ]  5       0 SS_SS_SS/_SS_S	S
_SS_SS_S0 SS _SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S S_0 S!S_S"S_S#S_S$S_S%S_S&S_S'S_S(S_S)S_S*S_S+S_S,S_S-S_S.S_S/S_S0S_S1S_E0 S2S_S3S_S4S_S5S_S6S_S7S_S8S_S9S_S:S_S;S_S<S_S=S_S>S_S?S_S@S_SAS_SBS_E0 SCS_SDS_SES_SFS_SGS_SHS_SIS_SJS_SKS_SLS_SMS_SNS_SOS_SPS_SQS_SRS_SSS_E0 STS_SUS_SVS_SWS_SXS_SYS_SZS_S[S_S\S_S]S_S^S_S_S_S`Sa_SbS_ScS_SdS_SeS_E0 SfS_SgS_ShS_SiS_SjS_SkS_SlS_SmS_SnS_SoS_SpS_SqS_SrS_SsS_StS_SuS_SvS_E0 SwS_SxS_SyS_SzS_S{S_S|S_S}S_S~S_SS_SS_SS_SS_SS_SS_SS_SS_SS_ESSSSSSSSSSSSS.E_SSSSSSSSSSSSSSSS._SSSSS.SSS.SSSSS._SSSSSSSSSSSSSSSSS.00 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSSSSS.ESSSSSSSSSSSSS.SS0SSSSSSSS.S.S._SSSSSU R	                  S5      U R	                  S5      U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //S.S.SSSU R	                  S5      U R	                  S5      U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      /U R	                  S5      U R	                  S5      //S.S.S.0_SSS S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_GS GS_0 SS_GSS_SS_SS_SS_GSS_SS_SS_SS_SS_SS_SS_SS_GSS_SS_GSGS _SS_SSSGSSGS.ESGS._GSSSSS SSSS SSSSGS	.SSSSSSSGS
.GSGS0SGSGSGSSGS.SSSSGS.SGSSSSGS.S S GSGS0GS.	GSGS0GSSSGS.SGSGS.GS.GSGS0S GS.S S GS.GS._GS0 _GS0 GS[
        _GS [        _GS![        _GS"[        _GS#[        _GS$[        _GS%[        _GS&[        _GS'[
        _GS([
        _GS)[
        _GS*[
        _GS+[        _GS,[        _GS-[
        _GS.[        _GS/[        _0 GS0[        _GS1[        _GS2[        _GS3[
        _GS4[        _GS5[        _GS6[        _GS7[        _GS8[        _GS9[        _GS:[         _GS;[
        _GS<["        _GS=[        _GS>[        _GS?[        _GS@[        _E0 GSA[        _GSB[
        _GSC[
        _GSD[
        _GSE[
        _GSF[
        _GSG[
        _GSH[        _GSI[        _GSJ[$        _GSK[        _GSL[&        _GSM[(        _GSN[        _GSO[        _GSP[*        _GSQ[        _E0 GSR[        _GSS[        _GST[        _GSU[,        _GSV[        _GSW[.        _GSX[        _GSY[        _GSZ[        _GS[[,        _GS\[,        _GS][,        _GS^[.        _GS_[.        _GS`[,        _GSa[0        _GSb[2        _E0 GSc[,        _GSd[4        _GSe[        _GSf[
        _GSg[
        _GSh[        _GSi[        _GSj[        _GSk[
        _GSl[
        _GSm[        _GSn[
        _GSo[
        _GSp[        _GSq[.        _GSr[6        _GSs[        _E0 GSt[        _GSu[        _GSv[
        _GSw[
        _GSx[
        _GSy[
        _GSz[
        _GS{[
        _GS|[
        _GS}[.        _GS~[
        _GS[
        _GS[
        _GS[
        _GS["        _GS[,        _GS[,        _E0 GS[,        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[.        _GS[.        _GS[
        _GS[        _GS[        _E0 GS[        _GS[        _GS[*        _GS[        _GS[,        _GS[        _GS[        _GS[*        _GS[        _GS[        _GS[*        _GS["        _GS[
        _GS[        _GS[        _GS[
        _GS[
        _E0 GS[
        _GS[
        _GS[
        _GS[
        _GS[        _GS[        _GS[        _GS[
        _GS[
        _GS[
        _GS[
        _GS[        _GS[        _GS[        _GS[8        _GS[
        _GS[
        _E[        [
        [
        [.        [*        [.        [        [        [        [        [,        GS.E0 GS._GS[:        _5      $ (  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)rR   rT   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        )r7  limitdaysBack	untilDayssymbolRequired)r7  triggerr@  rM  )r7  rJ  rN  r@  rM  rJ  )	r   rh   createOrdersr   r   r   r   r   r   extendsdefault)r8  rD  i  )rN  rJ  )rP  rh   r   forDerivatives)linearinverse)rQ  rR   rR  rT   rU   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    T/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/hashkey.pyrk  hashkey.describe)   sD   gt = ? 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$ %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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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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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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p +0$( %$)', #"!&#(  G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Yc	B
v %)&*#(!%!2!28!<!%!2!28!< "&!2!23!79J9J89T U!%!2!29!=t?P?PQZ?[ \!%!2!29!=t?P?PQZ?[ \!%!2!2:!>@Q@QR[@\ ]!%!2!2:!>@Q@QR[@\ ]!%!2!2;!?ARARS\A] ^!%!2!2;!?ARARS\A] ^!%!2!2;!?ARARSYAZ [	& "&!2!23!79J9J89T U!%!2!29!=t?P?PQZ?[ \!%!2!29!=t?P?PQZ?[ \!%!2!2:!>@Q@QR[@\ ]!%!2!2:!>@Q@QR[@\ ]!%!2!2;!?ARARS\A] ^!%!2!2;!?ARARS\A] ^!%!2!2;!?ARARS\A] ^	&"< &*&*#(!%!2!29!=!%!2!29!= "&!2!23!79J9J99U V!%!2!29!=t?P?PQZ?[ \!%!2!29!=t?P?PQZ?[ \!%!2!2:!>@Q@QR[@\ ]!%!2!2:!>@Q@QR\@] ^!%!2!2;!?ARARS]A^ _!%!2!2;!?ARARS]A^ _!%!2!2;!?ARARSYAZ [	& "&!2!23!79J9J99U V!%!2!29!=t?P?PQZ?[ \!%!2!29!=t?P?PQZ?[ \!%!2!2:!>@Q@QR[@\ ]!%!2!2:!>@Q@QR[@\ ]!%!2!2;!?ARARS\A] ^!%!2!2;!?ARARS\A] ^!%!2!2;!?ARARS\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l y  )(,/3$
 $(!$(
# "#3  $	 ##U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$ 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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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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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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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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t /''.).--**,IeL Ohsc	B
D YEc	B
 c	 c		    c                 d   #    U R                  U5      I Sh  vN nU R                  US5      $  N7f)a7  
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
N
serverTime)publicGetApiV1Timesafe_integerrm  paramsresponses      ro  
fetch_timehashkey.fetch_time  s4      0088   <88 9s   0.0c                 P   #    U R                  U5      I Sh  vN nSSSSUS.$  N7f)a4  
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>`
Nok)statusupdatedetaurlinfo)publicGetApiV1Pingrv  s      ro  fetch_statushashkey.fetch_status  s:      0088
 
 	
	 9s   &$&c                 $  #    0 nU R                  U R                  X!5      5      I Sh  vN nU R                  US/ 5      nU R                  US/ 5      nU R                  XE5      nU R	                  U5      (       a  U/nU R                  U5      $  Ne7f)a5  
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
Nsymbols	contracts)publicGetApiV1ExchangeInfoextend	safe_listarray_concatis_emptyparse_markets)rm  rw  requestrx  spotMarketsswapMarketsmarketss          ro  fetch_marketshashkey.fetch_markets  s      88W9UVV` nnXy"=nnX{B?##K===!!jG!!'**k Ws   &BBA&Bmarketc                 l	   U R                  US5      nU R                  US5      nU R                  U5      nU R                  US5      nU R                  U5      nU R                  US5      nSnSn	Sn
SnUR                  S	5      nU R                  US
5      nUS:X  a   SnSn	Sn
U R                  US5      nUSU-   -  nU R                  U5      nUS-   U-   U-   nU R                  US5      nUS:H  nS nS nU R                  US5      nUb  U(       a  SnSnOSnSnU R	                  US/ 5      nU R                  US5      nU R                  US0 5      nU R                  US0 5      nU R                  US0 5      nU R                  U R                  US5      5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nS nS n U
(       Ga  [        R                  " UU5      n[        R                  " UU5      n[        R                  " UU5      nU R	                  US5      n!U!b  U R                  U!S5      n"[        U!5      n#U R                  U!U#S
-
  5      n$U R                  U"S 5      n%U R                  U$S 5      n&[        R                  " U%U&5      (       a  U&U%/u  n%n&U R                  [        R                  " S!U&5      5      nU R                  [        R                  " S!U%5      5      n U R                  U R                  S"5      n'U	(       a  U R                  U'S5      OU R                  U'S5      n(U R                  0 S#U_SU_S$U_S%U_S&U_S'U_S(U_S)U_S*U_SU	_S+U R                  US,5      _SU
_S-S_S.S_S/U
_S0U_S1U_0 S2U R                  U5      _SU_SU_S3U R!                  U(S35      _S4U R!                  U(S45      _S5U R                  U(S55      _S6U R                  U(S65      _S7U R                  U(S75      _S8S _S9S _S:S _S;S _S<U R                  U5      U R!                  US=5      S>._S?U R                  U5      U R                  U5      S@.U R!                  USA5      U R!                  USB5      S@.UU S@.U R                  U5      S S@.SC._SDS _SEU_E5      $ )FNsymbol
quoteAssetmarginToken	baseAssetrR   TF -r   	PERPETUALrT   
underlying:/r}  TRADINGrT  rS  filters
filterTypePRICE_FILTERLOT_SIZEMIN_NOTIONALmin_notionalcontractMultiplierstepSizeminQtymaxQty
riskLimitsr   initialMargin1r   rF   basequotebaseIdquoteIdactivetypesubTyperS   allowMarginrU   rV   contractsettlesettleIdcontractSizer  r  r  r  r	  expiryexpiryDatetimestrike
optionType	precisiontickSize)amountpricelimitsminrF  minPricemaxPrice)r  r  rA  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_structurerl  safe_number))rm  r  marketIdr  r  r  r  r  
marketTypeisSpotisSwapsuffixparts
secondPartr  r  r}  r  isLinearr  	isInversefiltersListr  priceFilteramountFilter
costFilterminCostStringcontractSizeStringamountPrecisionStringamountMinLimitStringamountMaxLimitStringminLeveragemaxLeverager  firstarrayLengthlastminInitialMarginmaxInitialMargintradingFeesr   s)                                            ro  parse_markethashkey.parse_marketw  s   d ##FH5""6<8''0##FM:((2!!&+6
s#%%eQ/
$JFF%%fl;FcHn$F&&v.e#f,!!&(39$NN695	  #"nnVY;--\:nnWnbA~~gz2>^^G^R@
t'7'7
N'ST!--f6JK $ 0 0z J#//hG#//hG$+$6$67LN`$a!#*#5#56JL^#_ #*#5#56JL^#_ =J%z15!*o~~j+/B#'#3#3E?#K #'#3#3D/#J $$%57GHH:JL\9]6$&6"//0B0B3HX0YZ"//0B0B3HX0YZnnTYY	:6<t~~k62$..Q\^dBe)) 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+
$ D--.@A%6+
& h'6+
( y)6+
* T%%dG4+6+
, T%%dG4-6+
. $..|</6+
0 k:16+
2 t''i836+
4 d56+
6 d76+
8 d96+
: $;6+
< ++,AB))+zB=6+
D ,,-AB,,-AB
  ++KD++KD
 '&
  ,,];E6+
h ti6+
j Fk6+
 6 6	rq  c                   #    U R                  U5      I Sh  vN nU R                  US5      n0 n[        S[        U5      5       GH  nX5   nU R	                  US5      nU R                  U5      nU R                  US5      n	0 n
[        S[        U	5      5       H  nX   nU R	                  US5      nU R                  U5      nUUU R                  US5      U R                  U R                  U R	                  US5      5      5      S	.U R                  US
5      SS	.S.SU R                  US5      U R                  US5      U R                  US5      SUS.	X'   M     U R	                  US5      nUS:X  a  SOSnU R                  UUSUU R	                  US5      SU R                  US5      U R                  US5      SSSS	.SSS	.S.U
US.5      XH'   GM     U$  GN7f)z
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
Ncoinsr   coinId
chainTypes	chainTypeminWithdrawQuantitymaxWithdrawQuantityr  minDepositQuantity)r   depositallowDepositallowWithdrawwithdrawFee)	rF   networkr  r  r  r   feer  r  	tokenType
REAL_MONEYfiatcryptocoinFullName)r  r   )rF   coder  r  rG   r  r  r   r  r  r/  r  )r  r  ranger  r  r  network_code_to_idr  rl  r  r  safe_currency_structure)rm  rw  rx  r  resulticurrecy
currencyIdr  r/  parsedNetworksjr  	networkIdnetworkCoderawTyper  s                    ro  fetch_currencieshashkey.fetch_currencies~  s     88@@x18 q#e*%AhG))'8<J**:6D~~g|<H#%N1c(m,"+ ,,WkB	"55i@#* $(#3#3G=R#S#'#4#4T^^DDTDTU\^sDt5u#v%
 $(#3#3G=Q#R#'$	 ##~~g~F $w H++G]C!%#%/+	 -0 &&w<G%56HD77 !((.A>>'>B NN7OD  $# 
  $#!	 ++9 FLA &n k As   GGGGNr  rJ  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X%S'   U R                  U R                  XS5      5      I Sh  vN nU R	                  US5      nU R                  XaUSS5      $  Nq N,7f)a  
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
Nr  rF   rJ  tba)load_marketsr  publicGetQuoteV1Depthr  ru  parse_order_book)rm  r  rJ  rw  r  r  rx  	timestamps           ro  fetch_order_bookhashkey.fetch_order_book  s      !!!V$fTl
 $G33DKK4PQQ  %%h4	$$Xy#sKK1 	" Rs"   BBABB
+B
Bsincec                    #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X6S'   U R                  U R                  Xd5      5      I Sh  vN nU R	                  XuX#5      $  N] N7f)a  
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>`
Nr  rF   rJ  )r  r  publicGetQuoteV1Tradesr  parse_trades)rm  r  r  rJ  rw  r  r  rx  s           ro  fetch_tradeshashkey.fetch_trades  s      !!!V$fTl
 $G44T[[5QRR   5@@' 	" Ss"   A8A4AA8A6A86A8c                 0  #    SnU R                  5       I Sh  vN   0 nSnUb  U R                  U5      nSnU R                  XWU5      u  pUb  X&S'   Ub  X6S'   Sn	U R                  XES5      u  pU	b  XS'   Sn
U R                  XES5      u  pSnUS:X  a;  Ub  US	   US
'   U
b  XS'   U R	                  U R                  Xd5      5      I Sh  vN nOUS:X  a  Uc  [        U R                  S-   U-   S-   5      eUS	   US
'   U
b-  XS'   U R                  U R                  Xd5      5      I Sh  vN nOMU R                  U R                  Xd5      5      I Sh  vN nO$[        U R                  S-   U-   S-   U-   S-   5      eU R                  XX#5      $  GNu N Ni NB7f)aK  
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   NrR   	startTimerJ  untilendTime	accountIdrF   r  rT    .() 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,   rF   *privateGetApiV1FuturesSubAccountUserTrades privateGetApiV1FuturesUserTradesr8   r!  )rm  r  r  rJ  rw  
methodNamer  r  r  r&  r(  rx  s               ro  fetch_my_tradeshashkey.fetch_my_trades$  s    ( %
!!![[(F
!??
TZ[
#(K $G55f'R!&I	 99&kZ	!$*4L!$'0$!>>t{{7?[\\H< 6!~'#
(BEu(uvv &tGH$*3'!%!P!PQUQ\Q\]dQm!nn!%!F!Ft{{SZGc!dd* tww}z9<VVYccfxxyy  5@@g 	". ]H odsG   FFB0F	F
AF(F)(FF<FFFFtradec                    U R                  USS5      nU R                  US5      nU R                  XB5      nU R                  US5      nUb!  U R                  UR	                  S5      S5      nU R                  US5      nUb  U(       a  SOS	nS nU R                  US
S/5      nUb  U(       a  SOSnU R                  US5      n	U	b  SnU	(       a  S	OSnU R                  US5      n
U R                  US5      nU R                  US5      nS nUb$  U R                  US5      n
U R                  US5      nU
b#  U R                  U
5      U R                  U5      S.nU R                  U R                  USS5      UU R                  U5      US   UU R                  USS5      U R                  U/ SQ5      S US U R                  US5      UUS.U5      $ )Nr  timer  side_r   isBuyerbuysellisMakerisMarkerr  r  ibm
commissioncommissionAssetr  	feeCoinIdr  currencyrF   tradeIdpr  )qqtyquantityorderId)rF   r  datetimer  r9  r  r  r  takerOrMakerr  orderr  r  )safe_integer_2r  safe_marketsafe_string_lowerr  r  safe_bool_nr  rl  r  
safe_tradesafe_string_2iso8601safe_string_n)rm  r6  r  r  r  r9  r;  rM  r>  isBuyerMakerfeeCostfeeCurrncyIdfeeInfor  s                 ro  parse_tradehashkey.parse_trade  s   l ''sF;	##E84!!(3%%eV4##DJJsOQ7D..	2#5D""59j*AB&-77L~~eU3#"L)6uD""5,7''/@A...&&w6G++G[AL))'2 33LAC $$UD)<"Y/X&''sG<((0HI(%%eY7 
  	rq  r   	timeframec           	        #    SnU R                  5       I Sh  vN   SnU R                  XVS5      u  puU(       a  U R                  SXXBUS5      I Sh  vN $ U R                  U5      nU R	                  U R
                  X"5      nUS   US.n	Ub  X9S'   Ub  XIS	'   Sn
U R                  XVS
5      u  pU
b  XS'   U R                  U R                  X5      5      I Sh  vN nU R                  XX#U5      $  N N N7f)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   NFpaginaterH  rF   )r  intervalr%  rJ  r&  r'  )	r  r/  "fetch_paginated_call_deterministicr  r  r   publicGetQuoteV1Klinesr  parse_ohlcvs)rm  r  r]  r  rJ  rw  r3  r_  r  r  r&  rx  s               ro  fetch_ohlcvhashkey.fetch_ohlcv  s     "
!!!88ZX@@v^cpvx|}}}V$$$T__iK	Tl!
 #(K $G55f'R!&I44T[[5QRR"   9UKKI 	" ~ Ss4   C8C29C8C4BC8C6C84C86C8c           	          U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )Nr   r      r      r   )ru  r  )rm  ohlcvr  s      ro  parse_ohlcvhashkey.parse_ohlcv(  sn     eQ'UA&UA&UA&UA&UA&
 	
rq  c                 
  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R                  Xc5      $  Nh N*7f)a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://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>`
Nr  rF   r   )r  r  publicGetQuoteV1Ticker24hrr  r  parse_ticker)rm  r  rw  r  r  rx  tickers          ro  fetch_tickerhashkey.fetch_ticker?  s      !!!V$fTl
 88W9UVV" !R0  00/ 	"
 W!   BA??BB)BBr  c                    #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      I Sh  vN nU R                  X15      $  N? N7f)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>`
N)r  market_symbolsrm  parse_tickers)rm  r  rw  rx  s       ro  fetch_tickershashkey.fetch_tickersb  sU      !!!%%g.88@@!!(44 	"@s!   AA)A AAAc                 .   U R                  US5      nU R                  US5      nU R                  XB5      nUS   nU R                  US5      nU R                  0 SU_SU_SU R	                  U5      _SU R                  US5      _S	U R                  US
5      _SU R                  US5      _SS _SU R                  US5      _SS _SS _SU R                  US5      _SU_SU_SS _SS _SS _SS _U R                  US5      U R                  US5      US.EU5      $ )Nr  sr  cr  rL  highhlowlbidr  	bidVolumeaskr  	askVolumevwapopenocloser  previousClosechanger  averagevqv)
baseVolumequoteVolumer  )ru  r  rP  safe_tickerrU  )rm  ro  r  r  r  r  r  s          ro  rn  hashkey.parse_tickerq  s    %%fc2	##FC0!!(3!, !
f!
!
 Y/!
 D$$VS1	!

 4##FC0!
 4##FC0!
 !
 4##FC0!
 !
 D!
 D$$VS1!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **637++FD9)!
* + 	rq  c                    #    U R                  5       I Sh  vN   U R                  U5      n0 nU R                  U R                  X25      5      I Sh  vN nU R	                  XA5      $  NP N7f)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
N)r  rt  publicGetQuoteV1TickerPricer  parse_last_pricesrm  r  rw  r  rx  s        ro  fetch_last_priceshashkey.fetch_last_prices  sh      !!!%%g.99$++g:VWW %%h88 	" Xs!   A+A':A+A)A+)A+c                     U R                  US5      nU R                  X25      nUS   S S U R                  US5      S US.$ )Nry  r  rG  )r  r  rL  r  r9  r  )r  rP  r  )rm  entryr  r  s       ro  parse_last_pricehashkey.parse_last_price  sR    ##E3/!!(3X&%%eS1
 	
rq  c                   #    U R                  5       I Sh  vN   0 nSnSnU R                  USX5      u  pAUS:X  a=  U R                  U5      I Sh  vN nU R                  US0 5      nU R	                  U5      $ US:X  a9  U R                  U R                  X!5      5      I Sh  vN nU R                  U5      $ [        U R                  S-   U-   S-   U-   S-   5      e N N N=7f)	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>`
Nru   rR   rT   r   r)  r,  r-  )
r  r.  privateGetApiV1FuturesBalancer  parse_swap_balanceprivateGetApiV1Accountr  parse_balancer8   rF   )rm  rw  r  r3  r  rx  balances          ro  fetch_balancehashkey.fetch_balance  s      !!!#

!??
DRXe
!??GGH nnXq"5G**7336!!88W9UVVH" %%h//tww}z9<VVYccfxxyyS 	" H  Ws4   C"C9C"CAC""C #:C"C" C"c                 ~   SU0nU R                  US/ 5      n[        S[        U5      5       H}  nX4   nU R                  US5      nU R	                  U5      nU R                  5       nU R                  US5      US'   U R                  US5      US'   U R                  US5      US'   XU'   M     U R                  U5      $ )	Nr  balancesr   assettotalfreelockedused)r  r  r  r  r  accountsafe_balance)	rm  r  r	  r  r
  balanceEntryr  r  r  s	            ro  r  hashkey.parse_balance  s    $ G
 >>':r:q#h-(A#;L)),@J**:6DllnG#//gFGG"..|VDGFO"..|XFGFO"4L )   ((rq  c                 >   U R                  US5      nU R                  U5      nU R                  5       nU R                  US5      US'   U R                  US5      nU R                  US5      n[        R                  " XV5      US'   SU0nXGU'   U R                  U5      $ )Nr  r  r  positionMarginorderMarginr  r  )r  r  r  r@   
string_addr  )rm  r  r  r  r  r  r  r	  s           ro  r  hashkey.parse_swap_balance  s     %%gw7
&&z2,,.++GY?))'3CD&&w>!,,^IG
 t  ((rq  r  c                 j  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnU R                  U5      u  pRUc  U R                  U5      nU R	                  XQ5      US'   U R                  U R                  XB5      5      I Sh  vN nU R                  Xc5      nXWS'   U$  N N7f)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>`
NcoinrF   r  r  )r  rE  handle_network_code_and_paramsdefault_network_coder  $privateGetApiV1AccountDepositAddressr  parse_deposit_address)rm  r  rw  rE  r  r  rx  depositAddresss           ro  fetch_deposit_addresshashkey.fetch_deposit_address0  s      !!!==&HTN
  "AA&I33D9K#66{IBB4;;wC_`` 33HG$/y!3 	" as"   B3B/A<B3B1B31B3rE  c                     U R                  US5      nU R                  U5        U R                  US5      nUS:X  a  S nUUS   S UUS.$ )Naddress
addressExtr  r  )r  rE  r  r  tag)r  check_address)rm  r  rE  r  r  s        ro  r  hashkey.parse_deposit_addressV  s`     "">9=7#~|<"9C" (
 	
rq  c                 V  #    SnU R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   Ub  X&S'   Ub  X6S'   SnU R                  XES5      u  pUb  XS'   U R                  U R	                  Xd5      5      I Sh  vN n	U R                  XX#S	S
05      $  N N7f)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   NrF   r  r%  rJ  r&  r'  r  r  )r  rE  r/  #privateGetApiV1AccountDepositOrdersr  parse_transactions
rm  r  r  rJ  rw  r3  r  rE  r&  rx  s
             ro  fetch_depositshashkey.fetch_depositsp  s      %
!!!!}}T*H&tnGFO#(K $G55f'R!&IAA$++gB^__ &&x5&R[I\]]; 	" `"   B)B%A2B)B'B)'B)c                 V  #    SnU R                  5       I Sh  vN   0 nSnUb  U R                  U5      nUS   US'   Ub  X&S'   Ub  X6S'   SnU R                  XES5      u  pUb  XS'   U R                  U R	                  Xd5      5      I Sh  vN n	U R                  XX#S	S
05      $  N N7f)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   NrF   r  r%  rJ  r&  r'  r  
withdrawal)r  rE  r/  $privateGetApiV1AccountWithdrawOrdersr  r  r  s
             ro  fetch_withdrawalshashkey.fetch_withdrawals  s      (
!!!!}}T*H&tnGFO#(K $G55f'R!&IBB4;;wC_``, &&x5&R^I_``I 	" ar  r  r  r  c                 t  #    U R                  XE5      u  pEU R                  5       I Sh  vN   U R                  U5      nUS   UUS.nUb  XGS'   SnU R                  U5      u  pUb  U R	                  U5      US'   U R                  U R                  Xu5      5      I Sh  vN n	U R                  X5      $  N N7f)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>`
NrF   )r  r  rJ  r  r  )handle_withdraw_tag_and_paramsr  rE  r  r  privatePostApiV1AccountWithdrawr  parse_transaction)
rm  r  r  r  r  rw  rE  r  r  rx  s
             ro  r   hashkey.withdraw  s       99#F!!!==&TN

 ?$'L!"AA&I"#'#:#:;#GGK ==dkk'>Z[[ %%h99- 	" \s"   'B8B4A4B8B6B86B8c                 z   U R                  USS5      nU R                  US5      nU R                  US5      nUc4  U R                  USS5      nU(       a  SnOU R                  US5      nUb  SnU R                  US	5      nU R                  US
5      n	U R                  X5      n
U R	                  US5      nU R                  US5      nU R                  US5      nS nUb  UU
S.n0 SU_SU_SU_SU_SU R                  U5      _SS _SU_SS _SS _SS _SS _SS _SS _SU_SU
_SU R                  U5      _SS _S S US.E$ )NrF   rK  r  r}  successFr|  
addressUrltxIdr  r8  rJ  r  rD  r  txidr  rL  r  	addressToaddressFromr  tagTotagFromr  r  rE  r~  )internalcommentr  )rT  r  r  r  ru  r  rU  parse_transaction_status)rm  transactionrE  rF   r  r}  r  r  r  r  r  r  r  rX  r  s                  ro  r  hashkey.parse_transaction  s   R T9="";	:!!+x8>nn[)UCG!--k<H
)!FV4V4&&t6%%k6:	!!+z:"";6 C
K
"
 D
 	

 Y/
 t
 w
 
 4
 4
 T
 t
 D
 f
 
  d33F;!
" t#
$ )
 	
rq  c                 D    SSSSSSSSSSSSS.nU R                  X!U5      $ )Npendingfailedr|  	cancelled)r  2345678910
successfulr  r  rm  r}  statusess      ro  r   hashkey.parse_transaction_statusR  sB    
 &99rq  fromAccount	toAccountc                   #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  X5      UUS.nU R                  U R	                  Xu5      5      I Sh  vN nU R                  X5      $  Ng N7f)aU  
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>`
NrF   )r  rJ  fromAccountIdtoAccountId)r  rE  currency_to_precision$privatePostApiV1AccountAssetTransferr  parse_transfer)	rm  r  r  r  r  rw  rE  r  rx  s	            ro  r   hashkey.transferc  s      !!!==&TN224@($	
 BB4;;wC_`` ""866# 	" as"   BA>AB(B )B Bc           
          U R                  US5      nU R                  US5      nS nU R                  USS5      nU(       a  SnU R                  US5      UU R                  U5      U R	                  XB5      S S S UUS.	$ )Nr  rF   r  Fr|  rK  )	rF   r  rL  rE  r  r  r  r}  r  )ru  r  r  rU  r  )rm  r   rE  r  r  r}  r  s          ro  r  hashkey.parse_transfer  s    %%h<	%%h5
..9e<F""8Y7"Y///
E

 
	
rq  c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  X!5      $  N. N7f)aD  
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
N)r  privateGetApiV1AccountTypeparse_accountsrv  s      ro  fetch_accountshashkey.fetch_accounts  sG      !!!88@@ ""844 	"@s   A	AA	AA	A	c                     U R                  US5      nSnUS:X  d  US:X  a  SnOUS:X  d  US:X  a  SnU R                  U R                  US	5      5      nUS
-   U-   nU R                  US5      US US.$ )NaccountLabelr  zMain Trading AccountzMain Future AccountmainzSub Main Trading AccountzSub Main Future AccountsubaccountTyper)  r(  )rF   r  r  r  )r  parse_account_type)rm  r  r  labelr  r  s         ro  parse_accounthashkey.parse_account  s    ''@11\EZ5ZE77<Kd;dE--d.>.>w.VWs{[(""7K8	
 	
rq  c                 4    SSSSS.nU R                  X!U5      $ )Nzspot accountzswap accountzcustody accountzfiat account)r  r  r  r  r  rm  r  typess      ro  r  hashkey.parse_account_type  s*    "	
 T22rq  c                 2    SSSS.nU R                  X!U5      $ )Nr  r  r  )rR   rT   custodyru  r  s      ro  encode_account_typehashkey.encode_account_type  s'    

   d33rq  c                 6    SSSSSS.nU R                  X!U5      $ )Nr  r  51900904)r6  r  r   r  r   r  r  s      ro  encode_flow_typehashkey.encode_flow_type  s-    
   d33rq  c                 b  #    SnUc  [        U R                  S-   U-   S-   5      eSnU R                  XES5      u  pdUc  [        U R                  S-   U-   S-   5      eU R                  5       I Sh  vN   U R	                  U5      n0 nX(S'   Ub  X8S'   XhS	'   Sn	U R                  XES
5      u  pU	b  U R                  U	5      US
'   Sn
U R                  XES5      u  pU
b  U R                  U
5      US'   U R                  U R                  X5      5      I Sh  vN nU R                  XX#5      $  N N7f)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>`
r   Nr)  z() requires a since argumentr&  z() requires an until argumentr%  rJ  r'  flowTyper  )
r,   rF   r/  r  rE  r  r  !privateGetApiV1AccountBalanceFlowr  parse_ledger)rm  r  r  rJ  rw  r3  r&  rE  r  r  r  rx  s               ro  fetch_ledgerhashkey.fetch_ledger  sV     #
=#DGGcMJ$>A_$_``55f'R=#DGGcMJ$>A`$`aa!!!==&$$G"	88ZX"&"7"7"AGJ";;FP]^"%)%=%=k%JGM"??G@\]]&   UBBE 	" ^s%   A.D/0D+1B#D/D-D/-D/c                 6    SSSSSS.nU R                  X!U5      $ )Nr6  r  r   r  r   )r  r  r  r  r  r  r  s      ro  parse_ledger_entry_typehashkey.parse_ledger_entry_type	  s-    
 T22rq  itemc                 |   U R                  US5      nU R                  US5      nU R                  US5      nU R                  U R                  US5      5      nU R                  US5      nU R                  Xr5      nU R	                  Xr5      nU R                  US5      n	U R                  U	5      n
SnU	R                  S5      S	:  a  S
nU R                  US5      nU R                  U5      nSnU R                  0 SU_SU_SU_SU R                  U5      _SU_SU_SS _SS _SU_SU_SS _SU
_SS _SU_SU_SS _U5      $ )NrF   r(  r  flowTypeValuer  r  inr  r   outr  r|  r  r  rL  r  	directionreferenceIdreferenceAccountr  rE  r  r  beforeafterr}  r  )	r  ru  r!  r  safe_currencyrl  findsafe_ledger_entryrU  )rm  r#  rE  rF   r  r  r  r  r  amountStringr  r(  afterStringr,  r}  s                  ro  parse_ledger_entryhashkey.parse_ledger_entry	  s     dD)""45%%dI6	++D,<,<T?,ST%%dF3
&&z<%%j;''h7""<0	S!Q&I&&tW5!!+.%% '
D'
"'
 '
 Y/	'

 w'
 '
 4'
 '
 D'
 '
 d'
 f'
 d'
 U'
 f'
  4!'
" # 	rq  r  r9  r  c                 >  #    U R                  5       I Sh  vN   U R                  U5      nUS   (       a  U R                  XX4XV5      I Sh  vN $ US   (       a  U R                  XX4XV5      I Sh  vN $ [	        U R
                  S-   US   -   S-   5      e N NL N)7f)a  
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>`
NrR   rT   z$ createOrder() is not supported for r  r-  )r  r  create_spot_ordercreate_swap_orderr8   rF   rm  r  r  r9  r  r  rw  r  s           ro  create_orderhashkey.create_orderQ	  s     , !!!V$&>//dEZZZF^//dEZZZtww)OORXY_R``cuuvv 	" [Zs3   BB5BB$B1B2&BBBr  c                 
  #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSU0nU R	                  USSUSU R                  XS5      5      I Sh  vN $  Nh N7f)an  
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>`
NrR   zB createMarketBuyOrderWithCost() is supported for spot markets onlyr  r  r<  )r  r  r8   rF   r8  r  )rm  r  r  rw  r  reqs         ro  !create_market_buy_order_with_cost)hashkey.create_market_buy_order_with_costp	  s      !!!V$f~tww)mmnnD
 &&vxdDKKX[Ldeee 	" fs"   BA?A#B:B;BBc                   #    U R                  USS5      nUb  [        U R                  S-   5      eU R                  5       I Sh  vN   U R	                  U5      nUS:H  =(       a    US:H  n	U R                  US5      n
U	(       d  U
b  [        U R                  S-   5      eU R                  XX4XV5      n0 nU R                  US	5      nU(       a,  U R                  US	5      nU R                  U5      I Sh  vN nO=U	(       a  U
c  U R                  U5      I Sh  vN nOU R                  U5      I Sh  vN nU R                  X5      $  GN NV N4 N7f)
aY  
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>`
	stopPricer8  Nz2 trigger orders are not supported for spot marketsr  r<  r  zF createOrder() supports cost parameter for spot market buy orders onlyr   )rT  r8   rF   r  r  r  create_spot_order_requestr  omitprivatePostApiV1SpotOrderTestprivatePostApiV11SpotOrderprivatePostApiV1SpotOrderparse_order)rm  r  r  r9  r  r  rw  r8  r  isMarketBuyr  r  rx  r   s                 ro  r5  hashkey.create_spot_order	  s@    ( ))&+~N#tww)]]^^!!!V$x'<dem/$"2tww)qqrr66vTSXa~~ff-YYvv.F!??HHHdl!<<WEEH* ";;GDDHv 11{ 	" IE* EsI   AEEB.E3E
4#EEE1E2E
EEEc                     U R                  U5      nUS   (       a  U R                  XX4XV5      $ US   (       a  U R                  XX4XV5      $ [        U R                  S-   S-   US   -   S-   5      e)NrR   rT   r)  *createOrderRequest() is not supported for r  r-  )r  r@  create_swap_order_requestr8   rF   r7  s           ro  create_order_requesthashkey.create_order_request	  s    V$&>11&e\\F^11&e\\tww}/[[^dek^ll  pB   B  C  Crq  c                    U R                  U5      nUR                  5       nUS   UR                  5       US.nUb  U R                  X5      US'   Sn	U R                  US5      u  pU	b  U R	                  X5      US'   Ub  U R                  X5      US'   US:H  n
SnU R                  XS	:H  U5      u  pU(       a  US
:X  a  S	US'   SnU R                  US5      u  pUb  XS'   U R                  X5      $ )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
       rF   )r  r9  r  NrJ  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  )rm  r  r  r9  r  r  rw  r  r  r  isMarketOrderpostOnlyrQ  s                ro  r@  !hashkey.create_spot_order_request 
  s     V$zz|TlJJL

 "&":":6"JGJ//?"&"8"8"FGJ#66vEGG(00@UW]^+GFO! $ 8 8 Q$)6%&{{7++rq  c                    U R                  U5      nUS   SU R                  X5      S.nUS:H  n	U	(       a  SUS'   Ub  U R                  X5      US'   S	US'   S
n
U R                  USU
5      u  pSnU
(       a  SnUR	                  5       U-   US'   SnU R                  US5      u  pS
nU R                  XS:H  U5      u  pU(       a  SnUb  XS'   U R                  US5      nUc  U R                  5       US'   U R                  US5      nUb+  U R                  X5      US'   SUS'   U R                  US5      nU R                  X5      $ )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
       rF   rP  )r  r  rJ  r  rN  	priceTypeNr  INPUTF
reduceOnly_OPEN_CLOSEr9  r>  rO  rQ  r8  r?  STOPr  )r  rT  rW  handle_param_boolrS  rU  rX  r  uuidrA  r  )rm  r  r  r9  r  r  rw  r  r  rY  r_  r  r>  rZ  rQ  r8  s                   ro  rJ  !hashkey.create_swap_order_request*
  sy   " V$Tl00@

 (#+GK #66vEGG#*GK 
!33FL*U
F**,/"66v}M00}@\^de'K"%0M"((A '+yy{GO$''?##'#:#:6#PGK $GFOYYv~6F{{7++rq  c                    #    U R                  5       I Sh  vN   U R                  U5      nU R                  XX4XV5      nU R                  U R	                  X5      5      I Sh  vN n	U R                  X5      $  Na N7f)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>`
N)r  r  rJ  privatePostApiV1FuturesOrderr  rE  )
rm  r  r  r9  r  r  rw  r  r  rx  s
             ro  r6  hashkey.create_swap_order_
  su     & !!!V$00tU[::4;;w;WXX, 113 	" Ys"   A<A8AA<"A:#A<:A<ordersc           	      d  #    U R                  5       I Sh  vN   / n[        S[        U5      5       H  nX   nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  US5      n	U R	                  US5      n
U R                  US0 5      nU R                  XgXX5      nU R                  US	5      nUc  U R                  5       US	'   UR                  U5        M     US   nU R                  US5      nU R                  U5      nS
U0nSnUS   (       a*  U R                  U R                  UU5      5      I Sh  vN nOXUS   (       a*  U R                  U R                  UU5      5      I Sh  vN nO$[        U R                  S-   S-   US   -   S-   5      eU R                  US/ 5      n/ n[        S[        U5      5       H:  nU R                  UU0 5      nU R                  US0 5      nUR                  U5        M<     U R!                  U5      $  GN N N7f)a  
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>`
Nr   r  r  r9  r  r  rw  rQ  ri  rR   rT   r)  rI  r-  r	  rN  )r  r  r  r  r  r  rK  rd  appendr  privatePostApiV1SpotBatchOrdersr  "privatePostApiV1FuturesBatchOrdersr8   rF   r  parse_orders)rm  ri  rw  ordersRequestsr
  rawOrderr  r  r9  r  r  orderParamsorderRequestrQ  
firstOrderfirstSymbolr  r  rx  r	  responseOrdersresponseEntryresponseOrders                          ro  create_ordershashkey.create_orders
  s=     !!!q#f+&AyH%%h9F##Hf5D##Hf5D%%h9F$$Xw7E..8R@K44V4QVdL ,,\?KM$04		_-!!,/ ' $A&
&&z8<[)n
 &>!AA$++gW]B^__H8 F^!DDT[[QXZ`EabbHJ tww}/[[^dek^ll  pB   B  C  C(B7q#f+&A NN61b9M NN='2FM!!-0 '   00A 	". `: cs5   H0H)D;H0H,3H0H.B#H0,H0.H0rF   c                   #    SnU R                  XC5        U R                  5       I Sh  vN   0 nU R                  US5      nUc  XS'   SnUb  U R                  U5      nSnU R	                  XGX85      u  pSn	US:X  a)  U R                  U R                  XS5      5      I Sh  vN n	OUS:X  a\  Sn
U R                  X4U
5      u  pU
(       a  SUS	'   OS
US	'   Ub  US   US'   U R                  U R                  XS5      5      I Sh  vN n	O$[        U R                  S-   U-   S-   U-   S-   5      eU R                  U	5      $  GN N N?7f)a  
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]   NrQ  rK  rR   rT   Frb  r  rP  rF   r  r)  r,  r-  )check_type_paramr  r  r  r.  privateDeleteApiV1SpotOrderr   handle_trigger_option_and_paramsprivateDeleteApiV1FuturesOrderr8   rF   rE  rm  rF   r  rw  r3  r  rQ  r  r  rx  	isTriggers              ro  cancel_orderhashkey.cancel_order
  sg      #
j1!!!((A !#I[[(F
!??
TZg
!==dkk'>Z[[H" 6!I $ E EfZc dI"(")!$*4L!!@@WA]^^H2 tww}z9<VVYccfxxyy))A 	" \4 _s5   'ED=A6E E !A!EE;E EEc                 <  #    SnUc  [        U R                  S-   U-   S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nU R	                  US5      nUb  XeS'   SnUS   (       a)  U R                  U R                  XR5      5      I Sh  vN nOZUS	   (       a)  U R                  U R                  XR5      5      I Sh  vN nO'[        U R                  S-   U-   S
-   US   -   S-   5      eU R                  U5      nXxS'   U/$  N Ny NH7f)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
r[   Nr)  z() requires a symbol argumentr  rF   r9  rR   rT   r,  r  r-  r  )
r,   rF   r  r  r   privateDeleteApiV1SpotOpenOrdersr  $privateDeleteApiV1FuturesBatchOrdersr8   
safe_order)	rm  r  rw  r3  r  r  r9  rx  rN  s	            ro  cancel_all_ordershashkey.cancel_all_ordersN  s-     '
>#DGGcMJ$>A`$`aa!!!V$fTl
 /"FO&>!BB4;;wC_``H F^!FFt{{SZGcddH
 tww}z9<VVY_`fYggj||}}) fw/ 	" a
 es5   7DDA$DD2DDADDDidsc                   #    SnU R                  5       I Sh  vN   0 nSR                  U5      nXeS'   SnUb  U R                  U5      nSnU R                  XGX85      u  pSn	US:X  a)  U R	                  U R                  U5      5      I Sh  vN n	OKUS:X  a!  U R                  U R                  U5      5      n	O$[        U R                  S-   U-   S-   U-   S	-   5      eU R                  U	5      n
XS
'   U
/$  N Nj7f)a%  
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^   N,r  rR   rT   r)  r,  r-  r  )
r  joinr  r.  &privateDeleteApiV1SpotCancelOrderByIdsr  )privateDeleteApiV1FuturesCancelOrderByIdsr8   rF   r  )rm  r  r  rw  r3  r  orderIdsr  r  rx  rN  s              ro  cancel_ordershashkey.cancel_ordersw  s
     $
!!!88C=![[(F
!??
TZg
!HHU\I]^^H 6!EEdkkRYFZ[Htww}z9<VVYccfxxyy) fw1 	" _s#   C8C4A2C8C6A)C86C8c                   #    SnU R                  XC5        U R                  5       I Sh  vN   0 nSnU R                  US5      u  pcUc  XS'   SnUb  U R                  U5      nSnU R	                  XGX85      u  pSn	US:X  a0  Ub  XeS'   U R                  U R                  XS5      5      I Sh  vN n	OuUS:X  aK  Sn
U R                  X4U
5      u  pU
(       a  S	US
'   U R                  U R                  XS5      5      I Sh  vN n	O$[        U R                  S-   U-   S-   U-   S-   5      eU R                  U	5      $  GN N N?7f)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   NrQ  rK  rR   origClientOrderIdrT   Frb  r  r)  r,  r-  )r{  r  rU  r  r.  privateGetApiV1SpotOrderr  r}  privateGetApiV1FuturesOrderr8   rF   rE  r  s              ro  fetch_orderhashkey.fetch_order  sb    " "
j1!!!! $ 8 8 Q !#I[[(F
!??
TZg
(/<+,!::4;;w;WXXH< 6!I $ E EfZc dI"(!==dkk'>Z[[H2 tww}z9<VVYccfxxyy))Y 	" YF \s5   'D>D7BD>+D:,AD><D<=;D>:D><D>c                   #    SnU R                  XT5        U R                  5       I Sh  vN   SnUb  U R                  U5      nSnU R                  XVXG5      u  ptU R	                  SU0U5      nUS:X  a  U R                  XX45      I Sh  vN $ US:X  a  U R                  XX45      I Sh  vN $ [        U R                  S-   U-   S-   U-   S-   5      e N NJ N,7f)	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   NrR   r3  rT   r)  r,  r-  )	r{  r  r  r.  r  fetch_open_spot_ordersfetch_open_swap_ordersr8   rF   )rm  r  r  rJ  rw  r3  r  r  s           ro  fetch_open_ordershashkey.fetch_open_orders   s     , '
j1!!![[(F
!??
TZg
lJ7@44VERRR6!44VERRRtww}z9<VVYccfxxyy 	" SRs4   'CCAC	C
C)C*)CCCc                   #    U R                  5       I Sh  vN   SnU R                  USU5      u  pTSn0 nSnSn	U R                  XES5      u  pU	b-  XS'   U R                  U R	                  Xt5      5      I Sh  vN nOKUb  U R                  U5      nUS   US'   Ub  X7S'   U R                  U R	                  Xt5      5      I Sh  vN nU R                  XX#5      $  N Nd N7f)	az  
@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>`
       NfetchOpenSpotOrdersr3  r(  r+  rF   r  rJ  )r  rU  r/  'privateGetApiV1SpotSubAccountOpenOrdersr  r  privateGetApiV1SpotOpenOrdersrn  )
rm  r  r  rJ  rw  r3  r  r  rx  r(  s
             ro  r  hashkey.fetch_open_spot_orders&  s     " !!!*
!55flJW
	 99&kZ	 &/N#!II$++V]JfggH!V,$*4L! #( !??G@\]]H:   5@@] 	" h ^s5   C!CA!C!8C9AC!CC!C!C!c                   #    SnU R                  USU5      u  pTUc  [        U R                  S-   U-   S-   5      eU R                  U5      nSUS   0nSnU R	                  XEU5      u  pU(       a  S	US
'   OSUS
'   Ub  X7S'   Sn	Sn
U R                  XES5      u  pU
b-  XS'   U R                  U R                  Xt5      5      I Sh  vN n	O(U R                  U R                  Xt5      5      I Sh  vN n	U R                  XX#5      $  N? N7f)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>`
       fetchOpenSwapOrdersr3  Nr)  z4() requires a symbol argument for swap market ordersr  rF   Frb  r  rP  rJ  r(  r+  )
rU  r,   rF   r  r}  r/  *privateGetApiV1FuturesSubAccountOpenOrdersr   privateGetApiV1FuturesOpenOrdersrn  )rm  r  r  rJ  rw  r3  r  r  r  rx  r(  s              ro  r  hashkey.fetch_open_swap_ordersg  s*    $ +
!55flJW
>#DGGcMJ$>Aw$wxxV$fTl
 	 AA&V_`	$GFO%GFO$G	 99&kZ	 &/N#!LLT[[Y`MijjH!BB4;;wC_``HX   5@@] k`s$   CDD(D-D.DDc                   #    SnU R                  XT5        U R                  5       I Sh  vN   0 nUb  X6S'   Ub  X&S'   SnU R                  XES5      u  ptUb  XvS'   SnU R                  XES5      u  pSn	Ub  U R                  U5      n	Sn
U R	                  XYXJ5      u  pSnU
S:X  a;  U	b  U	S	   US
'   Ub  XS'   U R                  U R                  Xd5      5      I Sh  vN nOU
S:X  a  Uc  [        U R                  S-   U-   S-   5      eU	S	   US
'   SnU R                  XEU5      u  pU(       a  SUS'   OSUS'   Ub-  XS'   U R                  U R                  Xd5      5      I Sh  vN nOMU R                  U R                  Xd5      5      I Sh  vN nO$[        U R                  S-   U-   S-   U
-   S-   5      eU R                  XX#5      $  GN N Ni NB7f)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|   NrJ  r%  r&  r'  r(  rR   rF   r  rT   r)  r*  Frb  r  rP  r+  r,  r-  )r{  r  r/  r  r.  privateGetApiV1SpotTradeOrdersr  r,   rF   r}  -privateGetApiV1FuturesSubAccountHistoryOrders#privateGetApiV1FuturesHistoryOrdersr8   rn  )rm  r  r  rJ  rw  r3  r  r&  r(  r  r  rx  r  s                ro   fetch_canceled_and_closed_orders(hashkey.fetch_canceled_and_closed_orders  s    , 4
j1!!!$G#(K 55f'R!&I	 99&kZ	[[(F
!??
TZg
!$*4L!$'0$!@@WA]^^H< 6!~'#
(BEu(uvv &tGHI $ E EfZc dI"(")$*3'!%!S!STXT_T_`gTp!qq!%!I!I$++V]Jf!gg6 tww}z9<VVYccfxxyy  5@@ 	". _T rgsG   'GGB0GG	BG!G"(G
G<G	GGGc                     U R                  US5      nUb2  US:w  a+  US:w  a$  [        U R                  S-   U-   S-   U-   S-   5      eg g g )Nr  rR   rT   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-   rF   )rm  r3  rw  
paramsTypes       ro  r{  hashkey.check_type_param7  so     %%ff5
"v)=JRXDXTWWs]Z7:ZZ]gg  k|  |  }  } EY)="rq  rw  r3  c                 8    UnU R                  XSSU5      u  pAXA/$ )NstoprN  )handle_option_and_params_2)rm  rw  r3  defaultValuer  s        ro  r}  (hashkey.handle_trigger_option_and_params?  s,     	 ;;FPVXaclm	""rq  rN  c                    U R                  US5      nU R                  X25      nU R                  USS5      nU R                  US5      nU R                  US5      nU R                  US5      nUS:X  a  SnU R                  U R                  US	5      5      nUS
:X  a  Uc  SnOSnU R                  US5      n	S n
U R	                  Xi5      u  pin
U R                  U R                  US5      5      nUc  UnU R                  US5      nS nU R                  U5      u  pU R                  US5      nUS:X  a  S nU R                  0 SU R                  US5      _SU R                  US5      _SU R                  U5      _SU_SS _SU R                  US5      _SU R                  U5      _SUS   _SU_SU	_SU_S	U_SU_SU R                  U R                  US5      5      _SU R                  US5      _SS _SU R                  U R                  US 5      5      _S S U R                  U R                  US!S"5      5      S U R                  U5      U R                  U R                  US#5      5      S$.UU
US%.EU5      $ )&Nr  transactTimer8  r}  r  r]  rN  r  r  rb  rJ  r>  avgPricer9  feeCoinr  rF   rK  rQ  rL  r  lastTradeTimestamplastUpdateTimestamp
updateTimer  r  origQtyfilledexecutedQty	remainingr8  r?  cumulativeQuoteQtycummulativeQuoteQty	feeAmount)rE  r  )r<  r;  r  tradesr  r_  rZ  r  )r  rP  rO  r  ,parse_order_type_time_in_force_and_post_onlyrQ   parse_order_side_and_reduce_onlyr  rU  ru  parse_order_statusrT  r  )rm  rN  r  r  r  r}  r  r]  r  r>  rZ  r  r9  r_  rY  s                  ro  rE  hashkey.parse_orderD  s
   \ ##E84!!(3''~vF	!!%2v.$$UK8	 Dt//w?@6>}&&um<&*&W&WX\&j#8..!1!1%!DE=E%%eV4
@@F''y92L  
$""5)4 
T--e_E 
 Y/ 
 	 

 !$ 
 "4#4#4UL#I 
 d--f5 
 fX& 
 D 
 ; 
 D 
 U 
 w 
 dnnT%5%5eY%GH 
 d&&um< 
  ! 
" DNN4+;+;E;+OP# 
$  $!NN4#5#5e=QSh#ij 33LA..)9)9%)MN % 9 
: ; 	rq  c                     UR                  S5      nUS   nS nU R                  US5      nUb  US:X  a  SnX4/$ US:X  a  SnX4/$ )Nr:  r   r   r  Fr  T)r  r  )rm  unparsedr  r9  r_  r  s         ro  r  (hashkey.parse_order_side_and_reduce_only  sf    s#Qx
%%eQ/
!V#"
 !! '!
!!rq  c           
      >    SSSSSSSSSS.	nU R                  X!U5      $ )Nr  canceledclosedrejected)	NEWPARTIALLY_FILLEDPARTIALLY_CANCELEDFILLEDCANCELEDORDER_CANCELEDPENDING_CANCELREJECTED	ORDER_NEWr  r  s      ro  r  hashkey.parse_order_status  s9     &","(("

 &99rq  c                 b    S nUS:X  a  SnOUS:X  d  US:X  a  SnSnU R                  U5      nXU/$ )NrO  TMAKERr5  )parse_order_type)rm  r  r>  rZ  s       ro  r  4hashkey.parse_order_type_time_in_force_and_post_only  sH    = H]*w0FHK$$T*8,,rq  c                 4    SSSSS.nU R                  X!U5      $ )Nr  rJ  )rN  rP  rO  MARKET_OF_BASEr  r  s      ro  r  hashkey.parse_order_type  s*    "&	
 T22rq  c                 (  #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  5       S.nU R                  U R	                  XB5      5      I Sh  vN nU R                  US0 5      nU R                  Xc5      $  Nw N*7f)aA  
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>`
NrF   )r  r  r   )r  r  milliseconds publicGetApiV1FuturesFundingRater  r  parse_funding_rate)rm  r  rw  r  r  rx  rates          ro  fetch_funding_ratehashkey.fetch_funding_rate  s      !!!V$Tl**,
 >>t{{7?[\\ ~~h2.&&t44 	" ]s"   BBAB%B&)BBc                    #    U R                  5       I Sh  vN   U R                  U5      nSU R                  5       0nU R                  U R	                  X25      5      I Sh  vN nU R                  XA5      $  N` N7f)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
Nr  )r  rt  r  r  r  parse_funding_ratesr  s        ro  fetch_funding_rateshashkey.fetch_funding_rates1  sz      !!!%%g.**,
 >>t{{7?[\\ '':: 	"
 ]s"   A;A7A
A;!A9"A;9A;c                 *   U R                  US5      nU R                  X2S S5      nU R                  US5      nU R                  US5      n0 SU_SUS   _SS _SS _SS _S	S _S
S _SS _SU_SS _SS _SS _SU_SU R	                  U5      _SS _SS _SS _SS 0E$ )Nr  rT   r  nextSettleTimer  	markPrice
indexPriceinterestRateestimatedSettlePricer  rL  fundingRatefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimer`  )r  rP  r  ru  rU  )rm  r  r  r  r  r  s         ro  r  hashkey.parse_funding_rateI  s>    ##Hh7!!(D&A&&x8,,X7GH
H
fX&
 
 $	

 D
 #D
 
 
 ;
 
 t
 t
 #$4
 "4<<0@#A
 "4
  '!
" &t#
$ %
 	
rq  c           
      h  #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eU R                  U5      nSUS   0nUb  X6S'   U R	                  U R                  Xd5      5      I Sh  vN n/ n[        S[        U5      5       Hq  n	Xy   n
U R                  U
S5      nUR                  U
U R                  U R                  U
S5      USS5      U R                  U
S	5      UU R                  U5      S
.5        Ms     U R                  US5      nU R                  XU5      $  GN N7f)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  rF   rJ  r   
settleTimerT   
settleRate)r  r  r  r  rL  r  )r  r,   rF   r  'publicGetApiV1FuturesHistoryFundingRater  r  r  ru  rk  safe_symbolr  r  rU  sort_byfilter_by_since_limit)rm  r  r  rJ  rw  r  r  rx  ratesr
  r  r  sorteds                ro  fetch_funding_rate_history"hashkey.fetch_funding_rate_historyj  s:     !!!>#DGG.e$effV$fTl
 $GEEdkkRYFbcc q#h-(AKE))%>ILL**4+;+;E8+LfVZ\bc#//|D& LL3  ) e[1))&??C 	" ds#   D2D-A!D28D09B5D20D2c                 D  #    SnUc  [        U R                  S-   U-   S-   5      e[        U5      nUS:w  a  [        U R                  S-   U-   S-   5      eU R	                  5       I Sh  vN   U R                  US   U R                  SS0U5      5      I Sh  vN $  N3 N7f)	a  
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   r3  )r,   rF   r  r8   r  fetch_positions_for_symbolr  )rm  r  rw  r3  symbolsLengths        ro  fetch_positionshashkey.fetch_positions  s      &
O#DGGcMJ$>A~$~LM!"477S=:#=  AK  $K  L  L!!!44WQZl\lMmouAvwww 	"ws$   A&B (B).B BB B c                 d  #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  USU5      u  pBUS   (       d  [        U R                  S-   U-   S-   5      eSUS   0nU R                  U R                  XR5      5      I Sh  vN nU R                  Xa/5      $  N N7f)	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>`
Nr   r3  rT   r)  z() supports swap markets onlyr  rF   )r  r  rU  r8   rF   privateGetApiV1FuturesPositionsr  parse_positions)rm  r  rw  r  r3  r  rx  s          ro  r  "hashkey.fetch_positions_for_symbol  s      !!!V$$
!55flJW
f~tww}z9<[[\\fTl
 ==dkk'>Z[[, ##Hh77? 	" \s"   B0B,A>B0B.B0.B0positionc                 V   U R                  US5      nU R                  X25      nUS   nU R                  0 SU_SS _SS _SS _SU R                  US5      _SS _SU R	                  US5      _S	U R                  US
5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SS _SU R                  US5      _SS _SU R                  US5      _SS_SS_U R                  US5      S U R                  US5      S S S U R                  US5      S S S US.E5      $ )Nr  rF   r  rL  r  r  r  r9  notionalpositionValuerA  unrealizedPnlunrealizedPnLrealizedPnlrealizedPnL
collateral
entryPricer  r  liquidationPricer7  crossr?  T	minMarginrS   	lastPrice)maintenanceMarginmaintenanceMarginPercentager  initialMarginPercentagemarginRatior  r  r;  r<  r  r  )r  rP  safe_positionr  rQ  ru  )rm  r  r  r  r  s        ro  parse_positionhashkey.parse_position  s   ##Hh7!!(3!!! #
f#
$#
 #
 	#

 ))(J?#
 D#
 D**8V<#
 ((?C#
 ))(J?#
 T--hH#
 4++HmD#
 $#
 $**8Z@#
 #
  0 0;M N#
  '!#
" d##
$ "&!1!1(K!H+/!--hA'+#'))(K@!#9#
  	rq  c                 
  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R                  Xc5      $  Nh N*7f)aB  
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>`
Nr  rF   r   )r  r  privateGetApiV1FuturesLeverager  r  parse_leverage)rm  r  rw  r  r  rx  rA  s          ro  fetch_leveragehashkey.fetch_leverage  s      !!!V$fTl
 <<T[[=YZZ >>(Ar2""844! 	"
 [rr  rA  c                 `    U R                  US5      nU R                  US5      nUUS   UUUS.$ )N
marginTyperA  r  )r  r  r7  longLeverageshortLeverage)rQ  r  )rm  rA  r  r7  leverageValues        ro  r&  hashkey.parse_leverage  sD    ++HlC
((:>X&$)*
 	
rq  c                 $  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   SU0nU R                  U5      nUS   US'   U R	                  U R                  XC5      5      I Sh  vN nU R                  Xe5      $  NZ N7f)aE  
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 argumentrA  rF   r  )r,   rF   r  r  privatePostApiV1FuturesLeverager  r&  )rm  rA  r  rw  r  r  rx  s          ro  set_leveragehashkey.set_leverage(  s      >#DGG.Y$YZZ!!!
 V$"4L==dkk'>Z[[ ""844 	" \s"   /BBAB6B7BBc                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US/ 5      nU R                  U5      nU R	                  XAS5      $  NS N<7f)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
Nr  r  )r  r  r  rt  parse_leverage_tiers)rm  r  rw  rx  datas        ro  fetch_leverage_tiershashkey.fetch_leverage_tiersE  si      !!!88@@~~hR8%%g.((AA 	"@s   A.A*A.A,;A.,A.c                    U R                  US/ 5      nU R                  US5      nU R                  XB5      n/ n[        S[	        U5      5       H  nX6   nU R                  US5      nUR                  U R                  US5      U R                  XB5      US   S U R                  US5      U R                  US5      U R                  [        R                  " S	U5      5      US
.5        M     U$ )Nr  r  r   r  r   r  rJ  maintMarginr  )tierr  rE  minNotionalmaxNotionalmaintenanceMarginRater  r  )r  r  rP  r  r  rk  sumr  r  rl  r@   r  )	rm  r  r  r  r  r
  r
  r:  initialMarginRates	            ro  parse_market_leverage_tiers#hashkey.parse_market_leverage_tiersV  s    \ ^^D,;
##D(3!!(3q#j/*A=D $ 0 0 GLLA**8<"8,##//jA)-)9)9$)N#001C1CCIZ1[\	 	 + rq  c                   #    U R                  5       I Sh  vN   U R                  U5      nSnSnUS   (       a*  U R                  U5      I Sh  vN nU R                  XQ5      $ US   (       a?  U R	                  U R                  SUS   0U5      5      I Sh  vN nU R                  XS5      $ [        U R                  S-   U-   S-   US	   -   S
-   5      e N N N@7f)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>`
Nr   rR   rT   r  rF   r)  r,  r  r-  )	r  r  fetch_trading_feesr  $privateGetApiV1FuturesCommissionRater  parse_trading_feer8   rF   )rm  r  rw  r  r3  rx  s         ro  fetch_trading_feehashkey.fetch_trading_fee  s      !!!V$&
&>!44V<<H>>(33F^!FFt{{T\^dei^jSkmsGtuuH))(;; tww}z9<VVY_`fYggj||}}' 	"
 = vs4   CC7CCACC=CCCc                 .  #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US/ 5      n0 n[        S[	        U5      5       H-  nU R                  X50 5      nU R                  U5      nXtUS   '   M/     U$  Nz Nc7f)aE  
*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
Nr5  r   r  )r  privateGetApiV1AccountVipInfor  r  r  r  rE  )rm  rw  rx  r5  r	  r
  r  	parsedFees           ro  rC  hashkey.fetch_trading_fees  s      !!!;;FCC. ~~h3q#d)$A.."-C..s3I*39X&' % = 	"Cs    BBBBA"BBr  c                     U R                  US5      nU R                  X25      nUUS   U R                  USS5      U R                  USS5      SSS.$ )Nr  openMakerFeeactualMakerRateopenTakerFeeactualTakerRateT)r  r  r  r  r  r  )r  rP  safe_number_2)rm  r  r  r  s       ro  rE  hashkey.parse_trading_fee   sg    , ##C2!!(3X&''^=NO''^=NO
 	
rq  r   GETc                 .   U R                   S   U   S-   U-   nS nUS:X  Ga  U R                  5         U R                  5       n	SU	0n
U R                  U R                  S5      nUb  XS'   U R
                  SS.nS nUS:X  a  US	:X  d  US
:X  a  SUS'   U R                  U R                  US5      5      nU R                  U R                  U R                  U
5      5      U R                  U R                  5      [        R                  5      nU R                  U R                  U
SU05      5      nUSU-   -  nOU R                  X5      nU R                  U R                  U R                  U5      5      U R                  U R                  5      [        R                  5      nXS'   U R                  U5      nUS:X  a	  USU-   -  nOUnU R                  U R                  SS5      US'   XS'   O(U R!                  U5      n[#        U5      S:w  a  USU-   -  nXsXeS.$ )Nr   r  r   r  r-  z!application/x-www-form-urlencoded)zX-HK-APIKEYContent-TypePOSTr   r   zapplication/jsonrU  ri  	signature?rS  r,  r  zINPUT-SOURCEbroker_signr   )r  methodbodyheaders)r   check_required_credentialsr  ru  r  apiKeyjsonr  hmacencodecustom_urlencodesecrethashlibsha256r  r  	urlencoder  )rm  pathr   rZ  rw  r\  r[  r  queryr  additionalParamsr-  rW  totalParamss                 ro  signhashkey.sign!  s#   iis#c)D0)++-))+IY  **4<<FJ%1;.#{{ CG "I& 0I(ItWsOs*<'yy!AB IIdkk$2G2GHX2Y&Z\`\g\ghlhshs\tv}  wE  wE  F	--dkk:J[ZcLd.efsU{""kk*:C IIdkk$2G2G2T&UW[WbWbcgcncnWoqxqq  A	+4K(--k:U?3;&C D&*&6&6t||X}&]GN#%.M"NN6*E5zQsU{"dOOrq  c                 L    U R                  U5      nUR                  SS5      nU$ )Nz%2Cr  )rf  replace)rm  rw  r	  s      ro  rb  hashkey.custom_urlencodeI  s%    's+rq  c
                    Uc  g Sn
U R                  USS 5      nU R                  USS 5      nUS:X  an  U R                  US/ 5      n[        S[	        U5      5       HB  nU R                  X5      nU R                  US5      nUS:w  d  M.  Sn
U R                  US5      nMD     US:w  d  U
(       a]  U R                  S-   U-   nU R                  U R                  S   UU5        U R                  U R                  S	   UU5        [        U5      eg )
NFr  r   r	  T   r)  rg  rf  )r  ru  r  r  r  r  rF   throw_broadly_matched_exceptionrV  throw_exactly_matched_exceptionr'   )rm  r  reasonr  rZ  r\  r[  rx  requestHeadersrequestBodyerrorInArrayresponseCodeStringresponseCodeIntegerr	  r
  r  entryCodeIntegerfeedbacks                     ro  handle_errorshashkey.handle_errorsN  s   !--hE"//&$G!#^^Hh;F1c&k*v1#'#4#4UF#C #q(#'L)-)9)9%)H& + CKLww}t+H001IK]_gh001IK]_gh))rq   )N){__name__
__module____qualname____firstlineno__r   rk  r   ry  r  r&   r   r  dictr  r	   r  strr   r  r!   r"  r   r4  r[  listrd  rj  r   rp  r   r   rv  rn  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!  r2  r   r   r   r   r8  r<  r5  rK  r@  rJ  r6  r   rx  r  r  r  r  r  r  r  r  r{  objectr}  rE  r  r  r  r  r   r  r    r  r  r  r   r	  r  r"  r   r'  r&  intr1  r   r6  r   r@  r"   rF  r#   rC  rE  rk  rb  r|  __static_attributes____classcell__)rn  s   @ro  rB   rB   '   sh	   d	# d	L ') 9S 9" )+ 
* *, @+V @+DE4 EF EN -/ ^: ^@ @DB #LS #L #LS\ #LJ <@d[] A AS A Abfglbm AB 37TX\eg hAC hAs hARU hATb bv b bH ?CQUdhqs 4L 4L 4L3 4L^a 4Lx|  ~B  yC 4Ll
 
4 
. 68 !1 !1F !1F 6:" 57 5 5)6 )V )V :>b 9w 9Z 94

f 

	 

 *, 4z 4zl) )@)X )0 =? $ $> $L
h 
R` 
4 04$UYbd ,^ ,^C ,^s ,^imnyiz ,^\ 37TX\eg 2aC 2as 2aRU 2alpq|l} 2ah QU]_ ':3 ': ': ':# ':do ':RU
x U
; U
n:" ac  73  7  7C  7TW  7gt  7D
 
& +- 5g 50
 344 .2SW`b 8Cs 8C# 8CS 8Cgklwgx 8Ct30t 0x 0; 0d mqy{ w wI wY wX] wfi w  AF w> XZ fc f f^c f" rv  A t2c t2 t2) t2]b t2kn t2  FK t2l os{} C3 Ci Cy CZ_ Chk C  CG C tx  AC (, (,9 (,I (,_d (,mp (,  HL (,T tx  AC 3, 3,9 3,I 3,_d 3,mp 3,  HL 3,j rv  A ,2c ,2 ,2) ,2]b ,2kn ,2  FK ,2\ FH k1$|*< k1Z 9=R R*S R*# R*h 59 'c 'R AER &tCy &# &P 8<B _*C _* _*5 _*B 59tZ^gi $zc $z $zTW $znrsxny $zL :>D_cln ?A3 ?Ac ?AY\ ?Aswx}s~ ?AB :>D_cln UA3 UAc UAY\ UAswx}s~ UAn DHVZimvx wAS wAPS wAcf wA  ~B  CH  ~I wAr}#v #3 #
e ev e eN
":-3 <> 5s 5+ 52 <@ ; ;| ;0
6 
[ 
B >BPTcgpr /@s /@# /@]` /@b 8<B xW x4PX> x, DF +8s +8$x. +8Z!t !V !F 8: 53 5h 58	
t 	
V 	
x 	
 ?C2 53 5 5: =A B' BP] B"_ _$|J\ _B ;= ~c ~AT ~@ /1 '[ 'R
T 
6 
EX 
B &eBSW &PP /1 t S 
 rq  rB   )G ccxt.async_support.base.exchanger   ccxt.abstract.hashkeyr   rd  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   r~  rq  ro  <module>r     s    6 -  {  {  {  {  {  {  {  {  {  * 0 - . - . ' & . . + ) * 5 - - 0 ) , + . 1 ) + 4 %z@h z@rq  