
    !:h#                       d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& d dl'm(Z( d dl)m*Z* d dl)m+Z+ d dl)m,Z, d d	l)m-Z- d d
l)m.Z. d dl)m/Z/ d dl)m0Z0 d dl)m1Z1 d dl)m2Z2 d dl)m3Z3 d dl)m4Z4 d dl)m5Z5 d dl)m6Z6 d dl)m7Z7 d dl)m8Z8 d dl)m9Z9 d dl)m:Z: d dl)m;Z; d dl)m<Z< d dl)m=Z= d dl)m>Z> d dl)m?Z? d dl)m@Z@ d dl)mAZA d dlBmCZC d dlDmEZE  G d  d!ee      ZFy)"    )Exchange)ImplicitAPIN)!AccountAnyBalancesBool
CurrenciesCurrencyDepositAddressInt	LastPrice
LastPricesLedgerEntryLeverageLeverageTierLeverageTiersMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTradingFeeInterfaceTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountNotEnabled)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)OperationRejected)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)OrderImmediatelyFillable)OrderNotFillable)DuplicateOrderId)ContractUnavailable)NotSupported)OperationFailed)DDoSProtection)RateLimitExceeded)ExchangeNotAvailable)InvalidNonce)RequestTimeout)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdefdZi fdZi fdee	   fdZ
dede	fdZi fdefdZd	 Zd
i fdededefdZd
d
i fdedededee   fdZd
d
d
i fdededefdZdodede	defdZdd
d
i fdedededee   fdZdode	defdZi fdedefdZd
i fdedefdZdode	defdZ d
i fdede!fdZ"dode	de#fdZ$i fde%fdZ&de%fdZ'de%fdZ(i fdede)fd Z*dod!e+de)fd"Z,d
d
d
i fdedededee-   fd#Z.d
d
d
i fdedededee-   fd$Z/d
i fded%e0d&ede-fd'Z1dod!e+de-fd(Z2d) Z3i fded%e0d*ed+ede4f
d,Z5dod!e+fd-Z6i fdee7   fd.Z8d/ Z9d0 Z:d1 Z;d2 Z<d
d
d
i fdedededee=   fd3Z>d4 Z?dod5ed!e+de=fd6Z@d
i fded7eAd8eBd%e0d9eCdeDfd:ZEi fded;e0deDfd<ZFd
i fded7eAd8eBd%e0d9eCdeDfd=ZGd
i fded7eAd8eBd%e0d9eCdefd>ZHd
i fded7eAd8eBd%e0d9eCdefd?ZId
i fded7eAd8eBd%e0d9eCdefd@ZJd
i fded7eAd8eBd%e0d9eCdeDfdAZKi fdBeeL   fdCZMd
i fdDedefdEZNd
i fdefdFZOd
i fdGee   defdHZPd
i fdDededeDfdIZQd
d
d
i fdedededeeD   fdJZRd
d
d
i fdedededeeD   fdKZSd
d
d
i fdedededeeD   fdLZTd
d
d
i fdedededeeD   fdMZUdN ZVdodOeWdPefdQZXdodRede	deDfdSZYdT ZZdU Z[dV Z\dW Z]i fdede^fdXZ_d
i fdede`fdYZadode	de^fdZZbd
d
d
i fdededefd[Zcd
i fdedeed   fd\Zei fdedeed   fd]Zfdod^ede	fd_Zgi fdedehfd`Zidodaede	dehfdbZjd
i fdaedefdcZkd
i fdedelfddZmdode	deen   fdeZoi fdedepfdfZqi fderfdgZsdodhede	depfdiZtdjdki d
d
fdlZui fdOedefdmZvdn Zw xZxS )phashkeyreturnc                    | j                  t        t        |          i ddddddgddd	d
dddddi dd ddddddddddddddddddddddddddddddd di d!dd"dd#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1di d2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAddBdi dCddDddEddFddGddHdIdJddKddLddMddNddOddPddQddRddSddTdi dUddVddWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcdddddedddddddddfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydydzd{d{dzd|d}d~dddddddddddddddddddii ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddiddddddddddzddddd| j	                  d      | j	                  d      | j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      gg| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      ggddddd| j	                  d      | j	                  d      | j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      gg| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      ggdddiddd di ddÓddœddǓddɓdd˓dd͓ddϓddГddғddԓdd֓ddؓddړddۓddݓddߓi ddÓddÓddēddēddƓddƓddȓdd̓ddӓddʓddѓddΓddГddГddՓddޓddٓddddddddddddd dddd dddddddddddddddidddddddddddddddddd d ddid	ddiddddddddddid dd d dddi di dt
        dt        dt        d t        dt        dt        dt        dt        dt
        dt
        dt
        dt
        d	t        d
