ccxt-ir 4.3.46.0.3__py2.py3-none-any.whl → 4.5.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccxt/__init__.py +39 -35
- ccxt/abantether.py +8 -8
- ccxt/abstract/alpaca.py +4 -0
- ccxt/abstract/apex.py +31 -0
- ccxt/abstract/bigone.py +1 -1
- ccxt/abstract/binance.py +106 -48
- ccxt/abstract/binancecoinm.py +106 -48
- ccxt/abstract/binanceus.py +141 -83
- ccxt/abstract/binanceusdm.py +106 -48
- ccxt/abstract/bingx.py +50 -1
- ccxt/abstract/bitbank.py +5 -0
- ccxt/abstract/bitfinex.py +136 -65
- ccxt/abstract/bitflyer.py +1 -0
- ccxt/abstract/bitget.py +67 -0
- ccxt/abstract/bitmart.py +19 -1
- ccxt/abstract/bitopro.py +1 -0
- ccxt/abstract/bitrue.py +68 -68
- ccxt/abstract/bitstamp.py +1 -0
- ccxt/abstract/blofin.py +30 -0
- ccxt/abstract/btcbox.py +2 -0
- ccxt/abstract/bybit.py +28 -13
- ccxt/abstract/cex.py +28 -29
- ccxt/abstract/coinbaseexchange.py +1 -0
- ccxt/abstract/coinbaseinternational.py +1 -1
- ccxt/abstract/cryptocom.py +16 -0
- ccxt/abstract/cryptomus.py +20 -0
- ccxt/abstract/defx.py +69 -0
- ccxt/abstract/deribit.py +1 -0
- ccxt/abstract/derive.py +117 -0
- ccxt/abstract/digifinex.py +1 -0
- ccxt/abstract/ellipx.py +25 -0
- ccxt/abstract/foxbit.py +26 -0
- ccxt/abstract/gate.py +19 -0
- ccxt/abstract/gateio.py +19 -0
- ccxt/abstract/gemini.py +1 -0
- ccxt/abstract/hibachi.py +26 -0
- ccxt/abstract/hyperliquid.py +1 -1
- ccxt/abstract/independentreserve.py +6 -0
- ccxt/abstract/kraken.py +1 -0
- ccxt/abstract/krakenfutures.py +4 -0
- ccxt/abstract/kucoin.py +10 -0
- ccxt/abstract/kucoinfutures.py +18 -0
- ccxt/abstract/lbank.py +2 -1
- ccxt/abstract/luno.py +1 -0
- ccxt/abstract/mexc.py +2 -0
- ccxt/abstract/modetrade.py +119 -0
- ccxt/abstract/myokx.py +349 -0
- ccxt/abstract/oceanex.py +5 -0
- ccxt/abstract/okx.py +25 -0
- ccxt/abstract/okxus.py +349 -0
- ccxt/abstract/onetrading.py +0 -12
- ccxt/abstract/paradex.py +23 -0
- ccxt/abstract/phemex.py +2 -0
- ccxt/abstract/poloniex.py +36 -0
- ccxt/abstract/tradeogre.py +3 -1
- ccxt/abstract/upbit.py +51 -34
- ccxt/abstract/whitebit.py +16 -0
- ccxt/abstract/woo.py +64 -6
- ccxt/abstract/xt.py +10 -5
- ccxt/afratether.py +8 -8
- ccxt/alpaca.py +828 -51
- ccxt/apex.py +1875 -0
- ccxt/arzinja.py +7 -7
- ccxt/arzplus.py +9 -9
- ccxt/ascendex.py +501 -306
- ccxt/async_support/__init__.py +39 -35
- ccxt/async_support/abantether.py +8 -8
- ccxt/async_support/afratether.py +10 -10
- ccxt/async_support/alpaca.py +828 -51
- ccxt/async_support/apex.py +1875 -0
- ccxt/async_support/arzinja.py +10 -10
- ccxt/async_support/arzplus.py +12 -12
- ccxt/async_support/ascendex.py +502 -306
- ccxt/async_support/base/exchange.py +303 -89
- ccxt/async_support/base/ws/cache.py +9 -3
- ccxt/async_support/base/ws/client.py +173 -38
- ccxt/async_support/base/ws/future.py +25 -37
- ccxt/async_support/bequant.py +5 -3
- ccxt/async_support/bigone.py +279 -144
- ccxt/async_support/binance.py +2347 -1158
- ccxt/async_support/binancecoinm.py +9 -3
- ccxt/async_support/binanceus.py +17 -3
- ccxt/async_support/binanceusdm.py +9 -4
- ccxt/async_support/bingx.py +2962 -920
- ccxt/async_support/bit2c.py +147 -27
- ccxt/async_support/bitbank.py +151 -23
- ccxt/async_support/bitbns.py +104 -30
- ccxt/async_support/bitfinex.py +3291 -1113
- ccxt/async_support/bitflyer.py +202 -27
- ccxt/async_support/bitget.py +3683 -1538
- ccxt/async_support/bithumb.py +195 -38
- ccxt/async_support/bitimen.py +12 -12
- ccxt/async_support/bitir.py +38 -38
- ccxt/async_support/bitmart.py +1288 -350
- ccxt/async_support/bitmex.py +260 -75
- ccxt/async_support/bitopro.py +262 -62
- ccxt/async_support/bitpin.py +17 -16
- ccxt/async_support/bitrue.py +459 -290
- ccxt/async_support/bitso.py +199 -54
- ccxt/async_support/bitstamp.py +230 -96
- ccxt/async_support/bitteam.py +167 -25
- ccxt/async_support/{huobijp.py → bittrade.py} +158 -30
- ccxt/async_support/bitvavo.py +213 -49
- ccxt/async_support/blockchaincom.py +160 -46
- ccxt/async_support/blofin.py +502 -120
- ccxt/async_support/btcalpha.py +169 -31
- ccxt/async_support/btcbox.py +292 -23
- ccxt/async_support/btcmarkets.py +211 -58
- ccxt/async_support/btcturk.py +161 -38
- ccxt/async_support/bybit.py +1775 -1030
- ccxt/async_support/cex.py +1440 -1303
- ccxt/async_support/coinbase.py +724 -212
- ccxt/async_support/coinbaseadvanced.py +2 -1
- ccxt/async_support/coinbaseexchange.py +388 -89
- ccxt/async_support/coinbaseinternational.py +412 -57
- ccxt/async_support/coincatch.py +177 -78
- ccxt/async_support/coincheck.py +135 -19
- ccxt/async_support/coinex.py +606 -232
- ccxt/async_support/coinmate.py +189 -63
- ccxt/async_support/coinmetro.py +195 -54
- ccxt/async_support/coinone.py +158 -51
- ccxt/async_support/coinsph.py +336 -61
- ccxt/async_support/coinspot.py +151 -52
- ccxt/async_support/cryptocom.py +661 -111
- ccxt/async_support/cryptomus.py +1137 -0
- ccxt/async_support/defx.py +2071 -0
- ccxt/async_support/delta.py +299 -99
- ccxt/async_support/deribit.py +348 -126
- ccxt/async_support/derive.py +2572 -0
- ccxt/async_support/digifinex.py +430 -214
- ccxt/async_support/ellipx.py +2029 -0
- ccxt/async_support/eterex.py +10 -10
- ccxt/async_support/excoino.py +31 -31
- ccxt/async_support/exir.py +14 -14
- ccxt/async_support/exmo.py +344 -131
- ccxt/async_support/exnovin.py +10 -10
- ccxt/async_support/farhadexchange.py +12 -12
- ccxt/async_support/fmfwio.py +2 -1
- ccxt/async_support/foxbit.py +1935 -0
- ccxt/async_support/gate.py +1351 -529
- ccxt/async_support/gateio.py +2 -1
- ccxt/async_support/gemini.py +144 -39
- ccxt/async_support/hashkey.py +152 -109
- ccxt/async_support/hibachi.py +2080 -0
- ccxt/async_support/hitbtc.py +395 -167
- ccxt/async_support/hitobit.py +12 -12
- ccxt/async_support/hollaex.py +307 -119
- ccxt/async_support/htx.py +851 -383
- ccxt/async_support/huobi.py +2 -1
- ccxt/async_support/hyperliquid.py +1848 -536
- ccxt/async_support/independentreserve.py +288 -15
- ccxt/async_support/indodax.py +190 -33
- ccxt/async_support/jibitex.py +12 -12
- ccxt/async_support/kraken.py +795 -351
- ccxt/async_support/krakenfutures.py +214 -62
- ccxt/async_support/kucoin.py +715 -396
- ccxt/async_support/kucoinfutures.py +652 -89
- ccxt/async_support/latoken.py +217 -113
- ccxt/async_support/lbank.py +425 -97
- ccxt/async_support/luno.py +382 -35
- ccxt/async_support/mercado.py +113 -6
- ccxt/async_support/mexc.py +874 -437
- ccxt/async_support/modetrade.py +2818 -0
- ccxt/async_support/myokx.py +54 -0
- ccxt/async_support/ndax.py +221 -64
- ccxt/async_support/nobitex.py +32 -38
- ccxt/async_support/novadax.py +190 -34
- ccxt/async_support/oceanex.py +217 -28
- ccxt/async_support/okcoin.py +253 -145
- ccxt/async_support/okexchange.py +11 -11
- ccxt/async_support/okx.py +1088 -351
- ccxt/async_support/okxus.py +54 -0
- ccxt/async_support/ompfinex.py +32 -27
- ccxt/async_support/onetrading.py +213 -392
- ccxt/async_support/oxfun.py +245 -166
- ccxt/async_support/p2b.py +151 -29
- ccxt/async_support/paradex.py +562 -49
- ccxt/async_support/paymium.py +82 -19
- ccxt/async_support/phemex.py +713 -172
- ccxt/async_support/poloniex.py +1602 -283
- ccxt/async_support/probit.py +224 -95
- ccxt/async_support/ramzinex.py +34 -30
- ccxt/async_support/sarmayex.py +9 -9
- ccxt/async_support/sarrafex.py +13 -13
- ccxt/async_support/tabdeal.py +15 -14
- ccxt/async_support/tetherland.py +9 -9
- ccxt/async_support/timex.py +210 -51
- ccxt/async_support/tokocrypto.py +167 -47
- ccxt/async_support/tradeogre.py +266 -31
- ccxt/async_support/twox.py +9 -9
- ccxt/async_support/ubitex.py +12 -12
- ccxt/async_support/upbit.py +568 -165
- ccxt/async_support/vertex.py +160 -32
- ccxt/async_support/wallex.py +12 -12
- ccxt/async_support/wavesexchange.py +165 -30
- ccxt/async_support/whitebit.py +975 -127
- ccxt/async_support/woo.py +1918 -1016
- ccxt/async_support/woofipro.py +433 -141
- ccxt/async_support/xt.py +649 -193
- ccxt/async_support/yobit.py +195 -70
- ccxt/async_support/zaif.py +91 -15
- ccxt/async_support/zonda.py +151 -36
- ccxt/base/decimal_to_precision.py +14 -10
- ccxt/base/errors.py +49 -18
- ccxt/base/exchange.py +1556 -450
- ccxt/base/precise.py +10 -0
- ccxt/base/types.py +114 -6
- ccxt/bequant.py +5 -3
- ccxt/bigone.py +279 -144
- ccxt/binance.py +2347 -1158
- ccxt/binancecoinm.py +9 -3
- ccxt/binanceus.py +17 -3
- ccxt/binanceusdm.py +9 -4
- ccxt/bingx.py +2962 -920
- ccxt/bit2c.py +147 -27
- ccxt/bitbank.py +151 -23
- ccxt/bitbns.py +104 -30
- ccxt/bitfinex.py +3290 -1113
- ccxt/bitflyer.py +202 -27
- ccxt/bitget.py +3683 -1538
- ccxt/bithumb.py +194 -38
- ccxt/bitimen.py +9 -9
- ccxt/bitir.py +35 -35
- ccxt/bitmart.py +1288 -350
- ccxt/bitmex.py +260 -75
- ccxt/bitopro.py +262 -62
- ccxt/bitpin.py +15 -14
- ccxt/bitrue.py +459 -290
- ccxt/bitso.py +199 -54
- ccxt/bitstamp.py +230 -96
- ccxt/bitteam.py +167 -25
- ccxt/{huobijp.py → bittrade.py} +158 -30
- ccxt/bitvavo.py +213 -49
- ccxt/blockchaincom.py +160 -46
- ccxt/blofin.py +502 -120
- ccxt/btcalpha.py +169 -31
- ccxt/btcbox.py +291 -23
- ccxt/btcmarkets.py +211 -58
- ccxt/btcturk.py +161 -38
- ccxt/bybit.py +1775 -1030
- ccxt/cex.py +1439 -1303
- ccxt/coinbase.py +724 -212
- ccxt/coinbaseadvanced.py +2 -1
- ccxt/coinbaseexchange.py +388 -89
- ccxt/coinbaseinternational.py +412 -57
- ccxt/coincatch.py +177 -78
- ccxt/coincheck.py +135 -19
- ccxt/coinex.py +606 -232
- ccxt/coinmate.py +189 -63
- ccxt/coinmetro.py +194 -54
- ccxt/coinone.py +158 -51
- ccxt/coinsph.py +336 -61
- ccxt/coinspot.py +151 -52
- ccxt/cryptocom.py +661 -111
- ccxt/cryptomus.py +1137 -0
- ccxt/defx.py +2070 -0
- ccxt/delta.py +299 -99
- ccxt/deribit.py +348 -126
- ccxt/derive.py +2571 -0
- ccxt/digifinex.py +430 -214
- ccxt/ellipx.py +2029 -0
- ccxt/eterex.py +7 -7
- ccxt/excoino.py +29 -29
- ccxt/exir.py +11 -11
- ccxt/exmo.py +343 -131
- ccxt/exnovin.py +8 -8
- ccxt/farhadexchange.py +10 -10
- ccxt/fmfwio.py +2 -1
- ccxt/foxbit.py +1935 -0
- ccxt/gate.py +1351 -529
- ccxt/gateio.py +2 -1
- ccxt/gemini.py +144 -39
- ccxt/hashkey.py +152 -109
- ccxt/hibachi.py +2079 -0
- ccxt/hitbtc.py +395 -167
- ccxt/hitobit.py +9 -9
- ccxt/hollaex.py +307 -119
- ccxt/htx.py +851 -383
- ccxt/huobi.py +2 -1
- ccxt/hyperliquid.py +1848 -536
- ccxt/independentreserve.py +287 -15
- ccxt/indodax.py +190 -33
- ccxt/jibitex.py +9 -9
- ccxt/kraken.py +794 -351
- ccxt/krakenfutures.py +214 -62
- ccxt/kucoin.py +715 -396
- ccxt/kucoinfutures.py +652 -89
- ccxt/latoken.py +217 -113
- ccxt/lbank.py +425 -97
- ccxt/luno.py +382 -35
- ccxt/mercado.py +113 -6
- ccxt/mexc.py +873 -437
- ccxt/modetrade.py +2818 -0
- ccxt/myokx.py +54 -0
- ccxt/ndax.py +221 -64
- ccxt/nobitex.py +30 -36
- ccxt/novadax.py +190 -34
- ccxt/oceanex.py +217 -28
- ccxt/okcoin.py +253 -145
- ccxt/okexchange.py +9 -9
- ccxt/okx.py +1088 -351
- ccxt/okxus.py +54 -0
- ccxt/ompfinex.py +29 -24
- ccxt/onetrading.py +213 -392
- ccxt/oxfun.py +245 -166
- ccxt/p2b.py +151 -29
- ccxt/paradex.py +562 -49
- ccxt/paymium.py +82 -19
- ccxt/phemex.py +712 -172
- ccxt/poloniex.py +1601 -283
- ccxt/pro/__init__.py +76 -17
- ccxt/pro/alpaca.py +21 -6
- ccxt/pro/apex.py +984 -0
- ccxt/pro/ascendex.py +58 -10
- ccxt/pro/bequant.py +6 -1
- ccxt/pro/binance.py +728 -156
- ccxt/pro/binancecoinm.py +6 -2
- ccxt/pro/binanceus.py +8 -4
- ccxt/pro/binanceusdm.py +7 -2
- ccxt/pro/bingx.py +333 -142
- ccxt/pro/bitfinex.py +727 -262
- ccxt/pro/bitget.py +570 -79
- ccxt/pro/bithumb.py +20 -6
- ccxt/pro/bitmart.py +216 -87
- ccxt/pro/bitmex.py +47 -9
- ccxt/pro/bitopro.py +26 -14
- ccxt/pro/bitrue.py +22 -22
- ccxt/pro/bitstamp.py +54 -21
- ccxt/pro/{huobijp.py → bittrade.py} +7 -6
- ccxt/pro/bitvavo.py +191 -67
- ccxt/pro/blockchaincom.py +21 -8
- ccxt/pro/blofin.py +9 -1
- ccxt/pro/bybit.py +632 -245
- ccxt/pro/cex.py +59 -24
- ccxt/pro/coinbase.py +102 -73
- ccxt/pro/coinbaseadvanced.py +2 -1
- ccxt/pro/coinbaseexchange.py +8 -8
- ccxt/pro/coinbaseinternational.py +181 -25
- ccxt/pro/coincatch.py +6 -7
- ccxt/pro/coincheck.py +11 -6
- ccxt/pro/coinex.py +967 -665
- ccxt/pro/coinone.py +16 -9
- ccxt/pro/cryptocom.py +448 -45
- ccxt/pro/defx.py +831 -0
- ccxt/pro/deribit.py +150 -14
- ccxt/pro/derive.py +704 -0
- ccxt/pro/exmo.py +239 -6
- ccxt/pro/gate.py +623 -65
- ccxt/pro/gateio.py +2 -1
- ccxt/pro/gemini.py +27 -11
- ccxt/pro/hashkey.py +2 -2
- ccxt/pro/hitbtc.py +196 -91
- ccxt/pro/hollaex.py +23 -7
- ccxt/pro/htx.py +51 -14
- ccxt/pro/huobi.py +2 -1
- ccxt/pro/hyperliquid.py +591 -27
- ccxt/pro/independentreserve.py +9 -6
- ccxt/pro/kraken.py +640 -320
- ccxt/pro/krakenfutures.py +62 -35
- ccxt/pro/kucoin.py +267 -46
- ccxt/pro/kucoinfutures.py +165 -21
- ccxt/pro/lbank.py +102 -21
- ccxt/pro/luno.py +12 -8
- ccxt/pro/mexc.py +877 -111
- ccxt/pro/modetrade.py +1271 -0
- ccxt/pro/myokx.py +38 -0
- ccxt/pro/ndax.py +15 -2
- ccxt/pro/okcoin.py +23 -4
- ccxt/pro/okx.py +573 -98
- ccxt/pro/okxus.py +38 -0
- ccxt/pro/onetrading.py +30 -13
- ccxt/pro/oxfun.py +131 -27
- ccxt/pro/p2b.py +88 -22
- ccxt/pro/paradex.py +3 -3
- ccxt/pro/phemex.py +75 -21
- ccxt/pro/poloniex.py +124 -41
- ccxt/pro/probit.py +87 -80
- ccxt/pro/tradeogre.py +272 -0
- ccxt/pro/upbit.py +152 -12
- ccxt/pro/vertex.py +8 -3
- ccxt/pro/whitebit.py +58 -5
- ccxt/pro/woo.py +228 -37
- ccxt/pro/woofipro.py +106 -18
- ccxt/pro/xt.py +111 -5
- ccxt/probit.py +224 -95
- ccxt/protobuf/__init__.py +0 -0
- ccxt/protobuf/mexc/PrivateAccountV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PrivateDealsV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PrivateOrdersV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PublicAggreBookTickerV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PublicAggreDealsV3Api_pb2.py +39 -0
- ccxt/protobuf/mexc/PublicAggreDepthsV3Api_pb2.py +39 -0
- ccxt/protobuf/mexc/PublicBookTickerBatchV3Api_pb2.py +38 -0
- ccxt/protobuf/mexc/PublicBookTickerV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PublicDealsV3Api_pb2.py +39 -0
- ccxt/protobuf/mexc/PublicIncreaseDepthsBatchV3Api_pb2.py +38 -0
- ccxt/protobuf/mexc/PublicIncreaseDepthsV3Api_pb2.py +39 -0
- ccxt/protobuf/mexc/PublicLimitDepthsV3Api_pb2.py +39 -0
- ccxt/protobuf/mexc/PublicMiniTickerV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PublicMiniTickersV3Api_pb2.py +38 -0
- ccxt/protobuf/mexc/PublicSpotKlineV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PushDataV3ApiWrapper_pb2.py +52 -0
- ccxt/protobuf/mexc/__init__.py +0 -0
- ccxt/ramzinex.py +32 -28
- ccxt/sarmayex.py +7 -7
- ccxt/sarrafex.py +10 -10
- ccxt/static_dependencies/__init__.py +1 -1
- ccxt/static_dependencies/lark/py.typed +0 -0
- ccxt/static_dependencies/marshmallow/py.typed +0 -0
- ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
- ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
- ccxt/tabdeal.py +13 -12
- ccxt/test/tests_async.py +261 -57
- ccxt/test/tests_helpers.py +1 -3
- ccxt/test/tests_init.py +4 -3
- ccxt/test/tests_sync.py +261 -57
- ccxt/tetherland.py +7 -7
- ccxt/timex.py +210 -51
- ccxt/tokocrypto.py +167 -47
- ccxt/tradeogre.py +266 -31
- ccxt/twox.py +7 -7
- ccxt/ubitex.py +9 -9
- ccxt/upbit.py +568 -165
- ccxt/vertex.py +160 -32
- ccxt/wallex.py +9 -9
- ccxt/wavesexchange.py +165 -30
- ccxt/whitebit.py +975 -127
- ccxt/woo.py +1917 -1016
- ccxt/woofipro.py +432 -141
- ccxt/xt.py +649 -193
- ccxt/yobit.py +194 -70
- ccxt/zaif.py +91 -15
- ccxt/zonda.py +151 -36
- {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.1.dist-info}/METADATA +225 -73
- ccxt_ir-4.5.1.dist-info/RECORD +743 -0
- {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.1.dist-info}/WHEEL +1 -1
- ccxt/__test__.py +0 -7
- ccxt/abstract/ace.py +0 -15
- ccxt/abstract/bitbay.py +0 -53
- ccxt/abstract/bitcoincom.py +0 -115
- ccxt/abstract/bitfinex2.py +0 -139
- ccxt/abstract/bitpanda.py +0 -35
- ccxt/abstract/bl3p.py +0 -19
- ccxt/abstract/coinlist.py +0 -54
- ccxt/abstract/currencycom.py +0 -68
- ccxt/abstract/hitbtc3.py +0 -115
- ccxt/abstract/idex.py +0 -26
- ccxt/abstract/kuna.py +0 -182
- ccxt/abstract/lykke.py +0 -29
- ccxt/abstract/poloniexfutures.py +0 -48
- ccxt/abstract/wazirx.py +0 -30
- ccxt/ace.py +0 -1012
- ccxt/async_support/ace.py +0 -1012
- ccxt/async_support/base/ws/aiohttp_client.py +0 -125
- ccxt/async_support/base/ws/fast_client.py +0 -96
- ccxt/async_support/bitbay.py +0 -17
- ccxt/async_support/bitcoincom.py +0 -17
- ccxt/async_support/bitfinex2.py +0 -3552
- ccxt/async_support/bitpanda.py +0 -16
- ccxt/async_support/bl3p.py +0 -485
- ccxt/async_support/coinlist.py +0 -2243
- ccxt/async_support/currencycom.py +0 -1950
- ccxt/async_support/hitbtc3.py +0 -16
- ccxt/async_support/idex.py +0 -1766
- ccxt/async_support/kuna.py +0 -1841
- ccxt/async_support/lykke.py +0 -1270
- ccxt/async_support/poloniexfutures.py +0 -1717
- ccxt/async_support/wazirx.py +0 -1224
- ccxt/bitbay.py +0 -17
- ccxt/bitcoincom.py +0 -17
- ccxt/bitfinex2.py +0 -3552
- ccxt/bitpanda.py +0 -16
- ccxt/bl3p.py +0 -485
- ccxt/coinlist.py +0 -2243
- ccxt/currencycom.py +0 -1950
- ccxt/hitbtc3.py +0 -16
- ccxt/idex.py +0 -1766
- ccxt/kuna.py +0 -1841
- ccxt/lykke.py +0 -1270
- ccxt/poloniexfutures.py +0 -1717
- ccxt/pro/bitcoincom.py +0 -34
- ccxt/pro/bitfinex2.py +0 -1083
- ccxt/pro/bitpanda.py +0 -15
- ccxt/pro/currencycom.py +0 -536
- ccxt/pro/idex.py +0 -672
- ccxt/pro/poloniexfutures.py +0 -990
- ccxt/pro/wazirx.py +0 -749
- ccxt/test/base/__init__.py +0 -29
- ccxt/test/base/test_account.py +0 -26
- ccxt/test/base/test_balance.py +0 -56
- ccxt/test/base/test_borrow_interest.py +0 -35
- ccxt/test/base/test_borrow_rate.py +0 -32
- ccxt/test/base/test_calculate_fee.py +0 -51
- ccxt/test/base/test_crypto.py +0 -127
- ccxt/test/base/test_currency.py +0 -76
- ccxt/test/base/test_datetime.py +0 -109
- ccxt/test/base/test_decimal_to_precision.py +0 -392
- ccxt/test/base/test_deep_extend.py +0 -68
- ccxt/test/base/test_deposit_withdrawal.py +0 -50
- ccxt/test/base/test_exchange_datetime_functions.py +0 -76
- ccxt/test/base/test_funding_rate_history.py +0 -29
- ccxt/test/base/test_last_price.py +0 -31
- ccxt/test/base/test_ledger_entry.py +0 -45
- ccxt/test/base/test_ledger_item.py +0 -48
- ccxt/test/base/test_leverage_tier.py +0 -33
- ccxt/test/base/test_liquidation.py +0 -50
- ccxt/test/base/test_margin_mode.py +0 -24
- ccxt/test/base/test_margin_modification.py +0 -35
- ccxt/test/base/test_market.py +0 -193
- ccxt/test/base/test_number.py +0 -411
- ccxt/test/base/test_ohlcv.py +0 -33
- ccxt/test/base/test_open_interest.py +0 -32
- ccxt/test/base/test_order.py +0 -64
- ccxt/test/base/test_order_book.py +0 -69
- ccxt/test/base/test_position.py +0 -60
- ccxt/test/base/test_shared_methods.py +0 -353
- ccxt/test/base/test_status.py +0 -24
- ccxt/test/base/test_throttle.py +0 -126
- ccxt/test/base/test_ticker.py +0 -92
- ccxt/test/base/test_trade.py +0 -47
- ccxt/test/base/test_trading_fee.py +0 -26
- ccxt/test/base/test_transaction.py +0 -39
- ccxt/test/test_async.py +0 -1649
- ccxt/test/test_sync.py +0 -1648
- ccxt/wazirx.py +0 -1224
- ccxt_ir-4.3.46.0.3.dist-info/RECORD +0 -773
- /ccxt/abstract/{huobijp.py → bittrade.py} +0 -0
- {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.1.dist-info/licenses}/LICENSE.txt +0 -0
- {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.1.dist-info}/top_level.txt +0 -0
ccxt/htx.py
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.htx import ImplicitAPI
|
|
8
8
|
import hashlib
|
|
9
|
-
from ccxt.base.types import Account, Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
|
9
|
+
from ccxt.base.types import Account, Any, Balances, BorrowInterest, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, Transaction, TransferEntry
|
|
10
10
|
from typing import List
|
|
11
11
|
from ccxt.base.errors import ExchangeError
|
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
|
@@ -31,7 +31,7 @@ from ccxt.base.precise import Precise
|
|
|
31
31
|
|
|
32
32
|
class htx(Exchange, ImplicitAPI):
|
|
33
33
|
|
|
34
|
-
def describe(self):
|
|
34
|
+
def describe(self) -> Any:
|
|
35
35
|
return self.deep_extend(super(htx, self).describe(), {
|
|
36
36
|
'id': 'htx',
|
|
37
37
|
'name': 'HTX',
|
|
@@ -106,7 +106,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
106
106
|
'fetchLeverageTiers': True,
|
|
107
107
|
'fetchLiquidations': True,
|
|
108
108
|
'fetchMarginAdjustmentHistory': False,
|
|
109
|
-
'fetchMarketLeverageTiers':
|
|
109
|
+
'fetchMarketLeverageTiers': 'emulated',
|
|
110
110
|
'fetchMarkets': True,
|
|
111
111
|
'fetchMarkOHLCV': True,
|
|
112
112
|
'fetchMyLiquidations': False,
|
|
@@ -114,6 +114,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
114
114
|
'fetchOHLCV': True,
|
|
115
115
|
'fetchOpenInterest': True,
|
|
116
116
|
'fetchOpenInterestHistory': True,
|
|
117
|
+
'fetchOpenInterests': True,
|
|
117
118
|
'fetchOpenOrder': None,
|
|
118
119
|
'fetchOpenOrders': True,
|
|
119
120
|
'fetchOrder': True,
|
|
@@ -202,7 +203,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
202
203
|
},
|
|
203
204
|
'www': 'https://www.huobi.com',
|
|
204
205
|
'referral': {
|
|
205
|
-
'url': 'https://www.
|
|
206
|
+
'url': 'https://www.htx.com.vc/invite/en-us/1h?invite_code=6rmm2223',
|
|
206
207
|
'discount': 0.15,
|
|
207
208
|
},
|
|
208
209
|
'doc': [
|
|
@@ -908,6 +909,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
908
909
|
'1041': InvalidOrder, # {"status":"error","err_code":1041,"err_msg":"The order amount exceeds the limit(170000Cont), please modify and order again.","ts":1643802784940}
|
|
909
910
|
'1047': InsufficientFunds, # {"status":"error","err_code":1047,"err_msg":"Insufficient margin available.","ts":1643802672652}
|
|
910
911
|
'1048': InsufficientFunds, # {"status":"error","err_code":1048,"err_msg":"Insufficient close amount available.","ts":1652772408864}
|
|
912
|
+
'1061': OrderNotFound, # {"status":"ok","data":{"errors":[{"order_id":"1349442392365359104","err_code":1061,"err_msg":"The order does not exist."}],"successes":""},"ts":1741773744526}
|
|
911
913
|
'1051': InvalidOrder, # {"status":"error","err_code":1051,"err_msg":"No orders to cancel.","ts":1652552125876}
|
|
912
914
|
'1066': BadSymbol, # {"status":"error","err_code":1066,"err_msg":"The symbol field cannot be empty. Please re-enter.","ts":1640550819147}
|
|
913
915
|
'1067': InvalidOrder, # {"status":"error","err_code":1067,"err_msg":"The client_order_id field is invalid. Please re-enter.","ts":1643802119413}
|
|
@@ -960,6 +962,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
960
962
|
},
|
|
961
963
|
'precisionMode': TICK_SIZE,
|
|
962
964
|
'options': {
|
|
965
|
+
'include_OS_certificates': False, # temporarily leave self, remove in future
|
|
963
966
|
'fetchMarkets': {
|
|
964
967
|
'types': {
|
|
965
968
|
'spot': True,
|
|
@@ -967,6 +970,8 @@ class htx(Exchange, ImplicitAPI):
|
|
|
967
970
|
'inverse': True,
|
|
968
971
|
},
|
|
969
972
|
},
|
|
973
|
+
'timeDifference': 0, # the difference between system clock and exchange clock
|
|
974
|
+
'adjustForTimeDifference': False, # controls the adjustment logic upon instantiation
|
|
970
975
|
'fetchOHLCV': {
|
|
971
976
|
'useHistoricalEndpointForSpot': True,
|
|
972
977
|
},
|
|
@@ -1236,21 +1241,164 @@ class htx(Exchange, ImplicitAPI):
|
|
|
1236
1241
|
# https://github.com/ccxt/ccxt/issues/6081
|
|
1237
1242
|
# https://github.com/ccxt/ccxt/issues/3365
|
|
1238
1243
|
# https://github.com/ccxt/ccxt/issues/2873
|
|
1239
|
-
'
|
|
1240
|
-
'
|
|
1241
|
-
'
|
|
1244
|
+
'NGL': 'GFNGL',
|
|
1245
|
+
'GET': 'THEMIS', # conflict with GET(Guaranteed Entrance Token, GET Protocol)
|
|
1246
|
+
'GTC': 'GAMECOM', # conflict with Gitcoin and Gastrocoin
|
|
1247
|
+
'HIT': 'HITCHAIN',
|
|
1242
1248
|
# https://github.com/ccxt/ccxt/issues/7399
|
|
1243
1249
|
# https://coinmarketcap.com/currencies/pnetwork/
|
|
1244
1250
|
# https://coinmarketcap.com/currencies/penta/markets/
|
|
1245
1251
|
# https://en.cryptonomist.ch/blog/eidoo/the-edo-to-pnt-upgrade-what-you-need-to-know-updated/
|
|
1246
|
-
'PNT': '
|
|
1247
|
-
'SBTC': '
|
|
1248
|
-
'SOUL': '
|
|
1249
|
-
'BIFI': '
|
|
1252
|
+
'PNT': 'PENTA',
|
|
1253
|
+
'SBTC': 'SUPERBITCOIN',
|
|
1254
|
+
'SOUL': 'SOULSAVER',
|
|
1255
|
+
'BIFI': 'BITCOINFILE', # conflict with Beefy.Finance https://github.com/ccxt/ccxt/issues/8706
|
|
1256
|
+
'FUD': 'FTX Users Debt',
|
|
1257
|
+
},
|
|
1258
|
+
'features': {
|
|
1259
|
+
'spot': {
|
|
1260
|
+
'sandbox': True,
|
|
1261
|
+
'createOrder': {
|
|
1262
|
+
'marginMode': True,
|
|
1263
|
+
'triggerPrice': True,
|
|
1264
|
+
'triggerDirection': True,
|
|
1265
|
+
'triggerPriceType': None,
|
|
1266
|
+
'stopLossPrice': False, # todo: add support by triggerprice
|
|
1267
|
+
'takeProfitPrice': False,
|
|
1268
|
+
'attachedStopLossTakeProfit': None,
|
|
1269
|
+
'timeInForce': {
|
|
1270
|
+
'IOC': True,
|
|
1271
|
+
'FOK': True,
|
|
1272
|
+
'PO': True,
|
|
1273
|
+
'GTD': False,
|
|
1274
|
+
},
|
|
1275
|
+
'hedged': False,
|
|
1276
|
+
'trailing': False,
|
|
1277
|
+
'iceberg': False,
|
|
1278
|
+
'selfTradePrevention': True, # todo implement
|
|
1279
|
+
'leverage': True, # todo implement
|
|
1280
|
+
'marketBuyByCost': True,
|
|
1281
|
+
'marketBuyRequiresPrice': True,
|
|
1282
|
+
},
|
|
1283
|
+
'createOrders': {
|
|
1284
|
+
'max': 10,
|
|
1285
|
+
},
|
|
1286
|
+
'fetchMyTrades': {
|
|
1287
|
+
'marginMode': False,
|
|
1288
|
+
'limit': 500,
|
|
1289
|
+
'daysBack': 120,
|
|
1290
|
+
'untilDays': 2,
|
|
1291
|
+
'symbolRequired': False,
|
|
1292
|
+
},
|
|
1293
|
+
'fetchOrder': {
|
|
1294
|
+
'marginMode': False,
|
|
1295
|
+
'trigger': False,
|
|
1296
|
+
'trailing': False,
|
|
1297
|
+
'symbolRequired': False,
|
|
1298
|
+
},
|
|
1299
|
+
'fetchOpenOrders': {
|
|
1300
|
+
'marginMode': False,
|
|
1301
|
+
'trigger': True,
|
|
1302
|
+
'trailing': False,
|
|
1303
|
+
'limit': 500,
|
|
1304
|
+
'symbolRequired': False,
|
|
1305
|
+
},
|
|
1306
|
+
'fetchOrders': {
|
|
1307
|
+
'marginMode': False,
|
|
1308
|
+
'trigger': True,
|
|
1309
|
+
'trailing': False,
|
|
1310
|
+
'limit': 500,
|
|
1311
|
+
'untilDays': 2,
|
|
1312
|
+
'daysBack': 180,
|
|
1313
|
+
'symbolRequired': False,
|
|
1314
|
+
},
|
|
1315
|
+
'fetchClosedOrders': {
|
|
1316
|
+
'marginMode': False,
|
|
1317
|
+
'trigger': True,
|
|
1318
|
+
'trailing': False,
|
|
1319
|
+
'untilDays': 2,
|
|
1320
|
+
'limit': 500,
|
|
1321
|
+
'daysBack': 180,
|
|
1322
|
+
'daysBackCanceled': 1 / 12,
|
|
1323
|
+
'symbolRequired': False,
|
|
1324
|
+
},
|
|
1325
|
+
'fetchOHLCV': {
|
|
1326
|
+
'limit': 1000, # 2000 for non-historical
|
|
1327
|
+
},
|
|
1328
|
+
},
|
|
1329
|
+
'forDerivatives': {
|
|
1330
|
+
'extends': 'spot',
|
|
1331
|
+
'createOrder': {
|
|
1332
|
+
'stopLossPrice': True,
|
|
1333
|
+
'takeProfitPrice': True,
|
|
1334
|
+
'trailing': True,
|
|
1335
|
+
'hedged': True,
|
|
1336
|
+
# 'leverage': True, # todo
|
|
1337
|
+
},
|
|
1338
|
+
'createOrders': {
|
|
1339
|
+
'max': 25,
|
|
1340
|
+
},
|
|
1341
|
+
'fetchOrder': {
|
|
1342
|
+
'marginMode': True,
|
|
1343
|
+
},
|
|
1344
|
+
'fetchOpenOrders': {
|
|
1345
|
+
'marginMode': True,
|
|
1346
|
+
'trigger': False,
|
|
1347
|
+
'trailing': False,
|
|
1348
|
+
'limit': 50,
|
|
1349
|
+
},
|
|
1350
|
+
'fetchOrders': {
|
|
1351
|
+
'marginMode': True,
|
|
1352
|
+
'trigger': False,
|
|
1353
|
+
'trailing': False,
|
|
1354
|
+
'limit': 50,
|
|
1355
|
+
'daysBack': 90,
|
|
1356
|
+
},
|
|
1357
|
+
'fetchClosedOrders': {
|
|
1358
|
+
'marginMode': True,
|
|
1359
|
+
'trigger': False,
|
|
1360
|
+
'trailing': False,
|
|
1361
|
+
'untilDays': 2,
|
|
1362
|
+
'limit': 50,
|
|
1363
|
+
'daysBack': 90,
|
|
1364
|
+
'daysBackCanceled': 1 / 12,
|
|
1365
|
+
},
|
|
1366
|
+
'fetchOHLCV': {
|
|
1367
|
+
'limit': 2000,
|
|
1368
|
+
},
|
|
1369
|
+
},
|
|
1370
|
+
'swap': {
|
|
1371
|
+
'linear': {
|
|
1372
|
+
'extends': 'forDerivatives',
|
|
1373
|
+
},
|
|
1374
|
+
'inverse': {
|
|
1375
|
+
'extends': 'forDerivatives',
|
|
1376
|
+
},
|
|
1377
|
+
},
|
|
1378
|
+
'future': {
|
|
1379
|
+
'linear': {
|
|
1380
|
+
'extends': 'forDerivatives',
|
|
1381
|
+
},
|
|
1382
|
+
'inverse': {
|
|
1383
|
+
'extends': 'forDerivatives',
|
|
1384
|
+
},
|
|
1385
|
+
},
|
|
1250
1386
|
},
|
|
1251
1387
|
})
|
|
1252
1388
|
|
|
1253
1389
|
def fetch_status(self, params={}):
|
|
1390
|
+
"""
|
|
1391
|
+
the latest known information on the availability of the exchange API
|
|
1392
|
+
|
|
1393
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-system-status
|
|
1394
|
+
https://huobiapi.github.io/docs/dm/v1/en/#get-system-status
|
|
1395
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-system-status
|
|
1396
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#get-system-status
|
|
1397
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#query-whether-the-system-is-available # contractPublicGetHeartbeat
|
|
1398
|
+
|
|
1399
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1400
|
+
:returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
|
|
1401
|
+
"""
|
|
1254
1402
|
self.load_markets()
|
|
1255
1403
|
marketType = None
|
|
1256
1404
|
marketType, params = self.handle_market_type_and_params('fetchStatus', None, params)
|
|
@@ -1459,9 +1607,13 @@ class htx(Exchange, ImplicitAPI):
|
|
|
1459
1607
|
'info': response,
|
|
1460
1608
|
}
|
|
1461
1609
|
|
|
1462
|
-
def fetch_time(self, params={}):
|
|
1610
|
+
def fetch_time(self, params={}) -> Int:
|
|
1463
1611
|
"""
|
|
1464
1612
|
fetches the current integer timestamp in milliseconds from the exchange server
|
|
1613
|
+
|
|
1614
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-current-timestamp
|
|
1615
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-current-system-timestamp
|
|
1616
|
+
|
|
1465
1617
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1466
1618
|
:returns int: the current integer timestamp in milliseconds from the exchange server
|
|
1467
1619
|
"""
|
|
@@ -1508,6 +1660,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
1508
1660
|
def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
|
|
1509
1661
|
"""
|
|
1510
1662
|
fetch the trading fees for a market
|
|
1663
|
+
|
|
1664
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-current-fee-rate-applied-to-the-user
|
|
1665
|
+
|
|
1511
1666
|
:param str symbol: unified market symbol
|
|
1512
1667
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1513
1668
|
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
|
|
@@ -1551,6 +1706,15 @@ class htx(Exchange, ImplicitAPI):
|
|
|
1551
1706
|
return result
|
|
1552
1707
|
|
|
1553
1708
|
def fetch_trading_limits_by_id(self, id: str, params={}):
|
|
1709
|
+
"""
|
|
1710
|
+
@ignore
|
|
1711
|
+
|
|
1712
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-current-fee-rate-applied-to-the-user
|
|
1713
|
+
|
|
1714
|
+
:param str id: market id
|
|
1715
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1716
|
+
:returns dict: the limits object of a market structure
|
|
1717
|
+
"""
|
|
1554
1718
|
request: dict = {
|
|
1555
1719
|
'symbol': id,
|
|
1556
1720
|
}
|
|
@@ -1605,9 +1769,17 @@ class htx(Exchange, ImplicitAPI):
|
|
|
1605
1769
|
def fetch_markets(self, params={}) -> List[Market]:
|
|
1606
1770
|
"""
|
|
1607
1771
|
retrieves data on all markets for huobi
|
|
1772
|
+
|
|
1773
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v1-deprecated
|
|
1774
|
+
https://huobiapi.github.io/docs/dm/v1/en/#get-contract-info
|
|
1775
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-swap-info
|
|
1776
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-swap-info
|
|
1777
|
+
|
|
1608
1778
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1609
1779
|
:returns dict[]: an array of objects representing market data
|
|
1610
1780
|
"""
|
|
1781
|
+
if self.options['adjustForTimeDifference']:
|
|
1782
|
+
self.load_time_difference()
|
|
1611
1783
|
types = None
|
|
1612
1784
|
types, params = self.handle_option_and_params(params, 'fetchMarkets', 'types', {})
|
|
1613
1785
|
allMarkets = []
|
|
@@ -1628,7 +1800,21 @@ class htx(Exchange, ImplicitAPI):
|
|
|
1628
1800
|
allMarkets = self.array_concat(allMarkets, promises[i])
|
|
1629
1801
|
return allMarkets
|
|
1630
1802
|
|
|
1631
|
-
def fetch_markets_by_type_and_sub_type(self, type, subType, params={}):
|
|
1803
|
+
def fetch_markets_by_type_and_sub_type(self, type: Str, subType: Str, params={}):
|
|
1804
|
+
"""
|
|
1805
|
+
@ignore
|
|
1806
|
+
retrieves data on all markets of a certain type and/or subtype
|
|
1807
|
+
|
|
1808
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v1-deprecated
|
|
1809
|
+
https://huobiapi.github.io/docs/dm/v1/en/#get-contract-info
|
|
1810
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-swap-info
|
|
1811
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-swap-info
|
|
1812
|
+
|
|
1813
|
+
:param str [type]: 'spot', 'swap' or 'future'
|
|
1814
|
+
:param str [subType]: 'linear' or 'inverse'
|
|
1815
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
1816
|
+
:returns dict[]: an array of objects representing market data
|
|
1817
|
+
"""
|
|
1632
1818
|
isSpot = (type == 'spot')
|
|
1633
1819
|
request: dict = {}
|
|
1634
1820
|
response = None
|
|
@@ -1987,14 +2173,14 @@ class htx(Exchange, ImplicitAPI):
|
|
|
1987
2173
|
ask = None
|
|
1988
2174
|
askVolume = None
|
|
1989
2175
|
if 'bid' in ticker:
|
|
1990
|
-
if isinstance(ticker['bid'], list):
|
|
2176
|
+
if ticker['bid'] is not None and isinstance(ticker['bid'], list):
|
|
1991
2177
|
bid = self.safe_string(ticker['bid'], 0)
|
|
1992
2178
|
bidVolume = self.safe_string(ticker['bid'], 1)
|
|
1993
2179
|
else:
|
|
1994
2180
|
bid = self.safe_string(ticker, 'bid')
|
|
1995
2181
|
bidVolume = self.safe_string(ticker, 'bidSize')
|
|
1996
2182
|
if 'ask' in ticker:
|
|
1997
|
-
if isinstance(ticker['ask'], list):
|
|
2183
|
+
if ticker['ask'] is not None and isinstance(ticker['ask'], list):
|
|
1998
2184
|
ask = self.safe_string(ticker['ask'], 0)
|
|
1999
2185
|
askVolume = self.safe_string(ticker['ask'], 1)
|
|
2000
2186
|
else:
|
|
@@ -2030,6 +2216,12 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2030
2216
|
def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
|
2031
2217
|
"""
|
|
2032
2218
|
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
2219
|
+
|
|
2220
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-latest-aggregated-ticker
|
|
2221
|
+
https://huobiapi.github.io/docs/dm/v1/en/#get-market-data-overview
|
|
2222
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-market-data-overview
|
|
2223
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-market-data-overview
|
|
2224
|
+
|
|
2033
2225
|
:param str symbol: unified symbol of the market to fetch the ticker for
|
|
2034
2226
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2035
2227
|
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
|
@@ -2104,10 +2296,12 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2104
2296
|
def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
|
2105
2297
|
"""
|
|
2106
2298
|
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2299
|
+
|
|
2300
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-latest-tickers-for-all-pairs
|
|
2301
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-a-batch-of-market-data-overview
|
|
2302
|
+
https://huobiapi.github.io/docs/dm/v1/en/#get-a-batch-of-market-data-overview
|
|
2303
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-a-batch-of-market-data-overview-v2
|
|
2304
|
+
|
|
2111
2305
|
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
2112
2306
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2113
2307
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
|
@@ -2208,9 +2402,11 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2208
2402
|
def fetch_last_prices(self, symbols: Strings = None, params={}):
|
|
2209
2403
|
"""
|
|
2210
2404
|
fetches the last price for multiple markets
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2405
|
+
|
|
2406
|
+
https://www.htx.com/en-us/opend/newApiPages/?id=8cb81024-77b5-11ed-9966-0242ac110003 linear swap & linear future
|
|
2407
|
+
https://www.htx.com/en-us/opend/newApiPages/?id=28c2e8fc-77ae-11ed-9966-0242ac110003 inverse future
|
|
2408
|
+
https://www.htx.com/en-us/opend/newApiPages/?id=5d517ef5-77b6-11ed-9966-0242ac110003 inverse swap
|
|
2409
|
+
|
|
2214
2410
|
:param str[] [symbols]: unified symbols of the markets to fetch the last prices
|
|
2215
2411
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2216
2412
|
:returns dict: a dictionary of lastprices structures
|
|
@@ -2323,6 +2519,12 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2323
2519
|
def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
|
2324
2520
|
"""
|
|
2325
2521
|
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
|
2522
|
+
|
|
2523
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-market-depth
|
|
2524
|
+
https://huobiapi.github.io/docs/dm/v1/en/#get-market-depth
|
|
2525
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-market-depth
|
|
2526
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-market-depth
|
|
2527
|
+
|
|
2326
2528
|
:param str symbol: unified symbol of the market to fetch the order book for
|
|
2327
2529
|
:param int [limit]: the maximum amount of order book entries to return
|
|
2328
2530
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
@@ -2534,6 +2736,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2534
2736
|
def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
2535
2737
|
"""
|
|
2536
2738
|
fetch all the trades made from a single order
|
|
2739
|
+
|
|
2740
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-the-match-result-of-an-order
|
|
2741
|
+
|
|
2537
2742
|
:param str id: order id
|
|
2538
2743
|
:param str symbol: unified market symbol
|
|
2539
2744
|
:param int [since]: the earliest time in ms to fetch trades for
|
|
@@ -2551,6 +2756,19 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2551
2756
|
return self.fetch_spot_order_trades(id, symbol, since, limit, params)
|
|
2552
2757
|
|
|
2553
2758
|
def fetch_spot_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
2759
|
+
"""
|
|
2760
|
+
@ignore
|
|
2761
|
+
fetch all the trades made from a single order
|
|
2762
|
+
|
|
2763
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-the-match-result-of-an-order
|
|
2764
|
+
|
|
2765
|
+
:param str id: order id
|
|
2766
|
+
:param str symbol: unified market symbol
|
|
2767
|
+
:param int [since]: the earliest time in ms to fetch trades for
|
|
2768
|
+
:param int [limit]: the maximum number of trades to retrieve
|
|
2769
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2770
|
+
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
|
2771
|
+
"""
|
|
2554
2772
|
self.load_markets()
|
|
2555
2773
|
request: dict = {
|
|
2556
2774
|
'order-id': id,
|
|
@@ -2560,9 +2778,11 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2560
2778
|
|
|
2561
2779
|
def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
2562
2780
|
"""
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2781
|
+
|
|
2782
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-match-results-via-multiple-fields-new
|
|
2783
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-match-results-via-multiple-fields-new
|
|
2784
|
+
https://huobiapi.github.io/docs/spot/v1/en/#search-match-results
|
|
2785
|
+
|
|
2566
2786
|
fetch all trades made by the user
|
|
2567
2787
|
:param str symbol: unified market symbol
|
|
2568
2788
|
:param int [since]: the earliest time in ms to fetch trades for
|
|
@@ -2713,10 +2933,12 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2713
2933
|
|
|
2714
2934
|
def fetch_trades(self, symbol: str, since: Int = None, limit: Int = 1000, params={}) -> List[Trade]:
|
|
2715
2935
|
"""
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2936
|
+
|
|
2937
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-the-most-recent-trades
|
|
2938
|
+
https://huobiapi.github.io/docs/dm/v1/en/#query-a-batch-of-trade-records-of-a-contract
|
|
2939
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-a-batch-of-trade-records-of-a-contract
|
|
2940
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-a-batch-of-trade-records-of-a-contract
|
|
2941
|
+
|
|
2720
2942
|
get the list of most recent trades for a particular symbol
|
|
2721
2943
|
:param str symbol: unified symbol of the market to fetch trades for
|
|
2722
2944
|
:param int [since]: timestamp in ms of the earliest trade to fetch
|
|
@@ -2808,10 +3030,12 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2808
3030
|
def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
|
2809
3031
|
"""
|
|
2810
3032
|
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
3033
|
+
|
|
3034
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-klines-candles
|
|
3035
|
+
https://huobiapi.github.io/docs/dm/v1/en/#get-kline-data
|
|
3036
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-kline-data
|
|
3037
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
|
|
3038
|
+
|
|
2815
3039
|
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
|
2816
3040
|
:param str timeframe: the length of time each candle represents
|
|
2817
3041
|
:param int [since]: timestamp in ms of the earliest candle to fetch
|
|
@@ -2935,6 +3159,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2935
3159
|
def fetch_accounts(self, params={}) -> List[Account]:
|
|
2936
3160
|
"""
|
|
2937
3161
|
fetch all the accounts associated with a profile
|
|
3162
|
+
|
|
3163
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
|
|
3164
|
+
|
|
2938
3165
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
2939
3166
|
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
|
|
2940
3167
|
"""
|
|
@@ -2971,7 +3198,18 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2971
3198
|
'code': None,
|
|
2972
3199
|
}
|
|
2973
3200
|
|
|
2974
|
-
def fetch_account_id_by_type(self, type, marginMode=None, symbol=None, params={}):
|
|
3201
|
+
def fetch_account_id_by_type(self, type: str, marginMode: Str = None, symbol: Str = None, params={}):
|
|
3202
|
+
"""
|
|
3203
|
+
fetch all the accounts by a type and marginModeassociated with a profile
|
|
3204
|
+
|
|
3205
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
|
|
3206
|
+
|
|
3207
|
+
:param str type: 'spot', 'swap' or 'future
|
|
3208
|
+
:param str [marginMode]: 'cross' or 'isolated'
|
|
3209
|
+
:param str [symbol]: unified ccxt market symbol
|
|
3210
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
3211
|
+
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
|
|
3212
|
+
"""
|
|
2975
3213
|
accounts = self.load_accounts()
|
|
2976
3214
|
accountId = self.safe_value_2(params, 'accountId', 'account-id')
|
|
2977
3215
|
if accountId is not None:
|
|
@@ -2981,7 +3219,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2981
3219
|
type = 'super-margin'
|
|
2982
3220
|
elif marginMode == 'isolated':
|
|
2983
3221
|
type = 'margin'
|
|
2984
|
-
marketId = None
|
|
3222
|
+
marketId = None
|
|
3223
|
+
if symbol is not None:
|
|
3224
|
+
marketId = self.market_id(symbol)
|
|
2985
3225
|
for i in range(0, len(accounts)):
|
|
2986
3226
|
account = accounts[i]
|
|
2987
3227
|
info = self.safe_value(account, 'info')
|
|
@@ -2998,6 +3238,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
2998
3238
|
def fetch_currencies(self, params={}) -> Currencies:
|
|
2999
3239
|
"""
|
|
3000
3240
|
fetches all available currencies on an exchange
|
|
3241
|
+
|
|
3242
|
+
https://huobiapi.github.io/docs/spot/v1/en/#apiv2-currency-amp-chains
|
|
3243
|
+
|
|
3001
3244
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
3002
3245
|
:returns dict: an associative dictionary of currencies
|
|
3003
3246
|
"""
|
|
@@ -3028,7 +3271,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3028
3271
|
# "withdrawQuotaPerYear": null,
|
|
3029
3272
|
# "withdrawQuotaTotal": null,
|
|
3030
3273
|
# "withdrawFeeType": "fixed",
|
|
3031
|
-
# "transactFeeWithdraw": "11.
|
|
3274
|
+
# "transactFeeWithdraw": "11.1654",
|
|
3032
3275
|
# "addrWithTag": False,
|
|
3033
3276
|
# "addrDepositTag": False
|
|
3034
3277
|
# }
|
|
@@ -3037,9 +3280,8 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3037
3280
|
# }
|
|
3038
3281
|
# ]
|
|
3039
3282
|
# }
|
|
3040
|
-
# }
|
|
3041
3283
|
#
|
|
3042
|
-
data = self.
|
|
3284
|
+
data = self.safe_list(response, 'data', [])
|
|
3043
3285
|
result: dict = {}
|
|
3044
3286
|
self.options['networkChainIdsByNames'] = {}
|
|
3045
3287
|
self.options['networkNamesByChainIds'] = {}
|
|
@@ -3047,16 +3289,11 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3047
3289
|
entry = data[i]
|
|
3048
3290
|
currencyId = self.safe_string(entry, 'currency')
|
|
3049
3291
|
code = self.safe_currency_code(currencyId)
|
|
3292
|
+
assetType = self.safe_string(entry, 'assetType')
|
|
3293
|
+
type = assetType == 'crypto' if '1' else 'fiat'
|
|
3050
3294
|
self.options['networkChainIdsByNames'][code] = {}
|
|
3051
|
-
chains = self.
|
|
3295
|
+
chains = self.safe_list(entry, 'chains', [])
|
|
3052
3296
|
networks: dict = {}
|
|
3053
|
-
instStatus = self.safe_string(entry, 'instStatus')
|
|
3054
|
-
currencyActive = instStatus == 'normal'
|
|
3055
|
-
minPrecision = None
|
|
3056
|
-
minWithdraw = None
|
|
3057
|
-
maxWithdraw = None
|
|
3058
|
-
deposit = False
|
|
3059
|
-
withdraw = False
|
|
3060
3297
|
for j in range(0, len(chains)):
|
|
3061
3298
|
chainEntry = chains[j]
|
|
3062
3299
|
uniqueChainId = self.safe_string(chainEntry, 'chain') # i.e. usdterc20, trc20usdt ...
|
|
@@ -3064,65 +3301,53 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3064
3301
|
self.options['networkChainIdsByNames'][code][title] = uniqueChainId
|
|
3065
3302
|
self.options['networkNamesByChainIds'][uniqueChainId] = title
|
|
3066
3303
|
networkCode = self.network_id_to_code(uniqueChainId)
|
|
3067
|
-
minWithdraw = self.safe_number(chainEntry, 'minWithdrawAmt')
|
|
3068
|
-
maxWithdraw = self.safe_number(chainEntry, 'maxWithdrawAmt')
|
|
3069
|
-
withdrawStatus = self.safe_string(chainEntry, 'withdrawStatus')
|
|
3070
|
-
depositStatus = self.safe_string(chainEntry, 'depositStatus')
|
|
3071
|
-
withdrawEnabled = (withdrawStatus == 'allowed')
|
|
3072
|
-
depositEnabled = (depositStatus == 'allowed')
|
|
3073
|
-
withdraw = withdrawEnabled if (withdrawEnabled) else withdraw
|
|
3074
|
-
deposit = depositEnabled if (depositEnabled) else deposit
|
|
3075
|
-
active = withdrawEnabled and depositEnabled
|
|
3076
|
-
precision = self.parse_precision(self.safe_string(chainEntry, 'withdrawPrecision'))
|
|
3077
|
-
if precision is not None:
|
|
3078
|
-
minPrecision = precision if (minPrecision is None) else Precise.string_min(precision, minPrecision)
|
|
3079
|
-
fee = self.safe_number(chainEntry, 'transactFeeWithdraw')
|
|
3080
3304
|
networks[networkCode] = {
|
|
3081
3305
|
'info': chainEntry,
|
|
3082
3306
|
'id': uniqueChainId,
|
|
3083
3307
|
'network': networkCode,
|
|
3084
3308
|
'limits': {
|
|
3085
3309
|
'deposit': {
|
|
3086
|
-
'min':
|
|
3310
|
+
'min': self.safe_number(chainEntry, 'minDepositAmt'),
|
|
3087
3311
|
'max': None,
|
|
3088
3312
|
},
|
|
3089
3313
|
'withdraw': {
|
|
3090
|
-
'min':
|
|
3091
|
-
'max':
|
|
3314
|
+
'min': self.safe_number(chainEntry, 'minWithdrawAmt'),
|
|
3315
|
+
'max': self.safe_number(chainEntry, 'maxWithdrawAmt'),
|
|
3092
3316
|
},
|
|
3093
3317
|
},
|
|
3094
|
-
'active':
|
|
3095
|
-
'deposit':
|
|
3096
|
-
'withdraw':
|
|
3097
|
-
'fee':
|
|
3098
|
-
'precision': self.parse_number(
|
|
3318
|
+
'active': None,
|
|
3319
|
+
'deposit': self.safe_string(chainEntry, 'depositStatus') == 'allowed',
|
|
3320
|
+
'withdraw': self.safe_string(chainEntry, 'withdrawStatus') == 'allowed',
|
|
3321
|
+
'fee': self.safe_number(chainEntry, 'transactFeeWithdraw'),
|
|
3322
|
+
'precision': self.parse_number(self.parse_precision(self.safe_string(chainEntry, 'withdrawPrecision'))),
|
|
3099
3323
|
}
|
|
3100
|
-
result[code] = {
|
|
3324
|
+
result[code] = self.safe_currency_structure({
|
|
3101
3325
|
'info': entry,
|
|
3102
3326
|
'code': code,
|
|
3103
3327
|
'id': currencyId,
|
|
3104
|
-
'active':
|
|
3105
|
-
'deposit':
|
|
3106
|
-
'withdraw':
|
|
3328
|
+
'active': self.safe_string(entry, 'instStatus') == 'normal',
|
|
3329
|
+
'deposit': None,
|
|
3330
|
+
'withdraw': None,
|
|
3107
3331
|
'fee': None,
|
|
3108
3332
|
'name': None,
|
|
3333
|
+
'type': type,
|
|
3109
3334
|
'limits': {
|
|
3110
3335
|
'amount': {
|
|
3111
3336
|
'min': None,
|
|
3112
3337
|
'max': None,
|
|
3113
3338
|
},
|
|
3114
3339
|
'withdraw': {
|
|
3115
|
-
'min':
|
|
3116
|
-
'max':
|
|
3340
|
+
'min': None,
|
|
3341
|
+
'max': None,
|
|
3117
3342
|
},
|
|
3118
3343
|
'deposit': {
|
|
3119
3344
|
'min': None,
|
|
3120
3345
|
'max': None,
|
|
3121
3346
|
},
|
|
3122
3347
|
},
|
|
3123
|
-
'precision':
|
|
3348
|
+
'precision': None,
|
|
3124
3349
|
'networks': networks,
|
|
3125
|
-
}
|
|
3350
|
+
})
|
|
3126
3351
|
return result
|
|
3127
3352
|
|
|
3128
3353
|
def network_id_to_code(self, networkId: Str = None, currencyCode: Str = None):
|
|
@@ -3150,13 +3375,15 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3150
3375
|
|
|
3151
3376
|
def fetch_balance(self, params={}) -> Balances:
|
|
3152
3377
|
"""
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3378
|
+
|
|
3379
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-account-balance-of-a-specific-account
|
|
3380
|
+
https://www.htx.com/en-us/opend/newApiPages/?id=7ec4b429-7773-11ed-9966-0242ac110003
|
|
3381
|
+
https://www.htx.com/en-us/opend/newApiPages/?id=10000074-77b7-11ed-9966-0242ac110003
|
|
3382
|
+
https://huobiapi.github.io/docs/dm/v1/en/#query-asset-valuation
|
|
3383
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-user-s-account-information
|
|
3384
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-user-s-account-information
|
|
3385
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-query-user-39-s-account-information
|
|
3386
|
+
|
|
3160
3387
|
query for balance and get the amount of funds available for trading or funds locked in orders
|
|
3161
3388
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
3162
3389
|
:param bool [params.unified]: provide self parameter if you have a recent account with unified cross+isolated margin account
|
|
@@ -3455,6 +3682,15 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3455
3682
|
def fetch_order(self, id: str, symbol: Str = None, params={}):
|
|
3456
3683
|
"""
|
|
3457
3684
|
fetches information on an order made by the user
|
|
3685
|
+
|
|
3686
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-the-order-detail-of-an-order-based-on-client-order-id
|
|
3687
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-the-order-detail-of-an-order
|
|
3688
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-information-of-an-order
|
|
3689
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-information-of-order
|
|
3690
|
+
https://huobiapi.github.io/docs/dm/v1/en/#get-information-of-an-order
|
|
3691
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-information-of-an-order
|
|
3692
|
+
|
|
3693
|
+
:param str id: order id
|
|
3458
3694
|
:param str symbol: unified symbol of the market the order was made in
|
|
3459
3695
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
3460
3696
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
|
@@ -3746,11 +3982,11 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3746
3982
|
'status': '0', # support multiple query seperated by ',',such as '3,4,5', 0: all. 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled
|
|
3747
3983
|
}
|
|
3748
3984
|
response = None
|
|
3749
|
-
|
|
3985
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
|
3750
3986
|
stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
|
|
3751
3987
|
trailing = self.safe_bool(params, 'trailing', False)
|
|
3752
|
-
params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing'])
|
|
3753
|
-
if
|
|
3988
|
+
params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger'])
|
|
3989
|
+
if trigger or stopLossTakeProfit or trailing:
|
|
3754
3990
|
if limit is not None:
|
|
3755
3991
|
request['page_size'] = limit
|
|
3756
3992
|
request['contract_code'] = market['id']
|
|
@@ -3767,7 +4003,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3767
4003
|
marginMode, params = self.handle_margin_mode_and_params('fetchContractOrders', params)
|
|
3768
4004
|
marginMode = 'cross' if (marginMode is None) else marginMode
|
|
3769
4005
|
if marginMode == 'isolated':
|
|
3770
|
-
if
|
|
4006
|
+
if trigger:
|
|
3771
4007
|
response = self.contractPrivatePostLinearSwapApiV1SwapTriggerHisorders(self.extend(request, params))
|
|
3772
4008
|
elif stopLossTakeProfit:
|
|
3773
4009
|
response = self.contractPrivatePostLinearSwapApiV1SwapTpslHisorders(self.extend(request, params))
|
|
@@ -3776,7 +4012,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3776
4012
|
else:
|
|
3777
4013
|
response = self.contractPrivatePostLinearSwapApiV3SwapHisorders(self.extend(request, params))
|
|
3778
4014
|
elif marginMode == 'cross':
|
|
3779
|
-
if
|
|
4015
|
+
if trigger:
|
|
3780
4016
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerHisorders(self.extend(request, params))
|
|
3781
4017
|
elif stopLossTakeProfit:
|
|
3782
4018
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTpslHisorders(self.extend(request, params))
|
|
@@ -3786,7 +4022,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3786
4022
|
response = self.contractPrivatePostLinearSwapApiV3SwapCrossHisorders(self.extend(request, params))
|
|
3787
4023
|
elif market['inverse']:
|
|
3788
4024
|
if market['swap']:
|
|
3789
|
-
if
|
|
4025
|
+
if trigger:
|
|
3790
4026
|
response = self.contractPrivatePostSwapApiV1SwapTriggerHisorders(self.extend(request, params))
|
|
3791
4027
|
elif stopLossTakeProfit:
|
|
3792
4028
|
response = self.contractPrivatePostSwapApiV1SwapTpslHisorders(self.extend(request, params))
|
|
@@ -3796,7 +4032,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3796
4032
|
response = self.contractPrivatePostSwapApiV3SwapHisorders(self.extend(request, params))
|
|
3797
4033
|
elif market['future']:
|
|
3798
4034
|
request['symbol'] = market['settleId']
|
|
3799
|
-
if
|
|
4035
|
+
if trigger:
|
|
3800
4036
|
response = self.contractPrivatePostApiV1ContractTriggerHisorders(self.extend(request, params))
|
|
3801
4037
|
elif stopLossTakeProfit:
|
|
3802
4038
|
response = self.contractPrivatePostApiV1ContractTpslHisorders(self.extend(request, params))
|
|
@@ -3959,18 +4195,20 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3959
4195
|
|
|
3960
4196
|
def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
|
3961
4197
|
"""
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
4198
|
+
|
|
4199
|
+
https://huobiapi.github.io/docs/spot/v1/en/#search-past-orders
|
|
4200
|
+
https://huobiapi.github.io/docs/spot/v1/en/#search-historical-orders-within-48-hours
|
|
4201
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-orders-new
|
|
4202
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-orders-new
|
|
4203
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-history-orders-new
|
|
4204
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-history-orders-via-multiple-fields-new
|
|
4205
|
+
|
|
3968
4206
|
fetches information on multiple orders made by the user
|
|
3969
4207
|
:param str symbol: unified market symbol of the market orders were made in
|
|
3970
4208
|
:param int [since]: the earliest time in ms to fetch orders for
|
|
3971
4209
|
:param int [limit]: the maximum number of order structures to retrieve
|
|
3972
4210
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
3973
|
-
:param bool [params.
|
|
4211
|
+
:param bool [params.trigger]: *contract only* if the orders are trigger trigger orders or not
|
|
3974
4212
|
:param bool [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
|
|
3975
4213
|
:param int [params.until]: the latest time in ms to fetch entries for
|
|
3976
4214
|
:param boolean [params.trailing]: *contract only* set to True if you want to fetch trailing stop orders
|
|
@@ -3992,12 +4230,14 @@ class htx(Exchange, ImplicitAPI):
|
|
|
3992
4230
|
|
|
3993
4231
|
def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
|
3994
4232
|
"""
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4233
|
+
|
|
4234
|
+
https://huobiapi.github.io/docs/spot/v1/en/#search-past-orders
|
|
4235
|
+
https://huobiapi.github.io/docs/spot/v1/en/#search-historical-orders-within-48-hours
|
|
4236
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-orders-new
|
|
4237
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-orders-new
|
|
4238
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-history-orders-new
|
|
4239
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-history-orders-via-multiple-fields-new
|
|
4240
|
+
|
|
4001
4241
|
fetches information on multiple closed orders made by the user
|
|
4002
4242
|
:param str symbol: unified market symbol of the market orders were made in
|
|
4003
4243
|
:param int [since]: the earliest time in ms to fetch orders for
|
|
@@ -4024,15 +4264,17 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4024
4264
|
|
|
4025
4265
|
def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
|
4026
4266
|
"""
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4267
|
+
|
|
4268
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-all-open-orders
|
|
4269
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-current-unfilled-order-acquisition
|
|
4270
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-current-unfilled-order-acquisition
|
|
4271
|
+
|
|
4030
4272
|
fetch all unfilled currently open orders
|
|
4031
4273
|
:param str symbol: unified market symbol
|
|
4032
4274
|
:param int [since]: the earliest time in ms to fetch open orders for
|
|
4033
4275
|
:param int [limit]: the maximum number of open order structures to retrieve
|
|
4034
4276
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
4035
|
-
:param bool [params.
|
|
4277
|
+
:param bool [params.trigger]: *contract only* if the orders are trigger trigger orders or not
|
|
4036
4278
|
:param bool [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
|
|
4037
4279
|
:param boolean [params.trailing]: *contract only* set to True if you want to fetch trailing stop orders
|
|
4038
4280
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
|
@@ -4044,6 +4286,8 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4044
4286
|
request: dict = {}
|
|
4045
4287
|
marketType = None
|
|
4046
4288
|
marketType, params = self.handle_market_type_and_params('fetchOpenOrders', market, params)
|
|
4289
|
+
subType = None
|
|
4290
|
+
subType, params = self.handle_sub_type_and_params('fetchOpenOrders', market, params, 'linear')
|
|
4047
4291
|
response = None
|
|
4048
4292
|
if marketType == 'spot':
|
|
4049
4293
|
if symbol is not None:
|
|
@@ -4055,7 +4299,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4055
4299
|
self.load_accounts()
|
|
4056
4300
|
for i in range(0, len(self.accounts)):
|
|
4057
4301
|
account = self.accounts[i]
|
|
4058
|
-
if account
|
|
4302
|
+
if self.safe_string(account, 'type') == 'spot':
|
|
4059
4303
|
accountId = self.safe_string(account, 'id')
|
|
4060
4304
|
if accountId is not None:
|
|
4061
4305
|
break
|
|
@@ -4065,21 +4309,21 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4065
4309
|
params = self.omit(params, 'account-id')
|
|
4066
4310
|
response = self.spotPrivateGetV1OrderOpenOrders(self.extend(request, params))
|
|
4067
4311
|
else:
|
|
4068
|
-
if symbol is None:
|
|
4069
|
-
raise ArgumentsRequired(self.id + ' fetchOpenOrders() requires a symbol argument')
|
|
4312
|
+
if symbol is not None:
|
|
4313
|
+
# raise ArgumentsRequired(self.id + ' fetchOpenOrders() requires a symbol argument')
|
|
4314
|
+
request['contract_code'] = market['id']
|
|
4070
4315
|
if limit is not None:
|
|
4071
4316
|
request['page_size'] = limit
|
|
4072
|
-
|
|
4073
|
-
stop = self.safe_value(params, 'stop')
|
|
4317
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
|
4074
4318
|
stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
|
|
4075
4319
|
trailing = self.safe_bool(params, 'trailing', False)
|
|
4076
|
-
params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing'])
|
|
4077
|
-
if
|
|
4320
|
+
params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger'])
|
|
4321
|
+
if subType == 'linear':
|
|
4078
4322
|
marginMode = None
|
|
4079
4323
|
marginMode, params = self.handle_margin_mode_and_params('fetchOpenOrders', params)
|
|
4080
4324
|
marginMode = 'cross' if (marginMode is None) else marginMode
|
|
4081
4325
|
if marginMode == 'isolated':
|
|
4082
|
-
if
|
|
4326
|
+
if trigger:
|
|
4083
4327
|
response = self.contractPrivatePostLinearSwapApiV1SwapTriggerOpenorders(self.extend(request, params))
|
|
4084
4328
|
elif stopLossTakeProfit:
|
|
4085
4329
|
response = self.contractPrivatePostLinearSwapApiV1SwapTpslOpenorders(self.extend(request, params))
|
|
@@ -4088,7 +4332,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4088
4332
|
else:
|
|
4089
4333
|
response = self.contractPrivatePostLinearSwapApiV1SwapOpenorders(self.extend(request, params))
|
|
4090
4334
|
elif marginMode == 'cross':
|
|
4091
|
-
if
|
|
4335
|
+
if trigger:
|
|
4092
4336
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerOpenorders(self.extend(request, params))
|
|
4093
4337
|
elif stopLossTakeProfit:
|
|
4094
4338
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTpslOpenorders(self.extend(request, params))
|
|
@@ -4096,9 +4340,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4096
4340
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTrackOpenorders(self.extend(request, params))
|
|
4097
4341
|
else:
|
|
4098
4342
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossOpenorders(self.extend(request, params))
|
|
4099
|
-
elif
|
|
4100
|
-
if
|
|
4101
|
-
if
|
|
4343
|
+
elif subType == 'inverse':
|
|
4344
|
+
if marketType == 'swap':
|
|
4345
|
+
if trigger:
|
|
4102
4346
|
response = self.contractPrivatePostSwapApiV1SwapTriggerOpenorders(self.extend(request, params))
|
|
4103
4347
|
elif stopLossTakeProfit:
|
|
4104
4348
|
response = self.contractPrivatePostSwapApiV1SwapTpslOpenorders(self.extend(request, params))
|
|
@@ -4106,9 +4350,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4106
4350
|
response = self.contractPrivatePostSwapApiV1SwapTrackOpenorders(self.extend(request, params))
|
|
4107
4351
|
else:
|
|
4108
4352
|
response = self.contractPrivatePostSwapApiV1SwapOpenorders(self.extend(request, params))
|
|
4109
|
-
elif
|
|
4110
|
-
request['symbol'] = market
|
|
4111
|
-
if
|
|
4353
|
+
elif marketType == 'future':
|
|
4354
|
+
request['symbol'] = self.safe_string(market, 'settleId', 'usdt')
|
|
4355
|
+
if trigger:
|
|
4112
4356
|
response = self.contractPrivatePostApiV1ContractTriggerOpenorders(self.extend(request, params))
|
|
4113
4357
|
elif stopLossTakeProfit:
|
|
4114
4358
|
response = self.contractPrivatePostApiV1ContractTpslOpenorders(self.extend(request, params))
|
|
@@ -4703,14 +4947,10 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4703
4947
|
cost = None
|
|
4704
4948
|
amount = None
|
|
4705
4949
|
if (type is not None) and (type.find('market') >= 0):
|
|
4706
|
-
|
|
4707
|
-
if side == 'sell':
|
|
4708
|
-
cost = self.safe_string(order, 'field-cash-amount')
|
|
4709
|
-
else:
|
|
4710
|
-
cost = self.safe_string(order, 'amount')
|
|
4950
|
+
cost = self.safe_string(order, 'field-cash-amount')
|
|
4711
4951
|
else:
|
|
4712
4952
|
amount = self.safe_string_2(order, 'volume', 'amount')
|
|
4713
|
-
cost = self.safe_string_n(order, ['filled-cash-amount', 'field-cash-amount', 'trade_turnover']) # same typo
|
|
4953
|
+
cost = self.safe_string_n(order, ['filled-cash-amount', 'field-cash-amount', 'trade_turnover']) # same typo here
|
|
4714
4954
|
filled = self.safe_string_n(order, ['filled-amount', 'field-amount', 'trade_volume']) # typo in their API, filled amount
|
|
4715
4955
|
price = self.safe_string_2(order, 'price', 'order_price')
|
|
4716
4956
|
feeCost = self.safe_string_2(order, 'filled-fees', 'field-fees') # typo in their API, filled feeSide
|
|
@@ -4727,7 +4967,6 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4727
4967
|
'cost': feeCost,
|
|
4728
4968
|
'currency': feeCurrency,
|
|
4729
4969
|
}
|
|
4730
|
-
stopPrice = self.safe_string_2(order, 'stop-price', 'trigger_price')
|
|
4731
4970
|
average = self.safe_string(order, 'trade_avg_price')
|
|
4732
4971
|
trades = self.safe_value(order, 'trades')
|
|
4733
4972
|
reduceOnlyInteger = self.safe_integer(order, 'reduce_only')
|
|
@@ -4747,8 +4986,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4747
4986
|
'postOnly': None,
|
|
4748
4987
|
'side': side,
|
|
4749
4988
|
'price': price,
|
|
4750
|
-
'
|
|
4751
|
-
'triggerPrice': stopPrice,
|
|
4989
|
+
'triggerPrice': self.safe_string_2(order, 'stop-price', 'trigger_price'),
|
|
4752
4990
|
'average': average,
|
|
4753
4991
|
'cost': cost,
|
|
4754
4992
|
'amount': amount,
|
|
@@ -4763,7 +5001,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4763
5001
|
def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
|
|
4764
5002
|
"""
|
|
4765
5003
|
create a market buy order by providing the symbol and cost
|
|
4766
|
-
|
|
5004
|
+
|
|
5005
|
+
https://www.htx.com/en-us/opend/newApiPages/?id=7ec4ee16-7773-11ed-9966-0242ac110003
|
|
5006
|
+
|
|
4767
5007
|
:param str symbol: unified symbol of the market to create an order in
|
|
4768
5008
|
:param float cost: how much you want to trade in units of the quote currency
|
|
4769
5009
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
@@ -4776,7 +5016,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4776
5016
|
params['createMarketBuyOrderRequiresPrice'] = False
|
|
4777
5017
|
return self.create_order(symbol, 'market', 'buy', cost, None, params)
|
|
4778
5018
|
|
|
4779
|
-
def create_trailing_percent_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, trailingPercent=None, trailingTriggerPrice=None, params={}) -> Order:
|
|
5019
|
+
def create_trailing_percent_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, trailingPercent: Num = None, trailingTriggerPrice: Num = None, params={}) -> Order:
|
|
4780
5020
|
"""
|
|
4781
5021
|
create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
|
|
4782
5022
|
:param str symbol: unified symbol of the market to create an order in
|
|
@@ -4799,13 +5039,13 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4799
5039
|
|
|
4800
5040
|
def create_spot_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
|
4801
5041
|
"""
|
|
4802
|
-
|
|
5042
|
+
@ignore
|
|
4803
5043
|
helper function to build request
|
|
4804
5044
|
:param str symbol: unified symbol of the market to create an order in
|
|
4805
5045
|
:param str type: 'market' or 'limit'
|
|
4806
5046
|
:param str side: 'buy' or 'sell'
|
|
4807
5047
|
:param float amount: how much you want to trade in units of the base currency
|
|
4808
|
-
:param float [price]: the price at which the order is to be
|
|
5048
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
4809
5049
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
4810
5050
|
:param str [params.timeInForce]: supports 'IOC' and 'FOK'
|
|
4811
5051
|
:param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
|
|
@@ -4832,15 +5072,15 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4832
5072
|
orderType = type.replace('buy-', '')
|
|
4833
5073
|
orderType = orderType.replace('sell-', '')
|
|
4834
5074
|
options = self.safe_value(self.options, market['type'], {})
|
|
4835
|
-
|
|
4836
|
-
if
|
|
5075
|
+
triggerPrice = self.safe_string_n(params, ['triggerPrice', 'stopPrice', 'stop-price'])
|
|
5076
|
+
if triggerPrice is None:
|
|
4837
5077
|
stopOrderTypes = self.safe_value(options, 'stopOrderTypes', {})
|
|
4838
5078
|
if orderType in stopOrderTypes:
|
|
4839
|
-
raise ArgumentsRequired(self.id + ' createOrder() requires a
|
|
5079
|
+
raise ArgumentsRequired(self.id + ' createOrder() requires a triggerPrice for a trigger order')
|
|
4840
5080
|
else:
|
|
4841
5081
|
defaultOperator = 'lte' if (side == 'sell') else 'gte'
|
|
4842
5082
|
stopOperator = self.safe_string(params, 'operator', defaultOperator)
|
|
4843
|
-
request['stop-price'] = self.price_to_precision(symbol,
|
|
5083
|
+
request['stop-price'] = self.price_to_precision(symbol, triggerPrice)
|
|
4844
5084
|
request['operator'] = stopOperator
|
|
4845
5085
|
if (orderType == 'limit') or (orderType == 'limit-fok'):
|
|
4846
5086
|
orderType = 'stop-' + orderType
|
|
@@ -4898,18 +5138,18 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4898
5138
|
limitOrderTypes = self.safe_value(options, 'limitOrderTypes', {})
|
|
4899
5139
|
if orderType in limitOrderTypes:
|
|
4900
5140
|
request['price'] = self.price_to_precision(symbol, price)
|
|
4901
|
-
params = self.omit(params, ['stopPrice', 'stop-price', 'clientOrderId', 'client-order-id', 'operator', 'timeInForce'])
|
|
5141
|
+
params = self.omit(params, ['triggerPrice', 'stopPrice', 'stop-price', 'clientOrderId', 'client-order-id', 'operator', 'timeInForce'])
|
|
4902
5142
|
return self.extend(request, params)
|
|
4903
5143
|
|
|
4904
5144
|
def create_contract_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
|
4905
5145
|
"""
|
|
4906
|
-
|
|
5146
|
+
@ignore
|
|
4907
5147
|
helper function to build request
|
|
4908
5148
|
:param str symbol: unified symbol of the market to create an order in
|
|
4909
5149
|
:param str type: 'market' or 'limit'
|
|
4910
5150
|
:param str side: 'buy' or 'sell'
|
|
4911
5151
|
:param float amount: how much you want to trade in units of the base currency
|
|
4912
|
-
:param float [price]: the price at which the order is to be
|
|
5152
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
4913
5153
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
4914
5154
|
:param str [params.timeInForce]: supports 'IOC' and 'FOK'
|
|
4915
5155
|
:param float [params.trailingPercent]: *contract only* the percent to trail away from the current market price
|
|
@@ -4931,16 +5171,16 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4931
5171
|
type = 'fok'
|
|
4932
5172
|
elif timeInForce == 'IOC':
|
|
4933
5173
|
type = 'ioc'
|
|
4934
|
-
triggerPrice = self.
|
|
5174
|
+
triggerPrice = self.safe_number_n(params, ['triggerPrice', 'stopPrice', 'trigger_price'])
|
|
4935
5175
|
stopLossTriggerPrice = self.safe_number_2(params, 'stopLossPrice', 'sl_trigger_price')
|
|
4936
5176
|
takeProfitTriggerPrice = self.safe_number_2(params, 'takeProfitPrice', 'tp_trigger_price')
|
|
4937
5177
|
trailingPercent = self.safe_string_2(params, 'trailingPercent', 'callback_rate')
|
|
4938
5178
|
trailingTriggerPrice = self.safe_number(params, 'trailingTriggerPrice', price)
|
|
4939
5179
|
isTrailingPercentOrder = trailingPercent is not None
|
|
4940
|
-
|
|
5180
|
+
isTrigger = triggerPrice is not None
|
|
4941
5181
|
isStopLossTriggerOrder = stopLossTriggerPrice is not None
|
|
4942
5182
|
isTakeProfitTriggerOrder = takeProfitTriggerPrice is not None
|
|
4943
|
-
if
|
|
5183
|
+
if isTrigger:
|
|
4944
5184
|
triggerType = self.safe_string_2(params, 'triggerType', 'trigger_type', 'le')
|
|
4945
5185
|
request['trigger_type'] = triggerType
|
|
4946
5186
|
request['trigger_price'] = self.price_to_precision(symbol, triggerPrice)
|
|
@@ -4969,38 +5209,48 @@ class htx(Exchange, ImplicitAPI):
|
|
|
4969
5209
|
params = self.omit(params, ['clientOrderId'])
|
|
4970
5210
|
if type == 'limit' or type == 'ioc' or type == 'fok' or type == 'post_only':
|
|
4971
5211
|
request['price'] = self.price_to_precision(symbol, price)
|
|
5212
|
+
reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only', False)
|
|
4972
5213
|
if not isStopLossTriggerOrder and not isTakeProfitTriggerOrder:
|
|
4973
|
-
reduceOnly = self.safe_value_2(params, 'reduceOnly', 'reduce_only', False)
|
|
4974
5214
|
if reduceOnly:
|
|
4975
5215
|
request['reduce_only'] = 1
|
|
4976
5216
|
request['lever_rate'] = self.safe_integer_n(params, ['leverRate', 'lever_rate', 'leverage'], 1)
|
|
4977
5217
|
if not isTrailingPercentOrder:
|
|
4978
5218
|
request['order_price_type'] = type
|
|
5219
|
+
hedged = self.safe_bool(params, 'hedged', False)
|
|
5220
|
+
if hedged:
|
|
5221
|
+
if reduceOnly:
|
|
5222
|
+
request['offset'] = 'close'
|
|
5223
|
+
else:
|
|
5224
|
+
request['offset'] = 'open'
|
|
4979
5225
|
broker = self.safe_value(self.options, 'broker', {})
|
|
4980
5226
|
brokerId = self.safe_string(broker, 'id')
|
|
4981
5227
|
request['channel_code'] = brokerId
|
|
4982
|
-
params = self.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice'])
|
|
5228
|
+
params = self.omit(params, ['reduceOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice', 'hedged'])
|
|
4983
5229
|
return self.extend(request, params)
|
|
4984
5230
|
|
|
4985
5231
|
def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
|
4986
5232
|
"""
|
|
4987
5233
|
create a trade order
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
5234
|
+
|
|
5235
|
+
https://huobiapi.github.io/docs/spot/v1/en/#place-a-new-order # spot, margin
|
|
5236
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-an-order # coin-m swap
|
|
5237
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-trigger-order # coin-m swap trigger
|
|
5238
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-an-order # usdt-m swap cross
|
|
5239
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-trigger-order # usdt-m swap cross trigger
|
|
5240
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order # usdt-m swap isolated
|
|
5241
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-trigger-order # usdt-m swap isolated trigger
|
|
5242
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-set-a-take-profit-and-stop-loss-order-for-an-existing-position
|
|
5243
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-set-a-take-profit-and-stop-loss-order-for-an-existing-position
|
|
5244
|
+
https://huobiapi.github.io/docs/dm/v1/en/#place-an-order # coin-m futures
|
|
5245
|
+
https://huobiapi.github.io/docs/dm/v1/en/#place-trigger-order # coin-m futures contract trigger
|
|
5246
|
+
|
|
4997
5247
|
:param str symbol: unified symbol of the market to create an order in
|
|
4998
5248
|
:param str type: 'market' or 'limit'
|
|
4999
5249
|
:param str side: 'buy' or 'sell'
|
|
5000
5250
|
:param float amount: how much you want to trade in units of the base currency
|
|
5001
|
-
:param float [price]: the price at which the order is to be
|
|
5251
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
5002
5252
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
5003
|
-
:param float [params.
|
|
5253
|
+
:param float [params.triggerPrice]: the price a trigger order is triggered at
|
|
5004
5254
|
:param str [params.triggerType]: *contract trigger orders only* ge: greater than or equal to, le: less than or equal to
|
|
5005
5255
|
:param float [params.stopLossPrice]: *contract only* the price a stop-loss order is triggered at
|
|
5006
5256
|
:param float [params.takeProfitPrice]: *contract only* the price a take-profit order is triggered at
|
|
@@ -5012,16 +5262,17 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5012
5262
|
:param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
|
|
5013
5263
|
:param float [params.trailingPercent]: *contract only* the percent to trail away from the current market price
|
|
5014
5264
|
:param float [params.trailingTriggerPrice]: *contract only* the price to trigger a trailing order, default uses the price argument
|
|
5265
|
+
:param bool [params.hedged]: *contract only* True for hedged mode, False for one way mode, default is False
|
|
5015
5266
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
|
5016
5267
|
"""
|
|
5017
5268
|
self.load_markets()
|
|
5018
5269
|
market = self.market(symbol)
|
|
5019
|
-
triggerPrice = self.
|
|
5270
|
+
triggerPrice = self.safe_number_n(params, ['triggerPrice', 'stopPrice', 'trigger_price'])
|
|
5020
5271
|
stopLossTriggerPrice = self.safe_number_2(params, 'stopLossPrice', 'sl_trigger_price')
|
|
5021
5272
|
takeProfitTriggerPrice = self.safe_number_2(params, 'takeProfitPrice', 'tp_trigger_price')
|
|
5022
5273
|
trailingPercent = self.safe_number(params, 'trailingPercent')
|
|
5023
5274
|
isTrailingPercentOrder = trailingPercent is not None
|
|
5024
|
-
|
|
5275
|
+
isTrigger = triggerPrice is not None
|
|
5025
5276
|
isStopLossTriggerOrder = stopLossTriggerPrice is not None
|
|
5026
5277
|
isTakeProfitTriggerOrder = takeProfitTriggerPrice is not None
|
|
5027
5278
|
response = None
|
|
@@ -5037,7 +5288,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5037
5288
|
marginMode, contractRequest = self.handle_margin_mode_and_params('createOrder', contractRequest)
|
|
5038
5289
|
marginMode = 'cross' if (marginMode is None) else marginMode
|
|
5039
5290
|
if marginMode == 'isolated':
|
|
5040
|
-
if
|
|
5291
|
+
if isTrigger:
|
|
5041
5292
|
response = self.contractPrivatePostLinearSwapApiV1SwapTriggerOrder(contractRequest)
|
|
5042
5293
|
elif isStopLossTriggerOrder or isTakeProfitTriggerOrder:
|
|
5043
5294
|
response = self.contractPrivatePostLinearSwapApiV1SwapTpslOrder(contractRequest)
|
|
@@ -5046,7 +5297,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5046
5297
|
else:
|
|
5047
5298
|
response = self.contractPrivatePostLinearSwapApiV1SwapOrder(contractRequest)
|
|
5048
5299
|
elif marginMode == 'cross':
|
|
5049
|
-
if
|
|
5300
|
+
if isTrigger:
|
|
5050
5301
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerOrder(contractRequest)
|
|
5051
5302
|
elif isStopLossTriggerOrder or isTakeProfitTriggerOrder:
|
|
5052
5303
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder(contractRequest)
|
|
@@ -5059,7 +5310,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5059
5310
|
if offset is None:
|
|
5060
5311
|
raise ArgumentsRequired(self.id + ' createOrder() requires an extra parameter params["offset"] to be set to "open" or "close" when placing orders in inverse markets')
|
|
5061
5312
|
if market['swap']:
|
|
5062
|
-
if
|
|
5313
|
+
if isTrigger:
|
|
5063
5314
|
response = self.contractPrivatePostSwapApiV1SwapTriggerOrder(contractRequest)
|
|
5064
5315
|
elif isStopLossTriggerOrder or isTakeProfitTriggerOrder:
|
|
5065
5316
|
response = self.contractPrivatePostSwapApiV1SwapTpslOrder(contractRequest)
|
|
@@ -5068,7 +5319,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5068
5319
|
else:
|
|
5069
5320
|
response = self.contractPrivatePostSwapApiV1SwapOrder(contractRequest)
|
|
5070
5321
|
elif market['future']:
|
|
5071
|
-
if
|
|
5322
|
+
if isTrigger:
|
|
5072
5323
|
response = self.contractPrivatePostApiV1ContractTriggerOrder(contractRequest)
|
|
5073
5324
|
elif isStopLossTriggerOrder or isTakeProfitTriggerOrder:
|
|
5074
5325
|
response = self.contractPrivatePostApiV1ContractTpslOrder(contractRequest)
|
|
@@ -5142,11 +5393,13 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5142
5393
|
def create_orders(self, orders: List[OrderRequest], params={}):
|
|
5143
5394
|
"""
|
|
5144
5395
|
create a list of trade orders
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5396
|
+
|
|
5397
|
+
https://huobiapi.github.io/docs/spot/v1/en/#place-a-batch-of-orders
|
|
5398
|
+
https://huobiapi.github.io/docs/dm/v1/en/#place-a-batch-of-orders
|
|
5399
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-a-batch-of-orders
|
|
5400
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-a-batch-of-orders
|
|
5401
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-a-batch-of-orders
|
|
5402
|
+
|
|
5150
5403
|
: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
|
|
5151
5404
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
5152
5405
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
|
@@ -5259,7 +5512,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5259
5512
|
:param str id: order id
|
|
5260
5513
|
:param str symbol: unified symbol of the market the order was made in
|
|
5261
5514
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
5262
|
-
:param boolean [params.
|
|
5515
|
+
:param boolean [params.trigger]: *contract only* if the order is a trigger trigger order or not
|
|
5263
5516
|
:param boolean [params.stopLossTakeProfit]: *contract only* if the order is a stop-loss or take-profit order
|
|
5264
5517
|
:param boolean [params.trailing]: *contract only* set to True if you want to cancel a trailing order
|
|
5265
5518
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
|
@@ -5305,16 +5558,16 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5305
5558
|
request['symbol'] = market['settleId']
|
|
5306
5559
|
else:
|
|
5307
5560
|
request['contract_code'] = market['id']
|
|
5308
|
-
|
|
5561
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
|
5309
5562
|
stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
|
|
5310
5563
|
trailing = self.safe_bool(params, 'trailing', False)
|
|
5311
|
-
params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing'])
|
|
5564
|
+
params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger'])
|
|
5312
5565
|
if market['linear']:
|
|
5313
5566
|
marginMode = None
|
|
5314
5567
|
marginMode, params = self.handle_margin_mode_and_params('cancelOrder', params)
|
|
5315
5568
|
marginMode = 'cross' if (marginMode is None) else marginMode
|
|
5316
5569
|
if marginMode == 'isolated':
|
|
5317
|
-
if
|
|
5570
|
+
if trigger:
|
|
5318
5571
|
response = self.contractPrivatePostLinearSwapApiV1SwapTriggerCancel(self.extend(request, params))
|
|
5319
5572
|
elif stopLossTakeProfit:
|
|
5320
5573
|
response = self.contractPrivatePostLinearSwapApiV1SwapTpslCancel(self.extend(request, params))
|
|
@@ -5323,7 +5576,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5323
5576
|
else:
|
|
5324
5577
|
response = self.contractPrivatePostLinearSwapApiV1SwapCancel(self.extend(request, params))
|
|
5325
5578
|
elif marginMode == 'cross':
|
|
5326
|
-
if
|
|
5579
|
+
if trigger:
|
|
5327
5580
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancel(self.extend(request, params))
|
|
5328
5581
|
elif stopLossTakeProfit:
|
|
5329
5582
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel(self.extend(request, params))
|
|
@@ -5333,7 +5586,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5333
5586
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossCancel(self.extend(request, params))
|
|
5334
5587
|
elif market['inverse']:
|
|
5335
5588
|
if market['swap']:
|
|
5336
|
-
if
|
|
5589
|
+
if trigger:
|
|
5337
5590
|
response = self.contractPrivatePostSwapApiV1SwapTriggerCancel(self.extend(request, params))
|
|
5338
5591
|
elif stopLossTakeProfit:
|
|
5339
5592
|
response = self.contractPrivatePostSwapApiV1SwapTpslCancel(self.extend(request, params))
|
|
@@ -5342,7 +5595,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5342
5595
|
else:
|
|
5343
5596
|
response = self.contractPrivatePostSwapApiV1SwapCancel(self.extend(request, params))
|
|
5344
5597
|
elif market['future']:
|
|
5345
|
-
if
|
|
5598
|
+
if trigger:
|
|
5346
5599
|
response = self.contractPrivatePostApiV1ContractTriggerCancel(self.extend(request, params))
|
|
5347
5600
|
elif stopLossTakeProfit:
|
|
5348
5601
|
response = self.contractPrivatePostApiV1ContractTpslCancel(self.extend(request, params))
|
|
@@ -5382,7 +5635,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5382
5635
|
:param str[] ids: order ids
|
|
5383
5636
|
:param str symbol: unified market symbol, default is None
|
|
5384
5637
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
5385
|
-
:param bool [params.
|
|
5638
|
+
:param bool [params.trigger]: *contract only* if the orders are trigger trigger orders or not
|
|
5386
5639
|
:param bool [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
|
|
5387
5640
|
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
|
5388
5641
|
"""
|
|
@@ -5432,22 +5685,22 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5432
5685
|
request['symbol'] = market['settleId']
|
|
5433
5686
|
else:
|
|
5434
5687
|
request['contract_code'] = market['id']
|
|
5435
|
-
|
|
5688
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
|
5436
5689
|
stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
|
|
5437
|
-
params = self.omit(params, ['stop', 'stopLossTakeProfit'])
|
|
5690
|
+
params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trigger'])
|
|
5438
5691
|
if market['linear']:
|
|
5439
5692
|
marginMode = None
|
|
5440
5693
|
marginMode, params = self.handle_margin_mode_and_params('cancelOrders', params)
|
|
5441
5694
|
marginMode = 'cross' if (marginMode is None) else marginMode
|
|
5442
5695
|
if marginMode == 'isolated':
|
|
5443
|
-
if
|
|
5696
|
+
if trigger:
|
|
5444
5697
|
response = self.contractPrivatePostLinearSwapApiV1SwapTriggerCancel(self.extend(request, params))
|
|
5445
5698
|
elif stopLossTakeProfit:
|
|
5446
5699
|
response = self.contractPrivatePostLinearSwapApiV1SwapTpslCancel(self.extend(request, params))
|
|
5447
5700
|
else:
|
|
5448
5701
|
response = self.contractPrivatePostLinearSwapApiV1SwapCancel(self.extend(request, params))
|
|
5449
5702
|
elif marginMode == 'cross':
|
|
5450
|
-
if
|
|
5703
|
+
if trigger:
|
|
5451
5704
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancel(self.extend(request, params))
|
|
5452
5705
|
elif stopLossTakeProfit:
|
|
5453
5706
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel(self.extend(request, params))
|
|
@@ -5455,14 +5708,14 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5455
5708
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossCancel(self.extend(request, params))
|
|
5456
5709
|
elif market['inverse']:
|
|
5457
5710
|
if market['swap']:
|
|
5458
|
-
if
|
|
5711
|
+
if trigger:
|
|
5459
5712
|
response = self.contractPrivatePostSwapApiV1SwapTriggerCancel(self.extend(request, params))
|
|
5460
5713
|
elif stopLossTakeProfit:
|
|
5461
5714
|
response = self.contractPrivatePostSwapApiV1SwapTpslCancel(self.extend(request, params))
|
|
5462
5715
|
else:
|
|
5463
5716
|
response = self.contractPrivatePostSwapApiV1SwapCancel(self.extend(request, params))
|
|
5464
5717
|
elif market['future']:
|
|
5465
|
-
if
|
|
5718
|
+
if trigger:
|
|
5466
5719
|
response = self.contractPrivatePostApiV1ContractTriggerCancel(self.extend(request, params))
|
|
5467
5720
|
elif stopLossTakeProfit:
|
|
5468
5721
|
response = self.contractPrivatePostApiV1ContractTpslCancel(self.extend(request, params))
|
|
@@ -5521,14 +5774,69 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5521
5774
|
# "ts": 1604367997451
|
|
5522
5775
|
# }
|
|
5523
5776
|
#
|
|
5524
|
-
|
|
5777
|
+
data = self.safe_dict(response, 'data')
|
|
5778
|
+
return self.parse_cancel_orders(data)
|
|
5779
|
+
|
|
5780
|
+
def parse_cancel_orders(self, orders):
|
|
5781
|
+
#
|
|
5782
|
+
# {
|
|
5783
|
+
# "success": [
|
|
5784
|
+
# "5983466"
|
|
5785
|
+
# ],
|
|
5786
|
+
# "failed": [
|
|
5787
|
+
# {
|
|
5788
|
+
# "err-msg": "Incorrect order state",
|
|
5789
|
+
# "order-state": 7,
|
|
5790
|
+
# "order-id": "",
|
|
5791
|
+
# "err-code": "order-orderstate-error",
|
|
5792
|
+
# "client-order-id": "first"
|
|
5793
|
+
# },
|
|
5794
|
+
# ...
|
|
5795
|
+
# ]
|
|
5796
|
+
# }
|
|
5797
|
+
#
|
|
5798
|
+
# {
|
|
5799
|
+
# "errors": [
|
|
5800
|
+
# {
|
|
5801
|
+
# "order_id": "769206471845261312",
|
|
5802
|
+
# "err_code": 1061,
|
|
5803
|
+
# "err_msg": "This order doesnt exist."
|
|
5804
|
+
# }
|
|
5805
|
+
# ],
|
|
5806
|
+
# "successes": "1258075374411399168,1258075393254871040"
|
|
5807
|
+
# }
|
|
5808
|
+
#
|
|
5809
|
+
successes = self.safe_string(orders, 'successes')
|
|
5810
|
+
success = None
|
|
5811
|
+
if successes is not None:
|
|
5812
|
+
success = successes.split(',')
|
|
5813
|
+
else:
|
|
5814
|
+
success = self.safe_list(orders, 'success', [])
|
|
5815
|
+
failed = self.safe_list_2(orders, 'errors', 'failed', [])
|
|
5816
|
+
result = []
|
|
5817
|
+
for i in range(0, len(success)):
|
|
5818
|
+
order = success[i]
|
|
5819
|
+
result.append(self.safe_order({
|
|
5820
|
+
'info': order,
|
|
5821
|
+
'id': order,
|
|
5822
|
+
'status': 'canceled',
|
|
5823
|
+
}))
|
|
5824
|
+
for i in range(0, len(failed)):
|
|
5825
|
+
order = failed[i]
|
|
5826
|
+
result.append(self.safe_order({
|
|
5827
|
+
'info': order,
|
|
5828
|
+
'id': self.safe_string_2(order, 'order-id', 'order_id'),
|
|
5829
|
+
'status': 'failed',
|
|
5830
|
+
'clientOrderId': self.safe_string(order, 'client-order-id'),
|
|
5831
|
+
}))
|
|
5832
|
+
return result
|
|
5525
5833
|
|
|
5526
5834
|
def cancel_all_orders(self, symbol: Str = None, params={}):
|
|
5527
5835
|
"""
|
|
5528
5836
|
cancel all open orders
|
|
5529
5837
|
:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
|
|
5530
5838
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
5531
|
-
:param boolean [params.
|
|
5839
|
+
:param boolean [params.trigger]: *contract only* if the orders are trigger trigger orders or not
|
|
5532
5840
|
:param boolean [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
|
|
5533
5841
|
:param boolean [params.trailing]: *contract only* set to True if you want to cancel all trailing orders
|
|
5534
5842
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
|
@@ -5558,22 +5866,38 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5558
5866
|
if symbol is not None:
|
|
5559
5867
|
request['symbol'] = market['id']
|
|
5560
5868
|
response = self.spotPrivatePostV1OrderOrdersBatchCancelOpenOrders(self.extend(request, params))
|
|
5869
|
+
#
|
|
5870
|
+
# {
|
|
5871
|
+
# "code": 200,
|
|
5872
|
+
# "data": {
|
|
5873
|
+
# "success-count": 2,
|
|
5874
|
+
# "failed-count": 0,
|
|
5875
|
+
# "next-id": 5454600
|
|
5876
|
+
# }
|
|
5877
|
+
# }
|
|
5878
|
+
#
|
|
5879
|
+
data = self.safe_dict(response, 'data')
|
|
5880
|
+
return [
|
|
5881
|
+
self.safe_order({
|
|
5882
|
+
'info': data,
|
|
5883
|
+
}),
|
|
5884
|
+
]
|
|
5561
5885
|
else:
|
|
5562
5886
|
if symbol is None:
|
|
5563
5887
|
raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
|
|
5564
5888
|
if market['future']:
|
|
5565
5889
|
request['symbol'] = market['settleId']
|
|
5566
5890
|
request['contract_code'] = market['id']
|
|
5567
|
-
|
|
5891
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
|
5568
5892
|
stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
|
|
5569
5893
|
trailing = self.safe_bool(params, 'trailing', False)
|
|
5570
|
-
params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing'])
|
|
5894
|
+
params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger'])
|
|
5571
5895
|
if market['linear']:
|
|
5572
5896
|
marginMode = None
|
|
5573
5897
|
marginMode, params = self.handle_margin_mode_and_params('cancelAllOrders', params)
|
|
5574
5898
|
marginMode = 'cross' if (marginMode is None) else marginMode
|
|
5575
5899
|
if marginMode == 'isolated':
|
|
5576
|
-
if
|
|
5900
|
+
if trigger:
|
|
5577
5901
|
response = self.contractPrivatePostLinearSwapApiV1SwapTriggerCancelall(self.extend(request, params))
|
|
5578
5902
|
elif stopLossTakeProfit:
|
|
5579
5903
|
response = self.contractPrivatePostLinearSwapApiV1SwapTpslCancelall(self.extend(request, params))
|
|
@@ -5582,7 +5906,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5582
5906
|
else:
|
|
5583
5907
|
response = self.contractPrivatePostLinearSwapApiV1SwapCancelall(self.extend(request, params))
|
|
5584
5908
|
elif marginMode == 'cross':
|
|
5585
|
-
if
|
|
5909
|
+
if trigger:
|
|
5586
5910
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancelall(self.extend(request, params))
|
|
5587
5911
|
elif stopLossTakeProfit:
|
|
5588
5912
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancelall(self.extend(request, params))
|
|
@@ -5592,7 +5916,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5592
5916
|
response = self.contractPrivatePostLinearSwapApiV1SwapCrossCancelall(self.extend(request, params))
|
|
5593
5917
|
elif market['inverse']:
|
|
5594
5918
|
if market['swap']:
|
|
5595
|
-
if
|
|
5919
|
+
if trigger:
|
|
5596
5920
|
response = self.contractPrivatePostSwapApiV1SwapTriggerCancelall(self.extend(request, params))
|
|
5597
5921
|
elif stopLossTakeProfit:
|
|
5598
5922
|
response = self.contractPrivatePostSwapApiV1SwapTpslCancelall(self.extend(request, params))
|
|
@@ -5601,7 +5925,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5601
5925
|
else:
|
|
5602
5926
|
response = self.contractPrivatePostSwapApiV1SwapCancelall(self.extend(request, params))
|
|
5603
5927
|
elif market['future']:
|
|
5604
|
-
if
|
|
5928
|
+
if trigger:
|
|
5605
5929
|
response = self.contractPrivatePostApiV1ContractTriggerCancelall(self.extend(request, params))
|
|
5606
5930
|
elif stopLossTakeProfit:
|
|
5607
5931
|
response = self.contractPrivatePostApiV1ContractTpslCancelall(self.extend(request, params))
|
|
@@ -5611,35 +5935,25 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5611
5935
|
response = self.contractPrivatePostApiV1ContractCancelall(self.extend(request, params))
|
|
5612
5936
|
else:
|
|
5613
5937
|
raise NotSupported(self.id + ' cancelAllOrders() does not support ' + marketType + ' markets')
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
# future and swap
|
|
5627
|
-
#
|
|
5628
|
-
# {
|
|
5629
|
-
# "status": "ok",
|
|
5630
|
-
# "data": {
|
|
5631
|
-
# "errors": [],
|
|
5632
|
-
# "successes": "1104754904426696704"
|
|
5633
|
-
# },
|
|
5634
|
-
# "ts": "1683435723755"
|
|
5635
|
-
# }
|
|
5636
|
-
#
|
|
5637
|
-
return response
|
|
5938
|
+
#
|
|
5939
|
+
# {
|
|
5940
|
+
# "status": "ok",
|
|
5941
|
+
# "data": {
|
|
5942
|
+
# "errors": [],
|
|
5943
|
+
# "successes": "1104754904426696704"
|
|
5944
|
+
# },
|
|
5945
|
+
# "ts": "1683435723755"
|
|
5946
|
+
# }
|
|
5947
|
+
#
|
|
5948
|
+
data = self.safe_dict(response, 'data')
|
|
5949
|
+
return self.parse_cancel_orders(data)
|
|
5638
5950
|
|
|
5639
5951
|
def cancel_all_orders_after(self, timeout: Int, params={}):
|
|
5640
5952
|
"""
|
|
5641
5953
|
dead man's switch, cancel all orders after the given timeout
|
|
5642
|
-
|
|
5954
|
+
|
|
5955
|
+
https://huobiapi.github.io/docs/spot/v1/en/#dead-man-s-switch
|
|
5956
|
+
|
|
5643
5957
|
:param number timeout: time in milliseconds, 0 represents cancel the timer
|
|
5644
5958
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
5645
5959
|
:returns dict: the api result
|
|
@@ -5687,8 +6001,11 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5687
6001
|
'info': depositAddress,
|
|
5688
6002
|
}
|
|
5689
6003
|
|
|
5690
|
-
def fetch_deposit_addresses_by_network(self, code: str, params={}):
|
|
6004
|
+
def fetch_deposit_addresses_by_network(self, code: str, params={}) -> List[DepositAddress]:
|
|
5691
6005
|
"""
|
|
6006
|
+
|
|
6007
|
+
https://www.htx.com/en-us/opend/newApiPages/?id=7ec50029-7773-11ed-9966-0242ac110003
|
|
6008
|
+
|
|
5692
6009
|
fetch a dictionary of addresses for a currency, indexed by network
|
|
5693
6010
|
:param str code: unified currency code of the currency for the deposit address
|
|
5694
6011
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
@@ -5717,9 +6034,12 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5717
6034
|
parsed = self.parse_deposit_addresses(data, [currency['code']], False)
|
|
5718
6035
|
return self.index_by(parsed, 'network')
|
|
5719
6036
|
|
|
5720
|
-
def fetch_deposit_address(self, code: str, params={}):
|
|
6037
|
+
def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
|
|
5721
6038
|
"""
|
|
5722
6039
|
fetch the deposit address for a currency associated with self account
|
|
6040
|
+
|
|
6041
|
+
https://www.htx.com/en-us/opend/newApiPages/?id=7ec50029-7773-11ed-9966-0242ac110003
|
|
6042
|
+
|
|
5723
6043
|
:param str code: unified currency code
|
|
5724
6044
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
5725
6045
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
|
@@ -5765,6 +6085,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5765
6085
|
|
|
5766
6086
|
def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
|
5767
6087
|
"""
|
|
6088
|
+
|
|
6089
|
+
https://www.htx.com/en-us/opend/newApiPages/?id=7ec4f050-7773-11ed-9966-0242ac110003
|
|
6090
|
+
|
|
5768
6091
|
fetch all deposits made to an account
|
|
5769
6092
|
:param str code: unified currency code
|
|
5770
6093
|
:param int [since]: the earliest time in ms to fetch deposits for
|
|
@@ -5819,6 +6142,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5819
6142
|
def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
|
5820
6143
|
"""
|
|
5821
6144
|
fetch all withdrawals made from an account
|
|
6145
|
+
|
|
6146
|
+
https://huobiapi.github.io/docs/spot/v1/en/#search-for-existed-withdraws-and-deposits
|
|
6147
|
+
|
|
5822
6148
|
:param str code: unified currency code
|
|
5823
6149
|
:param int [since]: the earliest time in ms to fetch withdrawals for
|
|
5824
6150
|
:param int [limit]: the maximum number of withdrawals structures to retrieve
|
|
@@ -5982,8 +6308,11 @@ class htx(Exchange, ImplicitAPI):
|
|
|
5982
6308
|
}
|
|
5983
6309
|
return self.safe_string(statuses, status, status)
|
|
5984
6310
|
|
|
5985
|
-
def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
|
|
6311
|
+
def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
|
|
5986
6312
|
"""
|
|
6313
|
+
|
|
6314
|
+
https://www.htx.com/en-us/opend/newApiPages/?id=7ec4cc41-7773-11ed-9966-0242ac110003
|
|
6315
|
+
|
|
5987
6316
|
make a withdrawal
|
|
5988
6317
|
:param str code: unified currency code
|
|
5989
6318
|
:param float amount: the amount to withdraw
|
|
@@ -6012,7 +6341,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6012
6341
|
fee = self.safe_number(params, 'fee')
|
|
6013
6342
|
if fee is None:
|
|
6014
6343
|
currencies = self.fetch_currencies()
|
|
6015
|
-
self.currencies = self.deep_extend(self.currencies, currencies)
|
|
6344
|
+
self.currencies = self.map_to_safe_map(self.deep_extend(self.currencies, currencies))
|
|
6016
6345
|
targetNetwork = self.safe_value(currency['networks'], networkCode, {})
|
|
6017
6346
|
fee = self.safe_number(targetNetwork, 'fee')
|
|
6018
6347
|
if fee is None:
|
|
@@ -6061,13 +6390,15 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6061
6390
|
def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
|
|
6062
6391
|
"""
|
|
6063
6392
|
transfer currency internally between wallets on the same account
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6393
|
+
|
|
6394
|
+
https://huobiapi.github.io/docs/dm/v1/en/#transfer-margin-between-spot-account-and-future-account
|
|
6395
|
+
https://huobiapi.github.io/docs/spot/v1/en/#transfer-fund-between-spot-account-and-future-contract-account
|
|
6396
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-transfer-margin-between-spot-account-and-usdt-margined-contracts-account
|
|
6397
|
+
https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-spot-trading-account-to-cross-margin-account-cross
|
|
6398
|
+
https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-spot-trading-account-to-isolated-margin-account-isolated
|
|
6399
|
+
https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-cross-margin-account-to-spot-trading-account-cross
|
|
6400
|
+
https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-isolated-margin-account-to-spot-trading-account-isolated
|
|
6401
|
+
|
|
6071
6402
|
:param str code: unified currency code
|
|
6072
6403
|
:param float amount: amount to transfer
|
|
6073
6404
|
:param str fromAccount: account to transfer from 'spot', 'future', 'swap'
|
|
@@ -6143,6 +6474,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6143
6474
|
def fetch_isolated_borrow_rates(self, params={}) -> IsolatedBorrowRates:
|
|
6144
6475
|
"""
|
|
6145
6476
|
fetch the borrow interest rates of all currencies
|
|
6477
|
+
|
|
6478
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-loan-interest-rate-and-quota-isolated
|
|
6479
|
+
|
|
6146
6480
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
6147
6481
|
:returns dict: a list of `isolated borrow rate structures <https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure>`
|
|
6148
6482
|
"""
|
|
@@ -6180,7 +6514,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6180
6514
|
data = self.safe_value(response, 'data', [])
|
|
6181
6515
|
return self.parse_isolated_borrow_rates(data)
|
|
6182
6516
|
|
|
6183
|
-
def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
|
|
6517
|
+
def parse_isolated_borrow_rate(self, info: dict, market: Market = None) -> IsolatedBorrowRate:
|
|
6184
6518
|
#
|
|
6185
6519
|
# {
|
|
6186
6520
|
# "symbol": "1inchusdt",
|
|
@@ -6225,8 +6559,10 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6225
6559
|
|
|
6226
6560
|
def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
6227
6561
|
"""
|
|
6228
|
-
|
|
6229
|
-
|
|
6562
|
+
|
|
6563
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-historical-funding-rate
|
|
6564
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-historical-funding-rate
|
|
6565
|
+
|
|
6230
6566
|
fetches historical funding rate prices
|
|
6231
6567
|
:param str symbol: unified symbol of the market to fetch the funding rate history for
|
|
6232
6568
|
:param int [since]: not used by huobi, but filtered internally by ccxt
|
|
@@ -6240,12 +6576,16 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6240
6576
|
paginate = False
|
|
6241
6577
|
paginate, params = self.handle_option_and_params(params, 'fetchFundingRateHistory', 'paginate')
|
|
6242
6578
|
if paginate:
|
|
6243
|
-
return self.fetch_paginated_call_cursor('fetchFundingRateHistory', symbol, since, limit, params, '
|
|
6579
|
+
return self.fetch_paginated_call_cursor('fetchFundingRateHistory', symbol, since, limit, params, 'current_page', 'page_index', 1, 50)
|
|
6244
6580
|
self.load_markets()
|
|
6245
6581
|
market = self.market(symbol)
|
|
6246
6582
|
request: dict = {
|
|
6247
6583
|
'contract_code': market['id'],
|
|
6248
6584
|
}
|
|
6585
|
+
if limit is not None:
|
|
6586
|
+
request['page_size'] = limit
|
|
6587
|
+
else:
|
|
6588
|
+
request['page_size'] = 50 # max
|
|
6249
6589
|
response = None
|
|
6250
6590
|
if market['inverse']:
|
|
6251
6591
|
response = self.contractPublicGetSwapApiV1SwapHistoricalFundingRate(self.extend(request, params))
|
|
@@ -6295,7 +6635,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6295
6635
|
sorted = self.sort_by(rates, 'timestamp')
|
|
6296
6636
|
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
|
6297
6637
|
|
|
6298
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
|
6638
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
|
6299
6639
|
#
|
|
6300
6640
|
# {
|
|
6301
6641
|
# "status": "ok",
|
|
@@ -6314,6 +6654,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6314
6654
|
nextFundingRate = self.safe_number(contract, 'estimated_rate')
|
|
6315
6655
|
fundingTimestamp = self.safe_integer(contract, 'funding_time')
|
|
6316
6656
|
nextFundingTimestamp = self.safe_integer(contract, 'next_funding_time')
|
|
6657
|
+
fundingTimeString = self.safe_string(contract, 'funding_time')
|
|
6658
|
+
nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
|
|
6659
|
+
millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
|
|
6317
6660
|
marketId = self.safe_string(contract, 'contract_code')
|
|
6318
6661
|
symbol = self.safe_symbol(marketId, market)
|
|
6319
6662
|
return {
|
|
@@ -6334,11 +6677,26 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6334
6677
|
'previousFundingRate': None,
|
|
6335
6678
|
'previousFundingTimestamp': None,
|
|
6336
6679
|
'previousFundingDatetime': None,
|
|
6680
|
+
'interval': self.parse_funding_interval(millisecondsInterval),
|
|
6337
6681
|
}
|
|
6338
6682
|
|
|
6339
|
-
def
|
|
6683
|
+
def parse_funding_interval(self, interval):
|
|
6684
|
+
intervals: dict = {
|
|
6685
|
+
'3600000': '1h',
|
|
6686
|
+
'14400000': '4h',
|
|
6687
|
+
'28800000': '8h',
|
|
6688
|
+
'57600000': '16h',
|
|
6689
|
+
'86400000': '24h',
|
|
6690
|
+
}
|
|
6691
|
+
return self.safe_string(intervals, interval, interval)
|
|
6692
|
+
|
|
6693
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
|
6340
6694
|
"""
|
|
6341
6695
|
fetch the current funding rate
|
|
6696
|
+
|
|
6697
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-funding-rate
|
|
6698
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-funding-rate
|
|
6699
|
+
|
|
6342
6700
|
:param str symbol: unified market symbol
|
|
6343
6701
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
6344
6702
|
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
|
@@ -6373,23 +6731,30 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6373
6731
|
result = self.safe_value(response, 'data', {})
|
|
6374
6732
|
return self.parse_funding_rate(result, market)
|
|
6375
6733
|
|
|
6376
|
-
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
|
6734
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
|
6377
6735
|
"""
|
|
6378
6736
|
fetch the funding rate for multiple markets
|
|
6737
|
+
|
|
6738
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-a-batch-of-funding-rate
|
|
6739
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-a-batch-of-funding-rate
|
|
6740
|
+
|
|
6379
6741
|
:param str[]|None symbols: list of unified market symbols
|
|
6380
6742
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
6381
|
-
:returns dict: a
|
|
6743
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
|
|
6382
6744
|
"""
|
|
6383
6745
|
self.load_markets()
|
|
6384
6746
|
symbols = self.market_symbols(symbols)
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
subType = self.
|
|
6388
|
-
|
|
6747
|
+
defaultSubType = self.safe_string(self.options, 'defaultSubType', 'linear')
|
|
6748
|
+
subType = None
|
|
6749
|
+
subType, params = self.handle_option_and_params(params, 'fetchFundingRates', 'subType', defaultSubType)
|
|
6750
|
+
if symbols is not None:
|
|
6751
|
+
firstSymbol = self.safe_string(symbols, 0)
|
|
6752
|
+
market = self.market(firstSymbol)
|
|
6753
|
+
isLinear = market['linear']
|
|
6754
|
+
subType = 'linear' if isLinear else 'inverse'
|
|
6389
6755
|
request: dict = {
|
|
6390
6756
|
# 'contract_code': market['id'],
|
|
6391
6757
|
}
|
|
6392
|
-
params = self.omit(params, 'subType')
|
|
6393
6758
|
response = None
|
|
6394
6759
|
if subType == 'linear':
|
|
6395
6760
|
response = self.contractPublicGetLinearSwapApiV1SwapBatchFundingRate(self.extend(request, params))
|
|
@@ -6416,12 +6781,15 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6416
6781
|
# }
|
|
6417
6782
|
#
|
|
6418
6783
|
data = self.safe_value(response, 'data', [])
|
|
6419
|
-
|
|
6420
|
-
return self.filter_by_array(result, 'symbol', symbols)
|
|
6784
|
+
return self.parse_funding_rates(data, symbols)
|
|
6421
6785
|
|
|
6422
|
-
def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
6786
|
+
def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
|
|
6423
6787
|
"""
|
|
6424
6788
|
fetch the interest owed by the user for borrowing currency for margin trading
|
|
6789
|
+
|
|
6790
|
+
https://huobiapi.github.io/docs/spot/v1/en/#search-past-margin-orders-cross
|
|
6791
|
+
https://huobiapi.github.io/docs/spot/v1/en/#search-past-margin-orders-isolated
|
|
6792
|
+
|
|
6425
6793
|
:param str code: unified currency code
|
|
6426
6794
|
:param str symbol: unified market symbol when fetch interest in isolated markets
|
|
6427
6795
|
:param int [since]: the earliest time in ms to fetch borrrow interest for
|
|
@@ -6476,7 +6844,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6476
6844
|
interest = self.parse_borrow_interests(data, market)
|
|
6477
6845
|
return self.filter_by_currency_since_limit(interest, code, since, limit)
|
|
6478
6846
|
|
|
6479
|
-
def parse_borrow_interest(self, info: dict, market: Market = None):
|
|
6847
|
+
def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
|
|
6480
6848
|
# isolated
|
|
6481
6849
|
# {
|
|
6482
6850
|
# "interest-rate":"0.000040830000000000",
|
|
@@ -6524,18 +6892,20 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6524
6892
|
symbol = self.safe_string(market, 'symbol')
|
|
6525
6893
|
timestamp = self.safe_integer(info, 'accrued-at')
|
|
6526
6894
|
return {
|
|
6527
|
-
'
|
|
6895
|
+
'info': info,
|
|
6528
6896
|
'symbol': symbol,
|
|
6529
|
-
'marginMode': marginMode,
|
|
6530
6897
|
'currency': self.safe_currency_code(self.safe_string(info, 'currency')),
|
|
6531
6898
|
'interest': self.safe_number(info, 'interest-amount'),
|
|
6532
6899
|
'interestRate': self.safe_number(info, 'interest-rate'),
|
|
6533
6900
|
'amountBorrowed': self.safe_number(info, 'loan-amount'),
|
|
6901
|
+
'marginMode': marginMode,
|
|
6534
6902
|
'timestamp': timestamp, # Interest accrued time
|
|
6535
6903
|
'datetime': self.iso8601(timestamp),
|
|
6536
|
-
'info': info,
|
|
6537
6904
|
}
|
|
6538
6905
|
|
|
6906
|
+
def nonce(self):
|
|
6907
|
+
return self.milliseconds() - self.options['timeDifference']
|
|
6908
|
+
|
|
6539
6909
|
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
|
6540
6910
|
url = '/'
|
|
6541
6911
|
query = self.omit(params, self.extract_params(path))
|
|
@@ -6548,7 +6918,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6548
6918
|
url += '/' + self.implode_params(path, params)
|
|
6549
6919
|
if api == 'private' or api == 'v2Private':
|
|
6550
6920
|
self.check_required_credentials()
|
|
6551
|
-
timestamp = self.ymdhms(self.
|
|
6921
|
+
timestamp = self.ymdhms(self.nonce(), 'T')
|
|
6552
6922
|
request: dict = {
|
|
6553
6923
|
'SignatureMethod': 'HmacSHA256',
|
|
6554
6924
|
'SignatureVersion': '2',
|
|
@@ -6558,7 +6928,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6558
6928
|
if method != 'POST':
|
|
6559
6929
|
request = self.extend(request, query)
|
|
6560
6930
|
sortedRequest = self.keysort(request)
|
|
6561
|
-
auth = self.urlencode(sortedRequest)
|
|
6931
|
+
auth = self.urlencode(sortedRequest, True) # True is a go only requirment
|
|
6562
6932
|
# unfortunately, PHP demands double quotes for the escaped newline symbol
|
|
6563
6933
|
payload = "\n".join([method, self.hostname, url, auth]) # eslint-disable-line quotes
|
|
6564
6934
|
signature = self.hmac(self.encode(payload), self.encode(self.secret), hashlib.sha256, 'base64')
|
|
@@ -6612,17 +6982,19 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6612
6982
|
clientOrderId = self.safe_string(params, 'client-order-id')
|
|
6613
6983
|
if clientOrderId is None:
|
|
6614
6984
|
params['client-order-id'] = id + self.uuid()
|
|
6615
|
-
timestamp = self.ymdhms(self.
|
|
6985
|
+
timestamp = self.ymdhms(self.nonce(), 'T')
|
|
6616
6986
|
request: dict = {
|
|
6617
6987
|
'SignatureMethod': 'HmacSHA256',
|
|
6618
6988
|
'SignatureVersion': '2',
|
|
6619
6989
|
'AccessKeyId': self.apiKey,
|
|
6620
6990
|
'Timestamp': timestamp,
|
|
6621
6991
|
}
|
|
6622
|
-
|
|
6623
|
-
request = self.extend(request, query)
|
|
6992
|
+
# sorting needs such flow exactly, before urlencoding(more at: https://github.com/ccxt/ccxt/issues/24930 )
|
|
6624
6993
|
request = self.keysort(request)
|
|
6625
|
-
|
|
6994
|
+
if method != 'POST':
|
|
6995
|
+
sortedQuery = self.keysort(query)
|
|
6996
|
+
request = self.extend(request, sortedQuery)
|
|
6997
|
+
auth = self.urlencode(request, True).replace('%2c', '%2C') # in c# it manually needs to be uppercased
|
|
6626
6998
|
# unfortunately, PHP demands double quotes for the escaped newline symbol
|
|
6627
6999
|
payload = "\n".join([method, hostname, url, auth]) # eslint-disable-line quotes
|
|
6628
7000
|
signature = self.hmac(self.encode(payload), self.encode(self.secret), hashlib.sha256, 'base64')
|
|
@@ -6650,6 +7022,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6650
7022
|
if 'status' in response:
|
|
6651
7023
|
#
|
|
6652
7024
|
# {"status":"error","err-code":"order-limitorder-amount-min-error","err-msg":"limit order amount error, min: `0.001`","data":null}
|
|
7025
|
+
# {"status":"ok","data":{"errors":[{"order_id":"1349442392365359104","err_code":1061,"err_msg":"The order does not exist."}],"successes":""},"ts":1741773744526}
|
|
6653
7026
|
#
|
|
6654
7027
|
status = self.safe_string(response, 'status')
|
|
6655
7028
|
if status == 'error':
|
|
@@ -6665,14 +7038,25 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6665
7038
|
feedback = self.id + ' ' + body
|
|
6666
7039
|
code = self.safe_string(response, 'code')
|
|
6667
7040
|
self.throw_exactly_matched_exception(self.exceptions['exact'], code, feedback)
|
|
7041
|
+
data = self.safe_dict(response, 'data')
|
|
7042
|
+
errorsList = self.safe_list(data, 'errors')
|
|
7043
|
+
if errorsList is not None:
|
|
7044
|
+
first = self.safe_dict(errorsList, 0)
|
|
7045
|
+
errcode = self.safe_string(first, 'err_code')
|
|
7046
|
+
errmessage = self.safe_string(first, 'err_msg')
|
|
7047
|
+
feedBack = self.id + ' ' + body
|
|
7048
|
+
self.throw_exactly_matched_exception(self.exceptions['exact'], errcode, feedBack)
|
|
7049
|
+
self.throw_exactly_matched_exception(self.exceptions['exact'], errmessage, feedBack)
|
|
6668
7050
|
return None
|
|
6669
7051
|
|
|
6670
7052
|
def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
6671
7053
|
"""
|
|
6672
7054
|
fetch the history of funding payments paid and received on self account
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
7055
|
+
|
|
7056
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-account-financial-records-via-multiple-fields-new # linear swaps
|
|
7057
|
+
https://huobiapi.github.io/docs/dm/v1/en/#query-financial-records-via-multiple-fields-new # coin-m futures
|
|
7058
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-financial-records-via-multiple-fields-new # coin-m swaps
|
|
7059
|
+
|
|
6676
7060
|
:param str symbol: unified market symbol
|
|
6677
7061
|
:param int [since]: the earliest time in ms to fetch funding history for
|
|
6678
7062
|
:param int [limit]: the maximum number of funding history structures to retrieve
|
|
@@ -6749,9 +7133,15 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6749
7133
|
data = self.safe_list(response, 'data', [])
|
|
6750
7134
|
return self.parse_incomes(data, market, since, limit)
|
|
6751
7135
|
|
|
6752
|
-
def set_leverage(self, leverage:
|
|
7136
|
+
def set_leverage(self, leverage: int, symbol: Str = None, params={}):
|
|
6753
7137
|
"""
|
|
6754
7138
|
set the level of leverage for a market
|
|
7139
|
+
|
|
7140
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-leverage
|
|
7141
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-switch-leverage
|
|
7142
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#switch-leverage
|
|
7143
|
+
https://huobiapi.github.io/docs/dm/v1/en/#switch-leverage # Coin-m futures
|
|
7144
|
+
|
|
6755
7145
|
:param float leverage: the rate of leverage
|
|
6756
7146
|
:param str symbol: unified market symbol
|
|
6757
7147
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
@@ -6913,7 +7303,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6913
7303
|
'entryPrice': entryPrice,
|
|
6914
7304
|
'collateral': self.parse_number(collateral),
|
|
6915
7305
|
'side': side,
|
|
6916
|
-
'
|
|
7306
|
+
'unrealizedPnl': unrealizedProfit,
|
|
6917
7307
|
'leverage': self.parse_number(leverage),
|
|
6918
7308
|
'percentage': self.parse_number(percentage),
|
|
6919
7309
|
'marginMode': marginMode,
|
|
@@ -6934,10 +7324,16 @@ class htx(Exchange, ImplicitAPI):
|
|
|
6934
7324
|
'takeProfitPrice': None,
|
|
6935
7325
|
})
|
|
6936
7326
|
|
|
6937
|
-
def fetch_positions(self, symbols: Strings = None, params={}):
|
|
7327
|
+
def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
|
6938
7328
|
"""
|
|
6939
7329
|
fetch all open positions
|
|
6940
|
-
|
|
7330
|
+
|
|
7331
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-query-user-39-s-position-information
|
|
7332
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-user-s-position-information
|
|
7333
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-user-s-position-information
|
|
7334
|
+
https://huobiapi.github.io/docs/dm/v1/en/#query-user-s-position-information
|
|
7335
|
+
|
|
7336
|
+
:param str[] [symbols]: list of unified market symbols
|
|
6941
7337
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
6942
7338
|
:param str [params.subType]: 'linear' or 'inverse'
|
|
6943
7339
|
:param str [params.type]: *inverse only* 'future', or 'swap'
|
|
@@ -7067,6 +7463,12 @@ class htx(Exchange, ImplicitAPI):
|
|
|
7067
7463
|
def fetch_position(self, symbol: str, params={}):
|
|
7068
7464
|
"""
|
|
7069
7465
|
fetch data on a single open contract trade position
|
|
7466
|
+
|
|
7467
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-query-assets-and-positions
|
|
7468
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-assets-and-positions
|
|
7469
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-assets-and-positions
|
|
7470
|
+
https://huobiapi.github.io/docs/dm/v1/en/#query-assets-and-positions
|
|
7471
|
+
|
|
7070
7472
|
:param str symbol: unified market symbol of the market the position is held in, default is None
|
|
7071
7473
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
7072
7474
|
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
|
@@ -7327,7 +7729,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
7327
7729
|
}
|
|
7328
7730
|
return self.safe_string(types, type, type)
|
|
7329
7731
|
|
|
7330
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
|
7732
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
|
7331
7733
|
#
|
|
7332
7734
|
# {
|
|
7333
7735
|
# "accountId": 10000001,
|
|
@@ -7341,45 +7743,44 @@ class htx(Exchange, ImplicitAPI):
|
|
|
7341
7743
|
# "transferee": 13496526
|
|
7342
7744
|
# }
|
|
7343
7745
|
#
|
|
7344
|
-
id = self.safe_string(item, 'transactId')
|
|
7345
7746
|
currencyId = self.safe_string(item, 'currency')
|
|
7346
7747
|
code = self.safe_currency_code(currencyId, currency)
|
|
7347
|
-
|
|
7748
|
+
currency = self.safe_currency(currencyId, currency)
|
|
7749
|
+
id = self.safe_string(item, 'transactId')
|
|
7348
7750
|
transferType = self.safe_string(item, 'transferType')
|
|
7349
|
-
type = self.parse_ledger_entry_type(transferType)
|
|
7350
|
-
direction = self.safe_string(item, 'direction')
|
|
7351
7751
|
timestamp = self.safe_integer(item, 'transactTime')
|
|
7352
|
-
datetime = self.iso8601(timestamp)
|
|
7353
7752
|
account = self.safe_string(item, 'accountId')
|
|
7354
|
-
return {
|
|
7753
|
+
return self.safe_ledger_entry({
|
|
7754
|
+
'info': item,
|
|
7355
7755
|
'id': id,
|
|
7356
|
-
'direction': direction,
|
|
7756
|
+
'direction': self.safe_string(item, 'direction'),
|
|
7357
7757
|
'account': account,
|
|
7358
7758
|
'referenceId': id,
|
|
7359
7759
|
'referenceAccount': account,
|
|
7360
|
-
'type':
|
|
7760
|
+
'type': self.parse_ledger_entry_type(transferType),
|
|
7361
7761
|
'currency': code,
|
|
7362
|
-
'amount':
|
|
7762
|
+
'amount': self.safe_number(item, 'transactAmt'),
|
|
7363
7763
|
'timestamp': timestamp,
|
|
7364
|
-
'datetime':
|
|
7764
|
+
'datetime': self.iso8601(timestamp),
|
|
7365
7765
|
'before': None,
|
|
7366
7766
|
'after': None,
|
|
7367
7767
|
'status': None,
|
|
7368
7768
|
'fee': None,
|
|
7369
|
-
|
|
7370
|
-
}
|
|
7769
|
+
}, currency)
|
|
7371
7770
|
|
|
7372
|
-
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
7771
|
+
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
|
7373
7772
|
"""
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7773
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
|
7774
|
+
|
|
7775
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-account-history
|
|
7776
|
+
|
|
7777
|
+
:param str [code]: unified currency code, default is None
|
|
7377
7778
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
|
7378
|
-
:param int [limit]: max number of ledger
|
|
7779
|
+
:param int [limit]: max number of ledger entries to return, default is None
|
|
7379
7780
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
7380
7781
|
:param int [params.until]: the latest time in ms to fetch entries for
|
|
7381
|
-
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [
|
|
7382
|
-
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger
|
|
7782
|
+
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
7783
|
+
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
|
|
7383
7784
|
"""
|
|
7384
7785
|
self.load_markets()
|
|
7385
7786
|
paginate = False
|
|
@@ -7480,92 +7881,41 @@ class htx(Exchange, ImplicitAPI):
|
|
|
7480
7881
|
# ]
|
|
7481
7882
|
# }
|
|
7482
7883
|
#
|
|
7483
|
-
data = self.safe_list(response, 'data')
|
|
7884
|
+
data = self.safe_list(response, 'data', [])
|
|
7484
7885
|
return self.parse_leverage_tiers(data, symbols, 'contract_code')
|
|
7485
7886
|
|
|
7486
|
-
def
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
# "trade_partition": "USDT",
|
|
7510
|
-
# "list": [
|
|
7511
|
-
# {
|
|
7512
|
-
# "lever_rate": 75,
|
|
7513
|
-
# "ladders": [
|
|
7514
|
-
# {
|
|
7515
|
-
# "ladder": 0,
|
|
7516
|
-
# "min_size": 0,
|
|
7517
|
-
# "max_size": 999,
|
|
7518
|
-
# "adjust_factor": 0.7
|
|
7519
|
-
# },
|
|
7520
|
-
# ...
|
|
7521
|
-
# ]
|
|
7522
|
-
# }
|
|
7523
|
-
# ...
|
|
7524
|
-
# ]
|
|
7525
|
-
# },
|
|
7526
|
-
# ...
|
|
7527
|
-
# ]
|
|
7528
|
-
# }
|
|
7529
|
-
#
|
|
7530
|
-
data = self.safe_value(response, 'data')
|
|
7531
|
-
tiers = self.parse_leverage_tiers(data, [symbol], 'contract_code')
|
|
7532
|
-
return self.safe_value(tiers, symbol)
|
|
7533
|
-
|
|
7534
|
-
def parse_leverage_tiers(self, response, symbols: Strings = None, marketIdKey=None):
|
|
7535
|
-
result: dict = {}
|
|
7536
|
-
for i in range(0, len(response)):
|
|
7537
|
-
item = response[i]
|
|
7538
|
-
list = self.safe_value(item, 'list', [])
|
|
7539
|
-
tiers = []
|
|
7540
|
-
currency = self.safe_string(item, 'trade_partition')
|
|
7541
|
-
id = self.safe_string(item, marketIdKey)
|
|
7542
|
-
symbol = self.safe_symbol(id)
|
|
7543
|
-
if self.in_array(symbol, symbols):
|
|
7544
|
-
for j in range(0, len(list)):
|
|
7545
|
-
obj = list[j]
|
|
7546
|
-
leverage = self.safe_string(obj, 'lever_rate')
|
|
7547
|
-
ladders = self.safe_value(obj, 'ladders', [])
|
|
7548
|
-
for k in range(0, len(ladders)):
|
|
7549
|
-
bracket = ladders[k]
|
|
7550
|
-
adjustFactor = self.safe_string(bracket, 'adjust_factor')
|
|
7551
|
-
tiers.append({
|
|
7552
|
-
'tier': self.safe_integer(bracket, 'ladder'),
|
|
7553
|
-
'currency': self.safe_currency_code(currency),
|
|
7554
|
-
'minNotional': self.safe_number(bracket, 'min_size'),
|
|
7555
|
-
'maxNotional': self.safe_number(bracket, 'max_size'),
|
|
7556
|
-
'maintenanceMarginRate': self.parse_number(Precise.string_div(adjustFactor, leverage)),
|
|
7557
|
-
'maxLeverage': self.parse_number(leverage),
|
|
7558
|
-
'info': bracket,
|
|
7559
|
-
})
|
|
7560
|
-
result[symbol] = tiers
|
|
7561
|
-
return result
|
|
7887
|
+
def parse_market_leverage_tiers(self, info, market: Market = None) -> List[LeverageTier]:
|
|
7888
|
+
currencyId = self.safe_string(info, 'trade_partition')
|
|
7889
|
+
marketId = self.safe_string(info, 'contract_code')
|
|
7890
|
+
tiers = []
|
|
7891
|
+
brackets = self.safe_list(info, 'list', [])
|
|
7892
|
+
for i in range(0, len(brackets)):
|
|
7893
|
+
item = brackets[i]
|
|
7894
|
+
leverage = self.safe_string(item, 'lever_rate')
|
|
7895
|
+
ladders = self.safe_list(item, 'ladders', [])
|
|
7896
|
+
for k in range(0, len(ladders)):
|
|
7897
|
+
bracket = ladders[k]
|
|
7898
|
+
adjustFactor = self.safe_string(bracket, 'adjust_factor')
|
|
7899
|
+
tiers.append({
|
|
7900
|
+
'tier': self.safe_integer(bracket, 'ladder'),
|
|
7901
|
+
'symbol': self.safe_symbol(marketId, market, None, 'swap'),
|
|
7902
|
+
'currency': self.safe_currency_code(currencyId),
|
|
7903
|
+
'minNotional': self.safe_number(bracket, 'min_size'),
|
|
7904
|
+
'maxNotional': self.safe_number(bracket, 'max_size'),
|
|
7905
|
+
'maintenanceMarginRate': self.parse_number(Precise.string_div(adjustFactor, leverage)),
|
|
7906
|
+
'maxLeverage': self.parse_number(leverage),
|
|
7907
|
+
'info': bracket,
|
|
7908
|
+
})
|
|
7909
|
+
return tiers
|
|
7562
7910
|
|
|
7563
7911
|
def fetch_open_interest_history(self, symbol: str, timeframe='1h', since: Int = None, limit: Int = None, params={}):
|
|
7564
7912
|
"""
|
|
7565
7913
|
Retrieves the open interest history of a currency
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7914
|
+
|
|
7915
|
+
https://huobiapi.github.io/docs/dm/v1/en/#query-information-on-open-interest
|
|
7916
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-information-on-open-interest
|
|
7917
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-information-on-open-interest
|
|
7918
|
+
|
|
7569
7919
|
:param str symbol: Unified CCXT market symbol
|
|
7570
7920
|
:param str timeframe: '1h', '4h', '12h', or '1d'
|
|
7571
7921
|
:param int [since]: Not used by huobi api, but response parsed by CCXT
|
|
@@ -7670,14 +8020,109 @@ class htx(Exchange, ImplicitAPI):
|
|
|
7670
8020
|
#
|
|
7671
8021
|
data = self.safe_value(response, 'data')
|
|
7672
8022
|
tick = self.safe_list(data, 'tick')
|
|
7673
|
-
return self.
|
|
8023
|
+
return self.parse_open_interests_history(tick, market, since, limit)
|
|
8024
|
+
|
|
8025
|
+
def fetch_open_interests(self, symbols: Strings = None, params={}):
|
|
8026
|
+
"""
|
|
8027
|
+
Retrieves the open interest for a list of symbols
|
|
8028
|
+
|
|
8029
|
+
https://huobiapi.github.io/docs/dm/v1/en/#get-contract-open-interest-information
|
|
8030
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-swap-open-interest-information
|
|
8031
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-swap-open-interest-information
|
|
8032
|
+
|
|
8033
|
+
:param str[] [symbols]: a list of unified CCXT market symbols
|
|
8034
|
+
:param dict [params]: exchange specific parameters
|
|
8035
|
+
:returns dict[]: a list of `open interest structures <https://docs.ccxt.com/#/?id=open-interest-structure>`
|
|
8036
|
+
"""
|
|
8037
|
+
self.load_markets()
|
|
8038
|
+
symbols = self.market_symbols(symbols)
|
|
8039
|
+
market = None
|
|
8040
|
+
if symbols is not None:
|
|
8041
|
+
symbolsLength = len(symbols)
|
|
8042
|
+
if symbolsLength > 0:
|
|
8043
|
+
first = self.safe_string(symbols, 0)
|
|
8044
|
+
market = self.market(first)
|
|
8045
|
+
request: dict = {}
|
|
8046
|
+
subType = None
|
|
8047
|
+
subType, params = self.handle_sub_type_and_params('fetchPositions', market, params, 'linear')
|
|
8048
|
+
marketType = None
|
|
8049
|
+
marketType, params = self.handle_market_type_and_params('fetchPositions', market, params)
|
|
8050
|
+
response = None
|
|
8051
|
+
if marketType == 'future':
|
|
8052
|
+
response = self.contractPublicGetApiV1ContractOpenInterest(self.extend(request, params))
|
|
8053
|
+
#
|
|
8054
|
+
# {
|
|
8055
|
+
# "status": "ok",
|
|
8056
|
+
# "data": [
|
|
8057
|
+
# {
|
|
8058
|
+
# "volume": 118850.000000000000000000,
|
|
8059
|
+
# "amount": 635.502025211544374189,
|
|
8060
|
+
# "symbol": "BTC",
|
|
8061
|
+
# "contract_type": "self_week",
|
|
8062
|
+
# "contract_code": "BTC220930",
|
|
8063
|
+
# "trade_amount": 1470.9400749347598691119206024033947897351,
|
|
8064
|
+
# "trade_volume": 286286,
|
|
8065
|
+
# "trade_turnover": 28628600.000000000000000000
|
|
8066
|
+
# }
|
|
8067
|
+
# ],
|
|
8068
|
+
# "ts": 1664337928805
|
|
8069
|
+
# }
|
|
8070
|
+
#
|
|
8071
|
+
elif subType == 'inverse':
|
|
8072
|
+
response = self.contractPublicGetSwapApiV1SwapOpenInterest(self.extend(request, params))
|
|
8073
|
+
#
|
|
8074
|
+
# {
|
|
8075
|
+
# "status": "ok",
|
|
8076
|
+
# "data": [
|
|
8077
|
+
# {
|
|
8078
|
+
# "volume": 518018.000000000000000000,
|
|
8079
|
+
# "amount": 2769.675777407074725180,
|
|
8080
|
+
# "symbol": "BTC",
|
|
8081
|
+
# "contract_code": "BTC-USD",
|
|
8082
|
+
# "trade_amount": 9544.4032080046491323463688602729806842458,
|
|
8083
|
+
# "trade_volume": 1848448,
|
|
8084
|
+
# "trade_turnover": 184844800.000000000000000000
|
|
8085
|
+
# }
|
|
8086
|
+
# ],
|
|
8087
|
+
# "ts": 1664337226028
|
|
8088
|
+
# }
|
|
8089
|
+
#
|
|
8090
|
+
else:
|
|
8091
|
+
request['contract_type'] = 'swap'
|
|
8092
|
+
response = self.contractPublicGetLinearSwapApiV1SwapOpenInterest(self.extend(request, params))
|
|
8093
|
+
#
|
|
8094
|
+
# {
|
|
8095
|
+
# "status": "ok",
|
|
8096
|
+
# "data": [
|
|
8097
|
+
# {
|
|
8098
|
+
# "volume": 7192610.000000000000000000,
|
|
8099
|
+
# "amount": 7192.610000000000000000,
|
|
8100
|
+
# "symbol": "BTC",
|
|
8101
|
+
# "value": 134654290.332000000000000000,
|
|
8102
|
+
# "contract_code": "BTC-USDT",
|
|
8103
|
+
# "trade_amount": 70692.804,
|
|
8104
|
+
# "trade_volume": 70692804,
|
|
8105
|
+
# "trade_turnover": 1379302592.9518,
|
|
8106
|
+
# "business_type": "swap",
|
|
8107
|
+
# "pair": "BTC-USDT",
|
|
8108
|
+
# "contract_type": "swap",
|
|
8109
|
+
# "trade_partition": "USDT"
|
|
8110
|
+
# }
|
|
8111
|
+
# ],
|
|
8112
|
+
# "ts": 1664336503144
|
|
8113
|
+
# }
|
|
8114
|
+
#
|
|
8115
|
+
data = self.safe_list(response, 'data', [])
|
|
8116
|
+
return self.parse_open_interests(data, symbols)
|
|
7674
8117
|
|
|
7675
8118
|
def fetch_open_interest(self, symbol: str, params={}):
|
|
7676
8119
|
"""
|
|
7677
8120
|
Retrieves the open interest of a currency
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
8121
|
+
|
|
8122
|
+
https://huobiapi.github.io/docs/dm/v1/en/#get-contract-open-interest-information
|
|
8123
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-swap-open-interest-information
|
|
8124
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-swap-open-interest-information
|
|
8125
|
+
|
|
7681
8126
|
:param str symbol: Unified CCXT market symbol
|
|
7682
8127
|
:param dict [params]: exchange specific parameters
|
|
7683
8128
|
:returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
|
|
@@ -7828,8 +8273,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
7828
8273
|
timestamp = self.safe_integer(interest, 'ts')
|
|
7829
8274
|
amount = self.safe_number(interest, 'volume')
|
|
7830
8275
|
value = self.safe_number(interest, 'value')
|
|
8276
|
+
marketId = self.safe_string(interest, 'contract_code')
|
|
7831
8277
|
return self.safe_open_interest({
|
|
7832
|
-
'symbol': self.
|
|
8278
|
+
'symbol': self.safe_symbol(marketId, market),
|
|
7833
8279
|
'baseVolume': amount, # deprecated
|
|
7834
8280
|
'quoteVolume': value, # deprecated
|
|
7835
8281
|
'openInterestAmount': amount,
|
|
@@ -7842,8 +8288,10 @@ class htx(Exchange, ImplicitAPI):
|
|
|
7842
8288
|
def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
|
|
7843
8289
|
"""
|
|
7844
8290
|
create a loan to borrow margin
|
|
7845
|
-
|
|
7846
|
-
|
|
8291
|
+
|
|
8292
|
+
https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-isolated
|
|
8293
|
+
https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-cross
|
|
8294
|
+
|
|
7847
8295
|
:param str symbol: unified market symbol, required for isolated margin
|
|
7848
8296
|
:param str code: unified currency code of the currency to borrow
|
|
7849
8297
|
:param float amount: the amount to borrow
|
|
@@ -7875,8 +8323,10 @@ class htx(Exchange, ImplicitAPI):
|
|
|
7875
8323
|
def borrow_cross_margin(self, code: str, amount: float, params={}):
|
|
7876
8324
|
"""
|
|
7877
8325
|
create a loan to borrow margin
|
|
7878
|
-
|
|
7879
|
-
|
|
8326
|
+
|
|
8327
|
+
https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-isolated
|
|
8328
|
+
https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-cross
|
|
8329
|
+
|
|
7880
8330
|
:param str code: unified currency code of the currency to borrow
|
|
7881
8331
|
:param float amount: the amount to borrow
|
|
7882
8332
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
@@ -7905,10 +8355,12 @@ class htx(Exchange, ImplicitAPI):
|
|
|
7905
8355
|
def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
|
|
7906
8356
|
"""
|
|
7907
8357
|
repay borrowed margin and interest
|
|
7908
|
-
|
|
8358
|
+
|
|
8359
|
+
https://huobiapi.github.io/docs/spot/v1/en/#repay-margin-loan-cross-isolated
|
|
8360
|
+
|
|
8361
|
+
:param str symbol: unified market symbol
|
|
7909
8362
|
:param str code: unified currency code of the currency to repay
|
|
7910
8363
|
:param float amount: the amount to repay
|
|
7911
|
-
:param str symbol: unified market symbol
|
|
7912
8364
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
7913
8365
|
:returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
|
|
7914
8366
|
"""
|
|
@@ -7943,7 +8395,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
7943
8395
|
def repay_cross_margin(self, code: str, amount, params={}):
|
|
7944
8396
|
"""
|
|
7945
8397
|
repay borrowed margin and interest
|
|
7946
|
-
|
|
8398
|
+
|
|
8399
|
+
https://huobiapi.github.io/docs/spot/v1/en/#repay-margin-loan-cross-isolated
|
|
8400
|
+
|
|
7947
8401
|
:param str code: unified currency code of the currency to repay
|
|
7948
8402
|
:param float amount: the amount to repay
|
|
7949
8403
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
@@ -8012,6 +8466,11 @@ class htx(Exchange, ImplicitAPI):
|
|
|
8012
8466
|
def fetch_settlement_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
8013
8467
|
"""
|
|
8014
8468
|
Fetches historical settlement records
|
|
8469
|
+
|
|
8470
|
+
https://huobiapi.github.io/docs/dm/v1/en/#query-historical-settlement-records-of-the-platform-interface
|
|
8471
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-historical-settlement-records-of-the-platform-interface
|
|
8472
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-historical-settlement-records-of-the-platform-interface
|
|
8473
|
+
|
|
8015
8474
|
:param str symbol: unified symbol of the market to fetch the settlement history for
|
|
8016
8475
|
:param int [since]: timestamp in ms, value range = current time - 90 days,default = current time - 90 days
|
|
8017
8476
|
:param int [limit]: page items, default 20, shall not exceed 50
|
|
@@ -8105,7 +8564,9 @@ class htx(Exchange, ImplicitAPI):
|
|
|
8105
8564
|
def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
|
|
8106
8565
|
"""
|
|
8107
8566
|
fetch deposit and withdraw fees
|
|
8108
|
-
|
|
8567
|
+
|
|
8568
|
+
https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-currencies-v2
|
|
8569
|
+
|
|
8109
8570
|
:param str[]|None codes: list of unified currency codes
|
|
8110
8571
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
8111
8572
|
:returns dict[]: a list of `fees structures <https://docs.ccxt.com/#/?id=fee-structure>`
|
|
@@ -8306,9 +8767,11 @@ class htx(Exchange, ImplicitAPI):
|
|
|
8306
8767
|
def fetch_liquidations(self, symbol: str, since: Int = None, limit: Int = None, params={}):
|
|
8307
8768
|
"""
|
|
8308
8769
|
retrieves the public liquidations of a trading pair
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8770
|
+
|
|
8771
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-liquidation-orders-new
|
|
8772
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-liquidation-orders-new
|
|
8773
|
+
https://huobiapi.github.io/docs/dm/v1/en/#query-liquidation-order-information-new
|
|
8774
|
+
|
|
8312
8775
|
:param str symbol: unified CCXT market symbol
|
|
8313
8776
|
:param int [since]: the earliest time in ms to fetch liquidations for
|
|
8314
8777
|
:param int [limit]: the maximum number of liquidation structures to retrieve
|
|
@@ -8389,6 +8852,7 @@ class htx(Exchange, ImplicitAPI):
|
|
|
8389
8852
|
'contracts': self.safe_number(liquidation, 'volume'),
|
|
8390
8853
|
'contractSize': self.safe_number(market, 'contractSize'),
|
|
8391
8854
|
'price': self.safe_number(liquidation, 'price'),
|
|
8855
|
+
'side': self.safe_string_lower(liquidation, 'direction'),
|
|
8392
8856
|
'baseValue': self.safe_number(liquidation, 'amount'),
|
|
8393
8857
|
'quoteValue': self.safe_number(liquidation, 'trade_turnover'),
|
|
8394
8858
|
'timestamp': timestamp,
|
|
@@ -8398,17 +8862,19 @@ class htx(Exchange, ImplicitAPI):
|
|
|
8398
8862
|
def close_position(self, symbol: str, side: OrderSide = None, params={}) -> Order:
|
|
8399
8863
|
"""
|
|
8400
8864
|
closes open positions for a contract market, requires 'amount' in params, unlike other exchanges
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8865
|
+
|
|
8866
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-lightning-close-order # USDT-M(isolated)
|
|
8867
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-lightning-close-position # USDT-M(cross)
|
|
8868
|
+
https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-lightning-close-order # Coin-M swap
|
|
8869
|
+
https://huobiapi.github.io/docs/dm/v1/en/#place-flash-close-order # Coin-M futures
|
|
8870
|
+
|
|
8405
8871
|
:param str symbol: unified CCXT market symbol
|
|
8406
8872
|
:param str side: 'buy' or 'sell', the side of the closing order, opposite side side
|
|
8407
8873
|
:param dict [params]: extra parameters specific to the okx api endpoint
|
|
8408
8874
|
:param str [params.clientOrderId]: client needs to provide unique API and have to maintain the API themselves afterwards. [1, 9223372036854775807]
|
|
8409
8875
|
:param dict [params.marginMode]: 'cross' or 'isolated', required for linear markets
|
|
8410
|
-
|
|
8411
|
-
|
|
8876
|
+
|
|
8877
|
+
EXCHANGE SPECIFIC PARAMETERS
|
|
8412
8878
|
:param number [params.amount]: order quantity
|
|
8413
8879
|
:param str [params.order_price_type]: 'lightning' by default, 'lightning_fok': lightning fok type, 'lightning_ioc': lightning ioc type 'market' by default, 'market': market order type, 'lightning_fok': lightning
|
|
8414
8880
|
:returns dict: `an order structure <https://docs.ccxt.com/#/?id=position-structure>`
|
|
@@ -8449,8 +8915,10 @@ class htx(Exchange, ImplicitAPI):
|
|
|
8449
8915
|
def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
|
|
8450
8916
|
"""
|
|
8451
8917
|
set hedged to True or False
|
|
8452
|
-
|
|
8453
|
-
|
|
8918
|
+
|
|
8919
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-position-mode
|
|
8920
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-switch-position-mode
|
|
8921
|
+
|
|
8454
8922
|
: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
|
|
8455
8923
|
:param str [symbol]: unified market symbol, required for isolated margin mode
|
|
8456
8924
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|