
    in                       d dl mZ d dlmZ d dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlm Z  d d	lm!Z! d d
lm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dlm(Z( d dlm)Z) d dlm*Z* d dlm+Z+ d dlm,Z, d dlm-Z- d dl.m/Z/ d dl.m0Z0 d dl1m2Z2  G d dee          Z3dS )    )Exchange)ImplicitAPIN)AccountBalances
CurrenciesCurrencyIntMarketNumOrder	OrderBookOrderRequest	OrderSide	OrderTypeStrStringsTickerTickers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    e Zd Z fdZi fdZi fdZddedefdZi fde	defd	Z
di fd
efdZi fde	fdZdi fdefdZd Zi fdee         fdZi fdZde	fdZddedefdZi fde	defdZdi fd
edefdZdi fd
efdZddefdZdi fde	dedefdZddedefdZ dddi fde	dededefdZ!dddi fde	dededefdZ"dddi fdededefdZ#dd i fde	dededee         fd!Z$ddede%fd"Z&d#ddi fde	dededee%         fd$Z'i fdee(         fd%Z)d& Z*ddi fd'Z+i fde,fd(Z-d fd)	Z.d fd*	Z/i fde0fd+Z1di fde	defd,Z2d- Z3dddi fdededefd.Z4dddi fdededefd/Z5dddi fdededefd0Z6dddi fdededefd1Z7dddi fdededefd2Z8dddi fdedededee9         fd3Z:dddi fdedededee9         fd4Z;dddi fdedededee9         fd5Z<d6 Z=ddede9fd7Z>i fde	d8e?fd9Z@dddi fde	d:eAd;eBd<e?d=eCde9fd>ZDdi fde	d:eAd;eBd<e?d=eCf
d?ZEdi fde	d:eAd;eBd<e?d=eCf
d@ZFdi fde	d:eAd;eBd<e?d=eCf
dAZGi fdBeeH         fdCZIdi fde	defdDZJdi fdefdEZKdi fdefdFZLddGeMfdHZNi fdIe	fdJZOi fdIe	fdKZPddi fdIe	fdLZQdddi fdIedededeeR         fdMZSdddi fdIedededeeR         fdNZTddGeMdeRfdOZUdP ZVdi fdIe	d<e?fdQZWddGeMfdRZXi fdIe	d<e?dSe	dTe	deYf
dUZZi fdVZ[ddefdWZ\dddi fdededefdXZ]ddefdYZ^i fde	fdZZ_di fd
efd[Z`ddddi fdIedededefd\Zaddefd]Zbd^d_i ddfd`Zcda Zddddi fdededefdbZedi fdcedefddZfddefdeZgddefdfZhdi fd
efdgZii fde	fdhZjdi ZkddGeMfdjZldddi fdIededefdkZmdi fd
efdlZni fde	fdmZodd
efdnZpdoddi fde	dedefdpZqi fde	fdqZrddefdrZsi fde	dIe	d<e?fdsZti fdIe	d<e?fdtZui fde	dIe	fduZvi fdIe	fdvZwddGeMfdwZxdddi fdededefdxZydi fdyefdzZzddGeMfd{Z{d| Z|d} Z}ddi fde	dedefd~Z~ddefdZdi fdedefdZ xZS )htxc                     |                      t          t          |                                           i ddddddgddd	| j        d
         dddddddddi dd dddddddddd dd dddddddddddd d dd!d"d#d"d$di d%dd&d"d'dd(dd)dd*dd+dd,dd-dd.dd/dd0d d1dd2d d3d d4d d5d i d6dd7d"d8d"d9dd:d d;dd<d d=dd>dd?d@dAddBddCddDddEddFddGd"i dHddId dJddKddLd dMd"dNddOddPd"dQddRddSddTd"dUddVddWddXdi dYd dZdd[dd\dd]d d^dd_dd`ddaddbd"dcdddddeddfddgddhddidi djddkd"dlddmd dnd dod dpd dqddrd dsddtd dud dvddwddxddyd"dzdd ddd{d|d}d~ddddddddd
dddddddddddddddddddddddddg ddddddddii ddddddddddddddddddddddddddddddddddddddddddddddi dddddddddddddddddddddddddddddddddddddddddŜdƜdddddddǜii dddddddd̓ddddddddѓddѓddѓddѓddѓddddddddddddddddddۜi ddddddѓddddddѓddddѓddddddÓddÓddÓddÓdddddddddddƜddddiidddiidddiiddddiidddiiddidi ddddddddddddddddddddddddddddddddddddddddd ii dddddddddd̓ddddddd	dd
dddddddddddddddi ddddddddÓddddѓddѓddѓddѓddѓddѓddddddddd dd!dddddddddddddd"i d#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1dÓd2dÓd3di d4dѓd5dd6dd7dd8dѓd9dѓd:dd;dd<dd=dd>dÓd?dÓd@dÓdAdÓdBddCddDdddddddĐdEdƜdFdi dGddHddIddJddKddLddMddNddOddPddddQddddRddSddTddUdi dVddWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcdddddeddfdi dgddhddiddjddkddlddmddnddoddpddqddrddsddtdduddvddwdi dxddyddzdd{dd|dd}dd~dddddddddddddddddddddi dddddddddddddddddddddddddddddddddddddddddddddddddidddddddddddddi ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddd dddi ddddddddddddddd	dd
dddddddddddddddddi ddddddddddddddddddddddddddd dd!dd"dd#di d$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1dd2dd3dd4di d5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAddBddCddDddEdi dFddGddHddIddJddKddLddMddNddOddPddQddRddSddTddUddVdi dWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcdddddeddfddgdddddddddddddddhdƜdFdidjdkdd"d|                     dl          |                     dl          dmidnt          t          t          doi dpt          dqt          drt          dst          dtt          dut          dvt          dwt          dxt          dyt          dzt          d{t          d|t          d}t          d~t          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt           dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt           dt          dt          dt          dt          dt          dt          dt"          dt          dt          t          t          t          t          t          t          t"          dddt$          di dRdddddidVddiddd"iddddddddddddi ddddddddddddddddddddddÓdÐdÓdĐdēdŐdƓdƐdƓdǐdǓdȐdȓi dɐdɓdʐdʓdːd˓d̐d̓d͐d͓dΐdΓdϐdϓdАdГdѐdѓdҐdғdӐdӓdԐdԓdՐdՓd֐d֓dאdדdؐdٓdِdٓi dڐdړdېdۓdܐdܓdݐdݓdސdޓdߐdߓddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddi ddddddd d ddddddddddddddddd	d	d
d
ddddddi ddddddddddddddddddddddddddddddddddi ddd d d!d!d"d"d#d#d$d$d%d%d&d&d'd'd(d(d)d)d*d*d+d+d,d,d-d-d.d.d/d/i d0d0d1d1d2d2d3d3d4d4d5d5d6d6d7d8d9d9d:d;d<d=d>d>d?d?d@d@dAdAdBdBdCdCi dDdDdEdEdFdFdGdGdHdHdIdJdKdKdLdLdMdMdNdNdOdOdPdPdQdQdRdRdSdSdTdTdUdUi dVdVdWdWdXdXdYdYdZdZd[d[d\d\d]d]d^d^d_d_d`dadbdbdcdcdddddededfdfdgdgdhdidjdkdldmddndodpddqidrdddsdtdudddvdwdxdydzd{d|d}d~
ddddddddddddi ddddddddddddddddddddddddddddddddddddiddddddddddi          S (  Nidr.   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cancelOrdercancelOrderscreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrderWithCostF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fetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositions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)r@   rC   rB   )contractr@   statuszhttps://{hostname})r   r   r@   publicprivatev2Public	v2Privatezhttps://www.huobi.comz^https://www.huobi.com/en-us/v/register/double-invite/?inviter_id=11343840&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_ratez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   r@   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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 symbolzsymbol trade not open now)z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types)r@   r   r   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)r@   fundingrC   accountsByIdotcpointsuper-margin
investmentborrowgrid-tradingdeposit-earningotc-options)
r@   rA   r  r  r  r  r  r  r  r  typesByAccount)r=   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commonCurrenciesThemiszGame.comHitChainPentazSuper Bitcoin	SoulsaverzBitcoin File)GETGTCHITPNTrL  SOULrM  )deep_extendsuperr.   describe
userAgentsparse_numberr(   r   r   r   r    r#   r"   r!   r   r)   r'   r&   r+   )self	__class__s    \/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/htx.pyr  zhtx.describe#   sr4   c4 0 0 9 9 ; ; {>
%{>
E{>
 ${>
 	{>

 5{>
 {>
 t{>
 {>
 4{>
  jjj $j 	j
 $j $j Tj $Tj 'j "4j tj j 'j /j ,Uj  0!j" t#j j$ %j& ('j( ')j* &t+j, (-j. "4/j0 (1j2 -d3j4 %d5j6  7j8 9j:  ;j< &t=j> +D?j@ )$AjB &tCjD #DEj j jF $TGjH 'IjJ (KjL "4MjN OjP &tQjR (SjT 1$UjV  WjX *:YjZ +D[j\ &t]j^ #D_j` *4ajb $Tcjd "4ejf *5gj j jh +Dijj #Dkjl "4mjn tojp #Dqjr  sjt %dujv $Twjx /yjz +D{j| }j~ !$j@ &uAjB  CjD dEjF $TGjH +DIj j jJ !$KjL "4MjN dOjP !$QjR "4SjT tUjV #DWjX  YjZ !$[j\ %e]j^ )$_j` )$ajb tcjd tejf gjh Tijj tkj j jl "4mjn #Eojp %dqjr &tsjt 'ujv $Twjx !$yjz )${j| "4}j~ #Dj@ +DAjB CjD #DEjF &tGjH tIjJ  KjL "4Mj jN   Sj j j{>
j  k{>
B  ~ .+ 7'A&I# #
 (D&I! !
 
 & 3 4023 4!5  /{ $    ;]/ /C{>
b  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 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 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+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  7 R 4558:=9:;<@A4545<=3423,-m7  7  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! 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! 1!R HI78/012:<35a1! 1! 1!sk  k =J 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  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  g  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  g  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  g  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  g r MNIJKLLMJKJKDEJKOPJKTUUVFGRSMg  g  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! 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! c! 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! c! 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! c! 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! c! 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! c! 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! 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! c! 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! c! c!D HEc!F NqG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! c! 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! c! 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! c!l MNKLQRCDIJDEJKGHMNHINOGHMNEc! c! c!%v  v Wb bm	Y
 Y
c{>
V $!&"&!..w77!..w77 W{>
h ly -1A 
=.= -= /	=
 I= M= L= L= L= L= -= -= L= I= L=  L!=" -#=$ J%= =& L'=( J)=* ":+=, .z-=. 6z/=0 ,Z1=2 01A3=4 ~5=6 -.B7=8 @AR9=: %l;=< 8==> 8?=@ 9,A=B 7C=D 7E=F 3LG= = =H ,\I=J *<K=L 1,M=N 7O=P 4\Q=R -mS=T /U=V )*>W=X 12EY=Z ./B[=\ *=]=^ 1)_=` (a=b )-c=d :;Le=h %ii=j 0k= =l '0'11;/@/9-7%6y= = =D Di{>
r Ys{>
t  P $"&#' !P 2DP  %P vP !(P  !'!P" "" #$ $#P,  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 !"[  -Pn ,-OoPp 4TqPr GsPt ,uPz !!$'# #{PD "& $$2".&$2'8#0! !EP\ !!'# #]Pd &**.+/*..2/3' '((#T( %d( t	(
 "4( #D( &t( *4( +D( %d( )$( *4( $T( (( )$(  )$!(" -d#($ .t%( ( ePu{>
V%   !!
 '#&! !W%{>
 {>
 { { {	    c                 X  K   |                                   d {V  d }|                     dd |          \  }}|                     ddd          }d }|dk    r|r|                     |d| j        d                   }|dk    rB|dk    r|                                  d {V }n|d	k    r|                                  d {V }n|d
k    rB|dk    r|                                  d {V }nb|d	k    r|                                  d {V }nA|dk    r| 	                                 d {V }n |dk    r| 
                                 d {V }d }d }d }|dk    r<|                     |d          }	|	d }n
|	dk    rdnd}|                     |d          }n|                     |di           }
|                     |
d          }	|	dk    rdnd}|                     |di           }|                     |d          }|                     |          }|                     |d          }||d ||dS )Nr   enableForContractsFr@   subTyper  rB   r   r   rC   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responser  r   r  r   	statusRaw
statusDatapageDatadatetimes                r  fetch_statuszhtx.fetch_status  s     !!!!!!!!!
!??tU[\\
F"00@TV[\\$7&&vy$,GW:XYYGV##h&&%)%S%S%U%UUUUUUUHH	))%)%T%T%V%VVVVVVVHx''h&&%)%U%U%W%WWWWWWWHH	))%)%V%V%X%XXXXXXXHz))!%!@!@!B!BBBBBBB6!!!EEGGGGGGGGHD ##((8<<I "+t"3"3-&&x66GG8R@@J(([AAI'611TTFx<<H'',??HnnX..G""8U33C
 
 	
r  c                   K   |                      | j        di           }|                     | j        dd          }|                     |d|          }|                     |d|          }d}|dk    s|dk    r|                     |           d{V }n|                     |           d{V }|                     |dd	          S )
a  
        fetches the current integer timestamp in milliseconds from the exchange server
        :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  r@   typeNrC   rB   datar  )r  r   r   contractPublicGetApiV1TimestampspotPublicGetV1CommonTimestampsafe_integer_2)r  r	  r   r  r  r  s         r  
fetch_timezhtx.fetch_time  s       //$,R@@&&t|]FKK==55H$&..!AA&IIIIIIIIHH!@@HHHHHHHHH ""8VT:::r  Nmarketreturnc                     |                      |d          }||                     ||          |                     |d          |                     |d          d d dS )NsymbolactualMakerRateactualTakerRate)r  r  r   r   r   r   )r   safe_symbolsafe_number)r  feer  marketIds       r  parse_trading_feezhtx.parse_trading_fee  sl     ##C22&&x88%%c+<==%%c+<==
 
 	
r  r  c                 ^  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |dg           }|                     |di           }|                     ||          S )a  
        fetch the trading fees for a market
        :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symbolsr0   r  r   )r  r  (spotPrivateGetV2ReferenceTransactFeeRateextendr  r#  )r  r  r	  r  requestr  r  firsts           r  fetch_trading_feezhtx.fetch_trading_fee  s       !!!!!!!!!V$$vd|
 FFt{{SZ\bGcGcdddddddd  x44a,,%%eV444r  r%  c                   K   |                                   d {V  || j        }i }t          dt          |                    D ]<}||         }|                     |                     |          |           d {V ||<   =|S )Nr   )r  r%  rangelenfetch_trading_limits_by_id	market_id)r  r%  r	  resultir  s         r  fetch_trading_limitszhtx.fetch_trading_limits   s       !!!!!!!!!?lGq#g,,'' 	c 	cAQZF#'#B#B4>>RXCYCY[a#b#bbbbbbbF6NNr  r0   c                    K   d|i}|                      |                     ||                     d {V }|                     |                     |di                     S )Nr  r  )spotPublicGetV1CommonExchanger'  parse_trading_limitsr  )r  r0   r	  r(  r  s        r  r.  zhtx.fetch_trading_limits_by_id  sn      b
 ;;DKKQW<X<XYYYYYYYY" ((62)N)NOOOr  c                 f    |d|                      |d          |                      |d          didS )Namountzlimit-order-must-greater-thanzlimit-order-must-less-thanminmax)r  limits)r   )r  r;  r  r	  s       r  r5  zhtx.parse_trading_limits$  sP    " ++F4STT++F4PQQ 
 
 	
r  c                 t    |                      |t          | j        |         d         d         | j                  S )N	precisioncost)decimal_to_precisionr*   marketsr   )r  r  r>  s      r  cost_to_precisionzhtx.cost_to_precision>  s2    ((xf9Mk9Z[a9bdhdvwwwr  c                 "  K   d}|                      |ddi           \  }}g }g }t          |                                          }t          dt	          |                    D ]}||         }|                     ||          r|dk    r+|                    |                     dd|                     Q|dk    r+|                    |                     dd|                     |dk    rT|                    |                     dd|                     |                    |                     d	d|                     t          j	        |  d{V }t          dt	          |                    D ]}| 
                    |||                   }|S )
z
        retrieves data on all markets for huobi
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        Nr}   r   r   r@   r   r   rB   rC   )handle_option_and_paramslistkeysr,  r-  	safe_boolappend"fetch_markets_by_type_and_sub_typeasynciogatherarray_concat)r  r	  r   
allMarketspromisesrE  r1  keys           r  fetch_marketszhtx.fetch_marketsA  s      55fngWYZZv
EJJLL!!q#d))$$ 		j 		jAq'C~~eS)) j&==OOD$K$KFTXZ`$a$abbbbH__OOD$K$KDRZ\b$c$cddddI%%OOD$K$KFT]_e$f$fgggOOD$K$KHV_ag$h$hiii 2222222q#h--(( 	D 	DA**:x{CCJJr  c                   K   |dk    }i }d }|s|dk    r5d|d<   |                      |                     ||                     d {V }n|dk    rk|dk    r0|                     |                     ||                     d {V }ne|dk    r/|                     |                     ||                     d {V }n/|                     |                     ||                     d {V }|                     |dg           }t          |          }|d	k     r-t          | j        d
z   | 	                    |          z             g }	t          dt          |                    D ]}
||
         }d }d }d }d }d }d|v }| }d}d}d }d }|r|                     |d          }|                                }|                     |d          }|                     |d          }|d u}| }|d u}| }|rJd}|                    d          }|                     |d          }|                     |d	          }|r|n|}n|rbd}|                     |d          }|rd}|}n|                     |d          }|                    d          }|                     |d	          }|}nGd}|                     |d          }|                     |d          }||z   }|                                }|                     |          }|                     |          }|                     |          }|dz   |z   }d }|rH|r	|d|z   z  }n