t        dt
        dt        dt        i dt        dt        dt        dt
        dt        dt        dt        dt        dt        dt        dt         dt
        dt"        dt        dt        dt        dt        i dt        d t
        d!t
        d"t
        d#t
        d$t
        d%t
        d&t        d't        d(t$        d)t        d*t&        d+t(        d,t        d-t        d.t*        d/t        i d0t        d1t        d2t        d3t,        d4t        d5t.        d6t        d7t        d8t        d9t,        d:t,        d;t,        d<t.        d=t.        d>t,        d?t0        d@t2        i dAt,        dBt4        dCt        dDt
        dEt
        dFt        dGt        dHt        dIt
        dJt
        dKt        dLt
        dMt
        dNt        dOt.        dPt6        dQt        i dRt        dSt        dTt
        dUt
        dVt
        dWt
        dXt
        dYt
        dZt
        d[t.        d\t
        d]t
        d^t
        d_t
        d`t"        dat,        dbt,        i dct,        ddt        det        dft        dgt        dht        dit        djt        dkt        dlt        dmt        dnt        dot.        dpt.        dqt
        drt        dst        i dtt        dut        dvt*        dwt        dxt,        dyt        dzt        d{t*        d|t        d}t        d~t*        dt"        dt
        dt        dt        dt
        dt
        i dt
        dt
        dt
        dt
        dt        dt        dt        dt
        dt
        dt
        dt
        dt        dt        dt        dt8        dt
        dt
        t        t
        t
        t.        t*        t.        t        t        t        t        t,        di ddt:              S (  NidrB   namezHashKey Global	countriesBM	rateLimitd   versionv1	certifiedTprohasCORSspotmarginFswapfutureoption	addMargincancelAllOrderscancelAllOrdersAftercancelOrdercancelOrderscancelWithdrawclosePositioncreateConvertTradecreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrdercreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrder$createOrderWithTakeProfitAndStopLosscreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingAmountOrdercreateTrailingPercentOrdercreateTriggerOrderfetchAccountsfetchBalancefetchCanceledAndClosedOrdersfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchLedgerfetchLeveragefetchLeverageTiersfetchMarginAdjustmentHistoryfetchMarginModefetchMarketLeverageTiersemulatedfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsfetchTransfersfetchWithdrawals)reduceMarginsandboxsetLeverage	setMarginsetPositionModetransferwithdraw
timeframes1m3m5m15m30m1h2h4h6h8h12h1d1w1M)r   r   r   r   r   r   r   r   r   r   r   r   r   r   urlszOhttps://github.com/user-attachments/assets/6dd6127b-cc19-4a13-9b29-a98d81f80e98zhttps://api-glb.hashkey.com)publicprivatez"https://api-glb.sim.hashkeydev.comzhttps://global.hashkey.com/z'https://hashkeyglobal-apidoc.readme.io/z`https://support.global.hashkey.com/hc/en-us/articles/13199900083612-HashKey-Global-Fee-StructurezChttps://global.hashkey.com/en-US/register/invite?invite_code=82FQUN)logoapitestwwwdocfeesreferralr   get      )zapi/v1/exchangeInfozquote/v1/depthzquote/v1/tradeszquote/v1/klineszquote/v1/ticker/24hrzquote/v1/ticker/pricezquote/v1/ticker/bookTickerzquote/v1/depth/mergedzquote/v1/markPricezquote/v1/indexzapi/v1/futures/fundingRatez!api/v1/futures/historyFundingRatezapi/v1/pingzapi/v1/timeapi/v1/spot/orderapi/v1/spot/openOrderszapi/v1/spot/tradeOrdersapi/v1/futures/leverageapi/v1/futures/orderzapi/v1/futures/openOrderszapi/v1/futures/userTradeszapi/v1/futures/positionszapi/v1/futures/historyOrderszapi/v1/futures/balancez&api/v1/futures/liquidationAssignStatuszapi/v1/futures/riskLimitzapi/v1/futures/commissionRatezapi/v1/futures/getBestOrderzapi/v1/account/vipInfozapi/v1/accountzapi/v1/account/trades)zapi/v1/account/typezapi/v1/account/checkApiKeyzapi/v1/account/balanceFlowz!api/v1/spot/subAccount/openOrdersz"api/v1/spot/subAccount/tradeOrderszapi/v1/subAccount/tradesz$api/v1/futures/subAccount/openOrdersz'api/v1/futures/subAccount/historyOrdersz$api/v1/futures/subAccount/userTradeszapi/v1/account/deposit/addresszapi/v1/account/depositOrderszapi/v1/account/withdrawOrders   )api/v1/userDataStreamzapi/v1/spot/orderTestr   zapi/v1.1/spot/orderapi/v1/spot/batchOrdersr   r   z$api/v1/futures/position/trading-stopapi/v1/futures/batchOrderszapi/v1/account/assetTransferzapi/v1/account/authAddresszapi/v1/account/withdrawr   )r   r   zapi/v1/spot/cancelOrderByIdsr   r   zapi/v1/futures/cancelOrderByIdsr   )r   postputdeleter   tradingz0.001201000000z0.000805000000z0.0007010000000z0.0006050000000z0.00040	200000000z0.00030	400000000z0.00010	800000000z0.00z0.00090z0.00085z0.00075z0.00065z0.00045z0.00035)makertaker)	tierBased
percentagefeeSider   r   tiersz0.00025z0.00016z0.00014z0.00012z0.000080z0.000060z0.000020z0.00050z0.00020)rQ   rS   options10000700011BTCERC20ETHAVAX
AvalancheCSOLSolanaMATICPolygonATOMCosmosDOTPolkadotLTCOPTIMISMOptimismARBArbitrumDOGEDogecoinTRC20TronZKSYNCzkSyncTONKLAYTNKlaytnMERLINCHAINzMerlin ChainBitcoinzAVAX C-ChainLitecoinBSC)r   r   r   z
BSC(BEP20)r   )broker
recvWindowsandboxModenetworksnetworksByIddefaultNetworkfeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergmax        )r  limitdaysBack	untilDayssymbolRequired)r  triggerr  r%  )r  r"  r&  r  r%  r"  )	r   rc   createOrdersr   r   r   r   rs   r   extendsdefault)r  r  i  )r&  r"  )r(  rc   r   forDerivatives)linearinverse)r)  rQ   r*  rS   rT   commonCurrencies
exceptions000100020003010201030104020102020206020702090210021104010402z-1000z-1001z-100010z-100012z-1002z-1004z-1005z-1006z-1007z-1014z-1015z-1020z-1021z-1024z-1101z-1115z-1117z-1123z-1124z-1126z-1129z-1130z-1132z-1133z-1135z-1136z-1138z-1137z-1139z-1140z-1141z-1142z-1143z-1144z-1145z-1146z-1147z-1148z-1149z-1150z-1151z-1152z-1153z-1154z-1155z-1156z-1157z-1158z-1159z-1160z-1161z-1162z-1163z-1164z-1165z-1166z-1167z-1168z-1169z-1170z-1171z-1172z-1173z-1174z-1175z-1176z-1177z-1178z-1179z-1181z-1193z-1194z-1195z-1196z-1200z-1201z-1202z-1203z-1204z-1205z-1206z-1207z-1208z-1209z-2001z-2002z-2003z-2004z-2005z-2010z-2011z-2016z-2017z-2018z-2019z-2020z-2021z-2022z-2023z-2024z-2025z-2026z-2027z-2028z-2029z-2030z-2031z-2032z-2033z-2034z-2035z-2036z-2037z-2038z-2039z-2040z-2041z-2042z-2043z-2044z-2045z-2046z-2048z-2049z-2050z-2051z-2052z-2053z-2054z-2055z-2056z-2057z-3117z-3143z-3144z-3145z-4001z-4002)z-4003z-4004z-4005z-4006z-4007z-4008z-4009z-4010z-4011z-4012z-4013)exactbroadprecisionMode)deep_extendsuperrB   describeparse_numberr-   r(   r;   r)   r'   r3   r0   r.   r>   r2   r/   r=   r<   r4   r6   r5   r8   r9   r*   r7   r1   r,   r+   r:   r?   )self	__class__s    F/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/hashkey.pyrC  zhashkey.describe)   s7   gt = ? |B
)|B
$|B
 $|B
 	|B

 t|B
 |B
 4|B
  ]]] %] 	]
 %] %] U] "4] '] t] ] !%]  ] %e] ']  /!]" $T#]$ ,U%]& 0']( t)]* 7+], (-]. '/]0 &u1]2 (3]4 "45]6 (7]8 ,U9]: -e;]< %d=]>  ?]@ A]B /C]D &tE]F #DG]H $UI]J )%K]L $UM]N $UO]P +EQ]R "4S]T &tU]V (W]X 1%Y]Z  []\ +E]]^ &u_]` #Da]b *4c]d $Te]f "5g]h ti]j  k]l %dm]n /o]p "5q]r +Js]t u]v !%w]x  y]z d{]| +E}]~ !%]@ "4A]B dC]D !$E]F uG]H #EI]J  K]L 'M]N $UO]P !$Q]R *4S]T (U]V )%W]X tY]Z t[]\ ]]^ T_]` ta]b "4c]d #De]f $Ug]h !%i]j #Dk]l !& #"#(  y]|B
L M|B
l i;<
 CC 5@zam|B
J /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K|B
h %)&*#(!%!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] ^	&"=;=i|B
d '"$5U L 8	
 Y H : 5 
 : J V h 5 h  ">!$!5!u! 7! W	!
 !&! #F! e! f! ! w! 
