ccxt 4.2.77__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 +24 -0
- ccxt/abstract/kucoinfutures.py +34 -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 +3030 -1087
- 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 +3104 -880
- 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 +238 -49
- ccxt/async_support/bitget.py +1513 -563
- ccxt/async_support/bithumb.py +199 -65
- 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 +392 -148
- 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 +2231 -1193
- ccxt/async_support/cex.py +1409 -1329
- ccxt/async_support/coinbase.py +1454 -287
- 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 +404 -109
- ccxt/async_support/deribit.py +557 -323
- 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 +1472 -463
- 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 +1633 -268
- 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 +917 -357
- 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 +1776 -454
- 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 +1137 -296
- 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 +1722 -480
- 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 +3030 -1087
- ccxt/binancecoinm.py +2 -1
- ccxt/binanceus.py +12 -1
- ccxt/binanceusdm.py +3 -1
- ccxt/bingx.py +3104 -880
- 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 +238 -49
- ccxt/bitget.py +1513 -563
- ccxt/bithumb.py +198 -65
- 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 +392 -148
- ccxt/btcalpha.py +161 -55
- ccxt/btcbox.py +250 -34
- ccxt/btcmarkets.py +232 -85
- ccxt/btcturk.py +159 -60
- ccxt/bybit.py +2231 -1193
- ccxt/cex.py +1408 -1329
- ccxt/coinbase.py +1454 -287
- 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 +404 -109
- ccxt/deribit.py +557 -323
- ccxt/digifinex.py +340 -223
- ccxt/ellipx.py +1826 -0
- ccxt/exmo.py +259 -128
- ccxt/gate.py +1472 -463
- 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 +1632 -268
- 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 +917 -357
- 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 +1776 -454
- 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 +62 -14
- 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 +203 -81
- 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 +965 -665
- 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 +167 -31
- ccxt/pro/exmo.py +252 -20
- 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 +92 -33
- ccxt/pro/poloniex.py +128 -49
- ccxt/pro/poloniexfutures.py +53 -32
- ccxt/pro/probit.py +92 -85
- 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 +437 -65
- 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} +456 -391
- ccxt/test/tests_helpers.py +285 -0
- ccxt/test/tests_init.py +39 -0
- ccxt/test/{test_sync.py → tests_sync.py} +456 -393
- 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 +1137 -296
- 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.77.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.77.dist-info/METADATA +0 -626
- ccxt-4.2.77.dist-info/RECORD +0 -534
- {ccxt-4.2.77.dist-info → ccxt-4.4.48.dist-info}/top_level.txt +0 -0
ccxt/async_support/bitget.py
CHANGED
@@ -8,9 +8,10 @@ from ccxt.abstract.bitget import ImplicitAPI
|
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
10
|
import json
|
11
|
-
from ccxt.base.types import Balances, Currency, FundingHistory, Int, Leverage, Liquidation, MarginMode, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
11
|
+
from ccxt.base.types import Balances, BorrowInterest, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, FundingHistory, Int, IsolatedBorrowRate, LedgerEntry, Leverage, LeverageTier, Liquidation, LongShortRatio, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
14
|
+
from ccxt.base.errors import AuthenticationError
|
14
15
|
from ccxt.base.errors import PermissionDenied
|
15
16
|
from ccxt.base.errors import AccountSuspended
|
16
17
|
from ccxt.base.errors import ArgumentsRequired
|
@@ -20,7 +21,6 @@ from ccxt.base.errors import InsufficientFunds
|
|
20
21
|
from ccxt.base.errors import InvalidAddress
|
21
22
|
from ccxt.base.errors import InvalidOrder
|
22
23
|
from ccxt.base.errors import OrderNotFound
|
23
|
-
from ccxt.base.errors import CancelPending
|
24
24
|
from ccxt.base.errors import NotSupported
|
25
25
|
from ccxt.base.errors import DDoSProtection
|
26
26
|
from ccxt.base.errors import RateLimitExceeded
|
@@ -28,7 +28,7 @@ from ccxt.base.errors import ExchangeNotAvailable
|
|
28
28
|
from ccxt.base.errors import OnMaintenance
|
29
29
|
from ccxt.base.errors import InvalidNonce
|
30
30
|
from ccxt.base.errors import RequestTimeout
|
31
|
-
from ccxt.base.errors import
|
31
|
+
from ccxt.base.errors import CancelPending
|
32
32
|
from ccxt.base.decimal_to_precision import TICK_SIZE
|
33
33
|
from ccxt.base.precise import Precise
|
34
34
|
|
@@ -59,6 +59,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
59
59
|
'cancelOrders': True,
|
60
60
|
'closeAllPositions': True,
|
61
61
|
'closePosition': True,
|
62
|
+
'createConvertTrade': True,
|
62
63
|
'createDepositAddress': False,
|
63
64
|
'createMarketBuyOrderWithCost': True,
|
64
65
|
'createMarketOrderWithCost': False,
|
@@ -85,20 +86,27 @@ class bitget(Exchange, ImplicitAPI):
|
|
85
86
|
'fetchCanceledAndClosedOrders': True,
|
86
87
|
'fetchCanceledOrders': True,
|
87
88
|
'fetchClosedOrders': True,
|
89
|
+
'fetchConvertCurrencies': True,
|
90
|
+
'fetchConvertQuote': True,
|
91
|
+
'fetchConvertTrade': False,
|
92
|
+
'fetchConvertTradeHistory': True,
|
88
93
|
'fetchCrossBorrowRate': True,
|
89
94
|
'fetchCrossBorrowRates': False,
|
90
95
|
'fetchCurrencies': True,
|
91
96
|
'fetchDeposit': False,
|
92
97
|
'fetchDepositAddress': True,
|
93
98
|
'fetchDepositAddresses': False,
|
99
|
+
'fetchDepositAddressesByNetwork': False,
|
94
100
|
'fetchDeposits': True,
|
95
101
|
'fetchDepositsWithdrawals': False,
|
96
102
|
'fetchDepositWithdrawFee': 'emulated',
|
97
103
|
'fetchDepositWithdrawFees': True,
|
98
104
|
'fetchFundingHistory': True,
|
105
|
+
'fetchFundingInterval': True,
|
106
|
+
'fetchFundingIntervals': False,
|
99
107
|
'fetchFundingRate': True,
|
100
108
|
'fetchFundingRateHistory': True,
|
101
|
-
'fetchFundingRates':
|
109
|
+
'fetchFundingRates': True,
|
102
110
|
'fetchIndexOHLCV': True,
|
103
111
|
'fetchIsolatedBorrowRate': True,
|
104
112
|
'fetchIsolatedBorrowRates': False,
|
@@ -106,10 +114,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
106
114
|
'fetchLeverage': True,
|
107
115
|
'fetchLeverageTiers': False,
|
108
116
|
'fetchLiquidations': False,
|
117
|
+
'fetchLongShortRatio': False,
|
118
|
+
'fetchLongShortRatioHistory': True,
|
119
|
+
'fetchMarginAdjustmentHistory': False,
|
109
120
|
'fetchMarginMode': True,
|
110
121
|
'fetchMarketLeverageTiers': True,
|
111
122
|
'fetchMarkets': True,
|
112
123
|
'fetchMarkOHLCV': True,
|
124
|
+
'fetchMarkPrice': True,
|
113
125
|
'fetchMyLiquidations': True,
|
114
126
|
'fetchMyTrades': True,
|
115
127
|
'fetchOHLCV': True,
|
@@ -122,8 +134,10 @@ class bitget(Exchange, ImplicitAPI):
|
|
122
134
|
'fetchOrders': False,
|
123
135
|
'fetchOrderTrades': False,
|
124
136
|
'fetchPosition': True,
|
137
|
+
'fetchPositionHistory': 'emulated',
|
125
138
|
'fetchPositionMode': False,
|
126
139
|
'fetchPositions': True,
|
140
|
+
'fetchPositionsHistory': True,
|
127
141
|
'fetchPositionsRisk': False,
|
128
142
|
'fetchPremiumIndexOHLCV': False,
|
129
143
|
'fetchStatus': False,
|
@@ -168,7 +182,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
168
182
|
},
|
169
183
|
'hostname': 'bitget.com',
|
170
184
|
'urls': {
|
171
|
-
'logo': 'https://
|
185
|
+
'logo': 'https://github.com/user-attachments/assets/fbaa10cc-a277-441d-a5b7-997dd9a87658',
|
172
186
|
'api': {
|
173
187
|
'spot': 'https://api.{hostname}',
|
174
188
|
'mix': 'https://api.{hostname}',
|
@@ -277,6 +291,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
277
291
|
'v2/mix/market/current-fund-rate': 1,
|
278
292
|
'v2/mix/market/contracts': 1,
|
279
293
|
'v2/mix/market/query-position-lever': 2,
|
294
|
+
'v2/mix/market/account-long-short': 20,
|
280
295
|
},
|
281
296
|
},
|
282
297
|
'margin': {
|
@@ -287,6 +302,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
287
302
|
'margin/v1/isolated/public/tierData': 2, # 10 times/1s(IP) => 20/10 = 2
|
288
303
|
'margin/v1/public/currencies': 1, # 20 times/1s(IP) => 20/20 = 1
|
289
304
|
'v2/margin/currencies': 2,
|
305
|
+
'v2/margin/market/long-short-ratio': 20,
|
290
306
|
},
|
291
307
|
},
|
292
308
|
'earn': {
|
@@ -324,6 +340,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
324
340
|
'v2/spot/account/subaccount-assets': 2,
|
325
341
|
'v2/spot/account/bills': 2,
|
326
342
|
'v2/spot/account/transferRecords': 1,
|
343
|
+
'v2/account/funding-assets': 2,
|
344
|
+
'v2/account/bot-assets': 2,
|
345
|
+
'v2/account/all-account-balance': 20,
|
327
346
|
'v2/spot/wallet/deposit-address': 2,
|
328
347
|
'v2/spot/wallet/deposit-records': 2,
|
329
348
|
'v2/spot/wallet/withdrawal-records': 2,
|
@@ -446,6 +465,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
446
465
|
'v2/mix/order/orders-history': 2,
|
447
466
|
'v2/mix/order/orders-plan-pending': 2,
|
448
467
|
'v2/mix/order/orders-plan-history': 2,
|
468
|
+
'v2/mix/market/position-long-short': 20,
|
449
469
|
},
|
450
470
|
'post': {
|
451
471
|
'mix/v1/account/sub-account-contract-assets': 200, # 0.1 times/1s(UID) => 20/0.1 = 200
|
@@ -494,7 +514,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
494
514
|
'v2/mix/account/set-margin': 4,
|
495
515
|
'v2/mix/account/set-margin-mode': 4,
|
496
516
|
'v2/mix/account/set-position-mode': 4,
|
497
|
-
'v2/mix/order/place-order':
|
517
|
+
'v2/mix/order/place-order': 2,
|
498
518
|
'v2/mix/order/click-backhand': 20,
|
499
519
|
'v2/mix/order/batch-place-order': 20,
|
500
520
|
'v2/mix/order/modify-order': 2,
|
@@ -768,6 +788,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
768
788
|
'v2/earn/loan/borrow-history': 2,
|
769
789
|
'v2/earn/loan/debts': 2,
|
770
790
|
'v2/earn/loan/reduces': 2,
|
791
|
+
'v2/earn/account/assets': 2,
|
771
792
|
},
|
772
793
|
'post': {
|
773
794
|
'v2/earn/savings/subscribe': 2,
|
@@ -1238,9 +1259,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
1238
1259
|
'40712': InsufficientFunds, # Insufficient margin
|
1239
1260
|
'40713': ExchangeError, # Cannot exceed the maximum transferable margin amount
|
1240
1261
|
'40714': ExchangeError, # No direct margin call is allowed
|
1241
|
-
'
|
1262
|
+
'40762': InsufficientFunds, # {"code":"40762","msg":"The order amount exceeds the balance","requestTime":1716572156622,"data":null}
|
1263
|
+
'40768': OrderNotFound, # Order does not exist
|
1264
|
+
'40808': InvalidOrder, # {"code":"40808","msg":"Parameter verification exception size checkBDScale error value=2293.577 checkScale=2","requestTime":1725638500052,"data":null}
|
1265
|
+
'41103': InvalidOrder, # {"code":"41103","msg":"param price scale error error","requestTime":1725635883561,"data":null}
|
1242
1266
|
'41114': OnMaintenance, # {"code":"41114","msg":"The current trading pair is under maintenance, please refer to the official announcement for the opening time","requestTime":1679196062544,"data":null}
|
1243
1267
|
'43011': InvalidOrder, # The parameter does not meet the specification executePrice <= 0
|
1268
|
+
'43001': OrderNotFound,
|
1269
|
+
'43012': InsufficientFunds, # {"code":"43012","msg":"Insufficient balance","requestTime":1711648951774,"data":null}
|
1244
1270
|
'43025': InvalidOrder, # Plan order does not exist
|
1245
1271
|
'43115': OnMaintenance, # {"code":"43115","msg":"The current trading pair is opening soon, please refer to the official announcement for the opening time","requestTime":1688907202434,"data":null}
|
1246
1272
|
'45110': InvalidOrder, # {"code":"45110","msg":"less than the minimum amount 5 USDT","requestTime":1669911118932,"data":null}
|
@@ -1314,9 +1340,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
1314
1340
|
},
|
1315
1341
|
'precisionMode': TICK_SIZE,
|
1316
1342
|
'commonCurrencies': {
|
1343
|
+
'APX': 'AstroPepeX',
|
1344
|
+
'DEGEN': 'DegenReborn',
|
1317
1345
|
'JADE': 'Jade Protocol',
|
1346
|
+
'OMNI': 'omni', # conflict with Omni Network
|
1347
|
+
'TONCOIN': 'TON',
|
1318
1348
|
},
|
1319
1349
|
'options': {
|
1350
|
+
'timeDifference': 0, # the difference between system clock and Binance clock
|
1351
|
+
'adjustForTimeDifference': False, # controls the adjustment logic upon instantiation
|
1320
1352
|
'timeframes': {
|
1321
1353
|
'spot': {
|
1322
1354
|
'1m': '1min',
|
@@ -1413,19 +1445,243 @@ class bitget(Exchange, ImplicitAPI):
|
|
1413
1445
|
},
|
1414
1446
|
'sandboxMode': False,
|
1415
1447
|
'networks': {
|
1416
|
-
'TRX': '
|
1417
|
-
'
|
1448
|
+
# 'TRX': 'TRX', # different code for mainnet
|
1449
|
+
'TRC20': 'TRC20',
|
1450
|
+
# 'ETH': 'ETH', # different code for mainnet
|
1451
|
+
'ERC20': 'ERC20',
|
1452
|
+
'BEP20': 'BSC',
|
1453
|
+
# 'BEP20': 'BEP20', # different for BEP20
|
1418
1454
|
'BSC': 'BEP20',
|
1455
|
+
'ATOM': 'ATOM',
|
1456
|
+
'ACA': 'AcalaToken',
|
1457
|
+
'APT': 'Aptos',
|
1458
|
+
'ARBONE': 'ArbitrumOne',
|
1459
|
+
'ARBNOVA': 'ArbitrumNova',
|
1460
|
+
'AVAXC': 'C-Chain',
|
1461
|
+
'AVAXX': 'X-Chain',
|
1462
|
+
'AR': 'Arweave',
|
1463
|
+
'BCH': 'BCH',
|
1464
|
+
'BCHA': 'BCHA',
|
1465
|
+
'BITCI': 'BITCI',
|
1466
|
+
'BTC': 'BTC',
|
1467
|
+
'CELO': 'CELO',
|
1468
|
+
'CSPR': 'CSPR',
|
1469
|
+
'ADA': 'Cardano',
|
1470
|
+
'CHZ': 'ChilizChain',
|
1471
|
+
'CRC20': 'CronosChain',
|
1472
|
+
'DOGE': 'DOGE',
|
1473
|
+
'DOT': 'DOT',
|
1474
|
+
'EOS': 'EOS',
|
1475
|
+
'ETHF': 'ETHFAIR',
|
1476
|
+
'ETHW': 'ETHW',
|
1477
|
+
'ETC': 'ETC',
|
1478
|
+
'EGLD': 'Elrond',
|
1479
|
+
'FIL': 'FIL',
|
1480
|
+
'FIO': 'FIO',
|
1481
|
+
'FTM': 'Fantom',
|
1482
|
+
'HRC20': 'HECO',
|
1483
|
+
'ONE': 'Harmony',
|
1484
|
+
'HNT': 'Helium',
|
1485
|
+
'ICP': 'ICP',
|
1486
|
+
'IOTX': 'IoTeX',
|
1487
|
+
'KARDIA': 'KAI',
|
1488
|
+
'KAVA': 'KAVA',
|
1489
|
+
'KDA': 'KDA',
|
1490
|
+
'KLAY': 'Klaytn',
|
1491
|
+
'KSM': 'Kusama',
|
1492
|
+
'LAT': 'LAT',
|
1493
|
+
'LTC': 'LTC',
|
1494
|
+
'MINA': 'MINA',
|
1495
|
+
'MOVR': 'MOVR',
|
1496
|
+
'METIS': 'MetisToken',
|
1497
|
+
'GLMR': 'Moonbeam',
|
1498
|
+
'NEAR': 'NEARProtocol',
|
1499
|
+
'NULS': 'NULS',
|
1500
|
+
'OASYS': 'OASYS',
|
1501
|
+
'OASIS': 'ROSE',
|
1502
|
+
'OMNI': 'OMNI',
|
1503
|
+
'ONT': 'Ontology',
|
1504
|
+
'OPTIMISM': 'Optimism',
|
1505
|
+
'OSMO': 'Osmosis',
|
1506
|
+
'POKT': 'PocketNetwork',
|
1507
|
+
'MATIC': 'Polygon',
|
1508
|
+
'QTUM': 'QTUM',
|
1509
|
+
'REEF': 'REEF',
|
1510
|
+
'SOL': 'SOL',
|
1511
|
+
'SYS': 'SYS', # SyscoinNEVM is different
|
1512
|
+
'SXP': 'Solar',
|
1513
|
+
'XYM': 'Symbol',
|
1514
|
+
'TON': 'TON',
|
1515
|
+
'TT': 'TT',
|
1516
|
+
'TLOS': 'Telos',
|
1517
|
+
'THETA': 'ThetaToken',
|
1518
|
+
'VITE': 'VITE',
|
1519
|
+
'WAVES': 'WAVES',
|
1520
|
+
'WAX': 'WAXP',
|
1521
|
+
'WEMIX': 'WEMIXMainnet',
|
1522
|
+
'XDC': 'XDCNetworkXDC',
|
1523
|
+
'XRP': 'XRP',
|
1524
|
+
'FET': 'FETCH',
|
1525
|
+
'NEM': 'NEM',
|
1526
|
+
'REI': 'REINetwork',
|
1527
|
+
'ZIL': 'ZIL',
|
1528
|
+
'ABBC': 'ABBCCoin',
|
1529
|
+
'RSK': 'RSK',
|
1530
|
+
'AZERO': 'AZERO',
|
1531
|
+
'TRC10': 'TRC10',
|
1532
|
+
'JUNO': 'JUNO',
|
1533
|
+
# undetected: USDSP, more info at https://www.bitget.com/v1/spot/public/coinChainList
|
1534
|
+
# todo: uncomment below after unification
|
1535
|
+
# 'TERRACLASSIC': 'Terra', # tbd, that network id is also assigned to TERRANEW network
|
1536
|
+
# 'CUBENETWORK': 'CUBE',
|
1537
|
+
# 'CADUCEUS': 'CMP',
|
1538
|
+
# 'CONFLUX': 'CFX', # CFXeSpace is different
|
1539
|
+
# 'CERE': 'CERE',
|
1540
|
+
# 'CANTO': 'CANTO',
|
1541
|
+
'ZKSYNC': 'zkSyncEra',
|
1542
|
+
'STARKNET': 'Starknet',
|
1543
|
+
'VIC': 'VICTION',
|
1419
1544
|
},
|
1420
1545
|
'networksById': {
|
1421
|
-
'TRC20': 'TRX',
|
1422
|
-
'BSC': 'BEP20',
|
1423
1546
|
},
|
1424
1547
|
'fetchPositions': {
|
1425
1548
|
'method': 'privateMixGetV2MixPositionAllPosition', # or privateMixGetV2MixPositionHistoryPosition
|
1426
1549
|
},
|
1427
1550
|
'defaultTimeInForce': 'GTC', # 'GTC' = Good To Cancel(default), 'IOC' = Immediate Or Cancel
|
1428
1551
|
},
|
1552
|
+
'features': {
|
1553
|
+
'spot': {
|
1554
|
+
'sandbox': True,
|
1555
|
+
'createOrder': {
|
1556
|
+
'marginMode': True,
|
1557
|
+
'triggerPrice': True,
|
1558
|
+
'triggerPriceType': {
|
1559
|
+
'last': True,
|
1560
|
+
'mark': True,
|
1561
|
+
'index': False, # not on spot
|
1562
|
+
},
|
1563
|
+
'triggerDirection': False,
|
1564
|
+
'stopLossPrice': True, # todo: not yet implemented in spot
|
1565
|
+
'takeProfitPrice': True, # todo: not yet implemented in spot
|
1566
|
+
'attachedStopLossTakeProfit': {
|
1567
|
+
'triggerPriceType': {
|
1568
|
+
'last': False,
|
1569
|
+
'mark': False,
|
1570
|
+
'index': False,
|
1571
|
+
},
|
1572
|
+
'price': True,
|
1573
|
+
},
|
1574
|
+
'timeInForce': {
|
1575
|
+
'IOC': True,
|
1576
|
+
'FOK': True,
|
1577
|
+
'PO': True,
|
1578
|
+
'GTD': False,
|
1579
|
+
},
|
1580
|
+
'hedged': False,
|
1581
|
+
'trailing': False,
|
1582
|
+
'marketBuyRequiresPrice': True,
|
1583
|
+
'marketBuyByCost': True,
|
1584
|
+
# exchange-supported features
|
1585
|
+
# 'selfTradePrevention': True,
|
1586
|
+
# 'twap': False,
|
1587
|
+
# 'iceberg': False,
|
1588
|
+
# 'oco': False,
|
1589
|
+
},
|
1590
|
+
'createOrders': {
|
1591
|
+
'max': 50,
|
1592
|
+
},
|
1593
|
+
'fetchMyTrades': {
|
1594
|
+
'marginMode': True,
|
1595
|
+
'limit': 100,
|
1596
|
+
'daysBack': None,
|
1597
|
+
'untilDays': 90,
|
1598
|
+
},
|
1599
|
+
'fetchOrder': {
|
1600
|
+
'marginMode': False,
|
1601
|
+
'trigger': False,
|
1602
|
+
'trailing': False,
|
1603
|
+
},
|
1604
|
+
'fetchOpenOrders': {
|
1605
|
+
'marginMode': True,
|
1606
|
+
'limit': 100,
|
1607
|
+
'trigger': True,
|
1608
|
+
'trailing': False,
|
1609
|
+
},
|
1610
|
+
'fetchOrders': None,
|
1611
|
+
'fetchClosedOrders': {
|
1612
|
+
'marginMode': True,
|
1613
|
+
'limit': 100,
|
1614
|
+
'daysBack': None,
|
1615
|
+
'daysBackCanceled': None,
|
1616
|
+
'untilDays': 90,
|
1617
|
+
'trigger': True,
|
1618
|
+
'trailing': False,
|
1619
|
+
},
|
1620
|
+
'fetchOHLCV': {
|
1621
|
+
'limit': 1000, # variable timespans for recent endpoint, 200 for historical
|
1622
|
+
},
|
1623
|
+
},
|
1624
|
+
'forPerps': {
|
1625
|
+
'extends': 'spot',
|
1626
|
+
'createOrder': {
|
1627
|
+
'triggerPrice': True,
|
1628
|
+
'triggerPriceType': {
|
1629
|
+
'last': True,
|
1630
|
+
'mark': True,
|
1631
|
+
'index': False, # not on spot
|
1632
|
+
},
|
1633
|
+
'triggerDirection': False,
|
1634
|
+
'stopLossPrice': True,
|
1635
|
+
'takeProfitPrice': True,
|
1636
|
+
'attachedStopLossTakeProfit': {
|
1637
|
+
'triggerPriceType': {
|
1638
|
+
'last': True,
|
1639
|
+
'mark': True,
|
1640
|
+
'index': True,
|
1641
|
+
},
|
1642
|
+
'price': False,
|
1643
|
+
},
|
1644
|
+
'timeInForce': {
|
1645
|
+
'IOC': True,
|
1646
|
+
'FOK': True,
|
1647
|
+
'PO': True,
|
1648
|
+
'GTD': False,
|
1649
|
+
},
|
1650
|
+
'hedged': True,
|
1651
|
+
'trailing': True,
|
1652
|
+
'marketBuyRequiresPrice': False,
|
1653
|
+
'marketBuyByCost': False,
|
1654
|
+
# exchange-supported features
|
1655
|
+
# 'selfTradePrevention': True,
|
1656
|
+
# 'trailing': True,
|
1657
|
+
# 'twap': False,
|
1658
|
+
# 'iceberg': False,
|
1659
|
+
# 'oco': False,
|
1660
|
+
},
|
1661
|
+
'fetchMyTrades': {
|
1662
|
+
'untilDays': 7,
|
1663
|
+
},
|
1664
|
+
'fetchClosedOrders': {
|
1665
|
+
'trailing': True,
|
1666
|
+
},
|
1667
|
+
},
|
1668
|
+
'swap': {
|
1669
|
+
'linear': {
|
1670
|
+
'extends': 'forPerps',
|
1671
|
+
},
|
1672
|
+
'inverse': {
|
1673
|
+
'extends': 'forPerps',
|
1674
|
+
},
|
1675
|
+
},
|
1676
|
+
'future': {
|
1677
|
+
'linear': {
|
1678
|
+
'extends': 'forPerps',
|
1679
|
+
},
|
1680
|
+
'inverse': {
|
1681
|
+
'extends': 'forPerps',
|
1682
|
+
},
|
1683
|
+
},
|
1684
|
+
},
|
1429
1685
|
})
|
1430
1686
|
|
1431
1687
|
def set_sandbox_mode(self, enabled):
|
@@ -1492,7 +1748,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
1492
1748
|
async def fetch_time(self, params={}):
|
1493
1749
|
"""
|
1494
1750
|
fetches the current integer timestamp in milliseconds from the exchange server
|
1495
|
-
|
1751
|
+
|
1752
|
+
https://www.bitget.com/api-doc/common/public/Get-Server-Time
|
1753
|
+
|
1496
1754
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1497
1755
|
:returns int: the current integer timestamp in milliseconds from the exchange server
|
1498
1756
|
"""
|
@@ -1510,22 +1768,28 @@ class bitget(Exchange, ImplicitAPI):
|
|
1510
1768
|
data = self.safe_value(response, 'data', {})
|
1511
1769
|
return self.safe_integer(data, 'serverTime')
|
1512
1770
|
|
1513
|
-
async def fetch_markets(self, params={}):
|
1771
|
+
async def fetch_markets(self, params={}) -> List[Market]:
|
1514
1772
|
"""
|
1515
1773
|
retrieves data on all markets for bitget
|
1516
|
-
|
1517
|
-
|
1774
|
+
|
1775
|
+
https://www.bitget.com/api-doc/spot/market/Get-Symbols
|
1776
|
+
https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
|
1777
|
+
https://www.bitget.com/api-doc/margin/common/support-currencies
|
1778
|
+
|
1518
1779
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1519
1780
|
:returns dict[]: an array of objects representing market data
|
1520
1781
|
"""
|
1782
|
+
if self.options['adjustForTimeDifference']:
|
1783
|
+
await self.load_time_difference()
|
1521
1784
|
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
1522
1785
|
types = self.safe_value(self.options, 'fetchMarkets', ['spot', 'swap'])
|
1523
1786
|
if sandboxMode:
|
1524
1787
|
types = ['swap']
|
1525
1788
|
promises = []
|
1789
|
+
fetchMargins = False
|
1526
1790
|
for i in range(0, len(types)):
|
1527
1791
|
type = types[i]
|
1528
|
-
if type == 'swap':
|
1792
|
+
if (type == 'swap') or (type == 'future'):
|
1529
1793
|
subTypes = None
|
1530
1794
|
if sandboxMode:
|
1531
1795
|
# the following are simulated trading markets ['SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES']
|
@@ -1533,18 +1797,36 @@ class bitget(Exchange, ImplicitAPI):
|
|
1533
1797
|
else:
|
1534
1798
|
subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES']
|
1535
1799
|
for j in range(0, len(subTypes)):
|
1536
|
-
promises.append(self.
|
1800
|
+
promises.append(self.publicMixGetV2MixMarketContracts(self.extend(params, {
|
1537
1801
|
'productType': subTypes[j],
|
1538
1802
|
})))
|
1803
|
+
elif type == 'spot':
|
1804
|
+
promises.append(self.publicSpotGetV2SpotPublicSymbols(params))
|
1805
|
+
fetchMargins = True
|
1806
|
+
promises.append(self.publicMarginGetV2MarginCurrencies(params))
|
1539
1807
|
else:
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1808
|
+
raise NotSupported(self.id + ' does not support ' + type + ' market')
|
1809
|
+
results = await asyncio.gather(*promises)
|
1810
|
+
markets = []
|
1811
|
+
self.options['crossMarginPairsData'] = []
|
1812
|
+
self.options['isolatedMarginPairsData'] = []
|
1813
|
+
for i in range(0, len(results)):
|
1814
|
+
res = self.safe_dict(results, i)
|
1815
|
+
data = self.safe_list(res, 'data', [])
|
1816
|
+
firstData = self.safe_dict(data, 0, {})
|
1817
|
+
isBorrowable = self.safe_string(firstData, 'isBorrowable')
|
1818
|
+
if fetchMargins and isBorrowable is not None:
|
1819
|
+
keysList = list(self.index_by(data, 'symbol').keys())
|
1820
|
+
self.options['crossMarginPairsData'] = keysList
|
1821
|
+
self.options['isolatedMarginPairsData'] = keysList
|
1822
|
+
else:
|
1823
|
+
markets = self.array_concat(markets, data)
|
1824
|
+
result = []
|
1825
|
+
for i in range(0, len(markets)):
|
1826
|
+
result.append(self.parse_market(markets[i]))
|
1545
1827
|
return result
|
1546
1828
|
|
1547
|
-
def parse_market(self, market) -> Market:
|
1829
|
+
def parse_market(self, market: dict) -> Market:
|
1548
1830
|
#
|
1549
1831
|
# spot
|
1550
1832
|
#
|
@@ -1629,11 +1911,20 @@ class bitget(Exchange, ImplicitAPI):
|
|
1629
1911
|
expiry = None
|
1630
1912
|
expiryDatetime = None
|
1631
1913
|
symbolType = self.safe_string(market, 'symbolType')
|
1914
|
+
marginModes = None
|
1915
|
+
isMarginTradingAllowed = False
|
1632
1916
|
if symbolType is None:
|
1633
1917
|
type = 'spot'
|
1634
1918
|
spot = True
|
1635
1919
|
pricePrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'pricePrecision')))
|
1636
1920
|
amountPrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'quantityPrecision')))
|
1921
|
+
hasCrossMargin = self.in_array(marketId, self.options['crossMarginPairsData'])
|
1922
|
+
hasIsolatedMargin = self.in_array(marketId, self.options['isolatedMarginPairsData'])
|
1923
|
+
marginModes = {
|
1924
|
+
'cross': hasCrossMargin,
|
1925
|
+
'isolated': hasIsolatedMargin,
|
1926
|
+
}
|
1927
|
+
isMarginTradingAllowed = hasCrossMargin or hasCrossMargin
|
1637
1928
|
else:
|
1638
1929
|
if symbolType == 'perpetual':
|
1639
1930
|
type = 'swap'
|
@@ -1669,6 +1960,10 @@ class bitget(Exchange, ImplicitAPI):
|
|
1669
1960
|
preciseAmount.reduce()
|
1670
1961
|
amountString = str(preciseAmount)
|
1671
1962
|
amountPrecision = self.parse_number(amountString)
|
1963
|
+
marginModes = {
|
1964
|
+
'cross': True,
|
1965
|
+
'isolated': True,
|
1966
|
+
}
|
1672
1967
|
status = self.safe_string_2(market, 'status', 'symbolStatus')
|
1673
1968
|
active = None
|
1674
1969
|
if status is not None:
|
@@ -1688,7 +1983,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
1688
1983
|
'settleId': settleId,
|
1689
1984
|
'type': type,
|
1690
1985
|
'spot': spot,
|
1691
|
-
'margin':
|
1986
|
+
'margin': spot and isMarginTradingAllowed,
|
1987
|
+
'marginModes': marginModes,
|
1692
1988
|
'swap': swap,
|
1693
1989
|
'future': future,
|
1694
1990
|
'option': False,
|
@@ -1729,92 +2025,12 @@ class bitget(Exchange, ImplicitAPI):
|
|
1729
2025
|
'info': market,
|
1730
2026
|
}
|
1731
2027
|
|
1732
|
-
async def
|
1733
|
-
response = None
|
1734
|
-
if type == 'spot':
|
1735
|
-
response = await self.publicSpotGetV2SpotPublicSymbols(params)
|
1736
|
-
elif (type == 'swap') or (type == 'future'):
|
1737
|
-
response = await self.publicMixGetV2MixMarketContracts(params)
|
1738
|
-
else:
|
1739
|
-
raise NotSupported(self.id + ' does not support ' + type + ' market')
|
1740
|
-
#
|
1741
|
-
# spot
|
1742
|
-
#
|
1743
|
-
# {
|
1744
|
-
# "code": "00000",
|
1745
|
-
# "msg": "success",
|
1746
|
-
# "requestTime": 1700102364653,
|
1747
|
-
# "data": [
|
1748
|
-
# {
|
1749
|
-
# "symbol": "TRXUSDT",
|
1750
|
-
# "baseCoin": "TRX",
|
1751
|
-
# "quoteCoin": "USDT",
|
1752
|
-
# "minTradeAmount": "0",
|
1753
|
-
# "maxTradeAmount": "10000000000",
|
1754
|
-
# "takerFeeRate": "0.002",
|
1755
|
-
# "makerFeeRate": "0.002",
|
1756
|
-
# "pricePrecision": "6",
|
1757
|
-
# "quantityPrecision": "4",
|
1758
|
-
# "quotePrecision": "6",
|
1759
|
-
# "status": "online",
|
1760
|
-
# "minTradeUSDT": "5",
|
1761
|
-
# "buyLimitPriceRatio": "0.05",
|
1762
|
-
# "sellLimitPriceRatio": "0.05"
|
1763
|
-
# },
|
1764
|
-
# ]
|
1765
|
-
# }
|
1766
|
-
#
|
1767
|
-
# swap and future
|
1768
|
-
#
|
1769
|
-
# {
|
1770
|
-
# "code": "00000",
|
1771
|
-
# "msg": "success",
|
1772
|
-
# "requestTime": 1700102364709,
|
1773
|
-
# "data": [
|
1774
|
-
# {
|
1775
|
-
# "symbol": "BTCUSDT",
|
1776
|
-
# "baseCoin": "BTC",
|
1777
|
-
# "quoteCoin": "USDT",
|
1778
|
-
# "buyLimitPriceRatio": "0.01",
|
1779
|
-
# "sellLimitPriceRatio": "0.01",
|
1780
|
-
# "feeRateUpRatio": "0.005",
|
1781
|
-
# "makerFeeRate": "0.0002",
|
1782
|
-
# "takerFeeRate": "0.0006",
|
1783
|
-
# "openCostUpRatio": "0.01",
|
1784
|
-
# "supportMarginCoins": ["USDT"],
|
1785
|
-
# "minTradeNum": "0.001",
|
1786
|
-
# "priceEndStep": "1",
|
1787
|
-
# "volumePlace": "3",
|
1788
|
-
# "pricePlace": "1",
|
1789
|
-
# "sizeMultiplier": "0.001",
|
1790
|
-
# "symbolType": "perpetual",
|
1791
|
-
# "minTradeUSDT": "5",
|
1792
|
-
# "maxSymbolOrderNum": "200",
|
1793
|
-
# "maxProductOrderNum": "400",
|
1794
|
-
# "maxPositionNum": "150",
|
1795
|
-
# "symbolStatus": "normal",
|
1796
|
-
# "offTime": "-1",
|
1797
|
-
# "limitOpenTime": "-1",
|
1798
|
-
# "deliveryTime": "",
|
1799
|
-
# "deliveryStartTime": "",
|
1800
|
-
# "deliveryPeriod": "",
|
1801
|
-
# "launchTime": "",
|
1802
|
-
# "fundInterval": "8",
|
1803
|
-
# "minLever": "1",
|
1804
|
-
# "maxLever": "125",
|
1805
|
-
# "posLimit": "0.05",
|
1806
|
-
# "maintainTime": ""
|
1807
|
-
# },
|
1808
|
-
# ]
|
1809
|
-
# }
|
1810
|
-
#
|
1811
|
-
data = self.safe_value(response, 'data', [])
|
1812
|
-
return self.parse_markets(data)
|
1813
|
-
|
1814
|
-
async def fetch_currencies(self, params={}):
|
2028
|
+
async def fetch_currencies(self, params={}) -> Currencies:
|
1815
2029
|
"""
|
1816
2030
|
fetches all available currencies on an exchange
|
1817
|
-
|
2031
|
+
|
2032
|
+
https://www.bitget.com/api-doc/spot/market/Get-Coin-List
|
2033
|
+
|
1818
2034
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1819
2035
|
:returns dict: an associative dictionary of currencies
|
1820
2036
|
"""
|
@@ -1848,14 +2064,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
1848
2064
|
# "requestTime": "1700120731773"
|
1849
2065
|
# }
|
1850
2066
|
#
|
1851
|
-
result = {}
|
2067
|
+
result: dict = {}
|
1852
2068
|
data = self.safe_value(response, 'data', [])
|
1853
2069
|
for i in range(0, len(data)):
|
1854
2070
|
entry = data[i]
|
1855
|
-
id = self.safe_string(entry, 'coinId')
|
1856
|
-
code = self.safe_currency_code(
|
2071
|
+
id = self.safe_string(entry, 'coin') # we don't use 'coinId' has no use. it is 'coin' field that needs to be used in currency related endpoints(deposit, withdraw, etc..)
|
2072
|
+
code = self.safe_currency_code(id)
|
1857
2073
|
chains = self.safe_value(entry, 'chains', [])
|
1858
|
-
networks = {}
|
2074
|
+
networks: dict = {}
|
1859
2075
|
deposit = False
|
1860
2076
|
withdraw = False
|
1861
2077
|
minWithdrawString = None
|
@@ -1864,7 +2080,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
1864
2080
|
for j in range(0, len(chains)):
|
1865
2081
|
chain = chains[j]
|
1866
2082
|
networkId = self.safe_string(chain, 'chain')
|
1867
|
-
network = self.
|
2083
|
+
network = self.network_id_to_code(networkId, code)
|
2084
|
+
if network is not None:
|
2085
|
+
network = network.upper()
|
1868
2086
|
withdrawEnabled = self.safe_string(chain, 'withdrawable')
|
1869
2087
|
canWithdraw = withdrawEnabled == 'true'
|
1870
2088
|
withdraw = canWithdraw if (canWithdraw) else withdraw
|
@@ -1930,12 +2148,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
1930
2148
|
}
|
1931
2149
|
return result
|
1932
2150
|
|
1933
|
-
async def fetch_market_leverage_tiers(self, symbol: str, params={}):
|
2151
|
+
async def fetch_market_leverage_tiers(self, symbol: str, params={}) -> List[LeverageTier]:
|
1934
2152
|
"""
|
1935
2153
|
retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
2154
|
+
|
2155
|
+
https://www.bitget.com/api-doc/contract/position/Get-Query-Position-Lever
|
2156
|
+
https://www.bitget.com/api-doc/margin/cross/account/Cross-Tier-Data
|
2157
|
+
https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Tier-Data
|
2158
|
+
|
1939
2159
|
:param str symbol: unified market symbol
|
1940
2160
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1941
2161
|
:param str [params.marginMode]: for spot margin 'cross' or 'isolated', default is 'isolated'
|
@@ -1951,7 +2171,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
1951
2171
|
market = self.market(sandboxSymbol)
|
1952
2172
|
else:
|
1953
2173
|
market = self.market(symbol)
|
1954
|
-
request = {}
|
2174
|
+
request: dict = {}
|
1955
2175
|
response = None
|
1956
2176
|
marginMode = None
|
1957
2177
|
marginMode, params = self.handle_margin_mode_and_params('fetchMarketLeverageTiers', params, 'isolated')
|
@@ -1970,7 +2190,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
1970
2190
|
raise ArgumentsRequired(self.id + ' fetchMarketLeverageTiers() requires a code argument')
|
1971
2191
|
params = self.omit(params, 'code')
|
1972
2192
|
currency = self.currency(code)
|
1973
|
-
request['coin'] = currency['
|
2193
|
+
request['coin'] = currency['id']
|
1974
2194
|
response = await self.privateMarginGetV2MarginCrossedTierData(self.extend(request, params))
|
1975
2195
|
else:
|
1976
2196
|
raise BadRequest(self.id + ' fetchMarketLeverageTiers() symbol does not support market ' + market['symbol'])
|
@@ -2034,7 +2254,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2034
2254
|
result = self.safe_value(response, 'data', [])
|
2035
2255
|
return self.parse_market_leverage_tiers(result, market)
|
2036
2256
|
|
2037
|
-
def parse_market_leverage_tiers(self, info, market: Market = None):
|
2257
|
+
def parse_market_leverage_tiers(self, info, market: Market = None) -> List[LeverageTier]:
|
2038
2258
|
#
|
2039
2259
|
# swap and future
|
2040
2260
|
#
|
@@ -2081,8 +2301,10 @@ class bitget(Exchange, ImplicitAPI):
|
|
2081
2301
|
maxNotional = self.safe_number_n(item, ['endUnit', 'maxBorrowableAmount', 'baseMaxBorrowableAmount'])
|
2082
2302
|
marginCurrency = self.safe_string_2(item, 'coin', 'baseCoin')
|
2083
2303
|
currencyId = marginCurrency if (marginCurrency is not None) else market['base']
|
2304
|
+
marketId = self.safe_string(item, 'symbol')
|
2084
2305
|
tiers.append({
|
2085
2306
|
'tier': self.safe_integer_2(item, 'level', 'tier'),
|
2307
|
+
'symbol': self.safe_symbol(marketId, market),
|
2086
2308
|
'currency': self.safe_currency_code(currencyId),
|
2087
2309
|
'minNotional': minNotional,
|
2088
2310
|
'maxNotional': maxNotional,
|
@@ -2096,7 +2318,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
2096
2318
|
async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
2097
2319
|
"""
|
2098
2320
|
fetch all deposits made to an account
|
2099
|
-
|
2321
|
+
|
2322
|
+
https://www.bitget.com/api-doc/spot/account/Get-Deposit-Record
|
2323
|
+
|
2100
2324
|
:param str code: unified currency code
|
2101
2325
|
:param int [since]: the earliest time in ms to fetch deposits for
|
2102
2326
|
:param int [limit]: the maximum number of deposits structures to retrieve
|
@@ -2116,8 +2340,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
2116
2340
|
currency = self.currency(code)
|
2117
2341
|
if since is None:
|
2118
2342
|
since = self.milliseconds() - 7776000000 # 90 days
|
2119
|
-
request = {
|
2120
|
-
'coin': currency['
|
2343
|
+
request: dict = {
|
2344
|
+
'coin': currency['id'],
|
2121
2345
|
'startTime': since,
|
2122
2346
|
'endTime': self.milliseconds(),
|
2123
2347
|
}
|
@@ -2148,13 +2372,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
2148
2372
|
# ]
|
2149
2373
|
# }
|
2150
2374
|
#
|
2151
|
-
rawTransactions = self.
|
2375
|
+
rawTransactions = self.safe_list(response, 'data', [])
|
2152
2376
|
return self.parse_transactions(rawTransactions, currency, since, limit)
|
2153
2377
|
|
2154
|
-
async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
|
2378
|
+
async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
|
2155
2379
|
"""
|
2156
2380
|
make a withdrawal
|
2157
|
-
|
2381
|
+
|
2382
|
+
https://www.bitget.com/api-doc/spot/account/Wallet-Withdrawal
|
2383
|
+
|
2158
2384
|
:param str code: unified currency code
|
2159
2385
|
:param float amount: the amount to withdraw
|
2160
2386
|
:param str address: the address to withdraw to
|
@@ -2164,15 +2390,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
2164
2390
|
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
|
2165
2391
|
"""
|
2166
2392
|
self.check_address(address)
|
2167
|
-
|
2168
|
-
params = self.
|
2169
|
-
if
|
2170
|
-
raise ArgumentsRequired(self.id + ' withdraw() requires a
|
2393
|
+
networkCode = None
|
2394
|
+
networkCode, params = self.handle_network_code_and_params(params)
|
2395
|
+
if networkCode is None:
|
2396
|
+
raise ArgumentsRequired(self.id + ' withdraw() requires a "network" parameter')
|
2171
2397
|
await self.load_markets()
|
2172
2398
|
currency = self.currency(code)
|
2173
|
-
networkId = self.network_code_to_id(
|
2174
|
-
request = {
|
2175
|
-
'coin': currency['
|
2399
|
+
networkId = self.network_code_to_id(networkCode)
|
2400
|
+
request: dict = {
|
2401
|
+
'coin': currency['id'],
|
2176
2402
|
'address': address,
|
2177
2403
|
'chain': networkId,
|
2178
2404
|
'size': amount,
|
@@ -2193,27 +2419,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
2193
2419
|
# }
|
2194
2420
|
#
|
2195
2421
|
data = self.safe_value(response, 'data', {})
|
2196
|
-
result =
|
2197
|
-
|
2198
|
-
'info': response,
|
2199
|
-
'txid': None,
|
2200
|
-
'timestamp': None,
|
2201
|
-
'datetime': None,
|
2202
|
-
'network': None,
|
2203
|
-
'addressFrom': None,
|
2204
|
-
'address': None,
|
2205
|
-
'addressTo': None,
|
2206
|
-
'amount': None,
|
2207
|
-
'type': 'withdrawal',
|
2208
|
-
'currency': None,
|
2209
|
-
'status': None,
|
2210
|
-
'updated': None,
|
2211
|
-
'tagFrom': None,
|
2212
|
-
'tag': None,
|
2213
|
-
'tagTo': None,
|
2214
|
-
'comment': None,
|
2215
|
-
'fee': None,
|
2216
|
-
}
|
2422
|
+
result = self.parse_transaction(data, currency)
|
2423
|
+
result['type'] = 'withdrawal'
|
2217
2424
|
withdrawOptions = self.safe_value(self.options, 'withdraw', {})
|
2218
2425
|
fillResponseFromRequest = self.safe_bool(withdrawOptions, 'fillResponseFromRequest', True)
|
2219
2426
|
if fillResponseFromRequest:
|
@@ -2224,13 +2431,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
2224
2431
|
result['tag'] = tag
|
2225
2432
|
result['address'] = address
|
2226
2433
|
result['addressTo'] = address
|
2227
|
-
result['network'] =
|
2434
|
+
result['network'] = networkCode
|
2228
2435
|
return result
|
2229
2436
|
|
2230
2437
|
async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
2231
2438
|
"""
|
2232
2439
|
fetch all withdrawals made from an account
|
2233
|
-
|
2440
|
+
|
2441
|
+
https://www.bitget.com/api-doc/spot/account/Get-Withdraw-Record
|
2442
|
+
|
2234
2443
|
:param str code: unified currency code
|
2235
2444
|
:param int [since]: the earliest time in ms to fetch withdrawals for
|
2236
2445
|
:param int [limit]: the maximum number of withdrawals structures to retrieve
|
@@ -2250,8 +2459,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
2250
2459
|
currency = self.currency(code)
|
2251
2460
|
if since is None:
|
2252
2461
|
since = self.milliseconds() - 7776000000 # 90 days
|
2253
|
-
request = {
|
2254
|
-
'coin': currency['
|
2462
|
+
request: dict = {
|
2463
|
+
'coin': currency['id'],
|
2255
2464
|
'startTime': since,
|
2256
2465
|
'endTime': self.milliseconds(),
|
2257
2466
|
}
|
@@ -2285,10 +2494,10 @@ class bitget(Exchange, ImplicitAPI):
|
|
2285
2494
|
# ]
|
2286
2495
|
# }
|
2287
2496
|
#
|
2288
|
-
rawTransactions = self.
|
2497
|
+
rawTransactions = self.safe_list(response, 'data', [])
|
2289
2498
|
return self.parse_transactions(rawTransactions, currency, since, limit)
|
2290
2499
|
|
2291
|
-
def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
|
2500
|
+
def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
|
2292
2501
|
#
|
2293
2502
|
# fetchDeposits
|
2294
2503
|
#
|
@@ -2363,8 +2572,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
2363
2572
|
'fee': fee,
|
2364
2573
|
}
|
2365
2574
|
|
2366
|
-
def parse_transaction_status(self, status):
|
2367
|
-
statuses = {
|
2575
|
+
def parse_transaction_status(self, status: Str):
|
2576
|
+
statuses: dict = {
|
2368
2577
|
'success': 'ok',
|
2369
2578
|
'Pending': 'pending',
|
2370
2579
|
'pending_review': 'pending',
|
@@ -2373,26 +2582,25 @@ class bitget(Exchange, ImplicitAPI):
|
|
2373
2582
|
}
|
2374
2583
|
return self.safe_string(statuses, status, status)
|
2375
2584
|
|
2376
|
-
async def fetch_deposit_address(self, code: str, params={}):
|
2585
|
+
async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
|
2377
2586
|
"""
|
2378
2587
|
fetch the deposit address for a currency associated with self account
|
2379
|
-
|
2588
|
+
|
2589
|
+
https://www.bitget.com/api-doc/spot/account/Get-Deposit-Address
|
2590
|
+
|
2380
2591
|
:param str code: unified currency code
|
2381
2592
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2382
2593
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
2383
2594
|
"""
|
2384
2595
|
await self.load_markets()
|
2385
|
-
networkCode =
|
2386
|
-
params = self.
|
2387
|
-
networkId = None
|
2388
|
-
if networkCode is not None:
|
2389
|
-
networkId = self.network_code_to_id(networkCode, code)
|
2596
|
+
networkCode = None
|
2597
|
+
networkCode, params = self.handle_network_code_and_params(params)
|
2390
2598
|
currency = self.currency(code)
|
2391
|
-
request = {
|
2392
|
-
'coin': currency['
|
2599
|
+
request: dict = {
|
2600
|
+
'coin': currency['id'],
|
2393
2601
|
}
|
2394
|
-
if
|
2395
|
-
request['chain'] =
|
2602
|
+
if networkCode is not None:
|
2603
|
+
request['chain'] = self.network_code_to_id(networkCode, code)
|
2396
2604
|
response = await self.privateSpotGetV2SpotWalletDepositAddress(self.extend(request, params))
|
2397
2605
|
#
|
2398
2606
|
# {
|
@@ -2408,10 +2616,10 @@ class bitget(Exchange, ImplicitAPI):
|
|
2408
2616
|
# }
|
2409
2617
|
# }
|
2410
2618
|
#
|
2411
|
-
data = self.
|
2619
|
+
data = self.safe_dict(response, 'data', {})
|
2412
2620
|
return self.parse_deposit_address(data, currency)
|
2413
2621
|
|
2414
|
-
def parse_deposit_address(self, depositAddress, currency: Currency = None):
|
2622
|
+
def parse_deposit_address(self, depositAddress, currency: Currency = None) -> DepositAddress:
|
2415
2623
|
#
|
2416
2624
|
# {
|
2417
2625
|
# "coin": "BTC",
|
@@ -2428,18 +2636,20 @@ class bitget(Exchange, ImplicitAPI):
|
|
2428
2636
|
if networkId is not None:
|
2429
2637
|
network = self.network_id_to_code(networkId, parsedCurrency)
|
2430
2638
|
return {
|
2639
|
+
'info': depositAddress,
|
2431
2640
|
'currency': parsedCurrency,
|
2641
|
+
'network': network,
|
2432
2642
|
'address': self.safe_string(depositAddress, 'address'),
|
2433
2643
|
'tag': self.safe_string(depositAddress, 'tag'),
|
2434
|
-
'network': network,
|
2435
|
-
'info': depositAddress,
|
2436
2644
|
}
|
2437
2645
|
|
2438
2646
|
async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
2439
2647
|
"""
|
2440
2648
|
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
2441
|
-
|
2442
|
-
|
2649
|
+
|
2650
|
+
https://www.bitget.com/api-doc/spot/market/Get-Orderbook
|
2651
|
+
https://www.bitget.com/api-doc/contract/market/Get-Merge-Depth
|
2652
|
+
|
2443
2653
|
:param str symbol: unified symbol of the market to fetch the order book for
|
2444
2654
|
:param int [limit]: the maximum amount of order book entries to return
|
2445
2655
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -2453,7 +2663,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2453
2663
|
market = self.market(sandboxSymbol)
|
2454
2664
|
else:
|
2455
2665
|
market = self.market(symbol)
|
2456
|
-
request = {
|
2666
|
+
request: dict = {
|
2457
2667
|
'symbol': market['id'],
|
2458
2668
|
}
|
2459
2669
|
if limit is not None:
|
@@ -2482,7 +2692,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
2482
2692
|
timestamp = self.safe_integer(data, 'ts')
|
2483
2693
|
return self.parse_order_book(data, market['symbol'], timestamp)
|
2484
2694
|
|
2485
|
-
def parse_ticker(self, ticker, market: Market = None) -> Ticker:
|
2695
|
+
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
2696
|
+
#
|
2697
|
+
# {
|
2698
|
+
# "symbol": "BTCUSDT",
|
2699
|
+
# "price": "26242",
|
2700
|
+
# "indexPrice": "34867",
|
2701
|
+
# "markPrice": "25555",
|
2702
|
+
# "ts": "1695793390482"
|
2703
|
+
# }
|
2486
2704
|
#
|
2487
2705
|
# spot: fetchTicker, fetchTickers
|
2488
2706
|
#
|
@@ -2555,7 +2773,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2555
2773
|
#
|
2556
2774
|
marketId = self.safe_string(ticker, 'symbol')
|
2557
2775
|
close = self.safe_string(ticker, 'lastPr')
|
2558
|
-
timestamp = self.
|
2776
|
+
timestamp = self.safe_integer_omit_zero(ticker, 'ts') # exchange bitget provided 0
|
2559
2777
|
change = self.safe_string(ticker, 'change24h')
|
2560
2778
|
open24 = self.safe_string(ticker, 'open24')
|
2561
2779
|
open = self.safe_string(ticker, 'open')
|
@@ -2587,14 +2805,18 @@ class bitget(Exchange, ImplicitAPI):
|
|
2587
2805
|
'average': None,
|
2588
2806
|
'baseVolume': self.safe_string(ticker, 'baseVolume'),
|
2589
2807
|
'quoteVolume': self.safe_string(ticker, 'quoteVolume'),
|
2808
|
+
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
2809
|
+
'markPrice': self.safe_string(ticker, 'markPrice'),
|
2590
2810
|
'info': ticker,
|
2591
2811
|
}, market)
|
2592
2812
|
|
2593
2813
|
async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
2594
2814
|
"""
|
2595
2815
|
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
2596
|
-
|
2597
|
-
|
2816
|
+
|
2817
|
+
https://www.bitget.com/api-doc/spot/market/Get-Tickers
|
2818
|
+
https://www.bitget.com/api-doc/contract/market/Get-Ticker
|
2819
|
+
|
2598
2820
|
:param str symbol: unified symbol of the market to fetch the ticker for
|
2599
2821
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2600
2822
|
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
@@ -2607,7 +2829,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2607
2829
|
market = self.market(sandboxSymbol)
|
2608
2830
|
else:
|
2609
2831
|
market = self.market(symbol)
|
2610
|
-
request = {
|
2832
|
+
request: dict = {
|
2611
2833
|
'symbol': market['id'],
|
2612
2834
|
}
|
2613
2835
|
response = None
|
@@ -2681,16 +2903,51 @@ class bitget(Exchange, ImplicitAPI):
|
|
2681
2903
|
# ]
|
2682
2904
|
# }
|
2683
2905
|
#
|
2684
|
-
data = self.
|
2906
|
+
data = self.safe_list(response, 'data', [])
|
2907
|
+
return self.parse_ticker(data[0], market)
|
2908
|
+
|
2909
|
+
async def fetch_mark_price(self, symbol: str, params={}) -> Ticker:
|
2910
|
+
"""
|
2911
|
+
fetches the mark price for a specific market
|
2912
|
+
|
2913
|
+
https://www.bitget.com/api-doc/contract/market/Get-Symbol-Price
|
2914
|
+
|
2915
|
+
:param str symbol: unified symbol of the market to fetch the ticker for
|
2916
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2917
|
+
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
2918
|
+
"""
|
2919
|
+
await self.load_markets()
|
2920
|
+
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
2921
|
+
market = None
|
2922
|
+
if sandboxMode:
|
2923
|
+
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
2924
|
+
market = self.market(sandboxSymbol)
|
2925
|
+
else:
|
2926
|
+
market = self.market(symbol)
|
2927
|
+
request: dict = {
|
2928
|
+
'symbol': market['id'],
|
2929
|
+
}
|
2930
|
+
response = None
|
2931
|
+
if market['spot']:
|
2932
|
+
raise NotSupported(self.id + ' fetchMarkPrice() is not supported for spot markets')
|
2933
|
+
else:
|
2934
|
+
productType = None
|
2935
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
2936
|
+
request['productType'] = productType
|
2937
|
+
response = await self.publicMixGetV2MixMarketSymbolPrice(self.extend(request, params))
|
2938
|
+
data = self.safe_list(response, 'data', [])
|
2685
2939
|
return self.parse_ticker(data[0], market)
|
2686
2940
|
|
2687
2941
|
async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
2688
2942
|
"""
|
2689
2943
|
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
2690
|
-
|
2691
|
-
|
2944
|
+
|
2945
|
+
https://www.bitget.com/api-doc/spot/market/Get-Tickers
|
2946
|
+
https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker
|
2947
|
+
|
2692
2948
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
2693
2949
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2950
|
+
:param str [params.subType]: *contract only* 'linear', 'inverse'
|
2694
2951
|
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
2695
2952
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
2696
2953
|
"""
|
@@ -2704,15 +2961,20 @@ class bitget(Exchange, ImplicitAPI):
|
|
2704
2961
|
market = self.market(sandboxSymbol)
|
2705
2962
|
else:
|
2706
2963
|
market = self.market(symbol)
|
2707
|
-
|
2964
|
+
response = None
|
2965
|
+
request: dict = {}
|
2708
2966
|
type = None
|
2709
2967
|
type, params = self.handle_market_type_and_params('fetchTickers', market, params)
|
2710
|
-
|
2711
|
-
|
2968
|
+
# Calls like `.fetchTickers(None, {subType:'inverse'})` should be supported for self exchange, so
|
2969
|
+
# as "options.defaultSubType" is also set in exchange options, we should consider `params.subType`
|
2970
|
+
# with higher priority and only default to spot, if `subType` is not set in params
|
2971
|
+
passedSubType = self.safe_string(params, 'subType')
|
2972
|
+
productType = None
|
2973
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
2974
|
+
# only if passedSubType and productType is None, then use spot
|
2975
|
+
if type == 'spot' and passedSubType is None:
|
2712
2976
|
response = await self.publicSpotGetV2SpotMarketTickers(self.extend(request, params))
|
2713
2977
|
else:
|
2714
|
-
productType = None
|
2715
|
-
productType, params = self.handle_product_type_and_params(market, params)
|
2716
2978
|
request['productType'] = productType
|
2717
2979
|
response = await self.publicMixGetV2MixMarketTickers(self.extend(request, params))
|
2718
2980
|
#
|
@@ -2772,10 +3034,10 @@ class bitget(Exchange, ImplicitAPI):
|
|
2772
3034
|
# ]
|
2773
3035
|
# }
|
2774
3036
|
#
|
2775
|
-
data = self.
|
3037
|
+
data = self.safe_list(response, 'data', [])
|
2776
3038
|
return self.parse_tickers(data, symbols)
|
2777
3039
|
|
2778
|
-
def parse_trade(self, trade, market: Market = None) -> Trade:
|
3040
|
+
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
2779
3041
|
#
|
2780
3042
|
# spot, swap and future: fetchTrades
|
2781
3043
|
#
|
@@ -2895,10 +3157,12 @@ class bitget(Exchange, ImplicitAPI):
|
|
2895
3157
|
async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
2896
3158
|
"""
|
2897
3159
|
get the list of most recent trades for a particular symbol
|
2898
|
-
|
2899
|
-
|
2900
|
-
|
2901
|
-
|
3160
|
+
|
3161
|
+
https://www.bitget.com/api-doc/spot/market/Get-Recent-Trades
|
3162
|
+
https://www.bitget.com/api-doc/spot/market/Get-Market-Trades
|
3163
|
+
https://www.bitget.com/api-doc/contract/market/Get-Recent-Fills
|
3164
|
+
https://www.bitget.com/api-doc/contract/market/Get-Fills-History
|
3165
|
+
|
2902
3166
|
:param str symbol: unified symbol of the market to fetch trades for
|
2903
3167
|
:param int [since]: timestamp in ms of the earliest trade to fetch
|
2904
3168
|
:param int [limit]: the maximum amount of trades to fetch
|
@@ -2919,7 +3183,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2919
3183
|
market = self.market(sandboxSymbol)
|
2920
3184
|
else:
|
2921
3185
|
market = self.market(symbol)
|
2922
|
-
request = {
|
3186
|
+
request: dict = {
|
2923
3187
|
'symbol': market['id'],
|
2924
3188
|
}
|
2925
3189
|
if limit is not None:
|
@@ -2993,13 +3257,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
2993
3257
|
# ]
|
2994
3258
|
# }
|
2995
3259
|
#
|
2996
|
-
data = self.
|
3260
|
+
data = self.safe_list(response, 'data', [])
|
2997
3261
|
return self.parse_trades(data, market, since, limit)
|
2998
3262
|
|
2999
|
-
async def fetch_trading_fee(self, symbol: str, params={}):
|
3263
|
+
async def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
|
3000
3264
|
"""
|
3001
3265
|
fetch the trading fees for a market
|
3002
|
-
|
3266
|
+
|
3267
|
+
https://www.bitget.com/api-doc/common/public/Get-Trade-Rate
|
3268
|
+
|
3003
3269
|
:param str symbol: unified market symbol
|
3004
3270
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3005
3271
|
:param str [params.marginMode]: 'isolated' or 'cross', for finding the fee rate of spot margin trading pairs
|
@@ -3007,7 +3273,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
3007
3273
|
"""
|
3008
3274
|
await self.load_markets()
|
3009
3275
|
market = self.market(symbol)
|
3010
|
-
request = {
|
3276
|
+
request: dict = {
|
3011
3277
|
'symbol': market['id'],
|
3012
3278
|
}
|
3013
3279
|
marginMode = None
|
@@ -3034,12 +3300,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
3034
3300
|
data = self.safe_value(response, 'data', {})
|
3035
3301
|
return self.parse_trading_fee(data, market)
|
3036
3302
|
|
3037
|
-
async def fetch_trading_fees(self, params={}):
|
3303
|
+
async def fetch_trading_fees(self, params={}) -> TradingFees:
|
3038
3304
|
"""
|
3039
3305
|
fetch the trading fees for multiple markets
|
3040
|
-
|
3041
|
-
|
3042
|
-
|
3306
|
+
|
3307
|
+
https://www.bitget.com/api-doc/spot/market/Get-Symbols
|
3308
|
+
https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
|
3309
|
+
https://www.bitget.com/api-doc/margin/common/support-currencies
|
3310
|
+
|
3043
3311
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3044
3312
|
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
3045
3313
|
:param boolean [params.margin]: set to True for spot margin
|
@@ -3137,7 +3405,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
3137
3405
|
# }
|
3138
3406
|
#
|
3139
3407
|
data = self.safe_value(response, 'data', [])
|
3140
|
-
result = {}
|
3408
|
+
result: dict = {}
|
3141
3409
|
for i in range(0, len(data)):
|
3142
3410
|
entry = data[i]
|
3143
3411
|
marketId = self.safe_string(entry, 'symbol')
|
@@ -3154,6 +3422,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
3154
3422
|
'symbol': self.safe_symbol(marketId, market),
|
3155
3423
|
'maker': self.safe_number(data, 'makerFeeRate'),
|
3156
3424
|
'taker': self.safe_number(data, 'takerFeeRate'),
|
3425
|
+
'percentage': None,
|
3426
|
+
'tierBased': None,
|
3157
3427
|
}
|
3158
3428
|
|
3159
3429
|
def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
|
@@ -3180,12 +3450,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
3180
3450
|
async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
3181
3451
|
"""
|
3182
3452
|
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
3183
|
-
|
3184
|
-
|
3185
|
-
|
3186
|
-
|
3187
|
-
|
3188
|
-
|
3453
|
+
|
3454
|
+
https://www.bitget.com/api-doc/spot/market/Get-Candle-Data
|
3455
|
+
https://www.bitget.com/api-doc/spot/market/Get-History-Candle-Data
|
3456
|
+
https://www.bitget.com/api-doc/contract/market/Get-Candle-Data
|
3457
|
+
https://www.bitget.com/api-doc/contract/market/Get-History-Candle-Data
|
3458
|
+
https://www.bitget.com/api-doc/contract/market/Get-History-Index-Candle-Data
|
3459
|
+
https://www.bitget.com/api-doc/contract/market/Get-History-Mark-Candle-Data
|
3460
|
+
|
3189
3461
|
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
3190
3462
|
:param str timeframe: the length of time each candle represents
|
3191
3463
|
:param int [since]: timestamp in ms of the earliest candle to fetch
|
@@ -3215,15 +3487,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
3215
3487
|
timeframes = self.options['timeframes'][marketType]
|
3216
3488
|
msInDay = 86400000
|
3217
3489
|
duration = self.parse_timeframe(timeframe) * 1000
|
3218
|
-
request = {
|
3490
|
+
request: dict = {
|
3219
3491
|
'symbol': market['id'],
|
3220
3492
|
'granularity': self.safe_string(timeframes, timeframe, timeframe),
|
3221
3493
|
}
|
3222
|
-
until = self.
|
3494
|
+
until = self.safe_integer(params, 'until')
|
3223
3495
|
limitDefined = limit is not None
|
3224
3496
|
sinceDefined = since is not None
|
3225
3497
|
untilDefined = until is not None
|
3226
|
-
params = self.omit(params, ['until'
|
3498
|
+
params = self.omit(params, ['until'])
|
3227
3499
|
response = None
|
3228
3500
|
now = self.milliseconds()
|
3229
3501
|
# retrievable periods listed here:
|
@@ -3300,18 +3572,20 @@ class bitget(Exchange, ImplicitAPI):
|
|
3300
3572
|
async def fetch_balance(self, params={}) -> Balances:
|
3301
3573
|
"""
|
3302
3574
|
query for balance and get the amount of funds available for trading or funds locked in orders
|
3303
|
-
|
3304
|
-
|
3305
|
-
|
3306
|
-
|
3307
|
-
|
3308
|
-
|
3575
|
+
|
3576
|
+
https://www.bitget.com/api-doc/spot/account/Get-Account-Assets
|
3577
|
+
https://www.bitget.com/api-doc/contract/account/Get-Account-List
|
3578
|
+
https://www.bitget.com/api-doc/margin/cross/account/Get-Cross-Assets
|
3579
|
+
https://www.bitget.com/api-doc/margin/isolated/account/Get-Isolated-Assets
|
3580
|
+
https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-assets
|
3581
|
+
https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-assets
|
3582
|
+
|
3309
3583
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3310
3584
|
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
3311
3585
|
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
3312
3586
|
"""
|
3313
3587
|
await self.load_markets()
|
3314
|
-
request = {}
|
3588
|
+
request: dict = {}
|
3315
3589
|
marketType = None
|
3316
3590
|
marginMode = None
|
3317
3591
|
response = None
|
@@ -3421,7 +3695,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
3421
3695
|
return self.parse_balance(data)
|
3422
3696
|
|
3423
3697
|
def parse_balance(self, balance) -> Balances:
|
3424
|
-
result = {'info': balance}
|
3698
|
+
result: dict = {'info': balance}
|
3425
3699
|
#
|
3426
3700
|
# spot
|
3427
3701
|
#
|
@@ -3508,8 +3782,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
3508
3782
|
result[code] = account
|
3509
3783
|
return self.safe_balance(result)
|
3510
3784
|
|
3511
|
-
def parse_order_status(self, status):
|
3512
|
-
statuses = {
|
3785
|
+
def parse_order_status(self, status: Str):
|
3786
|
+
statuses: dict = {
|
3513
3787
|
'new': 'open',
|
3514
3788
|
'init': 'open',
|
3515
3789
|
'not_trigger': 'open',
|
@@ -3529,7 +3803,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
3529
3803
|
}
|
3530
3804
|
return self.safe_string(statuses, status, status)
|
3531
3805
|
|
3532
|
-
def parse_order(self, order, market: Market = None) -> Order:
|
3806
|
+
def parse_order(self, order: dict, market: Market = None) -> Order:
|
3533
3807
|
#
|
3534
3808
|
# createOrder, editOrder, closePosition
|
3535
3809
|
#
|
@@ -3822,7 +4096,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
3822
4096
|
if feeCostString is not None:
|
3823
4097
|
# swap
|
3824
4098
|
fee = {
|
3825
|
-
'cost': self.parse_number(Precise.
|
4099
|
+
'cost': self.parse_number(Precise.string_neg(feeCostString)),
|
3826
4100
|
'currency': market['settle'],
|
3827
4101
|
}
|
3828
4102
|
feeDetail = self.safe_value(order, 'feeDetail')
|
@@ -3836,7 +4110,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
3836
4110
|
feeObject = feeValue
|
3837
4111
|
break
|
3838
4112
|
fee = {
|
3839
|
-
'cost': self.parse_number(Precise.
|
4113
|
+
'cost': self.parse_number(Precise.string_neg(self.safe_string(feeObject, 'totalFee'))),
|
3840
4114
|
'currency': self.safe_currency_code(self.safe_string(feeObject, 'feeCoinCode')),
|
3841
4115
|
}
|
3842
4116
|
postOnly = None
|
@@ -3894,7 +4168,6 @@ class bitget(Exchange, ImplicitAPI):
|
|
3894
4168
|
'timeInForce': timeInForce,
|
3895
4169
|
'postOnly': postOnly,
|
3896
4170
|
'reduceOnly': reduceOnly,
|
3897
|
-
'stopPrice': self.safe_number(order, 'triggerPrice'),
|
3898
4171
|
'triggerPrice': self.safe_number(order, 'triggerPrice'),
|
3899
4172
|
'takeProfitPrice': self.safe_number_2(order, 'presetStopSurplusPrice', 'stopSurplusTriggerPrice'),
|
3900
4173
|
'stopLossPrice': self.safe_number_2(order, 'presetStopLossPrice', 'stopLossTriggerPrice'),
|
@@ -3906,9 +4179,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
3906
4179
|
async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
|
3907
4180
|
"""
|
3908
4181
|
create a market buy order by providing the symbol and cost
|
3909
|
-
|
3910
|
-
|
3911
|
-
|
4182
|
+
|
4183
|
+
https://www.bitget.com/api-doc/spot/trade/Place-Order
|
4184
|
+
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Place-Order
|
4185
|
+
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Place-Order
|
4186
|
+
|
3912
4187
|
:param str symbol: unified symbol of the market to create an order in
|
3913
4188
|
:param float cost: how much you want to trade in units of the quote currency
|
3914
4189
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -3918,24 +4193,28 @@ class bitget(Exchange, ImplicitAPI):
|
|
3918
4193
|
market = self.market(symbol)
|
3919
4194
|
if not market['spot']:
|
3920
4195
|
raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
|
3921
|
-
|
3922
|
-
|
4196
|
+
req = {
|
4197
|
+
'createMarketBuyOrderRequiresPrice': False,
|
4198
|
+
}
|
4199
|
+
return await self.create_order(symbol, 'market', 'buy', cost, None, self.extend(req, params))
|
3923
4200
|
|
3924
4201
|
async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
3925
4202
|
"""
|
3926
4203
|
create a trade order
|
3927
|
-
|
3928
|
-
|
3929
|
-
|
3930
|
-
|
3931
|
-
|
3932
|
-
|
3933
|
-
|
4204
|
+
|
4205
|
+
https://www.bitget.com/api-doc/spot/trade/Place-Order
|
4206
|
+
https://www.bitget.com/api-doc/spot/plan/Place-Plan-Order
|
4207
|
+
https://www.bitget.com/api-doc/contract/trade/Place-Order
|
4208
|
+
https://www.bitget.com/api-doc/contract/plan/Place-Tpsl-Order
|
4209
|
+
https://www.bitget.com/api-doc/contract/plan/Place-Plan-Order
|
4210
|
+
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Place-Order
|
4211
|
+
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Place-Order
|
4212
|
+
|
3934
4213
|
:param str symbol: unified symbol of the market to create an order in
|
3935
4214
|
:param str type: 'market' or 'limit'
|
3936
4215
|
:param str side: 'buy' or 'sell'
|
3937
4216
|
:param float amount: how much you want to trade in units of the base currency
|
3938
|
-
:param float [price]: the price at which the order is to be
|
4217
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
3939
4218
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3940
4219
|
:param float [params.cost]: *spot only* how much you want to trade in units of the quote currency, for market buy orders only
|
3941
4220
|
:param float [params.triggerPrice]: *swap only* The price at which a trigger order is triggered at
|
@@ -3957,6 +4236,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
3957
4236
|
:param str [params.trailingTriggerPrice]: *swap and future only* the price to trigger a trailing stop order, default uses the price argument
|
3958
4237
|
:param str [params.triggerType]: *swap and future only* 'fill_price', 'mark_price' or 'index_price'
|
3959
4238
|
:param boolean [params.oneWayMode]: *swap and future only* required to set self to True in one_way_mode and you can leave self in hedge_mode, can adjust the mode using the setPositionMode() method
|
4239
|
+
:param bool [params.hedged]: *swap and future only* True for hedged mode, False for one way mode, default is False
|
4240
|
+
:param bool [params.reduceOnly]: True or False whether the order is reduce-only
|
3960
4241
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
3961
4242
|
"""
|
3962
4243
|
await self.load_markets()
|
@@ -4001,7 +4282,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4001
4282
|
# }
|
4002
4283
|
# }
|
4003
4284
|
#
|
4004
|
-
data = self.
|
4285
|
+
data = self.safe_dict(response, 'data', {})
|
4005
4286
|
return self.parse_order(data, market)
|
4006
4287
|
|
4007
4288
|
def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
@@ -4016,7 +4297,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4016
4297
|
marginMode = None
|
4017
4298
|
marketType, params = self.handle_market_type_and_params('createOrder', market, params)
|
4018
4299
|
marginMode, params = self.handle_margin_mode_and_params('createOrder', params)
|
4019
|
-
request = {
|
4300
|
+
request: dict = {
|
4020
4301
|
'symbol': market['id'],
|
4021
4302
|
'orderType': type,
|
4022
4303
|
}
|
@@ -4040,7 +4321,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4040
4321
|
raise ExchangeError(self.id + ' createOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent')
|
4041
4322
|
if type == 'limit':
|
4042
4323
|
request['price'] = self.price_to_precision(symbol, price)
|
4043
|
-
|
4324
|
+
triggerPriceType = self.safe_string_2(params, 'triggerPriceType', 'triggerType', 'mark_price')
|
4044
4325
|
reduceOnly = self.safe_bool(params, 'reduceOnly', False)
|
4045
4326
|
clientOrderId = self.safe_string_2(params, 'clientOid', 'clientOrderId')
|
4046
4327
|
exchangeSpecificTifParam = self.safe_string_2(params, 'force', 'timeInForce')
|
@@ -4066,7 +4347,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4066
4347
|
if clientOrderId is not None:
|
4067
4348
|
request['clientOid'] = clientOrderId
|
4068
4349
|
if isTriggerOrder or isStopLossOrTakeProfitTrigger or isTrailingPercentOrder:
|
4069
|
-
request['triggerType'] =
|
4350
|
+
request['triggerType'] = triggerPriceType
|
4070
4351
|
if isTrailingPercentOrder:
|
4071
4352
|
if not isMarketOrder:
|
4072
4353
|
raise BadRequest(self.id + ' createOrder() bitget trailing orders must be market orders')
|
@@ -4116,18 +4397,23 @@ class bitget(Exchange, ImplicitAPI):
|
|
4116
4397
|
marginMode = 'cross'
|
4117
4398
|
marginModeRequest = 'crossed' if (marginMode == 'cross') else 'isolated'
|
4118
4399
|
request['marginMode'] = marginModeRequest
|
4119
|
-
|
4120
|
-
params = self.
|
4400
|
+
hedged = None
|
4401
|
+
hedged, params = self.handle_param_bool(params, 'hedged', False)
|
4402
|
+
# backward compatibility for `oneWayMode`
|
4403
|
+
oneWayMode = None
|
4404
|
+
oneWayMode, params = self.handle_param_bool(params, 'oneWayMode')
|
4405
|
+
if oneWayMode is not None:
|
4406
|
+
hedged = not oneWayMode
|
4121
4407
|
requestSide = side
|
4122
4408
|
if reduceOnly:
|
4123
|
-
if
|
4409
|
+
if not hedged:
|
4124
4410
|
request['reduceOnly'] = 'YES'
|
4125
4411
|
else:
|
4126
4412
|
# on bitget hedge mode if the position is long the side is always buy, and if the position is short the side is always sell
|
4127
4413
|
requestSide = 'sell' if (side == 'buy') else 'buy'
|
4128
4414
|
request['tradeSide'] = 'Close'
|
4129
4415
|
else:
|
4130
|
-
if
|
4416
|
+
if hedged:
|
4131
4417
|
request['tradeSide'] = 'Open'
|
4132
4418
|
request['side'] = requestSide
|
4133
4419
|
elif marketType == 'spot':
|
@@ -4161,7 +4447,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4161
4447
|
request['clientOid'] = clientOrderId
|
4162
4448
|
if marginMode is not None:
|
4163
4449
|
request['loanType'] = 'normal'
|
4164
|
-
if
|
4450
|
+
if isMarketOrder and (side == 'buy'):
|
4165
4451
|
request['quoteSize'] = quantity
|
4166
4452
|
else:
|
4167
4453
|
request['baseSize'] = quantity
|
@@ -4170,7 +4456,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4170
4456
|
request['size'] = quantity
|
4171
4457
|
if triggerPrice is not None:
|
4172
4458
|
request['planType'] = planType
|
4173
|
-
request['triggerType'] =
|
4459
|
+
request['triggerType'] = triggerPriceType
|
4174
4460
|
request['triggerPrice'] = self.price_to_precision(symbol, triggerPrice)
|
4175
4461
|
if price is not None:
|
4176
4462
|
request['executePrice'] = self.price_to_precision(symbol, price)
|
@@ -4181,10 +4467,12 @@ class bitget(Exchange, ImplicitAPI):
|
|
4181
4467
|
async def create_orders(self, orders: List[OrderRequest], params={}):
|
4182
4468
|
"""
|
4183
4469
|
create a list of trade orders(all orders should be of the same symbol)
|
4184
|
-
|
4185
|
-
|
4186
|
-
|
4187
|
-
|
4470
|
+
|
4471
|
+
https://www.bitget.com/api-doc/spot/trade/Batch-Place-Orders
|
4472
|
+
https://www.bitget.com/api-doc/contract/trade/Batch-Order
|
4473
|
+
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Order
|
4474
|
+
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Order
|
4475
|
+
|
4188
4476
|
: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
|
4189
4477
|
:param dict [params]: extra parameters specific to the api endpoint
|
4190
4478
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
@@ -4223,7 +4511,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4223
4511
|
market = self.market(sandboxSymbol)
|
4224
4512
|
else:
|
4225
4513
|
market = self.market(symbol)
|
4226
|
-
request = {
|
4514
|
+
request: dict = {
|
4227
4515
|
'symbol': market['id'],
|
4228
4516
|
'orderList': ordersRequests,
|
4229
4517
|
}
|
@@ -4276,16 +4564,18 @@ class bitget(Exchange, ImplicitAPI):
|
|
4276
4564
|
async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
|
4277
4565
|
"""
|
4278
4566
|
edit a trade order
|
4279
|
-
|
4280
|
-
|
4281
|
-
|
4282
|
-
|
4567
|
+
|
4568
|
+
https://www.bitget.com/api-doc/spot/plan/Modify-Plan-Order
|
4569
|
+
https://www.bitget.com/api-doc/contract/trade/Modify-Order
|
4570
|
+
https://www.bitget.com/api-doc/contract/plan/Modify-Tpsl-Order
|
4571
|
+
https://www.bitget.com/api-doc/contract/plan/Modify-Plan-Order
|
4572
|
+
|
4283
4573
|
:param str id: cancel order id
|
4284
4574
|
:param str symbol: unified symbol of the market to create an order in
|
4285
4575
|
:param str type: 'market' or 'limit'
|
4286
4576
|
:param str side: 'buy' or 'sell'
|
4287
4577
|
:param float amount: how much you want to trade in units of the base currency
|
4288
|
-
:param float [price]: the price at which the order is to be
|
4578
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
4289
4579
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4290
4580
|
:param float [params.triggerPrice]: the price that a trigger order is triggered at
|
4291
4581
|
:param float [params.stopLossPrice]: *swap only* The price at which a stop loss order is triggered at
|
@@ -4311,7 +4601,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4311
4601
|
market = self.market(sandboxSymbol)
|
4312
4602
|
else:
|
4313
4603
|
market = self.market(symbol)
|
4314
|
-
request = {
|
4604
|
+
request: dict = {
|
4315
4605
|
'orderId': id,
|
4316
4606
|
}
|
4317
4607
|
isMarketOrder = type == 'market'
|
@@ -4336,6 +4626,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
4336
4626
|
params = self.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'clientOrderId', 'trailingTriggerPrice', 'trailingPercent'])
|
4337
4627
|
response = None
|
4338
4628
|
if market['spot']:
|
4629
|
+
if triggerPrice is None:
|
4630
|
+
raise NotSupported(self.id + 'editOrder() only supports plan/trigger spot orders')
|
4339
4631
|
editMarketBuyOrderRequiresPrice = self.safe_bool(self.options, 'editMarketBuyOrderRequiresPrice', True)
|
4340
4632
|
if editMarketBuyOrderRequiresPrice and isMarketOrder and (side == 'buy'):
|
4341
4633
|
if price is None:
|
@@ -4418,23 +4710,25 @@ class bitget(Exchange, ImplicitAPI):
|
|
4418
4710
|
# }
|
4419
4711
|
# }
|
4420
4712
|
#
|
4421
|
-
data = self.
|
4713
|
+
data = self.safe_dict(response, 'data', {})
|
4422
4714
|
return self.parse_order(data, market)
|
4423
4715
|
|
4424
4716
|
async def cancel_order(self, id: str, symbol: Str = None, params={}):
|
4425
4717
|
"""
|
4426
4718
|
cancels an open order
|
4427
|
-
|
4428
|
-
|
4429
|
-
|
4430
|
-
|
4431
|
-
|
4432
|
-
|
4719
|
+
|
4720
|
+
https://www.bitget.com/api-doc/spot/trade/Cancel-Order
|
4721
|
+
https://www.bitget.com/api-doc/spot/plan/Cancel-Plan-Order
|
4722
|
+
https://www.bitget.com/api-doc/contract/trade/Cancel-Order
|
4723
|
+
https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order
|
4724
|
+
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Cancel-Order
|
4725
|
+
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Cancel-Order
|
4726
|
+
|
4433
4727
|
:param str id: order id
|
4434
4728
|
:param str symbol: unified symbol of the market the order was made in
|
4435
4729
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4436
4730
|
:param str [params.marginMode]: 'isolated' or 'cross' for spot margin trading
|
4437
|
-
:param boolean [params.
|
4731
|
+
:param boolean [params.trigger]: set to True for canceling trigger orders
|
4438
4732
|
:param str [params.planType]: *swap only* either profit_plan, loss_plan, normal_plan, pos_profit, pos_loss, moving_plan or track_plan
|
4439
4733
|
:param boolean [params.trailing]: set to True if you want to cancel a trailing order
|
4440
4734
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
@@ -4452,21 +4746,21 @@ class bitget(Exchange, ImplicitAPI):
|
|
4452
4746
|
marginMode = None
|
4453
4747
|
response = None
|
4454
4748
|
marginMode, params = self.handle_margin_mode_and_params('cancelOrder', params)
|
4455
|
-
request = {}
|
4749
|
+
request: dict = {}
|
4456
4750
|
trailing = self.safe_value(params, 'trailing')
|
4457
|
-
|
4751
|
+
trigger = self.safe_value_2(params, 'stop', 'trigger')
|
4458
4752
|
params = self.omit(params, ['stop', 'trigger', 'trailing'])
|
4459
|
-
if not (market['spot'] and
|
4753
|
+
if not (market['spot'] and trigger):
|
4460
4754
|
request['symbol'] = market['id']
|
4461
|
-
if not ((market['swap'] or market['future']) and
|
4755
|
+
if not ((market['swap'] or market['future']) and trigger):
|
4462
4756
|
request['orderId'] = id
|
4463
4757
|
if (market['swap']) or (market['future']):
|
4464
4758
|
productType = None
|
4465
4759
|
productType, params = self.handle_product_type_and_params(market, params)
|
4466
4760
|
request['productType'] = productType
|
4467
|
-
if
|
4761
|
+
if trigger or trailing:
|
4468
4762
|
orderIdList = []
|
4469
|
-
orderId = {
|
4763
|
+
orderId: dict = {
|
4470
4764
|
'orderId': id,
|
4471
4765
|
}
|
4472
4766
|
orderIdList.append(orderId)
|
@@ -4475,7 +4769,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4475
4769
|
planType = self.safe_string(params, 'planType', 'track_plan')
|
4476
4770
|
request['planType'] = planType
|
4477
4771
|
response = await self.privateMixPostV2MixOrderCancelPlanOrder(self.extend(request, params))
|
4478
|
-
elif
|
4772
|
+
elif trigger:
|
4479
4773
|
response = await self.privateMixPostV2MixOrderCancelPlanOrder(self.extend(request, params))
|
4480
4774
|
else:
|
4481
4775
|
response = await self.privateMixPostV2MixOrderCancelOrder(self.extend(request, params))
|
@@ -4486,7 +4780,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4486
4780
|
elif marginMode == 'cross':
|
4487
4781
|
response = await self.privateMarginPostV2MarginCrossedCancelOrder(self.extend(request, params))
|
4488
4782
|
else:
|
4489
|
-
if
|
4783
|
+
if trigger:
|
4490
4784
|
response = await self.privateSpotPostV2SpotTradeCancelPlanOrder(self.extend(request, params))
|
4491
4785
|
else:
|
4492
4786
|
response = await self.privateSpotPostV2SpotTradeCancelOrder(self.extend(request, params))
|
@@ -4535,7 +4829,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4535
4829
|
#
|
4536
4830
|
data = self.safe_value(response, 'data', {})
|
4537
4831
|
order = None
|
4538
|
-
if (market['swap'] or market['future']) and
|
4832
|
+
if (market['swap'] or market['future']) and trigger:
|
4539
4833
|
orderInfo = self.safe_value(data, 'successList', [])
|
4540
4834
|
order = orderInfo[0]
|
4541
4835
|
else:
|
@@ -4545,16 +4839,18 @@ class bitget(Exchange, ImplicitAPI):
|
|
4545
4839
|
async def cancel_orders(self, ids, symbol: Str = None, params={}):
|
4546
4840
|
"""
|
4547
4841
|
cancel multiple orders
|
4548
|
-
|
4549
|
-
|
4550
|
-
|
4551
|
-
|
4552
|
-
|
4842
|
+
|
4843
|
+
https://www.bitget.com/api-doc/spot/trade/Batch-Cancel-Orders
|
4844
|
+
https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
|
4845
|
+
https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order
|
4846
|
+
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Cancel-Order
|
4847
|
+
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Cancel-Orders
|
4848
|
+
|
4553
4849
|
:param str[] ids: order ids
|
4554
4850
|
:param str symbol: unified market symbol, default is None
|
4555
4851
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4556
4852
|
:param str [params.marginMode]: 'isolated' or 'cross' for spot margin trading
|
4557
|
-
:param boolean [params.
|
4853
|
+
:param boolean [params.trigger]: *contract only* set to True for canceling trigger orders
|
4558
4854
|
:returns dict: an array of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
4559
4855
|
"""
|
4560
4856
|
if symbol is None:
|
@@ -4569,16 +4865,16 @@ class bitget(Exchange, ImplicitAPI):
|
|
4569
4865
|
market = self.market(symbol)
|
4570
4866
|
marginMode = None
|
4571
4867
|
marginMode, params = self.handle_margin_mode_and_params('cancelOrders', params)
|
4572
|
-
|
4868
|
+
trigger = self.safe_value_2(params, 'stop', 'trigger')
|
4573
4869
|
params = self.omit(params, ['stop', 'trigger'])
|
4574
4870
|
orderIdList = []
|
4575
4871
|
for i in range(0, len(ids)):
|
4576
4872
|
individualId = ids[i]
|
4577
|
-
orderId = {
|
4873
|
+
orderId: dict = {
|
4578
4874
|
'orderId': individualId,
|
4579
4875
|
}
|
4580
4876
|
orderIdList.append(orderId)
|
4581
|
-
request = {
|
4877
|
+
request: dict = {
|
4582
4878
|
'symbol': market['id'],
|
4583
4879
|
}
|
4584
4880
|
if market['spot'] and (marginMode is None):
|
@@ -4598,7 +4894,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4598
4894
|
productType = None
|
4599
4895
|
productType, params = self.handle_product_type_and_params(market, params)
|
4600
4896
|
request['productType'] = productType
|
4601
|
-
if
|
4897
|
+
if trigger:
|
4602
4898
|
response = await self.privateMixPostV2MixOrderCancelPlanOrder(self.extend(request, params))
|
4603
4899
|
else:
|
4604
4900
|
response = await self.privateMixPostV2MixOrderBatchCancelOrders(self.extend(request, params))
|
@@ -4619,21 +4915,23 @@ class bitget(Exchange, ImplicitAPI):
|
|
4619
4915
|
# }
|
4620
4916
|
#
|
4621
4917
|
data = self.safe_value(response, 'data', {})
|
4622
|
-
orders = self.
|
4918
|
+
orders = self.safe_list(data, 'successList', [])
|
4623
4919
|
return self.parse_orders(orders, market)
|
4624
4920
|
|
4625
4921
|
async def cancel_all_orders(self, symbol: Str = None, params={}):
|
4626
4922
|
"""
|
4627
4923
|
cancel all open orders
|
4628
|
-
|
4629
|
-
|
4630
|
-
|
4631
|
-
|
4632
|
-
|
4924
|
+
|
4925
|
+
https://www.bitget.com/api-doc/spot/trade/Cancel-Symbol-Orders
|
4926
|
+
https://www.bitget.com/api-doc/spot/plan/Batch-Cancel-Plan-Order
|
4927
|
+
https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
|
4928
|
+
https://bitgetlimited.github.io/apidoc/en/margin/#isolated-batch-cancel-orders
|
4929
|
+
https://bitgetlimited.github.io/apidoc/en/margin/#cross-batch-cancel-order
|
4930
|
+
|
4633
4931
|
:param str symbol: unified market symbol
|
4634
4932
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4635
4933
|
:param str [params.marginMode]: 'isolated' or 'cross' for spot margin trading
|
4636
|
-
:param boolean [params.
|
4934
|
+
:param boolean [params.trigger]: *contract only* set to True for canceling trigger orders
|
4637
4935
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
4638
4936
|
"""
|
4639
4937
|
if symbol is None:
|
@@ -4648,10 +4946,10 @@ class bitget(Exchange, ImplicitAPI):
|
|
4648
4946
|
market = self.market(symbol)
|
4649
4947
|
marginMode = None
|
4650
4948
|
marginMode, params = self.handle_margin_mode_and_params('cancelAllOrders', params)
|
4651
|
-
request = {
|
4949
|
+
request: dict = {
|
4652
4950
|
'symbol': market['id'],
|
4653
4951
|
}
|
4654
|
-
|
4952
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
4655
4953
|
params = self.omit(params, ['stop', 'trigger'])
|
4656
4954
|
response = None
|
4657
4955
|
if market['spot']:
|
@@ -4660,103 +4958,115 @@ class bitget(Exchange, ImplicitAPI):
|
|
4660
4958
|
response = await self.privateMarginPostMarginV1CrossOrderBatchCancelOrder(self.extend(request, params))
|
4661
4959
|
else:
|
4662
4960
|
response = await self.privateMarginPostMarginV1IsolatedOrderBatchCancelOrder(self.extend(request, params))
|
4961
|
+
#
|
4962
|
+
# {
|
4963
|
+
# "code": "00000",
|
4964
|
+
# "msg": "success",
|
4965
|
+
# "requestTime": 1700717155622,
|
4966
|
+
# "data": {
|
4967
|
+
# "resultList": [
|
4968
|
+
# {
|
4969
|
+
# "orderId": "1111453253721796609",
|
4970
|
+
# "clientOid": "2ae7fc8a4ff949b6b60d770ca3950e2d"
|
4971
|
+
# },
|
4972
|
+
# ],
|
4973
|
+
# "failure": []
|
4974
|
+
# }
|
4975
|
+
# }
|
4976
|
+
#
|
4663
4977
|
else:
|
4664
|
-
if
|
4665
|
-
stopRequest = {
|
4978
|
+
if trigger:
|
4979
|
+
stopRequest: dict = {
|
4666
4980
|
'symbolList': [market['id']],
|
4667
4981
|
}
|
4668
4982
|
response = await self.privateSpotPostV2SpotTradeBatchCancelPlanOrder(self.extend(stopRequest, params))
|
4669
4983
|
else:
|
4670
4984
|
response = await self.privateSpotPostV2SpotTradeCancelSymbolOrder(self.extend(request, params))
|
4985
|
+
#
|
4986
|
+
# {
|
4987
|
+
# "code": "00000",
|
4988
|
+
# "msg": "success",
|
4989
|
+
# "requestTime": 1700716953996,
|
4990
|
+
# "data": {
|
4991
|
+
# "symbol": "BTCUSDT"
|
4992
|
+
# }
|
4993
|
+
# }
|
4994
|
+
#
|
4995
|
+
timestamp = self.safe_integer(response, 'requestTime')
|
4996
|
+
responseData = self.safe_dict(response, 'data')
|
4997
|
+
marketId = self.safe_string(responseData, 'symbol')
|
4998
|
+
return [
|
4999
|
+
self.safe_order({
|
5000
|
+
'info': response,
|
5001
|
+
'symbol': self.safe_symbol(marketId, None, None, 'spot'),
|
5002
|
+
'timestamp': timestamp,
|
5003
|
+
'datetime': self.iso8601(timestamp),
|
5004
|
+
}),
|
5005
|
+
]
|
4671
5006
|
else:
|
4672
5007
|
productType = None
|
4673
5008
|
productType, params = self.handle_product_type_and_params(market, params)
|
4674
5009
|
request['productType'] = productType
|
4675
|
-
if
|
5010
|
+
if trigger:
|
4676
5011
|
response = await self.privateMixPostV2MixOrderCancelPlanOrder(self.extend(request, params))
|
4677
5012
|
else:
|
4678
5013
|
response = await self.privateMixPostV2MixOrderBatchCancelOrders(self.extend(request, params))
|
4679
|
-
|
4680
|
-
|
4681
|
-
|
4682
|
-
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4686
|
-
|
4687
|
-
|
4688
|
-
|
4689
|
-
|
4690
|
-
|
4691
|
-
|
4692
|
-
|
4693
|
-
|
4694
|
-
|
4695
|
-
|
4696
|
-
|
4697
|
-
|
4698
|
-
|
4699
|
-
|
4700
|
-
|
4701
|
-
|
4702
|
-
|
4703
|
-
|
4704
|
-
|
4705
|
-
|
4706
|
-
|
4707
|
-
|
4708
|
-
|
4709
|
-
|
4710
|
-
|
4711
|
-
|
4712
|
-
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
|
4717
|
-
|
4718
|
-
|
4719
|
-
|
4720
|
-
|
4721
|
-
|
4722
|
-
|
4723
|
-
|
4724
|
-
|
4725
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
|
4729
|
-
|
4730
|
-
|
4731
|
-
|
4732
|
-
|
4733
|
-
:
|
4734
|
-
|
4735
|
-
"""
|
4736
|
-
if symbol is None:
|
4737
|
-
raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
|
4738
|
-
await self.load_markets()
|
4739
|
-
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
4740
|
-
market = None
|
4741
|
-
if sandboxMode:
|
4742
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
4743
|
-
market = self.market(sandboxSymbol)
|
4744
|
-
else:
|
4745
|
-
market = self.market(symbol)
|
4746
|
-
request = {
|
4747
|
-
'orderId': id,
|
4748
|
-
}
|
4749
|
-
response = None
|
4750
|
-
if market['spot']:
|
4751
|
-
response = await self.privateSpotGetV2SpotTradeOrderInfo(self.extend(request, params))
|
4752
|
-
elif market['swap'] or market['future']:
|
4753
|
-
request['symbol'] = market['id']
|
4754
|
-
productType = None
|
4755
|
-
productType, params = self.handle_product_type_and_params(market, params)
|
4756
|
-
request['productType'] = productType
|
4757
|
-
response = await self.privateMixGetV2MixOrderDetail(self.extend(request, params))
|
4758
|
-
else:
|
4759
|
-
raise NotSupported(self.id + ' fetchOrder() does not support ' + market['type'] + ' orders')
|
5014
|
+
# {
|
5015
|
+
# "code": "00000",
|
5016
|
+
# "msg": "success",
|
5017
|
+
# "requestTime": "1680008815965",
|
5018
|
+
# "data": {
|
5019
|
+
# "successList": [
|
5020
|
+
# {
|
5021
|
+
# "orderId": "1024598257429823488",
|
5022
|
+
# "clientOid": "876493ce-c287-4bfc-9f4a-8b1905881313"
|
5023
|
+
# },
|
5024
|
+
# ],
|
5025
|
+
# "failureList": []
|
5026
|
+
# }
|
5027
|
+
# }
|
5028
|
+
data = self.safe_dict(response, 'data')
|
5029
|
+
resultList = self.safe_list_2(data, 'resultList', 'successList')
|
5030
|
+
failureList = self.safe_list_2(data, 'failure', 'failureList')
|
5031
|
+
responseList = self.array_concat(resultList, failureList)
|
5032
|
+
return self.parse_orders(responseList)
|
5033
|
+
|
5034
|
+
async def fetch_order(self, id: str, symbol: Str = None, params={}):
|
5035
|
+
"""
|
5036
|
+
fetches information on an order made by the user
|
5037
|
+
|
5038
|
+
https://www.bitget.com/api-doc/spot/trade/Get-Order-Info
|
5039
|
+
https://www.bitget.com/api-doc/contract/trade/Get-Order-Details
|
5040
|
+
|
5041
|
+
:param str id: the order id
|
5042
|
+
:param str symbol: unified symbol of the market the order was made in
|
5043
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5044
|
+
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
5045
|
+
"""
|
5046
|
+
if symbol is None:
|
5047
|
+
raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
|
5048
|
+
await self.load_markets()
|
5049
|
+
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
5050
|
+
market = None
|
5051
|
+
if sandboxMode:
|
5052
|
+
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
5053
|
+
market = self.market(sandboxSymbol)
|
5054
|
+
else:
|
5055
|
+
market = self.market(symbol)
|
5056
|
+
request: dict = {
|
5057
|
+
'orderId': id,
|
5058
|
+
}
|
5059
|
+
response = None
|
5060
|
+
if market['spot']:
|
5061
|
+
response = await self.privateSpotGetV2SpotTradeOrderInfo(self.extend(request, params))
|
5062
|
+
elif market['swap'] or market['future']:
|
5063
|
+
request['symbol'] = market['id']
|
5064
|
+
productType = None
|
5065
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
5066
|
+
request['productType'] = productType
|
5067
|
+
response = await self.privateMixGetV2MixOrderDetail(self.extend(request, params))
|
5068
|
+
else:
|
5069
|
+
raise NotSupported(self.id + ' fetchOrder() does not support ' + market['type'] + ' orders')
|
4760
5070
|
#
|
4761
5071
|
# spot
|
4762
5072
|
#
|
@@ -4826,26 +5136,34 @@ class bitget(Exchange, ImplicitAPI):
|
|
4826
5136
|
#
|
4827
5137
|
if isinstance(response, str):
|
4828
5138
|
response = json.loads(response)
|
4829
|
-
data = self.
|
4830
|
-
|
5139
|
+
data = self.safe_dict(response, 'data')
|
5140
|
+
if (data is not None):
|
5141
|
+
if not isinstance(data, list):
|
5142
|
+
return self.parse_order(data, market)
|
5143
|
+
dataList = self.safe_list(response, 'data', [])
|
5144
|
+
first = self.safe_dict(dataList, 0, {})
|
4831
5145
|
return self.parse_order(first, market)
|
5146
|
+
# first = self.safe_dict(data, 0, data)
|
5147
|
+
# return self.parse_order(first, market)
|
4832
5148
|
|
4833
5149
|
async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
4834
5150
|
"""
|
4835
5151
|
fetch all unfilled currently open orders
|
4836
|
-
|
4837
|
-
|
4838
|
-
|
4839
|
-
|
4840
|
-
|
4841
|
-
|
5152
|
+
|
5153
|
+
https://www.bitget.com/api-doc/spot/trade/Get-Unfilled-Orders
|
5154
|
+
https://www.bitget.com/api-doc/spot/plan/Get-Current-Plan-Order
|
5155
|
+
https://www.bitget.com/api-doc/contract/trade/Get-Orders-Pending
|
5156
|
+
https://www.bitget.com/api-doc/contract/plan/get-orders-plan-pending
|
5157
|
+
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Open-Orders
|
5158
|
+
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Open-Orders
|
5159
|
+
|
4842
5160
|
:param str symbol: unified market symbol
|
4843
5161
|
:param int [since]: the earliest time in ms to fetch open orders for
|
4844
5162
|
:param int [limit]: the maximum number of open order structures to retrieve
|
4845
5163
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4846
5164
|
:param int [params.until]: the latest time in ms to fetch orders for
|
4847
5165
|
:param str [params.planType]: *contract stop only* 'normal_plan': average trigger order, 'profit_loss': opened tp/sl orders, 'track_plan': trailing stop order, default is 'normal_plan'
|
4848
|
-
:param boolean [params.
|
5166
|
+
:param boolean [params.trigger]: set to True for fetching trigger orders
|
4849
5167
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
4850
5168
|
:param str [params.isPlan]: *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
|
4851
5169
|
:param boolean [params.trailing]: set to True if you want to fetch trailing orders
|
@@ -4855,7 +5173,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4855
5173
|
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
4856
5174
|
market = None
|
4857
5175
|
type = None
|
4858
|
-
request = {}
|
5176
|
+
request: dict = {}
|
4859
5177
|
marginMode = None
|
4860
5178
|
marginMode, params = self.handle_margin_mode_and_params('fetchOpenOrders', params)
|
4861
5179
|
if symbol is not None:
|
@@ -4883,9 +5201,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
4883
5201
|
return await self.fetch_paginated_call_cursor('fetchOpenOrders', symbol, since, limit, params, cursorReceived, 'idLessThan')
|
4884
5202
|
response = None
|
4885
5203
|
trailing = self.safe_bool(params, 'trailing')
|
4886
|
-
|
5204
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
4887
5205
|
planTypeDefined = self.safe_string(params, 'planType') is not None
|
4888
|
-
|
5206
|
+
isTrigger = (trigger or planTypeDefined)
|
4889
5207
|
params = self.omit(params, ['stop', 'trigger', 'trailing'])
|
4890
5208
|
request, params = self.handle_until_option('endTime', request, params)
|
4891
5209
|
if since is not None:
|
@@ -4909,7 +5227,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4909
5227
|
elif marginMode == 'cross':
|
4910
5228
|
response = await self.privateMarginGetV2MarginCrossedOpenOrders(self.extend(request, query))
|
4911
5229
|
else:
|
4912
|
-
if
|
5230
|
+
if trigger:
|
4913
5231
|
response = await self.privateSpotGetV2SpotTradeCurrentPlanOrder(self.extend(request, query))
|
4914
5232
|
else:
|
4915
5233
|
response = await self.privateSpotGetV2SpotTradeUnfilledOrders(self.extend(request, query))
|
@@ -4921,7 +5239,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4921
5239
|
planType = self.safe_string(params, 'planType', 'track_plan')
|
4922
5240
|
request['planType'] = planType
|
4923
5241
|
response = await self.privateMixGetV2MixOrderOrdersPlanPending(self.extend(request, query))
|
4924
|
-
elif
|
5242
|
+
elif isTrigger:
|
4925
5243
|
planType = self.safe_string(query, 'planType', 'normal_plan')
|
4926
5244
|
request['planType'] = planType
|
4927
5245
|
response = await self.privateMixGetV2MixOrderOrdersPlanPending(self.extend(request, query))
|
@@ -5104,23 +5422,25 @@ class bitget(Exchange, ImplicitAPI):
|
|
5104
5422
|
#
|
5105
5423
|
data = self.safe_value(response, 'data')
|
5106
5424
|
if type == 'spot':
|
5107
|
-
if (marginMode is not None) or
|
5108
|
-
resultList = self.
|
5425
|
+
if (marginMode is not None) or trigger:
|
5426
|
+
resultList = self.safe_list(data, 'orderList', [])
|
5109
5427
|
return self.parse_orders(resultList, market, since, limit)
|
5110
5428
|
else:
|
5111
|
-
result = self.
|
5429
|
+
result = self.safe_list(data, 'entrustedList', [])
|
5112
5430
|
return self.parse_orders(result, market, since, limit)
|
5113
5431
|
return self.parse_orders(data, market, since, limit)
|
5114
5432
|
|
5115
5433
|
async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
5116
5434
|
"""
|
5117
5435
|
fetches information on multiple closed orders made by the user
|
5118
|
-
|
5119
|
-
|
5120
|
-
|
5121
|
-
|
5122
|
-
|
5123
|
-
|
5436
|
+
|
5437
|
+
https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
|
5438
|
+
https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
|
5439
|
+
https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
|
5440
|
+
https://www.bitget.com/api-doc/contract/plan/orders-plan-history
|
5441
|
+
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
|
5442
|
+
https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
|
5443
|
+
|
5124
5444
|
:param str symbol: unified market symbol of the closed orders
|
5125
5445
|
:param int [since]: timestamp in ms of the earliest order
|
5126
5446
|
:param int [limit]: the max number of closed orders to return
|
@@ -5139,12 +5459,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
5139
5459
|
async def fetch_canceled_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
5140
5460
|
"""
|
5141
5461
|
fetches information on multiple canceled orders made by the user
|
5142
|
-
|
5143
|
-
|
5144
|
-
|
5145
|
-
|
5146
|
-
|
5147
|
-
|
5462
|
+
|
5463
|
+
https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
|
5464
|
+
https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
|
5465
|
+
https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
|
5466
|
+
https://www.bitget.com/api-doc/contract/plan/orders-plan-history
|
5467
|
+
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
|
5468
|
+
https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
|
5469
|
+
|
5148
5470
|
:param str symbol: unified market symbol of the canceled orders
|
5149
5471
|
:param int [since]: timestamp in ms of the earliest order
|
5150
5472
|
:param int [limit]: the max number of canceled orders to return
|
@@ -5162,12 +5484,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
5162
5484
|
|
5163
5485
|
async def fetch_canceled_and_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
5164
5486
|
"""
|
5165
|
-
|
5166
|
-
|
5167
|
-
|
5168
|
-
|
5169
|
-
|
5170
|
-
|
5487
|
+
|
5488
|
+
https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
|
5489
|
+
https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
|
5490
|
+
https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
|
5491
|
+
https://www.bitget.com/api-doc/contract/plan/orders-plan-history
|
5492
|
+
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
|
5493
|
+
https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
|
5494
|
+
|
5171
5495
|
fetches information on multiple canceled and closed orders made by the user
|
5172
5496
|
:param str symbol: unified market symbol of the market orders were made in
|
5173
5497
|
:param int [since]: the earliest time in ms to fetch orders for
|
@@ -5182,7 +5506,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5182
5506
|
if symbol is not None:
|
5183
5507
|
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
5184
5508
|
symbol = sandboxSymbol
|
5185
|
-
request = {}
|
5509
|
+
request: dict = {}
|
5186
5510
|
if symbol is not None:
|
5187
5511
|
market = self.market(symbol)
|
5188
5512
|
request['symbol'] = market['id']
|
@@ -5202,7 +5526,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5202
5526
|
return await self.fetch_paginated_call_cursor('fetchCanceledAndClosedOrders', symbol, since, limit, params, cursorReceived, 'idLessThan')
|
5203
5527
|
response = None
|
5204
5528
|
trailing = self.safe_value(params, 'trailing')
|
5205
|
-
|
5529
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
5206
5530
|
params = self.omit(params, ['stop', 'trigger', 'trailing'])
|
5207
5531
|
request, params = self.handle_until_option('endTime', request, params)
|
5208
5532
|
if since is not None:
|
@@ -5224,20 +5548,19 @@ class bitget(Exchange, ImplicitAPI):
|
|
5224
5548
|
response = await self.privateMarginGetV2MarginIsolatedHistoryOrders(self.extend(request, params))
|
5225
5549
|
elif marginMode == 'cross':
|
5226
5550
|
response = await self.privateMarginGetV2MarginCrossedHistoryOrders(self.extend(request, params))
|
5551
|
+
elif trigger:
|
5552
|
+
if symbol is None:
|
5553
|
+
raise ArgumentsRequired(self.id + ' fetchCanceledAndClosedOrders() requires a symbol argument')
|
5554
|
+
endTime = self.safe_integer_n(params, ['endTime', 'until'])
|
5555
|
+
params = self.omit(params, ['until'])
|
5556
|
+
if since is None:
|
5557
|
+
since = now - 7776000000
|
5558
|
+
request['startTime'] = since
|
5559
|
+
if endTime is None:
|
5560
|
+
request['endTime'] = now
|
5561
|
+
response = await self.privateSpotGetV2SpotTradeHistoryPlanOrder(self.extend(request, params))
|
5227
5562
|
else:
|
5228
|
-
|
5229
|
-
if symbol is None:
|
5230
|
-
raise ArgumentsRequired(self.id + ' fetchCanceledAndClosedOrders() requires a symbol argument')
|
5231
|
-
endTime = self.safe_integer_n(params, ['endTime', 'until', 'till'])
|
5232
|
-
params = self.omit(params, ['until', 'till'])
|
5233
|
-
if since is None:
|
5234
|
-
since = now - 7776000000
|
5235
|
-
request['startTime'] = since
|
5236
|
-
if endTime is None:
|
5237
|
-
request['endTime'] = now
|
5238
|
-
response = await self.privateSpotGetV2SpotTradeHistoryPlanOrder(self.extend(request, params))
|
5239
|
-
else:
|
5240
|
-
response = await self.privateSpotGetV2SpotTradeHistoryOrders(self.extend(request, params))
|
5563
|
+
response = await self.privateSpotGetV2SpotTradeHistoryOrders(self.extend(request, params))
|
5241
5564
|
else:
|
5242
5565
|
productType = None
|
5243
5566
|
productType, params = self.handle_product_type_and_params(market, params)
|
@@ -5246,7 +5569,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5246
5569
|
planType = self.safe_string(params, 'planType', 'track_plan')
|
5247
5570
|
request['planType'] = planType
|
5248
5571
|
response = await self.privateMixGetV2MixOrderOrdersPlanHistory(self.extend(request, params))
|
5249
|
-
elif
|
5572
|
+
elif trigger:
|
5250
5573
|
planType = self.safe_string(params, 'planType', 'normal_plan')
|
5251
5574
|
request['planType'] = planType
|
5252
5575
|
response = await self.privateMixGetV2MixOrderOrdersPlanHistory(self.extend(request, params))
|
@@ -5432,29 +5755,31 @@ class bitget(Exchange, ImplicitAPI):
|
|
5432
5755
|
#
|
5433
5756
|
data = self.safe_value(response, 'data', {})
|
5434
5757
|
if marketType == 'spot':
|
5435
|
-
if (marginMode is not None) or
|
5758
|
+
if (marginMode is not None) or trigger:
|
5436
5759
|
return self.parse_orders(self.safe_value(data, 'orderList', []), market, since, limit)
|
5437
5760
|
else:
|
5438
5761
|
return self.parse_orders(self.safe_value(data, 'entrustedList', []), market, since, limit)
|
5439
5762
|
if isinstance(response, str):
|
5440
5763
|
response = json.loads(response)
|
5441
|
-
orders = self.
|
5764
|
+
orders = self.safe_list(response, 'data', [])
|
5442
5765
|
return self.parse_orders(orders, market, since, limit)
|
5443
5766
|
|
5444
|
-
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
5767
|
+
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
5445
5768
|
"""
|
5446
|
-
|
5447
|
-
|
5448
|
-
|
5449
|
-
|
5769
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
5770
|
+
|
5771
|
+
https://www.bitget.com/api-doc/spot/account/Get-Account-Bills
|
5772
|
+
https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
|
5773
|
+
|
5774
|
+
:param str [code]: unified currency code, default is None
|
5450
5775
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
5451
|
-
:param int [limit]: max number of ledger
|
5776
|
+
:param int [limit]: max number of ledger entries to return, default is None
|
5452
5777
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5453
5778
|
:param int [params.until]: end time in ms
|
5454
5779
|
:param str [params.symbol]: *contract only* unified market symbol
|
5455
5780
|
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
5456
5781
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
5457
|
-
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger
|
5782
|
+
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
|
5458
5783
|
"""
|
5459
5784
|
await self.load_markets()
|
5460
5785
|
symbol = self.safe_string(params, 'symbol')
|
@@ -5477,10 +5802,10 @@ class bitget(Exchange, ImplicitAPI):
|
|
5477
5802
|
cursorReceived = 'endId'
|
5478
5803
|
return await self.fetch_paginated_call_cursor('fetchLedger', symbol, since, limit, params, cursorReceived, 'idLessThan')
|
5479
5804
|
currency = None
|
5480
|
-
request = {}
|
5805
|
+
request: dict = {}
|
5481
5806
|
if code is not None:
|
5482
5807
|
currency = self.currency(code)
|
5483
|
-
request['coin'] = currency['
|
5808
|
+
request['coin'] = currency['id']
|
5484
5809
|
request, params = self.handle_until_option('endTime', request, params)
|
5485
5810
|
if since is not None:
|
5486
5811
|
request['startTime'] = since
|
@@ -5546,7 +5871,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5546
5871
|
return self.parse_ledger(bills, currency, since, limit)
|
5547
5872
|
return self.parse_ledger(data, currency, since, limit)
|
5548
5873
|
|
5549
|
-
def parse_ledger_entry(self, item, currency: Currency = None):
|
5874
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
5550
5875
|
#
|
5551
5876
|
# spot
|
5552
5877
|
#
|
@@ -5576,6 +5901,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5576
5901
|
#
|
5577
5902
|
currencyId = self.safe_string(item, 'coin')
|
5578
5903
|
code = self.safe_currency_code(currencyId, currency)
|
5904
|
+
currency = self.safe_currency(currencyId, currency)
|
5579
5905
|
timestamp = self.safe_integer(item, 'cTime')
|
5580
5906
|
after = self.safe_number(item, 'balance')
|
5581
5907
|
fee = self.safe_number_2(item, 'fees', 'fee')
|
@@ -5584,7 +5910,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5584
5910
|
direction = 'in'
|
5585
5911
|
if amountRaw.find('-') >= 0:
|
5586
5912
|
direction = 'out'
|
5587
|
-
return {
|
5913
|
+
return self.safe_ledger_entry({
|
5588
5914
|
'info': item,
|
5589
5915
|
'id': self.safe_string(item, 'billId'),
|
5590
5916
|
'timestamp': timestamp,
|
@@ -5599,11 +5925,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
5599
5925
|
'before': None,
|
5600
5926
|
'after': after,
|
5601
5927
|
'status': None,
|
5602
|
-
'fee':
|
5603
|
-
|
5928
|
+
'fee': {
|
5929
|
+
'currency': code,
|
5930
|
+
'cost': fee,
|
5931
|
+
},
|
5932
|
+
}, currency)
|
5604
5933
|
|
5605
5934
|
def parse_ledger_type(self, type):
|
5606
|
-
types = {
|
5935
|
+
types: dict = {
|
5607
5936
|
'trans_to_cross': 'transfer',
|
5608
5937
|
'trans_from_cross': 'transfer',
|
5609
5938
|
'trans_to_exchange': 'transfer',
|
@@ -5650,10 +5979,12 @@ class bitget(Exchange, ImplicitAPI):
|
|
5650
5979
|
async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
5651
5980
|
"""
|
5652
5981
|
fetch all trades made by the user
|
5653
|
-
|
5654
|
-
|
5655
|
-
|
5656
|
-
|
5982
|
+
|
5983
|
+
https://www.bitget.com/api-doc/spot/trade/Get-Fills
|
5984
|
+
https://www.bitget.com/api-doc/contract/trade/Get-Order-Fills
|
5985
|
+
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-Fills
|
5986
|
+
https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Transaction-Details
|
5987
|
+
|
5657
5988
|
:param str symbol: unified market symbol
|
5658
5989
|
:param int [since]: the earliest time in ms to fetch trades for
|
5659
5990
|
:param int [limit]: the maximum number of trades structures to retrieve
|
@@ -5685,7 +6016,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5685
6016
|
cursorReceived = 'endId'
|
5686
6017
|
return await self.fetch_paginated_call_cursor('fetchMyTrades', symbol, since, limit, params, cursorReceived, 'idLessThan')
|
5687
6018
|
response = None
|
5688
|
-
request = {
|
6019
|
+
request: dict = {
|
5689
6020
|
'symbol': market['id'],
|
5690
6021
|
}
|
5691
6022
|
request, params = self.handle_until_option('endTime', request, params)
|
@@ -5809,17 +6140,19 @@ class bitget(Exchange, ImplicitAPI):
|
|
5809
6140
|
#
|
5810
6141
|
data = self.safe_value(response, 'data')
|
5811
6142
|
if (market['swap']) or (market['future']):
|
5812
|
-
fillList = self.
|
6143
|
+
fillList = self.safe_list(data, 'fillList', [])
|
5813
6144
|
return self.parse_trades(fillList, market, since, limit)
|
5814
6145
|
elif marginMode is not None:
|
5815
|
-
fills = self.
|
6146
|
+
fills = self.safe_list(data, 'fills', [])
|
5816
6147
|
return self.parse_trades(fills, market, since, limit)
|
5817
6148
|
return self.parse_trades(data, market, since, limit)
|
5818
6149
|
|
5819
6150
|
async def fetch_position(self, symbol: str, params={}):
|
5820
6151
|
"""
|
5821
6152
|
fetch data on a single open contract trade position
|
5822
|
-
|
6153
|
+
|
6154
|
+
https://www.bitget.com/api-doc/contract/position/get-single-position
|
6155
|
+
|
5823
6156
|
:param str symbol: unified market symbol of the market the position is held in
|
5824
6157
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5825
6158
|
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
@@ -5834,7 +6167,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5834
6167
|
market = self.market(symbol)
|
5835
6168
|
productType = None
|
5836
6169
|
productType, params = self.handle_product_type_and_params(market, params)
|
5837
|
-
request = {
|
6170
|
+
request: dict = {
|
5838
6171
|
'symbol': market['id'],
|
5839
6172
|
'marginCoin': market['settleId'],
|
5840
6173
|
'productType': productType,
|
@@ -5870,15 +6203,17 @@ class bitget(Exchange, ImplicitAPI):
|
|
5870
6203
|
# ]
|
5871
6204
|
# }
|
5872
6205
|
#
|
5873
|
-
data = self.
|
5874
|
-
first = self.
|
6206
|
+
data = self.safe_list(response, 'data', [])
|
6207
|
+
first = self.safe_dict(data, 0, {})
|
5875
6208
|
return self.parse_position(first, market)
|
5876
6209
|
|
5877
6210
|
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
5878
6211
|
"""
|
5879
6212
|
fetch all open positions
|
5880
|
-
|
5881
|
-
|
6213
|
+
|
6214
|
+
https://www.bitget.com/api-doc/contract/position/get-all-position
|
6215
|
+
https://www.bitget.com/api-doc/contract/position/Get-History-Position
|
6216
|
+
|
5882
6217
|
:param str[] [symbols]: list of unified market symbols
|
5883
6218
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5884
6219
|
:param str [params.marginCoin]: the settle currency of the positions, needs to match the productType
|
@@ -5910,7 +6245,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5910
6245
|
market = self.market(first)
|
5911
6246
|
productType = None
|
5912
6247
|
productType, params = self.handle_product_type_and_params(market, params)
|
5913
|
-
request = {
|
6248
|
+
request: dict = {
|
5914
6249
|
'productType': productType,
|
5915
6250
|
}
|
5916
6251
|
response = None
|
@@ -6011,7 +6346,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6011
6346
|
symbols = self.market_symbols(symbols)
|
6012
6347
|
return self.filter_by_array_positions(result, 'symbol', symbols, False)
|
6013
6348
|
|
6014
|
-
def parse_position(self, position, market: Market = None):
|
6349
|
+
def parse_position(self, position: dict, market: Market = None):
|
6015
6350
|
#
|
6016
6351
|
# fetchPosition
|
6017
6352
|
#
|
@@ -6061,7 +6396,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6061
6396
|
# "cTime": "1700807507275"
|
6062
6397
|
# }
|
6063
6398
|
#
|
6064
|
-
#
|
6399
|
+
# fetchPositionsHistory: privateMixGetV2MixPositionHistoryPosition
|
6065
6400
|
#
|
6066
6401
|
# {
|
6067
6402
|
# "symbol": "BTCUSDT",
|
@@ -6177,7 +6512,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
6177
6512
|
async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
6178
6513
|
"""
|
6179
6514
|
fetches historical funding rate prices
|
6180
|
-
|
6515
|
+
|
6516
|
+
https://www.bitget.com/api-doc/contract/market/Get-History-Funding-Rate
|
6517
|
+
|
6181
6518
|
:param str symbol: unified symbol of the market to fetch the funding rate history for
|
6182
6519
|
:param int [since]: timestamp in ms of the earliest funding rate to fetch
|
6183
6520
|
:param int [limit]: the maximum amount of funding rate structures to fetch
|
@@ -6201,7 +6538,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6201
6538
|
market = self.market(symbol)
|
6202
6539
|
productType = None
|
6203
6540
|
productType, params = self.handle_product_type_and_params(market, params)
|
6204
|
-
request = {
|
6541
|
+
request: dict = {
|
6205
6542
|
'symbol': market['id'],
|
6206
6543
|
'productType': productType,
|
6207
6544
|
# 'pageSize': limit, # default 20
|
@@ -6241,10 +6578,12 @@ class bitget(Exchange, ImplicitAPI):
|
|
6241
6578
|
sorted = self.sort_by(rates, 'timestamp')
|
6242
6579
|
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
6243
6580
|
|
6244
|
-
async def fetch_funding_rate(self, symbol: str, params={}):
|
6581
|
+
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
6245
6582
|
"""
|
6246
6583
|
fetch the current funding rate
|
6247
|
-
|
6584
|
+
|
6585
|
+
https://www.bitget.com/api-doc/contract/market/Get-Current-Funding-Rate
|
6586
|
+
|
6248
6587
|
:param str symbol: unified market symbol
|
6249
6588
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
6250
6589
|
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
@@ -6261,7 +6600,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6261
6600
|
raise BadSymbol(self.id + ' fetchFundingRate() supports swap contracts only')
|
6262
6601
|
productType = None
|
6263
6602
|
productType, params = self.handle_product_type_and_params(market, params)
|
6264
|
-
request = {
|
6603
|
+
request: dict = {
|
6265
6604
|
'symbol': market['id'],
|
6266
6605
|
'productType': productType,
|
6267
6606
|
}
|
@@ -6282,39 +6621,148 @@ class bitget(Exchange, ImplicitAPI):
|
|
6282
6621
|
data = self.safe_value(response, 'data', [])
|
6283
6622
|
return self.parse_funding_rate(data[0], market)
|
6284
6623
|
|
6285
|
-
def
|
6624
|
+
async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
6625
|
+
"""
|
6626
|
+
fetch the current funding rates for all markets
|
6627
|
+
|
6628
|
+
https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker
|
6629
|
+
|
6630
|
+
:param str[] [symbols]: list of unified market symbols
|
6631
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
6632
|
+
:param str [params.subType]: *contract only* 'linear', 'inverse'
|
6633
|
+
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
6634
|
+
:returns dict: a dictionary of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
|
6635
|
+
"""
|
6636
|
+
await self.load_markets()
|
6637
|
+
market = None
|
6638
|
+
if symbols is not None:
|
6639
|
+
symbol = self.safe_value(symbols, 0)
|
6640
|
+
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
6641
|
+
if sandboxMode:
|
6642
|
+
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
6643
|
+
market = self.market(sandboxSymbol)
|
6644
|
+
else:
|
6645
|
+
market = self.market(symbol)
|
6646
|
+
request: dict = {}
|
6647
|
+
productType = None
|
6648
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
6649
|
+
request['productType'] = productType
|
6650
|
+
response = await self.publicMixGetV2MixMarketTickers(self.extend(request, params))
|
6651
|
+
# {
|
6652
|
+
# "code": "00000",
|
6653
|
+
# "msg": "success",
|
6654
|
+
# "requestTime": 1700533773477,
|
6655
|
+
# "data": [
|
6656
|
+
# {
|
6657
|
+
# "symbol": "BTCUSD",
|
6658
|
+
# "lastPr": "29904.5",
|
6659
|
+
# "askPr": "29904.5",
|
6660
|
+
# "bidPr": "29903.5",
|
6661
|
+
# "bidSz": "0.5091",
|
6662
|
+
# "askSz": "2.2694",
|
6663
|
+
# "high24h": "0",
|
6664
|
+
# "low24h": "0",
|
6665
|
+
# "ts": "1695794271400",
|
6666
|
+
# "change24h": "0",
|
6667
|
+
# "baseVolume": "0",
|
6668
|
+
# "quoteVolume": "0",
|
6669
|
+
# "usdtVolume": "0",
|
6670
|
+
# "openUtc": "0",
|
6671
|
+
# "changeUtc24h": "0",
|
6672
|
+
# "indexPrice": "29132.353333",
|
6673
|
+
# "fundingRate": "-0.0007",
|
6674
|
+
# "holdingAmount": "125.6844",
|
6675
|
+
# "deliveryStartTime": null,
|
6676
|
+
# "deliveryTime": null,
|
6677
|
+
# "deliveryStatus": "delivery_normal",
|
6678
|
+
# "open24h": "0",
|
6679
|
+
# "markPrice": "12345"
|
6680
|
+
# },
|
6681
|
+
# ]
|
6682
|
+
# }
|
6683
|
+
symbols = self.market_symbols(symbols)
|
6684
|
+
data = self.safe_list(response, 'data', [])
|
6685
|
+
return self.parse_funding_rates(data, symbols)
|
6686
|
+
|
6687
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
6688
|
+
#
|
6689
|
+
# fetchFundingRate
|
6286
6690
|
#
|
6287
6691
|
# {
|
6288
6692
|
# "symbol": "BTCUSDT",
|
6289
6693
|
# "fundingRate": "-0.000182"
|
6290
6694
|
# }
|
6291
6695
|
#
|
6696
|
+
# fetchFundingInterval
|
6697
|
+
#
|
6698
|
+
# {
|
6699
|
+
# "symbol": "BTCUSDT",
|
6700
|
+
# "nextFundingTime": "1727942400000",
|
6701
|
+
# "ratePeriod": "8"
|
6702
|
+
# }
|
6703
|
+
# fetchFundingRates
|
6704
|
+
# {
|
6705
|
+
# "symbol": "BTCUSD",
|
6706
|
+
# "lastPr": "29904.5",
|
6707
|
+
# "askPr": "29904.5",
|
6708
|
+
# "bidPr": "29903.5",
|
6709
|
+
# "bidSz": "0.5091",
|
6710
|
+
# "askSz": "2.2694",
|
6711
|
+
# "high24h": "0",
|
6712
|
+
# "low24h": "0",
|
6713
|
+
# "ts": "1695794271400",
|
6714
|
+
# "change24h": "0",
|
6715
|
+
# "baseVolume": "0",
|
6716
|
+
# "quoteVolume": "0",
|
6717
|
+
# "usdtVolume": "0",
|
6718
|
+
# "openUtc": "0",
|
6719
|
+
# "changeUtc24h": "0",
|
6720
|
+
# "indexPrice": "29132.353333",
|
6721
|
+
# "fundingRate": "-0.0007",
|
6722
|
+
# "holdingAmount": "125.6844",
|
6723
|
+
# "deliveryStartTime": null,
|
6724
|
+
# "deliveryTime": null,
|
6725
|
+
# "deliveryStatus": "delivery_normal",
|
6726
|
+
# "open24h": "0",
|
6727
|
+
# "markPrice": "12345"
|
6728
|
+
# }
|
6292
6729
|
marketId = self.safe_string(contract, 'symbol')
|
6293
6730
|
symbol = self.safe_symbol(marketId, market, None, 'swap')
|
6731
|
+
fundingTimestamp = self.safe_integer(contract, 'nextFundingTime')
|
6732
|
+
interval = self.safe_string(contract, 'ratePeriod')
|
6733
|
+
timestamp = self.safe_integer(contract, 'ts')
|
6734
|
+
markPrice = self.safe_number(contract, 'markPrice')
|
6735
|
+
indexPrice = self.safe_number(contract, 'indexPrice')
|
6736
|
+
intervalString = None
|
6737
|
+
if interval is not None:
|
6738
|
+
intervalString = interval + 'h'
|
6294
6739
|
return {
|
6295
6740
|
'info': contract,
|
6296
6741
|
'symbol': symbol,
|
6297
|
-
'markPrice':
|
6298
|
-
'indexPrice':
|
6742
|
+
'markPrice': markPrice,
|
6743
|
+
'indexPrice': indexPrice,
|
6299
6744
|
'interestRate': None,
|
6300
6745
|
'estimatedSettlePrice': None,
|
6301
|
-
'timestamp':
|
6302
|
-
'datetime':
|
6746
|
+
'timestamp': timestamp,
|
6747
|
+
'datetime': self.iso8601(timestamp),
|
6303
6748
|
'fundingRate': self.safe_number(contract, 'fundingRate'),
|
6304
|
-
'fundingTimestamp':
|
6305
|
-
'fundingDatetime':
|
6749
|
+
'fundingTimestamp': fundingTimestamp,
|
6750
|
+
'fundingDatetime': self.iso8601(fundingTimestamp),
|
6306
6751
|
'nextFundingRate': None,
|
6307
6752
|
'nextFundingTimestamp': None,
|
6308
6753
|
'nextFundingDatetime': None,
|
6309
6754
|
'previousFundingRate': None,
|
6310
6755
|
'previousFundingTimestamp': None,
|
6311
6756
|
'previousFundingDatetime': None,
|
6757
|
+
'interval': intervalString,
|
6312
6758
|
}
|
6313
6759
|
|
6314
6760
|
async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[FundingHistory]:
|
6315
6761
|
"""
|
6316
6762
|
fetch the funding history
|
6317
|
-
|
6763
|
+
|
6764
|
+
https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
|
6765
|
+
|
6318
6766
|
:param str symbol: unified market symbol
|
6319
6767
|
:param int [since]: the starting timestamp in milliseconds
|
6320
6768
|
:param int [limit]: the number of entries to return
|
@@ -6341,7 +6789,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6341
6789
|
raise BadSymbol(self.id + ' fetchFundingHistory() supports swap contracts only')
|
6342
6790
|
productType = None
|
6343
6791
|
productType, params = self.handle_product_type_and_params(market, params)
|
6344
|
-
request = {
|
6792
|
+
request: dict = {
|
6345
6793
|
'symbol': market['id'],
|
6346
6794
|
'marginCoin': market['settleId'],
|
6347
6795
|
'businessType': 'contract_settle_fee',
|
@@ -6416,7 +6864,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6416
6864
|
sorted = self.sort_by(result, 'timestamp')
|
6417
6865
|
return self.filter_by_since_limit(sorted, since, limit)
|
6418
6866
|
|
6419
|
-
async def modify_margin_helper(self, symbol: str, amount, type, params={}):
|
6867
|
+
async def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
|
6420
6868
|
await self.load_markets()
|
6421
6869
|
holdSide = self.safe_string(params, 'holdSide')
|
6422
6870
|
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
@@ -6428,7 +6876,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6428
6876
|
market = self.market(symbol)
|
6429
6877
|
productType = None
|
6430
6878
|
productType, params = self.handle_product_type_and_params(market, params)
|
6431
|
-
request = {
|
6879
|
+
request: dict = {
|
6432
6880
|
'symbol': market['id'],
|
6433
6881
|
'marginCoin': market['settleId'],
|
6434
6882
|
'amount': self.amount_to_precision(symbol, amount), # positive value for adding margin, negative for reducing
|
@@ -6450,22 +6898,38 @@ class bitget(Exchange, ImplicitAPI):
|
|
6450
6898
|
'type': type,
|
6451
6899
|
})
|
6452
6900
|
|
6453
|
-
def parse_margin_modification(self, data, market: Market = None):
|
6901
|
+
def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
|
6902
|
+
#
|
6903
|
+
# addMargin/reduceMargin
|
6904
|
+
#
|
6905
|
+
# {
|
6906
|
+
# "code": "00000",
|
6907
|
+
# "msg": "success",
|
6908
|
+
# "requestTime": 1700813444618,
|
6909
|
+
# "data": ""
|
6910
|
+
# }
|
6911
|
+
#
|
6454
6912
|
errorCode = self.safe_string(data, 'code')
|
6455
6913
|
status = 'ok' if (errorCode == '00000') else 'failed'
|
6456
6914
|
return {
|
6457
6915
|
'info': data,
|
6916
|
+
'symbol': market['symbol'],
|
6458
6917
|
'type': None,
|
6918
|
+
'marginMode': 'isolated',
|
6459
6919
|
'amount': None,
|
6920
|
+
'total': None,
|
6460
6921
|
'code': market['settle'],
|
6461
|
-
'symbol': market['symbol'],
|
6462
6922
|
'status': status,
|
6923
|
+
'timestamp': None,
|
6924
|
+
'datetime': None,
|
6463
6925
|
}
|
6464
6926
|
|
6465
|
-
async def reduce_margin(self, symbol: str, amount, params={}):
|
6927
|
+
async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
6466
6928
|
"""
|
6467
6929
|
remove margin from a position
|
6468
|
-
|
6930
|
+
|
6931
|
+
https://www.bitget.com/api-doc/contract/account/Change-Margin
|
6932
|
+
|
6469
6933
|
:param str symbol: unified market symbol
|
6470
6934
|
:param float amount: the amount of margin to remove
|
6471
6935
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -6478,10 +6942,12 @@ class bitget(Exchange, ImplicitAPI):
|
|
6478
6942
|
raise ArgumentsRequired(self.id + ' reduceMargin() requires a holdSide parameter, either long or short')
|
6479
6943
|
return await self.modify_margin_helper(symbol, amount, 'reduce', params)
|
6480
6944
|
|
6481
|
-
async def add_margin(self, symbol: str, amount, params={}):
|
6945
|
+
async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
6482
6946
|
"""
|
6483
6947
|
add margin
|
6484
|
-
|
6948
|
+
|
6949
|
+
https://www.bitget.com/api-doc/contract/account/Change-Margin
|
6950
|
+
|
6485
6951
|
:param str symbol: unified market symbol
|
6486
6952
|
:param float amount: the amount of margin to add
|
6487
6953
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -6495,7 +6961,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
6495
6961
|
async def fetch_leverage(self, symbol: str, params={}) -> Leverage:
|
6496
6962
|
"""
|
6497
6963
|
fetch the set leverage for a market
|
6498
|
-
|
6964
|
+
|
6965
|
+
https://www.bitget.com/api-doc/contract/account/Get-Single-Account
|
6966
|
+
|
6499
6967
|
:param str symbol: unified market symbol
|
6500
6968
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
6501
6969
|
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
|
@@ -6510,7 +6978,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6510
6978
|
market = self.market(symbol)
|
6511
6979
|
productType = None
|
6512
6980
|
productType, params = self.handle_product_type_and_params(market, params)
|
6513
|
-
request = {
|
6981
|
+
request: dict = {
|
6514
6982
|
'symbol': market['id'],
|
6515
6983
|
'marginCoin': market['settleId'],
|
6516
6984
|
'productType': productType,
|
@@ -6547,7 +7015,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6547
7015
|
data = self.safe_dict(response, 'data', {})
|
6548
7016
|
return self.parse_leverage(data, market)
|
6549
7017
|
|
6550
|
-
def parse_leverage(self, leverage, market=None) -> Leverage:
|
7018
|
+
def parse_leverage(self, leverage: dict, market: Market = None) -> Leverage:
|
6551
7019
|
return {
|
6552
7020
|
'info': leverage,
|
6553
7021
|
'symbol': market['symbol'],
|
@@ -6559,7 +7027,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
6559
7027
|
async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
|
6560
7028
|
"""
|
6561
7029
|
set the level of leverage for a market
|
6562
|
-
|
7030
|
+
|
7031
|
+
https://www.bitget.com/api-doc/contract/account/Change-Leverage
|
7032
|
+
|
6563
7033
|
:param int leverage: the rate of leverage
|
6564
7034
|
:param str symbol: unified market symbol
|
6565
7035
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -6578,7 +7048,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6578
7048
|
market = self.market(symbol)
|
6579
7049
|
productType = None
|
6580
7050
|
productType, params = self.handle_product_type_and_params(market, params)
|
6581
|
-
request = {
|
7051
|
+
request: dict = {
|
6582
7052
|
'symbol': market['id'],
|
6583
7053
|
'marginCoin': market['settleId'],
|
6584
7054
|
'leverage': self.number_to_string(leverage),
|
@@ -6606,7 +7076,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
6606
7076
|
async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
|
6607
7077
|
"""
|
6608
7078
|
set margin mode to 'cross' or 'isolated'
|
6609
|
-
|
7079
|
+
|
7080
|
+
https://www.bitget.com/api-doc/contract/account/Change-Margin-Mode
|
7081
|
+
|
6610
7082
|
:param str marginMode: 'cross' or 'isolated'
|
6611
7083
|
:param str symbol: unified market symbol
|
6612
7084
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -6629,7 +7101,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6629
7101
|
market = self.market(symbol)
|
6630
7102
|
productType = None
|
6631
7103
|
productType, params = self.handle_product_type_and_params(market, params)
|
6632
|
-
request = {
|
7104
|
+
request: dict = {
|
6633
7105
|
'symbol': market['id'],
|
6634
7106
|
'marginCoin': market['settleId'],
|
6635
7107
|
'marginMode': marginMode,
|
@@ -6655,7 +7127,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
6655
7127
|
async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
|
6656
7128
|
"""
|
6657
7129
|
set hedged to True or False for a market
|
6658
|
-
|
7130
|
+
|
7131
|
+
https://www.bitget.com/api-doc/contract/account/Change-Hold-Mode
|
7132
|
+
|
6659
7133
|
:param bool hedged: set to True to use dualSidePosition
|
6660
7134
|
:param str symbol: not used by bitget setPositionMode()
|
6661
7135
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -6674,7 +7148,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6674
7148
|
market = self.market(symbol)
|
6675
7149
|
productType = None
|
6676
7150
|
productType, params = self.handle_product_type_and_params(market, params)
|
6677
|
-
request = {
|
7151
|
+
request: dict = {
|
6678
7152
|
'posMode': posMode,
|
6679
7153
|
'productType': productType,
|
6680
7154
|
}
|
@@ -6694,7 +7168,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
6694
7168
|
async def fetch_open_interest(self, symbol: str, params={}):
|
6695
7169
|
"""
|
6696
7170
|
retrieves the open interest of a contract trading pair
|
6697
|
-
|
7171
|
+
|
7172
|
+
https://www.bitget.com/api-doc/contract/market/Get-Open-Interest
|
7173
|
+
|
6698
7174
|
:param str symbol: unified CCXT market symbol
|
6699
7175
|
:param dict [params]: exchange specific parameters
|
6700
7176
|
:returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
|
@@ -6711,7 +7187,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6711
7187
|
raise BadRequest(self.id + ' fetchOpenInterest() supports contract markets only')
|
6712
7188
|
productType = None
|
6713
7189
|
productType, params = self.handle_product_type_and_params(market, params)
|
6714
|
-
request = {
|
7190
|
+
request: dict = {
|
6715
7191
|
'symbol': market['id'],
|
6716
7192
|
'productType': productType,
|
6717
7193
|
}
|
@@ -6732,7 +7208,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6732
7208
|
# }
|
6733
7209
|
# }
|
6734
7210
|
#
|
6735
|
-
data = self.
|
7211
|
+
data = self.safe_dict(response, 'data', {})
|
6736
7212
|
return self.parse_open_interest(data, market)
|
6737
7213
|
|
6738
7214
|
def parse_open_interest(self, interest, market: Market = None):
|
@@ -6759,10 +7235,12 @@ class bitget(Exchange, ImplicitAPI):
|
|
6759
7235
|
'info': interest,
|
6760
7236
|
}, market)
|
6761
7237
|
|
6762
|
-
async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
7238
|
+
async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
|
6763
7239
|
"""
|
6764
7240
|
fetch a history of internal transfers made on an account
|
6765
|
-
|
7241
|
+
|
7242
|
+
https://www.bitget.com/api-doc/spot/account/Get-Account-TransferRecords
|
7243
|
+
|
6766
7244
|
:param str code: unified currency code of the currency transferred
|
6767
7245
|
:param int [since]: the earliest time in ms to fetch transfers for
|
6768
7246
|
:param int [limit]: the maximum number of transfers structures to retrieve
|
@@ -6780,8 +7258,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
6780
7258
|
accountsByType = self.safe_value(self.options, 'accountsByType', {})
|
6781
7259
|
type = self.safe_string(accountsByType, fromAccount)
|
6782
7260
|
currency = self.currency(code)
|
6783
|
-
request = {
|
6784
|
-
'coin': currency['
|
7261
|
+
request: dict = {
|
7262
|
+
'coin': currency['id'],
|
6785
7263
|
'fromType': type,
|
6786
7264
|
}
|
6787
7265
|
if since is not None:
|
@@ -6811,13 +7289,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
6811
7289
|
# ]
|
6812
7290
|
# }
|
6813
7291
|
#
|
6814
|
-
data = self.
|
7292
|
+
data = self.safe_list(response, 'data', [])
|
6815
7293
|
return self.parse_transfers(data, currency, since, limit)
|
6816
7294
|
|
6817
7295
|
async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
|
6818
7296
|
"""
|
6819
7297
|
transfer currency internally between wallets on the same account
|
6820
|
-
|
7298
|
+
|
7299
|
+
https://www.bitget.com/api-doc/spot/account/Wallet-Transfer
|
7300
|
+
|
6821
7301
|
:param str code: unified currency code
|
6822
7302
|
:param float amount: amount to transfer
|
6823
7303
|
:param str fromAccount: account to transfer from
|
@@ -6832,11 +7312,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
6832
7312
|
accountsByType = self.safe_value(self.options, 'accountsByType', {})
|
6833
7313
|
fromType = self.safe_string(accountsByType, fromAccount)
|
6834
7314
|
toType = self.safe_string(accountsByType, toAccount)
|
6835
|
-
request = {
|
7315
|
+
request: dict = {
|
6836
7316
|
'fromType': fromType,
|
6837
7317
|
'toType': toType,
|
6838
7318
|
'amount': amount,
|
6839
|
-
'coin': currency['
|
7319
|
+
'coin': currency['id'],
|
6840
7320
|
}
|
6841
7321
|
symbol = self.safe_string(params, 'symbol')
|
6842
7322
|
params = self.omit(params, 'symbol')
|
@@ -6860,7 +7340,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6860
7340
|
data['ts'] = self.safe_integer(response, 'requestTime')
|
6861
7341
|
return self.parse_transfer(data, currency)
|
6862
7342
|
|
6863
|
-
def parse_transfer(self, transfer, currency: Currency = None):
|
7343
|
+
def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
|
6864
7344
|
#
|
6865
7345
|
# transfer
|
6866
7346
|
#
|
@@ -6905,8 +7385,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
6905
7385
|
'status': self.parse_transfer_status(status),
|
6906
7386
|
}
|
6907
7387
|
|
6908
|
-
def parse_transfer_status(self, status):
|
6909
|
-
statuses = {
|
7388
|
+
def parse_transfer_status(self, status: Str) -> Str:
|
7389
|
+
statuses: dict = {
|
6910
7390
|
'successful': 'ok',
|
6911
7391
|
}
|
6912
7392
|
return self.safe_string(statuses, status, status)
|
@@ -6936,7 +7416,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6936
7416
|
#
|
6937
7417
|
chains = self.safe_value(fee, 'chains', [])
|
6938
7418
|
chainsLength = len(chains)
|
6939
|
-
result = {
|
7419
|
+
result: dict = {
|
6940
7420
|
'info': fee,
|
6941
7421
|
'withdraw': {
|
6942
7422
|
'fee': None,
|
@@ -6965,7 +7445,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
6965
7445
|
async def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
|
6966
7446
|
"""
|
6967
7447
|
fetch deposit and withdraw fees
|
6968
|
-
|
7448
|
+
|
7449
|
+
https://www.bitget.com/api-doc/spot/market/Get-Coin-List
|
7450
|
+
|
6969
7451
|
:param str[]|None codes: list of unified currency codes
|
6970
7452
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
6971
7453
|
:returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
|
@@ -7001,13 +7483,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
7001
7483
|
# "requestTime": "1700120731773"
|
7002
7484
|
# }
|
7003
7485
|
#
|
7004
|
-
data = self.
|
7486
|
+
data = self.safe_list(response, 'data', [])
|
7005
7487
|
return self.parse_deposit_withdraw_fees(data, codes, 'coin')
|
7006
7488
|
|
7007
7489
|
async def borrow_cross_margin(self, code: str, amount: float, params={}):
|
7008
7490
|
"""
|
7009
7491
|
create a loan to borrow margin
|
7010
|
-
|
7492
|
+
|
7493
|
+
https://www.bitget.com/api-doc/margin/cross/account/Cross-Borrow
|
7494
|
+
|
7011
7495
|
:param str code: unified currency code of the currency to borrow
|
7012
7496
|
:param str amount: the amount to borrow
|
7013
7497
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -7015,8 +7499,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
7015
7499
|
"""
|
7016
7500
|
await self.load_markets()
|
7017
7501
|
currency = self.currency(code)
|
7018
|
-
request = {
|
7019
|
-
'coin': currency['
|
7502
|
+
request: dict = {
|
7503
|
+
'coin': currency['id'],
|
7020
7504
|
'borrowAmount': self.currency_to_precision(code, amount),
|
7021
7505
|
}
|
7022
7506
|
response = await self.privateMarginPostV2MarginCrossedAccountBorrow(self.extend(request, params))
|
@@ -7038,7 +7522,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
7038
7522
|
async def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
|
7039
7523
|
"""
|
7040
7524
|
create a loan to borrow margin
|
7041
|
-
|
7525
|
+
|
7526
|
+
https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Borrow
|
7527
|
+
|
7042
7528
|
:param str symbol: unified market symbol
|
7043
7529
|
:param str code: unified currency code of the currency to borrow
|
7044
7530
|
:param str amount: the amount to borrow
|
@@ -7048,8 +7534,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
7048
7534
|
await self.load_markets()
|
7049
7535
|
currency = self.currency(code)
|
7050
7536
|
market = self.market(symbol)
|
7051
|
-
request = {
|
7052
|
-
'coin': currency['
|
7537
|
+
request: dict = {
|
7538
|
+
'coin': currency['id'],
|
7053
7539
|
'borrowAmount': self.currency_to_precision(code, amount),
|
7054
7540
|
'symbol': market['id'],
|
7055
7541
|
}
|
@@ -7073,7 +7559,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
7073
7559
|
async def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
|
7074
7560
|
"""
|
7075
7561
|
repay borrowed margin and interest
|
7076
|
-
|
7562
|
+
|
7563
|
+
https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Repay
|
7564
|
+
|
7077
7565
|
:param str symbol: unified market symbol
|
7078
7566
|
:param str code: unified currency code of the currency to repay
|
7079
7567
|
:param str amount: the amount to repay
|
@@ -7083,8 +7571,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
7083
7571
|
await self.load_markets()
|
7084
7572
|
currency = self.currency(code)
|
7085
7573
|
market = self.market(symbol)
|
7086
|
-
request = {
|
7087
|
-
'coin': currency['
|
7574
|
+
request: dict = {
|
7575
|
+
'coin': currency['id'],
|
7088
7576
|
'repayAmount': self.currency_to_precision(code, amount),
|
7089
7577
|
'symbol': market['id'],
|
7090
7578
|
}
|
@@ -7109,7 +7597,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
7109
7597
|
async def repay_cross_margin(self, code: str, amount, params={}):
|
7110
7598
|
"""
|
7111
7599
|
repay borrowed margin and interest
|
7112
|
-
|
7600
|
+
|
7601
|
+
https://www.bitget.com/api-doc/margin/cross/account/Cross-Repay
|
7602
|
+
|
7113
7603
|
:param str code: unified currency code of the currency to repay
|
7114
7604
|
:param str amount: the amount to repay
|
7115
7605
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -7117,8 +7607,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
7117
7607
|
"""
|
7118
7608
|
await self.load_markets()
|
7119
7609
|
currency = self.currency(code)
|
7120
|
-
request = {
|
7121
|
-
'coin': currency['
|
7610
|
+
request: dict = {
|
7611
|
+
'coin': currency['id'],
|
7122
7612
|
'repayAmount': self.currency_to_precision(code, amount),
|
7123
7613
|
}
|
7124
7614
|
response = await self.privateMarginPostV2MarginCrossedAccountRepay(self.extend(request, params))
|
@@ -7194,8 +7684,10 @@ class bitget(Exchange, ImplicitAPI):
|
|
7194
7684
|
async def fetch_my_liquidations(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Liquidation]:
|
7195
7685
|
"""
|
7196
7686
|
retrieves the users liquidated positions
|
7197
|
-
|
7198
|
-
|
7687
|
+
|
7688
|
+
https://www.bitget.com/api-doc/margin/cross/record/Get-Cross-Liquidation-Records
|
7689
|
+
https://www.bitget.com/api-doc/margin/isolated/record/Get-Isolated-Liquidation-Records
|
7690
|
+
|
7199
7691
|
:param str [symbol]: unified CCXT market symbol
|
7200
7692
|
:param int [since]: the earliest time in ms to fetch liquidations for
|
7201
7693
|
:param int [limit]: the maximum number of liquidation structures to retrieve
|
@@ -7217,7 +7709,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7217
7709
|
type, params = self.handle_market_type_and_params('fetchMyLiquidations', market, params)
|
7218
7710
|
if type != 'spot':
|
7219
7711
|
raise NotSupported(self.id + ' fetchMyLiquidations() supports spot margin markets only')
|
7220
|
-
request = {}
|
7712
|
+
request: dict = {}
|
7221
7713
|
request, params = self.handle_until_option('endTime', request, params)
|
7222
7714
|
if since is not None:
|
7223
7715
|
request['startTime'] = since
|
@@ -7288,7 +7780,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7288
7780
|
# }
|
7289
7781
|
#
|
7290
7782
|
data = self.safe_value(response, 'data', {})
|
7291
|
-
liquidations = self.
|
7783
|
+
liquidations = self.safe_list(data, 'resultList', [])
|
7292
7784
|
return self.parse_liquidations(liquidations, market, since, limit)
|
7293
7785
|
|
7294
7786
|
def parse_liquidation(self, liquidation, market: Market = None):
|
@@ -7339,17 +7831,19 @@ class bitget(Exchange, ImplicitAPI):
|
|
7339
7831
|
'datetime': self.iso8601(timestamp),
|
7340
7832
|
})
|
7341
7833
|
|
7342
|
-
async def fetch_isolated_borrow_rate(self, symbol: str, params={}):
|
7834
|
+
async def fetch_isolated_borrow_rate(self, symbol: str, params={}) -> IsolatedBorrowRate:
|
7343
7835
|
"""
|
7344
7836
|
fetch the rate of interest to borrow a currency for margin trading
|
7345
|
-
|
7837
|
+
|
7838
|
+
https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Margin-Interest-Rate-And-Max-Borrowable-Amount
|
7839
|
+
|
7346
7840
|
:param str symbol: unified market symbol
|
7347
7841
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
7348
7842
|
:returns dict: an `isolated borrow rate structure <https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure>`
|
7349
7843
|
"""
|
7350
7844
|
await self.load_markets()
|
7351
7845
|
market = self.market(symbol)
|
7352
|
-
request = {
|
7846
|
+
request: dict = {
|
7353
7847
|
'symbol': market['id'],
|
7354
7848
|
}
|
7355
7849
|
response = await self.privateMarginGetV2MarginIsolatedInterestRateAndLimit(self.extend(request, params))
|
@@ -7400,7 +7894,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7400
7894
|
first['timestamp'] = timestamp
|
7401
7895
|
return self.parse_isolated_borrow_rate(first, market)
|
7402
7896
|
|
7403
|
-
def parse_isolated_borrow_rate(self, info, market: Market = None):
|
7897
|
+
def parse_isolated_borrow_rate(self, info: dict, market: Market = None) -> IsolatedBorrowRate:
|
7404
7898
|
#
|
7405
7899
|
# {
|
7406
7900
|
# "symbol": "BTCUSDT",
|
@@ -7452,10 +7946,12 @@ class bitget(Exchange, ImplicitAPI):
|
|
7452
7946
|
'info': info,
|
7453
7947
|
}
|
7454
7948
|
|
7455
|
-
async def fetch_cross_borrow_rate(self, code: str, params={}):
|
7949
|
+
async def fetch_cross_borrow_rate(self, code: str, params={}) -> CrossBorrowRate:
|
7456
7950
|
"""
|
7457
7951
|
fetch the rate of interest to borrow a currency for margin trading
|
7458
|
-
|
7952
|
+
|
7953
|
+
https://www.bitget.com/api-doc/margin/cross/account/Get-Cross-Margin-Interest-Rate-And-Borrowable
|
7954
|
+
|
7459
7955
|
:param str code: unified currency code
|
7460
7956
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
7461
7957
|
:param str [params.symbol]: required for isolated margin
|
@@ -7463,8 +7959,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
7463
7959
|
"""
|
7464
7960
|
await self.load_markets()
|
7465
7961
|
currency = self.currency(code)
|
7466
|
-
request = {
|
7467
|
-
'coin': currency['
|
7962
|
+
request: dict = {
|
7963
|
+
'coin': currency['id'],
|
7468
7964
|
}
|
7469
7965
|
response = await self.privateMarginGetV2MarginCrossedInterestRateAndLimit(self.extend(request, params))
|
7470
7966
|
#
|
@@ -7530,11 +8026,13 @@ class bitget(Exchange, ImplicitAPI):
|
|
7530
8026
|
'info': info,
|
7531
8027
|
}
|
7532
8028
|
|
7533
|
-
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
8029
|
+
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
|
7534
8030
|
"""
|
7535
8031
|
fetch the interest owed by the user for borrowing currency for margin trading
|
7536
|
-
|
7537
|
-
|
8032
|
+
|
8033
|
+
https://www.bitget.com/api-doc/margin/cross/record/Get-Cross-Interest-Records
|
8034
|
+
https://www.bitget.com/api-doc/margin/isolated/record/Get-Isolated-Interest-Records
|
8035
|
+
|
7538
8036
|
:param str [code]: unified currency code
|
7539
8037
|
:param str [symbol]: unified market symbol when fetching interest in isolated markets
|
7540
8038
|
:param int [since]: the earliest time in ms to fetch borrow interest for
|
@@ -7551,11 +8049,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
7551
8049
|
market = None
|
7552
8050
|
if symbol is not None:
|
7553
8051
|
market = self.market(symbol)
|
7554
|
-
request = {}
|
8052
|
+
request: dict = {}
|
7555
8053
|
currency = None
|
7556
8054
|
if code is not None:
|
7557
8055
|
currency = self.currency(code)
|
7558
|
-
request['coin'] = currency['
|
8056
|
+
request['coin'] = currency['id']
|
7559
8057
|
if since is not None:
|
7560
8058
|
request['startTime'] = since
|
7561
8059
|
else:
|
@@ -7627,7 +8125,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7627
8125
|
interest = self.parse_borrow_interests(rows, market)
|
7628
8126
|
return self.filter_by_currency_since_limit(interest, code, since, limit)
|
7629
8127
|
|
7630
|
-
def parse_borrow_interest(self, info, market: Market = None):
|
8128
|
+
def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
|
7631
8129
|
#
|
7632
8130
|
# isolated
|
7633
8131
|
#
|
@@ -7661,21 +8159,23 @@ class bitget(Exchange, ImplicitAPI):
|
|
7661
8159
|
marginMode = 'isolated' if (marketId is not None) else 'cross'
|
7662
8160
|
timestamp = self.safe_integer(info, 'cTime')
|
7663
8161
|
return {
|
8162
|
+
'info': info,
|
7664
8163
|
'symbol': self.safe_string(market, 'symbol'),
|
7665
|
-
'marginMode': marginMode,
|
7666
8164
|
'currency': self.safe_currency_code(self.safe_string(info, 'interestCoin')),
|
7667
8165
|
'interest': self.safe_number(info, 'interestAmount'),
|
7668
8166
|
'interestRate': self.safe_number(info, 'dailyInterestRate'),
|
7669
8167
|
'amountBorrowed': None,
|
8168
|
+
'marginMode': marginMode,
|
7670
8169
|
'timestamp': timestamp,
|
7671
8170
|
'datetime': self.iso8601(timestamp),
|
7672
|
-
'info': info,
|
7673
8171
|
}
|
7674
8172
|
|
7675
8173
|
async def close_position(self, symbol: str, side: OrderSide = None, params={}) -> Order:
|
7676
8174
|
"""
|
7677
8175
|
closes an open position for a market
|
7678
|
-
|
8176
|
+
|
8177
|
+
https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
|
8178
|
+
|
7679
8179
|
:param str symbol: unified CCXT market symbol
|
7680
8180
|
:param str [side]: one-way mode: 'buy' or 'sell', hedge-mode: 'long' or 'short'
|
7681
8181
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -7691,7 +8191,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7691
8191
|
market = self.market(symbol)
|
7692
8192
|
productType = None
|
7693
8193
|
productType, params = self.handle_product_type_and_params(market, params)
|
7694
|
-
request = {
|
8194
|
+
request: dict = {
|
7695
8195
|
'symbol': market['id'],
|
7696
8196
|
'productType': productType,
|
7697
8197
|
}
|
@@ -7716,13 +8216,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
7716
8216
|
# }
|
7717
8217
|
#
|
7718
8218
|
data = self.safe_value(response, 'data', {})
|
7719
|
-
order = self.
|
8219
|
+
order = self.safe_list(data, 'successList', [])
|
7720
8220
|
return self.parse_order(order[0], market)
|
7721
8221
|
|
7722
8222
|
async def close_all_positions(self, params={}) -> List[Position]:
|
7723
8223
|
"""
|
7724
8224
|
closes all open positions for a market type
|
7725
|
-
|
8225
|
+
|
8226
|
+
https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
|
8227
|
+
|
7726
8228
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
7727
8229
|
:param str [params.productType]: 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
7728
8230
|
:returns dict[]: A list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
|
@@ -7730,7 +8232,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7730
8232
|
await self.load_markets()
|
7731
8233
|
productType = None
|
7732
8234
|
productType, params = self.handle_product_type_and_params(None, params)
|
7733
|
-
request = {
|
8235
|
+
request: dict = {
|
7734
8236
|
'productType': productType,
|
7735
8237
|
}
|
7736
8238
|
response = await self.privateMixPostV2MixOrderClosePositions(self.extend(request, params))
|
@@ -7752,13 +8254,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
7752
8254
|
# }
|
7753
8255
|
#
|
7754
8256
|
data = self.safe_value(response, 'data', {})
|
7755
|
-
orderInfo = self.
|
8257
|
+
orderInfo = self.safe_list(data, 'successList', [])
|
7756
8258
|
return self.parse_positions(orderInfo, None, params)
|
7757
8259
|
|
7758
8260
|
async def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
|
7759
8261
|
"""
|
7760
8262
|
fetches the margin mode of a trading pair
|
7761
|
-
|
8263
|
+
|
8264
|
+
https://www.bitget.com/api-doc/contract/account/Get-Single-Account
|
8265
|
+
|
7762
8266
|
:param str symbol: unified symbol of the market to fetch the margin mode for
|
7763
8267
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
7764
8268
|
:returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
|
@@ -7773,7 +8277,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7773
8277
|
market = self.market(symbol)
|
7774
8278
|
productType = None
|
7775
8279
|
productType, params = self.handle_product_type_and_params(market, params)
|
7776
|
-
request = {
|
8280
|
+
request: dict = {
|
7777
8281
|
'symbol': market['id'],
|
7778
8282
|
'marginCoin': market['settleId'],
|
7779
8283
|
'productType': productType,
|
@@ -7810,7 +8314,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7810
8314
|
data = self.safe_dict(response, 'data', {})
|
7811
8315
|
return self.parse_margin_mode(data, market)
|
7812
8316
|
|
7813
|
-
def parse_margin_mode(self, marginMode, market=None) -> MarginMode:
|
8317
|
+
def parse_margin_mode(self, marginMode: dict, market=None) -> MarginMode:
|
7814
8318
|
marginType = self.safe_string(marginMode, 'marginMode')
|
7815
8319
|
marginType = 'cross' if (marginType == 'crossed') else marginType
|
7816
8320
|
return {
|
@@ -7819,12 +8323,455 @@ class bitget(Exchange, ImplicitAPI):
|
|
7819
8323
|
'marginMode': marginType,
|
7820
8324
|
}
|
7821
8325
|
|
7822
|
-
def
|
8326
|
+
async def fetch_positions_history(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}) -> List[Position]:
|
8327
|
+
"""
|
8328
|
+
fetches historical positions
|
8329
|
+
|
8330
|
+
https://www.bitget.com/api-doc/contract/position/Get-History-Position
|
8331
|
+
|
8332
|
+
:param str[] [symbols]: unified contract symbols
|
8333
|
+
:param int [since]: timestamp in ms of the earliest position to fetch, default=3 months ago, max range for params["until"] - since is 3 months
|
8334
|
+
:param int [limit]: the maximum amount of records to fetch, default=20, max=100
|
8335
|
+
:param dict params: extra parameters specific to the exchange api endpoint
|
8336
|
+
:param int [params.until]: timestamp in ms of the latest position to fetch, max range for params["until"] - since is 3 months
|
8337
|
+
|
8338
|
+
EXCHANGE SPECIFIC PARAMETERS
|
8339
|
+
:param str [params.productType]: USDT-FUTURES(default), COIN-FUTURES, USDC-FUTURES, SUSDT-FUTURES, SCOIN-FUTURES, or SUSDC-FUTURES
|
8340
|
+
:returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
|
8341
|
+
"""
|
8342
|
+
await self.load_markets()
|
8343
|
+
until = self.safe_integer(params, 'until')
|
8344
|
+
params = self.omit(params, 'until')
|
8345
|
+
request: dict = {}
|
8346
|
+
if symbols is not None:
|
8347
|
+
symbolsLength = len(symbols)
|
8348
|
+
if symbolsLength > 0:
|
8349
|
+
market = self.market(symbols[0])
|
8350
|
+
request['symbol'] = market['id']
|
8351
|
+
if since is not None:
|
8352
|
+
request['startTime'] = since
|
8353
|
+
if limit is not None:
|
8354
|
+
request['limit'] = limit
|
8355
|
+
if until is not None:
|
8356
|
+
request['endTime'] = until
|
8357
|
+
response = await self.privateMixGetV2MixPositionHistoryPosition(self.extend(request, params))
|
8358
|
+
#
|
8359
|
+
# {
|
8360
|
+
# code: '00000',
|
8361
|
+
# msg: 'success',
|
8362
|
+
# requestTime: '1712794148791',
|
8363
|
+
# data: {
|
8364
|
+
# list: [
|
8365
|
+
# {
|
8366
|
+
# symbol: 'XRPUSDT',
|
8367
|
+
# marginCoin: 'USDT',
|
8368
|
+
# holdSide: 'long',
|
8369
|
+
# openAvgPrice: '0.64967',
|
8370
|
+
# closeAvgPrice: '0.58799',
|
8371
|
+
# marginMode: 'isolated',
|
8372
|
+
# openTotalPos: '10',
|
8373
|
+
# closeTotalPos: '10',
|
8374
|
+
# pnl: '-0.62976205',
|
8375
|
+
# netProfit: '-0.65356802',
|
8376
|
+
# totalFunding: '-0.01638',
|
8377
|
+
# openFee: '-0.00389802',
|
8378
|
+
# closeFee: '-0.00352794',
|
8379
|
+
# ctime: '1709590322199',
|
8380
|
+
# utime: '1709667583395'
|
8381
|
+
# },
|
8382
|
+
# ...
|
8383
|
+
# ]
|
8384
|
+
# }
|
8385
|
+
# }
|
8386
|
+
#
|
8387
|
+
data = self.safe_dict(response, 'data')
|
8388
|
+
responseList = self.safe_list(data, 'list')
|
8389
|
+
positions = self.parse_positions(responseList, symbols, params)
|
8390
|
+
return self.filter_by_since_limit(positions, since, limit)
|
8391
|
+
|
8392
|
+
async def fetch_convert_quote(self, fromCode: str, toCode: str, amount: Num = None, params={}) -> Conversion:
|
8393
|
+
"""
|
8394
|
+
fetch a quote for converting from one currency to another
|
8395
|
+
|
8396
|
+
https://www.bitget.com/api-doc/common/convert/Get-Quoted-Price
|
8397
|
+
|
8398
|
+
:param str fromCode: the currency that you want to sell and convert from
|
8399
|
+
:param str toCode: the currency that you want to buy and convert into
|
8400
|
+
:param float [amount]: how much you want to trade in units of the from currency
|
8401
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8402
|
+
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
|
8403
|
+
"""
|
8404
|
+
await self.load_markets()
|
8405
|
+
request: dict = {
|
8406
|
+
'fromCoin': fromCode,
|
8407
|
+
'toCoin': toCode,
|
8408
|
+
'fromCoinSize': self.number_to_string(amount),
|
8409
|
+
}
|
8410
|
+
response = await self.privateConvertGetV2ConvertQuotedPrice(self.extend(request, params))
|
8411
|
+
#
|
8412
|
+
# {
|
8413
|
+
# "code": "00000",
|
8414
|
+
# "msg": "success",
|
8415
|
+
# "requestTime": 1712121940158,
|
8416
|
+
# "data": {
|
8417
|
+
# "fromCoin": "USDT",
|
8418
|
+
# "fromCoinSize": "5",
|
8419
|
+
# "cnvtPrice": "0.9993007892377704",
|
8420
|
+
# "toCoin": "USDC",
|
8421
|
+
# "toCoinSize": "4.99650394",
|
8422
|
+
# "traceId": "1159288930228187140",
|
8423
|
+
# "fee": "0"
|
8424
|
+
# }
|
8425
|
+
# }
|
8426
|
+
#
|
8427
|
+
data = self.safe_dict(response, 'data', {})
|
8428
|
+
fromCurrencyId = self.safe_string(data, 'fromCoin', fromCode)
|
8429
|
+
fromCurrency = self.currency(fromCurrencyId)
|
8430
|
+
toCurrencyId = self.safe_string(data, 'toCoin', toCode)
|
8431
|
+
toCurrency = self.currency(toCurrencyId)
|
8432
|
+
return self.parse_conversion(data, fromCurrency, toCurrency)
|
8433
|
+
|
8434
|
+
async def create_convert_trade(self, id: str, fromCode: str, toCode: str, amount: Num = None, params={}) -> Conversion:
|
8435
|
+
"""
|
8436
|
+
convert from one currency to another
|
8437
|
+
|
8438
|
+
https://www.bitget.com/api-doc/common/convert/Trade
|
8439
|
+
|
8440
|
+
:param str id: the id of the trade that you want to make
|
8441
|
+
:param str fromCode: the currency that you want to sell and convert from
|
8442
|
+
:param str toCode: the currency that you want to buy and convert into
|
8443
|
+
:param float amount: how much you want to trade in units of the from currency
|
8444
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8445
|
+
:param str params['price']: the price of the conversion, obtained from fetchConvertQuote()
|
8446
|
+
:param str params['toAmount']: the amount you want to trade in units of the toCurrency, obtained from fetchConvertQuote()
|
8447
|
+
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
|
8448
|
+
"""
|
8449
|
+
await self.load_markets()
|
8450
|
+
price = self.safe_string_2(params, 'price', 'cnvtPrice')
|
8451
|
+
if price is None:
|
8452
|
+
raise ArgumentsRequired(self.id + ' createConvertTrade() requires a price parameter')
|
8453
|
+
toAmount = self.safe_string_2(params, 'toAmount', 'toCoinSize')
|
8454
|
+
if toAmount is None:
|
8455
|
+
raise ArgumentsRequired(self.id + ' createConvertTrade() requires a toAmount parameter')
|
8456
|
+
params = self.omit(params, ['price', 'toAmount'])
|
8457
|
+
request: dict = {
|
8458
|
+
'traceId': id,
|
8459
|
+
'fromCoin': fromCode,
|
8460
|
+
'toCoin': toCode,
|
8461
|
+
'fromCoinSize': self.number_to_string(amount),
|
8462
|
+
'toCoinSize': toAmount,
|
8463
|
+
'cnvtPrice': price,
|
8464
|
+
}
|
8465
|
+
response = await self.privateConvertPostV2ConvertTrade(self.extend(request, params))
|
8466
|
+
#
|
8467
|
+
# {
|
8468
|
+
# "code": "00000",
|
8469
|
+
# "msg": "success",
|
8470
|
+
# "requestTime": 1712123746203,
|
8471
|
+
# "data": {
|
8472
|
+
# "cnvtPrice": "0.99940076",
|
8473
|
+
# "toCoin": "USDC",
|
8474
|
+
# "toCoinSize": "4.99700379",
|
8475
|
+
# "ts": "1712123746217"
|
8476
|
+
# }
|
8477
|
+
# }
|
8478
|
+
#
|
8479
|
+
data = self.safe_dict(response, 'data', {})
|
8480
|
+
toCurrencyId = self.safe_string(data, 'toCoin', toCode)
|
8481
|
+
toCurrency = self.currency(toCurrencyId)
|
8482
|
+
return self.parse_conversion(data, None, toCurrency)
|
8483
|
+
|
8484
|
+
async def fetch_convert_trade_history(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Conversion]:
|
8485
|
+
"""
|
8486
|
+
fetch the users history of conversion trades
|
8487
|
+
|
8488
|
+
https://www.bitget.com/api-doc/common/convert/Get-Convert-Record
|
8489
|
+
|
8490
|
+
:param str [code]: the unified currency code
|
8491
|
+
:param int [since]: the earliest time in ms to fetch conversions for
|
8492
|
+
:param int [limit]: the maximum number of conversion structures to retrieve
|
8493
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8494
|
+
:returns dict[]: a list of `conversion structures <https://docs.ccxt.com/#/?id=conversion-structure>`
|
8495
|
+
"""
|
8496
|
+
await self.load_markets()
|
8497
|
+
request: dict = {}
|
8498
|
+
msInDay = 86400000
|
8499
|
+
now = self.milliseconds()
|
8500
|
+
if since is not None:
|
8501
|
+
request['startTime'] = since
|
8502
|
+
else:
|
8503
|
+
request['startTime'] = now - msInDay
|
8504
|
+
endTime = self.safe_string_2(params, 'endTime', 'until')
|
8505
|
+
if endTime is not None:
|
8506
|
+
request['endTime'] = endTime
|
8507
|
+
else:
|
8508
|
+
request['endTime'] = now
|
8509
|
+
if limit is not None:
|
8510
|
+
request['limit'] = limit
|
8511
|
+
params = self.omit(params, 'until')
|
8512
|
+
response = await self.privateConvertGetV2ConvertConvertRecord(self.extend(request, params))
|
8513
|
+
#
|
8514
|
+
# {
|
8515
|
+
# "code": "00000",
|
8516
|
+
# "msg": "success",
|
8517
|
+
# "requestTime": 1712124371799,
|
8518
|
+
# "data": {
|
8519
|
+
# "dataList": [
|
8520
|
+
# {
|
8521
|
+
# "id": "1159296505255219205",
|
8522
|
+
# "fromCoin": "USDT",
|
8523
|
+
# "fromCoinSize": "5",
|
8524
|
+
# "cnvtPrice": "0.99940076",
|
8525
|
+
# "toCoin": "USDC",
|
8526
|
+
# "toCoinSize": "4.99700379",
|
8527
|
+
# "ts": "1712123746217",
|
8528
|
+
# "fee": "0"
|
8529
|
+
# }
|
8530
|
+
# ],
|
8531
|
+
# "endId": "1159296505255219205"
|
8532
|
+
# }
|
8533
|
+
# }
|
8534
|
+
#
|
8535
|
+
data = self.safe_dict(response, 'data', {})
|
8536
|
+
dataList = self.safe_list(data, 'dataList', [])
|
8537
|
+
return self.parse_conversions(dataList, code, 'fromCoin', 'toCoin', since, limit)
|
8538
|
+
|
8539
|
+
def parse_conversion(self, conversion: dict, fromCurrency: Currency = None, toCurrency: Currency = None) -> Conversion:
|
8540
|
+
#
|
8541
|
+
# fetchConvertQuote
|
8542
|
+
#
|
8543
|
+
# {
|
8544
|
+
# "fromCoin": "USDT",
|
8545
|
+
# "fromCoinSize": "5",
|
8546
|
+
# "cnvtPrice": "0.9993007892377704",
|
8547
|
+
# "toCoin": "USDC",
|
8548
|
+
# "toCoinSize": "4.99650394",
|
8549
|
+
# "traceId": "1159288930228187140",
|
8550
|
+
# "fee": "0"
|
8551
|
+
# }
|
8552
|
+
#
|
8553
|
+
# createConvertTrade
|
8554
|
+
#
|
8555
|
+
# {
|
8556
|
+
# "cnvtPrice": "0.99940076",
|
8557
|
+
# "toCoin": "USDC",
|
8558
|
+
# "toCoinSize": "4.99700379",
|
8559
|
+
# "ts": "1712123746217"
|
8560
|
+
# }
|
8561
|
+
#
|
8562
|
+
# fetchConvertTradeHistory
|
8563
|
+
#
|
8564
|
+
# {
|
8565
|
+
# "id": "1159296505255219205",
|
8566
|
+
# "fromCoin": "USDT",
|
8567
|
+
# "fromCoinSize": "5",
|
8568
|
+
# "cnvtPrice": "0.99940076",
|
8569
|
+
# "toCoin": "USDC",
|
8570
|
+
# "toCoinSize": "4.99700379",
|
8571
|
+
# "ts": "1712123746217",
|
8572
|
+
# "fee": "0"
|
8573
|
+
# }
|
8574
|
+
#
|
8575
|
+
timestamp = self.safe_integer(conversion, 'ts')
|
8576
|
+
fromCoin = self.safe_string(conversion, 'fromCoin')
|
8577
|
+
fromCode = self.safe_currency_code(fromCoin, fromCurrency)
|
8578
|
+
to = self.safe_string(conversion, 'toCoin')
|
8579
|
+
toCode = self.safe_currency_code(to, toCurrency)
|
8580
|
+
return {
|
8581
|
+
'info': conversion,
|
8582
|
+
'timestamp': timestamp,
|
8583
|
+
'datetime': self.iso8601(timestamp),
|
8584
|
+
'id': self.safe_string_2(conversion, 'id', 'traceId'),
|
8585
|
+
'fromCurrency': fromCode,
|
8586
|
+
'fromAmount': self.safe_number(conversion, 'fromCoinSize'),
|
8587
|
+
'toCurrency': toCode,
|
8588
|
+
'toAmount': self.safe_number(conversion, 'toCoinSize'),
|
8589
|
+
'price': self.safe_number(conversion, 'cnvtPrice'),
|
8590
|
+
'fee': self.safe_number(conversion, 'fee'),
|
8591
|
+
}
|
8592
|
+
|
8593
|
+
async def fetch_convert_currencies(self, params={}) -> Currencies:
|
8594
|
+
"""
|
8595
|
+
fetches all available currencies that can be converted
|
8596
|
+
|
8597
|
+
https://www.bitget.com/api-doc/common/convert/Get-Convert-Currencies
|
8598
|
+
|
8599
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8600
|
+
:returns dict: an associative dictionary of currencies
|
8601
|
+
"""
|
8602
|
+
await self.load_markets()
|
8603
|
+
response = await self.privateConvertGetV2ConvertCurrencies(params)
|
8604
|
+
#
|
8605
|
+
# {
|
8606
|
+
# "code": "00000",
|
8607
|
+
# "msg": "success",
|
8608
|
+
# "requestTime": 1712121755897,
|
8609
|
+
# "data": [
|
8610
|
+
# {
|
8611
|
+
# "coin": "BTC",
|
8612
|
+
# "available": "0.00009850",
|
8613
|
+
# "maxAmount": "0.756266",
|
8614
|
+
# "minAmount": "0.00001"
|
8615
|
+
# },
|
8616
|
+
# ]
|
8617
|
+
# }
|
8618
|
+
#
|
8619
|
+
result: dict = {}
|
8620
|
+
data = self.safe_list(response, 'data', [])
|
8621
|
+
for i in range(0, len(data)):
|
8622
|
+
entry = data[i]
|
8623
|
+
id = self.safe_string(entry, 'coin')
|
8624
|
+
code = self.safe_currency_code(id)
|
8625
|
+
result[code] = {
|
8626
|
+
'info': entry,
|
8627
|
+
'id': id,
|
8628
|
+
'code': code,
|
8629
|
+
'networks': None,
|
8630
|
+
'type': None,
|
8631
|
+
'name': None,
|
8632
|
+
'active': None,
|
8633
|
+
'deposit': None,
|
8634
|
+
'withdraw': self.safe_number(entry, 'available'),
|
8635
|
+
'fee': None,
|
8636
|
+
'precision': None,
|
8637
|
+
'limits': {
|
8638
|
+
'amount': {
|
8639
|
+
'min': self.safe_number(entry, 'minAmount'),
|
8640
|
+
'max': self.safe_number(entry, 'maxAmount'),
|
8641
|
+
},
|
8642
|
+
'withdraw': {
|
8643
|
+
'min': None,
|
8644
|
+
'max': None,
|
8645
|
+
},
|
8646
|
+
'deposit': {
|
8647
|
+
'min': None,
|
8648
|
+
'max': None,
|
8649
|
+
},
|
8650
|
+
},
|
8651
|
+
'created': None,
|
8652
|
+
}
|
8653
|
+
return result
|
8654
|
+
|
8655
|
+
async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
8656
|
+
"""
|
8657
|
+
fetch the current funding rate interval
|
8658
|
+
|
8659
|
+
https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
|
8660
|
+
|
8661
|
+
:param str symbol: unified market symbol
|
8662
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8663
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
8664
|
+
"""
|
8665
|
+
await self.load_markets()
|
8666
|
+
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
8667
|
+
market = None
|
8668
|
+
if sandboxMode:
|
8669
|
+
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
8670
|
+
market = self.market(sandboxSymbol)
|
8671
|
+
else:
|
8672
|
+
market = self.market(symbol)
|
8673
|
+
productType = None
|
8674
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
8675
|
+
request: dict = {
|
8676
|
+
'symbol': market['id'],
|
8677
|
+
'productType': productType,
|
8678
|
+
}
|
8679
|
+
response = await self.publicMixGetV2MixMarketFundingTime(self.extend(request, params))
|
8680
|
+
#
|
8681
|
+
# {
|
8682
|
+
# "code": "00000",
|
8683
|
+
# "msg": "success",
|
8684
|
+
# "requestTime": 1727930153888,
|
8685
|
+
# "data": [
|
8686
|
+
# {
|
8687
|
+
# "symbol": "BTCUSDT",
|
8688
|
+
# "nextFundingTime": "1727942400000",
|
8689
|
+
# "ratePeriod": "8"
|
8690
|
+
# }
|
8691
|
+
# ]
|
8692
|
+
# }
|
8693
|
+
#
|
8694
|
+
data = self.safe_list(response, 'data', [])
|
8695
|
+
first = self.safe_dict(data, 0, {})
|
8696
|
+
return self.parse_funding_rate(first, market)
|
8697
|
+
|
8698
|
+
async def fetch_long_short_ratio_history(self, symbol: Str = None, timeframe: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LongShortRatio]:
|
8699
|
+
"""
|
8700
|
+
fetches the long short ratio history for a unified market symbol
|
8701
|
+
|
8702
|
+
https://www.bitget.com/api-doc/common/apidata/Margin-Ls-Ratio
|
8703
|
+
https://www.bitget.com/api-doc/common/apidata/Account-Long-Short
|
8704
|
+
|
8705
|
+
:param str symbol: unified symbol of the market to fetch the long short ratio for
|
8706
|
+
:param str [timeframe]: the period for the ratio
|
8707
|
+
:param int [since]: the earliest time in ms to fetch ratios for
|
8708
|
+
:param int [limit]: the maximum number of long short ratio structures to retrieve
|
8709
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8710
|
+
:returns dict[]: an array of `long short ratio structures <https://docs.ccxt.com/#/?id=long-short-ratio-structure>`
|
8711
|
+
"""
|
8712
|
+
await self.load_markets()
|
8713
|
+
market = self.market(symbol)
|
8714
|
+
request: dict = {
|
8715
|
+
'symbol': market['id'],
|
8716
|
+
}
|
8717
|
+
if timeframe is not None:
|
8718
|
+
request['period'] = timeframe
|
8719
|
+
response = None
|
8720
|
+
if market['swap'] or market['future']:
|
8721
|
+
response = await self.publicMixGetV2MixMarketAccountLongShort(self.extend(request, params))
|
8722
|
+
#
|
8723
|
+
# {
|
8724
|
+
# "code": "00000",
|
8725
|
+
# "msg": "success",
|
8726
|
+
# "requestTime": 1729321233281,
|
8727
|
+
# "data": [
|
8728
|
+
# {
|
8729
|
+
# "longAccountRatio": "0.58",
|
8730
|
+
# "shortAccountRatio": "0.42",
|
8731
|
+
# "longShortAccountRatio": "0.0138",
|
8732
|
+
# "ts": "1729312200000"
|
8733
|
+
# },
|
8734
|
+
# ]
|
8735
|
+
# }
|
8736
|
+
#
|
8737
|
+
else:
|
8738
|
+
response = await self.publicMarginGetV2MarginMarketLongShortRatio(self.extend(request, params))
|
8739
|
+
#
|
8740
|
+
# {
|
8741
|
+
# "code": "00000",
|
8742
|
+
# "msg": "success",
|
8743
|
+
# "requestTime": 1729306974712,
|
8744
|
+
# "data": [
|
8745
|
+
# {
|
8746
|
+
# "longShortRatio": "40.66",
|
8747
|
+
# "ts": "1729306800000"
|
8748
|
+
# },
|
8749
|
+
# ]
|
8750
|
+
# }
|
8751
|
+
#
|
8752
|
+
data = self.safe_list(response, 'data', [])
|
8753
|
+
return self.parse_long_short_ratio_history(data, market)
|
8754
|
+
|
8755
|
+
def parse_long_short_ratio(self, info: dict, market: Market = None) -> LongShortRatio:
|
8756
|
+
marketId = self.safe_string(info, 'symbol')
|
8757
|
+
timestamp = self.safe_integer_omit_zero(info, 'ts')
|
8758
|
+
return {
|
8759
|
+
'info': info,
|
8760
|
+
'symbol': self.safe_symbol(marketId, market, None, 'contract'),
|
8761
|
+
'timestamp': timestamp,
|
8762
|
+
'datetime': self.iso8601(timestamp),
|
8763
|
+
'timeframe': None,
|
8764
|
+
'longShortRatio': self.safe_number_2(info, 'longShortRatio', 'longShortAccountRatio'),
|
8765
|
+
}
|
8766
|
+
|
8767
|
+
def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
|
7823
8768
|
if not response:
|
7824
8769
|
return None # fallback to default error handler
|
7825
8770
|
#
|
7826
8771
|
# spot
|
7827
8772
|
#
|
8773
|
+
# {"code":"00000","msg":"success","requestTime":1713294492511,"data":[...]}"
|
8774
|
+
#
|
7828
8775
|
# {"status":"fail","err_code":"01001","err_msg":"系统异常,请稍后重试"}
|
7829
8776
|
# {"status":"error","ts":1595594160149,"err_code":"invalid-parameter","err_msg":"invalid size, valid range: [1,2000]"}
|
7830
8777
|
# {"status":"error","ts":1595684716042,"err_code":"invalid-parameter","err_msg":"illegal sign invalid"}
|
@@ -7846,13 +8793,13 @@ class bitget(Exchange, ImplicitAPI):
|
|
7846
8793
|
# {"code":"40108","msg":"","requestTime":1595885064600,"data":null}
|
7847
8794
|
# {"order_id":"513468410013679613","client_oid":null,"symbol":"ethusd","result":false,"err_code":"order_no_exist_error","err_msg":"订单不存在!"}
|
7848
8795
|
#
|
7849
|
-
message = self.
|
7850
|
-
errorCode = self.safe_string_2(response, 'code', 'err_code')
|
8796
|
+
message = self.safe_string_2(response, 'err_msg', 'msg')
|
7851
8797
|
feedback = self.id + ' ' + body
|
7852
|
-
nonEmptyMessage = ((message is not None) and (message != ''))
|
8798
|
+
nonEmptyMessage = ((message is not None) and (message != '') and (message != 'success'))
|
7853
8799
|
if nonEmptyMessage:
|
7854
8800
|
self.throw_exactly_matched_exception(self.exceptions['exact'], message, feedback)
|
7855
8801
|
self.throw_broadly_matched_exception(self.exceptions['broad'], message, feedback)
|
8802
|
+
errorCode = self.safe_string_2(response, 'code', 'err_code')
|
7856
8803
|
nonZeroErrorCode = (errorCode is not None) and (errorCode != '00000')
|
7857
8804
|
if nonZeroErrorCode:
|
7858
8805
|
self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
|
@@ -7860,6 +8807,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
7860
8807
|
raise ExchangeError(feedback) # unknown message
|
7861
8808
|
return None
|
7862
8809
|
|
8810
|
+
def nonce(self):
|
8811
|
+
return self.milliseconds() - self.options['timeDifference']
|
8812
|
+
|
7863
8813
|
def sign(self, path, api=[], method='GET', params={}, headers=None, body=None):
|
7864
8814
|
signed = api[0] == 'private'
|
7865
8815
|
endpoint = api[1]
|
@@ -7875,7 +8825,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7875
8825
|
url = url + '?' + self.urlencode(query)
|
7876
8826
|
if signed:
|
7877
8827
|
self.check_required_credentials()
|
7878
|
-
timestamp = str(self.
|
8828
|
+
timestamp = str(self.nonce())
|
7879
8829
|
auth = timestamp + method + payload
|
7880
8830
|
if method == 'POST':
|
7881
8831
|
body = self.json(params)
|