|r|d|z   z  }|r1|                     |d          }|d|                     |          z   z  }|                     |d          } |                     |d          }!|                     |d          }"|                     |d          }#|r	|r| }#n|r| }!d }$d }%d }&d }'d }(d })|r|                     |                     |                     |d                              }$|                     |                     |                     |d                              }%|                     |                     |                     |d                              }&|                     d          }'|                     d          }(|                     |d           }*|*d!k    })nq|                     |d"          }$|                     d#          }%|                     d$          }'|                     d%          }(|                     |d&          }+|+d	k    })|                     |d'd#          },|                     |d(d#          }-t+          j        |,d#          pt+          j        |-d#          }.d }/|                     |d)          }0|0z|                     |0          }1|1d         |1d	         z   |1d*         z   |1d+         z   dz   |1d,         z   |1d-         z   dz   |1d.         z   |1d/         z   d0z   }0|                     |0          }/|	                    i d1|d2|d|d3|d4|d5|d6|d7|d8|d9|d|d:|o|.d|d|d;dd<|)d=||||(|'| ||                     |          d d |%|$|&d>|                     d#          |                     |,          |                     |-          d?|#|"d@d d d@|!d d@dA|/|dB           |	S )CNr@   r   allbusiness_typer   rC   rB   r  r   z, fetchMarkets() returned an empty response: r   contract_codeFdelivery_date-r  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_date      r   r         z	 00:00:00r0   lowercaseIdbasequotesettlebaseIdquoteIdsettleIdr  rA   rD   activer   )r7  pricer>  )r9  r:  superMaxr8  )leverager7  rn  r>  )r   r   r   r   contractSizeexpiryexpiryDatetimestrike
optionTyper=  r;  createdr  )0contractPublicGetLinearSwapApiV1SwapContractInfor'  *contractPublicGetApiV1ContractContractInfo*contractPublicGetSwapApiV1SwapContractInfospotPublicGetV1CommonSymbols	safe_listr-  r%   r0   jsonr,  r   lowersplitsafe_string_lowersafe_currency_codesafe_integeryymmddr   r  parse_precisionr,   	string_gtstring_to_chars_arrayr  rG  iso8601)2r  r  r  r	  isSpotr(  r  r@  
numMarketsr0  r1  r  rj  rk  rl  r0   rf  r   r@   rB   rC   r   r   rT  rR  partsrW  rg  rh  ri  r  rr  rq  minCost	maxAmount	minAmountpricePrecisionamountPrecisioncostPrecisionr   r   rm  r\  contractStatusleverageRatiosuperLeverageRatiohasLeveragerv  createdDatecreatedArrays2                                                     r  rH  z&htx.fetch_markets_by_type_and_sub_type[  s5	     &. 
	](""+0(!%!V!VW[WbWbcjlrWsWs!t!tttttttI%%8##%)%T%TUYU`U`ahjpUqUq%r%rrrrrrrHHV^^%)%T%TUYU`U`ahjpUqUq%r%rrrrrrrH!>>t{{7TZ?[?[\\\\\\\\Hn ..6266\\
>>!$',Z"Z]a]f]fgo]p]p"pqqqq#g,,'' a	 a	AQZFFGHBK'61H<DDFFG )%%fo>> hhjj $ 0 0 I I $ 0 0 I I&d2!z&d2$* +!DHHSMME!33FHEEF"44UA>>G)0=vvgHH 
+#D!33FHEEF +"'#)#//?? $

3"&"8"8"B"B#*))&/BB**63CDDg% hhjj**622D++G44E,,X66FCZ%'FF 8 *cDj(FF *cEk)F 8!..vGGFcDKK$7$777F++FODDL&&v/@AAG((AAI((AAI + + ,II +*G!N"O MEEF /!%!2!243G3GHXHXY_arHsHs3t3t!u!u"&"3"3D4H4HIYIYZ`btIuIu4v4v"w"w $ 1 1$2F2FtGWGWX^`qGrGr2s2s t t))'22))'22((998+!%!1!1&,!G!G"&"3"3C"8"8))(33))(33!%!2!26;L!M!M(A- ,,V5EsKKM!%!1!1&:WY\!]!]!+M3??m7CTUgilCmCmK G**6=AAK&#99+F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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"6"-+)   $0055#00??$($5$56H$I$I! !  )( 
  $# 
  '#  & #i5 5 5 5 5 5 5l r  symbolOrMarketIdc                 V   || j         v r|S d| j        vr
i | j        d<   |                     | j        di           }||v r||         S |                     | j         dd          }ddddd}t	          d	t          |                    D ]}||         }|                     |d
i           }|                     |d          }||         }	|d         r|d         dz   |d         z   dz   |	z   n|d         dz   |	z   }
|
|k    r|d         }|| j        d         |<   |c S || j        d         |<   |S )NfutureMarketIdsForSymbolsrC   TCWNWCQNQ)	this_week	next_weekquarternext_quarterr   r  contract_typer   rg  rU  rh  _r  )r@  r   	safe_dict	filter_byr,  r-  r  r   )r  r  r  futureMarketsfuturesCharsMapsr1  r  r  contractTypecontractSuffixconstructedIdr  s               r  "try_get_symbol_from_future_marketsz&htx.try_get_symbol_from_future_marketsi  s   t|++##
 ,t|;;8:DL45$(NN4<A\^`$a$a!888,-=>>t|XtDD 	
 
 q#m,,-- 
	 
	A"1%F??66266D++D/BBL-l;N]cdl]m  YF6NS06'?BSH>YYsy  {A  tB  EH  tH  KY  tYM 000)NT89:JK 1
 GW012BCr  c                    |                      |dd          }|                     ||          }|                     |          }|                     |dd          }d }d }d }d }	d|v rt	          |d         t
                    r9|                     |d         d          }|                     |d         d          }n,|                     |d          }|                     |d          }d	|v rt	          |d	         t
                    r9|                     |d	         d          }|                     |d	         d          }	n,|                     |d	          }|                     |d
          }	|                     |d          }
|                     |d          }|                     |d          }|                     |d          }|                     i d|d|d|                     |          d|                     |d          d|                     |d          d|d|d	|d|	dd d|
d|d|dd dd dd dd |||d|          S )Nr  rS  r  	quoteTimebidr   r   bidSizeaskaskSizeopencloser7  vol	timestampr  highlow	bidVolume	askVolumevwaplastpreviousClosechanger   average)
baseVolumequoteVolumer  )	safe_string_2r  r  r  
isinstancerD  r   safe_tickerr  )r  tickerr  r"  r  r  r  r  r  r  r  r  r  r  s                 r  parse_tickerzhtx.parse_ticker  s   \ %%fhHH!!(F3388@@''kBB			F??&-.. @&&ve}a88 ,,VE]A>>		&&vu55 ,,VY??	F??&-.. @&&ve}a88 ,,VE]A>>		&&vu55 ,,VY??	//  11%%fh77
&&vu55 !
f!
!
 Y//!
 D$$VV44	!

 4##FE22!
 3!
 !
 3!
 !
 D!
 D!
 U!
 E!
 T!
 d!
  $!!
" t#!
$ %&)!
 !
 !
* +  	r  c                 F  K   |                                   d{V  |                     |          }i }d}|d         r;|d         |d<   |                     |                     ||                     d{V }n|d         r|d         r;|d         |d<   |                     |                     ||                     d{V }n}|d         r:|d         |d<   |                     |                     ||                     d{V }n:|d         |d<   |                     |                     ||                     d{V }|                     |d	i           }|                     ||          }| 	                    |d
          }||d<   | 
                    |          |d<   |S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :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   r0   rS  r   rC   r  rB   tickr  r  r  )r  r  /contractPublicGetLinearSwapExMarketDetailMergedr'  #contractPublicGetMarketDetailMerged)contractPublicGetSwapExMarketDetailMergedspotPublicGetMarketDetailMergedr  r  r  r  )	r  r  r	  r  r(  r  r  r  r  s	            r  fetch_tickerzhtx.fetch_ticker  s      !!!!!!!!!V$$( 	`'-d|GO$!QQRVR]R]^egmRnRnooooooooHHI 		`h n$*4L!!%!I!I$++V]_eJfJf!g!ggggggg n+1$<(!%!O!OPTP[P[\cekPlPl!m!mmmmmmm &tGH!AA$++gW]B^B^________HX x44""400%%h55	'{!\\)44zr  c                 .  K   |                                   d{V  |                     |          }|                     |d          }d}||                     |          }d|v pd|v }d}d}|                     d||          \  }}|                     d||          \  }}i }|dk    }	|dk    }
|dk    }|d	k    }|d
k    }d}|	r|r|rE|
rd|d<   n|rd|d<   nd|d<   |                     |                     ||                     d{V }n|r{|
r0|                     |                     ||                     d{V }n|r0| 	                    |                     ||                     d{V }n]t          | j        dz             t          | j        dz             |                     |                     ||                     d{V }|                     |ddg           }|                     |||          }|                     |d|          S )a_  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: https://huobiapi.github.io/docs/spot/v1/en/#get-latest-tickers-for-all-pairs
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-a-batch-of-market-data-overview
        :see: https://huobiapi.github.io/docs/dm/v1/en/#get-a-batch-of-market-data-overview
        :see: 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   r  rR  r   r@   rC   rB   r   r   r  rQ  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 contractsr  ticksr  )r  market_symbolsr   r  r  handle_sub_type_and_params4contractPublicGetLinearSwapExMarketDetailBatchMergedr'  (contractPublicGetMarketDetailBatchMerged.contractPublicGetSwapExMarketDetailBatchMergedr$   r0   spotPublicGetMarketTickerssafe_list_2parse_tickersfilter_by_array_tickers)r  r%  r	  r)  r  isSubTypeRequestedr  r  r(  r  rC   rB   r   r   r  
rawTickerstickerss                    r  fetch_tickerszhtx.fetch_tickers4  s      !!!!!!!!!%%g..  !,,[[''F'61Q&7P99.&RXYYf99.&RXYY&.("X%i' 	[+ 	[ P 5/8GO,, 5/5GO,,/4GO,!%!Z!Z[_[f[fgnpv[w[w!x!xxxxxxx P V%)%R%RSWS^S^_fhnSoSo%p%pppppppHH V%)%X%XY]YdYdelntYuYu%v%vvvvvvvHH&tw  2U  (U  V  V  V"47  .O  $O  P  P  P!<<T[[RX=Y=YZZZZZZZZHf %%hDD
$$Z&AA++GXwGGGr  c                   K   |                                   d{V  |                     |          }|                     |          }d}d}|                     d||          \  }}|                     d||          \  }}d}|dk    s|dk    r"|dk    r|                     |           d{V }nm|dk    r"|dk    r|                     |           d{V }nE|dk    r"|dk    r|                     |           d{V }nt          | j	        dz   |z   dz             | 
                    |d	i           }|                     |d
g           }|                     ||          S )a  
        fetches the last price for multiple markets
        :see: https://www.htx.com/en-us/opend/newApiPages/?id=8cb81024-77b5-11ed-9966-0242ac110003 linear swap & linear future
        :see: https://www.htx.com/en-us/opend/newApiPages/?id=28c2e8fc-77ae-11ed-9966-0242ac110003 inverse future
        :see: 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
        Nru   rB   rC   r   r   z$ fetchLastPrices() does not support z markets yetr  r  )r  r  get_market_from_symbolsr  r  (contractPublicGetLinearSwapExMarketTrade"contractPublicGetSwapExMarketTradecontractPublicGetMarketTrader$   r0   r  r{  parse_last_prices)	r  r%  r	  r  r  r  r  r  r  s	            r  fetch_last_priceszhtx.fetch_last_prices  s      !!!!!!!!!%%g..--g6699:KVU[\\99:KVU[\\fV^^!1!1H9L9L!JJ6RRRRRRRRHH4 fnn7i#7#7!DDVLLLLLLLLHH. hW	%9%9!>>vFFFFFFFFHH0 tw)OORVVYgghhhx44~~dFB//%%dG444r  c                     |                      |dd          }|                     ||          }|                     |d          }|                     |d          }|d         d d |||dS )Nr  rS  rn  	direction)r  r  r  rn  sider  )r  safe_marketr   r   )r  entryr  r"  rn  r  s         r  parse_last_pricezhtx.parse_last_price  s    %%eXGG!!(F33  00$$UK88	 X&
 
 	
r  r  c                   K   |                                   d{V  |                     |          }ddi}d}|d         r<|d         |d<   |                     |                     ||                     d{V }n|d         r|d         r;|d         |d	<   |                     |                     ||                     d{V }n|d
         r:|d         |d<   |                     |                     ||                     d{V }nv|:|dk    r)|dk    r#|dk    r|dk    rt          | j        dz             |dk    r||d<   |d         |d	<   |                     |                     ||                     d{V }d|v r|d         s-t          | j        dz   | 
                    |          z             |                     |d          }|                     |d|                     |d                    }|                     |||          }	|                     |d          |	d<   |	S t          | j        dz   | 
                    |          z             )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        Nr  step0r   r0   rS  r   rC   r  rB   r   r         zP fetchOrderBook() limit argument must be None, 5, 10, 20, or 150, default is 150depthr  z+ fetchOrderBook() returned empty response: r  r:   noncez2 fetchOrderBook() returned unrecognized response: )r  r  (contractPublicGetLinearSwapExMarketDepthr'  contractPublicGetMarketDepth"contractPublicGetSwapExMarketDepthr   r0   spotPublicGetMarketDepthr    r|  r  r  parse_order_bookr   )
r  r  r  r	  r  r(  r  r  r  r0  s
             r  fetch_order_bookzhtx.fetch_order_book	  s      !!!!!!!!!V$$ G

 ( 	Y'-d|GO$!JJ4;;W^`fKgKghhhhhhhhHHI 	Yh g$*4L!!%!B!B4;;wX^C_C_!`!``````` g+1$<(!%!H!HU\^dIeIe!f!fffffff QJJUb[[u{{RU$TW  0B  &B  C  C  C C<<',GG$ &tGH!::4;;wPV;W;WXXXXXXXXH6 XF# o*W WZ^ZcZcdlZmZm mnnn??8V44D))$d6G6GRV6W6WXXI**4CCF"//i@@F7OMDG&ZZ]a]f]fgo]p]ppqqqr  c                    |                      |dd          }|                     ||          }|d         }|                     |dd          }|                     |dd|          }|                      |dd          }|                     |d	          }|                     |d
          }|%|                    d          }	|	d         }|	d         }|                     |d          }
|                      |dd          }|                      |dd          }|                     |d|          }|                     |d          }d }|                     |d          }|(t          j        |                     |d                    }|                      |dd          }|                     |          }|                     |d          }|F|t          j	        |d          r/|                     |d          }||}|                     |          }|||d}| 
                    |g d          }|                     |||||                     |          ||||
||||d|          S )NrS  r  r  
created-at
created_atra  order-idorder_idr  r  rU  r   r   rolern  trade_pricefilled-amountr7  trade_volumetrade_turnoverfilled-fees	trade_feezfee-currency	fee_assetzfilled-points0zfee-deduct-currencyr>  currency)trade_idztrade-idr0   )r0   r  orderr  r  r  r  r  takerOrMakerrn  r7  r>  r!  )r  r  r  r   r~  r  r,   
string_negr  string_equalssafe_string_n
safe_trader  )r  trader  r"  r  r  r  r  r  	typePartsr  priceStringamountString
costStringr!  feeCostfeeCurrencyIdfeeCurrencyfilledPointsfeeDeductCurrencyr0   s                        r  parse_tradezhtx.parse_trade_	  s   ^ %%e_hGG!!(F33!''t\BB	''|]IVV	""5*jAA{33v..

3IQ<DQ<D--eV<<((GG))%(KK''~|LL%%e-=>>
""5-88?()9)9%)M)MNNG**5.+NN--m<<''??#G$9'3$G$G$($4$4U<Q$R$R!$0*G"&"9"9:K"L"LK' C 'E'E'EFF"Y//( " 
  
   	r  sincec                    K   d}||                      |          }d}|                     d||          \  }}|dk    rt          | j        dz             |                     |||||           d{V S )a  
        fetch all the trades made from a single 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   r@   z6 fetchOrderTrades() is only supported for spot markets)r  r  r$   r0   fetch_spot_order_trades)r  r0   r  r  r  r	  r  r
  s           r  fetch_order_tradeszhtx.fetch_order_trades	  s       [[((F
!??@RTZ\bcc
Ftw)aabbb11"feUFSSSSSSSSSr  c                    K   |                                   d {V  d|i}|                     |                     ||                     d {V }|                     |d         d ||          S )Nr  r  )r  .spotPrivateGetV1OrderOrdersOrderIdMatchresultsr'  parse_trades)r  r0   r  r  r  r	  r(  r  s           r  r  zhtx.fetch_spot_order_trades	  s      !!!!!!!!!
 LLT[[Y`bhMiMijjjjjjjj  &!14FFFr  c                   K   |                                   d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S d}||                     |          }d}|                     d||          \  }}i }d}	|dk    r{| |                     |          }|d         |d<   |||d<   |||d	<   |                     d
||          \  }}|                     |                     ||                     d{V }	n|t          | j	        dz             |d         |d<   d|d<   |||d<   |                     d||          \  }}|||d<   |d         rd}
| 
                    d|          \  }
}|
dn|
}
|
dk    r0|                     |                     ||                     d{V }	n|
dk    r/|                     |                     ||                     d{V }	n|d         r|dk    r;|d         |d<   |                     |                     ||                     d{V }	nS|dk    r0|                     |                     ||                     d{V }	nt          | j	        dz   |z   dz             |                     |	d          }t#          |t$                    s|                     |d          }|                     ||||          S )a5  
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-match-results-via-multiple-fields-new
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-match-results-via-multiple-fields-new
        :see: 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   paginater@   r0   r  size
start-timeend-timez+ fetchMyTrades() requires a symbol argumentr   r   
trade_type
start_timeend_time	page_sizer   crossisolatedr   rC   rl  rB   z" fetchMyTrades() does not support  marketsr  trades)r  rC  fetch_paginated_call_dynamicr  r  handle_until_option!spotPrivateGetV1OrderMatchresultsr'  r   r0   handle_margin_mode_and_params7contractPrivatePostLinearSwapApiV3SwapMatchresultsExact<contractPrivatePostLinearSwapApiV3SwapCrossMatchresultsExact1contractPrivatePostApiV3ContractMatchresultsExact1contractPrivatePostSwapApiV3SwapMatchresultsExactr$   r  r  rD  r  )r  r  r  r  r	  r  r  r
  r(  r  
marginModer)  s               r  fetch_my_tradeszhtx.fetch_my_trades	  s      !!!!!!!!!88R\]]& 	j::?FTY[`bhiiiiiiiii[[((F
!??QWY_``
F
& !V,,$*4L! "' (-%"66z7FSSOGV!CCDKKPWY_D`D`aaaaaaaaHH~'2_(_```"(,GJ$%GL! (-%"66z7FSSOGV ',$h q!
%)%G%GY_%`%`"
F)3);WW*
++%)%a%abfbmbmnuw}b~b~%%HH7**%)%f%fgkgrgrsz  }C  hD  hD  &E  &E   E   E   E   E   E   EH	" q))(.z(:GH%%)%[%[\`\g\ghoqw\x\x%y%yyyyyyyHH6))%)%[%[\`\g\ghoqw\x\x%y%yyyyyyyHH&tw1U'UXb'beo'opppF 622&$'' 	7__VX66F  >>>r    c                   K   |                                   d{V  |                     |          }i }|t          |d          |d<   d}|d         r|d         r<|d         |d<   |                     |                     ||                     d{V }n |d         r:|d         |d	<   |                     |                     ||                     d{V }n|d
         r{|d         |d	<   |d         r0|                     |                     ||                     d{V }nr|d         r/|                     |                     ||                     d{V }n:|d         |d<   |                     |                     ||                     d{V }|                     |dg           }g }	t          dt          |                    D ]p}