! ! 5! ! !  #M!!" h#!$ %# "'&-!0 #*]/e|B
D
 #&+(-,0,1).+06:#'#'"&#(	( #($)$)+/26/3#()$. r% ',!%$&%'*/& ',#($)*/	# ',!%#($)*/( $()-#c4l y  )(,/3$
 $(!$(
# "#3  $	 ##UNE
|B
b c|B
d 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e|B
v Yw|B
 | |	    c                 H    | j                  |      }| j                  |d      S )a_  
        fetches the current integer timestamp in milliseconds from the exchange server

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

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

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

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

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

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.symbol]: the id of the market to fetch
        :returns dict[]: an array of objects representing market data
        symbols	contracts)publicGetApiV1ExchangeInfoextend	safe_listarray_concatis_emptyparse_markets)rE  rN  requestrO  spotMarketsswapMarketsmarketss          rG  fetch_marketszhashkey.fetch_markets  s     224;;w3OP` nnXy"=nnX{B?##K===!jG!!'**rH  marketc                 2	   | j                  |d      }| j                  |d      }| j                  |      }| j                  |d      }| j                  |      }| j                  |d      }d}d}	d}
d}|j                  d	      }| j                  |d
      }|dk(  r d}d}	d}
| j                  |d      }|d|z   z  }| j                  |      }|dz   |z   |z   }| j                  |d      }|dk(  }d }d }| j                  |d      }||rd}d}nd}d}| j	                  |dg       }| j                  |d      }| j                  |di       }| j                  |di       }| j                  |di       }| j                  | j                  |d            }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }d }d } |
rt        j                  ||      }t        j                  ||      }t        j                  ||      }| j	                  |d      }!|!| j                  |!d      }"t        |!      }#| j                  |!|#d
z
        }$| j                  |"d       }%| j                  |$d       }&t        j                  |%|&      r|&|%g\  }%}&| j                  t        j                  d!|&            }| j                  t        j                  d!|%            } | j                  | j                  d"      }'|	r| j                  |'d      n| j                  |'d      }(| j                  i d#|d|d$|d%|d&|d'|d(|d)|d*|d|	d+| j                  |d,      d|
d-dd.dd/|
d0|d1|i d2| j                  |      d|d|d3| j!                  |(d3      d4| j!                  |(d4      d5| j                  |(d5      d6| j                  |(d6      d7| j                  |(d7      d8d d9d d:d d;d d<| j                  |      | j!                  |d=      d>d?| j                  |      | j                  |      d@| j!                  |dA      | j!                  |dB      d@|| d@| j                  |      d d@dCdDd dE|      S )FNsymbol
quoteAssetmarginToken	baseAssetrQ   TF -r   	PERPETUALrS   
underlying:/rS  TRADINGr,  r+  filters
filterTypePRICE_FILTERLOT_SIZEMIN_NOTIONALmin_notionalcontractMultiplierstepSizeminQtymaxQty
riskLimitsr   initialMargin1r   rE   basequotebaseIdquoteIdactivetypesubTyperR   allowMarginrT   rU   contractsettlesettleIdcontractSizer   r   r   r   r   expiryexpiryDatetimestrike
optionType	precisiontickSize)amountpricelimitsminr  minPricemaxPrice)r  r  r  costcreatedrW  )safe_stringsafe_currency_codesplit	safe_boolr_  index_by	safe_dict	omit_zeror@   
string_divlen	string_gtparse_to_intr   safe_market_structurerD  safe_number))rE  rh  marketIdr  r  r  r  r  
marketTypeisSpotisSwapsuffixparts
secondPartr  rj  rS  r  isLinearr  	isInversefiltersListru  priceFilteramountFilter
costFilterminCostStringcontractSizeStringamountPrecisionStringamountMinLimitStringamountMaxLimitStringminLeveragemaxLeverager  firstarrayLengthlastminInitialMarginmaxInitialMargintradingFeesr   s)                                            rG  parse_marketzhashkey.parse_marketP  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: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	rH  c                    | j                  |      }| j                  |d      }i }t        dt        |            D ]  }||   }| j	                  |d      }| j                  |      }| j                  |d      }	| j                  |d      }
| j                  |d      }| j                  | j                  d      }i }t        dt        |            D ]  }||   }| j	                  |d      }| j	                  |||      }| j                  | j	                  |d	            }| j                  |d      }| j                  |d      }||| j                  |d
      | j                  |      d| j                  |d      ddd|xr |||| j                  |d      d|d	||<    ||d| j                  | j	                  |d            | j	                  |d      |	xr |
|
|	dddddddd||d||<    |S )a  
        fetches all available currencies on an exchange

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

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        coinsr   coinIdallowWithdrawallowDeposit
chainTypesr  	chainTypemaxWithdrawQuantityminWithdrawQuantityr  minDepositQuantityN)r   depositwithdrawFee)	rE   networkr  r  r  r   feer  rW  	tokenTypecoinFullName)r  r   )rE   coder  r  rF   r  r  r   r  r  r  rW  )r]  r_  ranger  r  r  r  r  r   r  r  rD  parse_currency_type)rE  rN  rO  r  resulticurrecy
currencyIdr  r  r  r  r  parsedNetworksjr  	networkIdnetworkNamer  networkDepositnetworkWithdraws                        rG  fetch_currencieszhashkey.fetch_currenciesW  s@    226:x18 q#e*% :	AAhG))'8<J**:6D NN7ODM>>'>BL~~g|<H>>$,,GL#%N1c(m, "1+ ,,WkB	"..|Y	R&*nnT5E5EgOd5e&f#!%!H"&../"J#* $(#3#3G=R#S#'#4#45H#I%
 $(#3#3G=Q#R#'$	 -@- /++G]C!%#%/{+8 !!001A1A';1WX((.A'8L')  $# 
  $#!	 ++F4LI:	v rH  c                 4    ddddd}| j                  ||      S )Ncryptofiat)CHAIN_TOKENERC20_TOKEN	BSC_TOKEN
REAL_MONEYr  rE  r  typess      rG  r  zhashkey.parse_currency_type  s*    ##! 	
 t,,rH  Nrj  r"  c                     | j                          | j                  |      }d|d   i}|||d<   | j                  | j                  ||            }| j	                  |d      }| j                  |||dd      S )aS  
        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
        rj  rE   r"  tba)load_marketsrh  publicGetQuoteV1Depthr^  rL  parse_order_book)rE  rj  r"  rN  rh  rc  rO  	timestamps           rG  fetch_order_bookzhashkey.fetch_order_book  s     	V$fTl
 $GG--dkk'6.JK  %%h4	$$Xvy#sKKrH  sincec                     | j                          | j                  |      }d|d   i}|||d<   | j                  | j                  ||            }| j	                  ||||      S )aD  
        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>`
        rj  rE   r"  )r  rh  publicGetQuoteV1Tradesr^  parse_trades)rE  rj  r  r"  rN  rh  rc  rO  s           rG  fetch_tradeszhashkey.fetch_trades  st     	V$fTl
 $GG..t{{7F/KL   65%@@rH  c                    d}| j                          i }d}|| j                  |      }d}| j                  |||      \  }}|||d<   |||d<   d}	| j                  ||d      \  }	}|	|	|d<   d}
| j                  ||d      \  }
}d}|dk(  r3||d	   |d
<   |
|
|d<   | j	                  | j                  ||            }n|dk(  rs|t        | j                  dz   |z   dz         |d	   |d
<   |
'|
|d<   | j                  | j                  ||            }nF| j                  | j                  ||            }n$t        | j                  dz   |z   dz   |z   dz         | j                  ||||      S )a  
        fetch all trades made by the user

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

        :param str symbol: *is mandatory for swap markets* unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: 'spot' or 'swap' - the type of the market to fetch trades for(default 'spot')
        :param int [params.until]: the latest time in ms to fetch trades for, only supports the last 30 days timeframe
        :param str [params.fromId]: srarting trade id
        :param str [params.toId]: ending trade id
        :param str [params.clientOrderId]: *spot markets only* filter trades by orderId
        :param str [params.accountId]: account id to fetch the orders from
        :returns Trade[]: a list of `trade structures <https://github.com/ccxt/ccxt/wiki/Manual#trade-structure>`
        r   NrQ   	startTimer"  untilendTime	accountIdrE   rj  rS    .() requires a symbol argument for swap marketssubAccountId() is not supported for  type of markets)r  rh  handle_market_type_and_paramshandle_option_and_paramsprivateGetApiV1AccountTradesr^  r,   rE   *privateGetApiV1FuturesSubAccountUserTrades privateGetApiV1FuturesUserTradesr8   r  )rE  rj  r  r"  rN  
methodNamerc  rh  r  r  r  rO  s               rG  fetch_my_tradeszhashkey.fetch_my_trades
  s   ( %
[[(F
!??
FTZ[
F#(GK $GG55fj'Rv!&GI	 99&*kZ	6!$*4L!$'0$88Wf9UVH< 6!~'#
(BEu(uvv &tGH$*3'JJ4;;W^`fKgh@@WV\A]^* tww}z9<VVYccfxxyy  65%@@rH  tradec                 t   | j                  |dd      }| j                  |d      }| j                  ||      }| j                  |d      }|!| j                  |j	                  d      d      }| j                  |d      }||rdnd	}d }| j                  |d
dg      }||rdnd}| j                  |d      }	|	d}|	rd	nd}| j                  |d      }
| j                  |d      }| j                  |d      }d }|$| j                  |d      }
| j                  |d      }|
#| j                  |
      | j                  |      d}| j                  | j                  |dd      || j                  |      |d   || j                  |dd      | j                  |g d      d |d | j                  |d      ||d|      S )Nr  timerj  side_r   isBuyerbuysellisMakerisMarkerr   r   ibm
