
    E#i                       S SK Jr  S SKJr  S SKrS SKrS SKJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%  S SK&J'r'  S SK(J)r)  S SK(J*r*  S SK(J+r+  S S	K(J,r,  S S
K(J-r-  S SK(J.r.  S SK(J/r/  S SK(J0r0  S SK(J1r1  S SK(J2r2  S SK(J3r3  S SK(J4r4  S SK(J5r5  S SK(J6r6  S SK(J7r7  S SK(J8r8  S SK9J:r:  S SK9J;r;  S SK<J=r=   " S S\\5      r>g)    )Exchange)ImplicitAPIN)AccountAnyBalancesBorrowInterest
CurrenciesCurrencyDepositAddressIntIsolatedBorrowRateIsolatedBorrowRatesLedgerEntryLeverageTierLeverageTiersMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTradingFeeInterfaceTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountNotEnabled)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)OperationFailed)RateLimitExceeded)ExchangeNotAvailable)OnMaintenance)RequestTimeout)TRUNCATE)	TICK_SIZE)Precisec                      ^  \ rS rSrS\4U 4S jjr0 4S jr0 4S\4S jjrSS\	S\
S\4S	 jjr0 4S
\S\4S jjrS0 4S\4S jjr0 4S\4S jjrS0 4S
\4S jjrS r0 4S\\
   4S jjr0 4S\S\4S jjrS\4S jrSS\	S\
S\4S jjr0 4S
\S\4S jjrS0 4S\S\4S jjrS0 4S\4S jjrSS\
4S jjrS0 4S
\S\S\ 4S jjr!SS \	S\
S\"4S! jjr#SSS0 4S\S
\S"\S\4S# jjr$SSS0 4S\S
\S"\S\4S$ jjr%SSS0 4S
\S"\S\4S% jjr&SS&0 4S
\S"\S\S\\"   4S' jjr'SS\
S\(4S( jjr)S)SS0 4S
\S*\S"\S\S\\(   4
S+ jjr*0 4S\\+   4S, jjr,S- r-SS0 4S\S.\S
\4S/ jjr.0 4S\/4S0 jjr0SS1\S2\4U 4S3 jjjr1SS4\S2\4U 4S5 jjjr20 4S\34S6 jjr4S0 4S\S
\4S7 jjr5S8 r6SSS0 4S
\S"\S\4S9 jjr7SSS0 4S
\S"\S\4S: jjr8SSS0 4S
\S"\S\4S; jjr9SSS0 4S
\S"\S\4S< jjr:SSS0 4S
\S"\S\4S= jjr;SSS0 4S
\S"\S\S\\<   4S> jjr=SSS0 4S
\S"\S\S\\<   4S? jjr>SSS0 4S
\S"\S\S\\<   4S@ jjr?SA\4SB jr@SSC\	S\
S\<4SD jjrA0 4S
\SE\B4SF jjrCSSS0 4S
\S\DSG\ESH\BSI\FSJ\FSK\FS\<4SL jjrGS0 4S
\S\DSG\ESH\BSI\F4
SM jjrHS0 4S
\S\DSG\ESH\BSI\F4
SN jjrIS0 4S
\S\DSG\ESH\BSI\F4
SO jjrJ0 4SP\\K   4SQ jjrLS0 4S\S
\4SR jjrMS0 4SS\\   S
\4ST jjrNSU rOS0 4S
\4SV jjrP0 4SW\4SX jjrQSSY\R4SZ jjrS0 4S[\S\\T   4S\ jjrU0 4S[\S\T4S] jjrVSS0 4S[\4S^ jjrWSSS0 4S[\S"\S\S\\X   4S_ jjrYSSS0 4S[\S"\S\S\\X   4S` jjrZSSa\	SY\RS\X4Sb jjr[SA\4Sc jr\S0 4S[\SH\BSd\Se\S\X4
Sf jjr]SSg\	SY\RS\^4Sh jjr_0 4S[\SH\BSi\Sj\S\^4
Sk jjr`0 4S\a4Sl jjrbSSm\	S\
S\c4Sn jjrdSSS0 4S
\S"\S\4So jjreSS\
S\f4Sp jjrgSq rh0 4S
\S\f4Sr jjriS0 4S\S\j4Ss jjrkSSSS0 4S[\S
\S"\S\S\\l   4
St jjrmSSm\	S\
S\l4Su jjrnSv roSwSx0 SS4Sy jrpSz\qS{\S|\S}\S~\	S\4S jrrSSS0 4S
\S"\S\4S jjrsS0 4S\qS
\4S jjrtSS\
4S jjruSS\	S\
4S jjrvS0 4S\S\\w   4S jjrx0 4S
\4S jjryS rzSS\	SY\RS\{4S jjr|SSS0 4S[\S"\S\S\\{   4S jjr}S0 4S\S\~4S jjrSS\
S\\   4S jjrSSS0 4S
\S"\S\4S jjrS0 4S\4S jjr0 4S
\4S jjrSS\
4S jjr0 4S
\S[\SH\B4S jjr0 4S[\SH\B4S jjr0 4S
\S[\4S jjr0 4S[\4S jjrSSY\R4S jjrSSS0 4S
\S"\S\4S jjrS0 4S\4S jjrSSY\R4S jjrS rS rSS0 4S
\S"\S\4S jjrSS\
4S jjrS0 4S
\SG\ES\<4S jjrS0 4S\S
\4S jjrSrU =r$ )htx!   returnc                    > U R                  [        [        U ]  5       0 SS_SS_SS/_SS_S	U R                  S
   _SS_SS_SS_SS_S0 SS _SS_SS_SS_SS_SS _SS _SS_SS_SS_SS_SS_SS_S S!_S"S_S#S _S$S_0 S%S!_S&S!_S'S_S(S_S)S!_S*S_S+S_S,S_S-S_S.S_S/S_S0S_S1S_S2S_S3S _S4S_S5S _E0 S6S _S7S _S8S _S9S_S:S!_S;S!_S<S_S=S _S>S_S?S _S@S_SAS_SBSC_SDS_SES_SFS_SGS_E0 SHS_SIS_SJS!_SKS_SLS _SMS_SNS_SOS _SPS!_SQS_SRS_SSS!_STSC_SUS_SVS_SWS!_SXS_E0 SYS_SZS_S[S_S\S_S]S _S^S_S_S_S`S_SaS _SbS_ScS_SdS_SeSC_SfS_SgS!_ShS!_SiS_E0 SjS_SkS_SlS_SmS_SnS_SoS_SpS_SqS!_SrS_SsS _StS _SuS _SvS _SwS_SxS _SyS_SzS _ES SSSS!SS SSS{.	E_S|S}S~SSSSSSSSS.
_SSSSSSSS.SSS.S.S.SSSSSSSS.SSSS./ SQSS._SSSSS.00 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSSSS.E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSS.ES.SSSSSSS.00 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSS.E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSS.ES.SSSS00SSS00SSS00S.SSS00SSS00S.S.0S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSGS .E00 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GS	S_GS
S_SS_GSS_GSS_GSS_GSS_GSS_GSS_0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GS S_GS!S_ESSSSSSSSSSSSGS".E0 GS#S_GS$S_GS%S_GS&S_GS'S_GS(S_GS)S_GS*S_GS+S_GS,S_GS-S_GS.S_GS/S_GS0S_GS1S_GS2S_GS3S_0 GS4S_GS5S_GS6S_GS7S_GS8S_GS9S_GS:S_GS;S_GS<S_GS=S_GS>S_GS?S_GS@S_GSAS_GSBS_GSCS_GSDS_ESSSSSSGSE.ES.GSF.S0 GSGS_GSHS_GSIS_GSJS_GSKS_GSLS_GSMS_GSNS_GSOS_GSPS_SS_GSQS_SS_GSRS_GSSS_GSTS_GSUS_0 GSVS_GSWS_GSXS_GSYS_GSZS_GS[S_GS\S_GS]S_GS^S_GS_S_GS`S_GSaS_GSbS_GScS_GSdS_GSeS_GSfS_E0 GSgS_GShS_GSiS_GSjS_GSkS_GSlS_GSmS_GSnS_GSoS_GSpS_GSqS_GSrS_GSsS_GStS_GSuS_GSvS_GSwS_E0 GSxS_GSyS_GSzS_GS{S_GS|S_GS}S_GS~S_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_ESSSSSSSSSSSSSSGS.E0SSSSSSSSSSSSGS.0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSGS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSGS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GS S_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GS	S_GS
S_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_E0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GS S_GS!S_GS"S_GS#S_GS$S_E0 GS%S_GS&S_GS'S_GS(S_GS)S_GS*S_GS+S_GS,S_GS-S_GS.S_GS/S_GS0S_GS1S_GS2S_GS3S_GS4S_GS5S_E0 GS6GS_GS7GS_GS8S_GS9S_GS:S_GS;S_GS<S_GS=S_GS>S_GS?S_GS@S_GSAS_GSBS_GSCS_GSDS_GSES_GSFS_E0 GSGS_GSHS_GSIS_GSJS_GSKS_GSLS_GSMS_GSNS_GSOS_GSPS_GSQS_GSRS_GSSS_GSTS_GSUS_GSVS_GSWS_E0 GSXS_GSYS_GSZS_GS[S_GS\S_GS]S_GS^S_GS_S_GS`S_GSaS_GSbS_GScS_GSdS_GSeS_GSfS_GSgS_GShS_ESSSSSSSSSSSSSGSi.ES.GSF.GSj._GSkGSlSS!SU R                  GSm5      U R                  GSm5      GSn.0_GSo[        [        [        GSp.0 GSq[        _GSr[        _GSs[        _GSt[        _GSu[        _GSv[        _GSw[        _GSx[        _GSy[        _GSz[        _GS{[        _GS|[        _GS}[        _GS~[        _GS[        _GS[        _GS[        _0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[         _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _E0 GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS[         _GS[        _GS[        _GS[        _GS[        _GS[        _GS[        _GS["        _GS[        _E[        [        [        [        [        [        [        ["        GS.EGS._GS[$        _GS0 GSS!_SUGSSSSGS.0_GSGS_GSS!_SYGSS0_GSGSS!0_GSS_GSGS_GSGS_GSGSGSGSGS._GS0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_E0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_E0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GS GS _GSGS_E0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GS	GS	_GS
GS
_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_E0 GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GSGS_GS GS _GS!GS!_GS"GS"_GS#GS#_E0 GS$GS$_GS%GS%_GS&GS&_GS'GS'_GS(GS(_GS)GS)_GS*GS*_GS+GS+_GS,GS,_GS-GS-_GS.GS._GS/GS/_GS0GS0_GS1GS1_GS2GS2_GS3GS3_GS4GS4_E0 GS5GS5_GS6GS6_GS7GS7_GS8GS8_GS9GS9_GS:GS:_GS;GS;_GS<GS=_GS>GS>_GS?GS@_GSAGSB_GSCGSC_GSDGSD_GSEGSE_GSFGSF_GSGGSG_GSHGSH_E0 GSIGSI_GSJGSJ_GSKGSK_GSLGSL_GSMGSM_GSNGSO_GSPGSP_GSQGSQ_GSRGSR_GSSGSS_GSTGST_GSUGSU_GSVGSV_GSWGSW_GSXGSX_GSYGSY_GSZGSZ_E0 GS[GS[_GS\GS\_GS]GS]_GS^GS^_GS_GS__GS`GS`_GSaGSa_GSbGSb_GScGSc_GSdGSd_GSeGSf_GSgGSg_GShGSh_GSiGSi_GSjGSj_GSkGSk_GSlGSl_EGSmGSnGSo.E_GSpGSq_GSrS_GSsGSt_GSuSGSv0_GSwSSGSxGSy._GSzSSGS{GS|GS}GS~GSGSGSGSGS.
_SSGS.SSSSSSGS.0 GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS_GSS0EGS.GS.E_GSGSGSGSGSGSGSGSGSGS.	SSSSS S!S!S SSSS!GS.S!S!S!SSSSGS.GSS0S!GSGSGSS!GS.S!S!S!S!GS.S!SS!GSS!GS.S!SS!GSGSGSS!GS.S!SS!GSGSGSGSS!GS.GSGS0GS.	SSSSSGS.GSGS0GSS0SS!S!SGS.SS!S!SGSGS.SS!S!GSSGSGSGS.GSGS0GS.GSGS0GSGS0GS.GSGS0GSGS0GS.GS.GS.E5      $ (  Nidr9   nameHTX	countriesCN	rateLimitd   	userAgent	chrome100	certifiedTversionv1hostnamezapi.huobi.proprohasCORSspotmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMargincancelAllOrderscancelAllOrdersAftercancelOrdercancelOrderscloseAllPositionsFclosePositioncreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateOrderscreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingPercentOrdercreateTriggerOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL3OrderBookfetchLastPricesfetchLedgerfetchLedgerEntryfetchLeveragefetchLeverageTiersfetchLiquidationsfetchMarginAdjustmentHistoryfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMyLiquidationsfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionsfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTradingLimitsfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransfersfetchWithdrawAddressesfetchWithdrawalfetchWithdrawalsfetchWithdrawalWhitelist)	reduceMarginrepayCrossMarginrepayIsolatedMarginsetLeveragesetMarginModesetPositionModesignIntransferwithdraw
timeframes1min5min15min30min60min4hour1day1week1mon1year)
1m5m15m30m1h4h1d1w1M1yurlszchttps://user-images.githubusercontent.com/1294454/76137448-22748a80-604e-11ea-8069-6e389271911d.jpgzapi.hbdm.comzstatus.huobigroup.comzstatus-dm.huobigroup.comz!status-linear-swap.huobigroup.com)inverselinearzstatus-swap.huobigroup.com)rM   rP   rO   )contractrM   statuszhttps://{hostname})r   r   rM   publicprivatev2Public	v2Privatezhttps://www.huobi.comz;https://www.htx.com.vc/invite/en-us/1h?invite_code=6rmm2223g333333?)urldiscount)z+https://huobiapi.github.io/docs/spot/v1/en/z)https://huobiapi.github.io/docs/dm/v1/en/z9https://huobiapi.github.io/docs/coin_margined_swap/v1/en/z0https://huobiapi.github.io/docs/usdt_swap/v1/en/z.https://www.huobi.com/en-us/opend/newApiPages/z https://www.huobi.com/about/fee/)logo	hostnamesapiwwwreferraldocfeesr   get   )zreference/currencieszmarket-statuszaccount/ledgerzaccount/withdraw/quotazaccount/withdraw/addresszaccount/deposit/addresszaccount/repayment   zreference/transact-fee-ratezaccount/asset-valuationg?zpoint/accountzsub-user/user-listzsub-user/user-statezsub-user/account-listzsub-user/deposit-addresszsub-user/query-depositzuser/api-keyzuser/uidzalgo-orders/openingzalgo-orders/history)zalgo-orders/specificz
c2c/offers	c2c/offerzc2c/transactionsc2c/repaymentzc2c/accountzetp/referencezetp/transactionszetp/transactionzetp/rebalancez	etp/limitzaccount/transferzpoint/transferzsub-user/managementzsub-user/creationzsub-user/tradable-marketzsub-user/transferabilityzsub-user/api-key-generationzsub-user/api-key-modificationzsub-user/api-key-deletionzsub-user/deduct-modezalgo-orderszalgo-orders/cancel-all-afterzalgo-orders/cancellationr   zc2c/cancellationzc2c/cancel-all
   2   )r   zc2c/transferzetp/creationzetp/redemptionzetp/{transactId}/cancelzetp/batch-cancel)r   post)zcommon/symbolszcommon/currencyszcommon/timestampzcommon/exchangezsettings/currencyszaccount/accountszaccount/accounts/{id}/balancezaccount/accounts/{sub-uid}zaccount/history   zcross-margin/loan-infozmargin/loan-infozfee/fee-rate/getzorder/openOrdersg?zorder/orderszorder/orders/{id}zorder/orders/{id}/matchresultszorder/orders/getClientOrderzorder/historyzorder/matchresultszquery/deposit-withdrawzmargin/loan-orderszmargin/accounts/balance)zcross-margin/loan-orderszcross-margin/accounts/balancezpoints/actionszpoints/orderszsubuser/aggregate-balancezstable-coin/exchange_ratezstable-coin/quotezfutures/transferzorder/batch-orderszorder/orders/placez$order/orders/submitCancelClientOrderz"order/orders/batchCancelOpenOrderszorder/orders/{id}/submitcancelzorder/orders/batchcancelzdw/withdraw/api/createzdw/withdraw-virtual/{id}/cancelzdw/transfer-in/marginzdw/transfer-out/marginzmargin/orderszmargin/orders/{id}/repayzcross-margin/transfer-inzcross-margin/transfer-outzcross-margin/orders)zcross-margin/orders/{id}/repayzstable-coin/exchangezsubuser/transferr   zapi/v2/summary.jsonzv2/market-statuszv1/common/symbolszv1/common/currencyszv2/settings/common/currencieszv2/reference/currencieszv1/common/timestampzv1/common/exchangezv1/settings/common/chainszv1/settings/common/currencyszv1/settings/common/symbolszv2/settings/common/symbolsz!v1/settings/common/market-symbolszmarket/history/candleszmarket/history/klinezmarket/detail/mergedzmarket/tickerszmarket/detail)market/depthmarket/trademarket/history/tradez
market/etpzv2/etp/referencezv2/etp/rebalancezv1/account/accountsz(v1/account/accounts/{account-id}/balancezv2/account/valuationzv2/account/asset-valuationzv1/account/historyzv2/account/ledgerzv2/point/accountzv2/account/deposit/addresszv2/account/withdraw/quotazv2/account/withdraw/addresszv1/query/deposit-withdrawz!v1/query/withdraw/client-order-idzv2/user/api-keyzv2/user/uidzv2/sub-user/user-listzv2/sub-user/user-statezv2/sub-user/account-listzv2/sub-user/deposit-addresszv2/sub-user/query-depositzv1/subuser/aggregate-balancezv1/account/accounts/{sub-uid}zv1/order/openOrderszv1/order/orders/{order-id}zv1/order/orders/getClientOrderz&v1/order/orders/{order-id}/matchresultz'v1/order/orders/{order-id}/matchresultszv1/order/orderszv1/order/historyzv1/order/matchresultszv2/reference/transact-fee-ratezv2/algo-orders/openingzv2/algo-orders/historyzv2/algo-orders/specific)zv1/margin/loan-infozv1/margin/loan-orderszv1/margin/accounts/balancezv1/cross-margin/loan-infozv1/cross-margin/loan-ordersz v1/cross-margin/accounts/balancev2/account/repaymentzv1/stable-coin/quotezv1/stable_coin/exchange_ratezv2/etp/transactionszv2/etp/transactionzv2/etp/limitzv1/account/transferzv1/futures/transferzv2/point/transferzv2/account/transferzv1/dw/withdraw/api/createz+v1/dw/withdraw-virtual/{withdraw-id}/cancelzv2/sub-user/deduct-modezv2/sub-user/creationzv2/sub-user/managementzv2/sub-user/tradable-marketzv2/sub-user/transferabilityzv2/sub-user/api-key-generationz v2/sub-user/api-key-modificationzv2/sub-user/api-key-deletionzv1/subuser/transferzv1/trust/user/active/creditzv1/order/orders/placezv1/order/batch-orderszv1/order/auto/placez'v1/order/orders/{order-id}/submitcancelz'v1/order/orders/submitCancelClientOrderz%v1/order/orders/batchCancelOpenOrderszv1/order/orders/batchcancelzv2/algo-orders/cancel-all-afterzv2/algo-orderszv2/algo-orders/cancellationr   zv1/dw/transfer-in/marginzv1/dw/transfer-out/marginzv1/margin/ordersz!v1/margin/orders/{order-id}/repayzv1/cross-margin/transfer-inzv1/cross-margin/transfer-outzv1/cross-margin/orders)z'v1/cross-margin/orders/{order-id}/repayzv1/stable-coin/exchangezv2/etp/creationzv2/etp/redemptionzv2/etp/{transactId}/cancelzv2/etp/batch-cancel)r   r   zapi/v1/timestampz
heartbeat/zapi/v1/contract_contract_infozapi/v1/contract_indexzapi/v1/contract_query_elementszapi/v1/contract_price_limitzapi/v1/contract_open_interestzapi/v1/contract_delivery_pricer   z
market/bboz%index/market/history/mark_price_klinezmarket/detail/batch_mergedzv2/market/detail/batch_mergedr   r   zapi/v1/contract_risk_infozapi/v1/contract_insurance_fundzapi/v1/contract_adjustfactorz!api/v1/contract_his_open_interestzapi/v1/contract_ladder_marginzapi/v1/contract_api_statez#api/v1/contract_elite_account_ratioz$api/v1/contract_elite_position_ratioz"api/v1/contract_liquidation_ordersz"api/v1/contract_settlement_recordszindex/market/history/indexzindex/market/history/basisz*api/v1/contract_estimated_settlement_pricez"api/v3/contract_liquidation_orderszswap-api/v1/swap_contract_infozswap-api/v1/swap_indexzswap-api/v1/swap_query_elementszswap-api/v1/swap_price_limitzswap-api/v1/swap_open_interestzswap-ex/market/depthzswap-ex/market/bbozswap-ex/market/history/klinez*index/market/history/swap_mark_price_klinezswap-ex/market/detail/mergedz%v2/swap-ex/market/detail/batch_mergedz-index/market/history/swap_premium_index_klinez"swap-ex/market/detail/batch_mergedzswap-ex/market/tradezswap-ex/market/history/tradezswap-api/v1/swap_risk_infozswap-api/v1/swap_insurance_fundzswap-api/v1/swap_adjustfactorz"swap-api/v1/swap_his_open_interestzswap-api/v1/swap_ladder_marginzswap-api/v1/swap_api_statez$swap-api/v1/swap_elite_account_ratioz%swap-api/v1/swap_elite_position_ratioz+swap-api/v1/swap_estimated_settlement_pricez#swap-api/v1/swap_liquidation_ordersz#swap-api/v1/swap_settlement_recordszswap-api/v1/swap_funding_ratez#swap-api/v1/swap_batch_funding_ratez(swap-api/v1/swap_historical_funding_ratez#swap-api/v3/swap_liquidation_ordersz.index/market/history/swap_estimated_rate_klinezindex/market/history/swap_basisz%linear-swap-api/v1/swap_contract_infozlinear-swap-api/v1/swap_indexz&linear-swap-api/v1/swap_query_elementsz#linear-swap-api/v1/swap_price_limitz%linear-swap-api/v1/swap_open_interestzlinear-swap-ex/market/depthzlinear-swap-ex/market/bboz#linear-swap-ex/market/history/klinez1index/market/history/linear_swap_mark_price_klinez#linear-swap-ex/market/detail/mergedz)linear-swap-ex/market/detail/batch_mergedz,v2/linear-swap-ex/market/detail/batch_mergedzlinear-swap-ex/market/tradez#linear-swap-ex/market/history/tradez!linear-swap-api/v1/swap_risk_infoz2swap-api/v1/linear-swap-api/v1/swap_insurance_fundz$linear-swap-api/v1/swap_adjustfactorz*linear-swap-api/v1/swap_cross_adjustfactorz)linear-swap-api/v1/swap_his_open_interestz%linear-swap-api/v1/swap_ladder_marginz+linear-swap-api/v1/swap_cross_ladder_marginz!linear-swap-api/v1/swap_api_state)z,linear-swap-api/v1/swap_cross_transfer_statez)linear-swap-api/v1/swap_cross_trade_statez+linear-swap-api/v1/swap_elite_account_ratioz,linear-swap-api/v1/swap_elite_position_ratioz*linear-swap-api/v1/swap_liquidation_ordersz*linear-swap-api/v1/swap_settlement_recordsz$linear-swap-api/v1/swap_funding_ratez*linear-swap-api/v1/swap_batch_funding_ratez/linear-swap-api/v1/swap_historical_funding_ratez*linear-swap-api/v3/swap_liquidation_ordersz4index/market/history/linear_swap_premium_index_klinez5index/market/history/linear_swap_estimated_rate_klinez&index/market/history/linear_swap_basisz2linear-swap-api/v1/swap_estimated_settlement_price)zapi/v1/contract_sub_auth_listz"api/v1/contract_api_trading_statuszswap-api/v1/swap_sub_auth_listz#swap-api/v1/swap_api_trading_statusz%linear-swap-api/v1/swap_sub_auth_listz*linear-swap-api/v1/swap_api_trading_statusz+linear-swap-api/v1/swap_cross_position_sidez%linear-swap-api/v1/swap_position_sidez'linear-swap-api/v3/unified_account_infoz4linear-swap-api/v3/fix_position_margin_change_recordz,linear-swap-api/v3/swap_unified_account_typez4linear-swap-api/v3/linear_swap_overview_account_infoz!api/v1/contract_balance_valuationzapi/v1/contract_account_infozapi/v1/contract_position_infozapi/v1/contract_sub_authz api/v1/contract_sub_account_listz%api/v1/contract_sub_account_info_listz api/v1/contract_sub_account_infoz!api/v1/contract_sub_position_infoz api/v1/contract_financial_recordz&api/v1/contract_financial_record_exactz'api/v1/contract_user_settlement_recordszapi/v1/contract_order_limitzapi/v1/contract_feezapi/v1/contract_transfer_limitzapi/v1/contract_position_limitz%api/v1/contract_account_position_infoz#api/v1/contract_master_sub_transferz*api/v1/contract_master_sub_transfer_recordz$api/v1/contract_available_level_ratez api/v3/contract_financial_recordz&api/v3/contract_financial_record_exactzapi/v1/contract-cancel-afterzapi/v1/contract_orderzapi/v1/contract_batchorderzapi/v1/contract_cancelzapi/v1/contract_cancelallz!api/v1/contract_switch_lever_rate   zapi/v1/lightning_close_positionzapi/v1/contract_order_infozapi/v1/contract_order_detailzapi/v1/contract_openorderszapi/v1/contract_hisorderszapi/v1/contract_hisorders_exactzapi/v1/contract_matchresultsz"api/v1/contract_matchresults_exactzapi/v3/contract_hisorderszapi/v3/contract_hisorders_exactzapi/v3/contract_matchresultsz"api/v3/contract_matchresults_exactzapi/v1/contract_trigger_orderzapi/v1/contract_trigger_cancelz!api/v1/contract_trigger_cancelallz"api/v1/contract_trigger_openordersz!api/v1/contract_trigger_hisorderszapi/v1/contract_tpsl_orderzapi/v1/contract_tpsl_cancelzapi/v1/contract_tpsl_cancelallzapi/v1/contract_tpsl_openorderszapi/v1/contract_tpsl_hisordersz#api/v1/contract_relation_tpsl_orderzapi/v1/contract_track_orderzapi/v1/contract_track_cancelzapi/v1/contract_track_cancelallz api/v1/contract_track_openorderszapi/v1/contract_track_hisordersz"swap-api/v1/swap_balance_valuationzswap-api/v1/swap_account_infozswap-api/v1/swap_position_infoz&swap-api/v1/swap_account_position_infozswap-api/v1/swap_sub_authz!swap-api/v1/swap_sub_account_listz&swap-api/v1/swap_sub_account_info_listz!swap-api/v1/swap_sub_account_infoz"swap-api/v1/swap_sub_position_infoz!swap-api/v1/swap_financial_recordz'swap-api/v1/swap_financial_record_exactz(swap-api/v1/swap_user_settlement_recordsz%swap-api/v1/swap_available_level_ratezswap-api/v1/swap_order_limitzswap-api/v1/swap_feezswap-api/v1/swap_transfer_limitzswap-api/v1/swap_position_limitz$swap-api/v1/swap_master_sub_transferz+swap-api/v1/swap_master_sub_transfer_recordz!swap-api/v3/swap_financial_recordz'swap-api/v3/swap_financial_record_exactzswap-api/v1/swap-cancel-afterzswap-api/v1/swap_orderzswap-api/v1/swap_batchorderzswap-api/v1/swap_cancelzswap-api/v1/swap_cancelallz)swap-api/v1/swap_lightning_close_positionz"swap-api/v1/swap_switch_lever_ratezswap-api/v1/swap_order_infozswap-api/v1/swap_order_detailzswap-api/v1/swap_openorderszswap-api/v1/swap_hisordersz swap-api/v1/swap_hisorders_exactzswap-api/v1/swap_matchresultsz#swap-api/v1/swap_matchresults_exactzswap-api/v3/swap_matchresultsz#swap-api/v3/swap_matchresults_exactzswap-api/v3/swap_hisordersz swap-api/v3/swap_hisorders_exactzswap-api/v1/swap_trigger_orderzswap-api/v1/swap_trigger_cancelz"swap-api/v1/swap_trigger_cancelallz#swap-api/v1/swap_trigger_openordersz"swap-api/v1/swap_trigger_hisorderszswap-api/v1/swap_tpsl_orderzswap-api/v1/swap_tpsl_cancelzswap-api/v1/swap_tpsl_cancelallz swap-api/v1/swap_tpsl_openorderszswap-api/v1/swap_tpsl_hisordersz$swap-api/v1/swap_relation_tpsl_orderzswap-api/v1/swap_track_orderzswap-api/v1/swap_track_cancelz swap-api/v1/swap_track_cancelallz!swap-api/v1/swap_track_openordersz swap-api/v1/swap_track_hisordersz,linear-swap-api/v1/swap_lever_position_limitz2linear-swap-api/v1/swap_cross_lever_position_limitz)linear-swap-api/v1/swap_balance_valuationz$linear-swap-api/v1/swap_account_infoz*linear-swap-api/v1/swap_cross_account_infoz%linear-swap-api/v1/swap_position_infoz+linear-swap-api/v1/swap_cross_position_infoz-linear-swap-api/v1/swap_account_position_infoz3linear-swap-api/v1/swap_cross_account_position_infoz linear-swap-api/v1/swap_sub_authz(linear-swap-api/v1/swap_sub_account_listz.linear-swap-api/v1/swap_cross_sub_account_listz-linear-swap-api/v1/swap_sub_account_info_listz3linear-swap-api/v1/swap_cross_sub_account_info_listz(linear-swap-api/v1/swap_sub_account_infoz.linear-swap-api/v1/swap_cross_sub_account_infoz)linear-swap-api/v1/swap_sub_position_infoz/linear-swap-api/v1/swap_cross_sub_position_infoz(linear-swap-api/v1/swap_financial_recordz.linear-swap-api/v1/swap_financial_record_exactz/linear-swap-api/v1/swap_user_settlement_recordsz5linear-swap-api/v1/swap_cross_user_settlement_recordsz,linear-swap-api/v1/swap_available_level_ratez2linear-swap-api/v1/swap_cross_available_level_ratez#linear-swap-api/v1/swap_order_limitzlinear-swap-api/v1/swap_feez&linear-swap-api/v1/swap_transfer_limitz,linear-swap-api/v1/swap_cross_transfer_limitz&linear-swap-api/v1/swap_position_limitz,linear-swap-api/v1/swap_cross_position_limitz+linear-swap-api/v1/swap_master_sub_transferz2linear-swap-api/v1/swap_master_sub_transfer_recordz&linear-swap-api/v1/swap_transfer_innerz(linear-swap-api/v3/swap_financial_recordz.linear-swap-api/v3/swap_financial_record_exactzlinear-swap-api/v1/swap_orderz#linear-swap-api/v1/swap_cross_orderz"linear-swap-api/v1/swap_batchorderz(linear-swap-api/v1/swap_cross_batchorderzlinear-swap-api/v1/swap_cancelz$linear-swap-api/v1/swap_cross_cancelz!linear-swap-api/v1/swap_cancelallz'linear-swap-api/v1/swap_cross_cancelallz)linear-swap-api/v1/swap_switch_lever_ratez/linear-swap-api/v1/swap_cross_switch_lever_ratez0linear-swap-api/v1/swap_lightning_close_positionz6linear-swap-api/v1/swap_cross_lightning_close_positionz"linear-swap-api/v1/swap_order_infoz(linear-swap-api/v1/swap_cross_order_infoz$linear-swap-api/v1/swap_order_detailz*linear-swap-api/v1/swap_cross_order_detailz"linear-swap-api/v1/swap_openordersz(linear-swap-api/v1/swap_cross_openordersz!linear-swap-api/v1/swap_hisordersz'linear-swap-api/v1/swap_cross_hisordersz'linear-swap-api/v1/swap_hisorders_exactz-linear-swap-api/v1/swap_cross_hisorders_exactz$linear-swap-api/v1/swap_matchresultsz*linear-swap-api/v1/swap_cross_matchresultsz*linear-swap-api/v1/swap_matchresults_exactz0linear-swap-api/v1/swap_cross_matchresults_exactz&linear-swap-api/v1/linear-cancel-afterz,linear-swap-api/v1/swap_switch_position_modez2linear-swap-api/v1/swap_cross_switch_position_modez$linear-swap-api/v3/swap_matchresultsz*linear-swap-api/v3/swap_cross_matchresultsz*linear-swap-api/v3/swap_matchresults_exactz0linear-swap-api/v3/swap_cross_matchresults_exactz!linear-swap-api/v3/swap_hisordersz'linear-swap-api/v3/swap_cross_hisordersz'linear-swap-api/v3/swap_hisorders_exactz-linear-swap-api/v3/swap_cross_hisorders_exactz-linear-swap-api/v3/fix_position_margin_changez+linear-swap-api/v3/swap_switch_account_typez)linear-swap-api/v3/linear_swap_fee_switchz%linear-swap-api/v1/swap_trigger_orderz+linear-swap-api/v1/swap_cross_trigger_orderz&linear-swap-api/v1/swap_trigger_cancelz,linear-swap-api/v1/swap_cross_trigger_cancelz)linear-swap-api/v1/swap_trigger_cancelallz/linear-swap-api/v1/swap_cross_trigger_cancelallz*linear-swap-api/v1/swap_trigger_openordersz0linear-swap-api/v1/swap_cross_trigger_openordersz)linear-swap-api/v1/swap_trigger_hisordersz/linear-swap-api/v1/swap_cross_trigger_hisordersz"linear-swap-api/v1/swap_tpsl_orderz(linear-swap-api/v1/swap_cross_tpsl_orderz#linear-swap-api/v1/swap_tpsl_cancelz)linear-swap-api/v1/swap_cross_tpsl_cancelz&linear-swap-api/v1/swap_tpsl_cancelallz,linear-swap-api/v1/swap_cross_tpsl_cancelallz'linear-swap-api/v1/swap_tpsl_openordersz-linear-swap-api/v1/swap_cross_tpsl_openordersz&linear-swap-api/v1/swap_tpsl_hisorders)z,linear-swap-api/v1/swap_cross_tpsl_hisordersz+linear-swap-api/v1/swap_relation_tpsl_orderz1linear-swap-api/v1/swap_cross_relation_tpsl_orderz#linear-swap-api/v1/swap_track_orderz)linear-swap-api/v1/swap_cross_track_orderz$linear-swap-api/v1/swap_track_cancelz*linear-swap-api/v1/swap_cross_track_cancelz'linear-swap-api/v1/swap_track_cancelallz-linear-swap-api/v1/swap_cross_track_cancelallz(linear-swap-api/v1/swap_track_openordersz.linear-swap-api/v1/swap_cross_track_openordersz'linear-swap-api/v1/swap_track_hisordersz-linear-swap-api/v1/swap_cross_track_hisorders)r   r   r   r   r   rM   r   r   trading0.002)feeSide	tierBased
percentagemakertaker
exceptions)zTcontract is restricted of closing positions on API.  Please contact customer servicemaintainzAPI key has no permission4031010100310131017103410361039104110471048106110511066106710941220130314614007zbad-requestzvalidation-format-errorzvalidation-constraints-requiredzbase-date-limit-errorzapi-not-support-temp-addrtimeoutzgateway-internal-errorz)account-frozen-balance-insufficient-errorzinvalid-amountz!order-limitorder-amount-min-errorz!order-limitorder-amount-max-errorz"order-marketorder-amount-min-errorz order-limitorder-price-min-errorz order-limitorder-price-max-errorzorder-stop-order-hit-triggerzorder-value-min-errorzorder-invalid-pricezorder-holding-limit-failedz order-orderprice-precision-errorzorder-etp-nav-price-max-errorzorder-orderstate-errorzorder-queryorder-invalidzorder-update-errorzapi-signature-check-failedzapi-signature-not-validzbase-record-invalidzbase-symbol-trade-disabledzbase-symbol-errorzsystem-maintenancez#base-request-exceed-frequency-limitzinvalid symbol)zsymbol trade not open nowzrequire-symbolzinvalid-addresszbase-currency-chain-errorzdw-insufficient-balancezbase-withdraw-fee-errorzdw-withdraw-min-limitzrequest limit)broadexactprecisionModeoptionsinclude_OS_certificatestypes)rM   r   r   timeDifferencer   adjustForTimeDifferenceuseHistoricalEndpointForSpotr   
includeFeedefaultTypedefaultSubTyper   defaultNetworkERC20defaultNetworksBTCTRC20)ETHr  USDTnetworksTRXr   SOLSOLANAHRC20HECOBEP20BSCXMRLTCXRPXLMCRONOSCROGLMRPOLYGONMATICBTTCUBEIOSTNEOKLAYEOSTHETANASNULSQTUMFTMCELODOGE	DOGECHAINNEARSTEPBITCICARDANOADAETCLUKMINEPLEXDASHZECIOTANEON3XEMHCLSKDCRBTGSTEEMBTSICXWAVESCMTBTMVETXZCACTSMTBCDWAXWAX1WICCELFZILELABCXSBTCBIFICTXCWANPOLYXPAIWTCDGBXVGAACAESEELEBCVGRSARDRNANOZENRBTCBSVGASXTZLAMBCVNT1DOCKSCKMDETNTOPIRISUGASTTNEWTONVSYSFSNBHDONEEMCKBEOSSHIVERVNDOTKSMBANDOEP4NBSFISARHBARFILMASSKAVAXYMENJCRUSTICPCSPRFLOWIOTXLATAPTXCHMINAXECECASHXPRTCCAACAAOTICOTIAKTARSASTRAZEROBLDBRISECOREDESODFIEGLDERGETHFETHFAIRETHWEVMOSFIOFLRFINSCHIAKMAKYVEMEVMOVRNODLOASOSMOPAYCOINPOKTPYGREISCRTSDNSEISGBSUISXPSOLARSYSTENETTONUNQUYUWEMIXXDCXPLA)r  r  fetchOrdersByStatesMethod spot_private_get_v1_order_orders!createMarketBuyOrderRequiresPricelanguagezen-USbroker
AA03022abcaccountsByTypefutures)rM   fundingrP   accountsByIdotcpointsuper-margin
investmentborrowgrid-tradingdeposit-earningotc-options)
rM   rN   r  r  r  r  r  r  r  r  )rJ   r  )
stop-limitbuy-stop-limitsell-stop-limitstop-limit-fokbuy-stop-limit-foksell-stop-limit-foklimitz	buy-limitz
sell-limitioczbuy-ioczsell-ioclimit-makerzbuy-limit-makerzsell-limit-makerr  r  r  	limit-fokzbuy-limit-fokzsell-limit-fokr  r  r  )stopOrderTypeslimitOrderTypes)typesByAccountrM   GFNGLTHEMISGAMECOMHITCHAINPENTASUPERBITCOIN	SOULSAVERBITCOINFILEzFTX Users Debt)	NGLGETGTCHITPNTrd  SOULre  FUD)IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingicebergselfTradePreventionleveragemarketBuyByCostmarketBuyRequiresPricemax  x      )r  r  daysBack	untilDayssymbolRequired)r  triggerr  r  )r  r  r  r  r     )r  r  r  r  r  r  r  gUUUUUU?)r  r  r  r  r  r  daysBackCanceledr    )	sandboxr_   r`   r   r   r   r   rq   r   )r  r  r  r     r  )r  r  r  r  Z   )r  r  r  r  r  )r  r  r  r  r  r  r     )extendsr_   r`   r   r   r   rq   r   r&  forDerivatives)r   r   )rM   r'  rO   rP   )commonCurrenciesfeatures)deep_extendsuperr9   describe
userAgentsparse_numberr3   r'   r&   r(   r+   r.   r-   r,   r*   r4   r2   r1   r6   )self	__class__s    P/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/htx.pyr,  htx.describe#   sv3   c4 9 ; H>
%H>
EH>
 $H>
 	H>

 5H>
 H>
 tH>
 H>
 4H>
  ppp $p 	p
 $p $p Tp $Tp 'p "4p 'p tp p $Up  p  '!p" /#p$ ,U%p& 0'p( t)p* +p, (-p. '/p0 &t1p2 (3p4 "45p6 (7p8 -d9p: %d;p<  =p> ?p@  ApB &tCpD +DEpF )$GpH &tIpJ #DKpL $TMpN 'OpP (QpR "4SpT UpV &tWpX (YpZ 1$[p\  ]p^ *:_p` +Dapb &tcpd #Depf *4gph $Tipj "4kpl *5mpn +Dopp #Dqpr "4spt tupv #Dwpx  ypz %d{p| $T}p~ /p@ +JApB CpD !$EpF &uGpH  IpJ dKpL $TMpN +DOpP %dQpR !$SpT "4UpV dWpX !$YpZ "4[p\ t]p^ #D_p`  apb '
cpd !$epf (gph %eipj )$kpl )$mpn topp tqpr spt Tupv twpx "4ypz #E{p| %d}p~ &tp@ 'ApB $TCpD !$EpF )$GpH "4IpJ #DKpL +DMpN !%$('+#!&#'  _pH>
v wH>
N  ~ .+ 7'A&I#
 (D&I!
& 3 4023 4!5 /X $ ;]/OH>
n  01)*(!0! 3A 21	
 ,Q 6q 23 ( -a .q 0 3A 1! ' #A  .q!" .q#$ 12&'%&,-)*'()*,-+,)*%&9<*A+Q )! .q	
 ,Q 3A 3A 6q 8 4Q / &q 7 3A $Q  +A!" )!#$ *+()()*+35,./?8t *+,-,-+,./*C7 5a *1	
 1! +A +A +C ' ,S 9# 6s ( -a  1!!$ -c%& 23'( 569:*+)*5756-.58*A*A -c -c	
 ? =c 9# 3C 1! :1  0!" 1"#$ (%& 3B'( 3A)* 4Q+, .q-. ;<01,.3;8@ ! 5q$! !&$91("( !&$91("'# !&$91("( !&$91("'!% F   . /  21  <Q	 
 6q  21  1!  8  ;A  9!  9!  @  5a  3A   3A! " -a# $ ,Q% & -.,-45*+01013 <7 137  G7  3A	7 
 9#7  1!7  07  /7  9!7  87  :17  6q7  87  @7 " .q#7 $ *1%7 & 4Q'7 ( 5a)7 * 7+7 , :1-7 . 8/7 0 ;B17 2 <Q37 6 2377 8 9#97 : =c;7 < Ec=7 > Fs?7 @ .sA7 B /C7 D 4QE7 F =aG7 J 5aK7 L 5aM7 N 6qO7 R 4558:=9:;<@A4545<=3423,-m7 p1!111! 211! 0	1!
 211! 81! J11! 6q1! 3A1! 5a1! :11! :11! =a1!  ?!1!" ;A#1!$ 22%1!& :2'1!* 4S+1!, 4S-1!. 23/1!0 Fs11!2 Fs31!4 DS51!6 :371!8 >q91!< -a=1!> :1?1!B 3AC1!D 7E1!F 8G1!H /I1!J @K1!L :1M1!N ;AO1!P 5aQ1!R HI78/012:<35a1!sk =JZ  g .g (!g  <Q	g 
 4Qg  =ag  :1g  <Qg  =ag  +Ag  )!g  3Ag  DQg  3Ag  9!g   <Q!g " +A#g $ 3A%g & 8'g ( =a)g * ;A+g , @-g . <Q/g 0 81g 2 B13g 4 CA5g 6 A!7g 8 A!9g : 9!;g < 9!=g > I!?g @ A!Ag D =aEg F 5aGg H >qIg J ;AKg L =aMg N 3AOg P 1!Qg R ;ASg T I!Ug V ;AWg X DQYg Z LQ[g \ A!]g ^ 3A_g ` ;Aag b 9!cg d >qeg f <Qgg h A!ig j =akg l 9!mg n CAog p DQqg r J1sg t B1ug v B1wg x <Qyg z B1{g | G}g ~ B1g @ MaAg B >qCg F DQGg H <QIg J EaKg L B1Mg N DQOg P :1Qg R 8Sg T B1Ug V PQRWg X B1Yg Z H[g \ KA]g ^ :1_g ` B1ag b @cg d QRSeg f CAgg h I!ig j Hkg l DQmg n J1og p @qg r MNIJKLLMJKJKDEJKOPJKTUUVFGRSMg iZ >?BC>?CDEFJKKLEFGHTULMTU "c!?c! ;Ac! <Q	c!
 7c! ?c! DQc! ?c! @c! ?c! Eac! Fqc! :1c! 21c! =ac!  =a!c!" DQ#c!$ B1%c!& I!'c!( CA)c!* ?+c!, Ea-c!0 ;A1c!2 4Q3c!4 9!5c!6 5a7c!8 89c!: @;c!< >q=c!> 9!?c!@ ;AAc!B 9!Cc!D 8Ec!F >qGc!H ;AIc!J A!Kc!L 8Mc!N >qOc!P ;AQc!R A!Sc!V <QWc!X =aYc!Z @[c!\ A!]c!^ @_c!` 9!ac!b :1cc!d =aec!f >qgc!h =aic!j B1kc!l :1mc!n ;Aoc!p >qqc!r ?sc!t >quc!x A!yc!z <Q{c!| =a}c!~ Eac!@ 8Ac!B @Cc!D EaEc!F @Gc!H A!Ic!J @Kc!L FqMc!N GOc!P DQQc!R ;ASc!T 3AUc!V >qWc!X >qYc!Z CA[c!\ J1]c!^ @_c!` Fqac!d <Qec!f 5agc!h :1ic!j 6qkc!l 9!mc!n Hoc!p A"qc!r :1sc!t <Quc!v :1wc!x 9!yc!z ?{c!| <Q}c!~ B1c!@ <QAc!B B1Cc!D 9!Ec!F ?Gc!J =aKc!L >qMc!N A!Oc!P B1Qc!R A!Sc!T :1Uc!V ;AWc!X >qYc!Z ?[c!\ >q]c!^ CA_c!` ;Aac!b <Qcc!d ?ec!f @gc!h ?ic!l KAmc!n QRSoc!p Hqc!r CAsc!t I!uc!v DQwc!x J1yc!z LQ{c!| RST}c!~ ?c!@ GAc!B MaCc!D LQEc!F RSTGc!H GIc!J MaKc!L HMc!N NqOc!P GQc!R MaSc!T NqUc!V TUVWc!X KAYc!Z QRS[c!\ B1]c!^ :1_c!` Eaac!b KAcc!d Eaec!f KAgc!h J1ic!j QRSkc!l Eamc!n Goc!p Maqc!t <Quc!v B1wc!x A!yc!z G{c!| =a}c!~ CAc!@ @Ac!B FqCc!D HEc!F NrGc!H OPQIc!J UVWKc!L A!Mc!N GOc!P CAQc!R I!Sc!T A!Uc!V GWc!X @Yc!Z Fq[c!\ Fq]c!^ LQ_c!` CAac!b I!cc!d I!ec!f OPQgc!h Eaic!j KAkc!l QRSmc!n CAoc!p I!qc!r I!sc!t OPQuc!v @wc!x Fqyc!z Fq{c!| LQ}c!~ LQc!@ J1Ac!B HCc!F DQGc!H J1Ic!J EaKc!L KAMc!N HOc!P NqQc!R I!Sc!T OPQUc!V HWc!X NqYc!Z A![c!\ G]c!^ B1_c!` Hac!b Eacc!d KAec!f Fqgc!h LQic!j Eakc!l MNKLQRCDIJDEJKGHMNHINOGHMNEc!%v Wbm	Y