|                     ||
         dg           }t          dt          |                    D ]3}|                     ||         |          }|	                    |           4q|                     |	d          }	|                     |	|d         ||          S )a  
        :see: https://huobiapi.github.io/docs/spot/v1/en/#get-the-most-recent-trades
        :see: https://huobiapi.github.io/docs/dm/v1/en/#query-a-batch-of-trade-records-of-a-contract
        :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-a-batch-of-trade-records-of-a-contract
        :see: 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>`
        N  r  rC   r   r0   r  r   rS  rB   r  r   r  )r  r  r9  #contractPublicGetMarketHistoryTrader'  /contractPublicGetLinearSwapExMarketHistoryTrade)contractPublicGetSwapExMarketHistoryTradespotPublicGetMarketHistoryTrader  r,  r-  r  rG  sort_byfilter_by_symbol_since_limit)r  r  r  r  r	  r  r(  r  r  r0  r1  r)  jr  s                 r  fetch_tradeszhtx.fetch_trades
  s      !!!!!!!!!V$$
 !%..GFO( 	`i  t$*4L!!%!I!I$++V]_eJfJf!g!ggggggg! t+1$<(!%!U!UVZVaVabikqVrVr!s!sssssssF^ 	`'-d|GO$i  t!%!O!OPTP[P[\cekPlPl!m!mmmmmmm! t!%!U!UVZVaVabikqVrVr!s!sssssss &tGH!AA$++gW]B^B^________H2 x44q#d))$$ 	% 	%A__T!Wfb99F1c&kk** % %((F;;e$$$$% fk22009I5RWXXXr  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr0   r  r  r  r  r7  )safe_timestampr   )r  ohlcvr  s      r  parse_ohlcvzhtx.parse_ohlcv
  s     t,,UF++UF++UE**UG,,UH--
 	
r  r   c           	      V  K   |                                   d{V  d}|                     |dd          \  }}|r!|                     d|||||d           d{V S |                     |          }d|                     | j        ||          i}|                     |ddg          }	|                     |ddg          }d}
|                     |d	          \  }
}|
| 	                    |
dz            nd}|d
         r|t          |d          |d<   nd}|	|                     |          }d}|%|                                 }|||dz
  z  z
  |d<   |}n9| 	                    |dz            }||d<   |                     |||dz
  z            }||n||d<   d}|d         r|d         r|d         |d<   |	dk    r1|                     |                     ||                     d{V }n|	dk    r1|                     |                     ||                     d{V }n|	dk    r)t#          | j        dz   |d         z   dz   |	z   dz             |                     |                     ||                     d{V }nw|d         r|d         |d<   |	dk    r1|                     |                     ||                     d{V }n-|	dk    r)t#          | j        dz   |d         z   dz   |	z   dz             |	dk    r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|d         r|d         |d<   |d         r|	dk    r1|                     |                     ||                     d{V }nC|	dk    r)t#          | j        dz   |d         z   dz   |	z   dz             |	dk    r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|d         r|	dk    r1|                     |                     ||                     d{V }nm|	dk    r)t#          | j        dz   |d         z   dz   |	z   dz             |	dk    r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|d         |d<   d}|                     |ddd          \  }}|sE|t          |d          |d<   |                     |                     ||                     d{V }nh|| 	                    |dz            |d<   |||d<   |t          d|          |d<   |                     |                     ||                     d{V }|                     |d g           }|                     |||||          S )!a#  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: https://huobiapi.github.io/docs/spot/v1/en/#get-klines-candles
        :see: https://huobiapi.github.io/docs/dm/v1/en/#get-kline-data
        :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-kline-data
        :see: 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   r  r4  period	priceTypern  untilr   r6  r  r   fromtorC   r   r0   r  markindexpremiumIndex r  z has no api endpoint for z kline datar   rS  rB   r   Tr  )r  rC  "fetch_paginated_call_deterministicr  r   r   r	  omithandle_param_integerparse_to_intr9  parse_timeframesecondssum1contractPublicGetIndexMarketHistoryMarkPriceKliner'  (contractPublicGetIndexMarketHistoryIndexr   r0   #contractPublicGetMarketHistoryKline;contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline>contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline/contractPublicGetLinearSwapExMarketHistoryKline5contractPublicGetIndexMarketHistorySwapMarkPriceKline8contractPublicGetIndexMarketHistorySwapPremiumIndexKline)contractPublicGetSwapExMarketHistoryKlinespotPublicGetMarketHistoryKline!spotPublicGetMarketHistoryCandlesr{  parse_ohlcvs)r  r  	timeframer  r  r	  r  r  r(  rE  rF  untilSecondsdurationcalcualtedEndnowstartr  useHistoricalr  s                      r  fetch_ohlcvzhtx.fetch_ohlcv
  s[       !!!!!!!!!88zZZ& 	~@@vW\^cenpvx|}}}}}}}}}V$$d&&t	9MM
 &&vW/EFF	6K#9::11&'BBv;@;Lt((666SW* 	^ "%eT"2"2  //	:: $=,,..C&)H	,B&BGFO$'MM --edl;;E&+GFO$(HHUH	4J$K$KM1=1IP]( 9	fi  x$*4L!&&%)%[%[\`\g\ghoqw\x\x%y%yyyyyyyHH'))%)%R%RSWS^S^_fhnSoSo%p%pppppppHH.00$TWs]VF^%CFa%adm%mp}%}~~~%)%M%MdkkZaciNjNj%k%kkkkkkkHH! 	x+1$<(&&%)%e%efjfqfqry  |B  gC  gC  &D  &D   D   D   D   D   D   DHH'))$TWs]VF^%CFa%adm%mp}%}~~~.00%)%h%himititu|  E  jF  jF  &G  &G   G   G   G   G   G   GHH%)%Y%YZ^ZeZefmouZvZv%w%wwwwwwwHF^ $	f'-d|GO$i  x&&%)%_%_`d`k`klsu{`|`|%}%}}}}}}}HH'))$TWs]VF^%CFa%adm%mp}%}~~~.00%)%b%bcgcncnovx~cc  &A  &A   A   A   A   A   A   AHH%)%S%STXT_T_`gioTpTp%q%qqqqqqqHH! x&&%)%e%efjfqfqry  |B  gC  gC  &D  &D   D   D   D   D   D   DHH'))$TWs]VF^%CFa%adm%mp}%}~~~.00%)%h%himititu|  E  jF  jF  &G  &G   G   G   G   G   G   GHH%)%Y%YZ^ZeZefmouZvZv%w%wwwwwwwH &tGH M$($A$A&,Xvx|$}$}!M6  f$&)%&6&6GFO!%!E!EdkkRY[aFbFb!c!ccccccc $&*&7&7&E&EGFO+$0GDM$&)$&6&6GFO!%!G!GT[]cHdHd!e!eeeeeee ~~h33  vy%GGGr  c                    K   |                                   d{V  |                     |           d{V }|                     |d          }|                     |          S )a  
        fetch all the accounts associated with a profile
        :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
        Nr  )r  spotPrivateGetV1AccountAccountsr  parse_accounts)r  r	  r  r  s       r  fetch_accountszhtx.fetch_accountss  sz       !!!!!!!!!==fEEEEEEEE x00""4(((r  c                     |                      |d          }|                     | j        di           }|                     |||          }||                      |d          |d dS )Nr  r  r0   )r  r0   r  code)r   r  r   )r  accounttypeIdr  r  s        r  parse_accountzhtx.parse_account  sp     !!'622t|^RHH|VV<<""7D11	
 
 	
r  c                   K   |                                   d {V }|                     |dd          }||S |dk    r|dk    rd}n|dk    rd}|d n|                     |          }t          dt	          |                    D ]}||         }	|                     |	d	          }
|                     |
d
d           }|                     |	d          }|dk    r||k    r|                     |	d          c S r||k    r|                     |	d          c S |                     |di           }|                     |d          S )N	accountId
account-idr@   r&  r  r'  rA   r   r  subtyper  r0   )load_accountssafe_value_2r/  r,  r-  r  r   )r  r  r2  r  r	  accountsrr  r"  r1  rn  r  rt  typeFromAccountdefaultAccounts                 r  fetch_account_id_by_typezhtx.fetch_account_id_by_type  s     ++--------%%fk<HH	 6>>W$$%z))"N441G1Gq#h--(( 		7 		7AqkG??7F33D&&tY==G"..w??Oxh&&++GT::::: '((''66666 )1b99555r  c                 Z  K   |                      |           d{V }|                     |dg           }i }i | j        d<   i | j        d<   t          dt	          |                    D ]A}||         }|                     |d          }|                     |          }i | j        d         |<   |                     |dg           }	i }
|                     |d          }|d	k    }d}d}d}d
}d
}t          dt	          |	                    D ]l}|	|         }|                     |d          }|                     |dd          }|| j        d         |         |<   || j        d         |<   |                     |          }| 	                    |d          }| 	                    |d          }|                     |d          }|                     |d          }|dk    }|dk    }|r|n|}|r|n|}|o|}| 
                    |                     |d                    }|||nt          j        ||          }| 	                    |d          }|||ddd||dd|||||                     |          d	|
|<   n||||||ddddd||ddddd|                     |          |
d||<   C|S )z
        fetches all available currencies on an exchange
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        Nr  networkChainIdsByNamesnetworkNamesByChainIdsr   r  chains
instStatusnormalFchain	baseChaindisplayNameminWithdrawAmtmaxWithdrawAmtwithdrawStatusdepositStatusallowedwithdrawPrecisiontransactFeeWithdrawr8  )depositr   )	r  r0   networkr;  rm  r  r   r!  r=  )r7  r   r  )r  rm  r0   rm  r  r   r!  r1   r;  r=  r
  )"spotPublicGetV2ReferenceCurrenciesr  r   r,  r-  r   r  r  network_id_to_coder   r  r,   
string_minr  )r  r	  r  r  r0  r1  r  
currencyIdrm  r~  r
  r  currencyActiveminPrecisionminWithdrawmaxWithdrawr  r   r=  
chainEntryuniqueChainIdtitlenetworkCoder  r  withdrawEnableddepositEnabledrm  r=  r!  s                                 r  fetch_currencieszhtx.fetch_currencies  s      @@HHHHHHHHL x4413-.13-.q#d))$$ O	 O	AGE))%<<J**:66D;=DL1248__UHb99FH))%>>J'83NLKKGH1c&kk** ' '#AY
 $ 0 0W E E**:{MRRFS56t<UCHM56}E"55mDD"..z;KLL"..z;KLL!%!1!1*>N!O!O $ 0 0_ M M#1Y#>"/9"</>M??X-;I..'(;^ 001A1A*Na1b1bcc	(1=1E99GL^_hjvLwLwL&&z3HII&'* $(#'$ $
 $/#.% %	 	 %- /!%!2!29!=!=%) )%%*  ("$  $# 
  +*! !
  $#     "..|<<$1 F4LL4 r  c                 H   t          | j        d                                                   }t          |          }|dk    rt	          | j        dz             |                     | j        d         ||          }t          t          |           	                    |          S )Nr}  r   z7 networkIdToCode() - markets need to be loaded at first)
rD  r   rE  r-  r   r0   r  r  r.   r  )r  	networkIdcurrencyCoderE  
keysLengthnetworkTitler  s         r  r  zhtx.network_id_to_code4  s    DL!9:??AABBYY
??*c cdddt|4L'MyZcddS$22<@@@r  c                    |t          | j        dz             t          | j        d                                                   }t          |          }|dk    rt          | j        dz             |                     | j        d         |i           }||v r||         S t          t          |           
                    |          }|                     |||          S )Nz3 networkCodeToId() requires a currencyCode argumentr|  r   z7 networkCodeToId() - markets need to be loaded at first)r   r0   rD  r   rE  r-  r   r  r  r.   network_code_to_id)r  r  r  rE  r  uniqueNetworkIdsr  r  s          r  r  zhtx.network_code_to_id=  s    #DG.c$cdddDL!9:??AABBYY
??*c cddd??4<8P+QS_acdd***#K00 d++>>{KKL??#3\<PPPr  c                   K   |                                   d{V  d}|                     dd|          \  }}|                     | j        di           }|                     |ddd          }|                     |ddg          }i }|dk    }|dk    }|                     | j        dd	d
          }|                     |dd	|          }	|                     |dd	|	          }	|	dk    }
|	d
k    }d}|                     d|          \  }}|                     |dd	g          }|dk    }|dk    }|dk    p|o|p|}d}|s|r|rd|r1|                     | 	                    ||                     d{V }n| 
                    | 	                    ||                     d{V }nf|                                  d{V  |                     |dd|           d{V }||d<   |                     | 	                    ||                     d{V }n|r0|                     | 	                    ||                     d{V }n|rb|r0|                     | 	                    ||                     d{V }n|                     | 	                    ||                     d{V }nc|
ra|r0|                     | 	                    ||                     d{V }n/|                     | 	                    ||                     d{V }d|i}|                     |d          }|s|r|rt'          dt)          |                    D ]}||         }|                     |                     |d                    }|                     |d          }i }t'          dt)          |                    D ]O}||         }|                     |d          }|                     |          }|                     |||          ||<   P|                     |          ||<   ѐna|                     |dg           }t'          dt)          |                    D ]O}||         }|                     |d          }|                     |          }|                     |||          ||<   P|                     |          }n|rWt'          dt)          |                    D ]6}||         }|                     |d          }|                     |          }|r|                     |di           }t'          dt)          |                    D ]h}||         }|                     |d          } ||                     |d          d}!|                     |           }|!||<   |                     |          }i|                                 }"|                     |d          |"d<   |                     |d          |"d<   |"||<   |                     |          }8nl|r|                     |di           }#|rt'          dt)          |                    D ]}||         }|                     |dd          } |                     |           }$|                     |d          }|                     |          }%|                     |$d |%d!                   }|m|                                 }"|                     |d"          |"d<   |                     |d          |"d<   i }&|"|&|<   |$d         }|                     |&          ||<   nB|                                 }"|                     |#d#          |"d<   |                     |#d"          |"d$<   |                     |#dd          }|                     |          }|"||<   |                     |          }n|
rt'          dt)          |                    D ]}||         }|                     |d          }|                     |          }|                                 }"|                     |d          |"d<   |                     |d          |"d<   |"||<   |                     |          }|S )%aY  
        :see: https://huobiapi.github.io/docs/spot/v1/en/#get-account-balance-of-a-specific-account
        :see: https://www.htx.com/en-us/opend/newApiPages/?id=7ec4b429-7773-11ed-9966-0242ac110003
        :see: https://www.htx.com/en-us/opend/newApiPages/?id=10000074-77b7-11ed-9966-0242ac110003
        :see: https://huobiapi.github.io/docs/dm/v1/en/#query-asset-valuation
        :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-user-s-account-information
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-user-s-account-information
        :see: 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>`
        NrZ   isUnifiedAccountunifiedFr@   rC   r  r  r   r   r'  r&  rA   rs  r  r  r   r  rD  r  margin_assetisolated_swaprS  margin_available)rm  freemargin_staticr  margin_frozenusedmargin_accountri  rm  margin_balancewithdraw_availabletotal)r  r  r  r   rv  rN  r  r-  %spotPrivateGetV1MarginAccountsBalancer'  *spotPrivateGetV1CrossMarginAccountsBalanceru  rz  /spotPrivateGetV1AccountAccountsAccountIdBalance3contractPrivateGetLinearSwapApiV3UnifiedAccountInfo1contractPrivatePostLinearSwapApiV1SwapAccountInfo6contractPrivatePostLinearSwapApiV1SwapCrossAccountInfo+contractPrivatePostApiV1ContractAccountInfo+contractPrivatePostSwapApiV1SwapAccountInfor,  r-  r  r   r  parse_margin_balance_helpersafe_balancer   rn  r  safe_currency)'r  r	  r  r   r  r(  r@   rC   r  r  r   r   r2  r'  r&  rA   r  rr  r0  r  r1  r  r  balances	subResultr=  balancer  rm  marginAssetr  r  r"  
subBalancern  r)  r  r  accountsByCodes'                                          r  fetch_balancezhtx.fetch_balanceK  s	      !!!!!!!!!99.$PVWWf//$,CC,,V5GTYZZ6$6	#BCC("++DL:JIW_``$$W.>	>ZZ$$V-=y'RRi'X%
!??PVWW
F6$4i#@AA*,w&("E(D%2C8 	p6 	p 	t s%)%O%OPTP[P[\cekPlPl%m%mmmmmmmHH%)%T%TUYU`U`ahjpUqUq%r%rrrrrrrHH((*********"&"?"?dDRX"Y"YYYYYYY	(1%!%!U!UVZVaVabikqVrVr!s!sssssss 	p!UUVZVaVabikqVrVrssssssssHH 		p {!%!W!WX\XcXcdkmsXtXt!u!uuuuuuu!%!\!\]a]h]hiprx]y]y!z!zzzzzzz 	p p!%!Q!QRVR]R]^egmRnRn!o!ooooooo!%!Q!QRVR]R]^egmRnRn!o!ooooooo@ (#x00 R	/6 R	/ 3q#d)),, 
B 
BA GE!--d.>.>uh.O.OPPF#uf==H "I"1c(mm44 e e"*1+%)%5%5gz%J%J
#66zBB*.*J*J7TXZc*d*d	$%)%6%6y%A%AF6NN
B  ??4<<q#h--00 [ [A&qkG!%!1!1':!F!FJ22:>>D#'#C#CGTSY#Z#ZF4LL**622 =	/1c$ii(( 7 7Q"..unEE#66{CC 7$(OOE?B$O$OM"1c-&8&899 	; 	;"/"2#'#3#3G_#M#M$0$($4$4W>P$Q$Q& &
 "&!1!1(!;!;)3v!%!2!26!:!:	; #llnnG&*&6&6uo&N&NGFO&*&6&6uo&N&NGFO+2F<(!..v66FF+7,  &	/OOD!R00E 3q#d)),, K KA"1gG#11'?L\]]H!--h77F!%!1!1'>!J!JJ#11*==H++FHhv>NOOD '"&,,..*.*:*:7DT*U*U*.*:*:7O*T*T)+/6t,!'!1)-):):>)J)Jv#K& ,,.."&"2"25:N"O"O#'#3#3E;K#L#L !//~xPP
..z::&t**622 		/1c$ii(( ' 'q'!--gx@@
..z::,,.."&"2"27<N"O"O"&"2"27O"L"L&t&&v..Fr  c                   K   |                                   d{V  d}||                     |          }d}|                     d||          \  }}i }d}|dk    r|                     |d          }|1|                     |                     ||                     d{V }n||d<   |                     |                     ||                     d{V }n|t          | j        dz             | 	                    |dd          }|||d<   n||d<   | 
                    |ddg          }|d	         |d
<   |d         rd}	|                     d|          \  }	}|	dn|	}	|	dk    r0|                     |                     ||                     d{V }n|	dk    r/|                     |                     ||                     d{V }n|d         r|dk    r;|d         |d<   |                     |                     ||                     d{V }nS|dk    r0|                     |                     ||                     d{V }nt!          | j        dz   |z   dz             |                     |d          }
t%          |
t&                    r|                     |
d          }
|                     |
          S )a?  
        fetches information on an order made by the user
        :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   r@   clientOrderIdr  z( fetchOrder() requires a symbol argumentclient_order_idr  r0   rS  r   r&  r'  r   rC   rl  r  rB   z fetchOrder() does not support r(  r  r   )r  r  r  r   )spotPrivateGetV1OrderOrdersGetClientOrderr'  "spotPrivateGetV1OrderOrdersOrderIdr   r0   r  rN  r-  /contractPrivatePostLinearSwapApiV1SwapOrderInfo4contractPrivatePostLinearSwapApiV1SwapCrossOrderInfo)contractPrivatePostApiV1ContractOrderInfo)contractPrivatePostSwapApiV1SwapOrderInfor$   r  r  rD  parse_order)r  r0   r  r	  r  r
  r(  r  r  r2  r  s              r  fetch_orderzhtx.fetch_order{  sp      !!!!!!!!![[((F
!??fV\]]
F
  ,,V_EEM( "&!O!OPTP[P[\cekPlPl!m!mmmmmmm&(
#!%!H!HU\^dIeIe!f!fffffff~'2\(\]]] ..v7H/ZZM$&(
##-:)*6,=+OPP'-d|GO$h n!
%)%G%GV\%]%]"
F)3);WW*
++%)%Y%YZ^ZeZefmouZvZv%w%wwwwwwwHH7**%)%^%^_c_j_jkrtz_{_{%|%|||||||H	" n))(.z(:GH%%)%S%STXT_T_`gioTpTp%q%qqqqqqqHH6))%)%S%STXT_T_`gioTpTp%q%qqqqqqqHH&tw1R'RU_'_bl'lmmm| &11eT"" 	.OOE1--E&&&r  c                     d }||v r	||         }n|                                  }|d         dk    r|                     |d          |d<   |d         dk    r|                     |d          |d<   |S )Nr  r  r  r  frozenr  )rn  r   )r  r  rm  r0  rn  s        r  r  zhtx.parse_margin_balance_helper<  s}    6>>TlGGllnnG6?g%%"..w	BBGFO6?h&&"..w	BBGFOr  c                   K   |                      | j        dd          }|dk    r|t          | j        dz             |                                  d {V  d }d|i}| |                     |          }|d         |d<   |||d<   |                     |d          |d	<   |                     d	||          \  }}|||d
<   d }	|dk    r0|                     | 	                    ||                     d {V }	n/| 
                    | 	                    ||                     d {V }	|                     |	dg           }
|                     |
|||          S )Nr  r  z) fetchOrders() requires a symbol argumentstatesr0   r  r   i L
r!  r  r  )r   r   r   r0   r  r  rS  r+  spotPrivateGetV1OrderOrdersr'  spotPrivateGetV1OrderHistoryr{  parse_orders)r  r  r  r  r  r	  methodr  r(  r  r  s              r  fetch_spot_orders_by_stateszhtx.fetch_spot_orders_by_statesH  s     !!$,0KMopp777~'2](]^^^!!!!!!!!! f
" [[((F &tGH$)GL!"&((52E"F"FGJ22:wOO#GFO777!==dkk'SY>Z>Z[[[[[[[[HH!>>t{{7TZ?[?[\\\\\\\\H6 ~~h33  vue<<<r  c                 D   K   |                      d||||           d {V S )NzGpre-submitted,submitted,partial-filled,filled,partial-canceled,canceledr  r  r  r  r  r	  s        r  fetch_spot_orderszhtx.fetch_spot_orders  sd      556  BH  JO  QV  X^  _  _  _  _  _  _  _  _  	_r  c                 D   K   |                      d||||           d {V S )Nz filled,partial-canceled,canceledr  r  s        r  fetch_closed_spot_orderszhtx.fetch_closed_spot_orders  s9      556XZ`bginpvwwwwwwwwwr  c                 	  K   |t          | j        dz             |                                  d {V  |                     |          }ddd}d }|                     |d          }|                     |d          }	|                     |dd          }
|                     |g d	          }|s|	s|
r|||d
<   |d         |d<   d|d<   n|||d<   |d         |d<   d|d<   |                     d||          \  }}|d         rd }|                     d|          \  }}|dn|}|dk    r|r1| 	                    | 
                    ||                     d {V }n|	r1|                     | 
                    ||                     d {V }n|