commissioncommissionAssetr  	feeCoinIdr  currencyrE   tradeIdpr  )qqtyquantityorderId)rE   r  datetimerj  r  r  r  r  takerOrMakerr  orderr  rW  )safe_integer_2r  safe_marketsafe_string_lowerr  r  safe_bool_nr  rD  r  
safe_tradesafe_string_2iso8601safe_string_n)rE  r  rh  r  r  r  r  r#  r  isBuyerMakerfeeCostfeeCurrncyIdfeeInfor  s                 rG  parse_tradezhashkey.parse_tradet  s   l ''sF;	##E84!!(F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 
  	rH  r   c           	         d}| j                          d}| j                  ||d      \  }}|r| j                  d|||||d      S | j                  |      }| j	                  | j
                  ||      }|d   |d}	|||	d<   |||	d	<   d}
| j                  ||d
      \  }
}|
|
|	d<   | j                  | j                  |	|            }| j                  |||||      S )a  

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

        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest candle to fetch
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r   Fpaginater   rE   )rj  intervalNr  r"  r  r  )	r  r  "fetch_paginated_call_deterministicrh  r  r   publicGetQuoteV1Klinesr^  parse_ohlcvs)rE  rj  	timeframer  r"  rN  r
  r3  rh  rc  r  rO  s               rG  fetch_ohlcvzhashkey.fetch_ohlcv  s    "
88ZX&::<QVX]_hjprvwwV$$$T__iK	Tl!
 #(GK $GG55fj'Rv!&GI..t{{7F/KL"   69eUKKrH  c           	          | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )Nr   r      r      r   )rL  r  )rE  ohlcvrh  s      rG  parse_ohlcvzhashkey.parse_ohlcv  sn     eQ'UA&UA&UA&UA&UA&
 	
rH  c                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |di       }| j                  ||      S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

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

        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        rj  rE   r   )r  rh  publicGetQuoteV1Ticker24hrr^  r  parse_ticker)rE  rj  rN  rh  rc  rO  tickers          rG  fetch_tickerzhashkey.fetch_ticker%  sr     	V$fTl
 224;;w3OP" !R0  00rH  r[  c                     | j                          | j                  |      }| j                  |      }| j                  ||      S )a&  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

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

        :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        )r  market_symbolsr@  parse_tickers)rE  r[  rN  rO  s       rG  fetch_tickerszhashkey.fetch_tickersH  sC     	%%g.226:!!(G44rH  c                 0   | j                  |d      }| j                  |d      }| j                  ||      }|d   }| j                  |d      }| j                  i d|d|d| j	                  |      d| j                  |d      d	| j                  |d
      d| j                  |d      dd d| j                  |d      dd dd d| j                  |d      d|d|dd dd dd dd | j                  |d      | j                  |d      |d|      S )Nr  srj  cr  r"  highhlowlbidr  	bidVolumeaskr  	askVolumevwapopenocloser  previousClosechanger   averagevqv)
baseVolumequoteVolumerW  )rL  r  r&  safe_tickerr+  )rE  rB  rh  r  r  rj  r  s          rG  rA  zhashkey.parse_tickerW  s    %%fc2	##FC0!!(F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)!
* + 	rH  c                     | j                          | j                  |      }i }| j                  | j                  ||            }| j	                  ||      S )a  
        fetches the last price for multiple markets

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

        :param str[] [symbols]: unified symbols of the markets to fetch the last prices
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.symbol]: the id of the market to fetch last price for
        :returns dict: a dictionary of lastprices structures
        )r  rE  publicGetQuoteV1TickerPricer^  parse_last_pricesrE  r[  rN  rc  rO  s        rG  fetch_last_priceszhashkey.fetch_last_prices  sU     	%%g.33DKK4PQ %%h88rH  c                     | j                  |d      }| j                  ||      }|d   d d | j                  |d      d |dS )NrI  rj  r  )rj  r  r"  r  r  rW  )r  r&  r  )rE  entryrh  r  s       rG  parse_last_pricezhashkey.parse_last_price  sT    ##E3/!!(F3X&%%eS1
 	
rH  c                    | j                          i }d}d}| j                  |d||      \  }}|dk(  r5| j                  |      }| j                  |di       }| j	                  |      S |dk(  r2| j                  | j                  ||            }| j                  |      S t        | j                  dz   |z   dz   |z   dz         )	a,  
        query for balance and get the amount of funds available for trading or funds locked in orders

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

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

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

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

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

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

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

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

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

        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.network]: network for withdraw
        :param str [params.clientOrderId]: client order id
        :param str [params.platform]: the platform to withdraw to(hashkey, HashKey HK)
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        rE   )r}  r  r   Nr  r  )handle_withdraw_tag_and_paramsr  r  r~  r  privatePostApiV1AccountWithdrawr^  parse_transaction)
rE  r  r  r  r  rN  r  rc  r  rO  s
             rG  r   zhashkey.withdraw  s      99#vFV==&TN

 ?$'GL!"AA&IV"#'#:#:;#GGK 77GV8TU %%h99rH  c                 l   | j                  |dd      }| j                  |d      }| j                  |d      }|.| j                  |dd      }|rd}n| j                  |d      }|d}| j                  |d	      }| j                  |d
      }	| j                  |	|      }
| j	                  |d      }| j                  |d      }| j                  |d      }d }|||
d}i d|d|d|d|d| j                  |      dd d|dd dd dd dd dd dd d|d|
d| j                  |      dd d d |dS )NrE   r!  r  rS  successFrR  
addressUrltxIdr}  r  r   r  r  rW  txidr  r"  r  	addressToaddressFromr  tagTotagFromr  r  r  rT  )internalcommentr  )r*  r  r  r  rL  r  r+  parse_transaction_status)rE  transactionr  rE   r  rS  r  r  r  r}  r  r  r  r.  r  s                  rG  r  zhashkey.parse_transaction  s   R T9="";	:!!+x8>nn[)UCG!--k<H
)!FV4V4&&tX6%%k6:	!!+z:"";6 C
K
"
 D
 	

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

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

        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account id to transfer from
        :param str toAccount: account id to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.clientOrderId]: a unique id for the transfer
        :param str [params.remark]: a note for the transfer
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        rE   )r}  r   fromAccountIdtoAccountId)r  r  currency_to_precision$privatePostApiV1AccountAssetTransferr^  parse_transfer)	rE  r  r  r  r  rN  r  rc  rO  s	            rG  r   zhashkey.transferI  su     	==&TN224@($	
 <<T[[RX=YZ ""8X66rH  c           
          | j                  |d      }| j                  |d      }d }| j                  |dd      }|rd}| j                  |d      || j                  |      | j	                  ||      d d d ||d	S )Nr  rE   r  FrR  r!  )	rE   r  r"  r  r  r  r  rS  rW  )rL  r  r  r+  r  )rE  r   r  r  r  rS  r  s          rG  r  zhashkey.parse_transferk  s    %%h<	%%h5
..9e<F""8Y7"Y///
HE

 
	
