ccxt 4.2.76__py2.py3-none-any.whl → 4.4.48__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 +36 -14
- ccxt/abstract/alpaca.py +4 -0
- ccxt/abstract/bigone.py +1 -1
- ccxt/abstract/binance.py +112 -48
- ccxt/abstract/binancecoinm.py +112 -48
- ccxt/abstract/binanceus.py +147 -83
- ccxt/abstract/binanceusdm.py +112 -48
- ccxt/abstract/bingx.py +133 -78
- ccxt/abstract/bitbank.py +5 -0
- ccxt/abstract/bitfinex.py +136 -65
- ccxt/abstract/bitfinex1.py +69 -0
- ccxt/abstract/bitflyer.py +1 -0
- ccxt/abstract/bitget.py +8 -1
- ccxt/abstract/bitmart.py +13 -1
- ccxt/abstract/bitopro.py +1 -0
- ccxt/abstract/bitpanda.py +0 -12
- ccxt/abstract/bitrue.py +3 -3
- ccxt/abstract/bitstamp.py +26 -3
- ccxt/abstract/blofin.py +24 -0
- ccxt/abstract/btcbox.py +1 -0
- ccxt/abstract/bybit.py +29 -14
- ccxt/abstract/cex.py +28 -29
- ccxt/abstract/coinbase.py +6 -0
- ccxt/abstract/coinbaseadvanced.py +94 -0
- ccxt/abstract/{coinbasepro.py → coinbaseexchange.py} +1 -0
- ccxt/abstract/coinbaseinternational.py +1 -1
- ccxt/abstract/coincatch.py +94 -0
- ccxt/abstract/coinex.py +233 -123
- ccxt/abstract/coinmetro.py +1 -0
- ccxt/abstract/cryptocom.py +14 -0
- ccxt/abstract/defx.py +69 -0
- ccxt/abstract/deribit.py +1 -0
- ccxt/abstract/digifinex.py +1 -0
- ccxt/abstract/ellipx.py +25 -0
- ccxt/abstract/gate.py +20 -0
- ccxt/abstract/gateio.py +20 -0
- ccxt/abstract/gemini.py +1 -0
- ccxt/abstract/hashkey.py +67 -0
- ccxt/abstract/hyperliquid.py +1 -1
- ccxt/abstract/independentreserve.py +6 -0
- ccxt/abstract/kraken.py +4 -3
- ccxt/abstract/krakenfutures.py +4 -0
- ccxt/abstract/kucoin.py +25 -0
- ccxt/abstract/kucoinfutures.py +35 -0
- ccxt/abstract/luno.py +2 -0
- ccxt/abstract/mexc.py +4 -0
- ccxt/abstract/myokx.py +340 -0
- ccxt/abstract/oceanex.py +5 -0
- ccxt/abstract/okx.py +30 -0
- ccxt/abstract/onetrading.py +0 -12
- ccxt/abstract/oxfun.py +34 -0
- ccxt/abstract/paradex.py +40 -0
- ccxt/abstract/phemex.py +1 -0
- ccxt/abstract/upbit.py +4 -0
- ccxt/abstract/vertex.py +19 -0
- ccxt/abstract/whitebit.py +31 -1
- ccxt/abstract/woo.py +6 -2
- ccxt/abstract/woofipro.py +119 -0
- ccxt/abstract/xt.py +153 -0
- ccxt/abstract/zonda.py +6 -0
- ccxt/ace.py +164 -60
- ccxt/alpaca.py +727 -63
- ccxt/ascendex.py +395 -249
- ccxt/async_support/__init__.py +36 -14
- ccxt/async_support/ace.py +164 -60
- ccxt/async_support/alpaca.py +727 -63
- ccxt/async_support/ascendex.py +396 -249
- ccxt/async_support/base/exchange.py +531 -155
- ccxt/async_support/base/ws/aiohttp_client.py +28 -5
- ccxt/async_support/base/ws/cache.py +3 -2
- ccxt/async_support/base/ws/client.py +26 -5
- ccxt/async_support/base/ws/fast_client.py +4 -3
- ccxt/async_support/base/ws/functions.py +1 -1
- ccxt/async_support/base/ws/future.py +40 -31
- ccxt/async_support/base/ws/order_book_side.py +3 -0
- ccxt/async_support/bequant.py +1 -1
- ccxt/async_support/bigone.py +329 -202
- ccxt/async_support/binance.py +3513 -1511
- ccxt/async_support/binancecoinm.py +2 -1
- ccxt/async_support/binanceus.py +12 -1
- ccxt/async_support/binanceusdm.py +3 -1
- ccxt/async_support/bingx.py +3105 -881
- ccxt/async_support/bit2c.py +119 -38
- ccxt/async_support/bitbank.py +215 -76
- ccxt/async_support/bitbns.py +124 -53
- ccxt/async_support/bitfinex.py +3236 -1078
- ccxt/async_support/bitfinex1.py +1711 -0
- ccxt/async_support/bitflyer.py +239 -50
- ccxt/async_support/bitget.py +1513 -563
- ccxt/async_support/bithumb.py +201 -67
- ccxt/async_support/bitmart.py +1320 -435
- ccxt/async_support/bitmex.py +308 -111
- ccxt/async_support/bitopro.py +256 -96
- ccxt/async_support/bitrue.py +365 -233
- ccxt/async_support/bitso.py +201 -89
- ccxt/async_support/bitstamp.py +438 -269
- ccxt/async_support/bitteam.py +179 -73
- ccxt/async_support/bitvavo.py +180 -70
- ccxt/async_support/bl3p.py +92 -25
- ccxt/async_support/blockchaincom.py +193 -79
- ccxt/async_support/blofin.py +403 -150
- ccxt/async_support/btcalpha.py +161 -55
- ccxt/async_support/btcbox.py +250 -34
- ccxt/async_support/btcmarkets.py +232 -85
- ccxt/async_support/btcturk.py +159 -60
- ccxt/async_support/bybit.py +2326 -1255
- ccxt/async_support/cex.py +1409 -1329
- ccxt/async_support/coinbase.py +1455 -288
- ccxt/async_support/coinbaseadvanced.py +17 -0
- ccxt/async_support/{coinbasepro.py → coinbaseexchange.py} +233 -99
- ccxt/async_support/coinbaseinternational.py +428 -88
- ccxt/async_support/coincatch.py +5152 -0
- ccxt/async_support/coincheck.py +121 -38
- ccxt/async_support/coinex.py +4020 -3339
- ccxt/async_support/coinlist.py +273 -116
- ccxt/async_support/coinmate.py +204 -97
- ccxt/async_support/coinmetro.py +203 -110
- ccxt/async_support/coinone.py +142 -68
- ccxt/async_support/coinsph.py +206 -89
- ccxt/async_support/coinspot.py +137 -62
- ccxt/async_support/cryptocom.py +515 -185
- ccxt/async_support/currencycom.py +203 -85
- ccxt/async_support/defx.py +2066 -0
- ccxt/async_support/delta.py +467 -158
- ccxt/async_support/deribit.py +558 -324
- ccxt/async_support/digifinex.py +340 -223
- ccxt/async_support/ellipx.py +1826 -0
- ccxt/async_support/exmo.py +259 -128
- ccxt/async_support/gate.py +1473 -464
- ccxt/async_support/gemini.py +206 -84
- ccxt/async_support/hashkey.py +4164 -0
- ccxt/async_support/hitbtc.py +334 -178
- ccxt/async_support/hollaex.py +134 -83
- ccxt/async_support/htx.py +1095 -563
- ccxt/async_support/huobijp.py +105 -56
- ccxt/async_support/hyperliquid.py +1634 -269
- ccxt/async_support/idex.py +148 -95
- ccxt/async_support/independentreserve.py +236 -31
- ccxt/async_support/indodax.py +165 -62
- ccxt/async_support/kraken.py +871 -354
- ccxt/async_support/krakenfutures.py +324 -100
- ccxt/async_support/kucoin.py +1050 -355
- ccxt/async_support/kucoinfutures.py +1004 -149
- ccxt/async_support/kuna.py +138 -106
- ccxt/async_support/latoken.py +135 -79
- ccxt/async_support/lbank.py +290 -113
- ccxt/async_support/luno.py +112 -62
- ccxt/async_support/lykke.py +104 -55
- ccxt/async_support/mercado.py +36 -29
- ccxt/async_support/mexc.py +995 -429
- ccxt/async_support/myokx.py +43 -0
- ccxt/async_support/ndax.py +163 -82
- ccxt/async_support/novadax.py +121 -75
- ccxt/async_support/oceanex.py +175 -59
- ccxt/async_support/okcoin.py +222 -163
- ccxt/async_support/okx.py +1777 -455
- ccxt/async_support/onetrading.py +132 -414
- ccxt/async_support/oxfun.py +2832 -0
- ccxt/async_support/p2b.py +79 -51
- ccxt/async_support/paradex.py +2017 -0
- ccxt/async_support/paymium.py +56 -32
- ccxt/async_support/phemex.py +572 -196
- ccxt/async_support/poloniex.py +218 -95
- ccxt/async_support/poloniexfutures.py +260 -92
- ccxt/async_support/probit.py +143 -110
- ccxt/async_support/timex.py +123 -70
- ccxt/async_support/tokocrypto.py +129 -93
- ccxt/async_support/tradeogre.py +39 -25
- ccxt/async_support/upbit.py +322 -113
- ccxt/async_support/vertex.py +2983 -0
- ccxt/async_support/wavesexchange.py +227 -173
- ccxt/async_support/wazirx.py +145 -65
- ccxt/async_support/whitebit.py +533 -138
- ccxt/async_support/woo.py +1155 -295
- ccxt/async_support/woofipro.py +2716 -0
- ccxt/async_support/xt.py +4628 -0
- ccxt/async_support/yobit.py +160 -92
- ccxt/async_support/zaif.py +80 -33
- ccxt/async_support/zonda.py +140 -69
- ccxt/base/errors.py +51 -20
- ccxt/base/exchange.py +1729 -482
- ccxt/base/precise.py +10 -0
- ccxt/base/types.py +223 -4
- ccxt/bequant.py +1 -1
- ccxt/bigone.py +329 -202
- ccxt/binance.py +3513 -1511
- ccxt/binancecoinm.py +2 -1
- ccxt/binanceus.py +12 -1
- ccxt/binanceusdm.py +3 -1
- ccxt/bingx.py +3105 -881
- ccxt/bit2c.py +119 -38
- ccxt/bitbank.py +215 -76
- ccxt/bitbns.py +124 -53
- ccxt/bitfinex.py +3235 -1078
- ccxt/bitfinex1.py +1710 -0
- ccxt/bitflyer.py +239 -50
- ccxt/bitget.py +1513 -563
- ccxt/bithumb.py +200 -67
- ccxt/bitmart.py +1320 -435
- ccxt/bitmex.py +308 -111
- ccxt/bitopro.py +256 -96
- ccxt/bitrue.py +365 -233
- ccxt/bitso.py +201 -89
- ccxt/bitstamp.py +438 -269
- ccxt/bitteam.py +179 -73
- ccxt/bitvavo.py +180 -70
- ccxt/bl3p.py +92 -25
- ccxt/blockchaincom.py +193 -79
- ccxt/blofin.py +403 -150
- ccxt/btcalpha.py +161 -55
- ccxt/btcbox.py +250 -34
- ccxt/btcmarkets.py +232 -85
- ccxt/btcturk.py +159 -60
- ccxt/bybit.py +2326 -1255
- ccxt/cex.py +1408 -1329
- ccxt/coinbase.py +1455 -288
- ccxt/coinbaseadvanced.py +17 -0
- ccxt/{coinbasepro.py → coinbaseexchange.py} +233 -99
- ccxt/coinbaseinternational.py +428 -88
- ccxt/coincatch.py +5152 -0
- ccxt/coincheck.py +121 -38
- ccxt/coinex.py +4020 -3339
- ccxt/coinlist.py +273 -116
- ccxt/coinmate.py +204 -97
- ccxt/coinmetro.py +203 -110
- ccxt/coinone.py +142 -68
- ccxt/coinsph.py +206 -89
- ccxt/coinspot.py +137 -62
- ccxt/cryptocom.py +515 -185
- ccxt/currencycom.py +203 -85
- ccxt/defx.py +2065 -0
- ccxt/delta.py +467 -158
- ccxt/deribit.py +558 -324
- ccxt/digifinex.py +340 -223
- ccxt/ellipx.py +1826 -0
- ccxt/exmo.py +259 -128
- ccxt/gate.py +1473 -464
- ccxt/gemini.py +206 -84
- ccxt/hashkey.py +4164 -0
- ccxt/hitbtc.py +334 -178
- ccxt/hollaex.py +134 -83
- ccxt/htx.py +1095 -563
- ccxt/huobijp.py +105 -56
- ccxt/hyperliquid.py +1633 -269
- ccxt/idex.py +148 -95
- ccxt/independentreserve.py +235 -31
- ccxt/indodax.py +165 -62
- ccxt/kraken.py +871 -354
- ccxt/krakenfutures.py +324 -100
- ccxt/kucoin.py +1050 -355
- ccxt/kucoinfutures.py +1004 -149
- ccxt/kuna.py +138 -106
- ccxt/latoken.py +135 -79
- ccxt/lbank.py +290 -113
- ccxt/luno.py +112 -62
- ccxt/lykke.py +104 -55
- ccxt/mercado.py +36 -29
- ccxt/mexc.py +994 -429
- ccxt/myokx.py +43 -0
- ccxt/ndax.py +163 -82
- ccxt/novadax.py +121 -75
- ccxt/oceanex.py +175 -59
- ccxt/okcoin.py +222 -163
- ccxt/okx.py +1777 -455
- ccxt/onetrading.py +132 -414
- ccxt/oxfun.py +2831 -0
- ccxt/p2b.py +79 -51
- ccxt/paradex.py +2017 -0
- ccxt/paymium.py +56 -32
- ccxt/phemex.py +572 -196
- ccxt/poloniex.py +218 -95
- ccxt/poloniexfutures.py +260 -92
- ccxt/pro/__init__.py +29 -5
- ccxt/pro/alpaca.py +32 -17
- ccxt/pro/ascendex.py +63 -15
- ccxt/pro/bequant.py +4 -0
- ccxt/pro/binance.py +1596 -329
- ccxt/pro/binancecoinm.py +1 -0
- ccxt/pro/binanceus.py +2 -9
- ccxt/pro/binanceusdm.py +2 -0
- ccxt/pro/bingx.py +527 -134
- ccxt/pro/bitcoincom.py +4 -1
- ccxt/pro/bitfinex.py +731 -266
- ccxt/pro/bitfinex1.py +635 -0
- ccxt/pro/bitget.py +726 -357
- ccxt/pro/bithumb.py +380 -0
- ccxt/pro/bitmart.py +138 -39
- ccxt/pro/bitmex.py +199 -40
- ccxt/pro/bitopro.py +25 -13
- ccxt/pro/bitrue.py +31 -32
- ccxt/pro/bitstamp.py +7 -6
- ccxt/pro/bitvavo.py +204 -82
- ccxt/pro/blockchaincom.py +30 -17
- ccxt/pro/blofin.py +692 -0
- ccxt/pro/bybit.py +791 -82
- ccxt/pro/cex.py +99 -51
- ccxt/pro/coinbase.py +220 -30
- ccxt/{async_support/hitbtc3.py → pro/coinbaseadvanced.py} +5 -5
- ccxt/pro/{coinbasepro.py → coinbaseexchange.py} +19 -19
- ccxt/pro/coinbaseinternational.py +193 -30
- ccxt/pro/coincatch.py +1464 -0
- ccxt/pro/coincheck.py +11 -6
- ccxt/pro/coinex.py +967 -661
- ccxt/pro/coinone.py +17 -10
- ccxt/pro/cryptocom.py +446 -66
- ccxt/pro/currencycom.py +11 -10
- ccxt/pro/defx.py +832 -0
- ccxt/pro/deribit.py +168 -32
- ccxt/pro/exmo.py +253 -21
- ccxt/pro/gate.py +729 -64
- ccxt/pro/gemini.py +44 -26
- ccxt/pro/hashkey.py +802 -0
- ccxt/pro/hitbtc.py +208 -103
- ccxt/pro/hollaex.py +25 -9
- ccxt/pro/htx.py +83 -39
- ccxt/pro/huobijp.py +17 -16
- ccxt/pro/hyperliquid.py +502 -31
- ccxt/pro/idex.py +28 -13
- ccxt/pro/independentreserve.py +21 -16
- ccxt/pro/kraken.py +298 -51
- ccxt/pro/krakenfutures.py +166 -75
- ccxt/pro/kucoin.py +395 -77
- ccxt/pro/kucoinfutures.py +400 -99
- ccxt/pro/lbank.py +52 -31
- ccxt/pro/luno.py +12 -10
- ccxt/pro/mexc.py +400 -50
- ccxt/pro/myokx.py +28 -0
- ccxt/pro/ndax.py +25 -12
- ccxt/pro/okcoin.py +28 -9
- ccxt/pro/okx.py +935 -124
- ccxt/pro/onetrading.py +41 -24
- ccxt/pro/oxfun.py +1054 -0
- ccxt/pro/p2b.py +100 -24
- ccxt/pro/paradex.py +352 -0
- ccxt/pro/phemex.py +93 -34
- ccxt/pro/poloniex.py +129 -50
- ccxt/pro/poloniexfutures.py +53 -32
- ccxt/pro/probit.py +93 -86
- ccxt/pro/upbit.py +401 -8
- ccxt/pro/vertex.py +943 -0
- ccxt/pro/wazirx.py +46 -28
- ccxt/pro/whitebit.py +65 -12
- ccxt/pro/woo.py +486 -70
- ccxt/pro/woofipro.py +1271 -0
- ccxt/pro/xt.py +1067 -0
- ccxt/probit.py +143 -110
- ccxt/static_dependencies/__init__.py +1 -1
- ccxt/static_dependencies/lark/__init__.py +38 -0
- ccxt/static_dependencies/lark/__pyinstaller/__init__.py +6 -0
- ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +14 -0
- ccxt/static_dependencies/lark/ast_utils.py +59 -0
- ccxt/static_dependencies/lark/common.py +86 -0
- ccxt/static_dependencies/lark/exceptions.py +292 -0
- ccxt/static_dependencies/lark/grammar.py +130 -0
- ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
- ccxt/static_dependencies/lark/indenter.py +143 -0
- ccxt/static_dependencies/lark/lark.py +658 -0
- ccxt/static_dependencies/lark/lexer.py +678 -0
- ccxt/static_dependencies/lark/load_grammar.py +1428 -0
- ccxt/static_dependencies/lark/parse_tree_builder.py +391 -0
- ccxt/static_dependencies/lark/parser_frontends.py +257 -0
- ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
- ccxt/static_dependencies/lark/parsers/cyk.py +340 -0
- ccxt/static_dependencies/lark/parsers/earley.py +314 -0
- ccxt/static_dependencies/lark/parsers/earley_common.py +42 -0
- ccxt/static_dependencies/lark/parsers/earley_forest.py +801 -0
- ccxt/static_dependencies/lark/parsers/grammar_analysis.py +203 -0
- ccxt/static_dependencies/lark/parsers/lalr_analysis.py +332 -0
- ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +158 -0
- ccxt/static_dependencies/lark/parsers/lalr_parser.py +122 -0
- ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +110 -0
- ccxt/static_dependencies/lark/parsers/xearley.py +165 -0
- ccxt/static_dependencies/lark/py.typed +0 -0
- ccxt/static_dependencies/lark/reconstruct.py +107 -0
- ccxt/static_dependencies/lark/tools/__init__.py +70 -0
- ccxt/static_dependencies/lark/tools/nearley.py +202 -0
- ccxt/static_dependencies/lark/tools/serialize.py +32 -0
- ccxt/static_dependencies/lark/tools/standalone.py +196 -0
- ccxt/static_dependencies/lark/tree.py +267 -0
- ccxt/static_dependencies/lark/tree_matcher.py +186 -0
- ccxt/static_dependencies/lark/tree_templates.py +180 -0
- ccxt/static_dependencies/lark/utils.py +343 -0
- ccxt/static_dependencies/lark/visitors.py +596 -0
- ccxt/static_dependencies/marshmallow/__init__.py +81 -0
- ccxt/static_dependencies/marshmallow/base.py +65 -0
- ccxt/static_dependencies/marshmallow/class_registry.py +94 -0
- ccxt/static_dependencies/marshmallow/decorators.py +231 -0
- ccxt/static_dependencies/marshmallow/error_store.py +60 -0
- ccxt/static_dependencies/marshmallow/exceptions.py +71 -0
- ccxt/static_dependencies/marshmallow/fields.py +2114 -0
- ccxt/static_dependencies/marshmallow/orderedset.py +89 -0
- ccxt/static_dependencies/marshmallow/py.typed +0 -0
- ccxt/static_dependencies/marshmallow/schema.py +1228 -0
- ccxt/static_dependencies/marshmallow/types.py +12 -0
- ccxt/static_dependencies/marshmallow/utils.py +378 -0
- ccxt/static_dependencies/marshmallow/validate.py +678 -0
- ccxt/static_dependencies/marshmallow/warnings.py +2 -0
- ccxt/static_dependencies/marshmallow_dataclass/__init__.py +1047 -0
- ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +51 -0
- ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +45 -0
- ccxt/static_dependencies/marshmallow_dataclass/mypy.py +71 -0
- ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
- ccxt/static_dependencies/marshmallow_dataclass/typing.py +14 -0
- ccxt/static_dependencies/marshmallow_dataclass/union_field.py +82 -0
- ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +1 -0
- ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +193 -0
- ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
- ccxt/static_dependencies/starknet/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/data_types.py +123 -0
- ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +77 -0
- ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +46 -0
- ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +138 -0
- ccxt/static_dependencies/starknet/cairo/felt.py +64 -0
- ccxt/static_dependencies/starknet/cairo/type_parser.py +121 -0
- ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +59 -0
- ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
- ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +77 -0
- ccxt/static_dependencies/starknet/ccxt_utils.py +7 -0
- ccxt/static_dependencies/starknet/common.py +15 -0
- ccxt/static_dependencies/starknet/constants.py +39 -0
- ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
- ccxt/static_dependencies/starknet/hash/address.py +79 -0
- ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +111 -0
- ccxt/static_dependencies/starknet/hash/selector.py +16 -0
- ccxt/static_dependencies/starknet/hash/storage.py +12 -0
- ccxt/static_dependencies/starknet/hash/utils.py +78 -0
- ccxt/static_dependencies/starknet/models/__init__.py +0 -0
- ccxt/static_dependencies/starknet/models/typed_data.py +45 -0
- ccxt/static_dependencies/starknet/serialization/__init__.py +24 -0
- ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +40 -0
- ccxt/static_dependencies/starknet/serialization/_context.py +142 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +10 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +82 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +43 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +37 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +66 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +71 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +71 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +50 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +58 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +43 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +40 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +72 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +36 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +36 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +76 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +100 -0
- ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +32 -0
- ccxt/static_dependencies/starknet/serialization/errors.py +10 -0
- ccxt/static_dependencies/starknet/serialization/factory.py +229 -0
- ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +110 -0
- ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +59 -0
- ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
- ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +86 -0
- ccxt/static_dependencies/starknet/utils/iterable.py +13 -0
- ccxt/static_dependencies/starknet/utils/schema.py +13 -0
- ccxt/static_dependencies/starknet/utils/typed_data.py +182 -0
- ccxt/static_dependencies/starkware/__init__.py +0 -0
- ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
- ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +50 -0
- ccxt/static_dependencies/starkware/crypto/math_utils.py +78 -0
- ccxt/static_dependencies/starkware/crypto/signature.py +2344 -0
- ccxt/static_dependencies/starkware/crypto/utils.py +63 -0
- ccxt/static_dependencies/sympy/__init__.py +0 -0
- ccxt/static_dependencies/sympy/core/__init__.py +0 -0
- ccxt/static_dependencies/sympy/core/intfunc.py +35 -0
- ccxt/static_dependencies/sympy/external/__init__.py +0 -0
- ccxt/static_dependencies/sympy/external/gmpy.py +345 -0
- ccxt/static_dependencies/sympy/external/importtools.py +187 -0
- ccxt/static_dependencies/sympy/external/ntheory.py +637 -0
- ccxt/static_dependencies/sympy/external/pythonmpq.py +341 -0
- ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
- ccxt/static_dependencies/typing_inspect/typing_inspect.py +851 -0
- ccxt/test/{test_async.py → tests_async.py} +465 -407
- ccxt/test/tests_helpers.py +285 -0
- ccxt/test/tests_init.py +39 -0
- ccxt/test/{test_sync.py → tests_sync.py} +465 -409
- ccxt/timex.py +123 -70
- ccxt/tokocrypto.py +129 -93
- ccxt/tradeogre.py +39 -25
- ccxt/upbit.py +322 -113
- ccxt/vertex.py +2983 -0
- ccxt/wavesexchange.py +227 -173
- ccxt/wazirx.py +145 -65
- ccxt/whitebit.py +533 -138
- ccxt/woo.py +1155 -295
- ccxt/woofipro.py +2716 -0
- ccxt/xt.py +4627 -0
- ccxt/yobit.py +159 -92
- ccxt/zaif.py +80 -33
- ccxt/zonda.py +140 -69
- ccxt-4.4.48.dist-info/LICENSE.txt +21 -0
- ccxt-4.4.48.dist-info/METADATA +646 -0
- ccxt-4.4.48.dist-info/RECORD +669 -0
- {ccxt-4.2.76.dist-info → ccxt-4.4.48.dist-info}/WHEEL +1 -1
- ccxt/abstract/bitbay.py +0 -47
- ccxt/abstract/bitfinex2.py +0 -139
- ccxt/abstract/hitbtc3.py +0 -115
- ccxt/async_support/bitbay.py +0 -17
- ccxt/async_support/bitfinex2.py +0 -3496
- ccxt/async_support/flowbtc.py +0 -34
- ccxt/bitbay.py +0 -17
- ccxt/bitfinex2.py +0 -3496
- ccxt/flowbtc.py +0 -34
- ccxt/hitbtc3.py +0 -16
- ccxt/pro/bitfinex2.py +0 -1081
- ccxt/test/base/__init__.py +0 -28
- 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 -103
- 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 -32
- 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_margin_mode.py +0 -24
- ccxt/test/base/test_margin_modification.py +0 -35
- ccxt/test/base/test_market.py +0 -190
- ccxt/test/base/test_number.py +0 -411
- ccxt/test/base/test_ohlcv.py +0 -32
- 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 -63
- ccxt/test/base/test_position.py +0 -60
- ccxt/test/base/test_shared_methods.py +0 -345
- ccxt/test/base/test_status.py +0 -24
- ccxt/test/base/test_throttle.py +0 -126
- ccxt/test/base/test_ticker.py +0 -86
- 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-4.2.76.dist-info/METADATA +0 -626
- ccxt-4.2.76.dist-info/RECORD +0 -534
- {ccxt-4.2.76.dist-info → ccxt-4.4.48.dist-info}/top_level.txt +0 -0
@@ -5,8 +5,9 @@
|
|
5
5
|
|
6
6
|
from ccxt.async_support.kucoin import kucoin
|
7
7
|
from ccxt.abstract.kucoinfutures import ImplicitAPI
|
8
|
-
from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Trade, Transaction, TransferEntry
|
8
|
+
from ccxt.base.types import Balances, Currency, DepositAddress, Int, Leverage, LeverageTier, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
9
9
|
from typing import List
|
10
|
+
from ccxt.base.errors import AuthenticationError
|
10
11
|
from ccxt.base.errors import PermissionDenied
|
11
12
|
from ccxt.base.errors import AccountSuspended
|
12
13
|
from ccxt.base.errors import ArgumentsRequired
|
@@ -18,7 +19,6 @@ from ccxt.base.errors import NotSupported
|
|
18
19
|
from ccxt.base.errors import RateLimitExceeded
|
19
20
|
from ccxt.base.errors import ExchangeNotAvailable
|
20
21
|
from ccxt.base.errors import InvalidNonce
|
21
|
-
from ccxt.base.errors import AuthenticationError
|
22
22
|
from ccxt.base.decimal_to_precision import TICK_SIZE
|
23
23
|
from ccxt.base.precise import Precise
|
24
24
|
|
@@ -46,12 +46,14 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
46
46
|
'addMargin': True,
|
47
47
|
'cancelAllOrders': True,
|
48
48
|
'cancelOrder': True,
|
49
|
+
'cancelOrders': True,
|
49
50
|
'closeAllPositions': False,
|
50
51
|
'closePosition': True,
|
51
52
|
'closePositions': False,
|
52
53
|
'createDepositAddress': True,
|
53
54
|
'createOrder': True,
|
54
55
|
'createOrders': True,
|
56
|
+
'createOrderWithTakeProfitAndStopLoss': True,
|
55
57
|
'createReduceOnlyOrder': True,
|
56
58
|
'createStopLimitOrder': True,
|
57
59
|
'createStopLossOrder': True,
|
@@ -61,6 +63,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
61
63
|
'createTriggerOrder': True,
|
62
64
|
'fetchAccounts': True,
|
63
65
|
'fetchBalance': True,
|
66
|
+
'fetchBidsAsks': True,
|
64
67
|
'fetchBorrowRateHistories': False,
|
65
68
|
'fetchBorrowRateHistory': False,
|
66
69
|
'fetchClosedOrders': True,
|
@@ -68,10 +71,14 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
68
71
|
'fetchCrossBorrowRates': False,
|
69
72
|
'fetchCurrencies': False,
|
70
73
|
'fetchDepositAddress': True,
|
74
|
+
'fetchDepositAddresses': False,
|
75
|
+
'fetchDepositAddressesByNetwork': False,
|
71
76
|
'fetchDeposits': True,
|
72
77
|
'fetchDepositWithdrawFee': False,
|
73
78
|
'fetchDepositWithdrawFees': False,
|
74
79
|
'fetchFundingHistory': True,
|
80
|
+
'fetchFundingInterval': True,
|
81
|
+
'fetchFundingIntervals': False,
|
75
82
|
'fetchFundingRate': True,
|
76
83
|
'fetchFundingRateHistory': True,
|
77
84
|
'fetchIndexOHLCV': False,
|
@@ -79,29 +86,35 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
79
86
|
'fetchIsolatedBorrowRates': False,
|
80
87
|
'fetchL3OrderBook': True,
|
81
88
|
'fetchLedger': True,
|
89
|
+
'fetchLeverage': True,
|
82
90
|
'fetchLeverageTiers': False,
|
83
|
-
'
|
91
|
+
'fetchMarginAdjustmentHistory': False,
|
92
|
+
'fetchMarginMode': True,
|
84
93
|
'fetchMarketLeverageTiers': True,
|
85
94
|
'fetchMarkets': True,
|
86
95
|
'fetchMarkOHLCV': False,
|
96
|
+
'fetchMarkPrice': True,
|
87
97
|
'fetchMyTrades': True,
|
88
98
|
'fetchOHLCV': True,
|
89
99
|
'fetchOpenOrders': True,
|
90
100
|
'fetchOrder': True,
|
91
101
|
'fetchOrderBook': True,
|
92
102
|
'fetchPosition': True,
|
103
|
+
'fetchPositionHistory': False,
|
93
104
|
'fetchPositionMode': False,
|
94
105
|
'fetchPositions': True,
|
106
|
+
'fetchPositionsHistory': True,
|
95
107
|
'fetchPremiumIndexOHLCV': False,
|
96
108
|
'fetchStatus': True,
|
97
109
|
'fetchTicker': True,
|
98
|
-
'fetchTickers':
|
110
|
+
'fetchTickers': True,
|
99
111
|
'fetchTime': True,
|
100
112
|
'fetchTrades': True,
|
113
|
+
'fetchTradingFee': True,
|
101
114
|
'fetchTransactionFee': False,
|
102
115
|
'fetchWithdrawals': True,
|
103
116
|
'setLeverage': False,
|
104
|
-
'setMarginMode':
|
117
|
+
'setMarginMode': True,
|
105
118
|
'transfer': True,
|
106
119
|
'withdraw': None,
|
107
120
|
},
|
@@ -133,6 +146,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
133
146
|
'contracts/{symbol}': 1,
|
134
147
|
'contracts/risk-limit/{symbol}': 1,
|
135
148
|
'ticker': 1,
|
149
|
+
'allTickers': 1,
|
136
150
|
'level2/snapshot': 1.33,
|
137
151
|
'level2/depth{limit}': 1,
|
138
152
|
'level2/message/query': 1,
|
@@ -174,12 +188,18 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
174
188
|
'funding-history': 4.44,
|
175
189
|
'sub/api-key': 1,
|
176
190
|
'trade-statistics': 1,
|
191
|
+
'trade-fees': 1,
|
192
|
+
'history-positions': 1,
|
193
|
+
'getMaxOpenSize': 1,
|
194
|
+
'getCrossUserLeverage': 1,
|
195
|
+
'position/getMarginMode': 1,
|
177
196
|
},
|
178
197
|
'post': {
|
179
198
|
'withdrawals': 1,
|
180
199
|
'transfer-out': 1, # v2
|
181
200
|
'transfer-in': 1,
|
182
201
|
'orders': 1.33,
|
202
|
+
'st-orders': 1.33,
|
183
203
|
'orders/test': 1.33,
|
184
204
|
'position/margin/auto-deposit-status': 1,
|
185
205
|
'position/margin/deposit-margin': 1,
|
@@ -187,6 +207,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
187
207
|
'bullet-private': 1,
|
188
208
|
'sub/api-key': 1,
|
189
209
|
'sub/api-key/update': 1,
|
210
|
+
'changeCrossUserLeverage': 1,
|
211
|
+
'position/changeMarginMode': 1,
|
190
212
|
},
|
191
213
|
'delete': {
|
192
214
|
'withdrawals/{withdrawalId}': 1,
|
@@ -196,6 +218,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
196
218
|
'stopOrders': 1,
|
197
219
|
'sub/api-key': 1,
|
198
220
|
'orders/client-order/{clientOid}': 1,
|
221
|
+
'orders/multi-cancel': 20,
|
199
222
|
},
|
200
223
|
},
|
201
224
|
'webExchange': {
|
@@ -235,6 +258,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
235
258
|
'400100': BadRequest, # Parameter Error -- You tried to access the resource with invalid parameters
|
236
259
|
'411100': AccountSuspended, # User is frozen -- Please contact us via support center
|
237
260
|
'500000': ExchangeNotAvailable, # Internal Server Error -- We had a problem with our server. Try again later.
|
261
|
+
'300009': InvalidOrder, # {"msg":"No open positions to close.","code":"300009"}
|
238
262
|
},
|
239
263
|
'broad': {
|
240
264
|
'Position does not exist': OrderNotFound, # {"code":"200000", "msg":"Position does not exist"}
|
@@ -319,8 +343,15 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
319
343
|
# endpoint versions
|
320
344
|
'versions': {
|
321
345
|
'futuresPrivate': {
|
346
|
+
'GET': {
|
347
|
+
'getMaxOpenSize': 'v2',
|
348
|
+
'getCrossUserLeverage': 'v2',
|
349
|
+
'position/getMarginMode': 'v2',
|
350
|
+
},
|
322
351
|
'POST': {
|
323
352
|
'transfer-out': 'v2',
|
353
|
+
'changeCrossUserLeverage': 'v2',
|
354
|
+
'position/changeMarginMode': 'v2',
|
324
355
|
},
|
325
356
|
},
|
326
357
|
'futuresPublic': {
|
@@ -339,12 +370,98 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
339
370
|
# 'code': 'BTC',
|
340
371
|
# },
|
341
372
|
},
|
373
|
+
'features': {
|
374
|
+
'spot': None,
|
375
|
+
'forDerivs': {
|
376
|
+
'sandbox': False,
|
377
|
+
'createOrder': {
|
378
|
+
'marginMode': True,
|
379
|
+
'triggerPrice': True,
|
380
|
+
'triggerPriceType': {
|
381
|
+
'last': True,
|
382
|
+
'mark': True,
|
383
|
+
'index': True,
|
384
|
+
},
|
385
|
+
'triggerDirection': True,
|
386
|
+
'stopLossPrice': True,
|
387
|
+
'takeProfitPrice': True,
|
388
|
+
'attachedStopLossTakeProfit': {
|
389
|
+
'triggerPriceType': None,
|
390
|
+
'price': True,
|
391
|
+
},
|
392
|
+
'timeInForce': {
|
393
|
+
'IOC': True,
|
394
|
+
'FOK': False,
|
395
|
+
'PO': True,
|
396
|
+
'GTD': False,
|
397
|
+
},
|
398
|
+
'hedged': False,
|
399
|
+
'trailing': False,
|
400
|
+
'leverage': True, # todo implement
|
401
|
+
'marketBuyByCost': True,
|
402
|
+
'marketBuyRequiresPrice': False,
|
403
|
+
'selfTradePrevention': True, # todo implement
|
404
|
+
'iceberg': True,
|
405
|
+
},
|
406
|
+
'createOrders': {
|
407
|
+
'max': 20,
|
408
|
+
},
|
409
|
+
'fetchMyTrades': {
|
410
|
+
'marginMode': True,
|
411
|
+
'limit': 1000,
|
412
|
+
'daysBack': None,
|
413
|
+
'untilDays': 7,
|
414
|
+
},
|
415
|
+
'fetchOrder': {
|
416
|
+
'marginMode': False,
|
417
|
+
'trigger': False,
|
418
|
+
'trailing': False,
|
419
|
+
},
|
420
|
+
'fetchOpenOrders': {
|
421
|
+
'marginMode': False,
|
422
|
+
'limit': 1000,
|
423
|
+
'trigger': True,
|
424
|
+
'trailing': False,
|
425
|
+
},
|
426
|
+
'fetchOrders': None,
|
427
|
+
'fetchClosedOrders': {
|
428
|
+
'marginMode': False,
|
429
|
+
'limit': 1000,
|
430
|
+
'daysBack': None,
|
431
|
+
'daysBackCanceled': None,
|
432
|
+
'untilDays': None,
|
433
|
+
'trigger': True,
|
434
|
+
'trailing': False,
|
435
|
+
},
|
436
|
+
'fetchOHLCV': {
|
437
|
+
'limit': 500,
|
438
|
+
},
|
439
|
+
},
|
440
|
+
'swap': {
|
441
|
+
'linear': {
|
442
|
+
'extends': 'forDerivs',
|
443
|
+
},
|
444
|
+
'inverse': {
|
445
|
+
'extends': 'forDerivs',
|
446
|
+
},
|
447
|
+
},
|
448
|
+
'future': {
|
449
|
+
'linear': {
|
450
|
+
'extends': 'forDerivs',
|
451
|
+
},
|
452
|
+
'inverse': {
|
453
|
+
'extends': 'forDerivs',
|
454
|
+
},
|
455
|
+
},
|
456
|
+
},
|
342
457
|
})
|
343
458
|
|
344
459
|
async def fetch_status(self, params={}):
|
345
460
|
"""
|
346
461
|
the latest known information on the availability of the exchange API
|
347
|
-
|
462
|
+
|
463
|
+
https://www.kucoin.com/docs/rest/futures-trading/market-data/get-service-status
|
464
|
+
|
348
465
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
349
466
|
:returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
|
350
467
|
"""
|
@@ -368,10 +485,12 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
368
485
|
'info': response,
|
369
486
|
}
|
370
487
|
|
371
|
-
async def fetch_markets(self, params={}):
|
488
|
+
async def fetch_markets(self, params={}) -> List[Market]:
|
372
489
|
"""
|
373
490
|
retrieves data on all markets for kucoinfutures
|
374
|
-
|
491
|
+
|
492
|
+
https://www.kucoin.com/docs/rest/futures-trading/market-data/get-symbols-list
|
493
|
+
|
375
494
|
:param dict [params]: extra parameters specific to the exchange api endpoint
|
376
495
|
:returns dict[]: an array of objects representing market data
|
377
496
|
"""
|
@@ -529,7 +648,9 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
529
648
|
async def fetch_time(self, params={}):
|
530
649
|
"""
|
531
650
|
fetches the current integer timestamp in milliseconds from the exchange server
|
532
|
-
|
651
|
+
|
652
|
+
https://www.kucoin.com/docs/rest/futures-trading/market-data/get-server-time
|
653
|
+
|
533
654
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
534
655
|
:returns int: the current integer timestamp in milliseconds from the exchange server
|
535
656
|
"""
|
@@ -545,7 +666,9 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
545
666
|
async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
546
667
|
"""
|
547
668
|
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
548
|
-
|
669
|
+
|
670
|
+
https://www.kucoin.com/docs/rest/futures-trading/market-data/get-klines
|
671
|
+
|
549
672
|
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
550
673
|
:param str timeframe: the length of time each candle represents
|
551
674
|
:param int [since]: timestamp in ms of the earliest candle to fetch
|
@@ -562,7 +685,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
562
685
|
market = self.market(symbol)
|
563
686
|
marketId = market['id']
|
564
687
|
parsedTimeframe = self.safe_integer(self.timeframes, timeframe)
|
565
|
-
request = {
|
688
|
+
request: dict = {
|
566
689
|
'symbol': marketId,
|
567
690
|
}
|
568
691
|
if parsedTimeframe is not None:
|
@@ -591,7 +714,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
591
714
|
# ]
|
592
715
|
# }
|
593
716
|
#
|
594
|
-
data = self.
|
717
|
+
data = self.safe_list(response, 'data', [])
|
595
718
|
return self.parse_ohlcvs(data, market, timeframe, since, limit)
|
596
719
|
|
597
720
|
def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
|
@@ -615,10 +738,12 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
615
738
|
self.safe_number(ohlcv, 5),
|
616
739
|
]
|
617
740
|
|
618
|
-
async def fetch_deposit_address(self, code: str, params={}):
|
741
|
+
async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
|
619
742
|
"""
|
620
743
|
fetch the deposit address for a currency associated with self account
|
621
|
-
|
744
|
+
|
745
|
+
https://www.kucoin.com/docs/rest/funding/deposit/get-deposit-address
|
746
|
+
|
622
747
|
:param str code: unified currency code
|
623
748
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
624
749
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
@@ -626,7 +751,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
626
751
|
await self.load_markets()
|
627
752
|
currency = self.currency(code)
|
628
753
|
currencyId = currency['id']
|
629
|
-
request = {
|
754
|
+
request: dict = {
|
630
755
|
'currency': currencyId, # Currency,including XBT,USDT
|
631
756
|
}
|
632
757
|
response = await self.futuresPrivateGetDepositAddress(self.extend(request, params))
|
@@ -647,15 +772,17 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
647
772
|
return {
|
648
773
|
'info': response,
|
649
774
|
'currency': currencyId,
|
775
|
+
'network': self.safe_string(data, 'chain'),
|
650
776
|
'address': address,
|
651
777
|
'tag': self.safe_string(data, 'memo'),
|
652
|
-
'network': self.safe_string(data, 'chain'),
|
653
778
|
}
|
654
779
|
|
655
780
|
async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
656
781
|
"""
|
657
782
|
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
658
|
-
|
783
|
+
|
784
|
+
https://www.kucoin.com/docs/rest/futures-trading/market-data/get-part-order-book-level-2
|
785
|
+
|
659
786
|
:param str symbol: unified symbol of the market to fetch the order book for
|
660
787
|
:param int [limit]: the maximum amount of order book entries to return
|
661
788
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -666,7 +793,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
666
793
|
if level != 2 and level is not None:
|
667
794
|
raise BadRequest(self.id + ' fetchOrderBook() can only return level 2')
|
668
795
|
market = self.market(symbol)
|
669
|
-
request = {
|
796
|
+
request: dict = {
|
670
797
|
'symbol': market['id'],
|
671
798
|
}
|
672
799
|
if limit is not None:
|
@@ -704,14 +831,16 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
704
831
|
async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
705
832
|
"""
|
706
833
|
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
707
|
-
|
834
|
+
|
835
|
+
https://www.kucoin.com/docs/rest/futures-trading/market-data/get-ticker
|
836
|
+
|
708
837
|
:param str symbol: unified symbol of the market to fetch the ticker for
|
709
838
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
710
839
|
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
711
840
|
"""
|
712
841
|
await self.load_markets()
|
713
842
|
market = self.market(symbol)
|
714
|
-
request = {
|
843
|
+
request: dict = {
|
715
844
|
'symbol': market['id'],
|
716
845
|
}
|
717
846
|
response = await self.futuresPublicGetTicker(self.extend(request, params))
|
@@ -735,7 +864,120 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
735
864
|
#
|
736
865
|
return self.parse_ticker(response['data'], market)
|
737
866
|
|
738
|
-
def
|
867
|
+
async def fetch_mark_price(self, symbol: str, params={}) -> Ticker:
|
868
|
+
"""
|
869
|
+
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
870
|
+
|
871
|
+
https://www.kucoin.com/docs/rest/futures-trading/market-data/get-current-mark-price
|
872
|
+
|
873
|
+
:param str symbol: unified symbol of the market to fetch the ticker for
|
874
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
875
|
+
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
876
|
+
"""
|
877
|
+
await self.load_markets()
|
878
|
+
market = self.market(symbol)
|
879
|
+
request: dict = {
|
880
|
+
'symbol': market['id'],
|
881
|
+
}
|
882
|
+
response = await self.futuresPublicGetMarkPriceSymbolCurrent(self.extend(request, params))
|
883
|
+
#
|
884
|
+
return self.parse_ticker(response['data'], market)
|
885
|
+
|
886
|
+
async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
887
|
+
"""
|
888
|
+
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
889
|
+
|
890
|
+
https://www.kucoin.com/docs/rest/futures-trading/market-data/get-symbols-list
|
891
|
+
|
892
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
893
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
894
|
+
:param str [params.method]: the method to use, futuresPublicGetAllTickers or futuresPublicGetContractsActive
|
895
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
896
|
+
"""
|
897
|
+
await self.load_markets()
|
898
|
+
symbols = self.market_symbols(symbols)
|
899
|
+
method = None
|
900
|
+
method, params = self.handle_option_and_params(params, 'fetchTickers', 'method', 'futuresPublicGetContractsActive')
|
901
|
+
response: dict = None
|
902
|
+
if method == 'futuresPublicGetAllTickers':
|
903
|
+
response = await self.futuresPublicGetAllTickers(params)
|
904
|
+
else:
|
905
|
+
response = await self.futuresPublicGetContractsActive(params)
|
906
|
+
#
|
907
|
+
# {
|
908
|
+
# "code": "200000",
|
909
|
+
# "data": {
|
910
|
+
# "symbol": "ETHUSDTM",
|
911
|
+
# "rootSymbol": "USDT",
|
912
|
+
# "type": "FFWCSX",
|
913
|
+
# "firstOpenDate": 1591086000000,
|
914
|
+
# "expireDate": null,
|
915
|
+
# "settleDate": null,
|
916
|
+
# "baseCurrency": "ETH",
|
917
|
+
# "quoteCurrency": "USDT",
|
918
|
+
# "settleCurrency": "USDT",
|
919
|
+
# "maxOrderQty": 1000000,
|
920
|
+
# "maxPrice": 1000000.0000000000,
|
921
|
+
# "lotSize": 1,
|
922
|
+
# "tickSize": 0.05,
|
923
|
+
# "indexPriceTickSize": 0.01,
|
924
|
+
# "multiplier": 0.01,
|
925
|
+
# "initialMargin": 0.01,
|
926
|
+
# "maintainMargin": 0.005,
|
927
|
+
# "maxRiskLimit": 1000000,
|
928
|
+
# "minRiskLimit": 1000000,
|
929
|
+
# "riskStep": 500000,
|
930
|
+
# "makerFeeRate": 0.00020,
|
931
|
+
# "takerFeeRate": 0.00060,
|
932
|
+
# "takerFixFee": 0.0000000000,
|
933
|
+
# "makerFixFee": 0.0000000000,
|
934
|
+
# "settlementFee": null,
|
935
|
+
# "isDeleverage": True,
|
936
|
+
# "isQuanto": True,
|
937
|
+
# "isInverse": False,
|
938
|
+
# "markMethod": "FairPrice",
|
939
|
+
# "fairMethod": "FundingRate",
|
940
|
+
# "fundingBaseSymbol": ".ETHINT8H",
|
941
|
+
# "fundingQuoteSymbol": ".USDTINT8H",
|
942
|
+
# "fundingRateSymbol": ".ETHUSDTMFPI8H",
|
943
|
+
# "indexSymbol": ".KETHUSDT",
|
944
|
+
# "settlementSymbol": "",
|
945
|
+
# "status": "Open",
|
946
|
+
# "fundingFeeRate": 0.000535,
|
947
|
+
# "predictedFundingFeeRate": 0.002197,
|
948
|
+
# "openInterest": "8724443",
|
949
|
+
# "turnoverOf24h": 341156641.03354263,
|
950
|
+
# "volumeOf24h": 74833.54000000,
|
951
|
+
# "markPrice": 4534.07,
|
952
|
+
# "indexPrice":4531.92,
|
953
|
+
# "lastTradePrice": 4545.4500000000,
|
954
|
+
# "nextFundingRateTime": 25481884,
|
955
|
+
# "maxLeverage": 100,
|
956
|
+
# "sourceExchanges": ["huobi", "Okex", "Binance", "Kucoin", "Poloniex", "Hitbtc"],
|
957
|
+
# "premiumsSymbol1M": ".ETHUSDTMPI",
|
958
|
+
# "premiumsSymbol8H": ".ETHUSDTMPI8H",
|
959
|
+
# "fundingBaseSymbol1M": ".ETHINT",
|
960
|
+
# "fundingQuoteSymbol1M": ".USDTINT",
|
961
|
+
# "lowPrice": 4456.90,
|
962
|
+
# "highPrice": 4674.25,
|
963
|
+
# "priceChgPct": 0.0046,
|
964
|
+
# "priceChg": 21.15
|
965
|
+
# }
|
966
|
+
# }
|
967
|
+
#
|
968
|
+
data = self.safe_list(response, 'data')
|
969
|
+
tickers = self.parse_tickers(data, symbols)
|
970
|
+
return self.filter_by_array_tickers(tickers, 'symbol', symbols)
|
971
|
+
|
972
|
+
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
973
|
+
#
|
974
|
+
# {
|
975
|
+
# "symbol": "LTCUSDTM",
|
976
|
+
# "granularity": 1000,
|
977
|
+
# "timePoint": 1727967339000,
|
978
|
+
# "value": 62.37, mark price
|
979
|
+
# "indexPrice": 62.37
|
980
|
+
# }
|
739
981
|
#
|
740
982
|
# {
|
741
983
|
# "code": "200000",
|
@@ -754,16 +996,76 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
754
996
|
# }
|
755
997
|
# }
|
756
998
|
#
|
757
|
-
|
999
|
+
# from fetchTickers
|
1000
|
+
#
|
1001
|
+
# {
|
1002
|
+
# symbol: "XBTUSDTM",
|
1003
|
+
# rootSymbol: "USDT",
|
1004
|
+
# type: "FFWCSX",
|
1005
|
+
# firstOpenDate: 1585555200000,
|
1006
|
+
# expireDate: null,
|
1007
|
+
# settleDate: null,
|
1008
|
+
# baseCurrency: "XBT",
|
1009
|
+
# quoteCurrency: "USDT",
|
1010
|
+
# settleCurrency: "USDT",
|
1011
|
+
# maxOrderQty: 1000000,
|
1012
|
+
# maxPrice: 1000000,
|
1013
|
+
# lotSize: 1,
|
1014
|
+
# tickSize: 0.1,
|
1015
|
+
# indexPriceTickSize: 0.01,
|
1016
|
+
# multiplier: 0.001,
|
1017
|
+
# initialMargin: 0.008,
|
1018
|
+
# maintainMargin: 0.004,
|
1019
|
+
# maxRiskLimit: 100000,
|
1020
|
+
# minRiskLimit: 100000,
|
1021
|
+
# riskStep: 50000,
|
1022
|
+
# makerFeeRate: 0.0002,
|
1023
|
+
# takerFeeRate: 0.0006,
|
1024
|
+
# takerFixFee: 0,
|
1025
|
+
# makerFixFee: 0,
|
1026
|
+
# settlementFee: null,
|
1027
|
+
# isDeleverage: True,
|
1028
|
+
# isQuanto: True,
|
1029
|
+
# isInverse: False,
|
1030
|
+
# markMethod: "FairPrice",
|
1031
|
+
# fairMethod: "FundingRate",
|
1032
|
+
# fundingBaseSymbol: ".XBTINT8H",
|
1033
|
+
# fundingQuoteSymbol: ".USDTINT8H",
|
1034
|
+
# fundingRateSymbol: ".XBTUSDTMFPI8H",
|
1035
|
+
# indexSymbol: ".KXBTUSDT",
|
1036
|
+
# settlementSymbol: "",
|
1037
|
+
# status: "Open",
|
1038
|
+
# fundingFeeRate: 0.000297,
|
1039
|
+
# predictedFundingFeeRate: 0.000327,
|
1040
|
+
# fundingRateGranularity: 28800000,
|
1041
|
+
# openInterest: "8033200",
|
1042
|
+
# turnoverOf24h: 659795309.2524643,
|
1043
|
+
# volumeOf24h: 9998.54,
|
1044
|
+
# markPrice: 67193.51,
|
1045
|
+
# indexPrice: 67184.81,
|
1046
|
+
# lastTradePrice: 67191.8,
|
1047
|
+
# nextFundingRateTime: 20022985,
|
1048
|
+
# maxLeverage: 125,
|
1049
|
+
# premiumsSymbol1M: ".XBTUSDTMPI",
|
1050
|
+
# premiumsSymbol8H: ".XBTUSDTMPI8H",
|
1051
|
+
# fundingBaseSymbol1M: ".XBTINT",
|
1052
|
+
# fundingQuoteSymbol1M: ".USDTINT",
|
1053
|
+
# lowPrice: 64041.6,
|
1054
|
+
# highPrice: 67737.3,
|
1055
|
+
# priceChgPct: 0.0447,
|
1056
|
+
# priceChg: 2878.7
|
1057
|
+
# }
|
1058
|
+
#
|
758
1059
|
marketId = self.safe_string(ticker, 'symbol')
|
759
1060
|
market = self.safe_market(marketId, market, '-')
|
1061
|
+
last = self.safe_string_2(ticker, 'price', 'lastTradePrice')
|
760
1062
|
timestamp = self.safe_integer_product(ticker, 'ts', 0.000001)
|
761
1063
|
return self.safe_ticker({
|
762
1064
|
'symbol': market['symbol'],
|
763
1065
|
'timestamp': timestamp,
|
764
1066
|
'datetime': self.iso8601(timestamp),
|
765
|
-
'high':
|
766
|
-
'low':
|
1067
|
+
'high': self.safe_string(ticker, 'highPrice'),
|
1068
|
+
'low': self.safe_string(ticker, 'lowPrice'),
|
767
1069
|
'bid': self.safe_string(ticker, 'bestBidPrice'),
|
768
1070
|
'bidVolume': self.safe_string(ticker, 'bestBidSize'),
|
769
1071
|
'ask': self.safe_string(ticker, 'bestAskPrice'),
|
@@ -773,18 +1075,34 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
773
1075
|
'close': last,
|
774
1076
|
'last': last,
|
775
1077
|
'previousClose': None,
|
776
|
-
'change':
|
777
|
-
'percentage':
|
1078
|
+
'change': self.safe_string(ticker, 'priceChg'),
|
1079
|
+
'percentage': self.safe_string(ticker, 'priceChgPct'),
|
778
1080
|
'average': None,
|
779
|
-
'baseVolume':
|
780
|
-
'quoteVolume':
|
1081
|
+
'baseVolume': self.safe_string(ticker, 'volumeOf24h'),
|
1082
|
+
'quoteVolume': self.safe_string(ticker, 'turnoverOf24h'),
|
1083
|
+
'markPrice': self.safe_string_2(ticker, 'markPrice', 'value'),
|
1084
|
+
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
781
1085
|
'info': ticker,
|
782
1086
|
}, market)
|
783
1087
|
|
1088
|
+
async def fetch_bids_asks(self, symbols: Strings = None, params={}):
|
1089
|
+
"""
|
1090
|
+
fetches the bid and ask price and volume for multiple markets
|
1091
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
|
1092
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1093
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1094
|
+
"""
|
1095
|
+
request = {
|
1096
|
+
'method': 'futuresPublicGetAllTickers',
|
1097
|
+
}
|
1098
|
+
return await self.fetch_tickers(symbols, self.extend(request, params))
|
1099
|
+
|
784
1100
|
async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
785
1101
|
"""
|
786
1102
|
fetch the history of funding payments paid and received on self account
|
787
|
-
|
1103
|
+
|
1104
|
+
https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-funding-history
|
1105
|
+
|
788
1106
|
:param str symbol: unified market symbol
|
789
1107
|
:param int [since]: the earliest time in ms to fetch funding history for
|
790
1108
|
:param int [limit]: the maximum number of funding history structures to retrieve
|
@@ -795,7 +1113,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
795
1113
|
raise ArgumentsRequired(self.id + ' fetchFundingHistory() requires a symbol argument')
|
796
1114
|
await self.load_markets()
|
797
1115
|
market = self.market(symbol)
|
798
|
-
request = {
|
1116
|
+
request: dict = {
|
799
1117
|
'symbol': market['id'],
|
800
1118
|
}
|
801
1119
|
if since is not None:
|
@@ -849,7 +1167,9 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
849
1167
|
|
850
1168
|
async def fetch_position(self, symbol: str, params={}):
|
851
1169
|
"""
|
852
|
-
|
1170
|
+
|
1171
|
+
https://docs.kucoin.com/futures/#get-position-details
|
1172
|
+
|
853
1173
|
fetch data on an open position
|
854
1174
|
:param str symbol: unified market symbol of the market the position is held in
|
855
1175
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -857,7 +1177,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
857
1177
|
"""
|
858
1178
|
await self.load_markets()
|
859
1179
|
market = self.market(symbol)
|
860
|
-
request = {
|
1180
|
+
request: dict = {
|
861
1181
|
'symbol': market['id'],
|
862
1182
|
}
|
863
1183
|
response = await self.futuresPrivateGetPosition(self.extend(request, params))
|
@@ -905,13 +1225,15 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
905
1225
|
# }
|
906
1226
|
# }
|
907
1227
|
#
|
908
|
-
data = self.
|
1228
|
+
data = self.safe_dict(response, 'data', {})
|
909
1229
|
return self.parse_position(data, market)
|
910
1230
|
|
911
1231
|
async def fetch_positions(self, symbols: Strings = None, params={}):
|
912
1232
|
"""
|
913
1233
|
fetch all open positions
|
914
|
-
|
1234
|
+
|
1235
|
+
https://docs.kucoin.com/futures/#get-position-list
|
1236
|
+
|
915
1237
|
:param str[]|None symbols: list of unified market symbols
|
916
1238
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
917
1239
|
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
@@ -964,10 +1286,79 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
964
1286
|
# ]
|
965
1287
|
# }
|
966
1288
|
#
|
967
|
-
data = self.
|
1289
|
+
data = self.safe_list(response, 'data')
|
968
1290
|
return self.parse_positions(data, symbols)
|
969
1291
|
|
970
|
-
def
|
1292
|
+
async def fetch_positions_history(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}):
|
1293
|
+
"""
|
1294
|
+
fetches historical positions
|
1295
|
+
|
1296
|
+
https://www.kucoin.com/docs/rest/futures-trading/positions/get-positions-history
|
1297
|
+
|
1298
|
+
:param str[] [symbols]: list of unified market symbols
|
1299
|
+
:param int [since]: the earliest time in ms to fetch position history for
|
1300
|
+
:param int [limit]: the maximum number of entries to retrieve
|
1301
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1302
|
+
:param int [params.until]: closing end time
|
1303
|
+
:param int [params.pageId]: page id
|
1304
|
+
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
1305
|
+
"""
|
1306
|
+
await self.load_markets()
|
1307
|
+
if limit is None:
|
1308
|
+
limit = 200
|
1309
|
+
request: dict = {
|
1310
|
+
'limit': limit,
|
1311
|
+
}
|
1312
|
+
if since is not None:
|
1313
|
+
request['from'] = since
|
1314
|
+
until = self.safe_integer(params, 'until')
|
1315
|
+
if until is not None:
|
1316
|
+
params = self.omit(params, 'until')
|
1317
|
+
request['to'] = until
|
1318
|
+
response = await self.futuresPrivateGetHistoryPositions(self.extend(request, params))
|
1319
|
+
#
|
1320
|
+
# {
|
1321
|
+
# "success": True,
|
1322
|
+
# "code": "200",
|
1323
|
+
# "msg": "success",
|
1324
|
+
# "retry": False,
|
1325
|
+
# "data": {
|
1326
|
+
# "currentPage": 1,
|
1327
|
+
# "pageSize": 10,
|
1328
|
+
# "totalNum": 25,
|
1329
|
+
# "totalPage": 3,
|
1330
|
+
# "items": [
|
1331
|
+
# {
|
1332
|
+
# "closeId": "300000000000000030",
|
1333
|
+
# "positionId": "300000000000000009",
|
1334
|
+
# "uid": 99996908309485,
|
1335
|
+
# "userId": "6527d4fc8c7f3d0001f40f5f",
|
1336
|
+
# "symbol": "XBTUSDM",
|
1337
|
+
# "settleCurrency": "XBT",
|
1338
|
+
# "leverage": "0.0",
|
1339
|
+
# "type": "LIQUID_LONG",
|
1340
|
+
# "side": null,
|
1341
|
+
# "closeSize": null,
|
1342
|
+
# "pnl": "-1.0000003793999999",
|
1343
|
+
# "realisedGrossCost": "0.9993849748999999",
|
1344
|
+
# "withdrawPnl": "0.0",
|
1345
|
+
# "roe": null,
|
1346
|
+
# "tradeFee": "0.0006154045",
|
1347
|
+
# "fundingFee": "0.0",
|
1348
|
+
# "openTime": 1713785751181,
|
1349
|
+
# "closeTime": 1713785752784,
|
1350
|
+
# "openPrice": null,
|
1351
|
+
# "closePrice": null
|
1352
|
+
# }
|
1353
|
+
# ]
|
1354
|
+
# }
|
1355
|
+
# }
|
1356
|
+
#
|
1357
|
+
data = self.safe_dict(response, 'data')
|
1358
|
+
items = self.safe_list(data, 'items', [])
|
1359
|
+
return self.parse_positions(items, symbols)
|
1360
|
+
|
1361
|
+
def parse_position(self, position: dict, market: Market = None):
|
971
1362
|
#
|
972
1363
|
# {
|
973
1364
|
# "code": "200000",
|
@@ -1013,16 +1404,46 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1013
1404
|
# }
|
1014
1405
|
# ]
|
1015
1406
|
# }
|
1407
|
+
# position history
|
1408
|
+
# {
|
1409
|
+
# "closeId": "300000000000000030",
|
1410
|
+
# "positionId": "300000000000000009",
|
1411
|
+
# "uid": 99996908309485,
|
1412
|
+
# "userId": "6527d4fc8c7f3d0001f40f5f",
|
1413
|
+
# "symbol": "XBTUSDM",
|
1414
|
+
# "settleCurrency": "XBT",
|
1415
|
+
# "leverage": "0.0",
|
1416
|
+
# "type": "LIQUID_LONG",
|
1417
|
+
# "side": null,
|
1418
|
+
# "closeSize": null,
|
1419
|
+
# "pnl": "-1.0000003793999999",
|
1420
|
+
# "realisedGrossCost": "0.9993849748999999",
|
1421
|
+
# "withdrawPnl": "0.0",
|
1422
|
+
# "roe": null,
|
1423
|
+
# "tradeFee": "0.0006154045",
|
1424
|
+
# "fundingFee": "0.0",
|
1425
|
+
# "openTime": 1713785751181,
|
1426
|
+
# "closeTime": 1713785752784,
|
1427
|
+
# "openPrice": null,
|
1428
|
+
# "closePrice": null
|
1429
|
+
# }
|
1016
1430
|
#
|
1017
1431
|
symbol = self.safe_string(position, 'symbol')
|
1018
1432
|
market = self.safe_market(symbol, market)
|
1019
1433
|
timestamp = self.safe_integer(position, 'currentTimestamp')
|
1020
1434
|
size = self.safe_string(position, 'currentQty')
|
1021
1435
|
side = None
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1436
|
+
type = self.safe_string_lower(position, 'type')
|
1437
|
+
if size is not None:
|
1438
|
+
if Precise.string_gt(size, '0'):
|
1439
|
+
side = 'long'
|
1440
|
+
elif Precise.string_lt(size, '0'):
|
1441
|
+
side = 'short'
|
1442
|
+
elif type is not None:
|
1443
|
+
if type.find('long') > -1:
|
1444
|
+
side = 'long'
|
1445
|
+
else:
|
1446
|
+
side = 'short'
|
1026
1447
|
notional = Precise.string_abs(self.safe_string(position, 'posCost'))
|
1027
1448
|
initialMargin = self.safe_string(position, 'posInit')
|
1028
1449
|
initialMarginPercentage = Precise.string_div(initialMargin, notional)
|
@@ -1030,25 +1451,27 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1030
1451
|
unrealisedPnl = self.safe_string(position, 'unrealisedPnl')
|
1031
1452
|
crossMode = self.safe_value(position, 'crossMode')
|
1032
1453
|
# currently crossMode is always set to False and only isolated positions are supported
|
1033
|
-
marginMode =
|
1454
|
+
marginMode = None
|
1455
|
+
if crossMode is not None:
|
1456
|
+
marginMode = 'cross' if crossMode else 'isolated'
|
1034
1457
|
return self.safe_position({
|
1035
1458
|
'info': position,
|
1036
|
-
'id': self.
|
1459
|
+
'id': self.safe_string_2(position, 'id', 'positionId'),
|
1037
1460
|
'symbol': self.safe_string(market, 'symbol'),
|
1038
1461
|
'timestamp': timestamp,
|
1039
1462
|
'datetime': self.iso8601(timestamp),
|
1040
|
-
'lastUpdateTimestamp':
|
1463
|
+
'lastUpdateTimestamp': self.safe_integer(position, 'closeTime'),
|
1041
1464
|
'initialMargin': self.parse_number(initialMargin),
|
1042
1465
|
'initialMarginPercentage': self.parse_number(initialMarginPercentage),
|
1043
1466
|
'maintenanceMargin': self.safe_number(position, 'posMaint'),
|
1044
1467
|
'maintenanceMarginPercentage': self.safe_number(position, 'maintMarginReq'),
|
1045
|
-
'entryPrice': self.
|
1468
|
+
'entryPrice': self.safe_number_2(position, 'avgEntryPrice', 'openPrice'),
|
1046
1469
|
'notional': self.parse_number(notional),
|
1047
|
-
'leverage': self.
|
1470
|
+
'leverage': self.safe_number_2(position, 'realLeverage', 'leverage'),
|
1048
1471
|
'unrealizedPnl': self.parse_number(unrealisedPnl),
|
1049
1472
|
'contracts': self.parse_number(Precise.string_abs(size)),
|
1050
1473
|
'contractSize': self.safe_value(market, 'contractSize'),
|
1051
|
-
'realizedPnl': self.
|
1474
|
+
'realizedPnl': self.safe_number_2(position, 'realisedPnl', 'pnl'),
|
1052
1475
|
'marginRatio': None,
|
1053
1476
|
'liquidationPrice': self.safe_number(position, 'liquidationPrice'),
|
1054
1477
|
'markPrice': self.safe_number(position, 'markPrice'),
|
@@ -1064,25 +1487,32 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1064
1487
|
async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
1065
1488
|
"""
|
1066
1489
|
Create an order on the exchange
|
1067
|
-
|
1490
|
+
|
1491
|
+
https://www.kucoin.com/docs/rest/futures-trading/orders/place-order
|
1492
|
+
https://www.kucoin.com/docs/rest/futures-trading/orders/place-take-profit-and-stop-loss-order#http-request
|
1493
|
+
|
1068
1494
|
:param str symbol: Unified CCXT market symbol
|
1069
1495
|
:param str type: 'limit' or 'market'
|
1070
1496
|
:param str side: 'buy' or 'sell'
|
1071
1497
|
:param float amount: the amount of currency to trade
|
1072
|
-
:param float [price]:
|
1498
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1073
1499
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1500
|
+
:param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered and the triggerPriceType
|
1501
|
+
:param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered and the triggerPriceType
|
1074
1502
|
:param float [params.triggerPrice]: The price a trigger order is triggered at
|
1075
1503
|
:param float [params.stopLossPrice]: price to trigger stop-loss orders
|
1076
1504
|
:param float [params.takeProfitPrice]: price to trigger take-profit orders
|
1077
1505
|
:param bool [params.reduceOnly]: A mark to reduce the position size only. Set to False by default. Need to set the position size when reduceOnly is True.
|
1078
1506
|
:param str [params.timeInForce]: GTC, GTT, IOC, or FOK, default is GTC, limit orders only
|
1079
1507
|
:param str [params.postOnly]: Post only flag, invalid when timeInForce is IOC or FOK
|
1080
|
-
|
1081
|
-
|
1508
|
+
:param float [params.cost]: the cost of the order in units of USDT
|
1509
|
+
----------------- Exchange Specific Parameters -----------------
|
1510
|
+
:param float [params.leverage]: Leverage size of the order(mandatory param in request, default is 1)
|
1082
1511
|
:param str [params.clientOid]: client order id, defaults to uuid if not passed
|
1083
1512
|
:param str [params.remark]: remark for the order, length cannot exceed 100 utf8 characters
|
1084
|
-
:param str [params.stop]: 'up' or 'down', the direction the
|
1085
|
-
:param str [params.
|
1513
|
+
:param str [params.stop]: 'up' or 'down', the direction the triggerPrice is triggered from, requires triggerPrice. down: Triggers when the price reaches or goes below the triggerPrice. up: Triggers when the price reaches or goes above the triggerPrice.
|
1514
|
+
:param str [params.triggerPriceType]: "last", "mark", "index" - defaults to "mark"
|
1515
|
+
:param str [params.stopPriceType]: exchange-specific alternative for triggerPriceType: TP, IP or MP
|
1086
1516
|
:param bool [params.closeOrder]: set to True to close position
|
1087
1517
|
:param bool [params.test]: set to True to use the test order endpoint(does not submit order, use to validate params)
|
1088
1518
|
:param bool [params.forceHold]: A mark to forcely hold the funds for an order, even though it's an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to False by default.
|
@@ -1092,12 +1522,16 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1092
1522
|
market = self.market(symbol)
|
1093
1523
|
testOrder = self.safe_bool(params, 'test', False)
|
1094
1524
|
params = self.omit(params, 'test')
|
1525
|
+
isTpAndSlOrder = (self.safe_value(params, 'stopLoss') is not None) or (self.safe_value(params, 'takeProfit') is not None)
|
1095
1526
|
orderRequest = self.create_contract_order_request(symbol, type, side, amount, price, params)
|
1096
1527
|
response = None
|
1097
1528
|
if testOrder:
|
1098
1529
|
response = await self.futuresPrivatePostOrdersTest(orderRequest)
|
1099
1530
|
else:
|
1100
|
-
|
1531
|
+
if isTpAndSlOrder:
|
1532
|
+
response = await self.futuresPrivatePostStOrders(orderRequest)
|
1533
|
+
else:
|
1534
|
+
response = await self.futuresPrivatePostOrders(orderRequest)
|
1101
1535
|
#
|
1102
1536
|
# {
|
1103
1537
|
# "code": "200000",
|
@@ -1106,13 +1540,15 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1106
1540
|
# },
|
1107
1541
|
# }
|
1108
1542
|
#
|
1109
|
-
data = self.
|
1543
|
+
data = self.safe_dict(response, 'data', {})
|
1110
1544
|
return self.parse_order(data, market)
|
1111
1545
|
|
1112
1546
|
async def create_orders(self, orders: List[OrderRequest], params={}):
|
1113
1547
|
"""
|
1114
1548
|
create a list of trade orders
|
1115
|
-
|
1549
|
+
|
1550
|
+
https://www.kucoin.com/docs/rest/futures-trading/orders/place-multiple-orders
|
1551
|
+
|
1116
1552
|
:param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
1117
1553
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1118
1554
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
@@ -1152,7 +1588,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1152
1588
|
# ]
|
1153
1589
|
# }
|
1154
1590
|
#
|
1155
|
-
data = self.
|
1591
|
+
data = self.safe_list(response, 'data', [])
|
1156
1592
|
return self.parse_orders(data)
|
1157
1593
|
|
1158
1594
|
def create_contract_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
@@ -1160,30 +1596,50 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1160
1596
|
# required param, cannot be used twice
|
1161
1597
|
clientOrderId = self.safe_string_2(params, 'clientOid', 'clientOrderId', self.uuid())
|
1162
1598
|
params = self.omit(params, ['clientOid', 'clientOrderId'])
|
1163
|
-
|
1164
|
-
raise InvalidOrder(self.id + ' createOrder() minimum contract order amount is 1')
|
1165
|
-
preciseAmount = int(self.amount_to_precision(symbol, amount))
|
1166
|
-
request = {
|
1599
|
+
request: dict = {
|
1167
1600
|
'clientOid': clientOrderId,
|
1168
1601
|
'side': side,
|
1169
1602
|
'symbol': market['id'],
|
1170
1603
|
'type': type, # limit or market
|
1171
|
-
'size': preciseAmount,
|
1172
1604
|
'leverage': 1,
|
1173
1605
|
}
|
1606
|
+
cost = self.safe_string(params, 'cost')
|
1607
|
+
params = self.omit(params, 'cost')
|
1608
|
+
if cost is not None:
|
1609
|
+
request['valueQty'] = self.cost_to_precision(symbol, cost)
|
1610
|
+
else:
|
1611
|
+
if amount < 1:
|
1612
|
+
raise InvalidOrder(self.id + ' createOrder() minimum contract order amount is 1')
|
1613
|
+
request['size'] = int(self.amount_to_precision(symbol, amount))
|
1174
1614
|
triggerPrice, stopLossPrice, takeProfitPrice = self.handle_trigger_prices(params)
|
1175
|
-
|
1615
|
+
stopLoss = self.safe_dict(params, 'stopLoss')
|
1616
|
+
takeProfit = self.safe_dict(params, 'takeProfit')
|
1617
|
+
# isTpAndSl = stopLossPrice and takeProfitPrice
|
1618
|
+
triggerPriceTypes: dict = {
|
1176
1619
|
'mark': 'MP',
|
1177
1620
|
'last': 'TP',
|
1178
1621
|
'index': 'IP',
|
1179
1622
|
}
|
1180
1623
|
triggerPriceType = self.safe_string(params, 'triggerPriceType', 'mark')
|
1181
1624
|
triggerPriceTypeValue = self.safe_string(triggerPriceTypes, triggerPriceType, triggerPriceType)
|
1182
|
-
params = self.omit(params, ['stopLossPrice', 'takeProfitPrice', 'triggerPrice', 'stopPrice'])
|
1625
|
+
params = self.omit(params, ['stopLossPrice', 'takeProfitPrice', 'triggerPrice', 'stopPrice', 'takeProfit', 'stopLoss'])
|
1183
1626
|
if triggerPrice:
|
1184
1627
|
request['stop'] = 'up' if (side == 'buy') else 'down'
|
1185
1628
|
request['stopPrice'] = self.price_to_precision(symbol, triggerPrice)
|
1186
1629
|
request['stopPriceType'] = triggerPriceTypeValue
|
1630
|
+
elif stopLoss is not None or takeProfit is not None:
|
1631
|
+
priceType = triggerPriceTypeValue
|
1632
|
+
if stopLoss is not None:
|
1633
|
+
slPrice = self.safe_string_2(stopLoss, 'triggerPrice', 'stopPrice')
|
1634
|
+
request['triggerStopDownPrice'] = self.price_to_precision(symbol, slPrice)
|
1635
|
+
priceType = self.safe_string(stopLoss, 'triggerPriceType', 'mark')
|
1636
|
+
priceType = self.safe_string(triggerPriceTypes, priceType, priceType)
|
1637
|
+
if takeProfit is not None:
|
1638
|
+
tpPrice = self.safe_string_2(takeProfit, 'triggerPrice', 'takeProfitPrice')
|
1639
|
+
request['triggerStopUpPrice'] = self.price_to_precision(symbol, tpPrice)
|
1640
|
+
priceType = self.safe_string(takeProfit, 'triggerPriceType', 'mark')
|
1641
|
+
priceType = self.safe_string(triggerPriceTypes, priceType, priceType)
|
1642
|
+
request['stopPriceType'] = priceType
|
1187
1643
|
elif stopLossPrice or takeProfitPrice:
|
1188
1644
|
if stopLossPrice:
|
1189
1645
|
request['stop'] = 'up' if (side == 'buy') else 'down'
|
@@ -1220,7 +1676,9 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1220
1676
|
async def cancel_order(self, id: str, symbol: Str = None, params={}):
|
1221
1677
|
"""
|
1222
1678
|
cancels an open order
|
1223
|
-
|
1679
|
+
|
1680
|
+
https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-futures-order-by-orderid
|
1681
|
+
|
1224
1682
|
:param str id: order id
|
1225
1683
|
:param str symbol: unified symbol of the market the order was made in
|
1226
1684
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -1230,7 +1688,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1230
1688
|
await self.load_markets()
|
1231
1689
|
clientOrderId = self.safe_string_2(params, 'clientOid', 'clientOrderId')
|
1232
1690
|
params = self.omit(params, ['clientOrderId'])
|
1233
|
-
request = {}
|
1691
|
+
request: dict = {}
|
1234
1692
|
response = None
|
1235
1693
|
if clientOrderId is not None:
|
1236
1694
|
if symbol is None:
|
@@ -1254,24 +1712,83 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1254
1712
|
#
|
1255
1713
|
return self.safe_value(response, 'data')
|
1256
1714
|
|
1715
|
+
async def cancel_orders(self, ids, symbol: Str = None, params={}):
|
1716
|
+
"""
|
1717
|
+
cancel multiple orders
|
1718
|
+
|
1719
|
+
https://www.kucoin.com/docs/rest/futures-trading/orders/batch-cancel-orders
|
1720
|
+
|
1721
|
+
:param str[] ids: order ids
|
1722
|
+
:param str symbol: unified symbol of the market the order was made in
|
1723
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1724
|
+
:param str[] [params.clientOrderIds]: client order ids
|
1725
|
+
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1726
|
+
"""
|
1727
|
+
await self.load_markets()
|
1728
|
+
market = None
|
1729
|
+
if symbol is not None:
|
1730
|
+
market = self.market(symbol)
|
1731
|
+
ordersRequests = []
|
1732
|
+
clientOrderIds = self.safe_list_2(params, 'clientOrderIds', 'clientOids', [])
|
1733
|
+
params = self.omit(params, ['clientOrderIds', 'clientOids'])
|
1734
|
+
useClientorderId = False
|
1735
|
+
for i in range(0, len(clientOrderIds)):
|
1736
|
+
useClientorderId = True
|
1737
|
+
if symbol is None:
|
1738
|
+
raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument when cancelling by clientOrderIds')
|
1739
|
+
ordersRequests.append({
|
1740
|
+
'symbol': market['id'],
|
1741
|
+
'clientOid': self.safe_string(clientOrderIds, i),
|
1742
|
+
})
|
1743
|
+
for i in range(0, len(ids)):
|
1744
|
+
ordersRequests.append(ids[i])
|
1745
|
+
requestKey = 'clientOidsList' if useClientorderId else 'orderIdsList'
|
1746
|
+
request: dict = {}
|
1747
|
+
request[requestKey] = ordersRequests
|
1748
|
+
response = await self.futuresPrivateDeleteOrdersMultiCancel(self.extend(request, params))
|
1749
|
+
#
|
1750
|
+
# {
|
1751
|
+
# "code": "200000",
|
1752
|
+
# "data":
|
1753
|
+
# [
|
1754
|
+
# {
|
1755
|
+
# "orderId": "80465574458560512",
|
1756
|
+
# "clientOid": null,
|
1757
|
+
# "code": "200",
|
1758
|
+
# "msg": "success"
|
1759
|
+
# },
|
1760
|
+
# {
|
1761
|
+
# "orderId": "80465575289094144",
|
1762
|
+
# "clientOid": null,
|
1763
|
+
# "code": "200",
|
1764
|
+
# "msg": "success"
|
1765
|
+
# }
|
1766
|
+
# ]
|
1767
|
+
# }
|
1768
|
+
#
|
1769
|
+
orders = self.safe_list(response, 'data', [])
|
1770
|
+
return self.parse_orders(orders, market)
|
1771
|
+
|
1257
1772
|
async def cancel_all_orders(self, symbol: Str = None, params={}):
|
1258
1773
|
"""
|
1259
1774
|
cancel all open orders
|
1260
|
-
|
1261
|
-
|
1775
|
+
|
1776
|
+
https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-multiple-futures-limit-orders
|
1777
|
+
https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-multiple-futures-stop-orders
|
1778
|
+
|
1262
1779
|
:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
|
1263
1780
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1264
1781
|
:param dict [params.trigger]: When True, all the trigger orders will be cancelled
|
1265
1782
|
:returns: Response from the exchange
|
1266
1783
|
"""
|
1267
1784
|
await self.load_markets()
|
1268
|
-
request = {}
|
1785
|
+
request: dict = {}
|
1269
1786
|
if symbol is not None:
|
1270
1787
|
request['symbol'] = self.market_id(symbol)
|
1271
|
-
|
1788
|
+
trigger = self.safe_value_2(params, 'stop', 'trigger')
|
1272
1789
|
params = self.omit(params, ['stop', 'trigger'])
|
1273
1790
|
response = None
|
1274
|
-
if
|
1791
|
+
if trigger:
|
1275
1792
|
response = await self.futuresPrivateDeleteStopOrders(self.extend(request, params))
|
1276
1793
|
else:
|
1277
1794
|
response = await self.futuresPrivateDeleteOrders(self.extend(request, params))
|
@@ -1287,10 +1804,12 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1287
1804
|
#
|
1288
1805
|
return self.safe_value(response, 'data')
|
1289
1806
|
|
1290
|
-
async def add_margin(self, symbol: str, amount, params={}):
|
1807
|
+
async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
1291
1808
|
"""
|
1292
1809
|
add margin
|
1293
|
-
|
1810
|
+
|
1811
|
+
https://www.kucoin.com/docs/rest/futures-trading/positions/add-margin-manually
|
1812
|
+
|
1294
1813
|
:param str symbol: unified market symbol
|
1295
1814
|
:param float amount: amount of margin to add
|
1296
1815
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -1299,7 +1818,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1299
1818
|
await self.load_markets()
|
1300
1819
|
market = self.market(symbol)
|
1301
1820
|
uuid = self.uuid()
|
1302
|
-
request = {
|
1821
|
+
request: dict = {
|
1303
1822
|
'symbol': market['id'],
|
1304
1823
|
'margin': self.amount_to_precision(symbol, amount),
|
1305
1824
|
'bizNo': uuid,
|
@@ -1360,7 +1879,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1360
1879
|
'direction': 'in',
|
1361
1880
|
})
|
1362
1881
|
|
1363
|
-
def parse_margin_modification(self, info, market: Market = None):
|
1882
|
+
def parse_margin_modification(self, info, market: Market = None) -> MarginModification:
|
1364
1883
|
#
|
1365
1884
|
# {
|
1366
1885
|
# "id": "62311d26064e8f00013f2c6d",
|
@@ -1412,21 +1931,27 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1412
1931
|
crossMode = self.safe_value(info, 'crossMode')
|
1413
1932
|
mode = 'cross' if crossMode else 'isolated'
|
1414
1933
|
marketId = self.safe_string(market, 'symbol')
|
1934
|
+
timestamp = self.safe_integer(info, 'currentTimestamp')
|
1415
1935
|
return {
|
1416
1936
|
'info': info,
|
1417
|
-
'
|
1418
|
-
'
|
1937
|
+
'symbol': self.safe_symbol(marketId, market),
|
1938
|
+
'type': None,
|
1939
|
+
'marginMode': mode,
|
1419
1940
|
'amount': None,
|
1941
|
+
'total': None,
|
1420
1942
|
'code': self.safe_currency_code(currencyId),
|
1421
|
-
'symbol': self.safe_symbol(marketId, market),
|
1422
1943
|
'status': None,
|
1944
|
+
'timestamp': timestamp,
|
1945
|
+
'datetime': self.iso8601(timestamp),
|
1423
1946
|
}
|
1424
1947
|
|
1425
1948
|
async def fetch_orders_by_status(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
1426
1949
|
"""
|
1427
1950
|
fetches a list of orders placed on the exchange
|
1428
|
-
|
1429
|
-
|
1951
|
+
|
1952
|
+
https://docs.kucoin.com/futures/#get-order-list
|
1953
|
+
https://docs.kucoin.com/futures/#get-untriggered-stop-order-list
|
1954
|
+
|
1430
1955
|
:param str status: 'active' or 'closed', only 'active' is valid for stop orders
|
1431
1956
|
:param str symbol: unified symbol for the market to retrieve orders from
|
1432
1957
|
:param int [since]: timestamp in ms of the earliest order to retrieve
|
@@ -1444,15 +1969,15 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1444
1969
|
paginate, params = self.handle_option_and_params(params, 'fetchOrdersByStatus', 'paginate')
|
1445
1970
|
if paginate:
|
1446
1971
|
return await self.fetch_paginated_call_dynamic('fetchOrdersByStatus', symbol, since, limit, params)
|
1447
|
-
|
1448
|
-
until = self.
|
1449
|
-
params = self.omit(params, ['stop', 'until', '
|
1972
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
1973
|
+
until = self.safe_integer(params, 'until')
|
1974
|
+
params = self.omit(params, ['stop', 'until', 'trigger'])
|
1450
1975
|
if status == 'closed':
|
1451
1976
|
status = 'done'
|
1452
1977
|
elif status == 'open':
|
1453
1978
|
status = 'active'
|
1454
|
-
request = {}
|
1455
|
-
if not
|
1979
|
+
request: dict = {}
|
1980
|
+
if not trigger:
|
1456
1981
|
request['status'] = status
|
1457
1982
|
elif status != 'active':
|
1458
1983
|
raise BadRequest(self.id + ' fetchOrdersByStatus() can only fetch untriggered stop orders')
|
@@ -1465,7 +1990,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1465
1990
|
if until is not None:
|
1466
1991
|
request['endAt'] = until
|
1467
1992
|
response = None
|
1468
|
-
if
|
1993
|
+
if trigger:
|
1469
1994
|
response = await self.futuresPrivateGetStopOrders(self.extend(request, params))
|
1470
1995
|
else:
|
1471
1996
|
response = await self.futuresPrivateGetOrders(self.extend(request, params))
|
@@ -1521,18 +2046,20 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1521
2046
|
# }
|
1522
2047
|
#
|
1523
2048
|
responseData = self.safe_value(response, 'data', {})
|
1524
|
-
orders = self.
|
2049
|
+
orders = self.safe_list(responseData, 'items', [])
|
1525
2050
|
return self.parse_orders(orders, market, since, limit)
|
1526
2051
|
|
1527
2052
|
async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
1528
2053
|
"""
|
1529
2054
|
fetches information on multiple closed orders made by the user
|
1530
|
-
|
2055
|
+
|
2056
|
+
https://docs.kucoin.com/futures/#get-order-list
|
2057
|
+
|
1531
2058
|
:param str symbol: unified market symbol of the market orders were made in
|
1532
2059
|
:param int [since]: the earliest time in ms to fetch orders for
|
1533
2060
|
:param int [limit]: the maximum number of order structures to retrieve
|
1534
2061
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1535
|
-
:param int [params.
|
2062
|
+
:param int [params.until]: end time in ms
|
1536
2063
|
:param str [params.side]: buy or sell
|
1537
2064
|
:param str [params.type]: limit, or market
|
1538
2065
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
@@ -1545,16 +2072,44 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1545
2072
|
return await self.fetch_paginated_call_dynamic('fetchClosedOrders', symbol, since, limit, params)
|
1546
2073
|
return await self.fetch_orders_by_status('done', symbol, since, limit, params)
|
1547
2074
|
|
2075
|
+
async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
2076
|
+
"""
|
2077
|
+
fetches information on multiple open orders made by the user
|
2078
|
+
|
2079
|
+
https://docs.kucoin.com/futures/#get-order-list
|
2080
|
+
https://docs.kucoin.com/futures/#get-untriggered-stop-order-list
|
2081
|
+
|
2082
|
+
:param str symbol: unified market symbol of the market orders were made in
|
2083
|
+
:param int [since]: the earliest time in ms to fetch orders for
|
2084
|
+
:param int [limit]: the maximum number of order structures to retrieve
|
2085
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2086
|
+
:param int [params.until]: end time in ms
|
2087
|
+
:param str [params.side]: buy or sell
|
2088
|
+
:param str [params.type]: limit, or market
|
2089
|
+
:param boolean [params.trigger]: set to True to retrieve untriggered stop orders
|
2090
|
+
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
2091
|
+
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2092
|
+
"""
|
2093
|
+
await self.load_markets()
|
2094
|
+
paginate = False
|
2095
|
+
paginate, params = self.handle_option_and_params(params, 'fetchOpenOrders', 'paginate')
|
2096
|
+
if paginate:
|
2097
|
+
return await self.fetch_paginated_call_dynamic('fetchOpenOrders', symbol, since, limit, params)
|
2098
|
+
return await self.fetch_orders_by_status('open', symbol, since, limit, params)
|
2099
|
+
|
1548
2100
|
async def fetch_order(self, id: Str = None, symbol: Str = None, params={}):
|
1549
2101
|
"""
|
1550
2102
|
fetches information on an order made by the user
|
1551
|
-
|
2103
|
+
|
2104
|
+
https://docs.kucoin.com/futures/#get-details-of-a-single-order
|
2105
|
+
|
2106
|
+
:param str id: order id
|
1552
2107
|
:param str symbol: unified symbol of the market the order was made in
|
1553
2108
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1554
2109
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1555
2110
|
"""
|
1556
2111
|
await self.load_markets()
|
1557
|
-
request = {}
|
2112
|
+
request: dict = {}
|
1558
2113
|
response = None
|
1559
2114
|
if id is None:
|
1560
2115
|
clientOrderId = self.safe_string_2(params, 'clientOid', 'clientOrderId')
|
@@ -1610,10 +2165,10 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1610
2165
|
# }
|
1611
2166
|
#
|
1612
2167
|
market = self.market(symbol) if (symbol is not None) else None
|
1613
|
-
responseData = self.
|
2168
|
+
responseData = self.safe_dict(response, 'data')
|
1614
2169
|
return self.parse_order(responseData, market)
|
1615
2170
|
|
1616
|
-
def parse_order(self, order, market: Market = None) -> Order:
|
2171
|
+
def parse_order(self, order: dict, market: Market = None) -> Order:
|
1617
2172
|
#
|
1618
2173
|
# fetchOrder, fetchOrdersByStatus
|
1619
2174
|
#
|
@@ -1689,8 +2244,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1689
2244
|
amount = self.safe_string(order, 'size')
|
1690
2245
|
filled = self.safe_string(order, 'filledSize')
|
1691
2246
|
cost = self.safe_string(order, 'filledValue')
|
1692
|
-
average =
|
1693
|
-
if Precise.string_gt(filled, '0'):
|
2247
|
+
average = self.safe_string(order, 'avgDealPrice')
|
2248
|
+
if (average is None) and Precise.string_gt(filled, '0'):
|
1694
2249
|
contractSize = self.safe_string(market, 'contractSize')
|
1695
2250
|
if market['linear']:
|
1696
2251
|
average = Precise.string_div(cost, Precise.string_mul(contractSize, filled))
|
@@ -1713,7 +2268,6 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1713
2268
|
}
|
1714
2269
|
clientOrderId = self.safe_string(order, 'clientOid')
|
1715
2270
|
timeInForce = self.safe_string(order, 'timeInForce')
|
1716
|
-
stopPrice = self.safe_number(order, 'stopPrice')
|
1717
2271
|
postOnly = self.safe_value(order, 'postOnly')
|
1718
2272
|
reduceOnly = self.safe_value(order, 'reduceOnly')
|
1719
2273
|
lastUpdateTimestamp = self.safe_integer(order, 'updatedAt')
|
@@ -1728,8 +2282,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1728
2282
|
'side': side,
|
1729
2283
|
'amount': amount,
|
1730
2284
|
'price': price,
|
1731
|
-
'
|
1732
|
-
'triggerPrice': stopPrice,
|
2285
|
+
'triggerPrice': self.safe_number(order, 'stopPrice'),
|
1733
2286
|
'cost': cost,
|
1734
2287
|
'filled': filled,
|
1735
2288
|
'remaining': None,
|
@@ -1744,17 +2297,19 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1744
2297
|
'trades': None,
|
1745
2298
|
}, market)
|
1746
2299
|
|
1747
|
-
async def fetch_funding_rate(self, symbol: str, params={}):
|
2300
|
+
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
1748
2301
|
"""
|
1749
2302
|
fetch the current funding rate
|
1750
|
-
|
2303
|
+
|
2304
|
+
https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-current-funding-rate
|
2305
|
+
|
1751
2306
|
:param str symbol: unified market symbol
|
1752
2307
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1753
2308
|
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
1754
2309
|
"""
|
1755
2310
|
await self.load_markets()
|
1756
2311
|
market = self.market(symbol)
|
1757
|
-
request = {
|
2312
|
+
request: dict = {
|
1758
2313
|
'symbol': market['id'],
|
1759
2314
|
}
|
1760
2315
|
response = await self.futuresPublicGetFundingRateSymbolCurrent(self.extend(request, params))
|
@@ -1770,12 +2325,37 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1770
2325
|
# },
|
1771
2326
|
# }
|
1772
2327
|
#
|
1773
|
-
data = self.
|
1774
|
-
fundingTimestamp = self.safe_integer(data, 'timePoint')
|
2328
|
+
data = self.safe_dict(response, 'data', {})
|
1775
2329
|
# the website displayes the previous funding rate as "funding rate"
|
2330
|
+
return self.parse_funding_rate(data, market)
|
2331
|
+
|
2332
|
+
async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
2333
|
+
"""
|
2334
|
+
fetch the current funding rate interval
|
2335
|
+
|
2336
|
+
https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-current-funding-rate
|
2337
|
+
|
2338
|
+
:param str symbol: unified market symbol
|
2339
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2340
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
2341
|
+
"""
|
2342
|
+
return await self.fetch_funding_rate(symbol, params)
|
2343
|
+
|
2344
|
+
def parse_funding_rate(self, data, market: Market = None) -> FundingRate:
|
2345
|
+
#
|
2346
|
+
# {
|
2347
|
+
# "symbol": ".ETHUSDTMFPI8H",
|
2348
|
+
# "granularity": 28800000,
|
2349
|
+
# "timePoint": 1637380800000,
|
2350
|
+
# "value": 0.0001,
|
2351
|
+
# "predictedValue": 0.0001,
|
2352
|
+
# }
|
2353
|
+
#
|
2354
|
+
fundingTimestamp = self.safe_integer(data, 'timePoint')
|
2355
|
+
marketId = self.safe_string(data, 'symbol')
|
1776
2356
|
return {
|
1777
2357
|
'info': data,
|
1778
|
-
'symbol': market
|
2358
|
+
'symbol': self.safe_symbol(marketId, market, None, 'contract'),
|
1779
2359
|
'markPrice': None,
|
1780
2360
|
'indexPrice': None,
|
1781
2361
|
'interestRate': None,
|
@@ -1791,10 +2371,21 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1791
2371
|
'previousFundingRate': None,
|
1792
2372
|
'previousFundingTimestamp': None,
|
1793
2373
|
'previousFundingDatetime': None,
|
2374
|
+
'interval': self.parse_funding_interval(self.safe_string(data, 'granularity')),
|
1794
2375
|
}
|
1795
2376
|
|
2377
|
+
def parse_funding_interval(self, interval):
|
2378
|
+
intervals: dict = {
|
2379
|
+
'3600000': '1h',
|
2380
|
+
'14400000': '4h',
|
2381
|
+
'28800000': '8h',
|
2382
|
+
'57600000': '16h',
|
2383
|
+
'86400000': '24h',
|
2384
|
+
}
|
2385
|
+
return self.safe_string(intervals, interval, interval)
|
2386
|
+
|
1796
2387
|
def parse_balance(self, response) -> Balances:
|
1797
|
-
result = {
|
2388
|
+
result: dict = {
|
1798
2389
|
'info': response,
|
1799
2390
|
'timestamp': None,
|
1800
2391
|
'datetime': None,
|
@@ -1811,7 +2402,9 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1811
2402
|
async def fetch_balance(self, params={}) -> Balances:
|
1812
2403
|
"""
|
1813
2404
|
query for balance and get the amount of funds available for trading or funds locked in orders
|
1814
|
-
|
2405
|
+
|
2406
|
+
https://www.kucoin.com/docs/rest/funding/funding-overview/get-account-detail-futures
|
2407
|
+
|
1815
2408
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1816
2409
|
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
1817
2410
|
"""
|
@@ -1822,7 +2415,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1822
2415
|
defaultCode = self.safe_string(fetchBalanceOptions, 'code', defaultCode)
|
1823
2416
|
code = self.safe_string(params, 'code', defaultCode)
|
1824
2417
|
currency = self.currency(code)
|
1825
|
-
request = {
|
2418
|
+
request: dict = {
|
1826
2419
|
'currency': currency['id'],
|
1827
2420
|
}
|
1828
2421
|
response = await self.futuresPrivateGetAccountOverview(self.extend(request, params))
|
@@ -1846,6 +2439,10 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1846
2439
|
async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
|
1847
2440
|
"""
|
1848
2441
|
transfer currency internally between wallets on the same account
|
2442
|
+
|
2443
|
+
https://www.kucoin.com/docs/rest/funding/transfer/transfer-to-main-or-trade-account
|
2444
|
+
https://www.kucoin.com/docs/rest/funding/transfer/transfer-to-futures-account
|
2445
|
+
|
1849
2446
|
:param str code: unified currency code
|
1850
2447
|
:param float amount: amount to transfer
|
1851
2448
|
:param str fromAccount: account to transfer from
|
@@ -1853,62 +2450,123 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1853
2450
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1854
2451
|
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
|
1855
2452
|
"""
|
1856
|
-
if (toAccount != 'main' and toAccount != 'funding') or (fromAccount != 'futures' and fromAccount != 'future' and fromAccount != 'contract'):
|
1857
|
-
raise BadRequest(self.id + ' transfer() only supports transfers from contract(future) account to main(funding) account')
|
1858
2453
|
await self.load_markets()
|
1859
2454
|
currency = self.currency(code)
|
1860
2455
|
amountToPrecision = self.currency_to_precision(code, amount)
|
1861
|
-
request = {
|
1862
|
-
'currency': self.safe_string(currency, 'id'),
|
2456
|
+
request: dict = {
|
2457
|
+
'currency': self.safe_string(currency, 'id'),
|
1863
2458
|
'amount': amountToPrecision,
|
1864
2459
|
}
|
1865
|
-
|
1866
|
-
response =
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
2460
|
+
toAccountString = self.parse_transfer_type(toAccount)
|
2461
|
+
response = None
|
2462
|
+
if toAccountString == 'TRADE' or toAccountString == 'MAIN':
|
2463
|
+
request['recAccountType'] = toAccountString
|
2464
|
+
response = await self.futuresPrivatePostTransferOut(self.extend(request, params))
|
2465
|
+
#
|
2466
|
+
# {
|
2467
|
+
# "code": "200000",
|
2468
|
+
# "data": {
|
2469
|
+
# "applyId": "6738754373ceee00011ec3f8",
|
2470
|
+
# "bizNo": "6738754373ceee00011ec3f7",
|
2471
|
+
# "payAccountType": "CONTRACT",
|
2472
|
+
# "payTag": "DEFAULT",
|
2473
|
+
# "remark": "",
|
2474
|
+
# "recAccountType": "MAIN",
|
2475
|
+
# "recTag": "DEFAULT",
|
2476
|
+
# "recRemark": "",
|
2477
|
+
# "recSystem": "KUCOIN",
|
2478
|
+
# "status": "PROCESSING",
|
2479
|
+
# "currency": "USDT",
|
2480
|
+
# "amount": "5",
|
2481
|
+
# "fee": "0",
|
2482
|
+
# "sn": 1519769124846692,
|
2483
|
+
# "reason": "",
|
2484
|
+
# "createdAt": 1731753283000,
|
2485
|
+
# "updatedAt": 1731753283000
|
2486
|
+
# }
|
2487
|
+
# }
|
2488
|
+
#
|
2489
|
+
elif toAccount == 'future' or toAccount == 'swap' or toAccount == 'contract':
|
2490
|
+
request['payAccountType'] = self.parse_transfer_type(fromAccount)
|
2491
|
+
response = await self.futuresPrivatePostTransferIn(self.extend(request, params))
|
2492
|
+
#
|
2493
|
+
# {
|
2494
|
+
# "code": "200000",
|
2495
|
+
# "data": {
|
2496
|
+
# "applyId": "5bffb63303aa675e8bbe18f9" # Transfer-out request ID
|
2497
|
+
# }
|
2498
|
+
# }
|
2499
|
+
#
|
2500
|
+
else:
|
2501
|
+
raise BadRequest(self.id + ' transfer() only supports transfers between future/swap, spot and funding accounts')
|
2502
|
+
data = self.safe_dict(response, 'data', {})
|
1876
2503
|
return self.extend(self.parse_transfer(data, currency), {
|
1877
2504
|
'amount': self.parse_number(amountToPrecision),
|
1878
|
-
'fromAccount':
|
1879
|
-
'toAccount':
|
2505
|
+
'fromAccount': fromAccount,
|
2506
|
+
'toAccount': toAccount,
|
1880
2507
|
})
|
1881
2508
|
|
1882
|
-
def parse_transfer(self, transfer, currency: Currency = None):
|
2509
|
+
def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
|
1883
2510
|
#
|
1884
|
-
# transfer
|
2511
|
+
# transfer to spot or funding account
|
1885
2512
|
#
|
1886
2513
|
# {
|
1887
2514
|
# "applyId": "5bffb63303aa675e8bbe18f9" # Transfer-out request ID
|
1888
2515
|
# }
|
1889
2516
|
#
|
2517
|
+
# transfer to future account
|
2518
|
+
#
|
2519
|
+
# {
|
2520
|
+
# "applyId": "6738754373ceee00011ec3f8",
|
2521
|
+
# "bizNo": "6738754373ceee00011ec3f7",
|
2522
|
+
# "payAccountType": "CONTRACT",
|
2523
|
+
# "payTag": "DEFAULT",
|
2524
|
+
# "remark": "",
|
2525
|
+
# "recAccountType": "MAIN",
|
2526
|
+
# "recTag": "DEFAULT",
|
2527
|
+
# "recRemark": "",
|
2528
|
+
# "recSystem": "KUCOIN",
|
2529
|
+
# "status": "PROCESSING",
|
2530
|
+
# "currency": "USDT",
|
2531
|
+
# "amount": "5",
|
2532
|
+
# "fee": "0",
|
2533
|
+
# "sn": 1519769124846692,
|
2534
|
+
# "reason": "",
|
2535
|
+
# "createdAt": 1731753283000,
|
2536
|
+
# "updatedAt": 1731753283000
|
2537
|
+
# }
|
2538
|
+
#
|
1890
2539
|
timestamp = self.safe_integer(transfer, 'updatedAt')
|
1891
2540
|
return {
|
1892
2541
|
'id': self.safe_string(transfer, 'applyId'),
|
1893
2542
|
'timestamp': timestamp,
|
1894
2543
|
'datetime': self.iso8601(timestamp),
|
1895
2544
|
'currency': self.safe_currency_code(None, currency),
|
1896
|
-
'amount':
|
2545
|
+
'amount': self.safe_number(transfer, 'amount'),
|
1897
2546
|
'fromAccount': None,
|
1898
2547
|
'toAccount': None,
|
1899
2548
|
'status': self.safe_string(transfer, 'status'),
|
1900
2549
|
'info': transfer,
|
1901
2550
|
}
|
1902
2551
|
|
1903
|
-
def parse_transfer_status(self, status):
|
1904
|
-
statuses = {
|
2552
|
+
def parse_transfer_status(self, status: Str) -> Str:
|
2553
|
+
statuses: dict = {
|
1905
2554
|
'PROCESSING': 'pending',
|
1906
2555
|
}
|
1907
2556
|
return self.safe_string(statuses, status, status)
|
1908
2557
|
|
2558
|
+
def parse_transfer_type(self, transferType: Str) -> Str:
|
2559
|
+
transferTypes: dict = {
|
2560
|
+
'spot': 'TRADE',
|
2561
|
+
'funding': 'MAIN',
|
2562
|
+
}
|
2563
|
+
return self.safe_string_upper(transferTypes, transferType, transferType)
|
2564
|
+
|
1909
2565
|
async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
1910
2566
|
"""
|
1911
|
-
|
2567
|
+
|
2568
|
+
https://docs.kucoin.com/futures/#get-fills
|
2569
|
+
|
1912
2570
|
fetch all trades made by the user
|
1913
2571
|
:param str symbol: unified market symbol
|
1914
2572
|
:param int [since]: the earliest time in ms to fetch trades for
|
@@ -1923,13 +2581,13 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1923
2581
|
paginate, params = self.handle_option_and_params(params, 'fetchMyTrades', 'paginate')
|
1924
2582
|
if paginate:
|
1925
2583
|
return await self.fetch_paginated_call_dynamic('fetchMyTrades', symbol, since, limit, params)
|
1926
|
-
request = {
|
2584
|
+
request: dict = {
|
1927
2585
|
# orderId(str) [optional] Fills for a specific order(other parameters can be ignored if specified)
|
1928
2586
|
# symbol(str) [optional] Symbol of the contract
|
1929
2587
|
# side(str) [optional] buy or sell
|
1930
2588
|
# type(str) [optional] limit, market, limit_stop or market_stop
|
1931
|
-
# startAt(long) [optional] Start time(
|
1932
|
-
# endAt(long) [optional] End time(
|
2589
|
+
# startAt(long) [optional] Start time(millisecond)
|
2590
|
+
# endAt(long) [optional] End time(millisecond)
|
1933
2591
|
}
|
1934
2592
|
market = None
|
1935
2593
|
if symbol is not None:
|
@@ -1937,6 +2595,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1937
2595
|
request['symbol'] = market['id']
|
1938
2596
|
if since is not None:
|
1939
2597
|
request['startAt'] = since
|
2598
|
+
if limit is not None:
|
2599
|
+
request['pageSize'] = min(1000, limit)
|
1940
2600
|
request, params = self.handle_until_option('endAt', request, params)
|
1941
2601
|
response = await self.futuresPrivateGetFills(self.extend(request, params))
|
1942
2602
|
#
|
@@ -1979,7 +2639,9 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1979
2639
|
async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
1980
2640
|
"""
|
1981
2641
|
get the list of most recent trades for a particular symbol
|
1982
|
-
|
2642
|
+
|
2643
|
+
https://www.kucoin.com/docs/rest/futures-trading/market-data/get-transaction-history
|
2644
|
+
|
1983
2645
|
:param str symbol: unified symbol of the market to fetch trades for
|
1984
2646
|
:param int [since]: timestamp in ms of the earliest trade to fetch
|
1985
2647
|
:param int [limit]: the maximum amount of trades to fetch
|
@@ -1988,7 +2650,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1988
2650
|
"""
|
1989
2651
|
await self.load_markets()
|
1990
2652
|
market = self.market(symbol)
|
1991
|
-
request = {
|
2653
|
+
request: dict = {
|
1992
2654
|
'symbol': market['id'],
|
1993
2655
|
}
|
1994
2656
|
response = await self.futuresPublicGetTradeHistory(self.extend(request, params))
|
@@ -2009,10 +2671,10 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2009
2671
|
# ]
|
2010
2672
|
# }
|
2011
2673
|
#
|
2012
|
-
trades = self.
|
2674
|
+
trades = self.safe_list(response, 'data', [])
|
2013
2675
|
return self.parse_trades(trades, market, since, limit)
|
2014
2676
|
|
2015
|
-
def parse_trade(self, trade, market: Market = None) -> Trade:
|
2677
|
+
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
2016
2678
|
#
|
2017
2679
|
# fetchTrades(public)
|
2018
2680
|
#
|
@@ -2150,7 +2812,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2150
2812
|
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
|
2151
2813
|
"""
|
2152
2814
|
await self.load_markets()
|
2153
|
-
request = {}
|
2815
|
+
request: dict = {}
|
2154
2816
|
currency = None
|
2155
2817
|
if code is not None:
|
2156
2818
|
currency = self.currency(code)
|
@@ -2200,7 +2862,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2200
2862
|
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
|
2201
2863
|
"""
|
2202
2864
|
await self.load_markets()
|
2203
|
-
request = {}
|
2865
|
+
request: dict = {}
|
2204
2866
|
currency = None
|
2205
2867
|
if code is not None:
|
2206
2868
|
currency = self.currency(code)
|
@@ -2240,10 +2902,12 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2240
2902
|
responseData = response['data']['items']
|
2241
2903
|
return self.parse_transactions(responseData, currency, since, limit, {'type': 'withdrawal'})
|
2242
2904
|
|
2243
|
-
async def fetch_market_leverage_tiers(self, symbol: str, params={}):
|
2905
|
+
async def fetch_market_leverage_tiers(self, symbol: str, params={}) -> List[LeverageTier]:
|
2244
2906
|
"""
|
2245
2907
|
retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market
|
2246
|
-
|
2908
|
+
|
2909
|
+
https://www.kucoin.com/docs/rest/futures-trading/risk-limit/get-futures-risk-limit-level
|
2910
|
+
|
2247
2911
|
:param str symbol: unified market symbol
|
2248
2912
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2249
2913
|
:returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
|
@@ -2252,7 +2916,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2252
2916
|
market = self.market(symbol)
|
2253
2917
|
if not market['contract']:
|
2254
2918
|
raise BadRequest(self.id + ' fetchMarketLeverageTiers() supports contract markets only')
|
2255
|
-
request = {
|
2919
|
+
request: dict = {
|
2256
2920
|
'symbol': market['id'],
|
2257
2921
|
}
|
2258
2922
|
response = await self.futuresPublicGetContractsRiskLimitSymbol(self.extend(request, params))
|
@@ -2276,9 +2940,9 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2276
2940
|
data = self.safe_value(response, 'data')
|
2277
2941
|
return self.parse_market_leverage_tiers(data, market)
|
2278
2942
|
|
2279
|
-
def parse_market_leverage_tiers(self, info, market: Market = None):
|
2943
|
+
def parse_market_leverage_tiers(self, info, market: Market = None) -> List[LeverageTier]:
|
2280
2944
|
"""
|
2281
|
-
|
2945
|
+
@ignore
|
2282
2946
|
:param dict info: Exchange market response for 1 market
|
2283
2947
|
:param dict market: CCXT market
|
2284
2948
|
"""
|
@@ -2296,8 +2960,10 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2296
2960
|
tiers = []
|
2297
2961
|
for i in range(0, len(info)):
|
2298
2962
|
tier = info[i]
|
2963
|
+
marketId = self.safe_string(tier, 'symbol')
|
2299
2964
|
tiers.append({
|
2300
2965
|
'tier': self.safe_number(tier, 'level'),
|
2966
|
+
'symbol': self.safe_symbol(marketId, market, None, 'contract'),
|
2301
2967
|
'currency': market['base'],
|
2302
2968
|
'minNotional': self.safe_number(tier, 'minRiskLimit'),
|
2303
2969
|
'maxNotional': self.safe_number(tier, 'maxRiskLimit'),
|
@@ -2309,7 +2975,9 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2309
2975
|
|
2310
2976
|
async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2311
2977
|
"""
|
2312
|
-
|
2978
|
+
|
2979
|
+
https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-public-funding-history#request-url
|
2980
|
+
|
2313
2981
|
fetches historical funding rate prices
|
2314
2982
|
:param str symbol: unified symbol of the market to fetch the funding rate history for
|
2315
2983
|
:param int [since]: not used by kucuoinfutures
|
@@ -2322,13 +2990,13 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2322
2990
|
raise ArgumentsRequired(self.id + ' fetchFundingRateHistory() requires a symbol argument')
|
2323
2991
|
await self.load_markets()
|
2324
2992
|
market = self.market(symbol)
|
2325
|
-
request = {
|
2993
|
+
request: dict = {
|
2326
2994
|
'symbol': market['id'],
|
2327
2995
|
'from': 0,
|
2328
2996
|
'to': self.milliseconds(),
|
2329
2997
|
}
|
2330
|
-
until = self.
|
2331
|
-
params = self.omit(params, ['until'
|
2998
|
+
until = self.safe_integer(params, 'until')
|
2999
|
+
params = self.omit(params, ['until'])
|
2332
3000
|
if since is not None:
|
2333
3001
|
request['from'] = since
|
2334
3002
|
if until is None:
|
@@ -2367,7 +3035,9 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2367
3035
|
async def close_position(self, symbol: str, side: OrderSide = None, params={}) -> Order:
|
2368
3036
|
"""
|
2369
3037
|
closes open positions for a market
|
2370
|
-
|
3038
|
+
|
3039
|
+
https://www.kucoin.com/docs/rest/futures-trading/orders/place-order
|
3040
|
+
|
2371
3041
|
:param str symbol: Unified CCXT market symbol
|
2372
3042
|
:param str side: not used by kucoinfutures closePositions
|
2373
3043
|
:param dict [params]: extra parameters specific to the okx api endpoint
|
@@ -2381,7 +3051,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2381
3051
|
params = self.omit(params, ['test', 'clientOrderId'])
|
2382
3052
|
if clientOrderId is None:
|
2383
3053
|
clientOrderId = self.number_to_string(self.nonce())
|
2384
|
-
request = {
|
3054
|
+
request: dict = {
|
2385
3055
|
'symbol': market['id'],
|
2386
3056
|
'closeOrder': True,
|
2387
3057
|
'clientOid': clientOrderId,
|
@@ -2393,3 +3063,188 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2393
3063
|
else:
|
2394
3064
|
response = await self.futuresPrivatePostOrders(self.extend(request, params))
|
2395
3065
|
return self.parse_order(response, market)
|
3066
|
+
|
3067
|
+
async def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
|
3068
|
+
"""
|
3069
|
+
fetch the trading fees for a market
|
3070
|
+
|
3071
|
+
https://www.kucoin.com/docs/rest/funding/trade-fee/trading-pair-actual-fee-futures
|
3072
|
+
|
3073
|
+
:param str symbol: unified market symbol
|
3074
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3075
|
+
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
|
3076
|
+
"""
|
3077
|
+
await self.load_markets()
|
3078
|
+
market = self.market(symbol)
|
3079
|
+
request: dict = {
|
3080
|
+
'symbols': market['id'],
|
3081
|
+
}
|
3082
|
+
response = await self.privateGetTradeFees(self.extend(request, params))
|
3083
|
+
#
|
3084
|
+
# {
|
3085
|
+
# "code": "200000",
|
3086
|
+
# "data": {
|
3087
|
+
# "symbol": "XBTUSDTM",
|
3088
|
+
# "takerFeeRate": "0.0006",
|
3089
|
+
# "makerFeeRate": "0.0002"
|
3090
|
+
# }
|
3091
|
+
# }
|
3092
|
+
#
|
3093
|
+
data = self.safe_list(response, 'data', [])
|
3094
|
+
first = self.safe_dict(data, 0)
|
3095
|
+
marketId = self.safe_string(first, 'symbol')
|
3096
|
+
return {
|
3097
|
+
'info': response,
|
3098
|
+
'symbol': self.safe_symbol(marketId, market),
|
3099
|
+
'maker': self.safe_number(first, 'makerFeeRate'),
|
3100
|
+
'taker': self.safe_number(first, 'takerFeeRate'),
|
3101
|
+
'percentage': True,
|
3102
|
+
'tierBased': True,
|
3103
|
+
}
|
3104
|
+
|
3105
|
+
async def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
|
3106
|
+
"""
|
3107
|
+
fetches the margin mode of a trading pair
|
3108
|
+
|
3109
|
+
https://www.kucoin.com/docs/rest/futures-trading/positions/get-margin-mode
|
3110
|
+
|
3111
|
+
:param str symbol: unified symbol of the market to fetch the margin mode for
|
3112
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3113
|
+
:returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
|
3114
|
+
"""
|
3115
|
+
await self.load_markets()
|
3116
|
+
market = self.market(symbol)
|
3117
|
+
request: dict = {
|
3118
|
+
'symbol': market['id'],
|
3119
|
+
}
|
3120
|
+
response = await self.futuresPrivateGetPositionGetMarginMode(self.extend(request, params))
|
3121
|
+
#
|
3122
|
+
# {
|
3123
|
+
# "code": "200000",
|
3124
|
+
# "data": {
|
3125
|
+
# "symbol": "XBTUSDTM",
|
3126
|
+
# "marginMode": "ISOLATED"
|
3127
|
+
# }
|
3128
|
+
# }
|
3129
|
+
#
|
3130
|
+
data = self.safe_dict(response, 'data', {})
|
3131
|
+
return self.parse_margin_mode(data, market)
|
3132
|
+
|
3133
|
+
def parse_margin_mode(self, marginMode: dict, market=None) -> MarginMode:
|
3134
|
+
marginType = self.safe_string(marginMode, 'marginMode')
|
3135
|
+
marginType = 'isolated' if (marginType == 'ISOLATED') else 'cross'
|
3136
|
+
return {
|
3137
|
+
'info': marginMode,
|
3138
|
+
'symbol': market['symbol'],
|
3139
|
+
'marginMode': marginType,
|
3140
|
+
}
|
3141
|
+
|
3142
|
+
async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
|
3143
|
+
"""
|
3144
|
+
set margin mode to 'cross' or 'isolated'
|
3145
|
+
|
3146
|
+
https://www.kucoin.com/docs/rest/futures-trading/positions/modify-margin-mode
|
3147
|
+
|
3148
|
+
:param str marginMode: 'cross' or 'isolated'
|
3149
|
+
:param str symbol: unified market symbol
|
3150
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3151
|
+
:returns dict: response from the exchange
|
3152
|
+
"""
|
3153
|
+
if symbol is None:
|
3154
|
+
raise ArgumentsRequired(self.id + ' setMarginMode() requires a symbol argument')
|
3155
|
+
self.check_required_argument('setMarginMode', marginMode, 'marginMode', ['cross', 'isolated'])
|
3156
|
+
await self.load_markets()
|
3157
|
+
market = self.market(symbol)
|
3158
|
+
request: dict = {
|
3159
|
+
'symbol': market['id'],
|
3160
|
+
'marginMode': marginMode.upper(),
|
3161
|
+
}
|
3162
|
+
response = await self.futuresPrivatePostPositionChangeMarginMode(self.extend(request, params))
|
3163
|
+
#
|
3164
|
+
# {
|
3165
|
+
# "code": "200000",
|
3166
|
+
# "data": {
|
3167
|
+
# "symbol": "XBTUSDTM",
|
3168
|
+
# "marginMode": "ISOLATED"
|
3169
|
+
# }
|
3170
|
+
# }
|
3171
|
+
#
|
3172
|
+
data = self.safe_dict(response, 'data', {})
|
3173
|
+
return self.parse_margin_mode(data, market)
|
3174
|
+
|
3175
|
+
async def fetch_leverage(self, symbol: str, params={}) -> Leverage:
|
3176
|
+
"""
|
3177
|
+
fetch the set leverage for a market
|
3178
|
+
|
3179
|
+
https://www.kucoin.com/docs/rest/futures-trading/positions/get-cross-margin-leverage
|
3180
|
+
|
3181
|
+
:param str symbol: unified market symbol
|
3182
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3183
|
+
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
|
3184
|
+
"""
|
3185
|
+
marginMode = None
|
3186
|
+
marginMode, params = self.handle_margin_mode_and_params(symbol, params)
|
3187
|
+
if marginMode != 'cross':
|
3188
|
+
raise NotSupported(self.id + ' fetchLeverage() currently supports only params["marginMode"] = "cross"')
|
3189
|
+
await self.load_markets()
|
3190
|
+
market = self.market(symbol)
|
3191
|
+
request: dict = {
|
3192
|
+
'symbol': market['id'],
|
3193
|
+
}
|
3194
|
+
response = await self.futuresPrivateGetGetCrossUserLeverage(self.extend(request, params))
|
3195
|
+
#
|
3196
|
+
# {
|
3197
|
+
# "code": "200000",
|
3198
|
+
# "data": {
|
3199
|
+
# "symbol": "XBTUSDTM",
|
3200
|
+
# "leverage": "3"
|
3201
|
+
# }
|
3202
|
+
# }
|
3203
|
+
#
|
3204
|
+
data = self.safe_dict(response, 'data', {})
|
3205
|
+
parsed = self.parse_leverage(data, market)
|
3206
|
+
return self.extend(parsed, {
|
3207
|
+
'marginMode': marginMode,
|
3208
|
+
})
|
3209
|
+
|
3210
|
+
async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
|
3211
|
+
"""
|
3212
|
+
set the level of leverage for a market
|
3213
|
+
|
3214
|
+
https://www.kucoin.com/docs/rest/futures-trading/positions/modify-cross-margin-leverage
|
3215
|
+
|
3216
|
+
:param float leverage: the rate of leverage
|
3217
|
+
:param str symbol: unified market symbol
|
3218
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3219
|
+
:returns dict: response from the exchange
|
3220
|
+
"""
|
3221
|
+
marginMode = None
|
3222
|
+
marginMode, params = self.handle_margin_mode_and_params(symbol, params)
|
3223
|
+
if marginMode != 'cross':
|
3224
|
+
raise NotSupported(self.id + ' setLeverage() currently supports only params["marginMode"] = "cross"')
|
3225
|
+
await self.load_markets()
|
3226
|
+
market = self.market(symbol)
|
3227
|
+
request: dict = {
|
3228
|
+
'symbol': market['id'],
|
3229
|
+
'leverage': str(leverage),
|
3230
|
+
}
|
3231
|
+
response = await self.futuresPrivatePostChangeCrossUserLeverage(self.extend(request, params))
|
3232
|
+
#
|
3233
|
+
# {
|
3234
|
+
# "code": "200000",
|
3235
|
+
# "data": True
|
3236
|
+
# }
|
3237
|
+
#
|
3238
|
+
return self.parse_leverage(response, market)
|
3239
|
+
|
3240
|
+
def parse_leverage(self, leverage: dict, market: Market = None) -> Leverage:
|
3241
|
+
marketId = self.safe_string(leverage, 'symbol')
|
3242
|
+
market = self.safe_market(marketId, market)
|
3243
|
+
leverageNum = self.safe_integer(leverage, 'leverage')
|
3244
|
+
return {
|
3245
|
+
'info': leverage,
|
3246
|
+
'symbol': market['symbol'],
|
3247
|
+
'marginMode': None,
|
3248
|
+
'longLeverage': leverageNum,
|
3249
|
+
'shortLeverage': leverageNum,
|
3250
|
+
}
|