r1|                     | 
                    ||                     d {V }n|                     | 
                    ||                     d {V }n|dk    r|r1|                     | 
                    ||                     d {V }nI|	r1|                     | 
                    ||                     d {V }n|
r1|                     | 
                    ||                     d {V }n|                     | 
                    ||                     d {V }n|d         r|d         r|r1|                     | 
                    ||                     d {V }nn|	r1|                     | 
                    ||                     d {V }n;|
r1|                     | 
                    ||                     d {V }n|                     | 
                    ||                     d {V }n|d         r|d         |d<   |r0|                     | 
                    ||                     d {V }n|	r0|                     | 
                    ||                     d {V }na|
r0|                     | 
                    ||                     d {V }n/|                     | 
                    ||                     d {V }|                     |d          }t5          |t6                    s|                     |dg           }|                     ||||          S )Nz1 fetchContractOrders() requires a symbol argumentr   r  )r"  r   stopstopLossTakeProfittrailingFr  r  r  r%  r0   rS  Z   ra  r#  r   r   r  r$  r   fetchContractOrdersr&  r'  r   rB   rC   rl  r  r  orders)r   r0   r  r  r  rF  rN  r+  r-  6contractPrivatePostLinearSwapApiV1SwapTriggerHisordersr'  3contractPrivatePostLinearSwapApiV1SwapTpslHisorders4contractPrivatePostLinearSwapApiV1SwapTrackHisorders/contractPrivatePostLinearSwapApiV3SwapHisorders;contractPrivatePostLinearSwapApiV1SwapCrossTriggerHisorders8contractPrivatePostLinearSwapApiV1SwapCrossTpslHisorders9contractPrivatePostLinearSwapApiV1SwapCrossTrackHisorders4contractPrivatePostLinearSwapApiV3SwapCrossHisorders0contractPrivatePostSwapApiV1SwapTriggerHisorders-contractPrivatePostSwapApiV1SwapTpslHisorders.contractPrivatePostSwapApiV1SwapTrackHisorders)contractPrivatePostSwapApiV3SwapHisorders0contractPrivatePostApiV1ContractTriggerHisorders-contractPrivatePostApiV1ContractTpslHisorders.contractPrivatePostApiV1ContractTrackHisorders)contractPrivatePostApiV3ContractHisordersr  rD  r  )r  r  r  r  r	  r  r(  r  r  r  r  r2  r  s                r  fetch_contract_orderszhtx.fetch_contract_orders  s     >#DG.a$abbb!!!!!!!!!V$$ 	
 	
 vv..!__V5IJJ>>&*e<<6#M#M#MNN 
	 % 
	  
	  ',$'-d|GO$%'GM"" (-%"(,GJGFO22:wOO( )	rJ!%!C!CDY[a!b!bJ%/%7jJZ'' x%)%`%`aealalmtv|a}a}%~%~~~~~~~HH' x%)%]%]^b^i^ijqsy^z^z%{%{{{{{{{HH x%)%^%^_c_j_jkrtz_{_{%|%|||||||HH%)%Y%YZ^ZeZefmouZvZv%w%wwwwwwwHHw&& }%)%e%efjfqfqry  |B  gC  gC  &D  &D   D   D   D   D   D   DHH' }%)%b%bcgcncnovx~cc  &A  &A   A   A   A   A   A   AHH }%)%c%cdhdodopwy  eA  eA  &B  &B   B   B   B   B   B   BHH%)%^%^_c_j_jkrtz_{_{%|%|||||||HI 	rf~ r r%)%Z%Z[_[f[fgnpv[w[w%x%xxxxxxxHH' r%)%W%WX\XcXcdkmsXtXt%u%uuuuuuuHH r%)%X%XY]YdYdelntYuYu%v%vvvvvvvHH%)%S%STXT_T_`gioTpTp%q%qqqqqqqHH! 	r$*:$6! r%)%Z%Z[_[f[fgnpv[w[w%x%xxxxxxxHH' r%)%W%WX\XcXcdkmsXtXt%u%uuuuuuuHH r%)%X%XY]YdYdelntYuYu%v%vvvvvvvHH%)%S%STXT_T_`gioTpTp%q%qqqqqqqH^ 622&$'' 	;__VXr::F  >>>r  c           	      r   K   ddi}|                      ||||                     ||                     d {V S )Nr   z5,6,7)r  r'  )r  r  r  r  r	  r(  s         r  fetch_closed_contract_ordersz htx.fetch_closed_contract_ordersn  sP      g
 //udkkRY[aFbFbcccccccccr  c                 z  K   |                                   d{V  d}||                     |          }d}|                     d||          \  }}|dk    p|dk    }|r|t          | j        dz   |z   dz             |r|                     ||||           d{V S |                     ||||           d{V S )a  
        :see: https://huobiapi.github.io/docs/spot/v1/en/#search-past-orders
        :see: https://huobiapi.github.io/docs/spot/v1/en/#search-historical-orders-within-48-hours
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-orders-new
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-orders-new
        :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-history-orders-new
        :see: 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.stop]: *contract only* if the orders are stop 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   rB   rC   z. fetchOrders() requires a symbol argument for  orders)r  r  r  r   r0   r  r  )r  r  r  r  r	  r  r
  r   s           r  fetch_orderszhtx.fetch_orderst  s     & !!!!!!!!![[((F
!??vW]^^
F&(EjH.D 	y#DG.^$^ak$knw$wxxx 	N33FE5&QQQQQQQQQ//ufMMMMMMMMMr  c                   K   |                                   d{V  d}|                     |dd          \  }}|r |                     d||||d           d{V S d}||                     |          }d}|                     d||          \  }}|dk    r|                     ||||           d{V S |                     ||||           d{V S )as  
        :see: https://huobiapi.github.io/docs/spot/v1/en/#search-past-orders
        :see: https://huobiapi.github.io/docs/spot/v1/en/#search-historical-orders-within-48-hours
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-orders-new
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-orders-new
        :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-history-orders-new
        :see: 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>`
        NFra   r  r6   r@   )r  rC  r*  r  r  r  r  )r  r  r  r  r	  r  r  r
  s           r  fetch_closed_orderszhtx.fetch_closed_orders  s2     " !!!!!!!!!88ATV`aa& 	s::;NPVX]_dflnqrrrrrrrrr[[((F
!??@SU[]cdd
F66vueVTTTTTTTTT::65%QWXXXXXXXXXr  c                 D  K   |                                   d{V  d}||                     |          }i }d}|                     d||          \  }}d}|dk    r||d         |d<   |                     |d          }	|	r|                                  d{V  t          dt          | j                            D ]5}
| j        |
         }|d         dk    r|                     |d          }	|	 n6|	|d<   |||d	<   |                     |d          }| 	                    | 
                    ||                     d{V }n|t          | j        d
z             |||d<   |d         |d<   |                     |d          }|                     |d          }|                     |dd          }|                     |g d          }|d         rd}|                     d|          \  }}|dn|}|dk    r|r1|                     | 
                    ||                     d{V }n|r1|                     | 
                    ||                     d{V }n|r1|                     | 
                    ||                     d{V }n|                     | 
                    ||                     d{V }n|dk    r|r1|                     | 
                    ||                     d{V }nI|r1|                     | 
                    ||                     d{V }n|r1|                     | 
                    ||                     d{V }n|                     | 
                    ||                     d{V }n|d         r|d         r|r1|                     | 
                    ||                     d{V }nn|r1|                     | 
                    ||                     d{V }n;|r1|                     | 
                    ||                     d{V }n|                     | 
                    ||                     d{V }n|d         r|d         |d<   |r0|                     | 
                    ||                     d{V }n|r0|                     | 
                    ||                     d{V }na|r0|                     | 
                    ||                     d{V }n/|                     | 
                    ||                     d{V }|                     |d          }tA          |tB                    s|                     |dg           }| "                    ||||          S )a*  
        :see: https://huobiapi.github.io/docs/spot/v1/en/#get-all-open-orders
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-current-unfilled-order-acquisition
        :see: 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.stop]: *contract only* if the orders are stop 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@   r0   r  rs  r   r  r  z- fetchOpenOrders() requires a symbol argumentr%  rS  r  r  r  Fr  r   r&  r'  r   rB   rC   rl  r  r  )#r  r  r  r   ru  r,  r-  rw  rN  spotPrivateGetV1OrderOpenOrdersr'  r   r0   r  rF  r-  7contractPrivatePostLinearSwapApiV1SwapTriggerOpenorders4contractPrivatePostLinearSwapApiV1SwapTpslOpenorders5contractPrivatePostLinearSwapApiV1SwapTrackOpenorders0contractPrivatePostLinearSwapApiV1SwapOpenorders<contractPrivatePostLinearSwapApiV1SwapCrossTriggerOpenorders9contractPrivatePostLinearSwapApiV1SwapCrossTpslOpenorders:contractPrivatePostLinearSwapApiV1SwapCrossTrackOpenorders5contractPrivatePostLinearSwapApiV1SwapCrossOpenorders1contractPrivatePostSwapApiV1SwapTriggerOpenorders.contractPrivatePostSwapApiV1SwapTpslOpenorders/contractPrivatePostSwapApiV1SwapTrackOpenorders*contractPrivatePostSwapApiV1SwapOpenorders1contractPrivatePostApiV1ContractTriggerOpenorders.contractPrivatePostApiV1ContractTpslOpenorders/contractPrivatePostApiV1ContractTrackOpenorders*contractPrivatePostApiV1ContractOpenordersr  rD  r  )r  r  r  r  r	  r  r(  r
  r  rr  r1  rn  r  r  r  r2  r  s                    r  fetch_open_orderszhtx.fetch_open_orders  s      !!!!!!!!![[((F
!??@QSY[abb
F!$*4L!((>>I ((*********q#dm"4"455 " "A"mA.Gv&00$($4$4Wd$C$C	$0!E$-GL! "'YYv|44F!AA$++gW]B^B^________HH~'2a(abbb ',$'-d|GO$??6622D!%9M!N!N~~fj%@@HYYv'Q'Q'QRRFh )w!
%)%G%GHY[a%b%b"
F)3);WW*
++ })-)e)efjfqfqry  |B  gC  gC  *D  *D  $D  $D  $D  $D  $D  $D+ })-)b)bcgcncnovx~cc  *A  *A  $A  $A  $A  $A  $A  $A! })-)c)cdhdodopwy  eA  eA  *B  *B  $B  $B  $B  $B  $B  $B)-)^)^_c_j_jkrtz_{_{)|)|#|#|#|#|#|#|7** B)-)j)jkokvkvw~  AG  lH  lH  *I  *I  $I  $I  $I  $I  $I  $I+ B)-)g)ghlhshst{  ~D  iE  iE  *F  *F  $F  $F  $F  $F  $F  $F! B)-)h)himititu|  E  jF  jF  *G  *G  $G  $G  $G  $G  $G  $G)-)c)cdhdodopwy  eA  eA  *B  *B  $B  $B  $B  $B  $B  $B	" w&> w w)-)_)_`d`k`klsu{`|`|)})}#}#}#}#}#}#}+ w)-)\)\]a]h]hiprx]y]y)z)z#z#z#z#z#z#z! w)-)])]^b^i^ijqsy^z^z){){#{#{#{#{#{#{)-)X)XY]YdYdelntYuYu)v)v#v#v#v#v#v#vH% 	w(.z(:GH% w)-)_)_`d`k`klsu{`|`|)})}#}#}#}#}#}#}+ w)-)\)\]a]h]hiprx]y]y)z)z#z#z#z#z#z#z! w)-)])]^b^i^ijqsy^z^z){){#{#{#{#{#{#{)-)X)XY]YdYdelntYuYu)v)v#v#v#v#v#v#vr 622&$'' 	;__VXr::F  >>>r  c                 R    ddddddddddddddd}|                      |||          S )Nr  canceledclosed	canceling)zpartial-filledzpartial-canceledfilledr  	submittedrv  r_  23456711r   r  r   statusess      r  parse_order_statuszhtx.parse_order_status  sT     % *"!
 
$ &&999r  c           
      *   |                      |dd          }|                     |                      |dd                    }|d}|                     |g d          }|                     |d          }|                     |d          }d	|v r+|d	                             d
          }|d         }|d         }|                      |dd          }	|                     |	|          }|                     |g d          }
|                      |dd          }d }d }|M|                    d          dk    r4|dk    r|                     |d          }nF|                     |d          }n/|                      |dd          }|                     |g d          }|                     |g d          }|                      |dd          }|                      |dd          }|                     |d|          }d }|Kd }|                     |d          }||                     |          }n|dk    r|d         n|d          }||d!}|                      |d"d#          }|                     |d$          }| 	                    |d%          }| 
                    |d&          }d }|
|dk    rd'nd(}|                     i d)|d*|d+|d,|
d-|                     |
          d.d d|d         d	|d/d d0d d1|d|d2|d3|d4|d5|d||d ||||d6|          S )7Nerr_codeerr-coder\  r   rejected)r0   order_id_strr  r  order_price_typer  rU  r   r   rS  r  )r  r  ra  r  client-order-idr  sellfield-cash-amountr7  volume)zfilled-cash-amountr*  r  )r  zfield-amountr  rn  order_pricer  z
field-feesr!  r   rh  rg  r  
stop-pricetrigger_pricetrade_avg_pricer)  reduce_onlyFTr  r0   r  r  r  lastTradeTimestamptimeInForcepostOnlyr  	stopPricetriggerPricer  r>  )r  	remainingr   
reduceOnlyr!  r)  )r  r!  r	  r   r~  r  safe_integer_nfindr  r  r  
safe_orderr  )r  r  r  rejectedCreateOrdersr   r0   r  r  	orderTyper"  r  r  r>  r7  r  rn  r  r!  r  r  r4  r  r)  reduceOnlyIntegerr7  s                            r  r  zhtx.parse_order  s   N  $11%ZPP((););E7H)U)UVV+F'I'I'IJJ{33'9::U??f++C00IQ<DQ<D%%e_hGG!!(F33''/Z/Z/Z[[	**52CE[\\499X#6#6!#;#;v~~''/BCC''x88''xBBF%%e-j-j-jkkD##E+\+\+\]]""5'=AA$$UM<HH""5%99K ,,UK@@M("55mDD26&..fWoovf~' C &&ulOLL	""5*;<<11 --e]CC
(#4#9#9J  
E 
" 
 ] 
 	 

 Y// 
 !$ 
 fX& 
 D 
 4 
  
 D 
 U 
  
 I 
 w 
  D! 
" f# 
$ $/ 
  
  
0 1  	r  r>  c                    K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d<   |                     |dd|d|           d{V S )a  
        create a market buy order by providing the symbol and cost
        :see: 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>`
        Nr@   z9 createMarketBuyOrderWithCost() supports spot orders onlyFr  r  buy)r  r  r$   r0   create_order)r  r  r>  r	  r  s        r  !create_market_buy_order_with_costz%htx.create_market_buy_order_with_cost  s       !!!!!!!!!V$$f~ 	ftw)ddeee6;23&&vxdFSSSSSSSSSr  r  r  r7  rn  c	                    K   |t          | j        dz             |t          | j        dz             ||d<   ||d<   |                     ||||||           d{V S )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 argumenttrailingPercenttrailingTriggerPrice)r   r0   r@  )	r  r  r  r  r7  rn  rC  rD  r	  s	            r  create_trailing_percent_orderz!htx.create_trailing_percent_order  s       "#DG.q$qrrr'#DG.v$vwww$3 !)=%&&&vtT65&QQQQQQQQQr  c                   K   |                                   d{V  |                                  d{V  |                     |          }d}|                     d|          \  }}|                     |d         ||           d{V }	|	|d         d}
|                    dd          }|                    dd          }|                     | j        |d         i           }|                     |d	d
          }|3|                     |di           }||v rt          | j
        dz             nz|dk    rdnd}|                     |d|          }|                     ||          |
d
<   ||
d<   |dk    s|dk    rd|z   }n)|dk    r#|dk    rt          | j
        dz   |z   dz             d}|                     |dk    |dk    |          \  }}|rd}|                     |dd          }|dk    r|dz   }n|dk    rd}|d z   |z   |
d<   |                     |d!d"          }|M|                     | j        d#i           }|                     |d          }||                                 z   |
d"<   n||
d"<   |d$k    rd%|
d&<   n|d'k    rd(|
d&<   n|d)k    rd*|
d&<   |dk    r|d+k    rd}d,}|                     |dd-d,          \  }}|                     |d.          }|                     |d.          }||                     ||          }n|rm|t)          | j
        d/z             |                     |          }|                     |          }|                     |t-          j        ||                    }n|                     ||          }||
d0<   n|                     ||          |
d0<   |                     |d1i           }||v r|                     ||          |
d2<   |                     |g d3          }|                     |
|          S )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 fullfilled, 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
        NrO   r  r0   )rs  r  zbuy- zsell-r4  r-  r  zN createOrder() requires a stopPrice or a stop-price parameter for a stop orderr)  ltegteoperatorr  r  zstop-r  r  z  createOrder() does not support r  r  r  r2  r  FOKz-fokIOCr  rU  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 argumentr7  r  rn  )r4  r-  r  r(  rJ  r2  )r  ru  r  r-  rz  replacer  r   r  r   r0   r   price_to_precisionr$   handle_post_onlyuuidrC  r   rN  amount_to_precisionr"   number_to_stringr,   
string_mulr'  )r  r  r  r  r7  rn  r	  r  r2  rr  r(  r<  r   r4  r  defaultOperatorstopOperatorr3  r2  r  r  brokerIdquoteAmountr  r>  r  r  r  s                               r  create_spot_order_requestzhtx.create_spot_order_request  s      !!!!!!!!!  """""""""V$$
!??vVV
F77v
TZ[[[[[[[[	 $Tl
 
 LL,,	%%gr22	//$,vCC&&v{LII	!__W6FKKNN**'  3C  )C  D  D  D + )-eeUO++FJPPL$($;$;FI$N$NGL!".GJW$$){*B*B#i/		|++)?O2O2O"47-O#ORV#VYb#bccc00h1F	UbHbdjkk& 	&%I&&v}eDD%!F*IIE!!I*y0**6?DUVV __T\8R@@F''55H)1DIIKK)?G%&&)6G%&   2GH:%% ,GH5   0GH!!K04-8<8U8UV\^k  nQ  SW  9X  9X5-v##FF33DYYvv..F"66vtDD2 G=&tw  2m  (m  n  n  n $(#8#8#@#@L"&"7"7">">K"&":":67CUVbdoCpCp"q"qKK"66vvFF +GH $ 8 8 H HGH//'3DbII''#66vuEEGG6#}#}#}~~{{7F+++r  c                 p   |                      |          }|d         |                     ||          |d}d}	|                     |dk    |dk    |          \  }	}|	rd}|                     |dd          }
|
dk    rd	}n|
d
k    rd}|                     |dd          }|                     |dd          }|                     |dd          }|                     |dd          }|                     |d|          }|du}|du}|du}|du}|rS|                     |ddd          }||d<   |                     ||          |d<   ||                     ||          |d<   n/|s|rv|r:||d<   |                     ||          |d<   ||                     ||          |d<   n||d<   |                     ||          |d<   ||                     ||          |d<   n|rMt          j	        |d          }| 
                    |          |d<   ||d<   |                     |dd           |d<   nf|                     |d!d"          }|||d!<   |                     |d"g          }|d#k    s|dk    s|d	k    s|dk    r|                     ||          |d$<   |sD|sB|                     |d%d&d'          }|rd(|d&<   |                     |g d)d(          |d*<   |s||d<   |                     | j        d+i           }|                     |d          }||d,<   |                     |g d-          }|                     ||          S ).a  
         * @ignore
        helper function to build request
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :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 fullfilled, 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
        r0   )rS  r+  r  Nr  	post_onlyr2  r  rK  fokrL  r  r4  r.  stopLossPricesl_trigger_pricetakeProfitPricetp_trigger_pricerC  callback_raterD  triggerTypetrigger_typeler,  sl_order_price_typesl_order_pricetp_order_price_typetp_order_price100active_pricer'  formula_pricer  r  r  rn  r7  r0  Fr   )	leverRate
lever_raterp  rn  r  channel_code)
r7  r4  r^  r`  rc  rm  r2  rp  rC  rD  )r  rS  rQ  r   safe_number_2r  r   rP  r,   
string_divparse_to_numericr  rN  rv  r8  r  r   r'  )r  r  r  r  r7  rn  r	  r  r(  r3  r2  r5  stopLossTriggerPricetakeProfitTriggerPricerC  rD  isTrailingPercentOrderisStopisStopLossTriggerOrderisTakeProfitTriggerOrderrc  trailingPercentStringr  r7  r  rX  s                             r  create_contract_order_requestz!htx.create_contract_order_request$  s3    V$$#D\..vv>>
 

 001A4;CVX^__& 	D&&v}eDD%DDE!!D))&+OO#11&/K]^^!%!3!3F<MOa!b!b,,V5FXX#//8NPUVV!0!<T)!5T!A#9#E  	J,,V]NTXYYK&1GN#'+'>'>v|'T'TGO$ )-)@)@)O)O&# 	J'? 	J% 	W15-..2.E.EfNb.c.c*+$040G0GPU0V0VG,-15-..2.E.EfNd.e.e*+$040G0GPU0V0VG,-# 	J$+$6$N$N!'+'<'<=R'S'SGO$&:GN#*.*:*:6CUWf*g*gG&'' //8I?[[M(-:)*6O+<==w$%--45==DKDWDW#'#:#:65#I#I % 	3.F 	3**6<PUVVJ +)*&$($7$7@g@g@gij$k$kGL!) 3.2*+x<<##FD11"*6  $E  $E  $E  F  F{{7F+++r  c                   K   |                                   d{V  |                     |          }|                     |dd          }|                     |dd          }	|                     |dd          }
