ccxt-ir 4.3.46.0.2__py2.py3-none-any.whl → 4.5.0__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 +9 -9
- 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 +7 -7
- 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 +10 -10
- ccxt/async_support/afratether.py +9 -9
- 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 +31 -37
- 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 +25 -24
- 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 +30 -27
- ccxt/async_support/sarmayex.py +9 -9
- ccxt/async_support/sarrafex.py +13 -13
- ccxt/async_support/tabdeal.py +14 -13
- 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 +29 -35
- 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 +22 -21
- 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 +28 -25
- 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 +12 -11
- 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.2.dist-info → ccxt_ir-4.5.0.dist-info}/METADATA +225 -73
- ccxt_ir-4.5.0.dist-info/RECORD +743 -0
- {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info}/WHEEL +1 -1
- 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.2.dist-info/RECORD +0 -772
- /ccxt/abstract/{huobijp.py → bittrade.py} +0 -0
- {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info/licenses}/LICENSE.txt +0 -0
- {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info}/top_level.txt +0 -0
ccxt/xt.py
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.xt import ImplicitAPI
|
|
8
8
|
import hashlib
|
|
9
|
-
from ccxt.base.types import Currencies, Currency, Int, LeverageTier, MarginModification, Market, Num, Order, OrderSide, OrderType, Str, Tickers, Transaction, TransferEntry
|
|
9
|
+
from ccxt.base.types import Any, Currencies, Currency, DepositAddress, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderSide, OrderType, Position, Str, Tickers, FundingRate, Transaction, TransferEntry
|
|
10
10
|
from typing import List
|
|
11
11
|
from ccxt.base.errors import ExchangeError
|
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
|
@@ -27,7 +27,7 @@ from ccxt.base.precise import Precise
|
|
|
27
27
|
|
|
28
28
|
class xt(Exchange, ImplicitAPI):
|
|
29
29
|
|
|
30
|
-
def describe(self):
|
|
30
|
+
def describe(self) -> Any:
|
|
31
31
|
return self.deep_extend(super(xt, self).describe(), {
|
|
32
32
|
'id': 'xt',
|
|
33
33
|
'name': 'XT',
|
|
@@ -39,7 +39,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
39
39
|
'rateLimit': 100,
|
|
40
40
|
'version': 'v4',
|
|
41
41
|
'certified': False,
|
|
42
|
-
'pro':
|
|
42
|
+
'pro': True,
|
|
43
43
|
'has': {
|
|
44
44
|
'CORS': False,
|
|
45
45
|
'spot': True,
|
|
@@ -58,7 +58,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
58
58
|
'createOrder': True,
|
|
59
59
|
'createPostOnlyOrder': False,
|
|
60
60
|
'createReduceOnlyOrder': True,
|
|
61
|
-
'editOrder':
|
|
61
|
+
'editOrder': True,
|
|
62
62
|
'fetchAccounts': False,
|
|
63
63
|
'fetchBalance': True,
|
|
64
64
|
'fetchBidsAsks': True,
|
|
@@ -72,11 +72,15 @@ class xt(Exchange, ImplicitAPI):
|
|
|
72
72
|
'fetchCurrencies': True,
|
|
73
73
|
'fetchDeposit': False,
|
|
74
74
|
'fetchDepositAddress': True,
|
|
75
|
+
'fetchDepositAddresses': False,
|
|
76
|
+
'fetchDepositAddressesByNetwork': False,
|
|
75
77
|
'fetchDeposits': True,
|
|
76
78
|
'fetchDepositWithdrawals': False,
|
|
77
79
|
'fetchDepositWithdrawFee': False,
|
|
78
80
|
'fetchDepositWithdrawFees': False,
|
|
79
81
|
'fetchFundingHistory': True,
|
|
82
|
+
'fetchFundingInterval': True,
|
|
83
|
+
'fetchFundingIntervals': False,
|
|
80
84
|
'fetchFundingRate': True,
|
|
81
85
|
'fetchFundingRateHistory': True,
|
|
82
86
|
'fetchFundingRates': False,
|
|
@@ -124,7 +128,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
124
128
|
'repayMargin': False,
|
|
125
129
|
'setLeverage': True,
|
|
126
130
|
'setMargin': False,
|
|
127
|
-
'setMarginMode':
|
|
131
|
+
'setMarginMode': True,
|
|
128
132
|
'setPositionMode': False,
|
|
129
133
|
'signIn': False,
|
|
130
134
|
'transfer': True,
|
|
@@ -152,16 +156,16 @@ class xt(Exchange, ImplicitAPI):
|
|
|
152
156
|
'spot': {
|
|
153
157
|
'get': {
|
|
154
158
|
'currencies': 1,
|
|
155
|
-
'depth':
|
|
156
|
-
'kline':
|
|
157
|
-
'symbol': 1, #
|
|
158
|
-
'ticker': 1, #
|
|
159
|
-
'ticker/book': 1, #
|
|
160
|
-
'ticker/price': 1, #
|
|
161
|
-
'ticker/24h': 1, #
|
|
159
|
+
'depth': 10,
|
|
160
|
+
'kline': 1,
|
|
161
|
+
'symbol': 1, # 1 for a single symbol
|
|
162
|
+
'ticker': 1, # 1 for a single symbol
|
|
163
|
+
'ticker/book': 1, # 1 for a single symbol
|
|
164
|
+
'ticker/price': 1, # 1 for a single symbol
|
|
165
|
+
'ticker/24h': 1, # 1 for a single symbol
|
|
162
166
|
'time': 1,
|
|
163
|
-
'trade/history':
|
|
164
|
-
'trade/recent':
|
|
167
|
+
'trade/history': 1,
|
|
168
|
+
'trade/recent': 1,
|
|
165
169
|
'wallet/support/currency': 1,
|
|
166
170
|
},
|
|
167
171
|
},
|
|
@@ -231,15 +235,19 @@ class xt(Exchange, ImplicitAPI):
|
|
|
231
235
|
},
|
|
232
236
|
'post': {
|
|
233
237
|
'order': 0.2,
|
|
234
|
-
'withdraw':
|
|
238
|
+
'withdraw': 10,
|
|
235
239
|
'balance/transfer': 1,
|
|
236
240
|
'balance/account/transfer': 1,
|
|
241
|
+
'ws-token': 1,
|
|
237
242
|
},
|
|
238
243
|
'delete': {
|
|
239
244
|
'batch-order': 1,
|
|
240
245
|
'open-order': 1,
|
|
241
246
|
'order/{orderId}': 1,
|
|
242
247
|
},
|
|
248
|
+
'put': {
|
|
249
|
+
'order/{orderId}': 1,
|
|
250
|
+
},
|
|
243
251
|
},
|
|
244
252
|
'linear': {
|
|
245
253
|
'get': {
|
|
@@ -274,6 +282,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
274
282
|
'future/trade/v1/order/cancel-all': 1,
|
|
275
283
|
'future/trade/v1/order/create': 1,
|
|
276
284
|
'future/trade/v1/order/create-batch': 1,
|
|
285
|
+
'future/trade/v1/order/update': 1,
|
|
277
286
|
'future/user/v1/account/open': 1,
|
|
278
287
|
'future/user/v1/position/adjust-leverage': 1,
|
|
279
288
|
'future/user/v1/position/auto-margin': 1,
|
|
@@ -281,6 +290,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
281
290
|
'future/user/v1/position/margin': 1,
|
|
282
291
|
'future/user/v1/user/collection/add': 1,
|
|
283
292
|
'future/user/v1/user/collection/cancel': 1,
|
|
293
|
+
'future/user/v1/position/change-type': 1,
|
|
284
294
|
},
|
|
285
295
|
},
|
|
286
296
|
'inverse': {
|
|
@@ -316,6 +326,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
316
326
|
'future/trade/v1/order/cancel-all': 1,
|
|
317
327
|
'future/trade/v1/order/create': 1,
|
|
318
328
|
'future/trade/v1/order/create-batch': 1,
|
|
329
|
+
'future/trade/v1/order/update': 1,
|
|
319
330
|
'future/user/v1/account/open': 1,
|
|
320
331
|
'future/user/v1/position/adjust-leverage': 1,
|
|
321
332
|
'future/user/v1/position/auto-margin': 1,
|
|
@@ -526,10 +537,12 @@ class xt(Exchange, ImplicitAPI):
|
|
|
526
537
|
'TRANSFER_012': PermissionDenied, # Currency transfer prohibited
|
|
527
538
|
'symbol_not_support_trading_via_api': BadSymbol, # {"returnCode":1,"msgInfo":"failure","error":{"code":"symbol_not_support_trading_via_api","msg":"The symbol does not support trading via API"},"result":null}
|
|
528
539
|
'open_order_min_nominal_value_limit': InvalidOrder, # {"returnCode":1,"msgInfo":"failure","error":{"code":"open_order_min_nominal_value_limit","msg":"Exceeds the minimum notional value of a single order"},"result":null}
|
|
540
|
+
'insufficient_balance': InsufficientFunds,
|
|
529
541
|
},
|
|
530
542
|
'broad': {
|
|
531
543
|
'The symbol does not support trading via API': BadSymbol, # {"returnCode":1,"msgInfo":"failure","error":{"code":"symbol_not_support_trading_via_api","msg":"The symbol does not support trading via API"},"result":null}
|
|
532
544
|
'Exceeds the minimum notional value of a single order': InvalidOrder, # {"returnCode":1,"msgInfo":"failure","error":{"code":"open_order_min_nominal_value_limit","msg":"Exceeds the minimum notional value of a single order"},"result":null}
|
|
545
|
+
'insufficient balance': InsufficientFunds,
|
|
533
546
|
},
|
|
534
547
|
},
|
|
535
548
|
'timeframes': {
|
|
@@ -682,15 +695,134 @@ class xt(Exchange, ImplicitAPI):
|
|
|
682
695
|
'createMarketBuyOrderRequiresPrice': True,
|
|
683
696
|
'recvWindow': '5000', # in milliseconds, spot only
|
|
684
697
|
},
|
|
698
|
+
'features': {
|
|
699
|
+
'default': {
|
|
700
|
+
'sandbox': False,
|
|
701
|
+
'createOrder': {
|
|
702
|
+
'marginMode': False,
|
|
703
|
+
'triggerPrice': False,
|
|
704
|
+
'triggerDirection': False,
|
|
705
|
+
'triggerPriceType': None,
|
|
706
|
+
'stopLossPrice': False,
|
|
707
|
+
'takeProfitPrice': False,
|
|
708
|
+
'attachedStopLossTakeProfit': None,
|
|
709
|
+
'timeInForce': {
|
|
710
|
+
'IOC': True,
|
|
711
|
+
'FOK': True,
|
|
712
|
+
'PO': True,
|
|
713
|
+
'GTD': False,
|
|
714
|
+
},
|
|
715
|
+
'hedged': False,
|
|
716
|
+
'trailing': False,
|
|
717
|
+
'leverage': False,
|
|
718
|
+
'marketBuyByCost': True,
|
|
719
|
+
'marketBuyRequiresPrice': False,
|
|
720
|
+
'selfTradePrevention': False,
|
|
721
|
+
'iceberg': False,
|
|
722
|
+
},
|
|
723
|
+
'createOrders': None,
|
|
724
|
+
'fetchMyTrades': {
|
|
725
|
+
'marginMode': True,
|
|
726
|
+
'limit': 100,
|
|
727
|
+
'daysBack': 100000, # todo
|
|
728
|
+
'untilDays': 100000, # todo
|
|
729
|
+
'marketType': True,
|
|
730
|
+
'subType': True,
|
|
731
|
+
'symbolRequired': False,
|
|
732
|
+
},
|
|
733
|
+
'fetchOrder': {
|
|
734
|
+
'marginMode': False,
|
|
735
|
+
'trigger': True, # todo TPSL kind
|
|
736
|
+
'trailing': False,
|
|
737
|
+
'marketType': True,
|
|
738
|
+
'subType': True,
|
|
739
|
+
'symbolRequired': False,
|
|
740
|
+
},
|
|
741
|
+
'fetchOpenOrders': {
|
|
742
|
+
'marginMode': True,
|
|
743
|
+
'limit': 100,
|
|
744
|
+
'trigger': True, # todo TPSL
|
|
745
|
+
'trailing': False,
|
|
746
|
+
'marketType': True,
|
|
747
|
+
'subType': True,
|
|
748
|
+
'symbolRequired': False,
|
|
749
|
+
},
|
|
750
|
+
'fetchOrders': {
|
|
751
|
+
'marginMode': True,
|
|
752
|
+
'limit': 100,
|
|
753
|
+
'daysBack': 100000, # todo
|
|
754
|
+
'untilDays': 100000, # todo
|
|
755
|
+
'trigger': True, # todo TPSL
|
|
756
|
+
'trailing': False,
|
|
757
|
+
'marketType': True,
|
|
758
|
+
'subType': True,
|
|
759
|
+
'symbolRequired': False,
|
|
760
|
+
},
|
|
761
|
+
'fetchClosedOrders': {
|
|
762
|
+
'marginMode': True,
|
|
763
|
+
'limit': 100,
|
|
764
|
+
'daysBack': 100000, # todo
|
|
765
|
+
'daysBackCanceled': 1, # todo
|
|
766
|
+
'untilDays': 100000, # todo
|
|
767
|
+
'trigger': True, # todo TPSL
|
|
768
|
+
'trailing': False,
|
|
769
|
+
'marketType': True,
|
|
770
|
+
'subType': True,
|
|
771
|
+
'symbolRequired': False,
|
|
772
|
+
},
|
|
773
|
+
'fetchOHLCV': {
|
|
774
|
+
'limit': 1000, # todo for derivatives
|
|
775
|
+
},
|
|
776
|
+
},
|
|
777
|
+
'spot': {
|
|
778
|
+
'extends': 'default',
|
|
779
|
+
},
|
|
780
|
+
'forDerivatives': {
|
|
781
|
+
'extends': 'default',
|
|
782
|
+
'createOrder': {
|
|
783
|
+
'triggerPrice': True,
|
|
784
|
+
# todo
|
|
785
|
+
'triggerPriceType': {
|
|
786
|
+
'last': True,
|
|
787
|
+
'mark': True,
|
|
788
|
+
'index': True,
|
|
789
|
+
},
|
|
790
|
+
'stopLossPrice': True,
|
|
791
|
+
'takeProfitPrice': True,
|
|
792
|
+
},
|
|
793
|
+
'fetchMyTrades': {
|
|
794
|
+
'daysBack': None,
|
|
795
|
+
'untilDays': None,
|
|
796
|
+
},
|
|
797
|
+
},
|
|
798
|
+
'swap': {
|
|
799
|
+
'linear': {
|
|
800
|
+
'extends': 'forDerivatives',
|
|
801
|
+
},
|
|
802
|
+
'inverse': {
|
|
803
|
+
'extends': 'forDerivatives',
|
|
804
|
+
},
|
|
805
|
+
},
|
|
806
|
+
'future': {
|
|
807
|
+
'linear': {
|
|
808
|
+
'extends': 'forDerivatives',
|
|
809
|
+
},
|
|
810
|
+
'inverse': {
|
|
811
|
+
'extends': 'forDerivatives',
|
|
812
|
+
},
|
|
813
|
+
},
|
|
814
|
+
},
|
|
685
815
|
})
|
|
686
816
|
|
|
687
817
|
def nonce(self):
|
|
688
818
|
return self.milliseconds() - self.options['timeDifference']
|
|
689
819
|
|
|
690
|
-
def fetch_time(self, params={}):
|
|
820
|
+
def fetch_time(self, params={}) -> Int:
|
|
691
821
|
"""
|
|
692
822
|
fetches the current integer timestamp in milliseconds from the xt server
|
|
693
|
-
|
|
823
|
+
|
|
824
|
+
https://doc.xt.com/#market1serverInfo
|
|
825
|
+
|
|
694
826
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
695
827
|
:returns int: the current integer timestamp in milliseconds from the xt server
|
|
696
828
|
"""
|
|
@@ -711,7 +843,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
711
843
|
def fetch_currencies(self, params={}) -> Currencies:
|
|
712
844
|
"""
|
|
713
845
|
fetches all available currencies on an exchange
|
|
714
|
-
|
|
846
|
+
|
|
847
|
+
https://doc.xt.com/#deposit_withdrawalsupportedCurrenciesGet
|
|
848
|
+
|
|
715
849
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
716
850
|
:returns dict: an associative dictionary of currencies
|
|
717
851
|
"""
|
|
@@ -777,48 +911,30 @@ class xt(Exchange, ImplicitAPI):
|
|
|
777
911
|
entry = currenciesData[i]
|
|
778
912
|
currencyId = self.safe_string(entry, 'currency')
|
|
779
913
|
code = self.safe_currency_code(currencyId)
|
|
780
|
-
minPrecision = self.parse_number(self.parse_precision(self.safe_string(entry, 'maxPrecision')))
|
|
781
914
|
networkEntry = self.safe_value(chainsDataIndexed, currencyId, {})
|
|
782
915
|
rawNetworks = self.safe_value(networkEntry, 'supportChains', [])
|
|
783
916
|
networks = {}
|
|
784
|
-
minWithdrawString = None
|
|
785
|
-
minWithdrawFeeString = None
|
|
786
|
-
active = False
|
|
787
|
-
deposit = False
|
|
788
|
-
withdraw = False
|
|
789
917
|
for j in range(0, len(rawNetworks)):
|
|
790
918
|
rawNetwork = rawNetworks[j]
|
|
791
919
|
networkId = self.safe_string(rawNetwork, 'chain')
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
deposit = depositEnabled if (depositEnabled) else deposit
|
|
795
|
-
withdrawEnabled = self.safe_value(rawNetwork, 'withdrawEnabled')
|
|
796
|
-
withdraw = withdrawEnabled if (withdrawEnabled) else withdraw
|
|
797
|
-
networkActive = depositEnabled and withdrawEnabled
|
|
798
|
-
active = networkActive if (networkActive) else active
|
|
799
|
-
withdrawFeeString = self.safe_string(rawNetwork, 'withdrawFeeAmount')
|
|
800
|
-
if withdrawFeeString is not None:
|
|
801
|
-
minWithdrawFeeString = withdrawFeeString if (minWithdrawFeeString is None) else Precise.string_min(withdrawFeeString, minWithdrawFeeString)
|
|
802
|
-
minNetworkWithdrawString = self.safe_string(rawNetwork, 'withdrawMinAmount')
|
|
803
|
-
if minNetworkWithdrawString is not None:
|
|
804
|
-
minWithdrawString = minNetworkWithdrawString if (minWithdrawString is None) else Precise.string_min(minNetworkWithdrawString, minWithdrawString)
|
|
805
|
-
networks[network] = {
|
|
920
|
+
networkCode = self.network_id_to_code(networkId, code)
|
|
921
|
+
networks[networkCode] = {
|
|
806
922
|
'info': rawNetwork,
|
|
807
923
|
'id': networkId,
|
|
808
|
-
'network':
|
|
924
|
+
'network': networkCode,
|
|
809
925
|
'name': None,
|
|
810
|
-
'active':
|
|
811
|
-
'fee': self.
|
|
812
|
-
'precision':
|
|
813
|
-
'deposit': depositEnabled,
|
|
814
|
-
'withdraw': withdrawEnabled,
|
|
926
|
+
'active': None,
|
|
927
|
+
'fee': self.safe_number(rawNetwork, 'withdrawFeeAmount'),
|
|
928
|
+
'precision': None,
|
|
929
|
+
'deposit': self.safe_bool(rawNetwork, 'depositEnabled'),
|
|
930
|
+
'withdraw': self.safe_bool(rawNetwork, 'withdrawEnabled'),
|
|
815
931
|
'limits': {
|
|
816
932
|
'amount': {
|
|
817
933
|
'min': None,
|
|
818
934
|
'max': None,
|
|
819
935
|
},
|
|
820
936
|
'withdraw': {
|
|
821
|
-
'min': self.
|
|
937
|
+
'min': self.safe_number(rawNetwork, 'withdrawMinAmount'),
|
|
822
938
|
'max': None,
|
|
823
939
|
},
|
|
824
940
|
'deposit': {
|
|
@@ -827,24 +943,31 @@ class xt(Exchange, ImplicitAPI):
|
|
|
827
943
|
},
|
|
828
944
|
},
|
|
829
945
|
}
|
|
830
|
-
|
|
946
|
+
typeRaw = self.safe_string(entry, 'type')
|
|
947
|
+
type: Str = None
|
|
948
|
+
if typeRaw == 'FT':
|
|
949
|
+
type = 'crypto'
|
|
950
|
+
else:
|
|
951
|
+
type = 'other'
|
|
952
|
+
result[code] = self.safe_currency_structure({
|
|
831
953
|
'info': entry,
|
|
832
954
|
'id': currencyId,
|
|
833
955
|
'code': code,
|
|
834
956
|
'name': self.safe_string(entry, 'fullName'),
|
|
835
|
-
'active':
|
|
836
|
-
'fee':
|
|
837
|
-
'precision':
|
|
838
|
-
'deposit':
|
|
839
|
-
'withdraw':
|
|
957
|
+
'active': None,
|
|
958
|
+
'fee': None,
|
|
959
|
+
'precision': self.parse_number(self.parse_precision(self.safe_string(entry, 'maxPrecision'))),
|
|
960
|
+
'deposit': self.safe_string(entry, 'depositStatus') == '1',
|
|
961
|
+
'withdraw': self.safe_string(entry, 'withdrawStatus') == '1',
|
|
840
962
|
'networks': networks,
|
|
963
|
+
'type': type,
|
|
841
964
|
'limits': {
|
|
842
965
|
'amount': {
|
|
843
966
|
'min': None,
|
|
844
967
|
'max': None,
|
|
845
968
|
},
|
|
846
969
|
'withdraw': {
|
|
847
|
-
'min':
|
|
970
|
+
'min': None,
|
|
848
971
|
'max': None,
|
|
849
972
|
},
|
|
850
973
|
'deposit': {
|
|
@@ -852,14 +975,16 @@ class xt(Exchange, ImplicitAPI):
|
|
|
852
975
|
'max': None,
|
|
853
976
|
},
|
|
854
977
|
},
|
|
855
|
-
}
|
|
978
|
+
})
|
|
856
979
|
return result
|
|
857
980
|
|
|
858
981
|
def fetch_markets(self, params={}) -> List[Market]:
|
|
859
982
|
"""
|
|
860
983
|
retrieves data on all markets for xt
|
|
861
|
-
|
|
862
|
-
|
|
984
|
+
|
|
985
|
+
https://doc.xt.com/#market2symbol
|
|
986
|
+
https://doc.xt.com/#futures_quotesgetSymbols
|
|
987
|
+
|
|
863
988
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
864
989
|
:returns dict[]: an array of objects representing market data
|
|
865
990
|
"""
|
|
@@ -1136,17 +1261,21 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1136
1261
|
maxCost = None
|
|
1137
1262
|
minPrice = None
|
|
1138
1263
|
maxPrice = None
|
|
1264
|
+
amountPrecision = None
|
|
1139
1265
|
for i in range(0, len(filters)):
|
|
1140
1266
|
entry = filters[i]
|
|
1141
1267
|
filter = self.safe_string(entry, 'filter')
|
|
1142
1268
|
if filter == 'QUANTITY':
|
|
1143
1269
|
minAmount = self.safe_number(entry, 'min')
|
|
1144
1270
|
maxAmount = self.safe_number(entry, 'max')
|
|
1271
|
+
amountPrecision = self.safe_number(entry, 'tickSize')
|
|
1145
1272
|
if filter == 'QUOTE_QTY':
|
|
1146
1273
|
minCost = self.safe_number(entry, 'min')
|
|
1147
1274
|
if filter == 'PRICE':
|
|
1148
1275
|
minPrice = self.safe_number(entry, 'min')
|
|
1149
1276
|
maxPrice = self.safe_number(entry, 'max')
|
|
1277
|
+
if amountPrecision is None:
|
|
1278
|
+
amountPrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'quantityPrecision')))
|
|
1150
1279
|
underlyingType = self.safe_string(market, 'underlyingType')
|
|
1151
1280
|
linear = None
|
|
1152
1281
|
inverse = None
|
|
@@ -1221,7 +1350,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1221
1350
|
'optionType': None,
|
|
1222
1351
|
'precision': {
|
|
1223
1352
|
'price': self.parse_number(self.parse_precision(self.safe_string(market, 'pricePrecision'))),
|
|
1224
|
-
'amount':
|
|
1353
|
+
'amount': amountPrecision,
|
|
1225
1354
|
'base': self.parse_number(self.parse_precision(self.safe_string(market, 'baseCoinPrecision'))),
|
|
1226
1355
|
'quote': self.parse_number(self.parse_precision(self.safe_string(market, 'quoteCoinPrecision'))),
|
|
1227
1356
|
},
|
|
@@ -1249,16 +1378,24 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1249
1378
|
def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}):
|
|
1250
1379
|
"""
|
|
1251
1380
|
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
1252
|
-
|
|
1253
|
-
|
|
1381
|
+
|
|
1382
|
+
https://doc.xt.com/#market4kline
|
|
1383
|
+
https://doc.xt.com/#futures_quotesgetKLine
|
|
1384
|
+
|
|
1254
1385
|
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
|
1255
1386
|
:param str timeframe: the length of time each candle represents
|
|
1256
1387
|
:param int [since]: timestamp in ms of the earliest candle to fetch
|
|
1257
1388
|
:param int [limit]: the maximum amount of candles to fetch
|
|
1258
1389
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
1390
|
+
:param int [params.until]: timestamp in ms of the latest candle to fetch
|
|
1391
|
+
: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)
|
|
1259
1392
|
:returns int[][]: A list of candles ordered, open, high, low, close, volume
|
|
1260
1393
|
"""
|
|
1261
1394
|
self.load_markets()
|
|
1395
|
+
paginate = False
|
|
1396
|
+
paginate, params = self.handle_option_and_params(params, 'fetchOHLCV', 'paginate', False)
|
|
1397
|
+
if paginate:
|
|
1398
|
+
return self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000)
|
|
1262
1399
|
market = self.market(symbol)
|
|
1263
1400
|
request = {
|
|
1264
1401
|
'symbol': market['id'],
|
|
@@ -1268,6 +1405,12 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1268
1405
|
request['startTime'] = since
|
|
1269
1406
|
if limit is not None:
|
|
1270
1407
|
request['limit'] = limit
|
|
1408
|
+
else:
|
|
1409
|
+
request['limit'] = 1000
|
|
1410
|
+
until = self.safe_integer(params, 'until')
|
|
1411
|
+
params = self.omit(params, ['until'])
|
|
1412
|
+
if until is not None:
|
|
1413
|
+
request['endTime'] = until
|
|
1271
1414
|
response = None
|
|
1272
1415
|
if market['linear']:
|
|
1273
1416
|
response = self.publicLinearGetFutureMarketV1PublicQKline(self.extend(request, params))
|
|
@@ -1354,13 +1497,15 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1354
1497
|
self.safe_number(ohlcv, 'h'),
|
|
1355
1498
|
self.safe_number(ohlcv, 'l'),
|
|
1356
1499
|
self.safe_number(ohlcv, 'c'),
|
|
1357
|
-
self.safe_number_2(ohlcv,
|
|
1500
|
+
self.safe_number_2(ohlcv, 'q', volumeIndex),
|
|
1358
1501
|
]
|
|
1359
1502
|
|
|
1360
1503
|
def fetch_order_book(self, symbol: str, limit: Int = None, params={}):
|
|
1361
1504
|
"""
|
|
1362
|
-
|
|
1363
|
-
|
|
1505
|
+
|
|
1506
|
+
https://doc.xt.com/#market3depth
|
|
1507
|
+
https://doc.xt.com/#futures_quotesgetDepth
|
|
1508
|
+
|
|
1364
1509
|
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
|
1365
1510
|
:param str symbol: unified market symbol to fetch the order book for
|
|
1366
1511
|
:param int [limit]: the maximum amount of order book entries to return
|
|
@@ -1435,14 +1580,20 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1435
1580
|
orderBook = self.safe_value(response, 'result', {})
|
|
1436
1581
|
timestamp = self.safe_integer_2(orderBook, 'timestamp', 't')
|
|
1437
1582
|
if market['spot']:
|
|
1438
|
-
|
|
1439
|
-
|
|
1583
|
+
ob = self.parse_order_book(orderBook, symbol, timestamp)
|
|
1584
|
+
ob['nonce'] = self.safe_integer(orderBook, 'lastUpdateId')
|
|
1585
|
+
return ob
|
|
1586
|
+
swapOb = self.parse_order_book(orderBook, symbol, timestamp, 'b', 'a')
|
|
1587
|
+
swapOb['nonce'] = self.safe_integer_2(orderBook, 'u', 'lastUpdateId')
|
|
1588
|
+
return swapOb
|
|
1440
1589
|
|
|
1441
1590
|
def fetch_ticker(self, symbol: str, params={}):
|
|
1442
1591
|
"""
|
|
1443
1592
|
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
1444
|
-
|
|
1445
|
-
|
|
1593
|
+
|
|
1594
|
+
https://doc.xt.com/#market10ticker24h
|
|
1595
|
+
https://doc.xt.com/#futures_quotesgetAggTicker
|
|
1596
|
+
|
|
1446
1597
|
:param str symbol: unified market symbol to fetch the ticker for
|
|
1447
1598
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
1448
1599
|
:returns dict: a `ticker structure <https://docs.ccxt.com/en/latest/manual.html#ticker-structure>`
|
|
@@ -1513,8 +1664,10 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1513
1664
|
def fetch_tickers(self, symbols: List[str] = None, params={}) -> Tickers:
|
|
1514
1665
|
"""
|
|
1515
1666
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
|
1516
|
-
|
|
1517
|
-
|
|
1667
|
+
|
|
1668
|
+
https://doc.xt.com/#market10ticker24h
|
|
1669
|
+
https://doc.xt.com/#futures_quotesgetAggTickers
|
|
1670
|
+
|
|
1518
1671
|
:param str [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1519
1672
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
1520
1673
|
:returns dict: an array of `ticker structures <https://docs.ccxt.com/en/latest/manual.html#ticker-structure>`
|
|
@@ -1595,7 +1748,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1595
1748
|
def fetch_bids_asks(self, symbols: List[str] = None, params={}):
|
|
1596
1749
|
"""
|
|
1597
1750
|
fetches the bid and ask price and volume for multiple markets
|
|
1598
|
-
|
|
1751
|
+
|
|
1752
|
+
https://doc.xt.com/#market9tickerBook
|
|
1753
|
+
|
|
1599
1754
|
:param str [symbols]: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
|
|
1600
1755
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
1601
1756
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/en/latest/manual.html#ticker-structure>`
|
|
@@ -1679,11 +1834,15 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1679
1834
|
#
|
|
1680
1835
|
marketId = self.safe_string(ticker, 's')
|
|
1681
1836
|
marketType = market['type'] if (market is not None) else None
|
|
1837
|
+
hasSpotKeys = ('cv' in ticker) or ('aq' in ticker)
|
|
1682
1838
|
if marketType is None:
|
|
1683
|
-
marketType =
|
|
1839
|
+
marketType = 'spot' if hasSpotKeys else 'contract'
|
|
1684
1840
|
market = self.safe_market(marketId, market, '_', marketType)
|
|
1685
1841
|
symbol = market['symbol']
|
|
1686
1842
|
timestamp = self.safe_integer(ticker, 't')
|
|
1843
|
+
percentage = self.safe_string_2(ticker, 'cr', 'r')
|
|
1844
|
+
if percentage is not None:
|
|
1845
|
+
percentage = Precise.string_mul(percentage, '100')
|
|
1687
1846
|
return self.safe_ticker({
|
|
1688
1847
|
'symbol': symbol,
|
|
1689
1848
|
'timestamp': timestamp,
|
|
@@ -1700,7 +1859,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1700
1859
|
'last': self.safe_string(ticker, 'c'),
|
|
1701
1860
|
'previousClose': None,
|
|
1702
1861
|
'change': self.safe_number(ticker, 'cv'),
|
|
1703
|
-
'percentage': self.
|
|
1862
|
+
'percentage': self.parse_number(percentage),
|
|
1704
1863
|
'average': None,
|
|
1705
1864
|
'baseVolume': None,
|
|
1706
1865
|
'quoteVolume': self.safe_number_2(ticker, 'a', 'v'),
|
|
@@ -1710,8 +1869,10 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1710
1869
|
def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}):
|
|
1711
1870
|
"""
|
|
1712
1871
|
get the list of most recent trades for a particular symbol
|
|
1713
|
-
|
|
1714
|
-
|
|
1872
|
+
|
|
1873
|
+
https://doc.xt.com/#market5tradeRecent
|
|
1874
|
+
https://doc.xt.com/#futures_quotesgetDeal
|
|
1875
|
+
|
|
1715
1876
|
:param str symbol: unified market symbol to fetch trades for
|
|
1716
1877
|
:param int [since]: timestamp in ms of the earliest trade to fetch
|
|
1717
1878
|
:param int [limit]: the maximum amount of trades to fetch
|
|
@@ -1777,8 +1938,10 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1777
1938
|
def fetch_my_trades(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
|
|
1778
1939
|
"""
|
|
1779
1940
|
fetch all trades made by the user
|
|
1780
|
-
|
|
1781
|
-
|
|
1941
|
+
|
|
1942
|
+
https://doc.xt.com/#tradetradeGet
|
|
1943
|
+
https://doc.xt.com/#futures_ordergetTrades
|
|
1944
|
+
|
|
1782
1945
|
:param str [symbol]: unified market symbol to fetch trades for
|
|
1783
1946
|
:param int [since]: timestamp in ms of the earliest trade to fetch
|
|
1784
1947
|
:param int [limit]: the maximum amount of trades to fetch
|
|
@@ -1888,6 +2051,29 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1888
2051
|
# "b": True
|
|
1889
2052
|
# }
|
|
1890
2053
|
#
|
|
2054
|
+
# spot: watchTrades
|
|
2055
|
+
#
|
|
2056
|
+
# {
|
|
2057
|
+
# s: 'btc_usdt',
|
|
2058
|
+
# i: '228825383103928709',
|
|
2059
|
+
# t: 1684258222702,
|
|
2060
|
+
# p: '27003.65',
|
|
2061
|
+
# q: '0.000796',
|
|
2062
|
+
# b: True
|
|
2063
|
+
# }
|
|
2064
|
+
#
|
|
2065
|
+
# spot: watchMyTrades
|
|
2066
|
+
#
|
|
2067
|
+
# {
|
|
2068
|
+
# "s": "btc_usdt", # symbol
|
|
2069
|
+
# "t": 1656043204763, # time
|
|
2070
|
+
# "i": "6316559590087251233", # tradeId
|
|
2071
|
+
# "oi": "6216559590087220004", # orderId
|
|
2072
|
+
# "p": "30000", # trade price
|
|
2073
|
+
# "q": "3", # qty quantity
|
|
2074
|
+
# "v": "90000" # volume trade amount
|
|
2075
|
+
# }
|
|
2076
|
+
#
|
|
1891
2077
|
# swap and future: fetchTrades
|
|
1892
2078
|
#
|
|
1893
2079
|
# {
|
|
@@ -1932,19 +2118,61 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1932
2118
|
# "takerMaker": "TAKER"
|
|
1933
2119
|
# }
|
|
1934
2120
|
#
|
|
2121
|
+
# contract watchMyTrades
|
|
2122
|
+
#
|
|
2123
|
+
# {
|
|
2124
|
+
# "symbol": 'btc_usdt',
|
|
2125
|
+
# "orderSide": 'SELL',
|
|
2126
|
+
# "positionSide": 'LONG',
|
|
2127
|
+
# "orderId": '231485367663419328',
|
|
2128
|
+
# "price": '27152.7',
|
|
2129
|
+
# "quantity": '33',
|
|
2130
|
+
# "marginUnfrozen": '2.85318000',
|
|
2131
|
+
# "timestamp": 1684892412565
|
|
2132
|
+
# }
|
|
2133
|
+
#
|
|
2134
|
+
# watchMyTrades(ws, swap)
|
|
2135
|
+
#
|
|
2136
|
+
# {
|
|
2137
|
+
# 'fee': '0.04080840',
|
|
2138
|
+
# 'isMaker': False,
|
|
2139
|
+
# 'marginUnfrozen': '0.75711984',
|
|
2140
|
+
# 'orderId': '376172779053188416',
|
|
2141
|
+
# 'orderSide': 'BUY',
|
|
2142
|
+
# 'positionSide': 'LONG',
|
|
2143
|
+
# 'price': '3400.70',
|
|
2144
|
+
# 'quantity': '2',
|
|
2145
|
+
# 'symbol': 'eth_usdt',
|
|
2146
|
+
# 'timestamp': 1719388579622
|
|
2147
|
+
# }
|
|
2148
|
+
#
|
|
1935
2149
|
marketId = self.safe_string_2(trade, 's', 'symbol')
|
|
1936
2150
|
marketType = market['type'] if (market is not None) else None
|
|
2151
|
+
hasSpotKeys = ('b' in trade) or ('bizType' in trade) or ('oi' in trade)
|
|
1937
2152
|
if marketType is None:
|
|
1938
|
-
marketType =
|
|
2153
|
+
marketType = 'spot' if hasSpotKeys else 'contract'
|
|
1939
2154
|
market = self.safe_market(marketId, market, '_', marketType)
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
2155
|
+
side = None
|
|
2156
|
+
takerOrMaker = None
|
|
2157
|
+
isBuyerMaker = self.safe_bool(trade, 'b')
|
|
2158
|
+
if isBuyerMaker is not None:
|
|
2159
|
+
side = 'sell' if isBuyerMaker else 'buy'
|
|
2160
|
+
takerOrMaker = 'taker' # public trades always taker
|
|
2161
|
+
else:
|
|
2162
|
+
takerMaker = self.safe_string_lower(trade, 'takerMaker')
|
|
2163
|
+
if takerMaker is not None:
|
|
2164
|
+
takerOrMaker = takerMaker
|
|
2165
|
+
else:
|
|
2166
|
+
isMaker = self.safe_bool(trade, 'isMaker')
|
|
2167
|
+
if isMaker is not None:
|
|
2168
|
+
takerOrMaker = 'maker' if isMaker else 'taker'
|
|
2169
|
+
orderSide = self.safe_string_lower(trade, 'orderSide')
|
|
2170
|
+
if orderSide is not None:
|
|
2171
|
+
side = orderSide
|
|
2172
|
+
else:
|
|
2173
|
+
bidOrAsk = self.safe_string(trade, 'm')
|
|
2174
|
+
if bidOrAsk is not None:
|
|
2175
|
+
side = 'buy' if (bidOrAsk == 'BID') else 'sell'
|
|
1948
2176
|
timestamp = self.safe_integer_n(trade, ['t', 'time', 'timestamp'])
|
|
1949
2177
|
quantity = self.safe_string_2(trade, 'q', 'quantity')
|
|
1950
2178
|
amount = None
|
|
@@ -1961,7 +2189,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1961
2189
|
'timestamp': timestamp,
|
|
1962
2190
|
'datetime': self.iso8601(timestamp),
|
|
1963
2191
|
'symbol': market['symbol'],
|
|
1964
|
-
'order': self.
|
|
2192
|
+
'order': self.safe_string_2(trade, 'orderId', 'oi'),
|
|
1965
2193
|
'type': self.safe_string_lower(trade, 'orderType'),
|
|
1966
2194
|
'side': side,
|
|
1967
2195
|
'takerOrMaker': takerOrMaker,
|
|
@@ -1971,15 +2199,16 @@ class xt(Exchange, ImplicitAPI):
|
|
|
1971
2199
|
'fee': {
|
|
1972
2200
|
'currency': self.safe_currency_code(self.safe_string_2(trade, 'feeCurrency', 'feeCoin')),
|
|
1973
2201
|
'cost': self.safe_string(trade, 'fee'),
|
|
1974
|
-
'rate': None,
|
|
1975
2202
|
},
|
|
1976
2203
|
}, market)
|
|
1977
2204
|
|
|
1978
2205
|
def fetch_balance(self, params={}):
|
|
1979
2206
|
"""
|
|
1980
2207
|
query for balance and get the amount of funds available for trading or funds locked in orders
|
|
1981
|
-
|
|
1982
|
-
|
|
2208
|
+
|
|
2209
|
+
https://doc.xt.com/#balancebalancesGet
|
|
2210
|
+
https://doc.xt.com/#futures_usergetBalances
|
|
2211
|
+
|
|
1983
2212
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
1984
2213
|
:returns dict: a `balance structure <https://docs.ccxt.com/en/latest/manual.html?#balance-structure>`
|
|
1985
2214
|
"""
|
|
@@ -2095,7 +2324,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2095
2324
|
|
|
2096
2325
|
def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
|
|
2097
2326
|
"""
|
|
2098
|
-
|
|
2327
|
+
|
|
2328
|
+
https://doc.xt.com/#orderorderPost
|
|
2329
|
+
|
|
2099
2330
|
create a market buy order by providing the symbol and cost
|
|
2100
2331
|
:param str symbol: unified symbol of the market to create an order in
|
|
2101
2332
|
:param float cost: how much you want to trade in units of the quote currency
|
|
@@ -2111,10 +2342,12 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2111
2342
|
def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
|
2112
2343
|
"""
|
|
2113
2344
|
create a trade order
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2345
|
+
|
|
2346
|
+
https://doc.xt.com/#orderorderPost
|
|
2347
|
+
https://doc.xt.com/#futures_ordercreate
|
|
2348
|
+
https://doc.xt.com/#futures_entrustcreatePlan
|
|
2349
|
+
https://doc.xt.com/#futures_entrustcreateProfit
|
|
2350
|
+
|
|
2118
2351
|
:param str symbol: unified symbol of the market to create an order in
|
|
2119
2352
|
:param str type: 'market' or 'limit'
|
|
2120
2353
|
:param str side: 'buy' or 'sell'
|
|
@@ -2124,7 +2357,8 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2124
2357
|
:param str [params.timeInForce]: 'GTC', 'IOC', 'FOK' or 'GTX'
|
|
2125
2358
|
:param str [params.entrustType]: 'TAKE_PROFIT', 'STOP', 'TAKE_PROFIT_MARKET', 'STOP_MARKET', 'TRAILING_STOP_MARKET', required if stopPrice is defined, currently isn't functioning on xt's side
|
|
2126
2359
|
:param str [params.triggerPriceType]: 'INDEX_PRICE', 'MARK_PRICE', 'LATEST_PRICE', required if stopPrice is defined
|
|
2127
|
-
:param float [params.
|
|
2360
|
+
:param float [params.triggerPrice]: price to trigger a stop order
|
|
2361
|
+
:param float [params.stopPrice]: alias for triggerPrice
|
|
2128
2362
|
:param float [params.stopLoss]: price to set a stop-loss on an open position
|
|
2129
2363
|
:param float [params.takeProfit]: price to set a take-profit on an open position
|
|
2130
2364
|
:returns dict: an `order structure <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
|
|
@@ -2260,14 +2494,16 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2260
2494
|
def fetch_order(self, id: str, symbol: str = None, params={}):
|
|
2261
2495
|
"""
|
|
2262
2496
|
fetches information on an order made by the user
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2497
|
+
|
|
2498
|
+
https://doc.xt.com/#orderorderGet
|
|
2499
|
+
https://doc.xt.com/#futures_ordergetById
|
|
2500
|
+
https://doc.xt.com/#futures_entrustgetPlanById
|
|
2501
|
+
https://doc.xt.com/#futures_entrustgetProfitById
|
|
2502
|
+
|
|
2267
2503
|
:param str id: order id
|
|
2268
2504
|
:param str [symbol]: unified symbol of the market the order was made in
|
|
2269
2505
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
2270
|
-
:param bool [params.
|
|
2506
|
+
:param bool [params.trigger]: if the order is a trigger order or not
|
|
2271
2507
|
:param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
|
|
2272
2508
|
:returns dict: An `order structure <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
|
|
2273
2509
|
"""
|
|
@@ -2281,15 +2517,15 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2281
2517
|
response = None
|
|
2282
2518
|
type, params = self.handle_market_type_and_params('fetchOrder', market, params)
|
|
2283
2519
|
subType, params = self.handle_sub_type_and_params('fetchOrder', market, params)
|
|
2284
|
-
|
|
2520
|
+
trigger = self.safe_value(params, 'stop')
|
|
2285
2521
|
stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
|
|
2286
|
-
if
|
|
2522
|
+
if trigger:
|
|
2287
2523
|
request['entrustId'] = id
|
|
2288
2524
|
elif stopLossTakeProfit:
|
|
2289
2525
|
request['profitId'] = id
|
|
2290
2526
|
else:
|
|
2291
2527
|
request['orderId'] = id
|
|
2292
|
-
if
|
|
2528
|
+
if trigger:
|
|
2293
2529
|
params = self.omit(params, 'stop')
|
|
2294
2530
|
if subType == 'inverse':
|
|
2295
2531
|
response = self.privateInverseGetFutureTradeV1EntrustPlanDetail(self.extend(request, params))
|
|
@@ -2430,14 +2666,16 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2430
2666
|
def fetch_orders(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
|
|
2431
2667
|
"""
|
|
2432
2668
|
fetches information on multiple orders made by the user
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2669
|
+
|
|
2670
|
+
https://doc.xt.com/#orderhistoryOrderGet
|
|
2671
|
+
https://doc.xt.com/#futures_ordergetHistory
|
|
2672
|
+
https://doc.xt.com/#futures_entrustgetPlanHistory
|
|
2673
|
+
|
|
2436
2674
|
:param str [symbol]: unified market symbol of the market the orders were made in
|
|
2437
2675
|
:param int [since]: timestamp in ms of the earliest order
|
|
2438
2676
|
:param int [limit]: the maximum number of order structures to retrieve
|
|
2439
2677
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
2440
|
-
:param bool [params.
|
|
2678
|
+
:param bool [params.trigger]: if the order is a trigger order or not
|
|
2441
2679
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
|
|
2442
2680
|
"""
|
|
2443
2681
|
self.load_markets()
|
|
@@ -2455,9 +2693,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2455
2693
|
response = None
|
|
2456
2694
|
type, params = self.handle_market_type_and_params('fetchOrders', market, params)
|
|
2457
2695
|
subType, params = self.handle_sub_type_and_params('fetchOrders', market, params)
|
|
2458
|
-
|
|
2459
|
-
if
|
|
2460
|
-
params = self.omit(params, 'stop')
|
|
2696
|
+
trigger = self.safe_value_2(params, 'trigger', 'stop')
|
|
2697
|
+
if trigger:
|
|
2698
|
+
params = self.omit(params, ['trigger', 'stop'])
|
|
2461
2699
|
if subType == 'inverse':
|
|
2462
2700
|
response = self.privateInverseGetFutureTradeV1EntrustPlanListHistory(self.extend(request, params))
|
|
2463
2701
|
else:
|
|
@@ -2593,37 +2831,41 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2593
2831
|
if symbol is not None:
|
|
2594
2832
|
market = self.market(symbol)
|
|
2595
2833
|
request['symbol'] = market['id']
|
|
2834
|
+
if limit is not None:
|
|
2835
|
+
request['size'] = limit
|
|
2836
|
+
if since is not None:
|
|
2837
|
+
request['startTime'] = since
|
|
2596
2838
|
type = None
|
|
2597
2839
|
subType = None
|
|
2598
2840
|
response = None
|
|
2599
2841
|
type, params = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
|
|
2600
2842
|
subType, params = self.handle_sub_type_and_params('fetchOrdersByStatus', market, params)
|
|
2601
|
-
|
|
2843
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
|
2602
2844
|
stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
|
|
2603
2845
|
if status == 'open':
|
|
2604
|
-
if
|
|
2846
|
+
if trigger or stopLossTakeProfit:
|
|
2605
2847
|
request['state'] = 'NOT_TRIGGERED'
|
|
2606
|
-
elif
|
|
2607
|
-
request['state'] = 'NEW
|
|
2848
|
+
elif type == 'swap':
|
|
2849
|
+
request['state'] = 'UNFINISHED' # NEW & PARTIALLY_FILLED
|
|
2608
2850
|
elif status == 'closed':
|
|
2609
|
-
if
|
|
2851
|
+
if trigger or stopLossTakeProfit:
|
|
2610
2852
|
request['state'] = 'TRIGGERED'
|
|
2611
2853
|
else:
|
|
2612
2854
|
request['state'] = 'FILLED'
|
|
2613
2855
|
elif status == 'canceled':
|
|
2614
|
-
if
|
|
2856
|
+
if trigger or stopLossTakeProfit:
|
|
2615
2857
|
request['state'] = 'USER_REVOCATION'
|
|
2616
2858
|
else:
|
|
2617
2859
|
request['state'] = 'CANCELED'
|
|
2618
2860
|
else:
|
|
2619
2861
|
request['state'] = status
|
|
2620
|
-
if
|
|
2862
|
+
if trigger or stopLossTakeProfit or (subType is not None) or (type == 'swap') or (type == 'future'):
|
|
2621
2863
|
if since is not None:
|
|
2622
2864
|
request['startTime'] = since
|
|
2623
2865
|
if limit is not None:
|
|
2624
2866
|
request['size'] = limit
|
|
2625
|
-
if
|
|
2626
|
-
params = self.omit(params, 'stop')
|
|
2867
|
+
if trigger:
|
|
2868
|
+
params = self.omit(params, ['stop', 'trigger'])
|
|
2627
2869
|
if subType == 'inverse':
|
|
2628
2870
|
response = self.privateInverseGetFutureTradeV1EntrustPlanList(self.extend(request, params))
|
|
2629
2871
|
else:
|
|
@@ -2648,6 +2890,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2648
2890
|
if since is not None:
|
|
2649
2891
|
request['startTime'] = since
|
|
2650
2892
|
if limit is not None:
|
|
2893
|
+
request = self.omit(request, 'size')
|
|
2651
2894
|
request['limit'] = limit
|
|
2652
2895
|
response = self.privateSpotGetHistoryOrder(self.extend(request, params))
|
|
2653
2896
|
else:
|
|
@@ -2830,23 +3073,28 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2830
3073
|
# }
|
|
2831
3074
|
# }
|
|
2832
3075
|
#
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
3076
|
+
orders = []
|
|
3077
|
+
resultDict = self.safe_dict(response, 'result')
|
|
3078
|
+
if resultDict is not None:
|
|
3079
|
+
orders = self.safe_list(resultDict, 'items', [])
|
|
3080
|
+
else:
|
|
3081
|
+
orders = self.safe_list(response, 'result')
|
|
2836
3082
|
return self.parse_orders(orders, market, since, limit)
|
|
2837
3083
|
|
|
2838
3084
|
def fetch_open_orders(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
|
|
2839
3085
|
"""
|
|
2840
3086
|
fetch all unfilled currently open orders
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
3087
|
+
|
|
3088
|
+
https://doc.xt.com/#orderopenOrderGet
|
|
3089
|
+
https://doc.xt.com/#futures_ordergetOrders
|
|
3090
|
+
https://doc.xt.com/#futures_entrustgetPlan
|
|
3091
|
+
https://doc.xt.com/#futures_entrustgetProfit
|
|
3092
|
+
|
|
2845
3093
|
:param str [symbol]: unified market symbol of the market the orders were made in
|
|
2846
3094
|
:param int [since]: timestamp in ms of the earliest order
|
|
2847
3095
|
:param int [limit]: the maximum number of open order structures to retrieve
|
|
2848
3096
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
2849
|
-
:param bool [params.
|
|
3097
|
+
:param bool [params.trigger]: if the order is a trigger order or not
|
|
2850
3098
|
:param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
|
|
2851
3099
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
|
|
2852
3100
|
"""
|
|
@@ -2855,15 +3103,17 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2855
3103
|
def fetch_closed_orders(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
|
|
2856
3104
|
"""
|
|
2857
3105
|
fetches information on multiple closed orders made by the user
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
3106
|
+
|
|
3107
|
+
https://doc.xt.com/#orderhistoryOrderGet
|
|
3108
|
+
https://doc.xt.com/#futures_ordergetOrders
|
|
3109
|
+
https://doc.xt.com/#futures_entrustgetPlan
|
|
3110
|
+
https://doc.xt.com/#futures_entrustgetProfit
|
|
3111
|
+
|
|
2862
3112
|
:param str [symbol]: unified market symbol of the market the orders were made in
|
|
2863
3113
|
:param int [since]: timestamp in ms of the earliest order
|
|
2864
3114
|
:param int [limit]: the maximum number of order structures to retrieve
|
|
2865
3115
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
2866
|
-
:param bool [params.
|
|
3116
|
+
:param bool [params.trigger]: if the order is a trigger order or not
|
|
2867
3117
|
:param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
|
|
2868
3118
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
|
|
2869
3119
|
"""
|
|
@@ -2872,15 +3122,17 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2872
3122
|
def fetch_canceled_orders(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
|
|
2873
3123
|
"""
|
|
2874
3124
|
fetches information on multiple canceled orders made by the user
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
3125
|
+
|
|
3126
|
+
https://doc.xt.com/#orderhistoryOrderGet
|
|
3127
|
+
https://doc.xt.com/#futures_ordergetOrders
|
|
3128
|
+
https://doc.xt.com/#futures_entrustgetPlan
|
|
3129
|
+
https://doc.xt.com/#futures_entrustgetProfit
|
|
3130
|
+
|
|
2879
3131
|
:param str [symbol]: unified market symbol of the market the orders were made in
|
|
2880
3132
|
:param int [since]: timestamp in ms of the earliest order
|
|
2881
3133
|
:param int [limit]: the maximum number of order structures to retrieve
|
|
2882
3134
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
2883
|
-
:param bool [params.
|
|
3135
|
+
:param bool [params.trigger]: if the order is a trigger order or not
|
|
2884
3136
|
:param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
|
|
2885
3137
|
:returns dict: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
|
|
2886
3138
|
"""
|
|
@@ -2889,14 +3141,16 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2889
3141
|
def cancel_order(self, id: str, symbol: str = None, params={}):
|
|
2890
3142
|
"""
|
|
2891
3143
|
cancels an open order
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
3144
|
+
|
|
3145
|
+
https://doc.xt.com/#orderorderDel
|
|
3146
|
+
https://doc.xt.com/#futures_ordercancel
|
|
3147
|
+
https://doc.xt.com/#futures_entrustcancelPlan
|
|
3148
|
+
https://doc.xt.com/#futures_entrustcancelProfit
|
|
3149
|
+
|
|
2896
3150
|
:param str id: order id
|
|
2897
3151
|
:param str [symbol]: unified symbol of the market the order was made in
|
|
2898
3152
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
2899
|
-
:param bool [params.
|
|
3153
|
+
:param bool [params.trigger]: if the order is a trigger order or not
|
|
2900
3154
|
:param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
|
|
2901
3155
|
:returns dict: An `order structure <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
|
|
2902
3156
|
"""
|
|
@@ -2910,16 +3164,16 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2910
3164
|
response = None
|
|
2911
3165
|
type, params = self.handle_market_type_and_params('cancelOrder', market, params)
|
|
2912
3166
|
subType, params = self.handle_sub_type_and_params('cancelOrder', market, params)
|
|
2913
|
-
|
|
3167
|
+
trigger = self.safe_value_2(params, 'trigger', 'stop')
|
|
2914
3168
|
stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
|
|
2915
|
-
if
|
|
3169
|
+
if trigger:
|
|
2916
3170
|
request['entrustId'] = id
|
|
2917
3171
|
elif stopLossTakeProfit:
|
|
2918
3172
|
request['profitId'] = id
|
|
2919
3173
|
else:
|
|
2920
3174
|
request['orderId'] = id
|
|
2921
|
-
if
|
|
2922
|
-
params = self.omit(params, 'stop')
|
|
3175
|
+
if trigger:
|
|
3176
|
+
params = self.omit(params, ['trigger', 'stop'])
|
|
2923
3177
|
if subType == 'inverse':
|
|
2924
3178
|
response = self.privateInversePostFutureTradeV1EntrustCancelPlan(self.extend(request, params))
|
|
2925
3179
|
else:
|
|
@@ -2964,13 +3218,15 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2964
3218
|
def cancel_all_orders(self, symbol: str = None, params={}):
|
|
2965
3219
|
"""
|
|
2966
3220
|
cancel all open orders in a market
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
3221
|
+
|
|
3222
|
+
https://doc.xt.com/#orderopenOrderDel
|
|
3223
|
+
https://doc.xt.com/#futures_ordercancelBatch
|
|
3224
|
+
https://doc.xt.com/#futures_entrustcancelPlanBatch
|
|
3225
|
+
https://doc.xt.com/#futures_entrustcancelProfitBatch
|
|
3226
|
+
|
|
2971
3227
|
:param str [symbol]: unified market symbol of the market to cancel orders in
|
|
2972
3228
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
2973
|
-
:param bool [params.
|
|
3229
|
+
:param bool [params.trigger]: if the order is a trigger order or not
|
|
2974
3230
|
:param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
|
|
2975
3231
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
|
|
2976
3232
|
"""
|
|
@@ -2985,10 +3241,10 @@ class xt(Exchange, ImplicitAPI):
|
|
|
2985
3241
|
response = None
|
|
2986
3242
|
type, params = self.handle_market_type_and_params('cancelAllOrders', market, params)
|
|
2987
3243
|
subType, params = self.handle_sub_type_and_params('cancelAllOrders', market, params)
|
|
2988
|
-
|
|
3244
|
+
trigger = self.safe_value_2(params, 'trigger', 'stop')
|
|
2989
3245
|
stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
|
|
2990
|
-
if
|
|
2991
|
-
params = self.omit(params, 'stop')
|
|
3246
|
+
if trigger:
|
|
3247
|
+
params = self.omit(params, ['trigger', 'stop'])
|
|
2992
3248
|
if subType == 'inverse':
|
|
2993
3249
|
response = self.privateInversePostFutureTradeV1EntrustCancelAllPlan(self.extend(request, params))
|
|
2994
3250
|
else:
|
|
@@ -3035,7 +3291,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3035
3291
|
def cancel_orders(self, ids: List[str], symbol: str = None, params={}) -> List[Order]:
|
|
3036
3292
|
"""
|
|
3037
3293
|
cancel multiple orders
|
|
3038
|
-
|
|
3294
|
+
|
|
3295
|
+
https://doc.xt.com/#orderbatchOrderDel
|
|
3296
|
+
|
|
3039
3297
|
:param str[] ids: order ids
|
|
3040
3298
|
:param str [symbol]: unified market symbol of the market to cancel orders in
|
|
3041
3299
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
@@ -3081,7 +3339,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3081
3339
|
# "cancelId": "208322474307982720"
|
|
3082
3340
|
# }
|
|
3083
3341
|
#
|
|
3084
|
-
# swap and future: createOrder, cancelOrder
|
|
3342
|
+
# swap and future: createOrder, cancelOrder, editOrder
|
|
3085
3343
|
#
|
|
3086
3344
|
# {
|
|
3087
3345
|
# "returnCode": 0,
|
|
@@ -3186,6 +3444,14 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3186
3444
|
# "createdTime": 1681273420039
|
|
3187
3445
|
# }
|
|
3188
3446
|
#
|
|
3447
|
+
# spot editOrder
|
|
3448
|
+
#
|
|
3449
|
+
# {
|
|
3450
|
+
# "orderId": "484203027161892224",
|
|
3451
|
+
# "modifyId": "484203544105344000",
|
|
3452
|
+
# "clientModifyId": null
|
|
3453
|
+
# }
|
|
3454
|
+
#
|
|
3189
3455
|
marketId = self.safe_string(order, 'symbol')
|
|
3190
3456
|
marketType = ('result' in order) or 'contract' if ('positionSide' in order) else 'spot'
|
|
3191
3457
|
market = self.safe_market(marketId, market, None, marketType)
|
|
@@ -3199,7 +3465,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3199
3465
|
return self.safe_order({
|
|
3200
3466
|
'info': order,
|
|
3201
3467
|
'id': self.safe_string_n(order, ['orderId', 'result', 'cancelId', 'entrustId', 'profitId']),
|
|
3202
|
-
'clientOrderId': self.
|
|
3468
|
+
'clientOrderId': self.safe_string_2(order, 'clientOrderId', 'clientModifyId'),
|
|
3203
3469
|
'timestamp': timestamp,
|
|
3204
3470
|
'datetime': self.iso8601(timestamp),
|
|
3205
3471
|
'lastTradeTimestamp': lastUpdatedTimestamp,
|
|
@@ -3210,7 +3476,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3210
3476
|
'postOnly': None,
|
|
3211
3477
|
'side': self.safe_string_lower_2(order, 'side', 'orderSide'),
|
|
3212
3478
|
'price': self.safe_number(order, 'price'),
|
|
3213
|
-
'
|
|
3479
|
+
'triggerPrice': self.safe_number(order, 'stopPrice'),
|
|
3214
3480
|
'stopLoss': self.safe_number(order, 'triggerStopPrice'),
|
|
3215
3481
|
'takeProfit': self.safe_number(order, 'triggerProfitPrice'),
|
|
3216
3482
|
'amount': amount,
|
|
@@ -3244,10 +3510,12 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3244
3510
|
}
|
|
3245
3511
|
return self.safe_string(statuses, status, status)
|
|
3246
3512
|
|
|
3247
|
-
def fetch_ledger(self, code:
|
|
3513
|
+
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
|
3248
3514
|
"""
|
|
3249
3515
|
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
|
3250
|
-
|
|
3516
|
+
|
|
3517
|
+
https://doc.xt.com/#futures_usergetBalanceBill
|
|
3518
|
+
|
|
3251
3519
|
:param str [code]: unified currency code
|
|
3252
3520
|
:param int [since]: timestamp in ms of the earliest ledger entry
|
|
3253
3521
|
:param int [limit]: max number of ledger entries to return
|
|
@@ -3301,7 +3569,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3301
3569
|
ledger = self.safe_value(data, 'items', [])
|
|
3302
3570
|
return self.parse_ledger(ledger, currency, since, limit)
|
|
3303
3571
|
|
|
3304
|
-
def parse_ledger_entry(self, item, currency=None):
|
|
3572
|
+
def parse_ledger_entry(self, item, currency=None) -> LedgerEntry:
|
|
3305
3573
|
#
|
|
3306
3574
|
# {
|
|
3307
3575
|
# "id": "207260567109387524",
|
|
@@ -3317,8 +3585,10 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3317
3585
|
side = self.safe_string(item, 'side')
|
|
3318
3586
|
direction = 'in' if (side == 'ADD') else 'out'
|
|
3319
3587
|
currencyId = self.safe_string(item, 'coin')
|
|
3588
|
+
currency = self.safe_currency(currencyId, currency)
|
|
3320
3589
|
timestamp = self.safe_integer(item, 'createdTime')
|
|
3321
|
-
return {
|
|
3590
|
+
return self.safe_ledger_entry({
|
|
3591
|
+
'info': item,
|
|
3322
3592
|
'id': self.safe_string(item, 'id'),
|
|
3323
3593
|
'direction': direction,
|
|
3324
3594
|
'account': None,
|
|
@@ -3336,8 +3606,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3336
3606
|
'currency': None,
|
|
3337
3607
|
'cost': None,
|
|
3338
3608
|
},
|
|
3339
|
-
|
|
3340
|
-
}
|
|
3609
|
+
}, currency)
|
|
3341
3610
|
|
|
3342
3611
|
def parse_ledger_entry_type(self, type):
|
|
3343
3612
|
ledgerType = {
|
|
@@ -3352,10 +3621,12 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3352
3621
|
}
|
|
3353
3622
|
return self.safe_string(ledgerType, type, type)
|
|
3354
3623
|
|
|
3355
|
-
def fetch_deposit_address(self, code: str, params={}):
|
|
3624
|
+
def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
|
|
3356
3625
|
"""
|
|
3357
3626
|
fetch the deposit address for a currency associated with self account
|
|
3358
|
-
|
|
3627
|
+
|
|
3628
|
+
https://doc.xt.com/#deposit_withdrawaldepositAddressGet
|
|
3629
|
+
|
|
3359
3630
|
:param str code: unified currency code
|
|
3360
3631
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
3361
3632
|
:param str params['network']: required network id
|
|
@@ -3386,7 +3657,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3386
3657
|
result = self.safe_value(response, 'result', {})
|
|
3387
3658
|
return self.parse_deposit_address(result, currency)
|
|
3388
3659
|
|
|
3389
|
-
def parse_deposit_address(self, depositAddress, currency=None):
|
|
3660
|
+
def parse_deposit_address(self, depositAddress, currency=None) -> DepositAddress:
|
|
3390
3661
|
#
|
|
3391
3662
|
# {
|
|
3392
3663
|
# "address": "0x7f7173cf29d3846d20ca5a3aec1120b93dbd157a",
|
|
@@ -3396,17 +3667,19 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3396
3667
|
address = self.safe_string(depositAddress, 'address')
|
|
3397
3668
|
self.check_address(address)
|
|
3398
3669
|
return {
|
|
3670
|
+
'info': depositAddress,
|
|
3399
3671
|
'currency': self.safe_currency_code(None, currency),
|
|
3672
|
+
'network': None,
|
|
3400
3673
|
'address': address,
|
|
3401
3674
|
'tag': self.safe_string(depositAddress, 'memo'),
|
|
3402
|
-
'network': None,
|
|
3403
|
-
'info': depositAddress,
|
|
3404
3675
|
}
|
|
3405
3676
|
|
|
3406
|
-
def fetch_deposits(self, code:
|
|
3677
|
+
def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
3407
3678
|
"""
|
|
3408
3679
|
fetch all deposits made to an account
|
|
3409
|
-
|
|
3680
|
+
|
|
3681
|
+
https://doc.xt.com/#deposit_withdrawalhistoryDepositGet
|
|
3682
|
+
|
|
3410
3683
|
:param str [code]: unified currency code
|
|
3411
3684
|
:param int [since]: the earliest time in ms to fetch deposits for
|
|
3412
3685
|
:param int [limit]: the maximum number of transaction structures to retrieve
|
|
@@ -3454,10 +3727,12 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3454
3727
|
deposits = self.safe_value(data, 'items', [])
|
|
3455
3728
|
return self.parse_transactions(deposits, currency, since, limit, params)
|
|
3456
3729
|
|
|
3457
|
-
def fetch_withdrawals(self, code:
|
|
3730
|
+
def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
3458
3731
|
"""
|
|
3459
3732
|
fetch all withdrawals made from an account
|
|
3460
|
-
|
|
3733
|
+
|
|
3734
|
+
https://doc.xt.com/#deposit_withdrawalwithdrawHistory
|
|
3735
|
+
|
|
3461
3736
|
:param str [code]: unified currency code
|
|
3462
3737
|
:param int [since]: the earliest time in ms to fetch withdrawals for
|
|
3463
3738
|
:param int [limit]: the maximum number of transaction structures to retrieve
|
|
@@ -3505,10 +3780,12 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3505
3780
|
withdrawals = self.safe_value(data, 'items', [])
|
|
3506
3781
|
return self.parse_transactions(withdrawals, currency, since, limit, params)
|
|
3507
3782
|
|
|
3508
|
-
def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
|
|
3783
|
+
def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
|
|
3509
3784
|
"""
|
|
3510
3785
|
make a withdrawal
|
|
3511
|
-
|
|
3786
|
+
|
|
3787
|
+
https://doc.xt.com/#deposit_withdrawalwithdraw
|
|
3788
|
+
|
|
3512
3789
|
:param str code: unified currency code
|
|
3513
3790
|
:param float amount: the amount to withdraw
|
|
3514
3791
|
:param str address: the address to withdraw to
|
|
@@ -3633,10 +3910,12 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3633
3910
|
}
|
|
3634
3911
|
return self.safe_string(statuses, status, status)
|
|
3635
3912
|
|
|
3636
|
-
def set_leverage(self, leverage:
|
|
3913
|
+
def set_leverage(self, leverage: int, symbol: str = None, params={}):
|
|
3637
3914
|
"""
|
|
3638
3915
|
set the level of leverage for a market
|
|
3639
|
-
|
|
3916
|
+
|
|
3917
|
+
https://doc.xt.com/#futures_useradjustLeverage
|
|
3918
|
+
|
|
3640
3919
|
:param float leverage: the rate of leverage
|
|
3641
3920
|
:param str symbol: unified market symbol
|
|
3642
3921
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
@@ -3678,7 +3957,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3678
3957
|
def add_margin(self, symbol: str, amount: float, params={}):
|
|
3679
3958
|
"""
|
|
3680
3959
|
add margin to a position
|
|
3681
|
-
|
|
3960
|
+
|
|
3961
|
+
https://doc.xt.com/#futures_useradjustMargin
|
|
3962
|
+
|
|
3682
3963
|
:param str symbol: unified market symbol
|
|
3683
3964
|
:param float amount: amount of margin to add
|
|
3684
3965
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
@@ -3690,7 +3971,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3690
3971
|
def reduce_margin(self, symbol: str, amount: float, params={}):
|
|
3691
3972
|
"""
|
|
3692
3973
|
remove margin from a position
|
|
3693
|
-
|
|
3974
|
+
|
|
3975
|
+
https://doc.xt.com/#futures_useradjustMargin
|
|
3976
|
+
|
|
3694
3977
|
:param str symbol: unified market symbol
|
|
3695
3978
|
:param float amount: the amount of margin to remove
|
|
3696
3979
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
@@ -3741,10 +4024,12 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3741
4024
|
'datetime': None,
|
|
3742
4025
|
}
|
|
3743
4026
|
|
|
3744
|
-
def fetch_leverage_tiers(self, symbols: List[str] = None, params={}):
|
|
4027
|
+
def fetch_leverage_tiers(self, symbols: List[str] = None, params={}) -> LeverageTiers:
|
|
3745
4028
|
"""
|
|
3746
|
-
:see: https://doc.xt.com/#futures_quotesgetLeverageBrackets
|
|
3747
4029
|
retrieve information on the maximum leverage for different trade sizes
|
|
4030
|
+
|
|
4031
|
+
https://doc.xt.com/#futures_quotesgetLeverageBrackets
|
|
4032
|
+
|
|
3748
4033
|
:param str [symbols]: a list of unified market symbols
|
|
3749
4034
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
3750
4035
|
:returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
|
|
@@ -3785,7 +4070,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3785
4070
|
symbols = self.market_symbols(symbols)
|
|
3786
4071
|
return self.parse_leverage_tiers(data, symbols, 'symbol')
|
|
3787
4072
|
|
|
3788
|
-
def parse_leverage_tiers(self, response, symbols=None, marketIdKey=None):
|
|
4073
|
+
def parse_leverage_tiers(self, response, symbols=None, marketIdKey=None) -> LeverageTiers:
|
|
3789
4074
|
#
|
|
3790
4075
|
# {
|
|
3791
4076
|
# "symbol": "rad_usdt",
|
|
@@ -3818,8 +4103,10 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3818
4103
|
|
|
3819
4104
|
def fetch_market_leverage_tiers(self, symbol: str, params={}) -> List[LeverageTier]:
|
|
3820
4105
|
"""
|
|
3821
|
-
:see: https://doc.xt.com/#futures_quotesgetLeverageBracket
|
|
3822
4106
|
retrieve information on the maximum leverage for different trade sizes of a single market
|
|
4107
|
+
|
|
4108
|
+
https://doc.xt.com/#futures_quotesgetLeverageBracket
|
|
4109
|
+
|
|
3823
4110
|
:param str symbol: unified market symbol
|
|
3824
4111
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
3825
4112
|
:returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
|
|
@@ -3861,7 +4148,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3861
4148
|
data = self.safe_value(response, 'result', {})
|
|
3862
4149
|
return self.parse_market_leverage_tiers(data, market)
|
|
3863
4150
|
|
|
3864
|
-
def parse_market_leverage_tiers(self, info, market=None):
|
|
4151
|
+
def parse_market_leverage_tiers(self, info, market=None) -> List[LeverageTier]:
|
|
3865
4152
|
#
|
|
3866
4153
|
# {
|
|
3867
4154
|
# "symbol": "rad_usdt",
|
|
@@ -3887,6 +4174,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3887
4174
|
market = self.safe_market(marketId, market, '_', 'contract')
|
|
3888
4175
|
tiers.append({
|
|
3889
4176
|
'tier': self.safe_integer(tier, 'bracket'),
|
|
4177
|
+
'symbol': self.safe_symbol(marketId, market, '_', 'contract'),
|
|
3890
4178
|
'currency': market['settle'],
|
|
3891
4179
|
'minNotional': self.safe_number(brackets[i - 1], 'maxNominalValue', 0),
|
|
3892
4180
|
'maxNotional': self.safe_number(tier, 'maxNominalValue'),
|
|
@@ -3899,7 +4187,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3899
4187
|
def fetch_funding_rate_history(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
|
|
3900
4188
|
"""
|
|
3901
4189
|
fetches historical funding rates
|
|
3902
|
-
|
|
4190
|
+
|
|
4191
|
+
https://doc.xt.com/#futures_quotesgetFundingRateRecord
|
|
4192
|
+
|
|
3903
4193
|
:param str [symbol]: unified symbol of the market to fetch the funding rate history for
|
|
3904
4194
|
:param int [since]: timestamp in ms of the earliest funding rate to fetch
|
|
3905
4195
|
:param int [limit]: the maximum amount of [funding rate structures] to fetch
|
|
@@ -3962,10 +4252,24 @@ class xt(Exchange, ImplicitAPI):
|
|
|
3962
4252
|
sorted = self.sort_by(rates, 'timestamp')
|
|
3963
4253
|
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
|
3964
4254
|
|
|
3965
|
-
def
|
|
4255
|
+
def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
|
4256
|
+
"""
|
|
4257
|
+
fetch the current funding rate interval
|
|
4258
|
+
|
|
4259
|
+
https://doc.xt.com/#futures_quotesgetFundingRate
|
|
4260
|
+
|
|
4261
|
+
:param str symbol: unified market symbol
|
|
4262
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
4263
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
|
4264
|
+
"""
|
|
4265
|
+
return self.fetch_funding_rate(symbol, params)
|
|
4266
|
+
|
|
4267
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
|
3966
4268
|
"""
|
|
3967
4269
|
fetch the current funding rate
|
|
3968
|
-
|
|
4270
|
+
|
|
4271
|
+
https://doc.xt.com/#futures_quotesgetFundingRate
|
|
4272
|
+
|
|
3969
4273
|
:param str symbol: unified market symbol
|
|
3970
4274
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
3971
4275
|
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
|
@@ -4000,7 +4304,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
4000
4304
|
result = self.safe_value(response, 'result', {})
|
|
4001
4305
|
return self.parse_funding_rate(result, market)
|
|
4002
4306
|
|
|
4003
|
-
def parse_funding_rate(self, contract, market=None):
|
|
4307
|
+
def parse_funding_rate(self, contract, market=None) -> FundingRate:
|
|
4004
4308
|
#
|
|
4005
4309
|
# {
|
|
4006
4310
|
# "symbol": "btc_usdt",
|
|
@@ -4012,6 +4316,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
4012
4316
|
marketId = self.safe_string(contract, 'symbol')
|
|
4013
4317
|
symbol = self.safe_symbol(marketId, market, '_', 'swap')
|
|
4014
4318
|
timestamp = self.safe_integer(contract, 'nextCollectionTime')
|
|
4319
|
+
interval = self.safe_string(contract, 'collectionInternal')
|
|
4320
|
+
if interval is not None:
|
|
4321
|
+
interval = interval + 'h'
|
|
4015
4322
|
return {
|
|
4016
4323
|
'info': contract,
|
|
4017
4324
|
'symbol': symbol,
|
|
@@ -4030,12 +4337,15 @@ class xt(Exchange, ImplicitAPI):
|
|
|
4030
4337
|
'previousFundingRate': None,
|
|
4031
4338
|
'previousFundingTimestamp': None,
|
|
4032
4339
|
'previousFundingDatetime': None,
|
|
4340
|
+
'interval': interval,
|
|
4033
4341
|
}
|
|
4034
4342
|
|
|
4035
4343
|
def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
|
4036
4344
|
"""
|
|
4037
4345
|
fetch the funding history
|
|
4038
|
-
|
|
4346
|
+
|
|
4347
|
+
https://doc.xt.com/#futures_usergetFunding
|
|
4348
|
+
|
|
4039
4349
|
:param str symbol: unified market symbol
|
|
4040
4350
|
:param int [since]: the starting timestamp in milliseconds
|
|
4041
4351
|
:param int [limit]: the number of entries to return
|
|
@@ -4119,7 +4429,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
4119
4429
|
def fetch_position(self, symbol: str, params={}):
|
|
4120
4430
|
"""
|
|
4121
4431
|
fetch data on a single open contract trade position
|
|
4122
|
-
|
|
4432
|
+
|
|
4433
|
+
https://doc.xt.com/#futures_usergetPosition
|
|
4434
|
+
|
|
4123
4435
|
:param str symbol: unified market symbol of the market the position is held in
|
|
4124
4436
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
4125
4437
|
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
|
@@ -4171,10 +4483,12 @@ class xt(Exchange, ImplicitAPI):
|
|
|
4171
4483
|
return self.parse_position(entry, marketInner)
|
|
4172
4484
|
return None
|
|
4173
4485
|
|
|
4174
|
-
def fetch_positions(self, symbols: List[str] = None, params={}):
|
|
4486
|
+
def fetch_positions(self, symbols: List[str] = None, params={}) -> List[Position]:
|
|
4175
4487
|
"""
|
|
4176
4488
|
fetch all open positions
|
|
4177
|
-
|
|
4489
|
+
|
|
4490
|
+
https://doc.xt.com/#futures_usergetPosition
|
|
4491
|
+
|
|
4178
4492
|
:param str [symbols]: list of unified market symbols, not supported with xt
|
|
4179
4493
|
:param dict params: extra parameters specific to the xt api endpoint
|
|
4180
4494
|
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
|
@@ -4275,7 +4589,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
4275
4589
|
def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
|
|
4276
4590
|
"""
|
|
4277
4591
|
transfer currency internally between wallets on the same account
|
|
4278
|
-
|
|
4592
|
+
|
|
4593
|
+
https://doc.xt.com/#transfersubTransferPost
|
|
4594
|
+
|
|
4279
4595
|
:param str code: unified currency code
|
|
4280
4596
|
:param float amount: amount to transfer
|
|
4281
4597
|
:param str fromAccount: account to transfer from - spot, swap, leverage, finance
|
|
@@ -4325,6 +4641,141 @@ class xt(Exchange, ImplicitAPI):
|
|
|
4325
4641
|
'status': None,
|
|
4326
4642
|
}
|
|
4327
4643
|
|
|
4644
|
+
def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
|
|
4645
|
+
"""
|
|
4646
|
+
set margin mode to 'cross' or 'isolated'
|
|
4647
|
+
|
|
4648
|
+
https://doc.xt.com/#futures_userchangePositionType
|
|
4649
|
+
|
|
4650
|
+
:param str marginMode: 'cross' or 'isolated'
|
|
4651
|
+
:param str [symbol]: required
|
|
4652
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
4653
|
+
:param str [params.positionSide]: *required* "long" or "short"
|
|
4654
|
+
:returns dict: response from the exchange
|
|
4655
|
+
"""
|
|
4656
|
+
if symbol is None:
|
|
4657
|
+
raise ArgumentsRequired(self.id + ' setMarginMode() requires a symbol argument')
|
|
4658
|
+
self.load_markets()
|
|
4659
|
+
market = self.market(symbol)
|
|
4660
|
+
if market['spot']:
|
|
4661
|
+
raise BadSymbol(self.id + ' setMarginMode() supports contract markets only')
|
|
4662
|
+
marginMode = marginMode.lower()
|
|
4663
|
+
if marginMode != 'isolated' and marginMode != 'cross':
|
|
4664
|
+
raise BadRequest(self.id + ' setMarginMode() marginMode argument should be isolated or cross')
|
|
4665
|
+
if marginMode == 'cross':
|
|
4666
|
+
marginMode = 'CROSSED'
|
|
4667
|
+
else:
|
|
4668
|
+
marginMode = 'ISOLATED'
|
|
4669
|
+
posSide = self.safe_string_upper(params, 'positionSide')
|
|
4670
|
+
if posSide is None:
|
|
4671
|
+
raise ArgumentsRequired(self.id + ' setMarginMode() requires a positionSide parameter, either "LONG" or "SHORT"')
|
|
4672
|
+
request: dict = {
|
|
4673
|
+
'positionType': marginMode,
|
|
4674
|
+
'positionSide': posSide,
|
|
4675
|
+
'symbol': market['id'],
|
|
4676
|
+
}
|
|
4677
|
+
response = self.privateLinearPostFutureUserV1PositionChangeType(self.extend(request, params))
|
|
4678
|
+
#
|
|
4679
|
+
# {
|
|
4680
|
+
# "error": {
|
|
4681
|
+
# "code": "",
|
|
4682
|
+
# "msg": ""
|
|
4683
|
+
# },
|
|
4684
|
+
# "msgInfo": "",
|
|
4685
|
+
# "result": {},
|
|
4686
|
+
# "returnCode": 0
|
|
4687
|
+
# }
|
|
4688
|
+
#
|
|
4689
|
+
return response # unify return type
|
|
4690
|
+
|
|
4691
|
+
def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}) -> Order:
|
|
4692
|
+
"""
|
|
4693
|
+
cancels an order and places a new order
|
|
4694
|
+
|
|
4695
|
+
https://doc.xt.com/#orderorderUpdate
|
|
4696
|
+
https://doc.xt.com/#futures_orderupdate
|
|
4697
|
+
https://doc.xt.com/#futures_entrustupdateProfit
|
|
4698
|
+
|
|
4699
|
+
:param str id: order id
|
|
4700
|
+
:param str symbol: unified symbol of the market to create an order in
|
|
4701
|
+
:param str type: 'market' or 'limit'
|
|
4702
|
+
:param str side: 'buy' or 'sell'
|
|
4703
|
+
:param float amount: how much of the currency you want to trade in units of the base currency
|
|
4704
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
4705
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
|
4706
|
+
:param float [params.stopLoss]: price to set a stop-loss on an open position
|
|
4707
|
+
:param float [params.takeProfit]: price to set a take-profit on an open position
|
|
4708
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
|
4709
|
+
"""
|
|
4710
|
+
if amount is None:
|
|
4711
|
+
raise ArgumentsRequired(self.id + ' editOrder() requires an amount argument')
|
|
4712
|
+
self.load_markets()
|
|
4713
|
+
market = self.market(symbol)
|
|
4714
|
+
request = {}
|
|
4715
|
+
stopLoss = self.safe_number_2(params, 'stopLoss', 'triggerStopPrice')
|
|
4716
|
+
takeProfit = self.safe_number_2(params, 'takeProfit', 'triggerProfitPrice')
|
|
4717
|
+
params = self.omit(params, ['stopLoss', 'takeProfit'])
|
|
4718
|
+
isStopLoss = (stopLoss is not None)
|
|
4719
|
+
isTakeProfit = (takeProfit is not None)
|
|
4720
|
+
if isStopLoss or isTakeProfit:
|
|
4721
|
+
request['profitId'] = id
|
|
4722
|
+
else:
|
|
4723
|
+
request['orderId'] = id
|
|
4724
|
+
request['price'] = self.price_to_precision(symbol, price)
|
|
4725
|
+
response = None
|
|
4726
|
+
if market['swap']:
|
|
4727
|
+
if isStopLoss:
|
|
4728
|
+
request['triggerStopPrice'] = self.price_to_precision(symbol, stopLoss)
|
|
4729
|
+
elif takeProfit is not None:
|
|
4730
|
+
request['triggerProfitPrice'] = self.price_to_precision(symbol, takeProfit)
|
|
4731
|
+
else:
|
|
4732
|
+
request['origQty'] = self.amount_to_precision(symbol, amount)
|
|
4733
|
+
subType = None
|
|
4734
|
+
subType, params = self.handle_sub_type_and_params('editOrder', market, params)
|
|
4735
|
+
if subType == 'inverse':
|
|
4736
|
+
if isStopLoss or isTakeProfit:
|
|
4737
|
+
response = self.privateInversePostFutureTradeV1EntrustUpdateProfitStop(self.extend(request, params))
|
|
4738
|
+
else:
|
|
4739
|
+
response = self.privateInversePostFutureTradeV1OrderUpdate(self.extend(request, params))
|
|
4740
|
+
#
|
|
4741
|
+
# {
|
|
4742
|
+
# "returnCode": 0,
|
|
4743
|
+
# "msgInfo": "success",
|
|
4744
|
+
# "error": null,
|
|
4745
|
+
# "result": "483869474947826752"
|
|
4746
|
+
# }
|
|
4747
|
+
#
|
|
4748
|
+
else:
|
|
4749
|
+
if isStopLoss or isTakeProfit:
|
|
4750
|
+
response = self.privateLinearPostFutureTradeV1EntrustUpdateProfitStop(self.extend(request, params))
|
|
4751
|
+
else:
|
|
4752
|
+
response = self.privateLinearPostFutureTradeV1OrderUpdate(self.extend(request, params))
|
|
4753
|
+
#
|
|
4754
|
+
# {
|
|
4755
|
+
# "returnCode": 0,
|
|
4756
|
+
# "msgInfo": "success",
|
|
4757
|
+
# "error": null,
|
|
4758
|
+
# "result": "483869474947826752"
|
|
4759
|
+
# }
|
|
4760
|
+
#
|
|
4761
|
+
else:
|
|
4762
|
+
request['quantity'] = self.amount_to_precision(symbol, amount)
|
|
4763
|
+
response = self.privateSpotPutOrderOrderId(self.extend(request, params))
|
|
4764
|
+
#
|
|
4765
|
+
# {
|
|
4766
|
+
# "rc": 0,
|
|
4767
|
+
# "mc": "SUCCESS",
|
|
4768
|
+
# "ma": [],
|
|
4769
|
+
# "result": {
|
|
4770
|
+
# "orderId": "484203027161892224",
|
|
4771
|
+
# "modifyId": "484203544105344000",
|
|
4772
|
+
# "clientModifyId": null
|
|
4773
|
+
# }
|
|
4774
|
+
# }
|
|
4775
|
+
#
|
|
4776
|
+
result = response if (market['swap']) else self.safe_dict(response, 'result', {})
|
|
4777
|
+
return self.parse_order(result, market)
|
|
4778
|
+
|
|
4328
4779
|
def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
|
|
4329
4780
|
#
|
|
4330
4781
|
# spot: error
|
|
@@ -4375,6 +4826,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
4375
4826
|
# "result": {}
|
|
4376
4827
|
# }
|
|
4377
4828
|
#
|
|
4829
|
+
# {"returnCode":1,"msgInfo":"failure","error":{"code":"insufficient_balance","msg":"insufficient balance","args":[]},"result":null}
|
|
4830
|
+
#
|
|
4831
|
+
#
|
|
4378
4832
|
status = self.safe_string_upper_2(response, 'msgInfo', 'mc')
|
|
4379
4833
|
if status is not None and status != 'SUCCESS':
|
|
4380
4834
|
feedback = self.id + ' ' + body
|
|
@@ -4418,7 +4872,9 @@ class xt(Exchange, ImplicitAPI):
|
|
|
4418
4872
|
body['clientMedia'] = id
|
|
4419
4873
|
else:
|
|
4420
4874
|
body['media'] = id
|
|
4421
|
-
isUndefinedBody = ((method == 'GET') or (path == 'order/{orderId}'))
|
|
4875
|
+
isUndefinedBody = ((method == 'GET') or (path == 'order/{orderId}') or (path == 'ws-token'))
|
|
4876
|
+
if (method == 'PUT') and (endpoint == 'spot'):
|
|
4877
|
+
isUndefinedBody = False
|
|
4422
4878
|
body = None if isUndefinedBody else self.json(body)
|
|
4423
4879
|
payloadString = None
|
|
4424
4880
|
if (endpoint == 'spot') or (endpoint == 'user'):
|
|
@@ -4426,7 +4882,7 @@ class xt(Exchange, ImplicitAPI):
|
|
|
4426
4882
|
if isUndefinedBody:
|
|
4427
4883
|
if urlencoded:
|
|
4428
4884
|
url += '?' + urlencoded
|
|
4429
|
-
payloadString += '#' + method + '#' + payload + '#' +
|
|
4885
|
+
payloadString += '#' + method + '#' + payload + '#' + self.rawencode(self.keysort(query))
|
|
4430
4886
|
else:
|
|
4431
4887
|
payloadString += '#' + method + '#' + payload
|
|
4432
4888
|
else:
|