rH  c                 h    | j                          | j                  |      }| j                  ||      S )al  
        fetch all the accounts associated with a profile

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

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
        )r  privateGetApiV1AccountTypeparse_accountsrM  s      rG  fetch_accountszhashkey.fetch_accounts~  s5     	226: ""8V44rH  c                     | j                  |d      }d}|dk(  s|dk(  rd}n|dk(  s|dk(  rd}| j                  | j                  |d	            }|d
z   |z   }| j                  |d      |d |dS )NaccountLabelrn  zMain Trading AccountzMain Future AccountmainzSub Main Trading AccountzSub Main Future AccountsubaccountTyper   r  )rE   r  r  rW  )r  parse_account_type)rE  ru  r  labelr  r  s         rG  parse_accountzhashkey.parse_account  s    ''@11\EZ5ZE77<Kd;dE--d.>.>w.VWs{[(""7K8	
 	
rH  c                 6    ddddd}| j                  |||      S )Nzspot accountzswap accountzcustody accountzfiat account)r  r  r  r  r  r  s      rG  r  zhashkey.parse_account_type  s,    "	
 tT22rH  c                 4    dddd}| j                  |||      S )Nr  r  r  )rQ   rS   custodyrL  r  s      rG  encode_account_typezhashkey.encode_account_type  s)    

   d33rH  c                 8    dddddd}| j                  |||      S )Nr  r  51900904)r  r  r   r  r   r  r  s      rG  encode_flow_typezhashkey.encode_flow_type  s/    
   d33rH  c                 @   d}|t        | j                  dz   |z   dz         d}| j                  ||d      \  }}|t        | j                  dz   |z   dz         | j                          | j	                  |      }i }||d<   |||d<   ||d	<   d}	| j                  ||d
      \  }	}|	| j                  |	      |d
<   d}
| j                  ||d      \  }
}|
| j                  |
      |d<   | j                  | j                  ||            }| j                  ||||      S )aN  
        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  r"  r  flowTyper  )
r,   rE   r  r  r  r  r  !privateGetApiV1AccountBalanceFlowr^  parse_ledger)rE  r  r  r"  rN  r
  r  r  rc  r  r  rO  s               rG  fetch_ledgerzhashkey.fetch_ledger  sV    #
=#DGGcMJ$>A_$_``55fj'Rv=#DGGcMJ$>A`$`aa==&$$GG"	88ZX&"&"7"7"AGJ";;FJP]^V"%)%=%=k%JGM"99$++gv:VW&   8UEBBrH  c                 8    dddddd}| j                  |||      S )Nr  r  r   r  r   )r  r  r  r  r  r  r  s      rG  parse_ledger_entry_typezhashkey.parse_ledger_entry_type  s/    
 tT22rH  itemc                 ~   | j                  |d      }| j                  |d      }| j                  |d      }| j                  | j                  |d            }| j                  |d      }| j                  ||      }| j	                  ||      }| j                  |d      }	| j                  |	      }
d}|	j                  d      d	k\  rd
}| j                  |d      }| j                  |      }d}| j                  i d|d|d|d| j                  |      d|d|dd dd d|d|dd d|
dd d|d|dd |      S )NrE   r  r  flowTypeValuer}  rX  inro  r   outrq  rR  rW  r  r"  ru  	directionreferenceIdreferenceAccountr  r  rj  r  beforeafterrS  r  )	r  rL  r  r  safe_currencyrD  findsafe_ledger_entryr+  )rE  r  r  rE   ru  r  r  r  r  amountStringr  r  afterStringr  rS  s                  rG  parse_ledger_entryzhashkey.parse_ledger_entry	  s     dD)""45%%dI6	++D,<,<T?,ST%%dF3
&&z8<%%j(;''h7""<0	S!Q&I&&tW5!!+.%% '
D'
"'
 '
 Y/	'

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

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

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

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

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

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

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or 'STOP'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of you want to trade in units of the base currency
        :param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately
        :param bool [params.reduceOnly]: True or False whether the order is reduce only
        :param float [params.triggerPrice]: The price at which a trigger order is triggered at
        :param str [params.timeInForce]: 'GTC', 'FOK', 'IOC', 'LIMIT_MAKER' or 'PO'
        :param str [params.clientOrderId]: a unique id for the order
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        )r  rh  r  privatePostApiV1FuturesOrderr^  r  )
rE  rj  r  r  r  r  rN  rh  rc  rO  s
             rG  r  zhashkey.create_swap_orderE
  si    & 	V$00tVUTZ[44T[[&5QR, &11rH  ordersc           	         | j                          g }t        dt        |            D ]  }||   }| j                  |d      }| j                  |d      }| j                  |d      }| j	                  |d      }	| j	                  |d      }
| j                  |di       }| j                  ||||	|
|      }| j                  |d      }|| j                         |d<   |j                  |        |d   }| j                  |d      }| j                  |      }d
|i}d	}|d   r"| j                  | j                  ||            }nK|d   r"| j                  | j                  ||            }n$t        | j                  dz   dz   |d   z   dz         | j                  |dg       }g }t        dt        |            D ]9  }| j                  ||i       }| j                  |di       }|j                  |       ; | j!                  |      S )aV  
        create a list of trade orders(all orders should be of the same symbol)

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

        :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
        :param dict [params]: extra parameters specific to the api endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r   rj  r  r  r  r  rN  r  Nr  rQ   rS   r   r  r  r  r$  )r  r  r  r  r  r  r  r  appendrh  privatePostApiV1SpotBatchOrdersr^  "privatePostApiV1FuturesBatchOrdersr8   rE   r_  parse_orders)rE  r  rN  ordersRequestsr  rawOrderrj  r  r  r  r  orderParamsorderRequestr  
firstOrderfirstSymbolrh  rc  rO  r  responseOrdersresponseEntryresponseOrders                          rG  create_orderszhashkey.create_orderss
  s.    	q#f+& 	0AayH%%h9F##Hf5D##Hf5D%%h9F$$Xw7E..8R@K44VT4QVXcdL ,,\?KM$04		_-!!,/	0 $A&
&&z8<[)n
 &>;;DKKQW<XYH8 F^>>t{{7TZ?[\HJ tww}/[[^dek^ll  pB   B  C  C(B7q#f+& 	1A NN61b9M NN='2FM!!-0	1   00rH  rE   c                 D   d}| j                  ||       | j                          i }| j                  |d      }|||d<   d}|| j                  |      }d}| j	                  ||||      \  }}d}	|dk(  r"| j                  | j                  ||            }	nz|dk(  rQd}
| j                  |||
      \  }
}|
rd|d	<   nd
|d	<   ||d   |d<   | j                  | j                  ||            }	n$t        | j                  dz   |z   dz   |z   dz         | j                  |	      S )az  
        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>`
        rY   r  Nr!  rQ   rS   Fr  r  r  rE   rj  r   r  r  )check_type_paramr  r  rh  r  privateDeleteApiV1SpotOrderr^   handle_trigger_option_and_paramsprivateDeleteApiV1FuturesOrderr8   rE   r  rE  rE   rj  rN  r
  rc  r  rh  r  rO  	isTriggers              rG  cancel_orderzhashkey.cancel_order
  sZ     #
j&1((A !#GI[[(F
!??
FTZ\fg
F77GV8TUH" 6!I $ E EfjZc dIv"(")!$*4L!::4;;wPV;WXH2 tww}z9<VVYccfxxyy))rH  c                    d}|t        | j                  dz   |z   dz         | j                          | j                  |      }d|d   i}| j	                  |d      }|||d<   d}|d   r"| j                  | j                  ||            }nN|d	   r"| j                  | j                  ||            }n't        | j                  dz   |z   d
z   |d   z   dz         | j                  |      }||d<   |gS )a  
        cancel all open orders

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

        :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.side]: 'buy' or 'sell'
        :returns dict: response from exchange
        rW   Nr   z() requires a symbol argumentrj  rE   r  rQ   rS   r  r  r  rW  )
r,   rE   r  rh  r   privateDeleteApiV1SpotOpenOrdersr^  $privateDeleteApiV1FuturesBatchOrdersr8   
safe_order)	rE  rj  rN  r
  rh  rc  r  rO  r$  s	            rG  cancel_all_orderszhashkey.cancel_all_orders4  s    '
>#DGGcMJ$>A`$`aaV$fTl
 /"GFO&><<T[[RX=YZH F^@@WV\A]^H
 tww}z9<VVY_`fYggj||}}) fwrH  idsc                    d}| j                          i }dj                  |      }||d<   d}|| j                  |      }d}| j                  ||||      \  }}d}	|dk(  r!| j	                  | j                  |            }	nJ|dk(  r!| j                  | j                  |            }	n$t        | j                  dz   |z   dz   |z   d	z         | j                  |	      }