|                     |d          }|du}|du}|	du}|
du}d}|d	         rV|rt	          | j        d
z             |                     ||||||           d{V }|                     |           d{V }nO|                     ||||||          }|d         r%d}| 	                    d|          \  }}|dn|}|dk    r||r| 
                    |           d{V }n|s|r|                     |           d{V }n|r|                     |           d{V }n|                     |           d{V }n|dk    rz|r|                     |           d{V }nd|s|r|                     |           d{V }nC|r|                     |           d{V }n$|                     |           d{V }n|d         r|d         rx|r|                     |           d{V }n|s|r|                     |           d{V }n|r|                     |           d{V }n|                     |           d{V }n|d         rw|r|                     |           d{V }nY|s|r|                     |           d{V }n9|r|                     |           d{V }n|                     |           d{V }d}d}|d	         ra|                     i d|d|                     |d          ddddddddddd|d|d|d|ddddd dd!dd"dd#dd$di|          S |r/|                     |di           }|                     |d%i           }nH|r/|                     |di           }|                     |d&i           }n|                     |di           }|                     ||          S )'a  
        create a trade order
        :see: https://huobiapi.github.io/docs/spot/v1/en/#place-a-new-order                   # spot, margin
        :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-an-order        # coin-m swap
        :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-trigger-order   # coin-m swap trigger
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-an-order           # usdt-m swap cross
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-trigger-order      # usdt-m swap cross trigger
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order        # usdt-m swap isolated
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-trigger-order   # usdt-m swap isolated trigger
        :see: https://huobiapi.github.io/docs/dm/v1/en/#place-an-order                        # coin-m futures
        :see: 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 fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.stopPrice]: 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* 'open', 'close', or 'both', required in hedge mode
        :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
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr4  r.  r^  r_  r`  ra  rC  r@   z@ createOrder() does not support trailing orders for spot marketsr   rO   r&  r'  r   rB   rC   r  r0   r  r  r  r1  r   r  r  r  rn  r7  r  r6  r>  r)  r!  r  r  sl_ordertp_order)r  r  rp  r   r$   r0   rZ  !spotPrivatePostV1OrderOrdersPlacerz  r-  2contractPrivatePostLinearSwapApiV1SwapTriggerOrder/contractPrivatePostLinearSwapApiV1SwapTpslOrder0contractPrivatePostLinearSwapApiV1SwapTrackOrder+contractPrivatePostLinearSwapApiV1SwapOrder7contractPrivatePostLinearSwapApiV1SwapCrossTriggerOrder4contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder5contractPrivatePostLinearSwapApiV1SwapCrossTrackOrder0contractPrivatePostLinearSwapApiV1SwapCrossOrder,contractPrivatePostSwapApiV1SwapTriggerOrder)contractPrivatePostSwapApiV1SwapTpslOrder*contractPrivatePostSwapApiV1SwapTrackOrder%contractPrivatePostSwapApiV1SwapOrder,contractPrivatePostApiV1ContractTriggerOrder)contractPrivatePostApiV1ContractTpslOrder*contractPrivatePostApiV1ContractTrackOrder%contractPrivatePostApiV1ContractOrderr:  r   r  r  )r  r  r  r  r7  rn  r	  r  r5  rs  rt  rC  ru  rv  rw  rx  r  spotRequestcontractRequestr2  r  r0  s                         r  r@  zhtx.create_orderu  s     @ !!!!!!!!!V$$))&+OO#11&/K]^^!%!3!3F<MOa!b!b**63DEE!0!<T)!5T!A#9#E &> /	e% q"47-o#oppp $ > >vtTSY[`bh i iiiiiiiK!CCKPPPPPPPPHH"@@tU[]bdjkkOh (e!
.2.P.PQ^`o.p.p+
O)3);WW*
++ k)-)`)`ap)q)q#q#q#q#q#q#q/ k3K k)-)])]^m)n)n#n#n#n#n#n#n/ k)-)^)^_n)o)o#o#o#o#o#o#o)-)Y)YZi)j)j#j#j#j#j#j#j7** p)-)e)efu)v)v#v#v#v#v#v#v/ p3K p)-)b)bcr)s)s#s#s#s#s#s#s/ p)-)c)cds)t)t#t#t#t#t#t#t)-)^)^_n)o)o#o#o#o#o#o#o	" e&> e e)-)Z)Z[j)k)k#k#k#k#k#k#k/ e3K e)-)W)WXg)h)h#h#h#h#h#h#h/ e)-)X)XYh)i)i#i#i#i#i#i#i)-)S)STc)d)d#d#d#d#d#d#dH% e e)-)Z)Z[j)k)k#k#k#k#k#k#k/ e3K e)-)W)WXg)h)h#h#h#h#h#h#h/ e)-)X)XYh)i)i#i#i#i#i#i#i)-)S)STc)d)d#d#d#d#d#d#d> &> 	;?? $$d&&x88$ T$ D	$
 %d$ $$ $$ $ $ $ &$ $$ T$ $ $$  t!$"  #$$ 4%$ $& '  ( $ 	;??8VR88D__T:r::FF% 	;??8VR88D__T:r::FF__Xvr::F///r  r  c           	      <  K   |                                   d{V  g }d}d}d}t          dt          |                    D ]y}||         }|                     |d          }	||	}n||	k    rt	          | j        dz             |                     |d          }
|                     |d          }|                     |d          }|                     |d          }|                     |d	i           }|                     d
|          }|d         }|"||}n||k    rt	          | j        dz             |                     |          }d}|d         r!| 	                    |	|
||||           d{V }n| 
                    |	|
||||          }|                     |d          }|                    |           {i }d}|d         r|                     |           d{V }n||d<   |d         rJ|dn|}|dk    r|                     |           d{V }nq|dk    r|                     |           d{V }nO|d         rG|d         r|                     |           d{V }n#|d         r|                     |           d{V }d}|d         r|                     |dg           }n[|                     |di           }|                     |dg           }|                     |dg           }|                     ||          }|                     ||          S )aK  
        create a list of trade orders
        :see: https://huobiapi.github.io/docs/spot/v1/en/#place-a-batch-of-orders
        :see: https://huobiapi.github.io/docs/dm/v1/en/#place-a-batch-of-orders
        :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-a-batch-of-orders
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-a-batch-of-orders
        :see: 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   r  z; createOrders() requires all orders to have the same symbolr  r  r7  rn  r	  rP   zS createOrders() requires all orders to have the same margin mode(isolated or cross)r@   r2  orders_datar   r&  r'  r   rB   rC   r  successerrors)r  r,  r-  r   r   r0   r  r-  r  rZ  rz  rN  rG  privatePostOrderBatchOrders0contractPrivatePostLinearSwapApiV1SwapBatchorder5contractPrivatePostLinearSwapApiV1SwapCrossBatchorder*contractPrivatePostSwapApiV1SwapBatchorder*contractPrivatePostApiV1ContractBatchorderrK  r  )r  r  r	  ordersRequestsr  r  r2  r1  rawOrderr"  r  r  r7  rn  orderParamsmarginResultcurrentMarginModeorderRequestr(  r  r0  r  r  r  s                           r  create_orderszhtx.create_orders  s      !!!!!!!!!
q#f++&& 	0 	0AayH''(;;H~!X%%$TW/l%lmmm##Hf55D##Hf55D__Xx88FOOHg66E//(HbAAK==nkZZL ,Q ,%!2JJ!%666(  4I  *I  J  J  J[[((FLf~ t%)%C%CHdTXZ`bgit%u%uuuuuuu#AA(DRVX^`egrss99\<@@L!!,////&> 	^!==nMMMMMMMMHH%3GM"h 
^)3);WW*
++%)%Z%Z[b%c%cccccccHH7**%)%_%_`g%h%hhhhhhhH	" ^&> ^%)%T%TU\%]%]]]]]]]HHH% ^%)%T%TU\%]%]]]]]]]HT &> 	8__Xvr::FF??8VR88DoodIr::G__T8R88F&&w77F  000r  c                   K   |                                   d{V  d}||                     |          }d}|                     d||          \  }}i }d}|dk    r|                     |dd          }|6||d<   |                     |                     ||                     d{V }n||d<   |                     |ddg          }|                     |                     ||                     d{V }n^|t          | j	        dz             |                     |dd          }|||d	<   n||d<   |                     |ddg          }|d
         r|d         |d<   n|d         |d<   | 
                    |d          }	| 
                    |d          }
|                     |dd          }|                     |g d          }|d         rd}|                     d|          \  }}|dn|}|dk    r|	r1|                     |                     ||                     d{V }n,|
r1|                     |                     ||                     d{V }n|r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|dk    r|	r1|                     |                     ||                     d{V }n\|
r1|                     |                     ||                     d{V }n)|r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|d         r|d         r|	r1|                     |                     ||                     d{V }n|
r1|                     |                     ||                     d{V }nN|r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|d
         r|	r0|                     |                     ||                     d{V }n|
r0|                     |                     ||                     d{V }n|r0|                     |                     ||                     d{V }nM|                     |                     ||                     d{V }nt;          | j	        dz   |z   dz             |                     |                     ||          |dd          S )a  
        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.stop]: *contract only* if the order is a stop 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>`
        NrI   r@   r(  r  r  z) cancelOrder() requires a symbol argumentr  r  rC   rl  r  r0   rS  r  r  r  Fr  r   r&  r'  r   rB   z  cancelOrder() does not support r(  r  )r0   r   )r  r  r  r  /spotPrivatePostV1OrderOrdersOrderIdSubmitcancelr'  rN  3spotPrivatePostV1OrderOrdersSubmitCancelClientOrderr   r0   r  rF  r-  3contractPrivatePostLinearSwapApiV1SwapTriggerCancel0contractPrivatePostLinearSwapApiV1SwapTpslCancel1contractPrivatePostLinearSwapApiV1SwapTrackCancel,contractPrivatePostLinearSwapApiV1SwapCancel8contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancel5contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel6contractPrivatePostLinearSwapApiV1SwapCrossTrackCancel1contractPrivatePostLinearSwapApiV1SwapCrossCancel-contractPrivatePostSwapApiV1SwapTriggerCancel*contractPrivatePostSwapApiV1SwapTpslCancel+contractPrivatePostSwapApiV1SwapTrackCancel&contractPrivatePostSwapApiV1SwapCancel-contractPrivatePostApiV1ContractTriggerCancel*contractPrivatePostApiV1ContractTpslCancel+contractPrivatePostApiV1ContractTrackCancel&contractPrivatePostApiV1ContractCancelr$   r  )r  r0   r  r	  r  r
  r(  r  r  r  r  r  r2  s                r  cancel_orderzhtx.cancel_order  s|      !!!!!!!!![[((F
!??vW]^^
F
  ..v7H/ZZM$&(
#!%!U!UVZVaVabikqVrVr!s!sssssss-:)*6,=+OPP!%!Y!YZ^ZeZefmouZvZv!w!wwwwwww~'2](]^^^ ..v7H/ZZM$&(
##-:)*6,=+OPPh 8$*:$6!!+1$<(??6622D!%9M!N!N~~fj%@@HYYv'Q'Q'QRRFh *k!
%)%G%GW]%^%^"
F)3);WW*
++ y)-)a)abfbmbmnuw}b~b~))######+ y)-)^)^_c_j_jkrtz_{_{)|)|#|#|#|#|#|#|! y)-)_)_`d`k`klsu{`|`|)})}#}#}#}#}#}#})-)Z)Z[_[f[fgnpv[w[w)x)x#x#x#x#x#x#x7** ~)-)f)fgkgrgrsz  }C  hD  hD  *E  *E  $E  $E  $E  $E  $E  $E+ ~)-)c)cdhdodopwy  eA  eA  *B  *B  $B  $B  $B  $B  $B  $B! ~)-)d)deiepepqx  {A  fB  fB  *C  *C  $C  $C  $C  $C  $C  $C)-)_)_`d`k`klsu{`|`|)})}#}#}#}#}#}#}	" k&> s s)-)[)[\`\g\ghoqw\x\x)y)y#y#y#y#y#y#y+ s)-)X)XY]YdYdelntYuYu)v)v#v#v#v#v#v#v! s)-)Y)YZ^ZeZefmouZvZv)w)w#w#w#w#w#w#w)-)T)TUYU`U`ahjpUqUq)r)r#r#r#r#r#r#rH% s s)-)[)[\`\g\ghoqw\x\x)y)y#y#y#y#y#y#y+ s)-)X)XY]YdYdelntYuYu)v)v#v#v#v#v#v#v! s)-)Y)YZ^ZeZefmouZvZv)w)w#w#w#w#w#w#w)-)T)TUYU`U`ahjpUqUq)r)r#r#r#r#r#r#r"47-O#OR\#\_i#ijjj( {{4++Hf== @
 @
   	r  c                 	  K   |                                   d{V  d}||                     |          }d}|                     d||          \  }}i }d}|dk    r|                     |dd          }|                     |dd|          }|"t	          |t
                    r|g|d<   n?||d<   n9t	          |t
                    r|g|d<   n||d<   |                     |g d	          }|                     |                     ||                     d{V }n|t          | j
        d
z             |                     |dd          }|                     |dd|          }|d                    |          |d<   n||d<   |                     |g d          }|d         r|d         |d<   n|d         |d<   |                     |d          }	|                     |d          }
|                     |ddg          }|d         r[d}|                     d|          \  }}|dn|}|dk    r|	r1|                     |                     ||                     d{V }n`|
r1|                     |                     ||                     d{V }n-|                     |                     ||                     d{V }n|dk    r|	r1|                     |                     ||                     d{V }n|
r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n_|d         r9|d         r|	r1|                     |                     ||                     d{V }n|
r0|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|d         r|	r0|                     |                     ||                     d{V }n|
r0|                     |                     ||                     d{V }nM|                     |                     ||                     d{V }nt7          | j
        dz   |z   dz             |S )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.stop]: *contract only* if the orders are stop 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>`
        NrJ   r@   r(  r  client-order-idsclientOrderIdsz	order-ids)r(  r  r  r  z* cancelOrders() requires a symbol argumentr  client_order_ids,r  )r  r  r  r  rC   rl  r  r0   rS  r  r  r   r&  r'  r   rB   z! cancelOrders() does not support r(  )r  r  r  rv  r  strrN  'spotPrivatePostV1OrderOrdersBatchcancelr'  r   r0   r  joinr  r-  r  r  r  r  r  r  r  r  r  r  r  r  r$   )r  idsr  r	  r  r
  r(  r  r  r  r  r2  s               r  cancel_orderszhtx.cancel_orders  sR      !!!!!!!!![[((F
!??PVX^__
F	
 !..v7H/ZZN!..v7IK[]kllN%nc22 /,/5GK((+.GK((nc22 A3A2BG.//2@G./6+u+u+uvv!II$++V]_eJfJfggggggggHH~'2^(^___!//8I?[[N!//8JL\^lmmN%&)hhsmm
##-;)*6+u+u+uvvh 8$*:$6!!+1$<(??6622D!%9M!N!NYYv0D'EFFFh "l!
%)%G%GX^%_%_"
F)3);WW*
++ y)-)a)abfbmbmnuw}b~b~))######+ y)-)^)^_c_j_jkrtz_{_{)|)|#|#|#|#|#|#|)-)Z)Z[_[f[fgnpv[w[w)x)x#x#x#x#x#x#x7** ~)-)f)fgkgrgrsz  }C  hD  hD  *E  *E  $E  $E  $E  $E  $E  $E+ ~)-)c)cdhdodopwy  eA  eA  *B  *B  $B  $B  $B  $B  $B  $B)-)_)_`d`k`klsu{`|`|)})}#}#}#}#}#}#}	" l&> s s)-)[)[\`\g\ghoqw\x\x)y)y#y#y#y#y#y#y+ s)-)X)XY]YdYdelntYuYu)v)v#v#v#v#v#v#v)-)T)TUYU`U`ahjpUqUq)r)r#r#r#r#r#r#rH% s s)-)[)[\`\g\ghoqw\x\x)y)y#y#y#y#y#y#y+ s)-)X)XY]YdYdelntYuYu)v)v#v#v#v#v#v#v)-)T)TUYU`U`ahjpUqUq)r)r#r#r#r#r#r#r"47-P#PS]#]`j#jkkkh r  c                 z	  K   |                                   d{V  d}||                     |          }d}|                     d||          \  }}i }d}|dk    r>||d         |d<   |                     |                     ||                     d{V }n!|t          | j        dz             |d         r|d         |d<   |d         |d	<   |                     |d
          }|                     |d          }|                     |dd          }	| 	                    |g d          }|d         rd}