oH>
b $!&"&!..w7!..w7cH>
t ly -1A
>.> -> /	>
 I> M> L> L> L> L> -> -> M> L> I>  L!>" L#>$ -%>& J'>( L)>* J+>, ":->. .z/>0 6z1>2 ,Z3>4 01A5>6 ~7>8 -.B9>: @AR;>< %l=>> 8?>@ 8A>B 9,C>D 7E>F 7G>H 3LI>J ,\K>L *<M>N 1,O>P 7Q>R 4\S>T -mU>V /W>X )*>Y>Z 12E[>\ ./B]>^ *=_>` 1)a>b (c>d )-e>f :;Lg>j %ik>l 2;&/'11;/@/9-7%6{>EuH>
@ YAH>
B  S)5S $"&#'!S !!S *5S 2DS  %S" v#S$ !(%S& !''S( "" #$)S2  U 5 U	
 8 V U 5 5 5 5 e 5 F w  W!" 5#$ F%& F'( 5)* F+, 5-. W/0 512 F34 F56 578 F9: F;<  => F?@ FAB WCD uEF 5GH 5IJ 5KL 
MN FOP 5QR FST WUV 5WX $YZ 5[\ 5]^ 5_` Wab 5cd 5ef Wgh 5ij 5kl 5mn 5op 5qr 5st 5uv 6wx Fyz 5{| 5}~ 5@ 5AB FCD FEF FGH 5IJ WKL 5MN 5OP 5QR 5ST 5UV $WX WYZ 5[\ 5]^ F_` Fab 5cd Fef 5gh 5ij 5kl Fmn Wop Fqr $st 5uv 5wx 5yz F{| F}~ $@ hAB FCD 5EF 5GH 5IJ $KL 5MN FOP FQR 5ST 5UV 5WX FYZ F[\ 5]^ 5_` $ab Fcd 5ef Fgh Fij 5kl 5mn Wop 5qr Fst Fuv Fwx 5yz 5{| 5}~ F@ 7AB FCD 5EF FGH 5IJ 5KL FMN WOP 5QR WST FUV FWX 5YZ F[\ 5]^ I_` Fab Wcd 5ef 5gh 
ij 5kl Fmn 5op Fqr Fst 5uv Fwx yyz F{| 5}~ 5@ FAB 5CD 5EF 5GH 5IJ 7KL 5MN WOP 5QR 5ST 5UV WWX !"[3St ,-OuSv 4TwSx GySz ,{S@ !!$'#ASJ "& $$2".&$2'8#0!KSd "'# '+*.+/*..2/3'((#T( %d( t	(
 "4( #D( &t( *4( +D( %d( )$( *4( $T( (( )$(  )$!(" -d#($ .t%(kSCH>
r%  !
 &#%'!!(  $&*(,,0,0).+06:#'#'"&#(	( #($)#(/3$(+/26)$. r% ',!$$'%&*/& ',#($)*/	# ',#'$)!$*/( ',#'$)!$%&$'*/$ ',#'$)%&!$$',2*/	*  #EEN  &)-+/$("&	$ r% %d# '+#($)!#	( '+#($)!#$&$ '+#($)%&!#$&,2*  #K(#V "#3 "#3 	 "#3 "#3 	q@O&H>
 H H	    c                   #    U R                  5       I Sh  vN   SnU R                  SSU5      u  p!U R                  SSS5      nSnUS:w  a  U(       a  U R                  USU R                  S   5      nUS:X  a>  US	:X  a  U R                  5       I Sh  vN nOUS
:X  a  U R                  5       I Sh  vN nOUS:X  a>  US	:X  a  U R                  5       I Sh  vN nO\US
:X  a  U R                  5       I Sh  vN nO=US:X  a  U R                  5       I Sh  vN nOUS:X  a  U R                  5       I Sh  vN nSnSnSnUS:X  a5  U R                  US5      n	U	c  SnO
U	S:X  a  SOSnU R                  US5      nOwU R                  US0 5      n
U R                  U
S5      n	U	S:X  a  SOSnU R                  US0 5      nU R                  US5      nU R                  U5      nU R                  US5      nUUSUUS.$  GN GNi GNM GN+ GN N N7f)ao  
the latest known information on the availability of the exchange API

https://huobiapi.github.io/docs/spot/v1/en/#get-system-status
https://huobiapi.github.io/docs/dm/v1/en/#get-system-status
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-system-status
https://huobiapi.github.io/docs/usdt_swap/v1/en/#get-system-status
https://huobiapi.github.io/docs/usdt_swap/v1/en/#query-whether-the-system-is-available  # contractPublicGetHeartbeat

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
Nr   enableForContractsFrM   subTyper  rO   r   r   rP   r   r   okmaintenancets	indicatornonepage
updated_atr   )r   updatedetar   info)load_marketshandle_market_type_and_paramshandle_optionsafe_stringr  )statusPublicSwapLinearGetApiV2SummaryJson*statusPublicSwapInverseGetApiV2SummaryJson+statusPublicFutureLinearGetApiV2SummaryJson,statusPublicFutureInverseGetApiV2SummaryJsoncontractPublicGetHeartbeat#statusPublicSpotGetApiV2SummaryJson
safe_value	parse8601)r/  params
marketTypeenabledForContractsresponser6  r   r>  r   	statusRaw
statusDatapageDatadatetimes                r1  fetch_statushtx.fetch_statusn  s(     !!!
!??tU[\
"00@TV[\$7&&vy$,,GW:XYGV#h&%)%S%S%UUH	)%)%T%T%VVHx'h&%)%U%U%WWH	)%)%V%V%XXHz)!%!@!@!BB6!!EEGGHD #((8<I "+t"3-&&x6G8R@J(([AI'61TFx<H'',?HnnX.G""8U3C
 	
Q 	"  VV  XXBGs}   HG9A<HG<H2G?3$HHH6H7HHH4H
5CH<H?HHHH
Hc                 z  #    U R                  U R                  S0 5      nU R                  U R                  SS5      nU R                  USU5      nU R                  USU5      nSnUS:X  d  US:X  a  U R                  U5      I Sh  vN nOU R	                  U5      I Sh  vN nU R                  USS	5      $  N1 N7f)
a  
fetches the current integer timestamp in milliseconds from the exchange server

https://huobiapi.github.io/docs/spot/v1/en/#get-current-timestamp
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-current-system-timestamp

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int: the current integer timestamp in milliseconds from the exchange server
r   r  rM   typeNrP   rO   datar9  )rK  r  rD  contractPublicGetApiV1TimestampspotPublicGetV1CommonTimestampsafe_integer_2)r/  rM  r  r  rX  rP  s         r1  
fetch_timehtx.fetch_timeK  s      //$,,R@&&t||]FK=5H$&.!AA&IIH!@@HHH ""8VT:: JHs$   BB;B7B;B9 B;9B;Nfeemarketc                     U R                  US5      nUU R                  X25      U R                  US5      U R                  US5      S S S.$ )NsymbolactualMakerRateactualTakerRate)r@  rb  r   r   r   r   )rD  safe_symbolsafe_number)r/  r_  r`  marketIds       r1  parse_trading_feehtx.parse_trading_feei  sY     ##C2&&x8%%c+<=%%c+<=
 	
r3  rb  c                 0  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US/ 5      nU R	                  US0 5      nU R                  Xs5      $  N{ N=7f)a?  
fetch the trading fees for a market

https://huobiapi.github.io/docs/spot/v1/en/#get-current-fee-rate-applied-to-the-user