|	|
d
<   |
gS )am  
        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>`
        rZ   ,r6  NrQ   rS   r   r  r  rW  )
r  joinrh  r  &privateDeleteApiV1SpotCancelOrderByIdsr^  )privateDeleteApiV1FuturesCancelOrderByIdsr8   rE   r4  )rE  r6  rj  rN  r
  rc  orderIdsrh  r  rO  r$  s              rG  cancel_orderszhashkey.cancel_orders]  s     $
88C=![[(F
!??
FTZ\fg
FBB4;;wCWXH 6!EEdkkRYFZ[Htww}z9<VVYccfxxyy) fwrH  c                 <   d}| j                  ||       | j                          i }d}| j                  |d      \  }}|||d<   d}|| j                  |      }d}| j	                  ||||      \  }}d}	|dk(  r)|||d<   | j                  | j                  ||            }	nj|dk(  rAd}
| j                  |||
      \  }
}|
rd	|d
<   | j                  | j                  ||            }	n$t        | j                  dz   |z   dz   |z   dz         | j                  |	      S )a  
        fetches information on an order made by the user

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

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

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

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

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

        :param str [symbol]: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve - default 500, maximum 1000
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.orderId]: the id of the order to fetch
        :param str [params.side]: 'buy' or 'sell' - the side of the orders to fetch
        :param str [params.accountId]: account id to fetch the orders from
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        fetchOpenSpotOrdersr
  Nr  r  rE   rj  r"  )r  r  r  'privateGetApiV1SpotSubAccountOpenOrdersr^  rh  privateGetApiV1SpotOpenOrdersr  )
rE  rj  r  r"  rN  r
  rh  rc  rO  r  s
             rG  rD  zhashkey.fetch_open_spot_orders  s    " 	*
!55flJW
F	 99&*kZ	6 &/GN#CCDKKPWY_D`aH!V,$*4L! #( 99$++gv:VWH:   65%@@rH  c                    d}| j                  |d|      \  }}|t        | j                  dz   |z   dz         | j                  |      }d|d   i}d}| j	                  |||      \  }}|rd	|d
<   nd|d
<   |||d<   d}	d}
| j                  ||d      \  }
}|
'|
|d<   | j                  | j                  ||            }	n!| j                  | j                  ||            }	| j                  |	|||      S )a  
 @ignore
        fetch all unfilled currently open orders for swap markets

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

        :param str symbol: *is mandatory* unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve - maximum 500
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.fromOrderId]: the id of the order to start from
        :param bool [params.trigger]: True for fetching trigger orders(default False)
        :param bool [params.stop]: an alternative for trigger param
        :param str [params.accountId]: account id to fetch the orders from
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        fetchOpenSwapOrdersr
  Nr   z4() requires a symbol argument for swap market ordersrj  rE   Fr  r  r  r"  r  r  )
r  r,   rE   rh  r,  r  *privateGetApiV1FuturesSubAccountOpenOrdersr^   privateGetApiV1FuturesOpenOrdersr  )rE  rj  r  r"  rN  r
  rh  rc  r/  rO  r  s              rG  rE  zhashkey.fetch_open_swap_ordersM  s/   $ +
!55flJW
F>#DGGcMJ$>Aw$wxxV$fTl
 	 AA&*V_`	6$GFO%GFO$GG	 99&*kZ	6 &/GN#FFt{{SZ\bGcdH<<T[[RX=YZHX   65%@@rH  c                 R   d}| j                  ||       | j                          i }|||d<   |||d<   d}| j                  ||d      \  }}|||d<   d}| j                  ||d      \  }}d}	|| j                  |      }	d}
| j	                  ||	||
      \  }
}d}|
dk(  r3|	|	d	   |d
<   |||d<   | j                  | j                  ||            }n|
dk(  r|t        | j                  dz   |z   dz         |	d	   |d
<   d}| j                  |||      \  }}|rd|d<   nd|d<   |'||d<   | j                  | j                  ||            }nF| j                  | j                  ||            }n$t        | j                  dz   |z   dz   |
z   dz         | j                  ||	||      S )a  
        fetches information on multiple canceled and closed orders made by the user

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

        :param str symbol: *is mandatory for swap markets* unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve - default 500, maximum 1000
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for - only supports the last 90 days timeframe
        :param str [params.type]: 'spot' or 'swap' - the type of the market to fetch entries for(default 'spot')
        :param str [params.orderId]: *spot markets only* the id of the order to fetch
        :param str [params.side]: *spot markets only* 'buy' or 'sell' - the side of the orders to fetch
        :param str [params.fromOrderId]: *swap markets only* the id of the order to start from
        :param bool [params.trigger]: *swap markets only* the id of the order to start from True for fetching trigger orders(default False)
        :param bool [params.stop]: *swap markets only* the id of the order to start from an alternative for trigger param
        :param str [params.accountId]: account id to fetch the orders from
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        rp   Nr"  r  r  r  r  rQ   rE   rj  rS   r   r  Fr  r  r  r  r  r  )r*  r  r  rh  r  privateGetApiV1SpotTradeOrdersr^  r,   rE   r,  -privateGetApiV1FuturesSubAccountHistoryOrders#privateGetApiV1FuturesHistoryOrdersr8   r  )rE  rj  r  r"  rN  r
  rc  r  r  rh  r  rO  r/  s                rG   fetch_canceled_and_closed_ordersz(hashkey.fetch_canceled_and_closed_orders  s   , 4
j&1$GG#(GK 55fj'Rv!&GI	 99&*kZ	6[[(F
!??
FTZ\fg
F!$*4L!$'0$::4;;wPV;WXH< 6!~'#
(BEu(uvv &tGHI $ E EfjZc dIv"(")$*3'MMdkkZaciNjkCCDKKPWY_D`a6 tww}z9<VVYccfxxyy  65%@@rH  c                     | j                  |d      }|0|dk7  r*|dk7  r$t        | j                  dz   |z   dz   |z   dz         y y y )Nr  rQ   rS   r   z() type parameter can not be "z". It should define the type of the market("spot" or "swap"). To define the type of an order use the trigger parameter(True for trigger orders))r  r-   rE   )rE  r
  rN  
paramsTypes       rG  r*  zhashkey.check_type_param  so     %%ff5
"v)=JRXDXTWWs]Z7:ZZ]gg  k|  |  }  } EY)="rH  rN  r
  c                 >    |}| j                  ||dd|      \  }}||gS )Nstopr&  )handle_option_and_params_2)rE  rN  r
  defaultValuer/  s        rG  r,  z(hashkey.handle_trigger_option_and_params%  s2     	 ;;FJPVXaclm	66""rH  r$  c                    | j                  |d      }| j                  ||      }| j                  |dd      }| j                  |d      }| j                  |d      }| j                  |d      }|dk(  rd}| j                  | j                  |d	            }|d