| 
                    d|          \  }
}|
dn|
}
|
dk    r|r1|                     |                     ||                     d{V }n,|r1|                     |                     ||                     d{V }n|	r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|
dk    r|r1|                     |                     ||                     d{V }n\|r1|                     |                     ||                     d{V }n)|	r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|d         r|d         r|r1|                     |                     ||                     d{V }n|r1|                     |                     ||                     d{V }nN|	r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|d         r|r0|                     |                     ||                     d{V }n|r0|                     |                     ||                     d{V }n|	r0|                     |                     ||                     d{V }nM|                     |                     ||                     d{V }nt7          | j        dz   |z   dz             |S )a  
        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.stop]: *contract only* if the orders are stop 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>`
        NrH   r@   r0   r  z- cancelAllOrders() requires a symbol argumentrC   rl  rS  r  r  r  Fr  r   r&  r'  r   rB   z$ cancelAllOrders() does not support r(  )r  r  r  1spotPrivatePostV1OrderOrdersBatchCancelOpenOrdersr'  r   r0   r  rF  rN  r-  6contractPrivatePostLinearSwapApiV1SwapTriggerCancelall3contractPrivatePostLinearSwapApiV1SwapTpslCancelall4contractPrivatePostLinearSwapApiV1SwapTrackCancelall/contractPrivatePostLinearSwapApiV1SwapCancelall;contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancelall8contractPrivatePostLinearSwapApiV1SwapCrossTpslCancelall9contractPrivatePostLinearSwapApiV1SwapCrossTrackCancelall4contractPrivatePostLinearSwapApiV1SwapCrossCancelall0contractPrivatePostSwapApiV1SwapTriggerCancelall-contractPrivatePostSwapApiV1SwapTpslCancelall.contractPrivatePostSwapApiV1SwapTrackCancelall)contractPrivatePostSwapApiV1SwapCancelall0contractPrivatePostApiV1ContractTriggerCancelall-contractPrivatePostApiV1ContractTpslCancelall.contractPrivatePostApiV1ContractTrackCancelall)contractPrivatePostApiV1ContractCancelallr$   )r  r  r	  r  r
  r(  r  r  r  r  r2  s              r  cancel_all_orderszhtx.cancel_all_orders  s      !!!!!!!!![[((F
!??@QSY[abb
F
 !$*4L!!SSTXT_T_`gioTpTpqqqqqqqqHH~'2a(abbbh 7$*:$6!'-d|GO$??6622D!%9M!N!N~~fj%@@HYYv'Q'Q'QRRFh *o!
%)%G%GHY[a%b%b"
F)3);WW*
++ |)-)d)deiepepqx  {A  fB  fB  *C  *C  $C  $C  $C  $C  $C  $C+ |)-)a)abfbmbmnuw}b~b~))######! |)-)b)bcgcncnovx~cc  *A  *A  $A  $A  $A  $A  $A  $A)-)])]^b^i^ijqsy^z^z){){#{#{#{#{#{#{7** A)-)i)ijnjujuv}  @F  kG  kG  *H  *H  $H  $H  $H  $H  $H  $H+ A)-)f)fgkgrgrsz  }C  hD  hD  *E  *E  $E  $E  $E  $E  $E  $E! A)-)g)ghlhshst{  ~D  iE  iE  *F  *F  $F  $F  $F  $F  $F  $F)-)b)bcgcncnovx~cc  *A  *A  $A  $A  $A  $A  $A  $A	" o&> v v)-)^)^_c_j_jkrtz_{_{)|)|#|#|#|#|#|#|+ v)-)[)[\`\g\ghoqw\x\x)y)y#y#y#y#y#y#y! v)-)\)\]a]h]hiprx]y]y)z)z#z#z#z#z#z#z)-)W)WX\XcXcdkmsXtXt)u)u#u#u#u#u#u#uH% v v)-)^)^_c_j_jkrtz_{_{)|)|#|#|#|#|#|#|+ v)-)[)[\`\g\ghoqw\x\x)y)y#y#y#y#y#y#y! v)-)\)\]a]h]hiprx]y]y)z)z#z#z#z#z#z#z)-)W)WX\XcXcdkmsXtXt)u)u#u#u#u#u#u#u"47-S#SV`#`cm#mnnn0 r  r  c                    |                      |d          }|                      |d          }|                      |d          }|                     ||          }|                     ||          }|                      |d          }|                      |d          }|                     |           ||||                     |          ||dS )Naddress
addressTagr  noter  )r  r  tagr  r  r  )r   r  r  check_addressr  )	r  depositAddressr  r  r  r  rm  r  r  s	            r  parse_deposit_addresszhtx.parse_deposit_address   s     "">9==~|<<%%njAA
%%j(;;&&z8<<77$$^W==	7###..y99"
 
 	
r  rm  c                 l  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |dg           }|                     ||d         gd          }|                     |d          S )a  
        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
        Nr  r0   r  rm  Fr  )r  r  %spotPrivateGetV2AccountDepositAddressr'  r  parse_deposit_addressesindex_by)r  rm  r	  r  r(  r  r  parseds           r  "fetch_deposit_addresses_by_networkz&htx.fetch_deposit_addresses_by_network  s       !!!!!!!!!==&&
 CCDKKPWY_D`D`aaaaaaaa x44--dXf5E4FNN}}VY///r  c                   K   |                                   d{V  |                     |          }|                     |          \  }}|                     ||           d{V }|                     |d         ||          }||         S )a9  
        fetch the deposit address for a currency associated with self account
        :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>`
        Nrm  )r  r  handle_network_code_and_paramsr  )select_network_code_from_unified_networks)r  rm  r	  r  r  paramsOmitedindexedAddressesselectedNetworkCodes           r  fetch_deposit_addresszhtx.fetch_deposit_address8  s       !!!!!!!!!==&&$($G$G$O$O!\!%!H!H|!\!\\\\\\\"LLXV\M]_jl|}} 344r  c                 
  K   |                                   d {V  |                     |          }d|d         i}|                     |                     ||                     d {V }|                     |dg           }|                     ||d         gd          }	g }
t          dt          |	                    D ]C}|	|         }|d u p|d         |k    }|d u p|d         |k    }|r|r|
                    |           D|
S )	Nr  r0   r  rm  Fr   r  r  )	r  r  &spotPrivateGetV2AccountWithdrawAddressr'  r  r  r,  r-  rG  )r  rm  r  r  r	  r  r(  r  r  allAddresses	addressesr1  r  	noteMatchnetworkMatchs                  r  fetch_withdraw_addresseszhtx.fetch_withdraw_addressesF  sA     !!!!!!!!!==&&
 DDT[[QXZ`EaEabbbbbbbb x4433D8F;K:LeTT	q#l++,, 	* 	*A"1oGC76?d+BI'4/WWY5G;5VL *\ *  )))r  c                 N  K   ||dk    rd}|                                   d{V  d}||                     |          }dddd}||d         |d<   |||d	<   |                     |                     ||                     d{V }|                     |d
         |||          S )a  
        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>`
        Nr6   r  nextr   r  directrG  r0   r  r  r  r  r  $spotPrivateGetV1QueryDepositWithdrawr'  parse_transactionsr  rm  r  r  r	  r  r(  r  s           r  fetch_depositszhtx.fetch_depositsf  s       =ECKKE!!!!!!!!!}}T**H
 

 "*4.GJ#GFOBB4;;wX^C_C_````````6 &&x'75%PPPr  c                 N  K   ||dk    rd}|                                   d{V  d}||                     |          }dddd}||d         |d<   |||d	<   |                     |                     ||                     d{V }|                     |d
         |||          S )a  
        fetch all withdrawals made from an account
        :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>`
        Nr6   r   r  r   r  r0   r  r  r  r  r  s           r  fetch_withdrawalszhtx.fetch_withdrawals  s       =ECKKE!!!!!!!!!}}T**H
 

 "*4.GJ#GFOBB4;;wX^C_C_````````2 &&x'75%PPPr  c                    |                      |d          }|                     |                     |d                    }|                     |d          }|dk    rd}|                     |d          }|t          j        |          }|                     |d          }|                     |d          }|d	k    r|                    d
          dk     rd
|z   }|                     |d          }	|	dk    }
i d|d|                     |dd          d|d|d|                     |          d|                     |          d|                     |d          dd dd d|                     |d          dd dd d|d| 	                    |d          d|d| 
                    |                     |d                    d|                      |d           d |
||                     |          d d!d"S )#Nr  r  r  r   
withdrawalr!  r  ztx-hashr  0xr   zsub-typeFASTr  r0   r  txidr  r  r  r  	addressToaddressFromr  zaddress-tagtagTotagFromr7  r   r\  r  z
updated-at)r  r>  rate)commentinternalr!  )r  r  r   r,   
string_absr9  r  r  r  r   parse_transaction_statusr  )r  transactionr  r  rm  r  r  r  txHashr  r  s              r  parse_transactionzhtx.parse_transaction  s   f %%k<@@	&&t'7'7Z'P'PQQV44:D"";66(11G$$['::	!!+y99&++d"3"3a"7"7F]F"";
;;f$
K
$$$[$??
 F
 	

 Y//
 t..y99
 t''Y??
 
 4
 4##K??
 T
 t
 D
 d&&{H==
 
  d33D4D4D[RY4Z4Z[[!
" t((lCC#
$   ))'22 )
 
 
 	
r  c                 T    dddddddddddddddd}|                      |||          S )Nfailedpendingr  r  )unknown
confirming	confirmedsafeorphanr  r  	reexaminerejectpasszwallet-rejectzconfirm-errorrepealedzwallet-transferzpre-transferr  r  s      r  r  zhtx.parse_transaction_status*  sW      #"""%% (%%
 
( &&999r  c                 *  K   |                      ||          \  }}|                                  d{V  |                     |           |                     |          }||d                                         d}|||d<   d}|                     |          \  }}||                     ||          |d<   t          |                     |||                    }| 	                    | j
        di           }	|                     |	dd          r:|                     |d	          }
|
|                                  d{V }|                     | j        |          | _        | 	                    |d
         |i           }|                     |d	          }
|
t!          | j        dz             |                     ||
|          }|                     |d	          }|                     |          }t)          j        ||          }t          |          }t          |          |d	<   t          |                     |||                    }||d<   |                     |                     ||                     d{V }|                     ||          S )a  
        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>`
        Nr0   )r  r  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" parameterr7  )handle_withdraw_tag_and_paramsr  r  r  r}  r  r  floatcurrency_to_precisionr  r   rF  r   r  r  
currenciesr   r0   rN  rT  r,   
string_sub$spotPrivatePostV1DwWithdrawApiCreater'  r	  )r  rm  r7  r  r  r	  r  r(  r  withdrawOptionsr!  r  targetNetwork	feeStringr  amountSubtractedStringamountSubtractedr  s                     r  r   zhtx.withdrawA  s      99#vFFV!!!!!!!!!7###==&& ,,..
 
 ?"%GJ"AA&IIV"#66{DIIGGt11$LLMM//$,
BGG>>/<?? 	\""6511C{#'#8#8#:#:::::::
"&"2"24?J"O"O $0DkSU V V&&}e<<;+DG  7Y  -Y  Z  Z  Z224kJJIYYvu--F0088L%,%7i%P%P"$%;<<"9--GEN455d<LkZZ[[F"BB4;;wX^C_C_```````` %%h999r  c           
      r    |                      |d          }|                     d |          }||d d |d d d d d	S )Nr  )	r  r0   r  r  r  r7  fromAccount	toAccountr   )r   r  )r  r   r  r0   rm  s        r  parse_transferzhtx.parse_transferv  sX     h//&&tX66

 

 
	
r  r#  r$  c                 &  K   |                                   d{V  |                     |          }|d         t          |                     ||                    d}d}|                     dd|          \  }}|                     |          }	|                     |          }
|
dk    }|	dk    }|                     |
| j                  }|                     |	| j                  }|	dk    }|
dk    }|r"|r t          | j	        dz   |z   dz   |z             |	d	k    p|
d	k    }d}|rU|	d
z   |
z   }| 
                    |d|          }||d<   |                     |                     ||                     d{V }n|r3|r1|                     |                     ||                     d{V }nM|r3|r1|                     |                     ||                     d{V }n|r7|r5|
|d<   |                     |                     ||                     d{V }n|r7|r5|	|d<   |                     |                     ||                     d{V }n|dk    r_|	dk    s|dk    rd}	nd}
| 
                    |d          }|                     |d          }||                     |          }||d<   nd|d<   |rdn|	|d<   |rdn|
|d<   |                     |                     ||                     d{V }|                     ||          S )aA  
        transfer currency internally between wallets on the same account
        :see: https://huobiapi.github.io/docs/dm/v1/en/#transfer-margin-between-spot-account-and-future-account
        :see: https://huobiapi.github.io/docs/spot/v1/en/#transfer-fund-between-spot-account-and-future-contract-account
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-transfer-margin-between-spot-account-and-usdt-margined-contracts-account
        :see: https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-spot-trading-account-to-cross-margin-account-cross
        :see: https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-spot-trading-account-to-isolated-margin-account-isolated
        :see: https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-cross-margin-account-to-spot-trading-account-cross
        :see: 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>`
        Nr0   r  r7  r   r&  r=   z+ transfer() cannot make a transfer between z and r  z-to-r  r  r   rB   zlinear-swapzmargin-accountr	  r@   rG  rH  )r  r  r  r  r  convert_type_to_accountin_arrayr  r   r0   r    spotPrivatePostV1FuturesTransferr'   privatePostCrossMarginTransferIn!privatePostCrossMarginTransferOutprivatePostDwTransferInMarginprivatePostDwTransferOutMarginrN  r/  v2PrivatePostAccountTransferr%  )r  rm  r7  r#  r$  r	  r  r(  r  fromAccountIdtoAccountIdtoCross	fromCross
toIsolatedfromIsolatedfromSpottoSpotfromOrToFuturesAccountr  r  r  s                        r  r   zhtx.transfer  s     & !!!!!!!!!==&& D66tVDDEE
 
 99*dFSS44[AA229==(!W,	]];99
}}]DH== E)% 	z 	zTW'TTWbbelloxxyyy"/9"<![+QZBZ! 	] 6)K7D##FFD99D"GFO!BB4;;wX^C_C_````````HH 	]' 	]!BB4;;wX^C_C_````````HH 	]6 	]!CCDKKPWY_D`D`aaaaaaaaHH 	]* 	] +GH!??GU[@\@\]]]]]]]]HH 	]f 	] -GH!@@WV\A]A]^^^^^^^^HH(""!V++1M1M$1MM"/K))&(;;6844%!^^F33F06G,--06G,-(0CffmGFO&,=FF+GDM!>>t{{7TZ?[?[\\\\\\\\H ""8X666r  c                 B  K   |                                   d{V  |                     |           d{V }|                     |dg           }g }t          dt	          |                    D ]0}|                    |                     ||                              1|S )a  
        fetch the borrow interest rates of all currencies
        :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>`
        Nr  r   )r  spotPrivateGetV1MarginLoanInfor  r,  r-  rG  parse_isolated_borrow_rate)r  r	  r  r  ratesr1  s         r  fetch_isolated_borrow_rateszhtx.fetch_isolated_borrow_rates  s       !!!!!!!!!<<VDDDDDDDD< x44q#d))$$ 	C 	CALL88aAABBBBr  c           
         |                      |d          }|                     ||          }|                     |dg           }|                     |d          }|                     |d          }|                      |d          }|                      |d          }	||                     |          |                     |d          |                     |	          |                     |d          dd d |d	S )	Nr  r  r   r   r  zactual-ratei \&)	r  rg  baseRaterh  	quoteRaterD  r  r  r  )r   r  r  r  r   )
r  r  r  r"  r  r  baseData	quoteDatarj  rk  s
             r  r;  zhtx.parse_isolated_borrow_rate
  s    0 ##D(33!!(F33__T<<<
??:q11OOJ22	!!(J77""9j99++F33((=AA,,W55)))]CC

 

 
	
r  c                   K   |t          | j        dz             d}|                     |dd          \  }}|r#|                     d||||dddd		  	         d{V S |                                  d{V  |                     |          }d
|d         i}d}|d         r0|                     |                     ||                     d{V }nO|d         r0|                     |                     ||                     d{V }nt          | j        dz             | 
                    |d          }	| 
                    |	d          }
| 
                    |	dg           }g }t          dt          |                    D ]}||         }|
|d<   |                     |d
          }|                     |          }|                     |d          }|                    |||                     |d          ||                     |          d           |                     |d          }|                     ||d         ||          S )a  
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-historical-funding-rate
        :see: 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 argumentFro   r  
page_indexcurrent_pager   r   rS  r0   r   r   zA fetchFundingRateHistory() supports inverse and linear swaps onlyr  r   funding_timefunding_rate)r  r  fundingRater  r  r  r  )r   r0   rC  fetch_paginated_call_cursorr  r  3contractPublicGetSwapApiV1SwapHistoricalFundingRater'  9contractPublicGetLinearSwapApiV1SwapHistoricalFundingRater$   r  r,  r-  r   r  r  rG  r   r  r;  r<  )r  r  r  r  r	  r  r  r(  r  r  cursorr0  r<  r1  r  r"  symbolInnerr  sorteds                      r  fetch_funding_rate_historyzhtx.fetch_funding_rate_history5  s      >#DG.e$efff88AZ\fgg& 	X99:SU[]bdikqs  BP  RS  UW  X  X  X  X  X  X  X  X  X!!!!!!!!!V$$VD\
 ) 	n!UUVZVaVabikqVrVrssssssssHHH 	n![[\`\g\ghoqw\x\xyyyyyyyyHHtw)llmmm. x00~66vr22q#f++&& 	 	A1IE$*E.!''??H**844K))%@@ILL%#//~FF& LL33      e[11009I5RWXXXr  c                    |                      |d          }|                     |d          }|                     |d          }|                     |d          }|                     ||          }i d|d|dd dd d	d d
d dd dd d|                      |d          d|d|                     |          d|d|d|                     |          dd dd dd S )Nestimated_raterF  next_funding_timerS  r  r  	markPrice
indexPriceinterestRateestimatedSettlePricer  r  rH  rG  fundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetime)r   r  r   r  r  )r  r   r  rY  rW  rZ  r"  r  s           r  parse_funding_ratezhtx.parse_funding_rate}  so     **85EFF,,X~FF#00;NOO##Ho>>!!(F33
H
f
 
 $	

 D
 #D
 
 
 4++HnEE
  0
 t||,<==
 
 #$8
 "4<<0D#E#E
 "4
  '!
" &t#
 	
r  c                   K   |                                   d{V  |                     |          }d|d         i}d}|d         r0|                     |                     ||                     d{V }nO|d         r0|                     |                     ||                     d{V }nt          | j        dz             |                     |di           }|                     ||          S )a  
        fetch the current 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>`
        NrS  r0   r   r   z: fetchFundingRate() supports inverse and linear swaps onlyr  )	r  r  )contractPublicGetSwapApiV1SwapFundingRater'  /contractPublicGetLinearSwapApiV1SwapFundingRater$   r0   r  r_  )r  r  r	  r  r(  r  r0  s          r  fetch_funding_ratezhtx.fetch_funding_rate  s$      !!!!!!!!!V$$VD\
 ) 	g!KKDKKX_agLhLhiiiiiiiiHHH 	g!QQRVR]R]^egmRnRnooooooooHHtw)eefff  6266&&vv666r  c                   K   |                                   d{V  |                     |          }|                     | j        di           }|                     | j        dd          }|                     |d|          }|                     |d|          }i }|                     |d          }d}|dk    r0|                     |                     ||                     d{V }nM|dk    r0|                     |                     ||                     d{V }nt          | j
        dz             |                     |dg           }|                     |          }	|                     |	d	|          S )
af  
        fetch the funding rate for multiple markets
        :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 `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
        Nrp   r  r   r  r   z1 fetchFundingRates() not support self market typer  r  )r  r  r  r   r   rN  4contractPublicGetLinearSwapApiV1SwapBatchFundingRater'  .contractPublicGetSwapApiV1SwapBatchFundingRater$   r0   parse_funding_ratesfilter_by_array)
r  r%  r	  r   r  r  r(  r  r  r0  s
             r  fetch_funding_rateszhtx.fetch_funding_rates  s      !!!!!!!!!%%g..//$,0CRHH))$,8H)TT""7I~FF""69g>>
 69--h!VVW[WbWbcjlrWsWsttttttttHH	!!!PPQUQ\Q\]dflQmQmnnnnnnnnHHtw)\\]]]& x44))$//##FHg>>>r  c                   K   |                                   d{V  d}|                     d|          \  }}|dn|}i }||                     |          |d<   |||d<   d}d}	|dk    rR| |                     |          }|d         |d<   |                     |                     ||                     d{V }	nQ| |                     |          }
|
d         |d	<   |                     |                     ||                     d{V }	|                     |	d
          }| 	                    ||          }| 
                    ||||          S )aO  
        fetch the interest owed by the user for borrowing currency for margin trading
        :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>`
        Nr\   r&  z