: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>`
Nsymbolsr=   rY  r   )rA  r`  (spotPrivateGetV2ReferenceTransactFeeRateextendrK  rh  )r/  rb  rM  r`  requestrP  rY  firsts           r1  fetch_trading_feehtx.fetch_trading_fee}  s      !!!V$vd|
 FFt{{SZGcdd  x4a,%%e44/ 	"
 es!   BB?BB<BBrk  c                    #    U R                  5       I S h  vN   Uc  U R                  n0 n[        S[        U5      5       H2  nX   nU R	                  U R                  U5      U5      I S h  vN X5'   M4     U$  Nb N7f)Nr   )rA  rk  rangelenfetch_trading_limits_by_id	market_id)r/  rk  rM  resultirb  s         r1  fetch_trading_limitshtx.fetch_trading_limits  s|      !!!?llGq#g,'AZF#'#B#B4>>RXCY[a#bbFN (  	" cs"   A=A9AA=,A;-A=;A=r=   c                    #    SU0nU R                  U R                  X25      5      I Sh  vN nU R                  U R                  US0 5      5      $  N&7f)a   
@ignore

       https://huobiapi.github.io/docs/spot/v1/en/#get-current-fee-rate-applied-to-the-user

       :param str id: market id
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :returns dict: the limits object of a market structure
       rb  NrY  )spotPublicGetV1CommonExchangerm  parse_trading_limitsrK  )r/  r=   rM  rn  rP  s        r1  ru  htx.fetch_trading_limits_by_id  sW      b
 ;;DKK<XYY" ((62)NOO# Zs   (AA'Ac                 V    USU R                  US5      U R                  US5      S.0S.$ )Namountzlimit-order-must-greater-thanzlimit-order-must-less-thanminr  )r@  limits)rf  )r/  r  rb  rM  s       r1  r}  htx.parse_trading_limits  s@    " ++F4ST++F4PQ
 	
r3  c                 l    U R                  U[        U R                  U   S   S   U R                  5      $ )N	precisioncost)decimal_to_precisionr5   marketsr  )r/  rb  r  s      r1  cost_to_precisionhtx.cost_to_precision  s4    ((xf9Mk9Z[a9bdhdvdvwwr3  c                    #    U R                   S   (       a  U R                  5       I Sh  vN   SnU R                  USS0 5      u  p!/ n/ n[        UR	                  5       5      n[        S[        U5      5       H  nXV   nU R                  X'5      (       d  M  US:X  a$  UR                  U R                  SSU5      5        MI  US:X  a$  UR                  U R                  SSU5      5        Ms  US:X  d  M{  UR                  U R                  S	SU5      5        UR                  U R                  S
SU5      5        M     [        R                  " U6 I Sh  vN n[        S[        U5      5       H  nU R                  X4U   5      nM     U$  GN_ N97f)a  
retrieves data on all markets for huobi

https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v1-deprecated
https://huobiapi.github.io/docs/dm/v1/en/#get-contract-info
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-swap-info
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-swap-info

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
r  Nr   r  r   rM   r   r   rO   rP   )r  load_time_differencehandle_option_and_paramslistkeysrs  rt  	safe_boolappend"fetch_markets_by_type_and_sub_typeasynciogatherarray_concat)r/  rM  r  
allMarketspromisesr  rx  keys           r1  fetch_marketshtx.fetch_markets  s_     <<12++---55fngWYZ
EJJL!q#d)$A'C~~e))&=OOD$K$KFTXZ`$abH_OOD$K$KDRZ\b$cdI%OOD$K$KFT]_e$fgOOD$K$KHV_ag$hi % !22q#h-(A**:{CJ )' .  3s0   (FF	A)FAF4AFF7FFrX  r6  c                   #    US:H  n0 nSnU(       d  US:X  a.  SUS'   U R                  U R                  XS5      5      I Sh  vN nOUS:X  a]  US:X  a)  U R                  U R                  XS5      5      I Sh  vN nOWUS:X  a(  U R                  U R                  XS5      5      I Sh  vN nO(U R	                  U R                  XS5      5      I Sh  vN nU R                  US	/ 5      n[        U5      nUS
:  a*  [        U R                  S-   U R                  U5      -   5      e/ n	[        S[        U5      5       GH  n
Xz   nSnSnSnSnSnSU;   nU(       + nSnSnSnSnU(       Ga  U R                  US5      nUR                  5       nU R                  US5      nU R                  US5      nUSLnU(       + nUSLnU(       + nU(       aC  SnUR                  S5      nU R                  US5      nU R                  US
5      nU(       a  UOUnOU(       aW  SnU R                  US5      nU(       a  SnUnOrU R                  US5      nUR                  S5      nU R                  US
5      nUnO:SnU R                  US5      nU R                  US5      nX-   nUR                  5       nU R                  U5      nU R                  U5      nU R                  U5      nUS-   U-   nSnU(       aO  U(       a	  USU-   -  nOU(       a  USU-   -  nU(       a)  U R!                  US5      nUSU R#                  U5      -   -  nU R%                  US5      n U R%                  US5      n!U R%                  US5      n"U R%                  US5      n#U(       a  U(       a  U n#O	U(       a  U n!Sn$Sn%Sn&Sn'Sn(Sn)U(       a  U R'                  U R)                  U R                  US5      5      5      n$U R'                  U R)                  U R                  US5      5      5      n%U R'                  U R)                  U R                  US5      5      5      n&U R'                  S 5      n'U R'                  S 5      n(U R                  US!5      n*U*S":H  n)O\U R%                  US#5      n$U R'                  S$5      n%U R'                  S%5      n'U R'                  S&5      n(U R!                  US'5      n+U+S
:H  n)U R                  US(S$5      n,U R                  US)S$5      n-[*        R,                  " U,S$5      =(       d    [*        R,                  " U-S$5      n.Sn/U R                  US*5      n0U0bZ  U R/                  U05      n1U1S   U1S
   -   U1S+   -   U1S,   -   S-   U1S-   -   U1S.   -   S-   U1S/   -   U1S0   -   S1-   n0U R1                  U05      n/U	R3                  0 S2U_S3U_SU_S4U_S5U_S6U_S7U_S8U_S9U_S:U_SU_S;U=(       a    U._SU_SU_S<S_S=U)_S>U_UUU(U'U UU R5                  U5      SSU%U$U&S?.U R'                  S$5      U R'                  U,5      U R'                  U-5      S@.U#U"SA.SSSA.U!SSA.SB.U/USC.E5        GM     U	$  GN GN GN GN7f)Da  
@ignore
       retrieves data on all markets of a certain type and/or subtype

       https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v1-deprecated
       https://huobiapi.github.io/docs/dm/v1/en/#get-contract-info
       https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-swap-info
       https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-swap-info

       :param str [type]: 'spot', 'swap' or 'future'
       :param str [subType]: 'linear' or 'inverse'
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :returns dict[]: an array of objects representing market data
       rM   Nr   allbusiness_typer   rP   rO   rY  r   z, fetchMarkets() returned an empty response: r   contract_codeFdelivery_date-rb  USDpairzbase-currencyzquote-currency/:delivery_timecontract_sizezmin-order-valuezmax-order-amtzmin-order-amtzprice-precisionzamount-precisionzvalue-precisionr   stateonline
price_tick1z0.0002z0.0005contract_statuszleverage-ratiozsuper-margin-leverage-ratiocreate_dater     r   r         z	 00:00:00r=   lowercaseIdbasequotesettlebaseIdquoteIdsettleIdrX  rN   rQ   activer   )r  pricer  )r  r  superMaxr  )r  r  r  r  )r   r   r   r   contractSizeexpiryexpiryDatetimestrike
optionTyper  r  createdr@  )0contractPublicGetLinearSwapApiV1SwapContractInform  *contractPublicGetApiV1ContractContractInfo*contractPublicGetSwapApiV1SwapContractInfospotPublicGetV1CommonSymbols	safe_listrt  r0   r=   jsonrs  rD  lowersplitsafe_string_lowersafe_currency_codesafe_integeryymmddrf  r.  parse_precisionr7   	string_gtstring_to_chars_arrayrL  r  iso8601)2r/  rX  r6  rM  isSpotrn  rP  r  
numMarketsrw  rx  r`  r  r  r  r=   r  r   rM   rO   rP   r   r   r  r  partsr  r  r  r  rb  r  r  minCost	maxAmount	minAmountpricePrecisionamountPrecisioncostPrecisionr   r   r  r  contractStatusleverageRatiosuperLeverageRatiohasLeverager  createdDatecreatedArrays2                                                     r1  r  &htx.fetch_markets_by_type_and_sub_type  s     &.("+0(!%!V!VW[WbWbcjWs!ttI%8#%)%T%TUYU`U`ahUq%rrHV^%)%T%TUYU`U`ahUq%rrH!>>t{{7?[\\Hn ..626\
>!$'',Z"Z]a]f]fgo]p"pqqq#g,'AZFFGHBK'61H<DDFFG%%fo> hhj $ 0 0 I $ 0 0 I&d2!z&d2$*!DHHSME!33FHEF"44UA>G)0vgH#D!33FHEF"'#)#//? $

3"&"8"8"B#*))&/B**63CD% hhj**62D++G4E,,X6FCZ%'FFcDj(FcEk)F!..vGFcDKK$777F++FODL&&v/@AG((AI((AI ,I*G!N"O MEEF!%!2!243G3GHXHXY_arHs3t!u"&"3"3D4H4HIYIYZ`btIu4v"w $ 1 1$2F2FtGWGWX^`qGr2s t))'2))'2((98+!%!1!1&,!G"&"3"3C"8))(3))(3!%!2!26;L!M(A- ,,V5EsKM!%!1!1&:WY\!]!++M3?m7CTCTUgilCmK G**6=AK&#99+F*1oQ?,q/QT`abTccfiilxyzl{{  K  LM  N  N  QT  T  Wc  de  Wf  f  iu  vw  ix  x  {F  F..5MM 5b5{5 &5 	5
 5 &5 &5 75 H5 5 5 4/K5 5 &5 %5  &!5" H#5$ !" , "&,,v"6"-+)  $005#00?$($5$56H$I!  )(
  $#
  '#& #i5 5Y (D K u  sr\sH   ?Y!Y4Y!6Y7.Y!%Y&(Y!YVY!Y!Y!Y!symbolOrMarketIdc                 >   XR                   ;   a  U$ SU R                  ;  a  0 U R                  S'   U R                  U R                  S0 5      nX;   a  X!   $ U R                  U R                   SS5      nSSSSS.n[	        S	[        U5      5       Hx  nX5   nU R                  US
0 5      nU R                  US5      nXH   n	US   (       a  US   S-   US   -   S-   U	-   O
US   S-   U	-   n
X:X  d  M`  US   nXR                  S   U'   Us  $    XR                  S   U'   U$ )NfutureMarketIdsForSymbolsrP   TCWNWCQNQ)	this_week	next_weekquarternext_quarterr   r@  contract_typer   r  r  r  _rb  )r  r  	safe_dict	filter_byrs  rt  rK  rD  )r/  r  r  futureMarketsfuturesCharsMapsrx  r`  r@  contractTypecontractSuffixconstructedIdrb  s               r1  "try_get_symbol_from_future_markets&htx.try_get_symbol_from_future_markets(  sh   ||+##
 ,t||;8:DLL45$(NN4<<A\^`$a!8,>>t||XtD 	"
 q#m,-A"%F??6626D++D/BL-;N]cdl]mF6NS06'?BSH>Ysy  {A  tB  EH  tH  KY  tYM0)NT89:JK . GW012BCr3  tickerc                    U R                  USS5      nU R                  X25      nU R                  U5      nU R                  USS5      nS nS nS nS n	SU;   am  US   bC  [	        US   [
        5      (       a+  U R                  US   S5      nU R                  US   S5      nO$U R                  US5      nU R                  US5      nS	U;   am  US	   bC  [	        US	   [
        5      (       a+  U R                  US	   S5      nU R                  US	   S5      n	O$U R                  US	5      nU R                  US
5      n	U R                  US5      n
U R                  US5      nU R                  US5      nU R                  US5      nU R                  0 SU_SU_SU R                  U5      _SU R                  US5      _SU R                  US5      _SU_SU_S	U_SU	_SS _SU
_SU_SU_SS _SS _SS _SS _UUUS.EU5      $ )Nrb  r  r9  	quoteTimebidr   r   bidSizeaskaskSizeopencloser  vol	timestamprT  highlow	bidVolume	askVolumevwaplastpreviousClosechanger   average)
baseVolumequoteVolumer@  )	safe_string_2re  r  r\  
isinstancer  rD  safe_tickerr  )r/  r  r`  rg  rb  r  r  r  r  r  r  r  r  r  s                 r1  parse_tickerhtx.parse_tickerJ  s   \ %%fhH!!(388@''kB			F?e}(Zut-L-L&&ve}a8 ,,VE]A>	&&vu5 ,,VY?	F?e}(Zut-L-L&&ve}a8 ,,VE]A>	&&vu5 ,,VY?	/  1%%fh7
&&vu5 !
f!
!
 Y/!
 D$$VV4	!

 4##FE2!
 3!
 !
 3!
 !
 D!
 D!
 U!
 E!
 T!
 d!
  $!!
" t#!
$ %&)!
* + 	r3  c                   #    U R                  5       I Sh  vN   U R                  U5      n0 nSnUS   (       a1  US   US'   U R                  U R                  XB5      5      I Sh  vN nOUS   (       av  US   (       a1  US   US'   U R	                  U R                  XB5      5      I Sh  vN nOkUS   (       a0  US   US'   U R                  U R                  XB5      5      I Sh  vN nO0US   US'   U R                  U R                  XB5      5      I Sh  vN nU R                  US	0 5      nU R                  Xc5      nU R                  US
5      nXS'   U R                  U5      US'   U$  GNU GN	 N N N^7f)a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://huobiapi.github.io/docs/spot/v1/en/#get-latest-aggregated-ticker
https://huobiapi.github.io/docs/dm/v1/en/#get-market-data-overview
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-market-data-overview
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-market-data-overview

:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr   r=   r  r   rP   rb  rO   tickr9  r  rT  )rA  r`  /contractPublicGetLinearSwapExMarketDetailMergedrm  #contractPublicGetMarketDetailMerged)contractPublicGetSwapExMarketDetailMergedspotPublicGetMarketDetailMergedrK  r  r  r  )	r/  rb  rM  r`  rn  rP  r  r  r  s	            r1  fetch_tickerhtx.fetch_ticker  sw     !!!V$('-d|GO$!QQRVR]R]^eRnooHIh$*4L!!%!I!I$++V]Jf!gg+1$<(!%!O!OPTP[P[\cPl!mm &tGH!AA$++gB^__HX x4""40%%h5	'{!\\)4zC 	" p h n `sZ   E7E+AE7%E.&AE7*E1+:E7%E3&0E7E5AE7.E71E73E75E7c                 "  #    U R                  5       I Sh  vN   U R                  U5      nU R                  US5      nSnUb  U R                  U5      nSU;   =(       d    SU;   nSnSnU R	                  SXB5      u  pbU R                  SXB5      u  pr0 nUS:H  n	US:H  n
US:H  nUS	:H  nUS
:H  nSnU	(       a  U(       a  U(       aH  U
(       a  SUS'   OU(       a  SUS'   OSUS'   U R                  U R                  X5      5      I Sh  vN nOU(       ax  U
(       a)  U R                  U R                  X5      5      I Sh  vN nOU(       a)  U R                  U R                  X5      5      I Sh  vN nOX[        U R                  S-   5      e[        U R                  S-   5      eU R                  U R                  X5      5      I Sh  vN nU R                  USS/ 5      nU R                  XU5      nU R                  USU5      $  GN GN N N NG7f)a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://huobiapi.github.io/docs/spot/v1/en/#get-latest-tickers-for-all-pairs
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-a-batch-of-market-data-overview
https://huobiapi.github.io/docs/dm/v1/en/#get-a-batch-of-market-data-overview
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-a-batch-of-market-data-overview-v2

: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>`
Nr   r6  r  r   rM   rP   rO   r   r   r  r  za fetchTickers() you have to set params["type"] to either "swap" or "future" for inverse contractsz_ fetchTickers() you have to set params["subType"] to either "linear" or "inverse" for contractsrY  ticksrb  )rA  market_symbolsrD  r`  rB  handle_sub_type_and_params4contractPublicGetLinearSwapExMarketDetailBatchMergedrm  (contractPublicGetMarketDetailBatchMerged.contractPublicGetSwapExMarketDetailBatchMergedr/   r=   spotPublicGetMarketTickerssafe_list_2parse_tickersfilter_by_array_tickers)r/  rk  rM  ro  r`  isSubTypeRequestedrX  r6  rn  r  rP   rO   r   r   rP  
rawTickerstickerss                    r1  fetch_tickershtx.fetch_tickers  s$     !!!%%g.  !,[['F'61Q&7P99.&Y99.&Y&.("X%i'+/8GO,/5GO,/4GO,!%!Z!Z[_[f[fgn[w!xx%)%R%RSWS^S^_fSo%ppH%)%X%XY]YdYdelYu%vvH&tww  2U  (U  V  V"477  .O  $O  P  P!<<T[[=YZZHf %%hD
$$Z&A++GXwGGw 	"6 y  qv [sY   HHC.HH6H<H	=/H,H-AHH>HH	HHHc                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      nSnSnU R                  SX25      u  pRU R	                  SX25      u  pBSnUS:X  d  US:X  a   US:X  a  U R                  U5      I Sh  vN nOjUS:X  a   US:X  a  U R                  U5      I Sh  vN nODUS:X  a   US:X  a  U R                  U5      I Sh  vN nO[        U R                  S-   U-   S-   5      eU R                  US	0 5      nU R                  US
/ 5      nU R                  X5      $  GN" N N Na7f)a8  
fetches the last price for multiple markets

https://www.htx.com/en-us/opend/newApiPages/?id=8cb81024-77b5-11ed-9966-0242ac110003 linear swap & linear future
https://www.htx.com/en-us/opend/newApiPages/?id=28c2e8fc-77ae-11ed-9966-0242ac110003 inverse future
https://www.htx.com/en-us/opend/newApiPages/?id=5d517ef5-77b6-11ed-9966-0242ac110003 inverse swap

:param str[] [symbols]: unified symbols of the markets to fetch the last prices
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of lastprices structures
Nr   rO   rP   r   r   z$ fetchLastPrices() does not support z markets yetr  rY  )rA  r  get_market_from_symbolsr  rB  (contractPublicGetLinearSwapExMarketTrade"contractPublicGetSwapExMarketTradecontractPublicGetMarketTrader/   r=   rK  r  parse_last_prices)	r/  rk  rM  r`  rX  r6  rP  r  rY  s	            r1  fetch_last_priceshtx.fetch_last_pricesc	  sQ     !!!%%g.--g699:KV\99:KV\V^!1H9L!JJ6RRH4 fn7i#7!DDVLLH. hW	%9!>>vFFH0 tww)OORVVYgghhx4~~dFB/%%d44o 	" S6 M0 GsG   ED8A:ED;%E7D=8%ED?AE;E=E?Ec                     U R                  USS5      nU R                  X25      nU R                  US5      nU R                  US5      nUS   S S UUUS.$ )Nrb  r  r  	direction)rb  r  rT  r  sider@  )r  safe_marketrf  rD  )r/  entryr`  rg  r  r3  s         r1  parse_last_pricehtx.parse_last_price	  sm    %%eXG!!(3  0$$UK8	 X&
 	
r3  r  c                 X  #    U R                  5       I Sh  vN   U R                  U5      nSS0nSnUS   (       a1  US   US'   U R                  U R                  XS5      5      I Sh  vN nOUS   (       av  US   (       a1  US   US	'   U R	                  U R                  XS5      5      I Sh  vN nOUS
   (       a0  US   US'   U R                  U R                  XS5      5      I Sh  vN nOmUb:  US:w  a*  US:w  a$  US:w  a  US:w  a  [        U R                  S-   5      eUS:w  a  X%S'   US   US	'   U R                  U R                  XS5      5      I Sh  vN nSU;   a  US   (       d*  [        U R                  S-   U R                  U5      -   5      eU R                  US5      nU R                  USU R                  US5      5      nU R                  XqU5      n	U R                  US5      U	S'   U	$ [        U R                  S-   U R                  U5      -   5      e GN GN GNv GN> N7f)a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://huobiapi.github.io/docs/spot/v1/en/#get-market-depth
https://huobiapi.github.io/docs/dm/v1/en/#get-market-depth
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-market-depth
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-market-depth

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
NrX  step0r   r=   r  r   rP   rb  rO   r   r         zP fetchOrderBook() limit argument must be None, 5, 10, 20, or 150, default is 150depthr  z+ fetchOrderBook() returned empty response: r9  rG   noncez2 fetchOrderBook() returned unrecognized response: )rA  r`  (contractPublicGetLinearSwapExMarketDepthrm  contractPublicGetMarketDepth"contractPublicGetSwapExMarketDepthr*   r=   spotPublicGetMarketDepthr+   r  rK  r  parse_order_bookr%   )
r/  rb  r  rM  r`  rn  rP  r  r  rw  s
             r1  fetch_order_bookhtx.fetch_order_book	  s5     !!!V$ G

 ('-d|GO$!JJ4;;W^KghhHIh$*4L!!%!B!B4;;wC_!``+1$<(!%!H!HU\Ie!ff QJUb[u{RU$TWW  0B  &B  C  C C<',G$ &tGH!::4;;w;WXXH6 XF#*W WZ^ZcZcdlZm mnn??8V4D))$d6G6GRV6WXI**4CF"//i@F7OMDGG&ZZ]a]f]fgo]ppqqM 	"  i a g Ys[   H*HAH*'H(AH*,H"-:H*'H%(A-H*H(CH*H*"H*%H*(H*tradec                 t   U R                  USS5      nU R                  X25      nUS   nU R                  USS5      nU R                  USSU5      nU R                  USS5      nU R                  US	5      nU R                  US
5      nUb  UR	                  S5      n	U	S   nU	S   nU R                  US5      n
U R                  USS5      nU R                  USS5      nU R                  USU5      nU R                  US5      nS nU R                  US5      nUc&  [        R                  " U R                  US5      5      nU R                  USS5      nU R                  U5      nU R                  US5      nUbG  Ub  [        R                  " US5      (       a(  U R                  US5      nUb  UnU R                  U5      nUb  UUS.nS nU R                  US5      nUb  UR                  S5      S:  a  UnOU R                  U/ SQ5      nU R                  UUUUU R                  U5      UUUU
UUUUS.U5      $ ) Nr  rb  r9  
created-at
created_atr  order-idorder_idr3  rX  r  r   r   roler  trade_pricefilled-amountr  trade_volumetrade_turnoverfilled-fees	trade_feezfee-currency	fee_assetzfilled-points0zfee-deduct-currencyr  currencyr=   )trade_idztrade-idr=   )r=   r@  orderr  rT  rb  rX  r4  takerOrMakerr  r  r  r_  )r  r5  r\  rD  r  r  r7   
string_negr  string_equalsfindsafe_string_n
safe_trader  )r/  rF  r`  rg  rb  r  rX  r4  rX  	typePartsrY  priceStringamountString
costStringr_  feeCostfeeCurrencyIdfeeCurrencyfilledPointsfeeDeductCurrencyr=   safeIds                         r1  parse_tradehtx.parse_trade.
  s|   ^ %%e_hG!!(3!''t\B	''|]IV	""5*jA{3v.

3IQ<DQ<D--eV<((G))%(K''~|L%%e-=>
""5-8?(()9)9%)MNG**5.+N--m<''?#G$9$9'3$G$G$($4$4U<Q$R!$0*G"&"9"9:K"LK'C !!%.&++c"2a"7B##E+IJB"Y/( " 
  	r3  sincec                    #    SnUb  U R                  U5      nSnU R                  SXe5      u  puUS:w  a  [        U R                  S-   5      eU R	                  XX4U5      I Sh  vN $  N7f)a  
fetch all the trades made from a single order

https://huobiapi.github.io/docs/spot/v1/en/#get-the-match-result-of-an-order

:param str id: order id
:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Nr   rM   z6 fetchOrderTrades() is only supported for spot markets)r`  rB  r/   r=   fetch_spot_order_trades)r/  r=   rb  rk  r  rM  r`  rN  s           r1  fetch_order_tradeshtx.fetch_order_trades
  st      [[(F
!??@RTZc
tww)aabb11"eFSSSSs   A!A*#A($A*c                    #    U R                  5       I Sh  vN   SU0nU R                  U R                  Xe5      5      I Sh  vN nU R                  US   SX45      $  NF N7f)a,  
@ignore
       fetch all the trades made from a single order

       https://huobiapi.github.io/docs/spot/v1/en/#get-the-match-result-of-an-order

       :param str id: order id
       :param str symbol: unified market symbol
       :param int [since]: the earliest time in ms to fetch trades for
       :param int [limit]: the maximum number of trades to retrieve
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
       NrJ  rY  )rA  .spotPrivateGetV1OrderOrdersOrderIdMatchresultsrm  parse_trades)r/  r=   rb  rk  r  rM  rn  rP  s           r1  rm  htx.fetch_spot_order_trades
  si      !!!
 LLT[[Y`Mijj  &!14FF 	" ks!   A!A+A!AA!A!c                 \  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX45      I Sh  vN $ SnUb  U R                  U5      nSnU R	                  SXd5      u  pt0 nSn	US:X  ah  Ub  U R                  U5      nUS   US'   Ub  X8S'   Ub  X(S	'   U R                  S
X5      u  pU R                  U R                  X5      5      I Sh  vN n	GO]Uc  [        U R                  S-   5      eUS   US'   SUS'   Ub  X(S'   U R                  SX5      u  pUb  X8S'   US   (       a{  Sn
U R                  SU5      u  pU
c  SOU
n
U
S:X  a)  U R                  U R                  X5      5      I Sh  vN n	OU
S:X  a(  U R                  U R                  X5      5      I Sh  vN n	OUS   (       a  US:X  a1  US   US'   U R                  U R                  X5      5      I Sh  vN n	OMUS:X  a)  U R                  U R                  X5      5      I Sh  vN n	O[        U R                  S-   U-   S-   5      eU R!                  U	S5      n[#        U[$        5      (       d  U R!                  US5      nU R'                  XX#5      $  GN GNN GN GN N N N~7f)a  

https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-match-results-via-multiple-fields-new
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-match-results-via-multiple-fields-new
https://huobiapi.github.io/docs/spot/v1/en/#search-match-results

fetch all trades made by the user
:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch trades for
: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 Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
NFr   paginaterM   r=   rb  size
start-timeend-timez+ fetchMyTrades() requires a symbol argumentr   r   
trade_type
start_timeend_time	page_sizer   crossisolatedr   rP   r  rO   z" fetchMyTrades() does not support  marketsrY  trades)rA  r  fetch_paginated_call_dynamicr`  rB  handle_until_option!spotPrivateGetV1OrderMatchresultsrm  r)   r=   handle_margin_mode_and_params7contractPrivatePostLinearSwapApiV3SwapMatchresultsExact<contractPrivatePostLinearSwapApiV3SwapCrossMatchresultsExact1contractPrivatePostApiV3ContractMatchresultsExact1contractPrivatePostSwapApiV3SwapMatchresultsExactr/   rK  r  r  rr  )r/  rb  rk  r  rM  ru  r`  rN  rn  rP  r  r  s               r1  fetch_my_tradeshtx.fetch_my_trades
  s      !!!88R\]::?F[`iii[[(F
!??QW`

& !V,$*4L! "' (-%"66z7SOG!CCDKKPWD`aaH~'2_(_``"(,GJ$%GL! (-%"66z7SOG ',$h!
%)%G%GY_%`"
)3);W*
+%)%a%abfbmbmnub~%H7*%)%f%fgkgrgrsz  hD  &E   EH	")(.z(:GH%%)%[%[\`\g\gho\x%yyH6)%)%[%[\`\g\gho\x%yyH&tww1U'UXb'beo'oppF 62&$''__VX6F  >>S 	" jH b"  @  E  zys   J,J8J,JBJ,+J ,B J,J#.J,;J&<A J,<J(=.J,+J*,A/J,J, J,#J,&J,(J,*J,r!  c                 T  #    U R                  5       I Sh  vN   U R                  U5      n0 nUb  [        US5      US'   SnUS   (       av  US   (       a1  US   US'   U R                  U R	                  Xd5      5      I Sh  vN nOUS   (       a0  US   US	'   U R                  U R	                  Xd5      5      I Sh  vN nOUS
   (       an  US   US	'   US   (       a)  U R                  U R	                  Xd5      5      I Sh  vN nOcUS   (       a(  U R                  U R	                  Xd5      5      I Sh  vN nO0US   US'   U R                  U R	                  Xd5      5      I Sh  vN nU R                  US/ 5      n/ n	[        S[        U5      5       HY  n
U R                  X   S/ 5      n[        S[        U5      5       H(  nU R                  X   U5      nU	R                  U5        M*     M[     U R                  U	S5      n	U R                  XS   X#5      $  GN GN GNb GN  N N7f)a  

https://huobiapi.github.io/docs/spot/v1/en/#get-the-most-recent-trades
https://huobiapi.github.io/docs/dm/v1/en/#query-a-batch-of-trade-records-of-a-contract
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-a-batch-of-trade-records-of-a-contract
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-a-batch-of-trade-records-of-a-contract

get the list of most recent trades for a particular symbol
:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch
:param int [limit]: the maximum amount of trades to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
Nr%  rv  rP   r   r=   rb  r   r  rO   rY  r   r  )rA  r`  r  #contractPublicGetMarketHistoryTraderm  /contractPublicGetLinearSwapExMarketHistoryTrade)contractPublicGetSwapExMarketHistoryTradespotPublicGetMarketHistoryTraderK  rs  rt  ri  r  sort_byfilter_by_symbol_since_limit)r/  rb  rk  r  rM  r`  rn  rP  rY  rw  rx  r  jrF  s                 r1  fetch_tradeshtx.fetch_trades  s     !!!V$
 !%.GFO(i $*4L!!%!I!I$++V]Jf!gg!+1$<(!%!U!UVZVaVabiVr!ssF^'-d|GO$i !%!O!OPTP[P[\cPl!mm!!%!U!UVZVaVabiVr!ss &tGH!AA$++gB^__H2 x4q#d)$A__TWfb9F1c&k*((F;e$ + %
 fk2009I5XXs 	" h t ns `sl   H(HA*H(H:H(<H=AH(H!2H(4H$50H(%H&&B3H(H(H(!H($H(&H(c           	          U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )Nr=   r  r  r  r  r  )safe_timestamprf  )r/  ohlcvr`  s      r1  parse_ohlcvhtx.parse_ohlcv  sn     t,UF+UF+UE*UG,UH-
 	
r3  r   	timeframec           	      f  #    U R                  5       I Sh  vN   SnU R                  USS5      u  peU(       a  U R                  SXXBUS5      I Sh  vN $ U R                  U5      nSU R	                  U R
                  X"5      0nU R                  USS/5      n	U R                  USS/5      nSn
U R                  US	5      u  pU
b  U R                  U
S-  5      OSnUS
   (       a  Ub  [        US5      US'   OSnU	co  U R                  U5      nSnUc   U R                  5       nXUS-
  -  -
  US'   UnO/U R                  US-  5      nXS'   U R                  XUS-
  -  5      nUb  UOUUS'   SnUS   (       Ga  US   (       a  US   US'   U	S:X  a*  U R                  U R                  X5      5      I Sh  vN nGOU	S:X  a*  U R!                  U R                  X5      5      I Sh  vN nGOqU	S:X  a'  [#        U R$                  S-   US   -   S-   U	-   S-   5      eU R'                  U R                  X5      5      I Sh  vN nGOUS   (       a  US   US'   U	S:X  a*  U R)                  U R                  X5      5      I Sh  vN nGOU	S:X  a'  [#        U R$                  S-   US   -   S-   U	-   S-   5      eU	S:X  a*  U R+                  U R                  X5      5      I Sh  vN nGO{U R-                  U R                  X5      5      I Sh  vN nGOQUS   (       Ga  US   US'   US   (       a  U	S:X  a*  U R/                  U R                  X5      5      I Sh  vN nGOU	S:X  a'  [#        U R$                  S-   US   -   S-   U	-   S-   5      eU	S:X  a*  U R1                  U R                  X5      5      I Sh  vN nGOU R3                  U R                  X5      5      I Sh  vN nGO}US   (       a  U	S:X  a*  U R)                  U R                  X5      5      I Sh  vN nGOCU	S:X  a'  [#        U R$                  S-   US   -   S-   U	-   S-   5      eU	S:X  a)  U R+                  U R                  X5      5      I Sh  vN nOU R-                  U R                  X5      5      I Sh  vN nOUS   US'   SnU R                  USSS5      u  nnU(       d;  Ub  [        US5      US'   U R5                  U R                  X5      5      I Sh  vN nO[Ub  U R                  US-  5      US'   Ub  XS'   Ub  [        SU5      US'   U R7                  U R                  X5      5      I Sh  vN nU R9                  US / 5      nU R;                  UXrX45      $  GNm GN5 GN GN GNS GN GN GN GNI GN GN GN GN7 GN N NV7f)!a  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://huobiapi.github.io/docs/spot/v1/en/#get-klines-candles
https://huobiapi.github.io/docs/dm/v1/en/#get-kline-data
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-kline-data
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data

: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 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)
:param str [params.useHistoricalEndpointForSpot]: True/false - whether use the historical candles endpoint for spot markets or default klines endpoint
:returns int[][]: A list of candles ordered, open, high, low, close, volume
NFr   ru  r!  period	priceTyper  untilr   r%  rv  r   fromtorP   r   r=   rb  markindexpremiumIndex rX  z has no api endpoint for z kline datar   r  rO   r  TrY  )rA  r  "fetch_paginated_call_deterministicr`  rD  r   r]  omithandle_param_integerparse_to_intr  parse_timeframesecondssum1contractPublicGetIndexMarketHistoryMarkPriceKlinerm  (contractPublicGetIndexMarketHistoryIndexr*   r=   #contractPublicGetMarketHistoryKline;contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline>contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline/contractPublicGetLinearSwapExMarketHistoryKline5contractPublicGetIndexMarketHistorySwapMarkPriceKline8contractPublicGetIndexMarketHistorySwapPremiumIndexKline)contractPublicGetSwapExMarketHistoryKlinespotPublicGetMarketHistoryKline!spotPublicGetMarketHistoryCandlesr  parse_ohlcvs)r/  rb  r  rk  r  rM  ru  r`  rn  r  r  untilSecondsdurationcalcualtedEndnowstartrP  useHistoricalrY  s                      r1  fetch_ohlcvhtx.fetch_ohlcv  s    $ !!!88zZ@@v^cpvx|}}}V$d&&t	M
 &&vW/EF	6K#9:11&'B;@;Lt((6SW* "%eT"2  //	: $=,,.C&)	,B&BGFO$'M --edl;E&+FO$(HHU	4J$KM1=1IP](i $*4L!&%)%[%[\`\g\gho\x%yyH')%)%R%RSWS^S^_fSo%ppH.0$TWWs]VF^%CFa%adm%mp}%}~~%)%M%MdkkZaNj%kkH!+1$<(&%)%e%efjfqfqry  gC  &D   DH')$TWWs]VF^%CFa%adm%mp}%}~~.0%)%h%himititu|  jF  &G   GH%)%Y%YZ^ZeZefmZv%wwHF^^'-d|GO$i &%)%_%_`d`k`kls`|%}}H')$TWWs]VF^%CFa%adm%mp}%}~~.0%)%b%bcgcncnovc  &A   AH%)%S%STXT_T_`gTp%qqH!&%)%e%efjfqfqry  gC  &D   DH')$TWWs]VF^%CFa%adm%mp}%}~~.0%)%h%himititu|  jF  &G   GH%)%Y%YZ^ZeZefmZv%wwH &tGH M$($A$A&,Xvx|$}!M6 $&)%&6GFO!%!E!EdkkRYFb!cc $&*&7&7&EGFO+$0DM$&)$&6GFO!%!G!GT[Hd!ee ~~h3  v%GG[ 	" ~L  zp  l  D  Gw
  ~  Aq  D  Gw d fs&  V1V:V1VE#V15V	6/V1%V&AV1<V=AV1>V?AV1V)V1VAV1VAV1/V0)V1V!9V1V$AV10V'1(V1V*A"V1<V-=AV1V/+V1V1	V1V1V1V1V1V1V1V1!V1$V1'V1*V1-V1/V1c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US5      nU R                  U5      $  N@ N)7f)aR  
fetch all the accounts associated with a profile

https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user

: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
NrY  )rA  spotPrivateGetV1AccountAccountsrK  parse_accountsr/  rM  rP  rY  s       r1  fetch_accountshtx.fetch_accounts`  sW      !!!==fEE x0""4(( 	"Es   AAAA(AAc                     U R                  US5      nU R                  U R                  S0 5      nU R                  X2U5      nUU R                  US5      US S.$ )NrX  r  r=   )r@  r=   rX  code)rD  rK  r  )r/  accounttypeIdr  rX  s        r1  parse_accounthtx.parse_accountw  s_     !!'62t||^RH|V<""7D1	
 	
r3  r  c                 4  #    U R                  5       I Sh  vN nU R                  USS5      nUb  U$ US:X  a  US:X  a  SnOUS:X  a  SnSnUb  U R                  U5      n[        S	[	        U5      5       Hx  nXX   n	U R                  U	S
5      n
U R                  U
SS5      nU R                  U	S5      nUS:X  a  X:X  a  U R                  U	S5      s  $ M_  X:X  d  Mf  U R                  U	S5      s  $    U R                  US	0 5      nU R                  US5      $  N7f)a  
fetch all the accounts by a type and marginModeassociated with a profile

https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user

:param str type: 'spot', 'swap' or 'future
:param str [marginMode]: 'cross' or 'isolated'
:param str [symbol]: unified ccxt market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
N	accountId
account-idrM   r}  r  r~  rN   r   r@  subtyperX  r=   )load_accountssafe_value_2rv  rs  rt  rK  rD  )r/  rX  r  rb  rM  accountsr  rg  rx  r  r@  r  typeFromAccountdefaultAccounts                 r1  fetch_account_id_by_typehtx.fetch_account_id_by_type  s/     ++--%%fk<H	 6>W$%z)~~f-Hq#h-(AkG??7F3D&&tY=G"..w?Ox&++GT:: '(''66 ) 1b955/ .s   DDC D<Dc                   #    U R                  U5      I Sh  vN nU R                  US/ 5      n0 n0 U R                  S'   0 U R                  S'   [        S[	        U5      5       GH  nX5   nU R                  US5      nU R                  U5      nU R                  US5      n	U	S:H  n
0 U R                  S   U'   U R                  US	/ 5      n0 n[        S[	        U5      5       GH  nX   nU R                  US
5      nU R                  USS5      nXR                  S   U   U'   UU R                  S   U'   U R                  U5      nUUUU R                  US5      SS.U R                  US5      U R                  US5      S.S.SU R                  US5      S:H  U R                  US5      S:H  U R                  US5      U R                  U R                  U R                  US5      5      5      S.	UU'   GM     U R                  UUUU R                  US5      S:H  SSSSU
SSS.SSS.SSS.S.SUS.5      XH'   GM     U$  GN'7f)z
fetches all available currencies on an exchange

https://huobiapi.github.io/docs/spot/v1/en/#apiv2-currency-amp-chains

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
NrY  networkChainIdsByNamesnetworkNamesByChainIdsr   rV  	assetTypecryptochainschain	baseChaindisplayNameminDepositAmtr  minWithdrawAmtmaxWithdrawAmt)depositr   depositStatusallowedwithdrawStatustransactFeeWithdrawwithdrawPrecision)	r@  r=   networkr  r  r  r   r_  r  
instStatusnormal)r  r   r  )r@  r  r=   r  r  r   r_  r>   rX  r  r  r"  )"spotPublicGetV2ReferenceCurrenciesr  r  rs  rt  rD  r  r  network_id_to_coderf  r.  r  safe_currency_structure)r/  rM  rP  rY  rw  rx  r6  
currencyIdr  r  rX  r  r"  r  
chainEntryuniqueChainIdtitlenetworkCodes                     r1  fetch_currencieshtx.fetch_currencies  s     @@HHJ ~~h313-.13-.q#d)$AGE))%<J**:6D((<I(D;=DLL1248^^E8R8FH1c&k*#Y
 $ 0 0W E**:{MRFS56t<UCHM56}E"55mD&'* $(#3#3J#P#'$
 $(#3#3J@P#Q#'#3#3J@P#Q%	 ##//
OLPYY $ 0 0=M NR[ [++J8MN!%!2!243G3GHXHXYcexHy3z!{%)% +6  77 **5,?8K   $#
  $#!
  $#  "$39 FLI %~ Q Is   IH>H'I	networkIdcurrencyCodec                   > [        U R                  S   R                  5       5      n[        U5      nUS:X  a  [	        U R
                  S-   5      eU R                  U R                  S   X5      n[        [        U ]'  U5      $ )Nr  r   z7 networkIdToCode() - markets need to be loaded at first)
r  r  r  rt  r%   r=   rK  r+  r9   r  )r/  r  r  r  
keysLengthnetworkTitler0  s         r1  r  htx.network_id_to_code"  sq    DLL!9:??ABY
?*c cddt||4L'MydS$2<@@r3  r  c                 t  > Uc  [        U R                  S-   5      e[        U R                  S   R	                  5       5      n[        U5      nUS:X  a  [        U R                  S-   5      eU R                  U R                  S   U0 5      nX;   a  XQ   $ [        [        U ]+  U5      nU R                  XVU5      $ )Nz3 networkCodeToId() requires a currencyCode argumentr  r   z7 networkCodeToId() - markets need to be loaded at first)r)   r=   r  r  r  rt  r%   rK  r+  r9   network_code_to_id)r/  r  r  r  r  uniqueNetworkIdsr  r0  s          r1  r  htx.network_code_to_id+  s    #DGG.c$cddDLL!9:??ABY
?*c cdd??4<<8P+QS_acd*#00 d>{KL??#3<PPr3  c                   #    U R                  5       I Sh  vN   SnU R                  SSU5      u  p!U R                  U R                  S0 5      nU R	                  USSS5      nU R                  USS/5      n0 nUS:H  nUS:H  nU R                  U R                  SS	S
5      nU R                  USS	U5      n	U R                  USS	U	5      n	U	S:H  n
U	S
:H  nSnU R                  SU5      u  pU R                  USS	/5      nUS:H  nUS:H  nUS:H  =(       d    U=(       a    U=(       d    UnSnU(       d  U(       a  U(       a[  U(       a*  U R                  U R                  XQ5      5      I Sh  vN nGO{U R                  U R                  XQ5      5      I Sh  vN nGOQU R                  5       I Sh  vN   U R                  USSU5      I Sh  vN nUUS'   U R                  U R                  XQ5      5      I Sh  vN nOU(       a)  U R                  U R                  XQ5      5      I Sh  vN nOU(       aY  U(       a)  U R                  U R                  XQ5      5      I Sh  vN nOU R!                  U R                  XQ5      5      I Sh  vN nO_U
(       aX  U(       a)  U R#                  U R                  XQ5      5      I Sh  vN nO(U R%                  U R                  XQ5      5      I Sh  vN nSU0nU R                  US5      nU(       d  U(       GaN  U(       a  ['        S[)        U5      5       H  nUU   nU R+                  U R-                  US5      5      nU R                  US5      n0 n['        S[)        U5      5       HA  nUU   nU R-                  US5      nU R/                  U5      nU R1                  UUU5      UU'   MC     U R3                  U5      UU'   M     U$ U R                  US/ 5      n['        S[)        U5      5       HA  nUU   nU R-                  US5      nU R/                  U5      nU R1                  UUU5      UU'   MC     U R3                  U5      n U$ U(       Ga#  ['        S[)        U5      5       GH  nUU   nU R-                  US5      nU R/                  U5      nU(       a  U R                  US0 5      n['        S[)        U5      5       HV  nUU   nU R-                  US5      n UU R5                  US5      S.n!U R+                  U 5      nU!UU'   U R3                  U5      nMX     M  U R7                  5       n"U R-                  US5      U"S'   U R-                  US5      U"S'   U"UU'   U R3                  U5      nGM
     U$ U(       Gap  U R                  US0 5      n#U(       a  ['        S[)        U5      5       H  nUU   nU R                  USS5      n U R9                  U 5      n$U R-                  US5      nU R;                  U5      n%U R-                  U$S U%S!   5      nUc  Mj  U R7                  5       n"U R-                  US"5      U"S'   U R-                  US5      U"S'   0 n&U"U&U'   U$S   nU R3                  U&5      UU'   M     U$ U R7                  5       n"U R-                  U#S#5      U"S'   U R-                  U#S"5      U"S$'   U R                  U#SS5      nU R/                  U5      nU"UU'   U R3                  U5      n U$ U
(       a  ['        S[)        U5      5       Hj  nUU   nU R-                  US5      nU R/                  U5      nU R7                  5       n"U R-                  US5      U"S'   U R-                  US5      U"S'   U"UU'   Ml     U R3                  U5      nU$  GN GN8 GN GN GN GN GN GNV GN0 GN GN7f)%a  

https://huobiapi.github.io/docs/spot/v1/en/#get-account-balance-of-a-specific-account
https://www.htx.com/en-us/opend/newApiPages/?id=7ec4b429-7773-11ed-9966-0242ac110003
https://www.htx.com/en-us/opend/newApiPages/?id=10000074-77b7-11ed-9966-0242ac110003
https://huobiapi.github.io/docs/dm/v1/en/#query-asset-valuation
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-user-s-account-information
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-user-s-account-information
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-query-user-39-s-account-information

query for balance and get the amount of funds available for trading or funds locked in orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param bool [params.unified]: provide self parameter if you have a recent account with unified cross+isolated margin account
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
Nrj   isUnifiedAccountunifiedFrM   rP   r  r6  r   r   r~  r}  rN   r  r@  rY  r   rb  r  rV  margin_assetisolated_swapr  margin_available)r  freemargin_staticr  margin_frozenusedmargin_accountr  r  margin_balancewithdraw_availabletotal)rA  rB  rK  r  r  r  r  r  %spotPrivateGetV1MarginAccountsBalancerm  *spotPrivateGetV1CrossMarginAccountsBalancer  r  /spotPrivateGetV1AccountAccountsAccountIdBalance3contractPrivateGetLinearSwapApiV3UnifiedAccountInfo1contractPrivatePostLinearSwapApiV1SwapAccountInfo6contractPrivatePostLinearSwapApiV1SwapCrossAccountInfo+contractPrivatePostApiV1ContractAccountInfo+contractPrivatePostSwapApiV1SwapAccountInfors  rt  re  rD  r  parse_margin_balance_helpersafe_balancerf  r  r5  safe_currency)'r/  rM  rX  r  r  rn  rM   rP   r  r6  r   r   r  r~  r}  rN   rP  r  rw  rY  rx  r6  rb  balances	subResultr  balancer  r  marginAssetr  r  rg  
subBalancer  ro  r`  rV  accountsByCodes'                                          r1  fetch_balancehtx.fetch_balance9  s      !!!99.$PVW//$,,C,,V5GTYZ6$6	#BC("++DLL:JIW_`$$W.>	>Z$$V-=y'Ri'X%
!??PVW
6$4i#@A*,w&("E(D%2C86%)%O%OPTP[P[\cPl%mmH%)%T%TUYU`U`ahUq%rrH((***"&"?"?dDRX"YY	(1%!%!U!UVZVaVabiVr!ss!UUVZVaVabiVrssH!%!W!WX\XcXcdkXt!uu!%!\!\]a]h]hip]y!zz!%!Q!QRVR]R]^eRn!oo!%!Q!QRVR]R]^eRn!oo@ )x06q#d),A GE!--d.>.>uh.OPF#uf=H&(I"1c(m4"*1+%)%5%5gz%J
#66zB*.*J*J7TXZc*d	$	 5
 &*%6%6y%AF6N -b K  ??4<q#h-0A&qkG!%!1!1':!FJ22:>D#'#C#CGTSY#ZF4L	 1
 **62~ } 1c$i(Q"..unE#66{C$(OOE?B$OM"1c-&89"/"2#'#3#3G_#M$0$($4$4W>P$Q,
 "&!1!1(!;)3v!%!2!26!: : #llnG&*&6&6uo&NGFO&*&6&6uo&NGFO+2F<(!..v6F+ )z O OOD!R0Eq#d),A"1gG#11'?L\]H!--h7F!%!1!1'>!JJ#11*=H++FHhv>NOD '"&,,.*.*:*:7DT*U*.*:*:7O*T/1/6t,!'!1)-):):>)Jv# -H # ,,."&"2"25:N"O#'#3#3E;K#L !//~xP
..z:&t**62  1c$i(q'!--gx@
..z:,,."&"2"27<N"O"&"2"27O"L&t ) &&v.FA	 	"0  nr*Yss vz pos   ^>^E^>(^ ))^>^#^>,^&-^>^)	,^>5^,6/^>%^/&6^>^2(^>^56^><^8=(^>%^;&L?^>)E5^> ^>#^>&^>)^>,^>/^>2^>5^>8^>;^>c                 
  #    U R                  5       I Sh  vN   SnUb  U R                  U5      nSnU R                  SXC5      u  pS0 nSnUS:X  am  U R                  US5      nUb*  U R	                  U R                  Xc5      5      I Sh  vN nGOXS'   U R                  U R                  Xc5      5      I Sh  vN nGOiUc  [        U R                  S-   5      eU R                  USS5      nUc  XS'   OXS'   U R                  USS/5      nUS	   US
'   US   (       a{  Sn	U R                  SU5      u  pU	c  SOU	n	U	S:X  a)  U R                  U R                  Xc5      5      I Sh  vN nOU	S:X  a(  U R                  U R                  Xc5      5      I Sh  vN nOUS   (       a  US:X  a1  US   US'   U R                  U R                  Xc5      5      I Sh  vN nOMUS:X  a)  U R                  U R                  Xc5      5      I Sh  vN nO[!        U R                  S-   U-   S-   5      eU R#                  US5      n
[%        U
[&        5      (       a  U R#                  U
S5      n
U R)                  U
5      $  GN[ GN GN GN N N N}7f)a&  
fetches information on an order made by the user

https://huobiapi.github.io/docs/spot/v1/en/#get-the-order-detail-of-an-order-based-on-client-order-id
https://huobiapi.github.io/docs/spot/v1/en/#get-the-order-detail-of-an-order
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-information-of-an-order
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-information-of-order
https://huobiapi.github.io/docs/dm/v1/en/#get-information-of-an-order
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-information-of-an-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
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   rM   clientOrderIdrJ  z( fetchOrder() requires a symbol argumentclient_order_idrK  r=   r  r   r}  r~  r   rP   r  rb  rO   z fetchOrder() does not support r  rY  r   )rA  r`  rB  rD  )spotPrivateGetV1OrderOrdersGetClientOrderrm  "spotPrivateGetV1OrderOrdersOrderIdr)   r=   r  r  r  /contractPrivatePostLinearSwapApiV1SwapOrderInfo4contractPrivatePostLinearSwapApiV1SwapCrossOrderInfo)contractPrivatePostApiV1ContractOrderInfo)contractPrivatePostSwapApiV1SwapOrderInfor/   rK  r  r  parse_order)r/  r=   rb  rM  r`  rN  rn  rP  r"  r  rX  s              r1  fetch_orderhtx.fetch_orderk  s      !!![[(F
!??f]

  ,,V_EM( "&!O!OPTP[P[\cPl!mm&(
#!%!H!HU\Ie!ff~'2\(\]] ..v7H/ZM$&(
#-:)*6,=+OP'-d|GO$h!
%)%G%GV\%]"
)3);W*
+%)%Y%YZ^ZeZefmZv%wwH7*%)%^%^_c_j_jkr_{%||H	")(.z(:GH%%)%S%STXT_T_`gTp%qqH6)%)%S%STXT_T_`gTp%qqH&tww1R'RU_'_bl'lmm| &1eT""OOE1-E&&q 	"4 n g   x|  rqs   JI1A2J	I4
-J7I78B,J$I:%.JI=A JI?.JJA.J4J7J:J=J?JJc                     S nX#;   a  X2   nOU R                  5       nUS   S:X  a  U R                  US5      US'   US   S:X  a  U R                  US5      US'   U$ )NrX  rF  r  r  frozenr	  )r  rD  )r/  r  r  rw  r  s        r1  r  htx.parse_margin_balance_helper5  sg    >lGllnG6?g%"..w	BGFO6?h&"..w	BGFOr3  c                 p  #    U R                  U R                  SS5      nUS:X  a  Uc  [        U R                  S-   5      eU R	                  5       I S h  vN   S nSU0nUb  U R                  U5      nUS   US'   Ub  X8S'   U R                  US5      US	'   U R                  S	X5      u  pUb  XHS
'   S n	US:X  a)  U R                  U R                  X5      5      I S h  vN n	O(U R                  U R                  X5      5      I S h  vN n	U R                  U	S/ 5      n
U R                  XX45      $  N NT N-7f)Nr  r  z) fetchOrders() requires a symbol argumentstatesr=   rb  rw  i L
rx  rv  rY  )rD  r  r)   r=   rA  r`  r  r  spotPrivateGetV1OrderOrdersrm  spotPrivateGetV1OrderHistoryr  parse_orders)r/  r1  rb  rk  r  rM  methodr`  rn  rP  rY  s              r1  fetch_spot_orders_by_stateshtx.fetch_spot_orders_by_statesA  sL    !!$,,0KMop77~'2](]^^!!! f
" [[(F &tGH$)L!"&((52E"FGJ22:wO#FO77!==dkk'>Z[[H!>>t{{7?[\\H6 ~~h3  u<<y 	"< \\s7   AD6D0BD6D2(D6D4*D62D64D6c                 D   #    U R                  SXX45      I S h  vN $  N7f)NzGpre-submitted,submitted,partial-filled,filled,partial-canceled,canceledr6  r/  rb  rk  r  rM  s        r1  fetch_spot_ordershtx.fetch_spot_orders  s7     556  BH  QV  _  _  	_  _     c                 D   #    U R                  SXX45      I S h  vN $  N7f)Nz filled,partial-canceled,canceledr9  r:  s        r1  fetch_closed_spot_ordershtx.fetch_closed_spot_orders  s#     556XZ`inwwwwr=  c                 d	  #    Uc  [        U R                  S-   5      eU R                  5       I S h  vN   U R                  U5      nSSS.nS nU R	                  USS5      nU R                  US5      n	U R                  USS	5      n
U R                  U/ S
Q5      nU(       d  U	(       d  U
(       a  Ub  X6S'   US   US'   SUS'   OUb  X&S'   US   US'   SUS'   U R                  SXd5      u  pdUS   (       Ga  S nU R                  SU5      u  pUc  SOUnUS:X  a  U(       a*  U R                  U R                  Xd5      5      I S h  vN nGOU	(       a*  U R                  U R                  Xd5      5      I S h  vN nGOU
(       a*  U R                  U R                  Xd5      5      I S h  vN nGOU R                  U R                  Xd5      5      I S h  vN nGO]US:X  a  U(       a*  U R                  U R                  Xd5      5      I S h  vN nGO&U	(       a*  U R!                  U R                  Xd5      5      I S h  vN nGOU
(       a*  U R#                  U R                  Xd5      5      I S h  vN nGOU R%                  U R                  Xd5      5      I S h  vN nGOUS   (       Ga  US   (       a  U(       a*  U R'                  U R                  Xd5      5      I S h  vN nGOTU	(       a*  U R)                  U R                  Xd5      5      I S h  vN nGO#U
(       a)  U R+                  U R                  Xd5      5      I S h  vN nOU R-                  U R                  Xd5      5      I S h  vN nOUS   (       a  US   US'   U(       a)  U R/                  U R                  Xd5      5      I S h  vN nOU	(       a)  U R1                  U R                  Xd5      5      I S h  vN nOXU
(       a)  U R3                  U R                  Xd5      5      I S h  vN nO(U R5                  U R                  Xd5      5      I S h  vN nU R                  US5      n[7        U[8        5      (       d  U R                  US/ 5      nU R;                  XX#5      $  GNO GN? GN GN GN GN GNZ GN, GN GN GN GNf GN@ GN N N N~7f) Nz1 fetchContractOrders() requires a symbol argumentr   rT  )ry  r   stopr  stopLossTakeProfitr  FrB  rC  r  r  r|  r=   r  r$  r  rz  r   r   rX  r{  r   fetchContractOrdersr}  r~  r   rO   rP   r  rb  rY  orders)r)   r=   rA  r`  safe_bool_2rK  r  r  r  r  6contractPrivatePostLinearSwapApiV1SwapTriggerHisordersrm  3contractPrivatePostLinearSwapApiV1SwapTpslHisorders4contractPrivatePostLinearSwapApiV1SwapTrackHisorders/contractPrivatePostLinearSwapApiV3SwapHisorders;contractPrivatePostLinearSwapApiV1SwapCrossTriggerHisorders8contractPrivatePostLinearSwapApiV1SwapCrossTpslHisorders9contractPrivatePostLinearSwapApiV1SwapCrossTrackHisorders4contractPrivatePostLinearSwapApiV3SwapCrossHisorders0contractPrivatePostSwapApiV1SwapTriggerHisorders-contractPrivatePostSwapApiV1SwapTpslHisorders.contractPrivatePostSwapApiV1SwapTrackHisorders)contractPrivatePostSwapApiV3SwapHisorders0contractPrivatePostApiV1ContractTriggerHisorders-contractPrivatePostApiV1ContractTpslHisorders.contractPrivatePostApiV1ContractTrackHisorders)contractPrivatePostApiV3ContractHisordersr  r  r4  )r/  rb  rk  r  rM  r`  rn  rP  r  rC  r  r  rF  s                r1  fetch_contract_ordershtx.fetch_contract_orders  s>    >#DGG.a$abb!!!V$ 	
 ""669=!__V5IJ>>&*e<6#XY(H ',$'-d|GO$%'GM" (-%"(,GJGFO22:wO(J!%!C!CDY[a!bJ%/%7jJZ'%)%`%`aealalmta}%~~H'%)%]%]^b^i^ijq^z%{{H%)%^%^_c_j_jkr_{%||H%)%Y%YZ^ZeZefmZv%wwHw&%)%e%efjfqfqry  gC  &D   DH'%)%b%bcgcncnovc  &A   AH%)%c%cdhdodopw  eA  &B   BH%)%^%^_c_j_jkr_{%||HIf~%)%Z%Z[_[f[fgn[w%xxH'%)%W%WX\XcXcdkXt%uuH%)%X%XY]YdYdelYu%vvH%)%S%STXT_T_`gTp%qqH!$*:$6!%)%Z%Z[_[f[fgn[w%xxH'%)%W%WX\XcXcdkXt%uuH%)%X%XY]YdYdelYu%vvH%)%S%STXT_T_`gTp%qqH^ 62&$''__VXr:F  >>q 	"F  {|w  D  A  B|  yuvq  yuvqs3  /R0R DR0R0R05R60R0&R	')R0R6R0R0R08R90R0)R*)R0RAR0R0R0
R0R0;R!<(R0$R$%AR0&R''/R0R*/R0R,(R0/R.0AR0R0R0	R0R0R0R0R0R0R0R0!R0$R0'R0*R0,R0.R0c           	      h   #    SS0nU R                  XX0R                  XT5      5      I S h  vN $  N7f)Nr   z5,6,7)rX  rm  )r/  rb  rk  r  rM  rn  s         r1  fetch_closed_contract_orders htx.fetch_closed_contract_ordersg  s6     g
 //ukkRYFbccccs   )202c                   #    U R                  5       I Sh  vN   SnUb  U R                  U5      nSnU R                  SXT5      u  pdUS:H  =(       d    US:H  nU(       a!  Uc  [        U R                  S-   U-   S-   5      eU(       a  U R                  XX45      I Sh  vN $ U R                  XX45      I Sh  vN $  N N  N7f)a  

https://huobiapi.github.io/docs/spot/v1/en/#search-past-orders
https://huobiapi.github.io/docs/spot/v1/en/#search-historical-orders-within-48-hours
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-orders-new
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-orders-new
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-history-orders-new
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-history-orders-via-multiple-fields-new

fetches information on multiple orders made by the user
:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param bool [params.trigger]: *contract only* if the orders are trigger trigger orders or not
:param bool [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
:param int [params.until]: the latest time in ms to fetch entries for
:param boolean [params.trailing]: *contract only* set to True if you want to fetch trailing stop orders
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr   rO   rP   z. fetchOrders() requires a symbol argument for  orders)rA  r`  rB  r)   r=   rX  r;  )r/  rb  rk  r  rM  r`  rN  r   s           r1  fetch_ordershtx.fetch_ordersm  s     * !!![[(F
!??v^
&(EjH.D#DGG.^$^ak$knw$wxx33F5QQQ//uMMM 	" RMs4   CB;BCB=C6B?7C=C?Cc                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4S5      I Sh  vN $ SnUb  U R                  U5      nSnU R	                  SXd5      u  ptUS:X  a  U R                  XX45      I Sh  vN $ U R                  XX45      I Sh  vN $  N Nl N" N
7f)a  

https://huobiapi.github.io/docs/spot/v1/en/#search-past-orders
https://huobiapi.github.io/docs/spot/v1/en/#search-historical-orders-within-48-hours
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-orders-new
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-orders-new
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-history-orders-new
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-history-orders-via-multiple-fields-new

fetches information on multiple closed orders made by the user
:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch entries for
: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 Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NFrq   ru  rC   rM   )rA  r  r  r`  rB  r?  r[  )r/  rb  rk  r  rM  ru  r`  rN  s           r1  fetch_closed_ordershtx.fetch_closed_orders  s     & !!!88ATV`a::;NPV_dnqrrr[[(F
!??@SU[d
66veTTT::6%XXX 	" s UXsF   CB;9CB=ACB?C6C7C=C?CCc                 
  #    U R                  5       I Sh  vN   SnUb  U R                  U5      n0 nSnU R                  SXT5      u  ptSnU R                  SXTS5      u  pSn	US:X  a  Ub  US   US'   U R	                  US5      n
U
c|  U R                  5       I Sh  vN   [        S[        U R                  5      5       HA  nU R                  U   nU R	                  US	5      S:X  d  M*  U R	                  US5      n
U
c  MA    O   XS'   Ub  X6S
'   U R                  US5      nU R                  U R                  Xd5      5      I Sh  vN n	GOUb  US   US'   Ub  X6S'   U R                  USS5      nU R                  US5      nU R                  USS5      nU R                  U/ SQ5      nUS:X  Ga  SnU R                  SU5      u  nnUc  SOUnUS:X  a  U(       a*  U R!                  U R                  Xd5      5      I Sh  vN n	GOU(       a*  U R#                  U R                  Xd5      5      I Sh  vN n	GOU(       a*  U R%                  U R                  Xd5      5      I Sh  vN n	GOU R'                  U R                  Xd5      5      I Sh  vN n	GO_US:X  a  U(       a*  U R)                  U R                  Xd5      5      I Sh  vN n	GO(U(       a*  U R+                  U R                  Xd5      5      I Sh  vN n	GOU(       a*  U R-                  U R                  Xd5      5      I Sh  vN n	GOU R/                  U R                  Xd5      5      I Sh  vN n	GOUS:X  Ga  US:X  a  U(       a*  U R1                  U R                  Xd5      5      I Sh  vN n	GO^U(       a*  U R3                  U R                  Xd5      5      I Sh  vN n	GO-U(       a)  U R5                  U R                  Xd5      5      I Sh  vN n	OU R7                  U R                  Xd5      5      I Sh  vN n	OUS:X  a  U R	                  USS5      US'   U(       a)  U R9                  U R                  Xd5      5      I Sh  vN n	OU(       a)  U R;                  U R                  Xd5      5      I Sh  vN n	OXU(       a)  U R=                  U R                  Xd5      5      I Sh  vN n	O(U R?                  U R                  Xd5      5      I Sh  vN n	U R                  U	S5      n[A        U[B        5      (       d  U R                  US/ 5      nU RE                  UXRU5      $  GN' GN GN GNH GN GN GN GN GNc GN5 GN GN GN GNw GNQ GN N N N7f)a  

https://huobiapi.github.io/docs/spot/v1/en/#get-all-open-orders
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-current-unfilled-order-acquisition
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-current-unfilled-order-acquisition

fetch all unfilled currently open orders
:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch open orders for
:param int [limit]: the maximum number of open order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param bool [params.trigger]: *contract only* if the orders are trigger trigger orders or not
:param bool [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
:param boolean [params.trailing]: *contract only* set to True if you want to fetch trailing stop orders
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr   r   rM   r=   rb  r  r   rX  rv  r  r|  rB  r  rC  r  FrD  r}  r~  r   rO   rP   r  usdtrY  rF  )#rA  r`  rB  r  rD  r  rs  rt  r  r  spotPrivateGetV1OrderOpenOrdersrm  rG  rK  r  r  7contractPrivatePostLinearSwapApiV1SwapTriggerOpenorders4contractPrivatePostLinearSwapApiV1SwapTpslOpenorders5contractPrivatePostLinearSwapApiV1SwapTrackOpenorders0contractPrivatePostLinearSwapApiV1SwapOpenorders<contractPrivatePostLinearSwapApiV1SwapCrossTriggerOpenorders9contractPrivatePostLinearSwapApiV1SwapCrossTpslOpenorders:contractPrivatePostLinearSwapApiV1SwapCrossTrackOpenorders5contractPrivatePostLinearSwapApiV1SwapCrossOpenorders1contractPrivatePostSwapApiV1SwapTriggerOpenorders.contractPrivatePostSwapApiV1SwapTpslOpenorders/contractPrivatePostSwapApiV1SwapTrackOpenorders*contractPrivatePostSwapApiV1SwapOpenorders1contractPrivatePostApiV1ContractTriggerOpenorders.contractPrivatePostApiV1ContractTpslOpenorders/contractPrivatePostApiV1ContractTrackOpenorders*contractPrivatePostApiV1ContractOpenordersr  r  r4  )r/  rb  rk  r  rM  r`  rn  rN  r6  rP  r  rx  r  r  rC  r  r  rF  s                     r1  fetch_open_ordershtx.fetch_open_orders  s>    " !!![[(F
!??@QSYb
99:KV]ef!$*4L!((>I ((***q#dmm"45A"mmA.G''8FB$($4$4Wd$C	$0! 6 %.L! "'YYv|4F!AA$++gB^__H!+1$<( ',$&&vvyAG!%9M!N~~fj%@HYYv'\]F("!
%)%G%GHY[a%b"
F)3);W*
+)-)e)efjfqfqry  gC  *D  $D+)-)b)bcgcncnovc  *A  $A!)-)c)cdhdodopw  eA  *B  $B)-)^)^_c_j_jkr_{)|#|7*)-)j)jkokvkvw~  lH  *I  $I+)-)g)ghlhshst{  iE  *F  $F!)-)h)himititu|  jF  *G  $G)-)c)cdhdodopw  eA  *B  $BI%')-)_)_`d`k`kls`|)}#}+)-)\)\]a]h]hip]y)z#z!)-)])]^b^i^ijq^z){#{)-)X)XY]YdYdelYu)v#v8+(,(8(8V(TGH%)-)_)_`d`k`kls`|)}#}+)-)\)\]a]h]hip]y)z#z!)-)])]^b^i^ijq^z){#{)-)X)XY]YdYdelYu)v#vr 62&$''__VXr:F  >>Y 	"" + `" $D $A $B#| $I $F $G $B $~#z#{#v $~#z#{#vse  U3T=BU3U A	U3)U3 AU3UB9U3>U?0U3/U	00U3 U!)U3
U6U3U0U32U30U3#U$)U3U=U3U0U3<U!=0U3-U$.(U3U'AU3"U*#/U3U-/U3U/(U3+U1,AU3 U3U3U3	U3U3U3U3U3U3U3U3!U3$U3'U3*U3-U3/U31U3r   c                 H    SSSSSSSSSSSSSSS.nU R                  X!U5      $ )Nr  canceledclosed	canceling)zpartial-filledzpartial-canceledfilledrz  	submittedr  r  23456711rD  r/  r   statusess      r1  parse_order_statushtx.parse_order_status  sJ     % *"!
$ &99r3  rX  c           	         U R                  USS5      nU R                  U R                  USS5      5      nUb  SnU R                  U/ SQ5      nU R                  US5      nU R                  US5      nS	U;   a  US	   R	                  S
5      nUS   nUS   nU R                  USS5      n	U R                  X5      nU R                  U/ SQ5      n
U R                  USS5      nS nS nUb(  UR                  S5      S:  a  U R                  US5      nO'U R                  USS5      nU R                  U/ SQ5      nU R                  U/ SQ5      nU R                  USS5      nU R                  USS5      nU R                  USU5      nS nUb>  S nU R                  US5      nUb  U R                  U5      nOUS:X  a  US   OUS    nUUS!.nU R                  US"5      nU R                  US#5      nU R                  US$5      nS nUb
  US:X  a  S%OS&nU R                  0 S'U_S(U_S)U_S*U
_S+U R                  U
5      _S,S _SUS   _S	U_S-S _S.S _S/U_SU_S0U R                  US1S25      _S3U_S4U_SU_S5U_S UUUUS6.EU5      $ )7Nerr_codeerr-coder  r   rejected)r=   order_id_strrJ  r3  order_price_typerX  r  r   r   r  rb  )rI  rH  r  r#  client-order-idr`  field-cash-amountvolumer  )zfilled-cash-amountr  rP  )rN  zfield-amountrO  r  order_pricerQ  z
field-feesr_  rS  sellr  r  rU  trade_avg_pricer  reduce_onlyFTr@  r=   r"  r  rT  lastTradeTimestampr  postOnlyr4  r	  
stop-pricetrigger_pricer
  r  r}  )	remainingr   
reduceOnlyr_  r  )r  r  r]  rD  r  r5  safe_integer_nr\  r  rK  r  
safe_orderr  )r/  rX  r`  rejectedCreateOrdersr   r=   r4  rX  	orderTyperg  r  r"  r  r  r}  r  rc  r_  re  rd  r
  r  reduceOnlyIntegerr  s                           r1  r*  htx.parse_order  s`   N  $11%ZP((););E7H)UV+F'IJ{3'9:U?f++C0IQ<DQ<D%%e_hG!!(3''/Z[	**52CE[\499X#6!#;##E+>?D''xBF%%e-jkD##E+\]""5'=A$$UM<H""5%9K ,,UK@M("55mD26&.fWovf~'C ""5*;<1 --e]C
(#4#9J  
E 
" 
 ] 
 	 

 Y/ 
 !$ 
 fX& 
 D 
 4 
  
 D 
 U 
 D..ulOT 
 w 
 D 
  f! 
" f# 
$ $- 
. / 	r3  r  c                    #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eSUS'   U R	                  USSUSU5      I Sh  vN $  NZ N7f)a  
create a market buy order by providing the symbol and cost

https://www.htx.com/en-us/opend/newApiPages/?id=7ec4ee16-7773-11ed-9966-0242ac110003

: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>`
NrM   z9 createMarketBuyOrderWithCost() supports spot orders onlyFr  r`  buy)rA  r`  r/   r=   create_order)r/  rb  r  rM  r`  s        r1  !create_market_buy_order_with_cost%htx.create_market_buy_order_with_cost  sw      !!!V$f~tww)ddee6;23&&vxdFSSS 	"
 Ts"   A5A1AA5,A3-A53A5r4  r  r  trailingPercenttrailingTriggerPricec	                    #    Uc  [        U R                  S-   5      eUc  [        U R                  S-   5      eXhS'   XxS'   U R                  XX4XX5      I Sh  vN $  N7f)a*  
create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much you want to trade in units of the base currency, or number of contracts
:param float [price]: the price for the order to be filled at, in units of the quote currency, ignored in market orders
:param float trailingPercent: the percent to trail away from the current market price
:param float trailingTriggerPrice: the price to activate a trailing order, default uses the price argument
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NzA createTrailingPercentOrder() requires a trailingPercent argumentzF createTrailingPercentOrder() requires a trailingTriggerPrice argumentr  r  )r)   r=   r  )	r/  rb  rX  r4  r  r  r  r  rM  s	            r1  create_trailing_percent_order!htx.create_trailing_percent_order  sj      "#DGG.q$qrr'#DGG.v$vww$3 !)=%&&&vT5QQQQs   AAAAc                 ^  #    U R                  5       I Sh  vN   U R                  5       I Sh  vN   U R                  U5      nSnU R                  SU5      u  pU R	                  US   X5      I Sh  vN n	U	US   S.n
UR                  SS5      nUR                  SS5      nU R                  U R                  US   0 5      nU R                  U/ S	Q5      nUc1  U R                  US
0 5      nX;   a  [        U R                  S-   5      eOrUS:X  a  SOSnU R                  USU5      nU R                  X5      U
S'   UU
S'   US:X  d  US:X  a  SU-   nO*US:w  a$  US:w  a  [        U R                  S-   U-   S-   5      eSnU R                  US:H  US:H  U5      u  nnU(       a  SnU R                  USS5      nUS:X  a  US-   nOUS:X  a  SnUS -   U-   U
S'   U R                  US!S"5      nUcF  U R                  U R                  S#0 5      nU R                  US5      nUU R!                  5       -   U
S"'   OUU
S"'   US$:X  a  S%U
S&'   OUS':X  a  S(U
S&'   OUS):X  a  S*U
S&'   US:X  a  US+:X  a  SnS,nU R#                  USS-S,5      u  nnU R%                  US.5      nU R'                  US.5      nUb  U R)                  UU5      nO}U(       ae  Uc  [+        U R                  S/-   5      eU R-                  U5      nU R-                  U5      nU R)                  U[.        R0                  " UU5      5      nOU R)                  X5      nUU
S0'   OU R)                  X5      U
S0'   U R                  US10 5      nUU;   a  U R                  X5      U
S2'   U R'                  U/ S3Q5      nU R3                  X5      $  GN GNy GN87f)4a  
@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'
       :param str side: 'buy' or 'sell'
       :param float amount: how much you want to trade in units of the base currency
       :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param str [params.timeInForce]: supports 'IOC' and 'FOK'
       :param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
       :returns dict: request to be sent to the exchange
       Nr_   rX  r=   )r  rb  zbuy- zsell-)r	  	stopPricer  r  z: createOrder() requires a triggerPrice for a trigger orderr  ltegteoperatorr  r  r  zstop-r  r  z  createOrder() does not support r^  r`  r  r  r  r  z-fokr  r  r  r"  r  r  r}  zsuper-margin-apisourcer~  z
margin-apic2czc2c-margin-apir  Tr  r  z createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argumentr  r  r  )r	  r  r  r"  r  r  r  )rA  r  r`  r  r  replacerK  r  r]  r)   r=   rD  price_to_precisionr/   handle_post_onlyr  uuidr  rf  r  amount_to_precisionr-   number_to_stringr7   
string_mulrm  )r/  rb  rX  r4  r  r  rM  r`  r  r  rn  r  r  r	  r  defaultOperatorstopOperatorr  r  r"  r  brokerIdquoteAmountr  r  ra  r`  r  s                               r1  create_spot_order_requesthtx.create_spot_order_request  s$     !!!  """V$
!??vV
77v
[[	 $Tl
 LL,	%%gr2	//$,,vC))&2]^!__W6FKN*'2n(noo + )-eUO++FJPL$($;$;F$QGL!".GJW$){*B#i/	|+)?O2O"477-O#ORV#VYb#bcc00h1F	UbHbdjk&%I&&v}eD%!F*IE!I*y0**6?DUV __T\\8R@F''5H)1DIIK)?G%&)6G%&  2GH:% ,GH5  0GH!K04-8<8U8UV\^k  nQ  SW  9X5-v##FF3DYYvv.F"66vtD2=&tww  2m  (m  n  n $(#8#8#@L"&"7"7">K"&":":67CUCUVbdoCp"qK"66vF +GH $ 8 8 HGH//'3DbI'#66vEGG6  $N  O{{7++q 	"" \s3   N-N$N-N'AN-2N*3L2N-'N-*N-c                 F   U R                  U5      nUS   U R                  X5      US.nSn	U R                  US:H  US:H  U5      u  pU	(       a  SnU R                  USS5      n
U
S:X  a  S	nOU
S
:X  a  SnU R	                  U/ SQ5      nU R                  USS5      nU R                  USS5      nU R                  USS5      nU R                  USU5      nUSLnUSLnUSLnUSLnU(       aF  U R                  USSS5      nUUS'   U R                  X5      US'   Ub  U R                  X5      US'   GOU(       d  U(       ag  U(       a0  X(S'   U R                  X5      US'   Ub  U R                  X5      US'   OX(S'   U R                  X5      US'   Ub  U R                  X5      US'   OU(       aF  [        R                  " US5      nU R                  U5      US'   XS'   U R                  USS 5      US'   OZU R                  US!S"5      nUb  UUS!'   U R                  US"/5      nUS#:X  d  US:X  d  US	:X  d  US:X  a  U R                  X5      US$'   U R                  US%S&S'5      nU(       d6  U(       d/  U(       a  S(US&'   U R                  U/ S)QS(5      US*'   U(       d  X(S'   U R!                  US+S'5      nU(       a  U(       a  S,US-'   OS.US-'   U R#                  U R$                  S/0 5      nU R                  US5      nUUS0'   U R                  U/ S1Q5      nU R'                  X5      $ )2a  
@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'
       :param str side: 'buy' or 'sell'
       :param float amount: how much you want to trade in units of the base currency
       :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param str [params.timeInForce]: supports 'IOC' and 'FOK'
       :param float [params.trailingPercent]: *contract only* the percent to trail away from the current market price
       :param float [params.trailingTriggerPrice]: *contract only* the price to trigger a trailing order, default uses the price argument
       :returns dict: request to be sent to the exchange
       r=   )r  r  r3  Nr`  	post_onlyr  r  r  fokr  r  r	  r  r  r  sl_trigger_pricer  tp_trigger_pricer  callback_rater  triggerTypetrigger_typeler  r  sl_order_price_typesl_order_pricetp_order_price_typetp_order_price100active_pricer  formula_pricer#  r"  r  r  r  r  Fr   )	leverRate
lever_rater  r  r  r  offsetr  r  channel_code)r  r	  r  r  r  r  r  r  r  r  r  r  )r`  r  r  rD  safe_number_nsafe_number_2r  rf  r  r7   
string_divparse_to_numericr\  r  rG  r  r  rK  r  rm  )r/  rb  rX  r4  r  r  rM  r`  rn  r  r  r	  stopLossTriggerPricetakeProfitTriggerPricer  r  isTrailingPercentOrder	isTriggerisStopLossTriggerOrderisTakeProfitTriggerOrderr  trailingPercentStringr"  r  r  r  r  s                              r1  create_contract_order_request!htx.create_contract_order_request!  s    V$#D\..v>

 001A4;CVX^_D&&v}eD%DE!D))&2`a#11&/K]^!%!3!3F<MOa!b,,V5FX#//8NPUV!0!< ,	!5T!A#9#E ,,V]NTXYK&1GN#'+'>'>v'TGO$ )-)@)@)O&#'?%15-..2.E.Ef.c*+$040G0G0VG,-15-..2.E.Ef.e*+$040G0G0VG,-#$+$6$6$N!'+'<'<=R'SGO$&:N#*.*:*:6CUWf*gG&' //8I?[M(-:)*6O+<=w$%-45=DKDW#'#:#:6#I %%flM5Q
%.F)*&$($7$7@gij$kGL!).2*+%8$+!$*!x<##FD1"*6  $_  `{{7++r3  c                 n	  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U/ SQ5      nU R                  USS5      n	U R                  USS5      n
U R	                  US5      nUSLnUSLnU	SLnU
SLnSnUS   (       aU  U(       a  [        U R                  S	-   5      eU R                  XX4XV5      I Sh  vN nU R                  U5      I Sh  vN nGOU R                  XX4XV5      nUS
   (       Ga:  SnU R                  SU5      u  nnUc  SOUnUS:X  a  U(       a  U R                  U5      I Sh  vN nGOGU(       d  U(       a  U R                  U5      I Sh  vN nGOU(       a  U R                  U5      I Sh  vN nGOU R                  U5      I Sh  vN nGOUS:X  a  U(       a  U R                  U5      I Sh  vN nGOU(       d  U(       a  U R!                  U5      I Sh  vN nGOU(       a  U R#                  U5      I Sh  vN nGOnU R%                  U5      I Sh  vN nGOSUS   (       GaH  U R'                  US5      nUc  [)        U R                  S-   5      eUS   (       a  U(       a  U R+                  U5      I Sh  vN nOU(       d  U(       a  U R-                  U5      I Sh  vN nOU(       a  U R/                  U5      I Sh  vN nOU R1                  U5      I Sh  vN nOUS   (       a  U(       a  U R3                  U5      I Sh  vN nObU(       d  U(       a  U R5                  U5      I Sh  vN nO:U(       a  U R7                  U5      I Sh  vN nOU R9                  U5      I Sh  vN nSnSnUS   (       aY  U R;                  0 SU_SU R'                  US5      _SS_SS_SS_SS_SS_SU_SU_SU_SU_SS_S S_S!S_S"S_S#S_S$S_S%S0EU5      $ U(       a'  U R=                  US0 5      nU R=                  US&0 5      nOAU(       a'  U R=                  US0 5      nU R=                  US'0 5      nOU R=                  US0 5      nU R?                  UU5      $  GNf GN GN GN? GN GN GN GN GN GNx GN` GN GN GN GN GN} GNX GN: GN#7f)(a  
create a trade order

https://huobiapi.github.io/docs/spot/v1/en/#place-a-new-order                   # spot, margin
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-an-order        # coin-m swap
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-trigger-order   # coin-m swap trigger
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-an-order           # usdt-m swap cross
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-trigger-order      # usdt-m swap cross trigger
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order        # usdt-m swap isolated
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-trigger-order   # usdt-m swap isolated trigger
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-set-a-take-profit-and-stop-loss-order-for-an-existing-position
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-set-a-take-profit-and-stop-loss-order-for-an-existing-position
https://huobiapi.github.io/docs/dm/v1/en/#place-an-order                        # coin-m futures
https://huobiapi.github.io/docs/dm/v1/en/#place-trigger-order                   # coin-m futures contract trigger

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much you want to trade in units of the base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param float [params.triggerPrice]: the price a trigger order is triggered at
:param str [params.triggerType]: *contract trigger orders only* ge: greater than or equal to, le: less than or equal to
:param float [params.stopLossPrice]: *contract only* the price a stop-loss order is triggered at
:param float [params.takeProfitPrice]: *contract only* the price a take-profit order is triggered at
:param str [params.operator]: *spot and margin only* gte or lte, trigger price condition
:param str [params.offset]: *contract only* 'both'(linear only), 'open', or 'close', required in hedge mode and for inverse markets
:param bool [params.postOnly]: *contract only* True or False
:param int [params.leverRate]: *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
:param str [params.timeInForce]: supports 'IOC' and 'FOK'
:param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
:param float [params.trailingPercent]: *contract only* the percent to trail away from the current market price
:param float [params.trailingTriggerPrice]: *contract only* the price to trigger a trailing order, default uses the price argument
:param bool [params.hedged]: *contract only* True for hedged mode, False for one way mode, default is False
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r  r  r  r  r  rM   z@ createOrder() does not support trailing orders for spot marketsr   r_   r}  r~  r   r  z createOrder() requires an extra parameter params["offset"] to be set to "open" or "close" when placing orders in inverse marketsrO   rP   r@  r=   rY  r  rT  r  r   rb  rX  r4  r  r  r}  r  r  r  r_  r"  r
  sl_ordertp_order) rA  r`  r  r  rf  r/   r=   r  !spotPrivatePostV1OrderOrdersPlacer  r  2contractPrivatePostLinearSwapApiV1SwapTriggerOrder/contractPrivatePostLinearSwapApiV1SwapTpslOrder0contractPrivatePostLinearSwapApiV1SwapTrackOrder+contractPrivatePostLinearSwapApiV1SwapOrder7contractPrivatePostLinearSwapApiV1SwapCrossTriggerOrder4contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder5contractPrivatePostLinearSwapApiV1SwapCrossTrackOrder0contractPrivatePostLinearSwapApiV1SwapCrossOrderrD  r)   ,contractPrivatePostSwapApiV1SwapTriggerOrder)contractPrivatePostSwapApiV1SwapTpslOrder*contractPrivatePostSwapApiV1SwapTrackOrder%contractPrivatePostSwapApiV1SwapOrder,contractPrivatePostApiV1ContractTriggerOrder)contractPrivatePostApiV1ContractTpslOrder*contractPrivatePostApiV1ContractTrackOrder%contractPrivatePostApiV1ContractOrderr  rK  r*  )r/  rb  rX  r4  r  r  rM  r`  r	  r  r  r  r  r  r  r  rP  spotRequestcontractRequestr  r  rY  rw  s                          r1  r  htx.create_orderx  s    J !!!V$))&2`a#11&/K]^!%!3!3F<MOa!b**63DE!0!< ,	!5T!A#9#E &>%"477-o#opp $ > >vT[` iiK!CCKPPH"@@t]bkOh!
.2.P.PQ^`o.p+
O)3);W*
+ )-)`)`ap)q#q/3K)-)])]^m)n#n/)-)^)^_n)o#o)-)Y)YZi)j#j7* )-)e)efu)v#v/3K)-)b)bcr)s#s/)-)c)cds)t#t)-)^)^_n)o#o	""))&(;>+DGG  7z  -z  {  {&> )-)Z)Z[j)k#k/3K)-)W)WXg)h#h/)-)X)XYh)i#i)-)S)STc)d#dH% )-)Z)Z[j)k#k/3K)-)W)WXg)h#h/)-)X)XYh)i#i)-)S)STc)d#d> &>?? $$d&&x8$ T$ D	$
 %d$ $$ $$ $ $ $ &$ $$ T$ $ $$  t!$"  #$$ 4%$& ' ( $??8VR8D__T:r:F%??8VR8D__T:r:F__Xvr:F//w 	" jP $r#n#o#j $w#s#t#o $l#h#i#d $l#h#i#dsW  R5Q<B2R5	Q?
R5"R#A#R5R(R5/R0!R5RR5,R-'R5R(R5=R>!R5R R5:R;A#R5R'R5R  R5'R#(R5R&*R5,R)-'R5R, R55R/6R5R2C-R5?R5R5R5R5R5R5R5R5R5R5R5 R5#R5&R5)R5,R5/R52R5rF  c           	        #    U R                  5       I Sh  vN   / nSnSnSn[        S[        U5      5       GHE  nX   nU R                  US5      n	Uc  U	nOXI:w  a  [	        U R
                  S-   5      eU R                  US5      n
U R                  US5      nU R                  US5      nU R                  US5      nU R                  US	0 5      nU R                  S
U5      nUS   nUb$  Uc  UnOUU:w  a  [	        U R
                  S-   5      eU R                  U5      nSnUS   (       a  U R                  XXX5      I Sh  vN nOU R                  XXX5      nU R                  US5      nUR                  U5        GMH     0 nSnUS   (       a  U R                  U5      I Sh  vN nOUUS'   US   (       aG  Uc  SOUnUS:X  a  U R                  U5      I Sh  vN nOqUS:X  a  U R                  U5      I Sh  vN nOQUS   (       aG  US   (       a  U R!                  U5      I Sh  vN nO#US   (       a  U R#                  U5      I Sh  vN nSnUS   (       a  U R                  US/ 5      nOKU R                  US0 5      nU R                  US/ 5      nU R                  US/ 5      nU R%                  UU5      nU R'                  UU5      $  GN GN GN0 N N N N7f)a  
create a list of trade orders

https://huobiapi.github.io/docs/spot/v1/en/#place-a-batch-of-orders
https://huobiapi.github.io/docs/dm/v1/en/#place-a-batch-of-orders
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-a-batch-of-orders
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-a-batch-of-orders
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-a-batch-of-orders

: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 exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   rb  z; createOrders() requires all orders to have the same symbolrX  r4  r  r  rM  r`   zS createOrders() requires all orders to have the same margin mode(isolated or cross)rM   r  orders_datar   r}  r~  r   rO   rP   rY  successerrors)rA  rs  rt  rD  r*   r=   rK  r  r`  r  r  r  r  privatePostOrderBatchOrders0contractPrivatePostLinearSwapApiV1SwapBatchorder5contractPrivatePostLinearSwapApiV1SwapCrossBatchorder*contractPrivatePostSwapApiV1SwapBatchorder*contractPrivatePostApiV1ContractBatchorderr  r4  )r/  rF  rM  ordersRequestsrb  r`  r  rx  rawOrderrg  rX  r4  r  r  orderParamsmarginResultcurrentMarginModeorderRequestrn  rP  rw  rY  r  r  s                           r1  create_ordershtx.create_orders  s     !!!
q#f+&AyH''(;H~!%$TWW/l%lmm##Hf5D##Hf5D__Xx8FOOHg6E//(HbAK==nkZL ,Q ,%!2J!%66(  4I  *I  J  J[[(FLf~%)%C%CHTXbg%uu#AA(RV`es99\<@L!!,/9 ': &>!==nMMH%3GM"h)3);W*
+%)%Z%Z[b%ccH7*%)%_%_`g%hhH	"&>%)%T%TU\%]]HH%%)%T%TU\%]]HT &>__Xvr:F??8VR8DoodIr:G__T8R8F&&w7F  00I 	":  v N  dh  ^]s~   KKD*KKA"K$K%5KKK:K;-K(K)#KKBKKKKKKKc                 
  #    U R                  5       I Sh  vN   SnUb  U R                  U5      nSnU R                  SXC5      u  pS0 nSnUS:X  a  U R                  USS5      nUc.  XS'   U R	                  U R                  Xc5      5      I Sh  vN nGOWXS'   U R                  USS/5      nU R                  U R                  Xc5      5      I Sh  vN nGOUc  [        U R                  S-   5      eU R                  USS5      nUc  XS	'   OXS'   U R                  USS/5      nUS
   (       a	  US   US'   OUS   US'   U R                  USS5      n	U R                  US5      n
U R                  USS5      nU R                  U/ SQ5      nUS   (       Ga  SnU R                  SU5      u  pUc  SOUnUS:X  a  U	(       a*  U R                  U R                  Xc5      5      I Sh  vN nGOU
(       a*  U R                  U R                  Xc5      5      I Sh  vN nGOU(       a*  U R!                  U R                  Xc5      5      I Sh  vN nGOU R#                  U R                  Xc5      5      I Sh  vN nGOuUS:X  a  U	(       a*  U R%                  U R                  Xc5      5      I Sh  vN nGO>U
(       a*  U R'                  U R                  Xc5      5      I Sh  vN nGOU(       a*  U R)                  U R                  Xc5      5      I Sh  vN nGOU R+                  U R                  Xc5      5      I Sh  vN nGOUS   (       Ga  US   (       a  U	(       a*  U R-                  U R                  Xc5      5      I Sh  vN nGOlU
(       a*  U R/                  U R                  Xc5      5      I Sh  vN nGO;U(       a*  U R1                  U R                  Xc5      5      I Sh  vN nGO
U R3                  U R                  Xc5      5      I Sh  vN nOUS
   (       a  U	(       a)  U R5                  U R                  Xc5      5      I Sh  vN nOU
(       a)  U R7                  U R                  Xc5      5      I Sh  vN nOwU(       a)  U R9                  U R                  Xc5      5      I Sh  vN nOGU R;                  U R                  Xc5      5      I Sh  vN nO[=        U R                  S-   U-   S-   5      eU R                  U R?                  Xt5      USS.5      $  GN GN GNF GN5 GN GN GN GN~ GNP GN" GN GN GN GN\ GN5 N N N Nz7f)aF  
cancels an open 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 boolean [params.trigger]: *contract only* if the order is a trigger trigger order or not
:param boolean [params.stopLossTakeProfit]: *contract only* if the order is a stop-loss or take-profit order
:param boolean [params.trailing]: *contract only* set to True if you want to cancel a trailing order
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
NrW   rM   r  r"  rJ  z) cancelOrder() requires a symbol argumentr#  rK  rP   r  rb  r=   r  rB  r  rC  r  FrD  r   r}  r~  r   rO   z  cancelOrder() does not support r  rz  )r=   r   ) rA  r`  rB  r  /spotPrivatePostV1OrderOrdersOrderIdSubmitcancelrm  r  3spotPrivatePostV1OrderOrdersSubmitCancelClientOrderr)   r=   rG  rK  r  r  3contractPrivatePostLinearSwapApiV1SwapTriggerCancel0contractPrivatePostLinearSwapApiV1SwapTpslCancel1contractPrivatePostLinearSwapApiV1SwapTrackCancel,contractPrivatePostLinearSwapApiV1SwapCancel8contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancel5contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel6contractPrivatePostLinearSwapApiV1SwapCrossTrackCancel1contractPrivatePostLinearSwapApiV1SwapCrossCancel-contractPrivatePostSwapApiV1SwapTriggerCancel*contractPrivatePostSwapApiV1SwapTpslCancel+contractPrivatePostSwapApiV1SwapTrackCancel&contractPrivatePostSwapApiV1SwapCancel-contractPrivatePostApiV1ContractTriggerCancel*contractPrivatePostApiV1ContractTpslCancel+contractPrivatePostApiV1ContractTrackCancel&contractPrivatePostApiV1ContractCancelr/   r*  )r/  r=   rb  rM  r`  rN  rn  rP  r"  r  rC  r  r  s                r1  cancel_orderhtx.cancel_order  s     !!![[(F
!??v^

  ..v7H/ZM$&(
#!%!U!UVZVaVabiVr!ss-:)*6,=+OP!%!Y!YZ^ZeZefmZv!ww~'2](]^^ ..v7H/ZM$&(
#-:)*6,=+OPh$*:$6!+1$<(&&vvyAG!%9M!N~~fj%@HYYv'\]Fh!
%)%G%GW]%^"
)3);W*
+)-)a)abfbmbmnub~)#+)-)^)^_c_j_jkr_{)|#|!)-)_)_`d`k`kls`|)}#})-)Z)Z[_[f[fgn[w)x#x7*)-)f)fgkgrgrsz  hD  *E  $E+)-)c)cdhdodopw  eA  *B  $B!)-)d)deiepepqx  fB  *C  $C)-)_)_`d`k`kls`|)}#}	""&>)-)[)[\`\g\gho\x)y#y+)-)X)XY]YdYdelYu)v#v!)-)Y)YZ^ZeZefmZv)w#w)-)T)TUYU`U`ahUq)r#rH%)-)[)[\`\g\gho\x)y#y+)-)X)XY]YdYdelYu)v#v!)-)Y)YZ^ZeZefmZv)w#w)-)T)TUYU`U`ahUq)r#r"477-O#OR\#\_i#ijj( {{4++H= @
  	W 	". t x0 $@#|#}#x $E $B $C#} $z#v#w#r $z#v#w#rsX  UTA7UTAUTDU$T%0UT0UT)U0T"16U'T%(0UT(0U	T+
)U3T.4AU9T1:0U*T4+0UT7)UT:9U?T= /U/T?0/UU (UU	AUUUUUU"U%U(U+U.U1U4U7U:U=U?UUUidsc                 N	  #    U R                  5       I Sh  vN   SnUb  U R                  U5      nSnU R                  SXC5      u  pS0 nSnUS:X  a  U R                  USS5      nU R                  USSU5      nUc!  [	        U[
        5      (       a  U/US'   O9XS'   O4[	        U[
        5      (       a  U/US'   OXS'   U R                  U/ S	Q5      nU R                  U R                  Xc5      5      I Sh  vN nGObUc  [        U R                  S
-   5      eU R                  USS5      nU R                  USSU5      nUc  SR                  U5      US'   OXS'   U R                  U/ SQ5      nUS   (       a	  US   US'   OUS   US'   U R                  USS5      n	U R                  US5      n
U R                  U/ SQ5      nUS   (       GaA  SnU R                  SU5      u  pUc  SOUnUS:X  a  U	(       a*  U R!                  U R                  Xc5      5      I Sh  vN nGO=U
(       a*  U R#                  U R                  Xc5      5      I Sh  vN nGOU R%                  U R                  Xc5      5      I Sh  vN nGOUS:X  a  U	(       a*  U R'                  U R                  Xc5      5      I Sh  vN nGOU
(       a*  U R)                  U R                  Xc5      5      I Sh  vN nGOzU R+                  U R                  Xc5      5      I Sh  vN nGOPUS   (       Ga'  US   (       a  U	(       a*  U R-                  U R                  Xc5      5      I Sh  vN nGO
U
(       a)  U R/                  U R                  Xc5      5      I Sh  vN nOU R1                  U R                  Xc5      5      I Sh  vN nOUS   (       a  U	(       a)  U R3                  U R                  Xc5      5      I Sh  vN nOwU
(       a)  U R5                  U R                  Xc5      5      I Sh  vN nOGU R7                  U R                  Xc5      5      I Sh  vN nO[9        U R                  S-   U-   S-   5      eU R;                  US 5      nU R=                  U5      $  GNi GN GNm GN? GN GN GN GN GNL GN N N N Nj7f)!a  
cancel multiple orders
:param str[] ids: order ids
:param str symbol: unified market symbol, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param bool [params.trigger]: *contract only* if the orders are trigger trigger orders or not
:param bool [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NrX   rM   r  r"  client-order-idsclientOrderIdsz	order-ids)r  r$  r"  r%  z* cancelOrders() requires a symbol argumentr#  client_order_ids,rK  )r#  r&  r"  r%  rP   r  rb  r=   r  rB  r  rC  )rB  rC  r  r   r}  r~  r   rO   z! cancelOrders() does not support r  rY  )rA  r`  rB  r  r  strr  'spotPrivatePostV1OrderOrdersBatchcancelrm  r)   r=   r  joinrG  rK  r  r  r  r  r  r  r  r  r  r  r  r  r  r/   r  parse_cancel_orders)r/  r"  rb  rM  r`  rN  rn  rP  r%  r  rC  r  rY  s                r1  cancel_ordershtx.cancel_orders	  sn     !!![[(F
!??PV_
	
 !..v7H/ZN!..v7IK[]klN%nc22,/5GK(+.K(nc223A2BG./2@./6+uv!II$++V]JfggH~'2^(^__!//8I?[N!//8JL\^lmN%&)hhsm
#-;)*6+uvh$*:$6!+1$<(&&vvyAG!%9M!NYYv'PQFh!
%)%G%GX^%_"
)3);W*
+)-)a)abfbmbmnub~)#+)-)^)^_c_j_jkr_{)|#|)-)Z)Z[_[f[fgn[w)x#x7*)-)f)fgkgrgrsz  hD  *E  $E+)-)c)cdhdodopw  eA  *B  $B)-)_)_`d`k`kls`|)}#}	""&>)-)[)[\`\g\gho\x)y#y+)-)X)XY]YdYdelYu)v#v)-)T)TUYU`U`ahUq)r#rH%)-)[)[\`\g\gho\x)y#y+)-)X)XY]YdYdelYu)v#v)-)T)TUYU`U`ahUq)r#r"477-P#PS]#]`j#jkkh ~~h/''--Q 	"> h0 $@#|#x $E $B#} $z#v#r $z#v#rs   R%Q?CR%3R4D$R%R0R%	R
)R%3R46R%*R+0R%R)R%RAR%R0R%<R=(R%%R&9R%R /R%R!(R%8R#9AR%R%R%R%R%R%R%R%R%R%R%R%!R%#R%c                    U R                  US5      nS nUb  UR                  S5      nOU R                  US/ 5      nU R                  USS/ 5      n/ n[	        S[        U5      5       H+  nX6   nUR                  U R                  UUSS.5      5        M-     [	        S[        U5      5       HM  nXF   nUR                  U R                  UU R                  US	S
5      SU R                  US5      S.5      5        MO     U$ )N	successesr'  r  r  failedr   rz  )r@  r=   r   rJ  rK  r  )r@  r=   r   r"  )	rD  r  r  r"  rs  rt  r  r  r  )r/  rF  r/  r  r0  rw  rx  rX  s           r1  r+  htx.parse_cancel_orders  s   : $$V[9	 ooc*GnnVY;G!!&(HbAq#g,'AJEMM$//$+   ( q#f+&AIEMM$//((
JG"!%!1!1%9J!K	+   ' r3  c                 	  #    U R                  5       I Sh  vN   SnUb  U R                  U5      nSnU R                  SX25      u  pB0 nSnUS:X  aY  Ub  US   US'   U R                  U R	                  XR5      5      I Sh  vN nU R                  US5      nU R                  SU05      /$ Uc  [        U R                  S-   5      eUS	   (       a  US
   US'   US   US'   U R                  USS5      nU R                  US5      n	U R                  USS5      n
U R                  U/ SQ5      nUS   (       Ga  SnU R                  SU5      u  pUc  SOUnUS:X  a  U(       a*  U R                  U R	                  XR5      5      I Sh  vN nGOU	(       a*  U R                  U R	                  XR5      5      I Sh  vN nGOU
(       a*  U R!                  U R	                  XR5      5      I Sh  vN nGOU R#                  U R	                  XR5      5      I Sh  vN nGOuUS:X  a  U(       a*  U R%                  U R	                  XR5      5      I Sh  vN nGO>U	(       a*  U R'                  U R	                  XR5      5      I Sh  vN nGOU
(       a*  U R)                  U R	                  XR5      5      I Sh  vN nGOU R+                  U R	                  XR5      5      I Sh  vN nGOUS   (       Ga  US   (       a  U(       a*  U R-                  U R	                  XR5      5      I Sh  vN nGOlU	(       a*  U R/                  U R	                  XR5      5      I Sh  vN nGO;U
(       a*  U R1                  U R	                  XR5      5      I Sh  vN nGO
U R3                  U R	                  XR5      5      I Sh  vN nOUS	   (       a  U(       a)  U R5                  U R	                  XR5      5      I Sh  vN nOU	(       a)  U R7                  U R	                  XR5      5      I Sh  vN nOwU
(       a)  U R9                  U R	                  XR5      5      I Sh  vN nOGU R;                  U R	                  XR5      5      I Sh  vN nO[=        U R                  S-   U-   S-   5      eU R                  US5      nU R?                  U5      $  GN GN2 GN1 GN GN GN GNz GNL GN GN GN GN GNX GN1 N N N Nv7f)aq  
cancel all open orders
:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.trigger]: *contract only* if the orders are trigger trigger orders or not
:param boolean [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
:param boolean [params.trailing]: *contract only* set to True if you want to cancel all trailing orders
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NrU   rM   r=   rb  rY  r@  z- cancelAllOrders() requires a symbol argumentrP   r  r  rB  r  rC  r  FrD  r   r}  r~  r   rO   z$ cancelAllOrders() does not support r  ) rA  r`  rB  1spotPrivatePostV1OrderOrdersBatchCancelOpenOrdersrm  r  r  r)   r=   rG  rK  r  r  r  6contractPrivatePostLinearSwapApiV1SwapTriggerCancelall3contractPrivatePostLinearSwapApiV1SwapTpslCancelall4contractPrivatePostLinearSwapApiV1SwapTrackCancelall/contractPrivatePostLinearSwapApiV1SwapCancelall;contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancelall8contractPrivatePostLinearSwapApiV1SwapCrossTpslCancelall9contractPrivatePostLinearSwapApiV1SwapCrossTrackCancelall4contractPrivatePostLinearSwapApiV1SwapCrossCancelall0contractPrivatePostSwapApiV1SwapTriggerCancelall-contractPrivatePostSwapApiV1SwapTpslCancelall.contractPrivatePostSwapApiV1SwapTrackCancelall)contractPrivatePostSwapApiV1SwapCancelall0contractPrivatePostApiV1ContractTriggerCancelall-contractPrivatePostApiV1ContractTpslCancelall.contractPrivatePostApiV1ContractTrackCancelall)contractPrivatePostApiV1ContractCancelallr/   r+  )r/  rb  rM  r`  rN  rn  rP  rY  r  rC  r  r  s               r1  cancel_all_ordershtx.cancel_all_orders  s     !!![[(F
!??@QSYb

 !$*4L!!SSTXT_T_`gTpqqH >>(F3DD!   ~'2a(abbh$*:$6!'-d|GO$&&vvyAG!%9M!N~~fj%@HYYv'\]Fh!
%)%G%GHY[a%b"
)3);W*
+)-)d)deiepepqx  fB  *C  $C+)-)a)abfbmbmnub~)#!)-)b)bcgcncnovc  *A  $A)-)])]^b^i^ijq^z){#{7*)-)i)ijnjujuv}  kG  *H  $H+)-)f)fgkgrgrsz  hD  *E  $E!)-)g)ghlhshst{  iE  *F  $F)-)b)bcgcncnovc  *A  $A	""&>)-)^)^_c_j_jkr_{)|#|+)-)[)[\`\g\gho\x)y#y!)-)\)\]a]h]hip]y)z#z)-)W)WX\XcXcdkXt)u#uH%)-)^)^_c_j_jkr_{)|#|+)-)[)[\`\g\gho\x)y#y!)-)\)\]a]h]hip]y)z#z)-)W)WX\XcXcdkXt)u#u"477-S#SV`#`cm#mnn >>(F3D++D11S 	"0 rB $C# $A#{ $H $E $F $A $}#y#z#u $}#y#z#usE  S R.A(S ?R1 DS R40S 4R750S %R:&)S R=6S S 0S 7S80S (S))S S	AS S0S 	S
0S :S;)S $S%9S S/S S/S >S?(S 'S(AS 1S 4S 7S :S =S  S S S 	S S S S S S S S S r  c                    #    U R                  5       I Sh  vN   SUS:  a  U R                  US-  5      OS0nU R                  U R                  X25      5      I Sh  vN nU$  NL N7f)a4  
dead man's switch, cancel all orders after the given timeout

https://huobiapi.github.io/docs/spot/v1/en/#dead-man-s-switch

:param number timeout: time in milliseconds, 0 represents cancel the timer
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: the api result
Nr  r   r!  )rA  r  %v2PrivatePostAlgoOrdersCancelAllAfterrm  )r/  r  rM  rn  rP  s        r1  cancel_all_orders_afterhtx.cancel_all_orders_afterH  sm      !!!Wq[t((48q
 CCDKKPWD`aa  	" bs"   A'A#AA'A%A'%A'rV  c                 L   U R                  US5      nU R                  US5      nU R                  US5      nU R                  XR5      nU R                  XR5      nU R                  US5      nU R                  US5      nU R                  U5        UUUU R	                  U5      UUS.$ )Naddress
addressTagrV  noter  )rV  rK  tagr  rM  r@  )rD  r  r  check_addressr  )	r/  depositAddressrV  rK  rN  r  r  rM  r  s	            r1  parse_deposit_addresshtx.parse_deposit_addressc  s     "">9=~|<%%njA
%%j;&&z<7$$^W=	7#..y9"
 	
r3  r  c                 8  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US/ 5      nU R                  XcS   /S5      nU R                  US5      $  N NA7f)a  

https://www.htx.com/en-us/opend/newApiPages/?id=7ec50029-7773-11ed-9966-0242ac110003

fetch a dictionary of addresses for a currency, indexed by network
:param str code: unified currency code of the currency for the deposit address
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `address structures <https://docs.ccxt.com/#/?id=address-structure>` indexed by the network
NrV  r=   rY  r  Fr  )rA  rV  %spotPrivateGetV2AccountDepositAddressrm  rK  parse_deposit_addressesindex_by)r/  r  rM  rV  rn  rP  rY  parseds           r1  "fetch_deposit_addresses_by_network&htx.fetch_deposit_addresses_by_network}  s      !!!==&
 CCDKKPWD`aa x4--df5E4FN}}VY//+ 	"
 bs"   BB?BBA BBc                    #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      u  pEU R                  X5      I Sh  vN nU R	                  US   XF5      nXg   $  NZ N7f)ah  
fetch the deposit address for a currency associated with self account

https://www.htx.com/en-us/opend/newApiPages/?id=7ec50029-7773-11ed-9966-0242ac110003

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
Nr  )rA  rV  handle_network_code_and_paramsrX  )select_network_code_from_unified_networks)r/  r  rM  rV  r  paramsOmitedindexedAddressesselectedNetworkCodes           r1  fetch_deposit_addresshtx.fetch_deposit_address  s|      !!!==&$($G$G$O!!%!H!H!\\"LLXV\M]_j}44 	" ]s!   A5A1<A5A3A53A5c                   #    U R                  5       I S h  vN   U R                  U5      nSUS   0nU R                  U R                  Xd5      5      I S h  vN nU R	                  US/ 5      nU R                  XS   /S5      n	/ n
[        S[        U	5      5       HP  nX   nUS L =(       d    US   U:H  nUS L =(       d    US   U:H  nU(       d  M6  U(       d  M?  U
R                  U5        MR     U
$  N N7f)	NrV  r=   rY  r  Fr   rM  r  )	rA  rV  &spotPrivateGetV2AccountWithdrawAddressrm  rK  rU  rs  rt  r  )r/  r  rM  r  rM  rV  rn  rP  rY  allAddresses	addressesrx  rK  	noteMatchnetworkMatchs                  r1  fetch_withdraw_addresseshtx.fetch_withdraw_addresses  s     !!!==&
 DDT[[QXEabb x433DF;K:LeT	q#l+,A"oGC76?d+BI'4/WWY5G;5VLy\\  ) - ; 	"
 cs.   C5C1?C5C3A6C5C5C53C5c                 0  #    Ub  US:  a  SnU R                  5       I Sh  vN   SnUb  U R                  U5      nSSSS.nUb  US   US'   Ub  X6S	'   U R                  U R                  Xd5      5      I Sh  vN nU R	                  US
   XRU5      $  Np N7f)a  

https://www.htx.com/en-us/opend/newApiPages/?id=7ec4f050-7773-11ed-9966-0242ac110003

fetch all deposits made to an account
:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch deposits for
:param int [limit]: the maximum number of deposits structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
NrC   r  nextr   rX  directr  r=   rV  rv  rY  rA  rV  $spotPrivateGetV1QueryDepositWithdrawrm  parse_transactionsr/  r  rk  r  rM  rV  rn  rP  s           r1  fetch_depositshtx.fetch_deposits  s      =ECKE!!!}}T*H

 "*4.GJ#FOBB4;;wC_``6 &&x'7%PPQ 	" a"   BBAB7B8BBc                 0  #    Ub  US:  a  SnU R                  5       I Sh  vN   SnUb  U R                  U5      nSSSS.nUb  US   US'   Ub  X6S	'   U R                  U R                  Xd5      5      I Sh  vN nU R	                  US
   XRU5      $  Np N7f)a  
fetch all withdrawals made from an account

https://huobiapi.github.io/docs/spot/v1/en/#search-for-existed-withdraws-and-deposits

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch withdrawals for
:param int [limit]: the maximum number of withdrawals structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
NrC   r   rk  r   rl  r=   rV  rv  rY  rn  rq  s           r1  fetch_withdrawalshtx.fetch_withdrawals  s      =ECKE!!!}}T*H

 "*4.GJ#FOBB4;;wC_``2 &&x'7%PPM 	" art  transactionc                 `   U R                  US5      nU R                  U R                  US5      5      nU R                  US5      nUS:X  a  SnU R                  US5      nUb  [        R                  " U5      nU R                  US5      nU R                  US5      nUS	:X  a  UR                  S
5      S:  a  S
U-   nU R                  US5      n	U	S:H  n
0 SU_SU R                  USS5      _SU_SU_SU R                  U5      _SU R                  U5      _SU R                  US5      _SS _SS _SU R                  US5      _SS _SS _SU_SU R                  US5      _SU_SU R                  U R                  US5      5      _SU R                  US 5      _S U
UU R                  U5      S S!.S".E$ )#NrH  rV  rX  r   
withdrawalr_  r  ztx-hashr   0xr   zsub-typeFASTr@  r=   rY  txidr  rT  r  rK  	addressToaddressFromrN  zaddress-tagtagTotagFromr  r   r  r>  z
updated-at)rV  r  rate)commentinternalr_  )r  r  rD  r7   
string_absr\  r  r  r  rf  parse_transaction_statusr.  )r/  rx  rV  r  r  rX  rc  r  txHashr6  r  s              r1  parse_transactionhtx.parse_transaction=  sD   f %%k<@	&&t'7'7Z'PQV4:D"";6((1G$$[':	!!+y9&++d"3a"7F]F"";
;f$
K
$$$[$?
 F
 	

 Y/
 t..y9
 t''Y?
 
 4
 4##K?
 T
 t
 D
 d&&{H=
 
  d33D4D4D[RY4Z[!
" t((lC#
$   ))'2)
 	
r3  c                     0 SS_SS_SS_SS_SS_S	S_S
S
_SS_SS_SS_SS_SS_SS_SS_SS_SS_nU R                  X!U5      $ )Nunknownr0  
confirmingpending	confirmedr7  safeorphanr~  rz  	reexaminerejectpasszwallet-rejectzconfirm-errorrepealedzwallet-transferzpre-transfer	verifyingr  r  s      r1  r  htx.parse_transaction_status  s    
x
 )
 	

 D
 h
 
 

 
 h
 I
 X
 X
  !
" y#
$ I%
& '
* &99r3  rK  rN  c                   #    U R                  XE5      u  pEU R                  5       I Sh  vN   U R                  U5        U R                  U5      nUUS   R	                  5       S.nUb  XGS'   SnU R                  U5      u  pUb  U R                  X5      US'   [        U R                  XU5      5      nU R                  U R                  S0 5      n	U R                  U	SS5      (       Ga   U R                  US	5      n
U
c  U R                  5       I Sh  vN nU R                  U R                  U R                   U5      5      U l        U R                  US
   U0 5      nU R                  US	5      n
U
c  [#        U R$                  S-   5      eU R                  XU5      nU R'                  US	5      nU R)                  U5      n[*        R,                  " X5      n[        U5      n[        U5      US	'   [        U R                  UUU5      5      nX'S'   U R/                  U R1                  Xu5      5      I Sh  vN nU R3                  UU5      $  GN GN9 N7f)a  

https://www.htx.com/en-us/opend/newApiPages/?id=7ec4cc41-7773-11ed-9966-0242ac110003

make a withdrawal
:param str code: unified currency code
:param float amount: the amount to withdraw
:param str address: the address to withdraw to
:param str tag:
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
Nr=   )rK  rV  zaddr-tagr  r   r  Fr_  r"  z withdraw() function can not find withdraw fee for chosen network. You need to re-load markets with "exchange.loadMarkets(True)", or provide the "fee" parameterr  )handle_withdraw_tag_and_paramsrA  rO  rV  r  r[  r  floatcurrency_to_precisionrK  r  r  rf  r  map_to_safe_mapr*  
currenciesr)   r=   r  r  r7   
string_sub$spotPrivatePostV1DwWithdrawApiCreaterm  r  )r/  r  r  rK  rN  rM  rV  rn  r  withdrawOptionsr_  r  targetNetwork	feeStringra  amountSubtractedStringamountSubtractedrP  s                     r1  r   htx.withdraw  s@     99#F!!!7#==& ,,.
 ?"%J"AA&I"#66{IGGt11$LM//$,,
BG>>/<??""651C{#'#8#8#::
"&"6"6t7G7GYc7d"e $0DkSU V&&}e<;+DGG  7Y  -Y  Z  Z224kJIYYvu-F008L%,%7%7%P"$%;<"9-GEN455d<LkZ[F"BB4;;wC_`` %%h99Q 	"$ ; as5   'IIC(IIDI1I2IIIr   c           
      b    U R                  US5      nU R                  S U5      nUUS S US S S S S.	$ )NrY  )	r@  r=   r  rT  rV  r  fromAccount	toAccountr   )rD  r  )r/  r   rV  r=   r  s        r1  parse_transferhtx.parse_transfer  sM     h/&&tX6

 
	
r3  r  r  c                   #    U R                  5       I Sh  vN   U R                  U5      nUS   [        U R                  X5      5      S.nSnU R	                  SSU5      u  pU R                  U5      n	U R                  U5      n
U
S:H  nU	S:H  nU R                  XR                  5      nU R                  XR                  5      nU	S:H  nU
S:H  nU(       a(  U(       a!  [        U R                  S-   U-   S-   U-   5      eU	S	:H  =(       d    U
S	:H  nSnU(       aJ  U	S
-   U
-   nU R                  USU5      nUUS'   U R                  U R                  Xu5      5      I Sh  vN nGOU(       a1  U(       a*  U R                  U R                  Xu5      5      I Sh  vN nGOLU(       a1  U(       a*  U R                  U R                  Xu5      5      I Sh  vN nGOU(       a4  U(       a-  XS'   U R                  U R                  Xu5      5      I Sh  vN nOU(       a4  U(       a-  XS'   U R!                  U R                  Xu5      5      I Sh  vN nOUS:X  aT  U	S:X  d  US:X  a  Sn	OSn
U R                  US5      nU R#                  US5      nUb  U R%                  U5      nUUS'   OSUS'   U(       a  SOU	US'   U(       a  SOU
US'   U R'                  U R                  Xu5      5      I Sh  vN nU R)                  UU5      $  GN GN GNk GN6 N N N&7f)a  
transfer currency internally between wallets on the same account

https://huobiapi.github.io/docs/dm/v1/en/#transfer-margin-between-spot-account-and-future-account
https://huobiapi.github.io/docs/spot/v1/en/#transfer-fund-between-spot-account-and-future-contract-account
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-transfer-margin-between-spot-account-and-usdt-margined-contracts-account
https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-spot-trading-account-to-cross-margin-account-cross
https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-spot-trading-account-to-isolated-margin-account-isolated
https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-cross-margin-account-to-spot-trading-account-cross
https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-isolated-margin-account-to-spot-trading-account-isolated

:param str code: unified currency code
:param float amount: amount to transfer
:param str fromAccount: account to transfer from 'spot', 'future', 'swap'
:param str toAccount: account to transfer to 'spot', 'future', 'swap'
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.symbol]: used for isolated margin transfer
:param str [params.subType]: 'linear' or 'inverse', only used when transfering to/from swap accounts
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
Nr=   rV  r  r   r}  rJ   z+ transfer() cannot make a transfer between z and r  z-to-rX  rb  r   rO   zlinear-swapzmargin-accountr!  rM   r  r  )rA  rV  r  r  r  convert_type_to_accountin_arrayr"  r*   r=   rD   spotPrivatePostV1FuturesTransferrm   privatePostCrossMarginTransferIn!privatePostCrossMarginTransferOutprivatePostDwTransferInMarginprivatePostDwTransferOutMarginr  rv  v2PrivatePostAccountTransferr  )r/  r  r  r  r  rM  rV  rn  r6  fromAccountIdtoAccountIdtoCross	fromCross
toIsolatedfromIsolatedfromSpottoSpotfromOrToFuturesAccountrP  rX  rb  s                        r1  r   htx.transfer   s    * !!!==& D66tDE
 99*dFS44[A229=(!W,	]];9
}}]HH= E)%TWW'TTWbbelloxxyy"/9"<![+QZBZ! 6)K7D##FFD9D"GFO!BB4;;wC_``H'!BB4;;wC_``H6!CCDKKPWD`aaH* +H!??G@\]]Hf -H!@@WA]^^H("!V+1M$1M"/K))&(;684%!^^F3F06G,-06G,-(0fmGFO&,F+GDM!>>t{{7?[\\H ""8X66{ 	"0 a`a ^ _" ]s}   L
K8EL
K;7L
K>7L
L;L
L:L
LBL
!L"L
;L
>L
L
L
L
L
c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US/ 5      nU R                  U5      $  NA N*7f)aP  
fetch the borrow interest rates of all currencies

https://huobiapi.github.io/docs/spot/v1/en/#get-loan-interest-rate-and-quota-isolated

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `isolated borrow rate structures <https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure>`
NrY  )rA  spotPrivateGetV1MarginLoanInforK  parse_isolated_borrow_ratesr  s       r1  fetch_isolated_borrow_rateshtx.fetch_isolated_borrow_ratesT  sZ      !!!<<VDD< x4//55A 	"D   AAAA)AAr@  c           
         U R                  US5      nU R                  X25      nU R                  US/ 5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	UU R                  U5      U R	                  US5      U R                  U	5      U R	                  US5      SS S US.	$ )	Nrb  r  r   r   rV  zactual-ratei \&)	rb  r  baseRater  	quoteRater  r  rT  r@  )rD  re  rK  r  rf  )
r/  r@  r`  rg  rb  r  baseData	quoteDatar  r  s
             r1  parse_isolated_borrow_ratehtx.parse_isolated_borrow_rate  s    0 ##D(3!!(3__T<<
??:q1OOJ2	!!(J7""9j9++F3((=A,,W5)))]C

 
	
r3  c                 ,  #    Uc  [        U R                  S-   5      eSnU R                  USS5      u  pTU(       a  U R                  SXX4SSSS	5	      I Sh  vN $ U R	                  5       I Sh  vN   U R                  U5      nS
US   0nUb  X7S'   OS	US'   SnUS   (       a)  U R                  U R                  Xt5      5      I Sh  vN nOKUS   (       a)  U R                  U R                  Xt5      5      I Sh  vN nO[        U R                  S-   5      eU R                  US5      n	U R                  U	S5      n
U R                  U	S/ 5      n/ n[        S[        U5      5       Hv  nX   nXS'   U R                  US
5      nU R                  U5      nU R                  US5      nUR!                  UUU R#                  US5      UU R%                  U5      S.5        Mx     U R'                  US5      nU R)                  UUS   X#5      $  GN GN GNG GN7f)af  

https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-historical-funding-rate
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-historical-funding-rate

fetches historical funding rate prices
:param str symbol: unified symbol of the market to fetch the funding rate history for
:param int [since]: not used by huobi, but filtered internally by ccxt
:param int [limit]: not used by huobi, but filtered internally by ccxt
:param dict [params]: extra parameters specific to the exchange API endpoint
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
Nz5 fetchFundingRateHistory() requires a symbol argumentFr   ru  current_page
page_indexr   r   r  r=   r|  r   r   zA fetchFundingRateHistory() supports inverse and linear swaps onlyrY  r   funding_timefunding_rate)r@  rb  fundingRater  rT  r  rb  )r)   r=   r  fetch_paginated_call_cursorrA  r`  3contractPublicGetSwapApiV1SwapHistoricalFundingRaterm  9contractPublicGetLinearSwapApiV1SwapHistoricalFundingRater/   rK  rs  rt  rD  re  r  r  rf  r  r  r  )r/  rb  rk  r  rM  ru  r`  rn  rP  rY  cursorrw  ratesrx  r6  rg  symbolInnerr  sorteds                      r1  fetch_funding_rate_historyhtx.fetch_funding_rate_history  s<     >#DGG.e$eff88AZ\fg99:SU[di  tB  DP  RS  UW  X  X  X!!!V$VD\
 #(K #%GK )!UUVZVaVabiVrssHH![[\`\g\gho\xyyHtww)llmm. x0~6vr2q#f+&AIE$*.!''?H**84K))%@ILL%#//~F& LL3  ' e[1009I5XXs X! tysJ   AHHH.H/AHH2H:H;DHHHHc                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n[        R                  " Xv5      nU R                  US5      n	U R                  X5      n
0 SU_SU
_SS _SS _S	S _S
S _SS _SS _SU R                  US5      _SU_SU R                  U5      _SU_SU_SU R                  U5      _SS _SS _SS _SU R                  U5      0E$ )Nestimated_rater  next_funding_timer  r@  rb  	markPrice
indexPriceinterestRateestimatedSettlePricer  rT  r  r  fundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimeinterval)rf  r  rD  r7   r  re  r  parse_funding_interval)r/  r   r`  r  r  r  fundingTimeStringnextFundingTimeStringmillisecondsIntervalrg  rb  s              r1  parse_funding_ratehtx.parse_funding_rate  s     **85EF,,X~F#00;NO ,,X~F $ 0 0;N O&112G[##Ho>!!(3
H
f
 
 $	

 D
 #D
 
 
 4++HnE
  0
 t||,<=
 
 #$8
 "4<<0D#E
 "4
  '!
" &t#
$ 334HI%
 	
r3  c                 6    SSSSSS.nU R                  X!U5      $ )Nr   r   8h16h24h)360000014400000288000005760000086400000r  )r/  r  	intervalss      r1  r  htx.parse_funding_interval%  s-    
	 	X>>r3  c                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nSnUS   (       a)  U R                  U R                  XB5      5      I Sh  vN nOKUS   (       a)  U R	                  U R                  XB5      5      I Sh  vN nO[        U R                  S-   5      eU R                  US0 5      nU R                  Xc5      $  N Nv NE7f)a  
fetch the current funding rate

https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-funding-rate
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-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>`
Nr  r=   r   r   z: fetchFundingRate() supports inverse and linear swaps onlyrY  )	rA  r`  )contractPublicGetSwapApiV1SwapFundingRaterm  /contractPublicGetLinearSwapApiV1SwapFundingRater/   r=   rK  r  )r/  rb  rM  r`  rn  rP  rw  s          r1  fetch_funding_ratehtx.fetch_funding_rate/  s      !!!V$VD\
 )!KKDKKX_LhiiHH!QQRVR]R]^eRnooHtww)eeff  626&&v669 	" jos5   CCAC"C#2CCACCCc                 |  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U R                  SS5      nSnU R	                  USSU5      u  pBUb3  U R                  US5      nU R                  U5      nUS   nU(       a  SOSn0 nSn	US:X  a)  U R                  U R                  X5      5      I Sh  vN n	OGUS:X  a)  U R                  U R                  X5      5      I Sh  vN n	O[        U R                  S-   5      eU R                  U	S	/ 5      n
U R                  X5      $  GN Ns NF7f)
a  
fetch the funding rate for multiple markets

https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-a-batch-of-funding-rate
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-a-batch-of-funding-rate

:param str[]|None symbols: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
Nr  r   r   r6  r   r   z1 fetchFundingRates() not support self market typerY  )rA  r  rD  r  r  r`  4contractPublicGetLinearSwapApiV1SwapBatchFundingRaterm  .contractPublicGetSwapApiV1SwapBatchFundingRater/   r=   rK  parse_funding_rates)r/  rk  rM  r  r6  firstSymbolr`  isLinearrn  rP  rY  s              r1  fetch_funding_rateshtx.fetch_funding_ratesX  sB     !!!%%g.))$,,8H(S77@SU^`no**7A6K[[-Fh'H"*h	G
 h!VVW[WbWbcjWsttH	!!PPQUQ\Q\]dQmnnHtww)\\]]& x4''66O 	" uns5   D<D5B-D<D8.D<3D:4AD<8D<:D<c                 R  #    U R                  5       I Sh  vN   SnU R                  SU5      u  peUc  SOUn0 nUb  U R                  U5      US'   Ub  XGS'   SnSn	US:X  aE  Ub  U R                  U5      nUS   US'   U R	                  U R                  Xu5      5      I Sh  vN n	ODUb  U R                  U5      n
U
S   US	'   U R                  U R                  Xu5      5      I Sh  vN n	U R                  U	S
5      nU R                  X5      nU R                  XX45      $  GN
 N N>7f)a  
fetch the interest owed by the user for borrowing currency for margin trading

https://huobiapi.github.io/docs/spot/v1/en/#search-past-margin-orders-cross
https://huobiapi.github.io/docs/spot/v1/en/#search-past-margin-orders-isolated

:param str code: unified currency code
:param str symbol: unified market symbol when fetch interest in isolated markets
:param int [since]: the earliest time in ms to fetch borrrow interest for
:param int [limit]: the maximum number of structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `borrow interest structures <https://docs.ccxt.com/#/?id=borrow-interest-structure>`
Nrl   r}  z
start-daterv  r~  r=   rb  rV  rY  )rA  r  yyyymmddr`  privateGetMarginLoanOrdersrm  rV  privateGetCrossMarginLoanOrdersrK  parse_borrow_interestsfilter_by_currency_since_limit)r/  r  rb  rk  r  rM  r  rn  r`  rP  rV  rY  interests                r1  fetch_borrow_interesthtx.fetch_borrow_interest  sA     !!!
!??@UW]^
!+!3W*
$(MM%$8GL!#FO#!V,$*4L!!<<T[[=YZZH==.&.tn
#!AA$++gB^__H. x0..t<2285PP[ 	" [
 `s5   D'D B
D'!D#"AD'&D%':D'#D'%D'c                 r   U R                  US5      nUc  SOSnU R                  U5      nU R                  US5      nU R                  US5      nUUU R                  U R                  US5      5      U R	                  US5      U R	                  US5      U R	                  US5      UUU R                  U5      S	.	$ )
Nrb  r}  r~  z
accrued-atrV  zinterest-amountzinterest-ratezloan-amount)	r@  rb  rV  r  r  amountBorrowedr  r  rT  )rD  r5  r  r  rf  r  )r/  r@  r`  rg  r  rb  r  s          r1  parse_borrow_interesthtx.parse_borrow_interest  s    T ##D(3!)!1W

!!(+!!&(3%%dL9	//0@0@z0RS((/@A ,,T?C"..t]C$"Y/

 
	
r3  c                 B    U R                  5       U R                  S   -
  $ )Nr  )millisecondsr  )r/  s    r1  r>  	htx.nonce  s       "T\\2B%CCCr3  r   r  c                 `
   SnU R                  X@R                  U5      5      n[        U[        5      (       Ga  US:X  d  US:X  a  XpR                  -  nOUS:X  d  US:X  a  US-  nUSU R                  X5      -   -  nUS:X  d  US:X  Ga$  U R                  5         U R                  U R                  5       S5      n	SS	U R                  U	S
.n
US:w  a  U R                  X5      n
U R                  U
5      nU R                  US5      nSR                  X0R                  X|/5      nU R                  U R!                  U5      U R!                  U R"                  5      [$        R&                  S5      nUSU R                  SU05      -   -  nUSU-   -  nUS:X  a  U R)                  U5      nSS0nO#SS0nOU(       a  USU R                  U5      -   -  nU R                  U R*                  S   U   SU R                  05      U-   nGO-U R-                  US5      nU R-                  US5      nU R-                  US5      nU R-                  US5      nS nU R/                  U R*                  S   U5      n[        U[        5      (       d<  U R/                  UU5      n[        U[        5      (       d  Ub  U R/                  UU5      nUnXpR                  X5      -  nUS:X  a   U(       a  USU R                  U5      -   -  nGOUS:X  Ga
  U R                  5         US:X  a  U R/                  U R0                  S0 5      nU R-                  USS5      nUR3                  S5      S :X  a1  UR5                  S!5      (       a  U R-                  US"5      nUc  UUS"'   OAUR5                  S#5      (       a+  U R-                  US$5      nUc  UU R7                  5       -   US$'   U R                  U R                  5       S5      n	SS	U R                  U	S
.n
U R                  U
5      n
US:w  a#  U R                  U5      nU R                  U
U5      n
U R                  U
S5      R9                  S%S&5      nSR                  UUX|/5      nU R                  U R!                  U5      U R!                  U R"                  5      [$        R&                  S5      nUSU R                  SU05      -   -  nUSU-   -  nUS:X  a'  U R)                  U5      n[;        U5      S:X  a  S'nSS0nOSS0nU R                  U R*                  S   U   SU05      U-   nXsXeS(.$ ))Nr  r   r   r   r   v2T
HmacSHA256r  )SignatureMethodSignatureVersionAccessKeyId	TimestampPOSTT
base64&	Signature?zContent-Typezapplication/jsonz!application/x-www-form-urlencodedr   rI   r   r   r  r  r   r  r=   r  cancelrX  r  zorders/placer  z%2cz%2Cz{})r   r5  bodyheaders)r  extract_paramsr  r(  rG   implode_paramscheck_required_credentialsymdhmsr>  apiKeyrm  keysort	urlencoder*  rI   hmacencodesecrethashlibsha256r  r   rD  rK  r  r\  endswithr  r  rt  )r/  pathr   r5  rM  r)  r(  r   queryr  rn  sortedRequestauthpayload	signaturerX  accesslevelOneNestedPathlevelTwoNestedPathrI   r   r  r=   channelCoder"  sortedQuerys                             r1  signhtx.sign  s   		&"5"5d";<c3xSI%5||##);t3,,T:::Ci3+#5//1 KK

c:	'3(+#';;!*	! V#"kk'9G $W 5~~mT:))V]]C$FG IIdkk'&:DKK<TV]VdVdfno	dnnk9-EFFFsTz!V#99U+D&(:G
 '(KG 3!666C%%dii&6s&;DMM> C ##C+D%%c1-F!%!1!1#q!9!%!1!1#q!9H		+(>EIi-- OOI7IJ	"9c229K9W $	;M NI H&&t44C!3!666C9$//1V#"oodllHbIG))'4FByy*b0T]]75K5K&*&6&6v~&N&.57F>2~66(,(8(8AR(S(08:TYY[8HF#45 KK

c:	'3(+#';;!*	! ,,w/V#"&,,u"5K"kk';?G~~gt4<<UEJ))VXs$AB IIdkk'&:DKK<TV]VdVdfno	dnnk9-EFFFsTz!V#99U+D4yA~#&(:G
 '(KG %%dii&6t&<H? C dOOr3  httpCodereasonr   r5  r)  r(  c
                 x   Uc  g SU;   a  U R                  US5      n
U
S:X  a  U R                  USS5      nU R                  S-   U-   nU R                  U R                  S   Xl5        U R                  U R                  S   X5        U R                  USS	5      nU R                  U R                  S   X5        [        U5      eS
U;   aC  U R                  S-   U-   nU R                  US
5      nU R                  U R                  S   X5        U R                  US5      nU R                  US5      nUb  U R                  US5      nU R                  US5      nU R                  US	5      nU R                  S-   U-   nU R                  U R                  S   UU5        U R                  U R                  S   UU5        g )Nr   errorr  r  r  r  r  zerr-msgerr_msgr  rY  r  r   )	rD  r  r=   throw_broadly_matched_exceptionr   throw_exactly_matched_exceptionr%   r  r  )r/  rD  rE  r   r5  r)  r(  rP  requestHeadersrequestBodyr   r  feedbackmessagerY  
errorsListro  errcode
errmessagefeedBacks                       r1  handle_errorshtx.handle_errorsu  s   x
 %%h9F ))(J
K77S=4/44T__W5Mt^44T__W5Mt^,,Xy)L44T__W5Mwa#H--Xww}t+H##Hf5D001I4Z~~h/^^D(3
!NN:q1E&&uj9G))%;Jww}t+H001I7T\]001I:W_`r3  c                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  SXT5      u  pgSS0nUb  X(S'   Sn	US:X  a  US   US'   US	   (       a]  Sn
U R                  SU5      u  pU
c  S
OU
n
U
S:X  a	  US   US'   OUS   US'   U R	                  U R                  X5      5      I Sh  vN n	OYU R                  U R                  X5      5      I Sh  vN n	O0US   US'   U R                  U R                  X5      5      I Sh  vN n	U R                  U	S/ 5      nU R                  XX#5      $  GN* N N_ N07f)aH  
fetch the history of funding payments paid and received on self account

https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-account-financial-records-via-multiple-fields-new   # linear swaps
https://huobiapi.github.io/docs/dm/v1/en/#query-financial-records-via-multiple-fields-new                          # coin-m futures
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-financial-records-via-multiple-fields-new          # coin-m swaps

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch funding history for
:param int [limit]: the maximum number of funding history structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
Nr}   rX  z30,31
start_daterO   r=   r   r   r}  r~  mar_acctr  rb  rY  )
rA  r`  rB  r  :contractPrivatePostLinearSwapApiV3SwapFinancialRecordExactrm  4contractPrivatePostSwapApiV3SwapFinancialRecordExact4contractPrivatePostApiV3ContractFinancialRecordExactr  parse_incomes)r/  rb  rk  r  rM  r`  rN  r8  rn  rP  r  rY  s               r1  fetch_funding_historyhtx.fetch_funding_history  sz     !!!V$ >>?TV\e
G
 $)L!"(,GJh. "
%)%G%GH]_e%f"
)3);W*
+*0,GJ'*0*;GJ'!%!`!`aealalmta|!}}, "&!Z!Z[_[f[fgn[v!ww &tGH!VVW[WbWbcjWrssH~~h3!!$==I 	"R ~, x tsF   E	E B%E	<E=(E	%E&0E	E*E	E	E	E	r  c                 L  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nU R	                  SXC5      u  pVSU0nUS:X  a  US   (       a	  US   US'   OUS	   US
'   SnUS   (       a  Sn	U R                  SU5      u  pU	c  SOU	n	U	S:X  a*  U R                  U R                  Xv5      5      I Sh  vN nU$ U	S:X  a*  U R                  U R                  Xv5      5      I Sh  vN nU$ [        U R                  S-   5      eUS:X  a*  U R                  U R                  Xv5      5      I Sh  vN nU$ US:X  a*  U R                  U R                  Xv5      5      I Sh  vN nU$ [        U R                  S-   5      e GNh N N NU N'7f)a  
set the level of leverage for a market

https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-leverage
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-switch-leverage
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#switch-leverage
https://huobiapi.github.io/docs/dm/v1/en/#switch-leverage  # Coin-m futures

:param float leverage: the rate of leverage
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: response from the exchange
Nz) setLeverage() requires a symbol argumentr   r  rP   r   r  rb  r=   r  r   r}  r~  + setLeverage() not support self market typerO   )r)   r=   rA  r`  rB  r  5contractPrivatePostLinearSwapApiV1SwapSwitchLeverRaterm  :contractPrivatePostLinearSwapApiV1SwapCrossSwitchLeverRater/   /contractPrivatePostApiV1ContractSwitchLeverRate/contractPrivatePostSwapApiV1SwapSwitchLeverRate)
r/  r  rb  rM  r`  rN  r8  rn  rP  r  s
             r1  set_leveragehtx.set_leverage  s     >#DGG.Y$YZZ!!!V$ >>}f]
(
 !fY&7 &z 2GH'-d|GO$(J!%!C!CMSY!ZJ%/%7jJZ'!%![![\`\g\gho\w!xxN M w&!%!`!`aealalmta|!}}J G #477-Z#Z[[ X%!%!U!UVZVaVabiVq!rr* ) v%!%!U!UVZVaVabiVq!rr& # #477-Z#Z[[M 	"  y}  srsY   /F$FB F$F/F$FAF$
F /F$:F";F$F$F$ F$"F$c                 .   U R                  US5      nU R                  X25      nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  USS5      nU R                  U5      n	UUU	UU R                  U5      UUS.$ )Nr  r  r9  r=   rb  asset)r@  rb  r  r  rT  r=   r  )rD  re  rf  r  r  r  r  )
r/  incomer`  rg  rb  r  r  r=   r  r  s
             r1  parse_incomehtx.parse_income3  s     ##FO<!!(3!!&(3%%fd3	fd+'''B
&&z2"Y/
 	
r3  positionc                    U R                  U R                  US5      5      nUS   nU R                  US5      nU R                  US5      nU R                  U5      nU R	                  US5      nU R                  US5      nU R                  US5      n	U	S:X  a  S	OS
n
U R	                  US5      nU R                  US5      nU R                  US5      n[
        R                  " U R                  US5      S5      nU R                  US5      n[
        R                  " XF5      nS nUS   (       a  [
        R                  " UU5      nO[
        R                  " UU5      nSn[
        R                  " UU5      nU R                  US5      nU R	                  US5      nU R                  US5      n[
        R                  " UU5      n[
        R                  " UU5      n[
        R                  " UU5      nU R                  0 SU_SS _SU_SU R                  U5      _SU_SU_SU R                  U5      _SU
_SU_SU R                  U5      _SU R                  U5      _SU_S U R                  U5      _S!S _S"S _S#U_S$U R                  U5      _U R                  U5      U R                  U5      U R                  U5      U R                  U5      S S S S S S S%.
E5      $ )&Nr  rb  r  r  	cost_openposition_marginr3  r  longshortprofit_unrealmargin_moder  profit_rater  
last_pricer   r}  r  liquidation_priceadjust_factorr@  r=   	contracts
entryPrice
collateralr4  unrealizedPnlr  r   r  notionalr  	lastPriceliquidationPriceinitialMargin)
initialMarginPercentagemaintenanceMarginmaintenanceMarginPercentagemarginRatior  rT  r  lastUpdateTimestampr  r  )
r5  rD  rK  r  rf  r7   r  r  safe_positionr.  )r/  rk  r`  rb  rw  r  contractSizeStringrx  r~  rawSider4  unrealizedProfitr  r  r   r|  	faceValuer{  intialMarginPercentagery  r}  adjustmentFactorr  r  r  s                            r1  parse_positionhtx.parse_positionO  sS   @ !!$"2"28_"MN!$$Xx8	v~>!22<@%%h<
((3DE""8[9!U*v++HoF%%h>
##Hl;''(8(8=(QSXY
$$X|<	&&yE	()))Y?H)))Y?H J!(!3!3M8!L%%h0@A
++H6IJ++HoF&-&8&89I8&T##../JHU(():JG!! #
H#
$#
 f#
 **95	#

 L#
 *#
 $++J7#
 D#
 -#
 ))(3#
 $++J7#
 *#
 ))(3#
 #
 #
   0!#
" T..}=##
$ (,'8'89O'P!%!2!23D!E+/+<+<=X+Y,,[9#'!#7#
  	r3  c           
      .  #    U R                  5       I Sh  vN   U R                  U5      nSnUb4  [        U5      nUS:  a#  U R                  US5      nU R	                  U5      nSnU R                  SUS5      u  pbSnU R                  SX2S5      u  prSnU R                  SX25      u  pUS:X  a  SnSn	US:X  aX  US:X  a  U R                  U5      I Sh  vN n	OUS:X  a  U R                  U5      I Sh  vN n	Op[        U R                  S	-   5      eUS:X  a  U R                  U5      I Sh  vN n	O8US
:X  a  U R                  U5      I Sh  vN n	O[        U R                  S	-   5      eU R                  U	S/ 5      n
U R                  U	S5      n/ n[!        S[        U
5      5       HK  nX   nU R#                  U5      nUR%                  U R'                  UUU R)                  U5      S.5      5        MM     U R+                  USUS5      $  GN GN8 GN N N7f)a  
fetch all open positions

https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-query-user-39-s-position-information
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-user-s-position-information
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-user-s-position-information
https://huobiapi.github.io/docs/dm/v1/en/#query-user-s-position-information

:param str[] [symbols]: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.subType]: 'linear' or 'inverse'
:param str [params.type]: *inverse only* 'future', or 'swap'
:param str [params.marginMode]: *linear only* 'cross' or 'isolated'
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nr   r   r}  r   rM   rP   r~  z. fetchPositions() not support self market typerO   rY  r9  r  rT  rb  F)rA  r  rt  rD  r`  r  r  rB  2contractPrivatePostLinearSwapApiV1SwapPositionInfo7contractPrivatePostLinearSwapApiV1SwapCrossPositionInfor/   r=   ,contractPrivatePostApiV1ContractPositionInfo,contractPrivatePostSwapApiV1SwapPositionInforK  r  rs  r  r  rm  r  filter_by_array_positions)r/  rk  rM  r`  symbolsLengthro  r  r6  rN  rP  rY  r  rw  rx  rk  rW  s                   r1  fetch_positionshtx.fetch_positions  s*      !!!%%g.LMq ((!4U+
!??@PRXZab
99:JF\de
!??@PRXa
!JhZ'!%!X!XY_!``w&!%!]!]^d!ee"477-]#]^^: X%!%!R!RSY!ZZv%!%!R!RSY!ZZ"477-]#]^^f x4%%h5	q#d)$AwH((2FMM$++f& LL3/   % --fhOOm 	"& ae@ [ZsY   HHB<HHH3H47H+H,HHB=HHHHHc                 $  #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  SU5      u  pBUc  SOUnU R                  SX25      u  pV0 nUS   (       a  US   (       a	  US   US'   OUS:X  a  SUS	'   US
   US'   SnUS   (       av  US:X  a)  U R	                  U R                  Xv5      5      I Sh  vN nOUS:X  a)  U R                  U R                  Xv5      5      I Sh  vN nO[        U R                  S-   5      eUS:X  a)  U R                  U R                  Xv5      5      I Sh  vN nOGUS:X  a)  U R                  U R                  Xv5      5      I Sh  vN nO[        U R                  S-   5      eU R                  US5      n	Sn
US:X  a  U	n
OU R                  U	S5      n
U R                  U
S/5      nU R                  U
S5      nSnUS   (       a;  US   (       a1  [        S[        U5      5       H  nX   nUS   US
   :X  d  M  Un  O   OU R                  US5      nU R                  US5      nU R!                  U R                  X5      5      nUUS'   U R#                  U5      US'   U$  GNk GN GN GNP GN$7f)a|  
fetch data on a single open contract trade position

https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-query-assets-and-positions
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-assets-and-positions
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-assets-and-positions
https://huobiapi.github.io/docs/dm/v1/en/#query-assets-and-positions

:param str symbol: unified market symbol of the market the position is held in, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nr   r}  rP   r   r  rb  r!  r
  r=   r  r   r~  z- fetchPosition() not support self market typerO   r_  rY  r   	positionsr9  r  rT  )rA  r`  r  rB  9contractPrivatePostLinearSwapApiV1SwapAccountPositionInform  >contractPrivatePostLinearSwapApiV1SwapCrossAccountPositionInfor/   r=   3contractPrivatePostApiV1ContractAccountPositionInfo3contractPrivatePostSwapApiV1SwapAccountPositionInforK  r  rs  rt  r  r  r  )r/  rb  rM  r`  r  rN  r8  rn  rP  rY  r  omittedr  rk  rx  r6  r  rW  s                     r1  fetch_positionhtx.fetch_position1  s     !!!V$
!??QWX
!+!3W*
 >>PV_
(y 1 &z 2GHW$,2()'-d|GO$(Z'!%!_!_`d`k`kls`{!||w&!%!d!deiepepqx  fA  "B  B"477-\#\]]n X%!%!Y!YZ^ZeZefmZu!vvv%!%!Y!YZ^ZeZefmZu!vv"477-Z#Z[[L x0 GoodA.G))Gk]3OOG[9	(y 11c)n-!)VD\9$H	 . y!4H%%h5	$$T[[%CD'{!\\)4zW 	"  } Bt wvsa   JJB-JJ.J3J4AJ:J
;.J)J*B-JA'JJJ
JJc                 H    SSSSSSSSSSSSSSS	.nU R                  X!U5      $ )
NrF  r_  r   creditr  rz  exchangerebate)rF  etfztransact-feezfee-deductionr   r  liquidationr  r  r   zwithdraw-feer  zother-typesr  r  )r/  rX  r  s      r1  parse_ledger_entry_typehtx.parse_ledger_entry_type+  sH    !"""  $!"%
  T22r3  itemc                    U R                  US5      nU R                  X25      nU R                  X25      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  UUU R                  US5      UUUU R                  U5      UU R                  US5      UU R                  U5      S S S S S.U5      $ )	NrV  
transactIdtransferTypetransactTimer  r3  transactAmt)r@  r=   r3  r  referenceIdreferenceAccountrX  rV  r  r  rT  beforeafterr   r_  )rD  r  r  r  safe_ledger_entryr  rf  r  )	r/  r  rV  r  r  r=   r  r  r  s	            r1  parse_ledger_entryhtx.parse_ledger_entry>  s     %%dJ7
&&z<%%j;dL1''n=%%dN;	""45%%))$< '00>&&t];"Y/'
  ! 	r3  c                   #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX4S5      I Sh  vN $ U R                  SSSU5      I Sh  vN nSU0nSnUb  U R	                  U5      nUS   US	'   Ub  X'S
'   Ub  X7S'   U R                  SXt5      u  ptU R                  U R                  Xt5      5      I Sh  vN n	U R                  U	S/ 5      n
U R                  XX#5      $  N N N N/7f)aL  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

https://huobiapi.github.io/docs/spot/v1/en/#get-account-history

:param str [code]: unified currency code, default is None
: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 boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
NFr   ru  r  rM   r  r=   rV  	startTimer  endTimerY  )
rA  r  r  r  rV  r  spotPrivateGetV2AccountLedgerrm  rK  parse_ledger)r/  r  rk  r  rM  ru  r  rn  rV  rP  rY  s              r1  fetch_ledgerhtx.fetch_ledgere  s,     !!!88PZ[::=$W\fijjj77dFSS		
 }}T*H"*4.GJ#(K $G229gN;;DKK<XYYB x4  >>w 	" kS( ZsF   D
D9D
DD
,D-A+D
D*D
D
D
D
c                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US/ 5      nU R                  XAS5      $  NB N+7f)a|  
retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
: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
NrY  r  )rA  0contractPublicGetLinearSwapApiV1SwapAdjustfactorr  parse_leverage_tiers)r/  rk  rM  rP  rY  s        r1  fetch_leverage_tiershtx.fetch_leverage_tiers  s\      !!!NNvVV< ~~h3((HHA 	"Vs   AAAA*AAc                    U R                  US5      nU R                  US5      n/ nU R                  US/ 5      n[        S[        U5      5       H  nXg   nU R                  US5      n	U R                  US/ 5      n
[        S[        U
5      5       H  nX   nU R                  US5      nUR	                  U R                  US5      U R                  XBS S	5      U R                  U5      U R                  US
5      U R                  US5      U R                  [        R                  " X5      5      U R                  U	5      US.5        M     M     U$ )Ntrade_partitionr  r  r   r  laddersrv  ladderrO   min_sizemax_size)tierrb  rV  minNotionalmaxNotionalmaintenanceMarginRatemaxLeverager@  )rD  r  rs  rt  r  r  re  r  rf  r.  r7   r  )r/  r@  r`  r  rg  tiersbracketsrx  r  r  r  kbracketadjustFactors                 r1  parse_market_leverage_tiershtx.parse_market_leverage_tiers  s?   %%d,=>
##D/:>>$3q#h-(A;D''l;HnnT9b9G1c'l+!*#//I --gx@"..xvN $ 7 7
 C#'#3#3GZ#H#'#3#3GZ#H-1->->w?Q?QR^?i-j#'#4#4X#>#	 	 ,	 )" r3  r   c                 &  #    US:w  a*  US:w  a$  US:w  a  US:w  a  [        U R                  S-   5      eU R                  5       I Sh  vN   SSS	S
S.nU R                  U5      nU R	                  USSS5      nXb   US.n	Ub  XIS'   Sn
US   (       aI  U R                  US   S5      U	S'   US   U	S'   U R                  U R                  X5      5      I Sh  vN n
OxUS   (       a>  SU	S'   US   U	S'   US   U	S'   U R                  U R                  X5      5      I Sh  vN n
O0US   U	S'   U R                  U R                  X5      5      I Sh  vN n
U R                  U
S5      nU R                  US5      nU R                  XX45      $  GNB N Np NA7f)uH  
Retrieves the open interest history of a currency

https://huobiapi.github.io/docs/dm/v1/en/#query-information-on-open-interest
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-information-on-open-interest
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-information-on-open-interest

:param str symbol: Unified CCXT market symbol
:param str timeframe: '1h', '4h', '12h', or '1d'
:param int [since]: Not used by huobi api, but response parsed by CCXT
:param int [limit]: Default：48，Data Range [1,200]
:param dict [params]: Exchange specific parameters
:param int [params.amount_type]: *required* Open interest unit. 1-cont，2-cryptocurrency
:param int [params.pair]: eg BTC-USDT *Only for USDT-M*
:returns dict: an array of `open interest structures <https://docs.ccxt.com/#/?id=open-interest-structure>`
r   r   12hr   zJ fetchOpenInterestHistory cannot only use the 1h, 4h, 12h and 1d timeframeNr   r   12hourr   )r   r   r  r   amount_type
amountTyper  )r  r  rv  rP   r@  r  r  rb  r   rO   r=   r  rY  r  )r*   r=   rA  r`  r\  rD  -contractPublicGetApiV1ContractHisOpenInterestrm  3contractPublicGetLinearSwapApiV1SwapHisOpenInterest-contractPublicGetSwapApiV1SwapHisOpenInterestrK  r  parse_open_interests_history)r/  rb  r  rk  r  rM  r   r`  r  rn  rP  rY  r  s                r1  fetch_open_interest_historyhtx.fetch_open_interest_history  s    " d!2yE7Ii[_N_TWW'sstt!!!	

 V$((aP
 +%
 #FO('+'7'7v'XGO$ &x 0GH!OOPTP[P[\cPlmmHH'-GO$'-d|GO$'-d|GO$!UUVZVaVabiVrssH'-d|GO$!OOPTP[P[\cPlmmHz x0~~dF+00uLL{ 	"( n t nsJ   AFFBFFAFF0FF;FFFFc                   #    U R                  5       I Sh  vN   U R                  U5      nSnUb4  [        U5      nUS:  a#  U R                  US5      nU R	                  U5      n0 nSnU R                  SX2S5      u  prSnU R                  SX25      u  pSn	US:X  a)  U R                  U R                  Xb5      5      I Sh  vN n	O\US:X  a)  U R                  U R                  Xb5      5      I Sh  vN n	O-SUS'   U R                  U R                  Xb5      5      I Sh  vN n	U R                  U	S	/ 5      n
U R                  X5      $  GN/ N N[ N/7f)
a  
Retrieves the open interest for a list of symbols

https://huobiapi.github.io/docs/dm/v1/en/#get-contract-open-interest-information
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-swap-open-interest-information
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-swap-open-interest-information

:param str[] [symbols]: a list of unified CCXT market symbols
:param dict [params]: exchange specific parameters
:returns dict[]: a list of `open interest structures <https://docs.ccxt.com/#/?id=open-interest-structure>`
Nr   r   r   rP   r   rO   r  rY  )rA  r  rt  rD  r`  r  rB  *contractPublicGetApiV1ContractOpenInterestrm  *contractPublicGetSwapApiV1SwapOpenInterest0contractPublicGetLinearSwapApiV1SwapOpenInterestr  parse_open_interests)r/  rk  rM  r`  r  ro  rn  r6  rN  rP  rY  s              r1  fetch_open_interestshtx.fetch_open_interestsc  s]     !!!%%g.LMq ((!4U+99:JF\de
!??@PRXa
!!LLT[[Y`MijjH& 	!!LLT[[Y`MijjH& (.GO$!RRSWS^S^_fSoppH. ~~h3((77_ 	" k( k( qsF   EEB(E?E .E.E
/-EE)EE
EEc                   #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eUS   (       a  [	        U R                  S-   5      eSUS   0nSnUS   (       aI  U R                  US	   S
5      US
'   US   US'   U R                  U R                  XB5      5      I Sh  vN nO`US   (       a.  SUS
'   U R                  U R                  XB5      5      I Sh  vN nO(U R                  U R                  XB5      5      I Sh  vN nU R                  US/ 5      nU R                  US   U5      nU R                  US5      nXS'   U R                  U5      US'   U$  GNj N N N_7f)a  
Retrieves the open interest of a currency

https://huobiapi.github.io/docs/dm/v1/en/#get-contract-open-interest-information
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-swap-open-interest-information
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-swap-open-interest-information

:param str symbol: Unified CCXT market symbol
:param dict [params]: exchange specific parameters
:returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
Nr   z3 fetchOpenInterest() supports contract markets onlyrQ   z> fetchOpenInterest() does not currently support option marketsr  r=   rP   r@  r  r  rb  r   rO   rY  r   r9  r  rT  )rA  r`  r*   r=   r/   rD  r  rm  r  r  rK  parse_open_interestr  r  )	r/  rb  rM  r`  rn  rP  rY  openInterestr  s	            r1  fetch_open_interesthtx.fetch_open_interest  s     !!!V$j!TWW'\\]](tww)iijjVD\
 ('+'7'7v'XGO$ &x 0GH!LLT[[Y`MijjHH'-GO$!RRSWS^S^_fSoppH "LLT[[Y`MijjH| x4//Q@%%h5	$-[!#'<<	#:Z q 	" k q ksG   F	F B/F	F7F	>F?(F	'F(AF	F	F	F	c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  U R	                  Xb5      UUUUUU R                  U5      US.U5      $ )Nr9  r  valuer  )rb  r  r  openInterestAmountopenInterestValuer  rT  r@  )r  rf  rD  safe_open_interestre  r  )r/  r  r`  r  r  r  rg  s          r1  r  htx.parse_open_interest&   s    j %%h5	!!(H5  73##Ho>&&&&x8  "(!&"Y/	(
 	 		r3  c                 X  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      nUS   U R                  X#5      US   S.nU R	                  U R                  Xt5      5      I Sh  vN nU R                  X5      n	U R                  U	UUS.5      $  N N,7f)a  
create a loan to borrow margin

https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-isolated
https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-cross

:param str symbol: unified market symbol, required for isolated margin
:param str code: unified currency code of the currency to borrow
:param float amount: the amount to borrow
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
Nr=   )rV  r  rb  r  rb  )rA  rV  r`  r  privatePostMarginOrdersrm  parse_margin_loan)
r/  rb  r  r  rM  rV  r`  rn  rP  rx  s
             r1  borrow_isolated_marginhtx.borrow_isolated_marginj   s      !!!==&V$ 00>Tl

 55dkk'6RSS ,,X@{{;)
  	# 	" Ts"   B*B&A$B*;B(<+B*(B*c                 ,  #    U R                  5       I Sh  vN   U R                  U5      nUS   U R                  X5      S.nU R                  U R	                  XS5      5      I Sh  vN nU R                  Xd5      nU R	                  USU05      $  Ny N+7f)a  
create a loan to borrow margin

https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-isolated
https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-cross

:param str code: unified currency code of the currency to borrow
:param float amount: the amount to borrow
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
Nr=   r  r  )rA  rV  r  privatePostCrossMarginOrdersrm  r  )r/  r  r  rM  rV  rn  rP  rx  s           r1  borrow_cross_marginhtx.borrow_cross_margin   s      !!!==& 00>
 ::4;;w;WXX ,,X@{{;f)
  	! 	" Ys"   BBAB&B'*BBc                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  SSX5      I Sh  vN nUS   U R                  X#5      US.nU R	                  U R                  Xt5      5      I Sh  vN nU R                  US/ 5      n	U R                  U	S5      n
U R                  X5      nU R                  UUUS.5      $  N N NS7f)	a  
repay borrowed margin and interest

https://huobiapi.github.io/docs/spot/v1/en/#repay-margin-loan-cross-isolated

:param str symbol: unified market symbol
:param str code: unified currency code of the currency to repay
:param float amount: the amount to repay
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
NrM   r~  r=   rV  r  r  Datar   r  rA  rV  r  r  v2PrivatePostAccountRepaymentrm  rK  r  )r/  rb  r  r  rM  rV  r  rn  rP  rY  loanrx  s               r1  repay_isolated_marginhtx.repay_isolated_margin   s      !!!==&77
F[[	 00>"

 ;;DKK<XYY x4tQ',,T<{{;)
  	/ 	"[ Zs4   CC+CC?CCACCCc                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  SSSU5      I Sh  vN nUS   U R                  X5      US.nU R	                  U R                  Xc5      5      I Sh  vN nU R                  US/ 5      nU R                  US5      n	U R                  X5      n
U R                  U
SU05      $  N N NR7f)	a  
repay borrowed margin and interest

https://huobiapi.github.io/docs/spot/v1/en/#repay-margin-loan-cross-isolated

:param str code: unified currency code of the currency to repay
:param float amount: the amount to repay
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
NrM   r}  r=   r  r  r   r  r  )r/  r  r  rM  rV  r  rn  rP  rY  r  rx  s              r1  repay_cross_marginhtx.repay_cross_margin   s      !!!==&77vVV	 00>"

 ;;DKK<XYY x4tQ',,T<{{;f)
  	/ 	"V Zs4   CC,CC?CCACCCc                     U R                  US5      nU R                  USS5      U R                  S U5      S S UU R                  U5      US.$ )N	repayTimerepayIdrY  )r=   rV  r  rb  r  rT  r@  )r  r  r  r  )r/  r@  rV  r  s       r1  r  htx.parse_margin_loan   sZ    , %%dK8	$$T9f=//h?"Y/
 	
r3  c                   #    Uc  [        U R                  S-   5      eU R                  US5      nU R                  US/5      nU R	                  U5      n0 nUS   (       a	  US   US'   OUS   US'   Ub  X'S	'   Ub  X7S
'   Ub  XWS'   SnUS   (       a\  US   (       a)  U R                  U R                  Xt5      5      I Sh  vN nOQU R                  U R                  Xt5      5      I Sh  vN nO(U R                  U R                  Xt5      5      I Sh  vN nU R                  US5      n	U R                  U	S5      n
U R                  X5      nU R                  US5      $  N Nv NO7f)u+  
Fetches historical settlement records

https://huobiapi.github.io/docs/dm/v1/en/#query-historical-settlement-records-of-the-platform-interface
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-historical-settlement-records-of-the-platform-interface
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-historical-settlement-records-of-the-platform-interface

:param str symbol: unified symbol of the market to fetch the settlement history for
:param int [since]: timestamp in ms, value range = current time - 90 days，default = current time - 90 days
:param int [limit]: page items, default 20, shall not exceed 50
:param dict [params]: exchange specific params
:param int [params.until]: timestamp in ms, value range = start_time -> current time，default = current time
:param int [params.page_index]: page index, default page 1 if not filled
:param int [params.code]: unified currency code, can be used when symbol is None
:returns dict[]: a list of `settlement history objects <https://docs.ccxt.com/#/?id=settlement-history-structure>`
Nz4 fetchSettlementHistory() requires a symbol argumentr  rP   r  rb  r=   r  start_atr|  end_atrO   r   rY  settlement_recordr  )r)   r=   r  r  r`  5contractPublicGetLinearSwapApiV1SwapSettlementRecordsrm  /contractPublicGetSwapApiV1SwapSettlementRecords/contractPublicGetApiV1ContractSettlementRecordsrK  parse_settlementsr  )r/  rb  rk  r  rM  r  r`  rn  rP  rY  settlementRecordsettlementss               r1  fetch_settlement_historyhtx.fetch_settlement_history!  so    " >#DGG.d$dee!!&'26G9-V$( &x 0GH'-d|GO$"'J#(K  %H&>h!%![![\`\g\gho\x!yy!%!U!UVZVaVabiVr!ss!QQRVR]R]^eRnooHj x0??41DE,,-=F||K55y zsos7   B=E#?E (E#(E)(E#E!AE#E#!E#codesc                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  US5      nU R                  XAS5      $  NA N*7f)aM  
fetch deposit and withdraw fees

https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-currencies-v2

:param str[]|None codes: list of unified currency codes
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `fees structures <https://docs.ccxt.com/#/?id=fee-structure>`
NrY  rV  )rA  r  r  parse_deposit_withdraw_fees)r/  r  rM  rP  rY  s        r1  fetch_deposit_withdraw_feeshtx.fetch_deposit_withdraw_fees~!  s[      !!!@@HHJ ~~h///ZHHO 	"Hr  c                    U R                  US/ 5      nU R                  U5      n[        S[        U5      5       H  nX5   nU R	                  US5      nU R	                  US5      nU R                  U5      n	S n
S nUS:X  a  U R                  US5      n
U
SS.nOU R                  US	5      n
U
S
S.nUS S S.S.US   U	'   U R                  XB5      nM     U$ )Nr  r   r  withdrawFeeTypefixedr  F)r_  r   transactFeeRateWithdrawT)r   r  r"  )rK  deposit_withdraw_feers  rt  rD  r  rf  $assign_default_deposit_withdraw_fees)r/  r_  rV  r  rw  r  r  r  r  r  withdrawFeewithdrawResults               r1  parse_deposit_withdraw_feehtx.parse_deposit_withdraw_fee!  s   @ h3**3/q#f+&AJ((W=I"..z;LMO11)<KK!N')"..z;PQ&"'"
 #..z;TU&"&"
 +"&/F:{+ >>vPF5 '6 r3  c                    / n[        S[        U5      5       H  nX   nU R                  US5      nUby  U R                  US5      nUU R	                  U5      S.n[        S[        U5      5       H8  n	Xi   n
U R                  X5      nUR                  U R                  X5      5        M:     M  UR                  U R                  X   U5      5        M     U$ )Nr   r  settlement_timer  )rs  rt  rK  r  r  parse_settlementr  rm  )r/  r  r`  rw  rx  
settlementr  r  timestampDetailsr  r  parsedSettlements               r1  r  htx.parse_settlements!  s    J q#k*+A$J??:v6D --j:KL	!* $Y 7*  q#d),A7D'+'<'<T'J$MM$++.>"QR -
 d33KNFKL , r3  c                     U R                  US5      nU R                  US5      nUU R                  XB5      U R                  US5      UU R	                  U5      S.$ )Nr%  r  settlement_price)r@  rb  r  r  rT  )r  rD  re  rf  r  )r/  r'  r`  r  rg  s        r1  r&  htx.parse_settlement'"  sd    0 %%j2CD	##J@&&x8%%j2DE"Y/
 	
r3  c                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  USS5      nSU0nUb  X'S'   U R                  SXt5      u  ptSnUS   (       ad  US   US'   US	   (       a)  U R	                  U R                  Xt5      5      I Sh  vN nOU R                  U R                  Xt5      5      I Sh  vN nO\US
   (       a1  US   US'   U R                  U R                  Xt5      5      I Sh  vN nO![        U R                  S-   US   -   S-   5      eU R                  US/ 5      n	U R                  XX#5      $  GN9 N N NR7f)a  
retrieves the public liquidations of a trading pair

https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-liquidation-orders-new
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-liquidation-orders-new
https://huobiapi.github.io/docs/dm/v1/en/#query-liquidation-order-information-new

:param str symbol: unified CCXT market symbol
:param int [since]: the earliest time in ms to fetch liquidations for
:param int [limit]: the maximum number of liquidation structures to retrieve
:param dict [params]: exchange specific parameters for the huobi api endpoint
:param int [params.until]: timestamp in ms of the latest liquidation
:param int [params.tradeType]: default 0, linear swap 0: all liquidated orders, 5: liquidated longs; 6: liquidated shorts, inverse swap and future 0: filled liquidated orders, 5: liquidated close orders, 6: liquidated open orders
:returns dict: an array of `liquidation structures <https://docs.ccxt.com/#/?id=liquidation-structure>`
Nry  r   rz  r{  rO   r=   r   r   rP   rb  z& fetchLiquidations() does not support rX  r^  rY  )rA  r`  r  r  5contractPublicGetLinearSwapApiV3SwapLiquidationOrdersrm  /contractPublicGetSwapApiV3SwapLiquidationOrders/contractPublicGetApiV3ContractLiquidationOrdersr/   r=   r  parse_liquidations)
r/  rb  rk  r  rM  r`  	tradeTypern  rP  rY  s
             r1  fetch_liquidationshtx.fetch_liquidationsI"  sf      !!!V$%%flA>	)
 $)L!22:wO&>"(,GJh!%![![\`\g\gho\x!yy!%!U!UVZVaVabiVr!ssH &tGH!QQRVR]R]^eRnooHtww)QQTZ[aTbbennoo0 ~~h3&&tUBB[ 	" zs psG   EEBEE (EE	:EEAEEEEc                 ~   U R                  US5      nU R                  US5      nU R                  UU R                  X25      U R	                  US5      U R	                  US5      U R	                  US5      U R                  US5      U R	                  US5      U R	                  US5      UU R                  U5      S	.
5      $ )
Nr  rI  r  r  r  r3  r  rP  )
r@  rb  rw  r  r  r4  	baseValue
quoteValuer  rT  )rD  r  safe_liquidationre  rf  r  r  )r/  r  r`  rg  r  s        r1  parse_liquidationhtx.parse_liquidation"  s    " ##KA%%k<@	$$&&x8))+x@ ,,V^D%%k7;**;D))+x@**;8HI"Y/&
  	r3  c                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  US5      nUS   (       d  [        U R                  S-   5      eU R                  SUS5        US   US.nUb  XVS	'   US
   (       aB  U R                  USS5      nUc  [        U R                  S-   5      eU R                  X5      US'   U R                  U/ SQ5      nSnUS
   (       a\  US   (       a)  U R                  U R                  Xc5      5      I Sh  vN nOU R                  U R                  Xc5      5      I Sh  vN nOnSn	U R                  SUS5      u  pU	S:X  a)  U R                  U R                  Xc5      5      I Sh  vN nO(U R                  U R                  Xc5      5      I Sh  vN nU R!                  X5      $  GN N N NE N7f)a  
       closes open positions for a contract market, requires 'amount' in params, unlike other exchanges

       https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-lightning-close-order  # USDT-M(isolated)
       https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-lightning-close-position  # USDT-M(cross)
       https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-lightning-close-order  # Coin-M swap
       https://huobiapi.github.io/docs/dm/v1/en/#place-flash-close-order                      # Coin-M futures

       :param str symbol: unified CCXT market symbol
       :param str side: 'buy' or 'sell', the side of the closing order, opposite side side
       :param dict [params]: extra parameters specific to the okx api endpoint
       :param str [params.clientOrderId]: client needs to provide unique API and have to maintain the API themselves afterwards. [1, 9223372036854775807]
       :param dict [params.marginMode]: 'cross' or 'isolated', required for linear markets

EXCHANGE SPECIFIC PARAMETERS
       :param number [params.amount]: order quantity
       :param str [params.order_price_type]: 'lightning' by default, 'lightning_fok': lightning fok type, 'lightning_ioc': lightning ioc type 'market' by default, 'market': market order type, 'lightning_fok': lightning
       :returns dict: `an order structure <https://docs.ccxt.com/#/?id=position-structure>`
       Nr"  r   z6 closePosition() symbol supports contract markets onlyrZ   r4  r=   )r  r3  r#  r   r  r  zP closePosition() requires an extra argument params["amount"] for inverse markets)r"  r  r  rO   r}  )rA  r`  rD  r*   r=   check_required_argumentr  r)   r  r  6contractPrivatePostSwapApiV1SwapLightningClosePositionrm  .contractPrivatePostApiV1LightningClosePositionr  AcontractPrivatePostLinearSwapApiV1SwapCrossLightningClosePosition<contractPrivatePostLinearSwapApiV1SwapLightningClosePositionr*  )
r/  rb  r4  rM  r`  r"  rn  r  rP  r  s
             r1  close_positionhtx.close_position"  s    ( !!!V$((Aj!TWW'__``$$_dFC#D\
 $)6%&)''(CF~'  3E  )E  F  F $ 8 8 HGH6#HI)f~!%!\!\]a]h]hip]y!zz!%!T!TUYU`U`ahUq!rrJ!%!C!COU[]d!eJW$!%!g!ghlhshst{  iE  "F  F!%!b!bcgcncnovc  "A  A11? 	"* {r
 F AsY   GG	DGG(GGAG
G(G3G4GGGGGr  c                   #    U R                  5       I Sh  vN   U(       a  SOSnSnUb  U R                  U5      nSnU R                  SUS5      u  pcSU0nSnUb"  US   (       a  [        U R                  S-   5      eUS	:X  aM  Uc  [        U R                  S
-   5      eUS   US'   U R                  U R                  Xs5      5      I Sh  vN nU$ SUS'   U R                  U R                  Xs5      5      I Sh  vN nU$  N N7 N
7f)aP  
set hedged to True or False

https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-position-mode
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-switch-position-mode

:param bool hedged: set to True to for hedged mode, must be set separately for each market in isolated margin mode, only valid for linear markets
:param str [symbol]: unified market symbol, required for isolated margin mode
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: "cross"(default) or "isolated"
:returns dict: response from the exchange
N	dual_sidesingle_sider   r}  position_moder   z4 setPositionMode can only be used for linear marketsr~  zD setPositionMode requires a symbol argument for isolated margin moder=   r
  r!  )	rA  r`  r  r*   r=   r)   8contractPrivatePostLinearSwapApiV1SwapSwitchPositionModerm  =contractPrivatePostLinearSwapApiV1SwapCrossSwitchPositionMode)	r/  r  rb  rM  posModer`  r  rn  rP  s	            r1  set_position_modehtx.set_position_mode"  s-     !!!!'+][[(F