k(  r|d}nd}| j                  |d      }	d }
| j	                  ||	      \  }}	}
| j                  | j                  |d            }||}| j                  |d      }d }| j                  |      \  }}| j                  |d      }|dk(  rd }| j                  i d| j                  |d      d| j                  |d      d| j                  |      d|dd d| j                  |d      d| j                  |      d|d   d|d|	d|d	|d|d| j                  | j                  |d            d| j                  |d      dd d| j                  | j                  |d             d d | j                  | j                  |d!d"            d | j                  |      | j                  | j                  |d#            d$||
|d%|      S )&Nrj  transactTimer  rS  r  r  r  rh  r  r  r"  r  avgPricer  feeCoinrn  rE   r!  r  r"  r  lastTradeTimestamplastUpdateTimestamp
updateTimerY  r  origQtyfilledexecutedQty	remainingr  r  cumulativeQuoteQtycummulativeQuoteQty	feeAmount)r  r  )r  r  r  tradesr  r  r  rW  )r  r&  r%  r  ,parse_order_type_time_in_force_and_post_onlyr'   parse_order_side_and_reduce_onlyr4  r+  rL  parse_order_statusr*  r  )rE  r$  rh  r  r  rS  r  r  r  r  r  rY  r  r  r/  s                  rG  r  zhashkey.parse_order*  s   \ ##E84!!(F3''~vF	!!%2v.$$UK8	 Dt//w?@6>}&&um<&*&W&WX\^i&j#k8..!1!1%!DE=E%%eV4
@@Fj''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 
: ; 	rH  c                     |j                  d      }|d   }d }| j                  |d      }||dk(  rd}||gS |dk(  rd}||gS )Nr  r   r   rT  FrV  T)r  r  )rE  unparsedr  r  r  r  s         rG  rj  z(hashkey.parse_order_side_and_reduce_only  sj    s#Qx
%%eQ/
!V#"
 j!! '!
j!!rH  c           
      @    dddddddddd	}| j                  |||      S )NrT  canceledclosedrejected)	NEWPARTIALLY_FILLEDPARTIALLY_CANCELEDFILLEDCANCELEDORDER_CANCELEDPENDING_CANCELREJECTED	ORDER_NEWr  r  s      rG  rk  zhashkey.parse_order_status  s;     &","(("

 &&99rH  c                 ^    d }|dk(  rd}n|dk(  s|dk(  rd}d}| j                  |      }|||gS )Nr  TMAKERr  )parse_order_type)rE  r  r  r  s       rG  ri  z4hashkey.parse_order_type_time_in_force_and_post_only  sJ    = H]*w0FHK$$T*k8,,rH  c                 6    ddddd}| j                  |||      S )Nrh  r"  )r  r  r  MARKET_OF_BASEr  r  s      rG  r}  zhashkey.parse_order_type  s,    "&	
 tT22rH  c                     | j                          | j                  |      }|d   | j                         d}| j                  | j	                  ||            }| j                  |di       }| j                  ||      S )aq  
        fetch the current funding rate

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

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
        rE   )rj  r  r   )r  rh  milliseconds publicGetApiV1FuturesFundingRater^  r  parse_funding_rate)rE  rj  rN  rh  rc  rO  rates          rG  fetch_funding_ratezhashkey.fetch_funding_rate  s|     	V$Tl**,
 88Wf9UV ~~h2.&&tV44rH  c                     | j                          | j                  |      }d| j                         i}| j                  | j	                  ||            }| j                  ||      S )a  
        fetch the funding rate for multiple markets

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

        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
        r  )r  rE  r  r  r^  parse_funding_ratesrb  s        rG  fetch_funding_rateszhashkey.fetch_funding_rates  sg     	%%g.**,
 88Wf9UV '''::rH  c                 ,   | j                  |d      }| j                  ||d d      }| j                  |d      }| j                  |d      }i d|d|d   dd dd dd d	d d
d dd d|dd dd dd d|d| j	                  |      dd dd dd dd iS )Nrj  rS   r  nextSettleTimerW  	markPrice
indexPriceinterestRateestimatedSettlePricer  r"  fundingRatefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimer4  )r  r&  r  rL  r+  )rE  r  rh  r  r  r  s         rG  r  zhashkey.parse_funding_rate/  s@    ##Hh7!!(FD&A&&x8,,X7GH
H
fX&
 
 $	

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

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

        :param str symbol: unified symbol of the market to fetch the funding rate history for
        :param int [since]: timestamp in ms of the earliest funding rate to fetch
        :param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.fromId]: the id of the entry to start from
        :param int [params.endId]: the id of the entry to end with
        :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
        Nz5 fetchFundingRateHistory() requires a symbol argumentrj  rE   r"  r   
settleTimerS   
settleRate)rW  rj  r  r  r"  r  )r  r,   rE   rh  'publicGetApiV1FuturesHistoryFundingRater^  r  r  rL  r  safe_symbolr  r  r+  sort_byfilter_by_since_limit)rE  rj  r  r"  rN  rh  rc  rO  ratesr  re  r  sorteds                rG  fetch_funding_rate_historyz"hashkey.fetch_funding_rate_historyP  s/    	>#DGG.e$effV$fTl
 $GG??GU[@\] q#h-( 		AQKE))%>ILL**4+;+;E8+LfVZ\bc#//|D& LL3 		 e[1))&%??rH  c                    d}|t        | j                  dz   |z   dz         t        |      }|dk7  rt        | j                  dz   |z   dz         | j	                          | j                  |d   | j                  ddi|            S )a5  
        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   r   z;() requires a symbol argument with one single market symbolr   zH() is supported for a symbol argument with one single market symbol onlyr   r
  )r,   rE   r  r8   r  fetch_positions_for_symbolr^  )rE  r[  rN  r
  symbolsLengths        rG  fetch_positionszhashkey.fetch_positions  s     &
O#DGGcMJ$>A~$~LM!"477S=:#=  AK  $K  L  L..wqz4;;VfGgio;pqqrH  c                 0   | j                          | j                  |      }d}| j                  |d|      \  }}|d   st        | j                  dz   |z   dz         d|d   i}| j                  | j                  ||            }| j                  ||g      S )a?  
        fetch open positions for a single market

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

        fetch all open positions for specific symbol
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.side]: 'LONG' or 'SHORT' - the direction of the position(if not provided, positions for both sides will be returned)
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
        r   r
  rS   r   z() supports swap markets onlyrj  rE   )r  rh  r  r8   rE   privateGetApiV1FuturesPositionsr^  parse_positions)rE  rj  rN  rh  r
  rc  rO  s          rG  r  z"hashkey.fetch_positions_for_symbol  s     	V$$
!55flJW
Ff~tww}z9<[[\\fTl
 77GV8TU, ##Hvh77rH  positionc                 X   | j                  |d      }| j                  ||      }|d   }| j                  i d|dd dd dd d| j                  |d      dd d| j	                  |d      d	| j                  |d
      d| j                  |d      d| j                  |d      d| j                  |d      dd d| j                  |d      dd d| j                  |d      dddd| j                  |d      d | j                  |d      d d d | j                  |d      d d d |d      S )Nrj  rE   r  r"  r\  r  r  r  notionalpositionValuer  unrealizedPnlunrealizedPnLrealizedPnlrealizedPnL
collateral
entryPricer\  r  liquidationPricer  crossr  T	minMarginrR   	lastPrice)maintenanceMarginmaintenanceMarginPercentager  initialMarginPercentagemarginRatior_  r  r  r  r   rW  )r  r&  safe_positionr  r'  rL  )rE  r  rh  r  rj  s        rG  parse_positionzhashkey.parse_position  s   ##Hh7!!(F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#
  	rH  c                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |di       }| j                  ||      S )ar  
        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>`
        rj  rE   r   )r  rh  privateGetApiV1FuturesLeverager^  r  parse_leverage)rE  rj  rN  rh  rc  rO  r  s          rG  fetch_leveragezhashkey.fetch_leverage  sr     	V$fTl
 66t{{7F7ST >>(Ar2""8V44rH  r  c                 `    | j                  |d      }| j                  |d      }||d   |||dS )N
marginTyper  rj  )rW  rj  r  longLeverageshortLeverage)r'  r  )rE  r  rh  r  leverageValues        rG  r  zhashkey.parse_leverage  sD    ++HlC
((:>X&$)*
 	
rH  c                     |t        | j                  dz         | j                          d|i}| j                  |      }|d   |d<   | j	                  | j                  ||            }| j                  ||      S )a}  
        set the level of leverage for a market

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

        :param float leverage: the rate of leverage
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        z) setLeverage() requires a symbol argumentr  rE   rj  )r,   rE   r  rh  privatePostApiV1FuturesLeverager^  r  )rE  r  rj  rN  rc  rh  rO  s          rG  set_leveragezhashkey.set_leverage  s     >#DGG.Y$YZZ
 V$"4L77GV8TU ""8V44rH  c                     | j                          | j                  |      }| j                  |dg       }| j                  |      }| j	                  ||d      S )a  
        retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes

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

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

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

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
        r   NrQ   rS   rj  rE   r   r  r  r  )	r  rh  fetch_trading_feesr  $privateGetApiV1FuturesCommissionRater^  parse_trading_feer8   rE   )rE  rj  rN  rh  r
  rO  s         rG  fetch_trading_feezhashkey.fetch_trading_fee  s     	V$&
&>..v6H>>(F33F^@@hX^_cXdMegmAnoH))(F;; tww}z9<VVY_`fYggj||}}rH  c                     | j                          | j                  |      }| j                  |dg       }i }t        dt	        |            D ].  }| j                  ||i       }| j                  |      }|||d   <   0 |S )am  
        *for spot markets only* fetch the trading fees for multiple markets

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

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
        r  r   rj  )r  privateGetApiV1AccountVipInfor_  r  r  r  r  )rE  rN  rO  r  r  r  r  	parsedFees           rG  r  zhashkey.fetch_trading_fees  s     	55f=. ~~h3q#d)$ 	4A..q"-C..s3I*3F9X&'	4 rH  r  c                     | j                  |d      }| j                  ||      }||d   | j                  |dd      | j                  |dd      dddS )Nrj  openMakerFeeactualMakerRateopenTakerFeeactualTakerRateT)rW  rj  r   r   r   r   )r  r&  safe_number_2)rE  r  rh  r  s       rG  r  zhashkey.parse_trading_fee  si    , ##C2!!(F3X&''^=NO''^=NO
 	
rH  r   GETc                 ,   | j                   d   |   dz   |z   }d }|dk(  r| j                          | j                         }	d|	i}
| j                  | j                  d      }|||
d<   | j
                  dd}d }|dk(  r|d	k(  s|d
k(  rd|d<   | j                  | j                  |d            }| j                  | j                  | j                  |
            | j                  | j                        t        j                        }| j                  | j                  |
d|i            }|d|z   z  }n| j                  |
|      }| j                  | j                  | j                  |            | j                  | j                        t        j                        }||d<   | j                  |      }|dk(  r	|d|z   z  }n|}| j                  | j                  dd      |d<   ||d<   n'| j!                  |      }t#        |      dk7  r|d|z   z  }||||dS )Nr   rs  r   r  r  z!application/x-www-form-urlencoded)zX-HK-APIKEYContent-TypePOSTr   r   zapplication/jsonr  r  	signature?r  r  r   zINPUT-SOURCEbroker_signr   )rV  methodbodyheaders)r   check_required_credentialsr  rL  r   apiKeyjsonr_  hmacencodecustom_urlencodesecrethashlibsha256r^  r  	urlencoder  )rE  pathr   r  rN  r  r  rV  queryr  additionalParamsr  r  totalParamss                 rG  signzhashkey.sign  s0   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*:FC IIdkk$2G2G2T&UW[WbWbcgcncnWoqxqq  A	+4K(--k:U?3;&C D&*&6&6t||X}&]GN#%.GM"NN6*E5zQsU{"fdwOOrH  c                 L    | j                  |      }|j                  dd      }|S )Nz%2Cr8  )r  replace)rE  rN  r  s      rG  r  zhashkey.custom_urlencode/  s%    's+rH  c
                    |y d}
| j                  |dd       }| j                  |dd       }|dk(  rk| j                  |dg       }t        dt	        |            D ]@  }| j                  ||      }| j                  |d      }|dk7  s-d}
| j                  |d      }B |dk7  s|
r]| j                  dz   |z   }| j                  | j                  d   ||       | j                  | j                  d	   ||       t        |      y )
NFr  r   r  T   r   r?  r>  )r  rL  r_  r  r  r  rE   throw_broadly_matched_exceptionr.  throw_exactly_matched_exceptionr'   )rE  r  reasonrV  r  r  r  rO  requestHeadersrequestBodyerrorInArrayresponseCodeStringresponseCodeIntegerr  r  re  entryCodeIntegerfeedbacks                     rG  handle_errorszhashkey.handle_errors4  s   !--hE"//&$G!#^^Hh;F1c&k* Ivq1#'#4#4UF#C #q(#'L)-)9)9%)H&I CKLww}t+H001IK]_gh001IK]_gh))rH  )N)y__name__
__module____qualname__r   rC  r   rP  rY  r&   r   rg  dictr  r	   r  r  strr   r  r!   r  r   r  r1  listr9  r>  r   rC  r   r   rG  rA  r   rc  r   rf  r   rm  rk  ri  r   r  r
   r  r$   r  r  floatr   r  r  r%   r   r  r   r  r  r  r  r  r   r  r  r  r   r   r   r   r  r  r  r  r  r  r  r   r(  r0  r5  r=  rB  rF  rD  rE  rS  r*  objectr,  r  rj  rk  ri  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  __classcell__)rF  s   @rG  rB   rB   '   s)	   }# }~ !# 9s 9" #% 
* $& @+$v, @+DE4 EF EN ') bZ bH- :>b #Ls #L3 #LY #LJ 6:UW A3 As A# A\`af\g AB -1tRV_a hAc hA hAC hATb bv b bH 26DW[df 4L# 4Lc 4LQT 4Lkoptku 4Ll
 
4 
. 02 !13 !1f !1F 04B 5W 57 5)6 )V )V 48 9 9z 94

f 

	 

 $& 4z( 4zl) )@)X )0 79 $# $^ $L
h 
R` 
4 *.Dt\^ ,^3 ,^c ,^ ,^cghsct ,^\ -1tRV_a 2ac 2a 2aC 2afjkvfw 2ah DHPR ':S ':% ':# ':Wb ':RU
x U
; U
n:" []  7S  7%  7c  7c  7an  7D
 
& %' 54= 50
 344 (,$TZ\ 8C 8CC 8Cs 8Caefqar 8Ct30t 0x 0; 0d gksu w3 wi wy wRW w`c wz w> RT ` `5 `X] `" lpxz t2 t29 t2I t2W\ t2eh t2  @E 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 lpxz ,2 ,29 ,2I ,2W\ ,2eh ,2  @E ,2\ @B k1D$6 k1Z 37r R*s R*C R*h /32 ' 'R ;?r &c &C &P 26b _*c _*3 _*U _*B /3TXac $z $z3 $zc $zhlmrhs $zL 48dY]fh ?AS ?A ?ASV ?Amqrwmx ?AB 48dY]fh UAS UA UASV UAmqrwmx UAn >BPTcgpr wAs wA# wA]` wAw{  }B  xC wAr}#v #3 #
e ev e eN
":-3 68 5 5K 52 6:" ;7 ; ;0
6 
[ 
B 8<$]ajl /@ /@C /@WZ /@b 26b rw rT(^ r, >@ +8 +8DN +8Z!t !V !F 24 5S 5 58	
t 	
V 	
x 	
 9=R 5S 5# 5: 7;2 BG B- B"_ _$|J\ _B 57 ~ ~;N ~@ )+ '{ 'R
T 
6 
EX 
B &eBSW &PP /1 t S 
rH  rB   )Gccxt.base.exchanger   ccxt.abstract.hashkeyr   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   typingr&   ccxt.base.errorsr'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   ccxt.base.decimal_to_precisionr?   ccxt.base.preciser@   rB    rH  rG  <module>r     s    ( -  {  {  {  {  {  {  {  {  {  * 0 - . - . ' & . . + ) * 5 - - 0 ) , + . 1 ) + 4 %`@h `@rH  