start-dater  r'  r0   r  r  r  )r  r-  yyyymmddr  privateGetMarginLoanOrdersr'  r  privateGetCrossMarginLoanOrdersr  parse_borrow_interestsfilter_by_currency_since_limit)r  rm  r  r  r  r	  r2  r(  r  r  r  r  interests                r  fetch_borrow_interestzhtx.fetch_borrow_interest  s      !!!!!!!!!
!??@UW]^^
F!+!3WW*
$(MM%$8$8GL!#GFO##!V,,$*4L!!<<T[[RX=Y=YZZZZZZZZHH==..&.tn
#!AA$++gW]B^B^________H. x00..tV<<228T5%PPPr  c                    |                      |d          }|dnd}|                     |          }|                      |d          }|                     |d          }|dk    r|nd|||                     |                      |d                    |                     |d          |                     |d          |                     |d          ||                     |          |d	
S )
Nr  r&  r'  z
accrued-atr  zinterest-amountzinterest-ratezloan-amount)
rn  r  r2  r  rp  rU  amountBorrowedr  r  r  )r   r  r  r  r   r  )r  r  r  r"  r2  r  r  s          r  parse_borrow_interestzhtx.parse_borrow_interest2  s    T ##D(33!)!1WW

!!(++!!&(33%%dL99	",
":":vv$//0@0@z0R0RSS((/@AA ,,T?CC"..t]CC"Y//
 
 	
r  r   r  c                 "   d}|                      ||                     |                    }t          |t                    r|dk    s|dk    r|| j        z  }n|dk    s|dk    r|dz  }|d|                     ||          z   z  }|dk    s|dk    rC|                                  |                     |                                 d          }	dd	| j	        |	d
}
|dk    r| 
                    |
|          }
|                     |
          }|                     |          }d                    || j        ||g          }|                     |                     |          |                     | j                  t$          j        d          }|d|                     d|i          z   z  }|d|z   z  }|dk    r|                     |          }ddi}n"ddi}n|r|d|                     |          z   z  }|                     | j        d         |         d| j        i          |z   }nd|                     |d          }|                     |d          }|                     |d          }|                     |d          }d }|                     | j        d         |          }t          |t                    sC|                     ||          }t          |t                    s||                     ||          }|}||                     ||          z  }|dk    r|r|d|                     |          z   z  }n%|dk    r|                                  |dk    r|                     | j        di           }|                     |dd          }|                    d          dk    r3|                    d           r|                     |d!          }|||d!<   nG|                    d"          r2|                     |d#          }|||                                 z   |d#<   |                     |                                 d          }	dd	| j	        |	d
}
|dk    r| 
                    |
|          }
|                     |
          }
|                     |
          }d                    ||||g          }|                     |                     |          |                     | j                  t$          j        d          }|d|                     d|i          z   z  }|d|z   z  }|dk    r/|                     |          }t9          |          dk    rd$}ddi}nddi}|                     | j        d         |         d|i          |z   }||||d%S )&NrX  r   r   r   r   v2T
HmacSHA256r  )SignatureMethodSignatureVersionAccessKeyId	TimestampPOST
base64&	Signature?zContent-Typezapplication/jsonz!application/x-www-form-urlencodedr   r<   r   r   rb  rc  r   r  r0   r  cancelr  ro  zorders/placer(  z{})r   r  bodyheaders)rN  extract_paramsr  r  r:   implode_paramscheck_required_credentialsymdhmsmillisecondsapiKeyr'  keysort	urlencoder  r<   hmacencodesecrethashlibsha256r|  r   r   r  r   r9  endswithrR  r-  )r  pathr   r  r	  r  r  r   queryr  r(  sortedRequestauthpayload	signaturer  accesslevelOneNestedPathlevelTwoNestedPathr<   r   r   r0   channelCoder  s                            r  signzhtx.signn  s   		&$"5"5d";";<<c3 f	xSI%5%5t|###););t3,,T6::::Ci3+#5#5//111 KK(9(9(;(;SAA	'3(+#';!*	  V##"kk'599G $W 5 5~~m44))VT]C$FGG IIdkk'&:&:DKK<T<TV]Vdfnoo	dnnk9-EFFFFsTz!V##99U++D&(:GG
 '(KGG  73!6!666C%%di&6s&;DM>  CC ##C++D%%c1--F!%!1!1#q!9!9!%!1!1#q!9!9H	+(>EEIi-- O OOI7IJJ	"9c22 O9K9W $	;M N NI H4&&tV444C!! 73!6!666C9$$//111V##"oodlHbIIG))'4FFByy**b00T]]75K5K0&*&6&6v~&N&N&.57F>2~66 I(,(8(8AR(S(S(08:TYY[[8HF#45 KK(9(9(;(;SAA	'3(+#';!*	  V##"kk'599G,,w//~~g..))VXsD$ABB IIdkk'&:&:DKK<T<TV]Vdfnoo	dnnk9-EFFFFsTz!V##99U++D4yyA~~#&(:GG
 '(KG %%di&6t&<H?  C fdwOOOr  c
                 @   |d S d|v r|                      |d          }
|
dk    r|                     |dd          }| j        dz   |z   }|                     | j        d         ||           |                     | j        d         ||           |                     |dd	          }|                     | j        d         ||           t          |          d
|v rE| j        dz   |z   }|                      |d
          }|                     | j        d         ||           d S )Nr   errorr$  r#  rL  r   r   zerr-msgerr_msgrm  )r   r  r0   throw_broadly_matched_exceptionr   throw_exactly_matched_exceptionr   )r  httpCodereasonr   r  r  r  r  requestHeadersrequestBodyr   rm  feedbackmessages                 r  handle_errorszhtx.handle_errors  s;   4x %%h99F  ))(J
KK7S=4/44T_W5MtU]^^^44T_W5MtU]^^^,,Xy)LL44T_W5MwX`aaa#H---Xw}t+H##Hf55D001I4QYZZZtr  c                   K   |                                   d{V  |                     |          }|                     d||          \  }}ddi}|||d<   d}	|dk    r|d         |d<   |d	         rnd}
|                     d|          \  }
}|
d
n|
}
|
dk    r|d         |d<   n|d         |d<   |                     |                     ||                     d{V }	nj|                     |                     ||                     d{V }	n:|d         |d<   |                     |                     ||                     d{V }	|                     |	dg           }| 	                    ||||          S )a  
        fetch the history of funding payments paid and received on self account
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-account-financial-records-via-multiple-fields-new   # linear swaps
        :see: https://huobiapi.github.io/docs/dm/v1/en/#query-financial-records-via-multiple-fields-new                          # coin-m futures
        :see: 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>`
        Nrm   r  z30,31
start_daterB   r0   r   r   r&  r'  mar_acctrk  r  r  )
r  r  r  r-  :contractPrivatePostLinearSwapApiV3SwapFinancialRecordExactr'  4contractPrivatePostSwapApiV3SwapFinancialRecordExact4contractPrivatePostApiV3ContractFinancialRecordExactr{  parse_incomes)r  r  r  r  r	  r  r
  r  r(  r  r2  r  s               r  fetch_funding_historyzhtx.fetch_funding_history  s      !!!!!!!!!V$$ >>?TV\^dee
EG
 $)GL!"(,GJh 4x. "
%)%G%GH]_e%f%f"
F)3);WW*
++*0,GJ''*0*;GJ'!%!`!`aealalmtv{a|a|!}!}}}}}}}, "&!Z!Z[_[f[fgnpu[v[v!w!wwwwwww &tGH!VVW[WbWbcjlqWrWrssssssssH~~h33!!$u===r  rp  c                   K   |t          | j        dz             |                                  d{V  |                     |          }|                     d||          \  }}d|i}|dk    r|d         r|d         |d<   n|d	         |d
<   d}|d         rd}	|                     d|          \  }	}|	dn|	}	|	dk    r0|                     |                     ||                     d{V }n|	dk    r0|                     |                     ||                     d{V }nt          | j        dz             |dk    r0| 
                    |                     ||                     d{V }nM|dk    r0|                     |                     ||                     d{V }nt          | j        dz             |S )a$  
        set the level of leverage for a market
        :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   rn  rC   r   rl  r  r0   rS  r   r&  r'  + setLeverage() not support self market typerB   )r   r0   r  r  r  r-  5contractPrivatePostLinearSwapApiV1SwapSwitchLeverRater'  :contractPrivatePostLinearSwapApiV1SwapCrossSwitchLeverRater$   /contractPrivatePostApiV1ContractSwitchLeverRate/contractPrivatePostSwapApiV1SwapSwitchLeverRate)
r  rp  r  r	  r  r
  r  r(  r  r2  s
             r  set_leveragezhtx.set_leverageC  sB      >#DG.Y$YZZZ!!!!!!!!!V$$ >>}fV\]]
E(
 !!fY&7! &z 2GH'-d|GO$( 	\J!%!C!CMSY!Z!ZJ%/%7jJZ''!%![![\`\g\ghoqv\w\w!x!xxxxxxxw&&!%!`!`aealalmtv{a|a|!}!}}}}}}}"47-Z#Z[[[ X%%!%!U!UVZVaVabikpVqVq!r!rrrrrrrv%%!%!U!UVZVaVabikpVqVq!r!rrrrrrr"47-Z#Z[[[" r  c                 p   |                      |d          }|                     ||          }|                     |d          }|                     |d          }|                      |d          }|                     |dd          }|                     |          }	|||	||                     |          ||dS )NrS  r7  r  r0   r  asset)r  r  rm  r  r  r0   r7  )r   r  r   r  r  r  r  )
r  incomer  r"  r  r7  r  r0   r  rm  s
             r  parse_incomezhtx.parse_income  s     ##FO<<!!(F33!!&(33%%fd33	fd++'''BB
&&z22"Y//
 
 	
r  c                 j   |                      |                     |d                    }|d         }|                     |d          }|                     |d          }|                     |          }|                     |d          }|                     |d          }|                     |d          }	|	dk    rd	nd
}
|                     |d          }|                     |d          }|                     |d          }t          j        |                     |d          d          }|                     |d          }t          j        ||          }d }|d         rt          j        ||          }nt          j        ||          }d}t          j        ||          }|                     |d          }|                     |d          }|                     |d          }t          j        ||          }t          j        ||          }t          j        ||          }|                     i d|dd d|d| 	                    |          d|d|d| 	                    |          d|
d|d| 	                    |          d| 	                    |          d|d | 	                    |          d!d d"d d#|d$| 	                    |          | 	                    |          | 	                    |          | 	                    |          | 	                    |          d d d d d d d%
          S )&NrS  r  r+  rq  	cost_openposition_marginr  r?  longshortprofit_unrealmargin_modern  profit_raterj  