!??@QSY[bc
W
 VI%6TWW']]^^#~'2x(xyy(.tG$%!ZZ[_[f[fgn[wxxH8  )/G$%!__`d`k`kls`|}}H [ 	"" y ~s4   DD B3D
D.D9D:DDD)r  )N)NN)__name__
__module____qualname____firstlineno__r   r,  rU  r   r]  dictr   r!   rh  r(  rp  r   ry  ru  r   r}  r  r$   r  r  r  r   r  r  r   r(  r0  r7  r   rD  r    ri  rn  rm  r  r  r  r  r  r   r  r  r  r	   r  r  r  r   r  r+  r  r6  r;  r?  rX  r[  r   r_  rb  rw  r  r*  r  r  r   r   r   r  r  r  r  r   r  r   r,  r+  rD  rH  r
   rQ  r   rX  r`  rh  r"   rr  rv  r  r  r   r#   r  r   r   r  r   r  r  r   r  r  r  r   r  r   r  r  r>  rB  intrS  r\  rd  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&  r4  r:  rB  boolrK  __static_attributes____classcell__)r0  s   @r1  r9   r9   !   sJ   I# IV* )+ [
z ') ;S ;<
T 
6 
EX 
( ;= !5c !5AT !5F =A '  @B P3 P@ :>b 
3 
4x *,  V  D XZ ZS Z3 Zx  3   D]4 ] ]6 ]~ 68 N NF N` 6:" hH7 hH hHT :>b c5w c5J
f 
  @DB TrS Tr TrS\ TrlI Iv I IV ?CQUdhqs T3 T T3 T^a T, DHVZimvx G GS GPS Gcf G* 37TX\eg Y?C Y?s Y?RU Y?v <@d[] HY HYS HY HYbfglbm HYT
 
4 
, ?CQUdhqs H H H3 H^a Hx|  ~B  yC HB +- )g ).
& KO^bkm #63 #6C #6X[ #6J -/ q: qfAC Ac A AQc Q Q Q *, p pd	 8<B H'C H' H'T
 GKY]lpy{ A= A=SV A=fi A=F 59tZ^gi _c _ _TW _ <@daenp xS x x[^ x 9=4^bkm [?# [?S [?X[ [?z @DRVeirt d dC d_b d 04$UYbd !N !NC !Ns !Nimnsit !NF 7;\`ik  Y  Y3  YVY  Yptuzp{  YD 59tZ^gi ]?c ]? ]?TW ]?nrsxny ]?~: :*j jv j jX XZ Tc T T$ ~B  [_  }A  JL R# RY RV_ Rin Rwz R  UX R  wz R  QV R* z~  GI f,c f, f,R[ f,ej f,sv f,P x|  EG U,C U,y U,PY U,ch U,qt U,n mqy{ `0 `0I `0Y `0X] `0fi `0D FH r1$|*< r1h 9=R yS y# yv AER R.tCy R.# R.h4l 59 s2c s2j BD S 6
h 
4 JL 0S 0PTUcPd 0B =? 5 5> 5" >Bt\^ 3 @ 04$UYbd 6Q 6QC 6Qs 6Qimnyiz 6Qp 37TX\eg 4QC 4Qs 4QRU 4Qlpq|l} 4QlZ
T Z
X Z
Q\ Z
x:s :0 QU]_ 6:3 6: 6: 6:# 6:do 6:p
t 
x 
= 
. ac R73 R7 R7C R7TW R7gt R7h 8: )6>Q )6V)
t )
V )
Oa )
V >BPTcgpr LYs LY# LY]` LY\+
6 +
[ +
Z? <> '7s '7+ '7R <@ 27 27| 27h 7;$]apt} ;Q ;QC ;QWZ ;Qjm ;Q  EI  JX  EY ;Qz9
$ 9
 9
. 9
vD &eBSW lP\c 3 S # X\ dg B 9=4^bkm R># R>S R>X[ R>h ?C2 G3 G GR
6 
8Xt XV Xt 8<B FPW FP4PX> FPP 8: x3 xt3&%t %x %; %N .2SW`b I?s I?# I?S I?gklwgx I?V =A 'I' 'IP] 'IR $|J\ 0 HLZ^mqz| pM pMTW pMgj pMd =A [8' [8z =? d dLBF BH Z\ !3 !c !5 !F JL c 5 @ RT &# &S &P BD $S $L
 
B <@daenp `6S `6 `6[^ `6D BFb 1Iw 1If= =~5n 
D BFTXac =Cs =C3 =Cc =C~V @ CGr 323 32i 32V[ 32j CGr :d :C : :r3  r9   )? ccxt.async_support.base.exchanger   ccxt.abstract.htxr   r  r4  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#   typingr$   ccxt.base.errorsr%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   ccxt.base.decimal_to_precisionr5   r6   ccxt.base.preciser7   r9    r3  r1  <module>r^     s    6 )   @  @  @  @  @  @  @  @  @  * 0 - . . ' & . ) * ) , . 1 * + 3 4 %vK(K vKr3  