last_pricer   r&  r  liquidation_priceadjust_factorr  r0   	contracts
entryPrice
collateralr  unrealizedProfitrp  r   r2  notionalrS  	lastPriceliquidationPriceinitialMargin)
initialMarginPercentagemaintenanceMarginmaintenanceMarginPercentagemarginRatior  r  hedgedlastUpdateTimestampr^  r`  )
r  r   r  rT  r   r,   rU  rq  safe_positionr  )r  positionr  r  r  rq  contractSizeStringr  r  rawSider  r  r2  rp  r   r  	faceValuer  intialMarginPercentager  r  adjustmentFactorr  r  r  s                            r  parse_positionzhtx.parse_position  s   @ !!$"2"28_"M"MNN!$$Xx88	v~>>!22<@@%%h<<
((3DEE""8[99!U**vv++HoFF%%h>>
##Hl;;'(8(8=(Q(QSXYY
$$X|<<	&y2DEE	( 	!))Y??HH))Y??H J!(!3M8!L!L%%h0@AA
++H6IJJ++HoFF&-&89I8&T&T##./JHUU():JGG!! #
H#
$#
 f#
 **955	#

 L#
 *#
 $++J77#
 D#
  0#
 ))(33#
 $++J77#
 *#
 ))(33#
 #
 #
   0!#
" T..}==##
$ (,'8'89O'P'P!%!2!23D!E!E+/+<+<=X+Y+Y,,[99#'!#7#
 #
 #
   	r  c           
      ~  K   |                                   d{V  |                     |          }d}|+|                     |d          }|                     |          }d}|                     d|d          \  }}d}|                     d||d          \  }}d}|                     d||          \  }}|dk    rd}d}|dk    r[|dk    r|                     |           d{V }n|dk    r|                     |           d{V }nrt          | j
        d	z             |dk    r|                     |           d{V }n9|d
k    r|                     |           d{V }nt          | j
        d	z             |                     |dg           }	|                     |d          }
g }t          dt!          |	                    D ]^}|	|         }|                     |          }|                    |                     ||
|                     |
          d                     _|                     |d|d          S )a*  
        fetch all open positions
        :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 `position structure <https://docs.ccxt.com/#/?id=position-structure>`
        Nr   r   r&  r   r@   rC   r'  z. fetchPositions() not support self market typerB   r  r  r  r  r  F)r  r  r   r  r-  r  r  2contractPrivatePostLinearSwapApiV1SwapPositionInfo7contractPrivatePostLinearSwapApiV1SwapCrossPositionInfor$   r0   ,contractPrivatePostApiV1ContractPositionInfo,contractPrivatePostSwapApiV1SwapPositionInfor  r  r,  r-  r  rG  r'  r  filter_by_array_positions)r  r%  r	  r  r)  r2  r  r
  r  r  r  r0  r1  r  r  s                  r  fetch_positionszhtx.fetch_positions  s      !!!!!!!!!%%g..$$Wa00E[[''F
!??@PRXZabb
F99:JFTZ\dee
!??@PRXZ`aa
F!JhZ''!%!X!XY_!`!```````w&&!%!]!]^d!e!eeeeeee"47-]#]^^^: X%%!%!R!RSY!Z!ZZZZZZZv%%!%!R!RSY!Z!ZZZZZZZ"47-]#]^^^f x44%%h55	q#d))$$ 	 	AAwH((22FMM$++f& LL33/ /       --fhOOOr  c                   K   |                                   d{V  |                     |          }d}|                     d|          \  }}|dn|}|                     d||          \  }}i }|d         r|d         r|d         |d<   n|dk    rd|d	<   |d
         |d<   d}|d         r|dk    r0|                     |                     ||                     d{V }n|dk    r0|                     |                     ||                     d{V }nt          | j        dz             |dk    r0| 	                    |                     ||                     d{V }nM|dk    r0| 
                    |                     ||                     d{V }nt          | j        dz             |                     |d          }	d}
|dk    r|	}
n|                     |	d          }
|                     |
dg          }|                     |
d          }d}|d         rG|d         r?t          dt          |                    D ] }||         }|d         |d
         k    r|} n!n|                     |d          }|                     |d          }|                     |                     ||                    }||d<   |                     |          |d<   |S )aa  
        fetch data on a single open contract trade position
        :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&  rC   r   rl  r  r	  r  r0   rS  r   r'  z- fetchPosition() not support self market typerB   r  r  r   	positionsr  r  r  )r  r  r-  r  9contractPrivatePostLinearSwapApiV1SwapAccountPositionInfor'  >contractPrivatePostLinearSwapApiV1SwapCrossAccountPositionInfor$   r0   3contractPrivatePostApiV1ContractAccountPositionInfo3contractPrivatePostSwapApiV1SwapAccountPositionInfor  rN  r,  r-  r  r  r  )r  r  r	  r  r2  r
  r  r(  r  r  rn  omittedr  r  r1  r  r  r  s                     r  fetch_positionzhtx.fetch_positiony  s      !!!!!!!!!V$$
!??QWXX
F!+!3WW*
 >>PVX^__
E( 	4y 1 	4 &z 2GHW$$,2()'-d|GO$( B	\Z''!%!_!_`d`k`klsuz`{`{!|!|||||||w&&!%!d!deiepepqxz  fA  fA  "B  "B  B  B  B  B  B  B"47-\#\]]]n X%%!%!Y!YZ^ZeZefmotZuZu!v!vvvvvvvv%%!%!Y!YZ^ZeZefmotZuZu!v!vvvvvvv"47-Z#Z[[[L x00  GGoodA..G))Gk]33OOG[99	( 	5y 1 	51c)nn--  !!)VD\99$HE : y!44H%%h55	$$T[[7%C%CDD'{!\\)44zr  c                 R    ddddddddddddddd	}|                      |||          S )
Nr  r!  r   creditr  r  exchangerebate)r  etfztransact-feezfee-deductionr   r  liquidationrp  r  r   zwithdraw-feer  zother-typesr  r  )r  r  r   s      r  parse_ledger_entry_typezhtx.parse_ledger_entry_typem  sR    !"""  $!"%
 
  tT222r  c                    |                      |d          }|                      |d          }|                     ||          }|                     |d          }|                      |d          }|                     |          }|                      |d          }	|                     |d          }
|                     |
          }|                      |d          }||	|||||||
|d d d d |dS )	N
transactIdr  transactAmttransferTyper  transactTimerr  )r0   r  rn  referenceIdreferenceAccountr  r  r7  r  r  beforeafterr   r!  r  )r   r  r   r  r  r  )r  itemr  r0   r  rm  r7  r  r  r  r  r  rn  s                r  parse_ledger_entryzhtx.parse_ledger_entry  s    dL11%%dJ77
&&z8<<!!$66''n==++L99$$T;77	%%dN;;	<<	**""455" '" 
 
 	
r  c                 N  K   |                                   d{V  d}|                     |dd          \  }}|r |                     d||||d           d{V S |                     ddd|           d{V }d|i}d}| |                     |          }|d         |d	<   |||d
<   |||d<   |                     d||          \  }}|                     |                     ||                     d{V }	|                     |	dg           }
| 	                    |
|||          S )a  
        :see: https://huobiapi.github.io/docs/spot/v1/en/#get-account-history
        fetch the history of changes, actions done by the user or operations that altered balance of the user
        :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 entrys 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 [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
        NFrv   r  i  r@   rr  r0   r  	startTimer  endTimer  )
r  rC  r*  rz  r  r+  spotPrivateGetV2AccountLedgerr'  r  parse_ledger)r  rm  r  r  r	  r  rr  r(  r  r  r  s              r  fetch_ledgerzhtx.fetch_ledger  s      !!!!!!!!!88PZ[[& 	k::=$PUW\^dfijjjjjjjjj77dFSSSSSSSS		
 }}T**H"*4.GJ#(GK $GG229gvNN;;DKKQW<X<XYYYYYYYYB x44  x>>>r  c                    K   |                                   d{V  |                     |           d{V }|                     |d          }|                     ||d          S )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
        Nr  rS  )r  0contractPublicGetLinearSwapApiV1SwapAdjustfactorr{  parse_leverage_tiers)r  r%  r	  r  r  s        r  fetch_leverage_tierszhtx.fetch_leverage_tiers  s~       !!!!!!!!!NNvVVVVVVVV< ~~h//((wHHHr  c                   K   |                                   d{V  i }|?|                     |          }|d         st          | j        dz             |d         |d<   |                     |                     ||                     d{V }|                     |d          }|                     ||gd          }|                     ||          S )a}  
        retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
        Nr   zA fetchMarketLeverageTiers() symbol supports contract markets onlyr0   rS  r  )r  r  r   r0   r	  r'  r  r
  )r  r  r	  r(  r  r  r  tierss           r  fetch_market_leverage_tierszhtx.fetch_market_leverage_tiers  s       !!!!!!!!![[((F*% p +n!nooo'-d|GO$NNt{{[bdjOkOkllllllll< x00))$/JJuf---r  c                    i }t          dt          |                    D ]}||         }|                     |dg           }g }|                     |d          }	|                     ||          }
|                     |
          }|                     ||          r?t          dt          |                    D ]}||         }|                     |d          }|                     |dg           }t          dt          |                    D ]}||         }|                     |d          }|                    |                     |d          |                     |	          | 	                    |d          | 	                    |d	          | 
                    t          j        ||                    | 
                    |          |d
           Ɛ|||<   |S )Nr   rD  trade_partitionrn  laddersr  laddermin_sizemax_size)tierr  minNotionalmaxNotionalmaintenanceMarginRatemaxLeverager  )r,  r-  r  r   r  r)  rG  r  r  r   r  r,   rq  )r  r  r%  marketIdKeyr0  r1  r   rD  r  r  r0   r  r=  objrp  r  kbracketadjustFactors                      r  r
  zhtx.parse_leverage_tiersL  s   q#h--(( 	' 	'AA;D??444DE''.?@@H!!$44B%%b))F}}VW-- 'q#d)),,  Aq'C#//\BBH"ooc9bAAG"1c'll33  ")!*'+'7'7'Q'Q$($5$5gx$H$H(,(?(?(I(I+/+;+;GZ+P+P+/+;+;GZ+P+P595F5FwGYZfhpGqGq5r5r+/+<+<X+F+F$+& &     "'vr  r   c                   K   |dk    r)|dk    r#|dk    r|dk    rt          | j        dz             |                                  d{V  ddd	d
d}|                     |          }|                     |ddd          }||         |d}	|||	d<   d}
|d         rZ|                     |d         d          |	d<   |d         |	d<   |                     |                     |	|                     d{V }
n|d         rKd|	d<   |d         |	d<   |d         |	d<   |                     |                     |	|                     d{V }
n:|d         |	d<   | 	                    |                     |	|                     d{V }
| 
                    |
d          }|                     |d          }|                     ||||          S )u  
        Retrieves the open interest history of a currency
        :see: https://huobiapi.github.io/docs/dm/v1/en/#query-information-on-open-interest
        :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-information-on-open-interest
        :see: 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
amountTyperb  )rD  r"  r  rC   r  r  rj  r  r   rB   r0   rS  r  r  )r   r0   r  r  r  r   -contractPublicGetApiV1ContractHisOpenInterestr'  3contractPublicGetLinearSwapApiV1SwapHisOpenInterest-contractPublicGetSwapApiV1SwapHisOpenInterestr  r{  parse_open_interests)r  r  r`  r  r  r	  r   r  r#  r(  r  r  r  s                r  fetch_open_interest_historyzhtx.fetch_open_interest_historyi  sI      d!2!2yE7I7Ii[_N_N_TW'ssttt!!!!!!!!!	
 

 V$$((aPP
 +%
 
 #GFO( 	n'+'7'7v'X'XGO$ &x 0GH!OOPTP[P[\cekPlPlmmmmmmmmHHH 		n'-GO$'-d|GO$'-d|GO$!UUVZVaVabikqVrVrssssssssHH'-d|GO$!OOPTP[P[\cekPlPlmmmmmmmmHz x00~~dF++((vueDDDr  c                 d  K   |                                   d{V  |                     |          }|d         st          | j        dz             |d         rt	          | j        dz             d|d         i}d}|d         rZ|                     |d	         d
          |d
<   |d         |d<   |                     |                     ||                     d{V }nl|d         r5d|d
<   |                     |                     ||                     d{V }n/| 	                    |                     ||                     d{V }| 
                    |dg           }|                     |d         |          }|                     |d          }||d<   |                     |          |d<   |S )aM  
        Retrieves the open interest of a currency
        :see: https://huobiapi.github.io/docs/dm/v1/en/#get-contract-open-interest-information
        :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-swap-open-interest-information
        :see: 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 onlyrD   z> fetchOpenInterest() does not currently support option marketsrS  r0   rC   r  r  rj  r  r   rB   r  r   r  r  r  )r  r  r   r0   r$   r   *contractPublicGetApiV1ContractOpenInterestr'  0contractPublicGetLinearSwapApiV1SwapOpenInterest*contractPublicGetSwapApiV1SwapOpenInterestr  parse_open_interestr  r  )	r  r  r	  r  r(  r  r  openInterestr  s	            r  fetch_open_interestzhtx.fetch_open_interest  s      !!!!!!!!!V$$j! 	^TW'\\]]]( 	ktw)iijjjVD\
 ( 	k'+'7'7v'X'XGO$ &x 0GH!LLT[[Y`bhMiMijjjjjjjjHHH 	k'-GO$!RRSWS^S^_fhnSoSoppppppppHH "LLT[[Y`bhMiMijjjjjjjjH| x44//Q@@%%h55	$-[!#'<<	#:#:Z r  c                    |                      |d          }|                     |d          }|                     |d          }|                     |                     |d          ||||||                     |          |d|          S )Nr  r+  valuer  )r  r  r  openInterestAmountopenInterestValuer  r  r  )r  r   safe_open_interestr   r  )r  rp  r  r  r7  r1  s         r  r-  zhtx.parse_open_interest=  s    j %%h55	!!(H55  733&&&&vx88  "(!&"Y//	(
 	(
 	 	 		r  c                   K   |                                   d{V  |                     |          }|                     |          }|d         |                     ||          |d         d}|                     |                     ||                     d{V }|                     ||          }	|                     |	||d          S )ac  
        create a loan to borrow margin
        :see: https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-isolated
        :see: 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>`
        Nr0   )r  r7  r  r7  r  )r  r  r  r  privatePostMarginOrdersr'  parse_margin_loan)
r  r  rm  r7  r	  r  r  r(  r  r  s
             r  borrow_isolated_marginzhtx.borrow_isolated_margin  s       !!!!!!!!!==&&V$$ 00v>>Tl
 

 55dkk'66R6RSSSSSSSS ,,Xx@@{{;)
 )
   	r  c                 \  K   |                                   d{V  |                     |          }|d         |                     ||          d}|                     |                     ||                     d{V }|                     ||          }|                     |d|i          S )a  
        create a loan to borrow margin
        :see: https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-isolated
        :see: 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>`
        Nr0   r'  r7  )r  r  r  privatePostCrossMarginOrdersr'  r8  )r  rm  r7  r	  r  r(  r  r  s           r  borrow_cross_marginzhtx.borrow_cross_margin  s       !!!!!!!!!==&& 00v>>
 
 ::4;;wPV;W;WXXXXXXXX ,,Xx@@{{;f)
   	r  c                   K   |                                   d{V  |                     |          }|                     dd||           d{V }|d         |                     ||          |d}|                     |                     ||                     d{V }|                     |dg           }	|                     |	d          }
|                     |
|          }|                     |||d          S )	a  
        repay borrowed margin and interest
        :see: 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 str symbol: unified market symbol
        :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'  r0   r  r7  rr  Datar   r6  r  r  rz  r  v2PrivatePostAccountRepaymentr'  r  r8  )r  r  rm  r7  r	  r  rr  r(  r  r  loanr  s               r  repay_isolated_marginzhtx.repay_isolated_margin  s/      !!!!!!!!!==&&77
FTZ[[[[[[[[	 00v>>"
 

 ;;DKKQW<X<XYYYYYYYY x44tQ'',,T8<<{{;)
 )
   	r  c                   K   |                                   d{V  |                     |          }|                     ddd|           d{V }|d         |                     ||          |d}|                     |                     ||                     d{V }|                     |dg           }|                     |d          }	|                     |	|          }
|                     |
d|i          S )	a  
        repay borrowed margin and interest
        :see: 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>`
        Nr@   r&  r0   r>  r?  r   r7  r@  )r  rm  r7  r	  r  rr  r(  r  r  rB  r  s              r  repay_cross_marginzhtx.repay_cross_margin  s(      !!!!!!!!!==&&77vVVVVVVVV	 00v>>"
 

 ;;DKKQW<X<XYYYYYYYY x44tQ'',,T8<<{{;f)
   	r  c                     |                      |d          }|                     |dd          |                     d |          d d ||                     |          |dS )N	repayTimerepayIdr  )r0   r  r7  r  r  r  r  )r  r  r  r  )r  r  r  r  s       r  r8  zhtx.parse_margin_loan	  sk    , %%dK88	$$T9f==//h??"Y//
 
 	
r  c                   K   |t          | j        dz             |                     |dd          }|                     |ddg          }|                     |          }i }|d         r|d         |d<   n|d         |d	<   |||d
<   |||d<   |||d<   d}|d         rh|d         r0|                     |                     ||                     d{V }n_|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }| 	                    |d          }	| 	                    |	d          }
| 
                    |
|          }|                     |d          S )u"  
        Fetches historical settlement records
        :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 argumentrF  tillrC   rj  r  r0   rS  start_atr%  end_atrB   r   r  settlement_recordr  )r   r0   r  rN  r  5contractPublicGetLinearSwapApiV1SwapSettlementRecordsr'  /contractPublicGetSwapApiV1SwapSettlementRecords/contractPublicGetApiV1ContractSettlementRecordsr  parse_settlementsr;  )r  r  r  r  r	  rF  r  r(  r  r  settlementRecordsettlementss               r  fetch_settlement_historyzhtx.fetch_settlement_history*  s      >#DG.d$deee##FGV<<6GV#455V$$( 	4 &x 0GH'-d|GO$"'GJ#(GK  %GH&> 	ph t!%![![\`\g\ghoqw\x\x!y!yyyyyyy!%!U!UVZVaVabikqVrVr!s!sssssss!QQRVR]R]^egmRnRnooooooooHj x00??41DEE,,-=vFF||K555r  codesc                    K   |                                   d{V  |                     |           d{V }|                     |d          }|                     ||d          S )a  
        fetch deposit and withdraw fees
        :see: 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>`
        Nr  r  )r  r  r{  parse_deposit_withdraw_fees)r  rU  r	  r  r  s        r  fetch_deposit_withdraw_feeszhtx.fetch_deposit_withdraw_fees  s       !!!!!!!!!@@HHHHHHHHJ ~~h////eZHHHr  c                     |                      |dg           }|                     |          }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |          }	d }
d }|dk    r|                     |d          }
|
dd}n|                     |d	          }
|
d
d}|d d dd|d         |	<   |                     ||          }|S )Nr~  r   r  withdrawFeeTypefixedr  F)r!  r   transactFeeRateWithdrawT)r   r  r
  )r  deposit_withdraw_feer,  r-  r   r  r   $assign_default_deposit_withdraw_fees)r  r!  r  r~  r0  r=  r  r  rZ  r  withdrawFeewithdrawResults               r  parse_deposit_withdraw_feezhtx.parse_deposit_withdraw_fee  sG   @ h33**3//q#f++&& 	Q 	QAJ((W==I"..z;LMMO11)<<KK!N'))"..z;PQQ&"'" "
 #..z;TUU&"&" "
 +"& / /F:{+ >>vxPPFFr  c                    g }t          dt          |                    D ]}||         }|                     |d          }||                     |d          }||                     |          d}t          dt          |                    D ]I}	||	         }
|                     |
|          }|                    |                     ||                     J|                    |                     ||         |                     |S )Nr   rD  settlement_timer  )r,  r-  r  r  r  parse_settlementrG  r'  )r  rS  r  r0  r1  
settlementrD  r  timestampDetailsr=  r   parsedSettlements               r  rQ  zhtx.parse_settlements  s!   J q#k**++ 	M 	MA$QJ??:v66D --j:KLL	!* $Y 7 7$ $  q#d)),, S SA7D'+'<'<T6'J'J$MM$++.>@P"Q"QRRRRS
 d33KNFKKLLLLr  c                     |                      |d          }|                     |d          }||                     ||          |                     |d          ||                     |          dS )Nrc  rS  settlement_price)r  r  rn  r  r  )r  r   r  r   r  )r  re  r  r  r"  s        r  rd  zhtx.parse_settlement.   sz    0 %%j2CDD	##J@@&&x88%%j2DEE"Y//
 
 	
r  c                    K   |                                   d{V  |                     |          }|                     |dd          }d|i}|||d<   |                     d||          \  }}d}|d         rs|d         |d<   |d	         r0|                     |                     ||                     d{V }n|                     |                     ||                     d{V }nf|d
         r;|d         |d<   |                     |                     ||                     d{V }n#t          | j	        dz   |d         z   dz             | 
                    |dg           }	|                     |	|||          S )aH  
        retrieves the public liquidations of a trading pair
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-liquidation-orders-new
        :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-liquidation-orders-new
        :see: 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>`
        Nr"  r   r#  r$  rB   r0   r   r   rC   r  z& fetchLiquidations() does not support r  r  r  )r  r  r  r+  5contractPublicGetLinearSwapApiV3SwapLiquidationOrdersr'  /contractPublicGetSwapApiV3SwapLiquidationOrders/contractPublicGetApiV3ContractLiquidationOrdersr$   r0   r{  parse_liquidations)
r  r  r  r  r	  r  	tradeTyper(  r  r  s
             r  fetch_liquidationszhtx.fetch_liquidationsP   s      !!!!!!!!!V$$%%flA>>	)
 $)GL!22:wOO&> 
	p"(,GJh t!%![![\`\g\ghoqw\x\x!y!yyyyyyy!%!U!UVZVaVabikqVrVr!s!sssssssH 	p &tGH!QQRVR]R]^egmRnRnooooooooHHtw)QQTZ[aTbbennooo0 ~~h33&&tVUEBBBr  c                    |                      |d          }|                     |d          }|                     ||                     ||          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          ||                     |          d	          S )	NrS  r  r+  rq  rn  r7  r  )	r  r  r  rq  rn  	baseValue
quoteValuer  r  )r   r  safe_liquidationr  r   r  )r  r  r  r"  r  s        r  parse_liquidationzhtx.parse_liquidation   s    " ##KAA%%k<@@	$$&&x88))+x@@ ,,V^DD%%k7;;))+x@@**;8HII"Y//
&
 
&
 
 
 
	r  r  c                   K   |                                   d{V  |rdnd}d}||                     |          }d}|                     d|d          \  }}d|i}d}||d         rt          | j        dz             |d	k    rT|t          | j        d
z             |d         |d<   |                     |                     ||                     d{V }n4d|d<   |                     |                     ||                     d{V }|S )a  
        set hedged to True or False
        :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-position-mode
        :see: 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 moder0   r  r	  )	r  r  r-  r   r0   r   8contractPrivatePostLinearSwapApiV1SwapSwitchPositionModer'  =contractPrivatePostLinearSwapApiV1SwapCrossSwitchPositionMode)	r  r  r  r	  posModer  r2  r(  r  s	            r  set_position_modezhtx.set_position_mode   sn      !!!!!!!!!!':++][[((F
!??@QSY[bcc
FW
 VI%6TW']]^^^##~'2x(xyyy(.tG$%!ZZ[_[f[fgnpv[w[wxxxxxxxxHH )/G$%!__`d`k`klsu{`|`|}}}}}}}}H r  )N)NN)__name__
__module____qualname__r  r  r  r
   r   r#  r  r*  r   r2  r.  r   r5  rA  r   rO  rH  r  r   r  r  r   r  r  r  r	   r   r  r   r  r  r  r3  r>  rD  rB  rg  r   rk  rp  rz  r   r  r  r  r   r  r  r  r  r  r  r  r  r   r  r  r  r!  r  r  rA  r   r   r   rE  rZ  rz  r@  r   r  r  r  r  r   r  r  r  r  r   r  r  r	  r  r   r%  r   r   r=  r;  rO  r_  rc  ri  rq  rt  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r(  r/  r-  r9  r<  rC  rE  r8  rT  rX  ra  rQ  rd  rp  ru  boolr}  __classcell__)r  s   @r  r.   r.   !   s       | | | | ||% )+ O
 O
 O
 O
b ') ; ; ; ;4
 
V 
?R 
 
 
 
( ;= 5 5c 5AT 5 5 5 5@ =A  '     @B P P3 P P P P. :>b 
 
3 
 
 
 
4x x x *,  V    4 NP L L L L\  3            D] ]6 ]V ] ] ] ]~ 68 H H HF H H H HT 6:" fH fH7 fH fH fH fH fHP :>b a5 a5w a5 a5 a5 a5F
 
f 
 
 
 
  @DB Nr NrS Nr NrS\ Nr Nr Nr Nr`A A A5 A A A AF ?CQUdhqs T T3 T T3 T^a T T T T& DHVZimvx G G GS GPS Gcf G G G G 37TX\eg W? W?C W?s W?RU W? W? W? W?r <@d[] FY FY FYS FY FYbfglbm FY FY FY FYP
 
 
4 
 
 
 
, 8<$]ajl }H }H }HC }HWZ }Hquvzq{ }H }H }H }H~ +- ) )g ) ) ) )(
 
 
& ?C4XZ 6 6 6 60 -/ @ @: @ @ @ @DA A A A A AQ Q Q Q Q Q *, n n n n n n`	 8<B ' 'C ' ' ' ' 'B
 
 
 GKY]lpy{ A= A= A=SV A=fi A= A= A= A=F 59tZ^gi _ _c _ _TW _ _ _ _ <@daenp x xS x x[^ x x x x 9=4^bkm [? [?# [?S [?X[ [? [? [? [?z @DRVeirt d d dC d_b d d d d 04$UYbd N N NC Ns Nimnsit N N N NB 7;\`ik Y Y Y3 YVY Yptuzp{ Y Y Y Y@ 59tZ^gi Y? Y?c Y? Y?TW Y?nrsxny Y? Y? Y? Y?v: : :*p p p5 p p p pd XZ T Tc T T T T T  ~B  TX  os  |~ R R# RY RV_ Rin Rwz R  CH R R R R* z~  GI f, f,c f, f,R[ f,ej f,sv f, f, f, f,P x|  EG O, O,C O,y O,PY O,ch O,qt O, O, O, O,b mqy{ X0 X0 X0I X0Y X0X] X0fi X0 X0 X0 X0t FH p1 p1$|*< p1 p1 p1 p1d 9=R y yS y# y y y yv 6:" Q Qs Q Q Q Qf 59 o oc o o o ob
 
h 
 
 
 
4 JL 0 0S 0 0 0 0< =? 5 5 5 5 5 5 >Bt\^  3    @ 04$UYbd 3Q 3Q 3QC 3Qs 3Qimnyiz 3Q 3Q 3Q 3Qj 37TX\eg 1Q 1QC 1Qs 1QRU 1Qlpq|l} 1Q 1Q 1Q 1QfZ
 Z
x Z
; Z
 Z
 Z
 Z
x: : :. EIQS 3: 3:3 3: 3: 3: 3: 3:j
 
 
 
 
 
. ac P7 P73 P7 P7C P7TW P7gt P7 P7 P7 P7d 8: ) ) ) )V)
 )
v )
 )
 )
 )
V >BPTcgpr FY FYs FY# FY]` FY FY FY FYP'
 '
6 '
 '
 '
 '
R <> #7 #7s #7 #7 #7 #7J <@ ,? ,? ,? ,? ,? ,?\ 7;$]apt} 7Q 7Q 7QC 7QWZ 7Qjm 7Q 7Q 7Q 7Qr:
 :
& :
 :
 :
 :
x &eBSW jP jP jP jPX  . 9=4^bkm P> P># P>S P>X[ P> P> P> P>d ?C2 A A3 A A A A AF
 
6 
 
 
 
8X Xv X X X Xt 8<B {P {PW {P {P {P {Pz 8: r r3 r r r rh3 3 3&(
 (
 (
 (
 (
 (
T .2SW`b G? G?s G?# G?S G? G? G? G?R =A 'I 'I' 'I 'I 'I 'IR EG .. .. .. .. .. ..` g    : HLZ^mqz| nE nE nETW nEgj nE nE nE nE` =? b b b b b bHA AF A A A AF Z\  3 c 5    B JL  c 5    < RT $ $# $S $ $ $ $L BD " "S " " " "H
 
 
 
 
 
B <@daenp [6 [6S [6 [6[^ [6 [6 [6 [6z BFb /I /Iw /I /I /I /Ib= = = = = =~5 5 5n 
  
  
D BFTXac ;C ;Cs ;C3 ;Cc ;C ;C ;C ;Cz V    > CGr 8 8d 8C 8 8 8 8 8 8 8 8r  r.   )4 ccxt.async_support.base.exchanger   ccxt.abstract.htxr   rI  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   ccxt.base.decimal_to_precisionr*   r+   ccxt.base.preciser,   r.    r  r  <module>r     s   6 5 5 5 5 5 ) ) ) ) ) )   c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) , , , , , , . . . . . . 1 1 1 1 1 1 * * * * * * + + + + + + 3 3 3 3 3 3 4 4 4 4 4 4 % % % % % %CC CC CC CC CC(K CC CC CC CC CCr  