ccxt 4.2.77__py2.py3-none-any.whl → 4.4.49__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 +3205 -937
- 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 +1525 -573
- 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 +223 -97
- 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 +639 -323
- ccxt/async_support/digifinex.py +465 -233
- ccxt/async_support/ellipx.py +1887 -0
- ccxt/async_support/exmo.py +317 -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 +433 -178
- ccxt/async_support/hollaex.py +207 -83
- ccxt/async_support/htx.py +1095 -563
- ccxt/async_support/huobijp.py +178 -56
- ccxt/async_support/hyperliquid.py +1678 -292
- ccxt/async_support/idex.py +219 -95
- ccxt/async_support/independentreserve.py +300 -31
- ccxt/async_support/indodax.py +226 -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 +198 -107
- ccxt/async_support/latoken.py +199 -79
- ccxt/async_support/lbank.py +360 -113
- ccxt/async_support/luno.py +185 -62
- ccxt/async_support/lykke.py +168 -55
- ccxt/async_support/mercado.py +101 -29
- ccxt/async_support/mexc.py +995 -429
- ccxt/async_support/myokx.py +53 -0
- ccxt/async_support/ndax.py +234 -82
- ccxt/async_support/novadax.py +195 -75
- ccxt/async_support/oceanex.py +244 -59
- ccxt/async_support/okcoin.py +301 -165
- ccxt/async_support/okx.py +1776 -454
- ccxt/async_support/onetrading.py +198 -414
- ccxt/async_support/oxfun.py +2898 -0
- ccxt/async_support/p2b.py +142 -52
- ccxt/async_support/paradex.py +2085 -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 +3205 -937
- 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 +1525 -573
- 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 +223 -97
- 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 +639 -323
- ccxt/digifinex.py +465 -233
- ccxt/ellipx.py +1887 -0
- ccxt/exmo.py +317 -128
- ccxt/gate.py +1472 -463
- ccxt/gemini.py +206 -84
- ccxt/hashkey.py +4164 -0
- ccxt/hitbtc.py +433 -178
- ccxt/hollaex.py +207 -83
- ccxt/htx.py +1095 -563
- ccxt/huobijp.py +178 -56
- ccxt/hyperliquid.py +1677 -292
- ccxt/idex.py +219 -95
- ccxt/independentreserve.py +299 -31
- ccxt/indodax.py +226 -62
- ccxt/kraken.py +871 -354
- ccxt/krakenfutures.py +324 -100
- ccxt/kucoin.py +917 -357
- ccxt/kucoinfutures.py +1004 -149
- ccxt/kuna.py +198 -107
- ccxt/latoken.py +199 -79
- ccxt/lbank.py +360 -113
- ccxt/luno.py +185 -62
- ccxt/lykke.py +168 -55
- ccxt/mercado.py +101 -29
- ccxt/mexc.py +994 -429
- ccxt/myokx.py +53 -0
- ccxt/ndax.py +234 -82
- ccxt/novadax.py +195 -75
- ccxt/oceanex.py +244 -59
- ccxt/okcoin.py +301 -165
- ccxt/okx.py +1776 -454
- ccxt/onetrading.py +198 -414
- ccxt/oxfun.py +2897 -0
- ccxt/p2b.py +142 -52
- ccxt/paradex.py +2085 -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 +143 -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.49.dist-info/LICENSE.txt +21 -0
- ccxt-4.4.49.dist-info/METADATA +646 -0
- ccxt-4.4.49.dist-info/RECORD +669 -0
- {ccxt-4.2.77.dist-info → ccxt-4.4.49.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.49.dist-info}/top_level.txt +0 -0
ccxt/async_support/mexc.py
CHANGED
@@ -5,10 +5,12 @@
|
|
5
5
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.mexc import ImplicitAPI
|
8
|
+
import asyncio
|
8
9
|
import hashlib
|
9
|
-
from ccxt.base.types import Account, Balances, Currency, IndexType, Int, Leverage, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Account, Balances, Currencies, Currency, DepositAddress, IndexType, Int, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
10
11
|
from typing import List
|
11
12
|
from ccxt.base.errors import ExchangeError
|
13
|
+
from ccxt.base.errors import AuthenticationError
|
12
14
|
from ccxt.base.errors import PermissionDenied
|
13
15
|
from ccxt.base.errors import AccountSuspended
|
14
16
|
from ccxt.base.errors import ArgumentsRequired
|
@@ -20,7 +22,6 @@ from ccxt.base.errors import InvalidOrder
|
|
20
22
|
from ccxt.base.errors import NotSupported
|
21
23
|
from ccxt.base.errors import OnMaintenance
|
22
24
|
from ccxt.base.errors import InvalidNonce
|
23
|
-
from ccxt.base.errors import AuthenticationError
|
24
25
|
from ccxt.base.decimal_to_precision import TICK_SIZE
|
25
26
|
from ccxt.base.precise import Precise
|
26
27
|
|
@@ -44,6 +45,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
44
45
|
'future': False,
|
45
46
|
'option': False,
|
46
47
|
'addMargin': True,
|
48
|
+
'borrowCrossMargin': False,
|
49
|
+
'borrowIsolatedMargin': False,
|
50
|
+
'borrowMargin': False,
|
47
51
|
'cancelAllOrders': True,
|
48
52
|
'cancelOrder': True,
|
49
53
|
'cancelOrders': None,
|
@@ -51,18 +55,27 @@ class mexc(Exchange, ImplicitAPI):
|
|
51
55
|
'closePosition': False,
|
52
56
|
'createDepositAddress': True,
|
53
57
|
'createMarketBuyOrderWithCost': True,
|
54
|
-
'createMarketOrderWithCost':
|
55
|
-
'createMarketSellOrderWithCost':
|
58
|
+
'createMarketOrderWithCost': True,
|
59
|
+
'createMarketSellOrderWithCost': True,
|
56
60
|
'createOrder': True,
|
57
61
|
'createOrders': True,
|
58
62
|
'createPostOnlyOrder': True,
|
59
63
|
'createReduceOnlyOrder': True,
|
64
|
+
'createStopLimitOrder': True,
|
65
|
+
'createStopMarketOrder': True,
|
66
|
+
'createStopOrder': True,
|
67
|
+
'createTriggerOrder': True,
|
60
68
|
'deposit': None,
|
61
69
|
'editOrder': None,
|
62
70
|
'fetchAccounts': True,
|
63
71
|
'fetchBalance': True,
|
64
72
|
'fetchBidsAsks': True,
|
65
|
-
'
|
73
|
+
'fetchBorrowInterest': False,
|
74
|
+
'fetchBorrowRate': False,
|
75
|
+
'fetchBorrowRateHistories': False,
|
76
|
+
'fetchBorrowRateHistory': False,
|
77
|
+
'fetchBorrowRates': False,
|
78
|
+
'fetchBorrowRatesPerSymbol': False,
|
66
79
|
'fetchCanceledOrders': True,
|
67
80
|
'fetchClosedOrder': None,
|
68
81
|
'fetchClosedOrders': True,
|
@@ -77,24 +90,30 @@ class mexc(Exchange, ImplicitAPI):
|
|
77
90
|
'fetchDepositWithdrawFee': 'emulated',
|
78
91
|
'fetchDepositWithdrawFees': True,
|
79
92
|
'fetchFundingHistory': True,
|
93
|
+
'fetchFundingInterval': True,
|
94
|
+
'fetchFundingIntervals': False,
|
80
95
|
'fetchFundingRate': True,
|
81
96
|
'fetchFundingRateHistory': True,
|
82
|
-
'fetchFundingRates':
|
97
|
+
'fetchFundingRates': False,
|
83
98
|
'fetchIndexOHLCV': True,
|
84
99
|
'fetchIsolatedBorrowRate': False,
|
85
100
|
'fetchIsolatedBorrowRates': False,
|
101
|
+
'fetchIsolatedPositions': False,
|
86
102
|
'fetchL2OrderBook': True,
|
87
103
|
'fetchLedger': None,
|
88
104
|
'fetchLedgerEntry': None,
|
89
105
|
'fetchLeverage': True,
|
90
106
|
'fetchLeverages': False,
|
91
107
|
'fetchLeverageTiers': True,
|
108
|
+
'fetchMarginAdjustmentHistory': False,
|
92
109
|
'fetchMarginMode': False,
|
93
|
-
'fetchMarketLeverageTiers':
|
110
|
+
'fetchMarketLeverageTiers': 'emulated',
|
94
111
|
'fetchMarkets': True,
|
95
112
|
'fetchMarkOHLCV': True,
|
96
113
|
'fetchMyTrades': True,
|
97
114
|
'fetchOHLCV': True,
|
115
|
+
'fetchOpenInterest': False,
|
116
|
+
'fetchOpenInterestHistory': False,
|
98
117
|
'fetchOpenOrder': None,
|
99
118
|
'fetchOpenOrders': True,
|
100
119
|
'fetchOrder': True,
|
@@ -102,9 +121,11 @@ class mexc(Exchange, ImplicitAPI):
|
|
102
121
|
'fetchOrderBooks': None,
|
103
122
|
'fetchOrders': True,
|
104
123
|
'fetchOrderTrades': True,
|
105
|
-
'fetchPosition':
|
124
|
+
'fetchPosition': 'emulated',
|
125
|
+
'fetchPositionHistory': 'emulated',
|
106
126
|
'fetchPositionMode': True,
|
107
127
|
'fetchPositions': True,
|
128
|
+
'fetchPositionsHistory': True,
|
108
129
|
'fetchPositionsRisk': None,
|
109
130
|
'fetchPremiumIndexOHLCV': False,
|
110
131
|
'fetchStatus': True,
|
@@ -112,8 +133,8 @@ class mexc(Exchange, ImplicitAPI):
|
|
112
133
|
'fetchTickers': True,
|
113
134
|
'fetchTime': True,
|
114
135
|
'fetchTrades': True,
|
115
|
-
'fetchTradingFee':
|
116
|
-
'fetchTradingFees':
|
136
|
+
'fetchTradingFee': True,
|
137
|
+
'fetchTradingFees': False,
|
117
138
|
'fetchTradingLimits': None,
|
118
139
|
'fetchTransactionFee': 'emulated',
|
119
140
|
'fetchTransactionFees': True,
|
@@ -126,7 +147,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
126
147
|
'repayCrossMargin': False,
|
127
148
|
'repayIsolatedMargin': False,
|
128
149
|
'setLeverage': True,
|
129
|
-
'setMarginMode':
|
150
|
+
'setMarginMode': True,
|
130
151
|
'setPositionMode': True,
|
131
152
|
'signIn': None,
|
132
153
|
'transfer': None,
|
@@ -158,7 +179,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
158
179
|
'fees': [
|
159
180
|
'https://www.mexc.com/fee',
|
160
181
|
],
|
161
|
-
'referral': 'https://
|
182
|
+
'referral': 'https://www.mexc.com/register?inviteCode=mexc-1FQ1GNu1',
|
162
183
|
},
|
163
184
|
'api': {
|
164
185
|
'spot': {
|
@@ -186,6 +207,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
186
207
|
'allOrders': 10,
|
187
208
|
'account': 10,
|
188
209
|
'myTrades': 10,
|
210
|
+
'tradeFee': 10,
|
189
211
|
'sub-account/list': 1,
|
190
212
|
'sub-account/apiKey': 1,
|
191
213
|
'capital/config/getall': 10,
|
@@ -222,6 +244,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
222
244
|
'rebate/affiliate/commission/detail': 1,
|
223
245
|
'mxDeduct/enable': 1,
|
224
246
|
'userDataStream': 1,
|
247
|
+
'selfSymbols': 1,
|
225
248
|
},
|
226
249
|
'post': {
|
227
250
|
'order': 1,
|
@@ -232,6 +255,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
232
255
|
'sub-account/margin': 1,
|
233
256
|
'batchOrders': 10,
|
234
257
|
'capital/withdraw/apply': 1,
|
258
|
+
'capital/withdraw': 1,
|
235
259
|
'capital/transfer': 1,
|
236
260
|
'capital/transfer/internal': 1,
|
237
261
|
'capital/deposit/address': 1,
|
@@ -250,6 +274,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
250
274
|
'margin/order': 1,
|
251
275
|
'margin/openOrders': 1,
|
252
276
|
'userDataStream': 1,
|
277
|
+
'capital/withdraw': 1,
|
253
278
|
},
|
254
279
|
},
|
255
280
|
},
|
@@ -408,7 +433,8 @@ class mexc(Exchange, ImplicitAPI):
|
|
408
433
|
},
|
409
434
|
},
|
410
435
|
'options': {
|
411
|
-
'
|
436
|
+
'adjustForTimeDifference': False,
|
437
|
+
'timeDifference': 0,
|
412
438
|
'unavailableContracts': {
|
413
439
|
'BTC/USDT:USDT': True,
|
414
440
|
'LTC/USDT:USDT': True,
|
@@ -432,6 +458,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
432
458
|
'1h': '60m',
|
433
459
|
'4h': '4h',
|
434
460
|
'1d': '1d',
|
461
|
+
'1w': '1W',
|
435
462
|
'1M': '1M',
|
436
463
|
},
|
437
464
|
'swap': {
|
@@ -457,164 +484,85 @@ class mexc(Exchange, ImplicitAPI):
|
|
457
484
|
'LTC': 'LTC',
|
458
485
|
},
|
459
486
|
'networks': {
|
460
|
-
'
|
487
|
+
'ZKSYNC': 'ZKSYNCERA',
|
488
|
+
'TRC20': 'TRX',
|
489
|
+
'TON': 'TONCOIN',
|
490
|
+
'AVAXC': 'AVAX_CCHAIN',
|
491
|
+
'ERC20': 'ETH',
|
461
492
|
'ACA': 'ACALA',
|
462
|
-
'
|
463
|
-
'
|
464
|
-
'
|
465
|
-
'
|
466
|
-
'
|
467
|
-
'
|
468
|
-
'
|
469
|
-
'
|
470
|
-
'ARB': 'Arbitrum One(ARB)',
|
471
|
-
'ARBNOVA': 'ARBNOVA',
|
472
|
-
'ARBONE': 'ArbitrumOne(ARB)',
|
473
|
-
'ARK': 'ARK',
|
493
|
+
'BEP20': 'BSC',
|
494
|
+
'OPTIMISM': 'OP',
|
495
|
+
# 'ADA': 'Cardano(ADA)',
|
496
|
+
# 'AE': 'AE',
|
497
|
+
# 'ALGO': 'Algorand(ALGO)',
|
498
|
+
# 'ALPH': 'Alephium(ALPH)',
|
499
|
+
# 'ARB': 'Arbitrum One(ARB)',
|
500
|
+
# 'ARBONE': 'ArbitrumOne(ARB)',
|
474
501
|
'ASTR': 'ASTAR', # ASTAREVM is different
|
475
|
-
'ATOM': 'Cosmos(ATOM)',
|
476
|
-
'AVAXC': 'Avalanche C Chain(AVAX CCHAIN)',
|
477
|
-
'AVAXX': 'Avalanche X Chain(AVAX XCHAIN)',
|
478
|
-
'AZERO': 'Aleph Zero(AZERO)',
|
479
|
-
'BCH': 'Bitcoin Cash(BCH)',
|
480
|
-
'
|
481
|
-
'
|
482
|
-
'
|
483
|
-
'BEP20': 'BNB Smart Chain(BEP20)',
|
484
|
-
'BITCI': 'BITCI',
|
485
|
-
'BNC': 'BNC',
|
486
|
-
'BNCDOT': 'BNCPOLKA',
|
487
|
-
'BOBA': 'BOBA',
|
488
|
-
'BSC': 'BEP20(BSC)',
|
489
|
-
'BSV': 'Bitcoin SV(BSV)',
|
490
|
-
'BTC': 'Bitcoin(BTC)',
|
502
|
+
# 'ATOM': 'Cosmos(ATOM)',
|
503
|
+
# 'AVAXC': 'Avalanche C Chain(AVAX CCHAIN)',
|
504
|
+
# 'AVAXX': 'Avalanche X Chain(AVAX XCHAIN)',
|
505
|
+
# 'AZERO': 'Aleph Zero(AZERO)',
|
506
|
+
# 'BCH': 'Bitcoin Cash(BCH)',
|
507
|
+
# 'BNCDOT': 'BNCPOLKA',
|
508
|
+
# 'BSV': 'Bitcoin SV(BSV)',
|
509
|
+
# 'BTC': 'Bitcoin(BTC)',
|
491
510
|
'BTM': 'BTM2',
|
492
|
-
'
|
493
|
-
'
|
494
|
-
'
|
495
|
-
'CHZ2': 'Chiliz Chain(CHZ2)',
|
496
|
-
'CKB': 'CKB',
|
497
|
-
'CLORE': 'Clore.ai(CLORE)',
|
511
|
+
# 'CHZ': 'Chiliz Legacy Chain(CHZ)',
|
512
|
+
# 'CHZ2': 'Chiliz Chain(CHZ2)',
|
513
|
+
# 'CLORE': 'Clore.ai(CLORE)',
|
498
514
|
'CRC20': 'CRONOS',
|
499
|
-
'
|
500
|
-
'
|
501
|
-
'
|
502
|
-
'
|
503
|
-
'
|
504
|
-
'DOGE': 'Dogecoin(DOGE)',
|
505
|
-
'DOT': 'Polkadot(DOT)',
|
506
|
-
'DYM': 'Dymension(DYM)',
|
507
|
-
'EDG': 'EDG',
|
508
|
-
'EGLD': 'EGLD',
|
509
|
-
'EOS': 'EOS',
|
510
|
-
'ERC20': 'Ethereum(ERC20)',
|
511
|
-
'ETC': 'Ethereum Classic(ETC)',
|
515
|
+
# 'DC': 'Dogechain(DC)',
|
516
|
+
# 'DNX': 'Dynex(DNX)',
|
517
|
+
# 'DOGE': 'Dogecoin(DOGE)',
|
518
|
+
# 'DOT': 'Polkadot(DOT)',
|
519
|
+
# 'DYM': 'Dymension(DYM)',
|
512
520
|
'ETHF': 'ETF',
|
513
|
-
'ETHW': 'ETHW',
|
514
|
-
'EVER': 'EVER',
|
515
|
-
'FET': 'FET',
|
516
|
-
'FIL': 'FIL',
|
517
|
-
'FIO': 'FIO',
|
518
|
-
'FLOW': 'FLOW',
|
519
|
-
'FSN': 'FSN',
|
520
|
-
'FTM': 'Fantom(FTM)',
|
521
|
-
'FUSE': 'FUSE',
|
522
|
-
'GLMR': 'GLMR',
|
523
|
-
'GRIN': 'GRIN',
|
524
|
-
'HBAR': 'Hedera(HBAR)',
|
525
|
-
'HIVE': 'HIVE',
|
526
521
|
'HRC20': 'HECO',
|
527
|
-
'
|
528
|
-
'ICP': 'Internet Computer(ICP)',
|
529
|
-
'INDEX': 'Index Chain',
|
530
|
-
'IOST': 'IOST',
|
531
|
-
'IOTA': 'IOTA',
|
532
|
-
'IOTX': 'IOTX',
|
533
|
-
'IRIS': 'IRIS',
|
534
|
-
'KAR': 'KAR',
|
535
|
-
'KAS': 'Kaspa(KAS)',
|
536
|
-
'KAVA': 'KAVA',
|
537
|
-
'KDA': 'KDA',
|
538
|
-
'KILT': 'KILT',
|
539
|
-
'KLAY': 'Klaytn(KLAY)',
|
540
|
-
'KMA': 'KMA',
|
541
|
-
'KSM': 'KSM',
|
542
|
-
'LAT': 'LAT',
|
543
|
-
'LAVA': 'Elysium(LAVA)',
|
544
|
-
'LTC': 'Litecoin(LTC)',
|
545
|
-
'LUNA': 'Terra(LUNA)',
|
546
|
-
'MASS': 'MASS',
|
547
|
-
'MATIC': 'Polygon(MATIC)',
|
548
|
-
'MCOIN': 'Mcoin Network',
|
549
|
-
'METIS': 'METIS',
|
550
|
-
'MINA': 'MINA',
|
551
|
-
'MNT': 'Mantle(MNT)',
|
552
|
-
'MOVR': 'MOVR',
|
553
|
-
'MTRG': 'Meter(MTRG)',
|
554
|
-
'NAS': 'NAS',
|
555
|
-
'NEAR': 'NEAR Protocol(NEAR)',
|
556
|
-
'NEBL': 'NEBL',
|
557
|
-
'NEM': 'NEM',
|
558
|
-
'NEO': 'NEO',
|
559
|
-
'NEO3': 'NEO3',
|
560
|
-
'NEOXA': 'Neoxa Network',
|
561
|
-
'NULS': 'NULS',
|
522
|
+
# 'KLAY': 'Klaytn(KLAY)',
|
562
523
|
'OASIS': 'ROSE',
|
563
|
-
'OASYS': 'OASYS',
|
564
524
|
'OKC': 'OKT',
|
565
|
-
'OMN': 'Omega Network(OMN)',
|
566
|
-
'OMNI': 'OMNI',
|
567
|
-
'ONE': 'ONE',
|
568
|
-
'ONT': 'ONT',
|
569
|
-
'OPTIMISM': 'Optimism(OP)',
|
570
|
-
'OSMO': 'OSMO',
|
571
|
-
'PLCU': 'PLCU',
|
572
|
-
'POKT': 'POKT',
|
573
|
-
'QKC': 'QKC',
|
574
|
-
'QTUM': 'QTUM',
|
575
|
-
'RAP20': 'RAP20(Rangers Mainnet)',
|
576
|
-
'REI': 'REI',
|
577
525
|
'RSK': 'RBTC',
|
578
|
-
'RVN': 'Ravencoin(RVN)',
|
579
|
-
'SATOX': 'Satoxcoin(SATOX)',
|
580
|
-
'SC': 'SC',
|
581
|
-
'SCRT': 'SCRT',
|
582
|
-
'SDN': 'SDN',
|
583
|
-
'SGB': 'SGB',
|
584
|
-
'SOL': 'Solana(SOL)',
|
585
|
-
'STAR': 'STAR',
|
586
|
-
'STARK': 'Starknet(STARK)',
|
587
|
-
'STEEM': 'STEEM',
|
588
|
-
'SYS': 'SYS',
|
589
|
-
'TAO': 'Bittensor(TAO)',
|
590
|
-
'TIA': 'Celestia(TIA)',
|
591
|
-
'TOMO': 'TOMO',
|
592
|
-
'TON': 'Toncoin(TON)',
|
593
|
-
'TRC10': 'TRC10',
|
594
|
-
'TRC20': 'Tron(TRC20)',
|
595
|
-
'UGAS': 'UGAS(Ultrain)',
|
596
|
-
'VET': 'VeChain(VET)',
|
597
|
-
'VEX': 'Vexanium(VEX)',
|
598
|
-
'VSYS': 'VSYS',
|
599
|
-
'WAVES': 'WAVES',
|
600
|
-
'WAX': 'WAX',
|
601
|
-
'WEMIX': 'WEMIX',
|
602
|
-
'XCH': 'Chia(XCH)',
|
603
|
-
'XDC': 'XDC',
|
604
|
-
'XEC': 'XEC',
|
605
|
-
'XLM': 'Stellar(XLM)',
|
606
|
-
'XMR': 'Monero(XMR)',
|
607
|
-
'XNA': 'Neurai(XNA)',
|
608
|
-
'XPR': 'XPR Network',
|
609
|
-
'XRD': 'XRD',
|
610
|
-
'XRP': 'Ripple(XRP)',
|
611
|
-
'XTZ': 'XTZ',
|
612
|
-
'XVG': 'XVG',
|
613
|
-
'XYM': 'XYM',
|
614
|
-
'ZEC': 'ZEC',
|
615
|
-
'ZEN': 'ZEN',
|
616
|
-
'ZIL': 'Zilliqa(ZIL)',
|
617
|
-
'ZTG': 'ZTG',
|
526
|
+
# 'RVN': 'Ravencoin(RVN)',
|
527
|
+
# 'SATOX': 'Satoxcoin(SATOX)',
|
528
|
+
# 'SC': 'SC',
|
529
|
+
# 'SCRT': 'SCRT',
|
530
|
+
# 'SDN': 'SDN',
|
531
|
+
# 'SGB': 'SGB',
|
532
|
+
# 'SOL': 'Solana(SOL)',
|
533
|
+
# 'STAR': 'STAR',
|
534
|
+
# 'STARK': 'Starknet(STARK)',
|
535
|
+
# 'STEEM': 'STEEM',
|
536
|
+
# 'SYS': 'SYS',
|
537
|
+
# 'TAO': 'Bittensor(TAO)',
|
538
|
+
# 'TIA': 'Celestia(TIA)',
|
539
|
+
# 'TOMO': 'TOMO',
|
540
|
+
# 'TON': 'Toncoin(TON)',
|
541
|
+
# 'TRC10': 'TRC10',
|
542
|
+
# 'TRC20': 'Tron(TRC20)',
|
543
|
+
# 'UGAS': 'UGAS(Ultrain)',
|
544
|
+
# 'VET': 'VeChain(VET)',
|
545
|
+
# 'VEX': 'Vexanium(VEX)',
|
546
|
+
# 'VSYS': 'VSYS',
|
547
|
+
# 'WAVES': 'WAVES',
|
548
|
+
# 'WAX': 'WAX',
|
549
|
+
# 'WEMIX': 'WEMIX',
|
550
|
+
# 'XCH': 'Chia(XCH)',
|
551
|
+
# 'XDC': 'XDC',
|
552
|
+
# 'XEC': 'XEC',
|
553
|
+
# 'XLM': 'Stellar(XLM)',
|
554
|
+
# 'XMR': 'Monero(XMR)',
|
555
|
+
# 'XNA': 'Neurai(XNA)',
|
556
|
+
# 'XPR': 'XPR Network',
|
557
|
+
# 'XRD': 'XRD',
|
558
|
+
# 'XRP': 'Ripple(XRP)',
|
559
|
+
# 'XTZ': 'XTZ',
|
560
|
+
# 'XVG': 'XVG',
|
561
|
+
# 'XYM': 'XYM',
|
562
|
+
# 'ZEC': 'ZEC',
|
563
|
+
# 'ZEN': 'ZEN',
|
564
|
+
# 'ZIL': 'Zilliqa(ZIL)',
|
565
|
+
# 'ZTG': 'ZTG',
|
618
566
|
# todo: uncomment below after concensus
|
619
567
|
# 'ALAYA': 'ATP',
|
620
568
|
# 'ANDUSCHAIN': 'DEB',
|
@@ -722,69 +670,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
722
670
|
# OKB <> OKT(for usdt it's exception) for OKC, PMEER, FLARE, STRD, ZEL, FUND, "NONE", CRING, FREETON, QTZ (probably unique network is meant), HT, BSC(RACAV1), BSC(RACAV2), AMBROSUS, BAJUN, NOM. their individual info is at https://www.mexc.com/api/platform/asset/spot/{COINNAME}
|
723
671
|
},
|
724
672
|
'networksById': {
|
725
|
-
'Aleph Zero(AZERO)': 'AZERO',
|
726
|
-
'Alephium(ALPH)': 'ALPH',
|
727
|
-
'Algorand(ALGO)': 'ALGO',
|
728
|
-
'APTOS(APT)': 'APT',
|
729
|
-
'Arbitrum One(ARB)': 'ARB',
|
730
|
-
'Avalanche C Chain(AVAX CCHAIN)': 'AVAXC',
|
731
|
-
'Avalanche X Chain(AVAX XCHAIN)': 'AVAXX',
|
732
|
-
'BEP20(BSC)': 'BSC',
|
733
|
-
'Bitcoin Cash(BCH)': 'BCH',
|
734
|
-
'Bitcoin SV(BSV)': 'BSV',
|
735
|
-
'Bitcoin(BTC)': 'BTC',
|
736
|
-
'Bittensor(TAO)': 'TAO',
|
737
|
-
'BNB Beacon Chain(BEP2)': 'BEP2',
|
738
673
|
'BNB Smart Chain(BEP20-RACAV1)': 'BSC',
|
739
674
|
'BNB Smart Chain(BEP20-RACAV2)': 'BSC',
|
740
675
|
'BNB Smart Chain(BEP20)': 'BSC',
|
741
|
-
'Cardano(ADA)': 'ADA',
|
742
|
-
'Celestia(TIA)': 'TIA',
|
743
|
-
'Chia(XCH)': 'XCH',
|
744
|
-
'Chiliz Chain(CHZ2)': 'CHZ2',
|
745
|
-
'Chiliz Legacy Chain(CHZ)': 'CHZ',
|
746
|
-
'Clore.ai(CLORE)': 'CLORE',
|
747
|
-
'Cosmos(ATOM)': 'ATOM',
|
748
|
-
'Dogechain(DC)': 'DC',
|
749
|
-
'Dogecoin(DOGE)': 'DOGE',
|
750
|
-
'Dymension(DYM)': 'DYM',
|
751
|
-
'Dynex(DNX)': 'DNX',
|
752
|
-
'Elysium(LAVA)': 'LAVA',
|
753
|
-
'Ethereum Classic(ETC)': 'ETC',
|
754
|
-
'Ethereum(ERC20)': 'ERC20',
|
755
|
-
'Fantom(FTM)': 'FTM',
|
756
|
-
'Hedera(HBAR)': 'HBAR',
|
757
|
-
'Index Chain': 'INDEX',
|
758
|
-
'Internet Computer(ICP)': 'ICP',
|
759
|
-
'Kaspa(KAS)': 'KAS',
|
760
|
-
'Klaytn(KLAY)': 'KLAY',
|
761
|
-
'Litecoin(LTC)': 'LTC',
|
762
|
-
'Mantle(MNT)': 'MNT',
|
763
|
-
'Mcoin Network': 'MCOIN',
|
764
|
-
'Meter(MTRG)': 'MTRG',
|
765
|
-
'Monero(XMR)': 'XMR',
|
766
|
-
'NEAR Protocol(NEAR)': 'NEAR',
|
767
|
-
'Neoxa Network': 'NEOXA',
|
768
|
-
'Neurai(XNA)': 'XNA',
|
769
|
-
'Omega Network(OMN)': 'OMN',
|
770
|
-
'Optimism(OP)': 'OPTIMISM',
|
771
|
-
'Polkadot(DOT)': 'DOT',
|
772
|
-
'Polygon(MATIC)': 'MATIC',
|
773
|
-
'RAP20(Rangers Mainnet)': 'RAP20',
|
774
|
-
'Ravencoin(RVN)': 'RVN',
|
775
|
-
'Ripple(XRP)': 'XRP',
|
776
|
-
'Satoxcoin(SATOX)': 'SATOX',
|
777
|
-
'Solana(SOL)': 'SOL',
|
778
|
-
'Starknet(STARK)': 'STARK',
|
779
|
-
'Stellar(XLM)': 'XLM',
|
780
|
-
'Terra(LUNA)': 'LUNA',
|
781
|
-
'Toncoin(TON)': 'TON',
|
782
|
-
'Tron(TRC20)': 'TRC20',
|
783
|
-
'UGAS(Ultrain)': 'UGAS',
|
784
|
-
'VeChain(VET)': 'VET',
|
785
|
-
'Vexanium(VEX)': 'VEX',
|
786
|
-
'XPR Network': 'XPR',
|
787
|
-
'Zilliqa(ZIL)': 'ZIL',
|
788
676
|
# TODO: uncomment below after deciding unified name
|
789
677
|
# 'PEPE COIN BSC':
|
790
678
|
# 'SMART BLOCKCHAIN':
|
@@ -802,27 +690,166 @@ class mexc(Exchange, ImplicitAPI):
|
|
802
690
|
'maxTimeTillEnd': 90 * 86400 * 1000 - 1, # 90 days
|
803
691
|
'broker': 'CCXT',
|
804
692
|
},
|
693
|
+
'features': {
|
694
|
+
'default': {
|
695
|
+
'sandbox': False,
|
696
|
+
'createOrder': {
|
697
|
+
'marginMode': True,
|
698
|
+
'triggerPrice': False,
|
699
|
+
'triggerDirection': False,
|
700
|
+
'triggerPriceType': {
|
701
|
+
'last': False,
|
702
|
+
'mark': False,
|
703
|
+
'index': False,
|
704
|
+
},
|
705
|
+
'stopLossPrice': False, # todo
|
706
|
+
'takeProfitPrice': False,
|
707
|
+
'attachedStopLossTakeProfit': None,
|
708
|
+
'timeInForce': {
|
709
|
+
'IOC': True,
|
710
|
+
'FOK': True,
|
711
|
+
'PO': True,
|
712
|
+
'GTD': False,
|
713
|
+
},
|
714
|
+
'hedged': True, # todo implement
|
715
|
+
'trailing': False,
|
716
|
+
'leverage': True, # todo implement
|
717
|
+
'marketBuyByCost': True,
|
718
|
+
'marketBuyRequiresPrice': False,
|
719
|
+
'selfTradePrevention': False,
|
720
|
+
'iceberg': False,
|
721
|
+
},
|
722
|
+
'createOrders': {
|
723
|
+
'max': 20,
|
724
|
+
},
|
725
|
+
'fetchMyTrades': {
|
726
|
+
'marginMode': False,
|
727
|
+
'limit': 100,
|
728
|
+
'daysBack': 30,
|
729
|
+
'untilDays': None,
|
730
|
+
},
|
731
|
+
'fetchOrder': {
|
732
|
+
'marginMode': False,
|
733
|
+
'trigger': False,
|
734
|
+
'trailing': False,
|
735
|
+
},
|
736
|
+
'fetchOpenOrders': {
|
737
|
+
'marginMode': True,
|
738
|
+
'limit': None,
|
739
|
+
'trigger': False,
|
740
|
+
'trailing': False,
|
741
|
+
},
|
742
|
+
'fetchOrders': {
|
743
|
+
'marginMode': True,
|
744
|
+
'limit': 1000,
|
745
|
+
'daysBack': 7,
|
746
|
+
'untilDays': 7,
|
747
|
+
'trigger': False,
|
748
|
+
'trailing': False,
|
749
|
+
},
|
750
|
+
'fetchClosedOrders': {
|
751
|
+
'marginMode': True,
|
752
|
+
'limit': 1000,
|
753
|
+
'daysBack': 7,
|
754
|
+
'daysBackCanceled': 7,
|
755
|
+
'untilDays': 7,
|
756
|
+
'trigger': False,
|
757
|
+
'trailing': False,
|
758
|
+
},
|
759
|
+
'fetchOHLCV': {
|
760
|
+
'limit': 1000,
|
761
|
+
},
|
762
|
+
},
|
763
|
+
'spot': {
|
764
|
+
'extends': 'default',
|
765
|
+
},
|
766
|
+
'forDerivs': {
|
767
|
+
'extends': 'default',
|
768
|
+
'createOrder': {
|
769
|
+
'triggerPrice': True,
|
770
|
+
'triggerPriceType': {
|
771
|
+
'last': True,
|
772
|
+
'mark': True,
|
773
|
+
'index': True,
|
774
|
+
},
|
775
|
+
'triggerDirection': True, # todo
|
776
|
+
'stopLossPrice': False, # todo
|
777
|
+
'takeProfitPrice': False, # todo
|
778
|
+
'hedged': True,
|
779
|
+
'leverage': True, # todo
|
780
|
+
'marketBuyByCost': False,
|
781
|
+
},
|
782
|
+
'createOrders': None, # todo: needs implementation https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance:~:text=Order%20the%20contract%20in%20batch
|
783
|
+
'fetchMyTrades': {
|
784
|
+
'marginMode': False,
|
785
|
+
'limit': 100,
|
786
|
+
'daysBack': 90,
|
787
|
+
'untilDays': 90,
|
788
|
+
},
|
789
|
+
'fetchOrder': {
|
790
|
+
'marginMode': False,
|
791
|
+
},
|
792
|
+
'fetchOpenOrders': {
|
793
|
+
'marginMode': False,
|
794
|
+
'limit': 100,
|
795
|
+
'trigger': True,
|
796
|
+
'trailing': False,
|
797
|
+
},
|
798
|
+
'fetchOrders': {
|
799
|
+
'marginMode': False,
|
800
|
+
'limit': 100,
|
801
|
+
'daysBack': 90,
|
802
|
+
'untilDays': 90,
|
803
|
+
'trigger': True,
|
804
|
+
'trailing': False,
|
805
|
+
},
|
806
|
+
'fetchClosedOrders': {
|
807
|
+
'marginMode': False,
|
808
|
+
'limit': 100,
|
809
|
+
'daysBack': 90,
|
810
|
+
'daysBackCanceled': None,
|
811
|
+
'untilDays': 90,
|
812
|
+
'trigger': True,
|
813
|
+
'trailing': False,
|
814
|
+
},
|
815
|
+
'fetchOHLCV': {
|
816
|
+
'limit': 2000,
|
817
|
+
},
|
818
|
+
},
|
819
|
+
'swap': {
|
820
|
+
'linear': {
|
821
|
+
'extends': 'forDerivs',
|
822
|
+
},
|
823
|
+
'inverse': {
|
824
|
+
'extends': 'forDerivs',
|
825
|
+
},
|
826
|
+
},
|
827
|
+
'future': {
|
828
|
+
'linear': None,
|
829
|
+
'inverse': None,
|
830
|
+
},
|
831
|
+
},
|
805
832
|
'commonCurrencies': {
|
806
833
|
'BEYONDPROTOCOL': 'BEYOND',
|
807
834
|
'BIFI': 'BIFIF',
|
808
|
-
'BYN': '
|
835
|
+
'BYN': 'BEYONDFI',
|
809
836
|
'COFI': 'COFIX', # conflict with CoinFi
|
810
|
-
'DFI': '
|
811
|
-
'DFT': '
|
837
|
+
'DFI': 'DFISTARTER',
|
838
|
+
'DFT': 'DFUTURE',
|
812
839
|
'DRK': 'DRK',
|
813
|
-
'EGC': '
|
840
|
+
'EGC': 'EGORASCREDIT',
|
814
841
|
'FLUX1': 'FLUX', # switched places
|
815
842
|
'FLUX': 'FLUX1', # switched places
|
816
|
-
'FREE': '
|
843
|
+
'FREE': 'FREEROSSDAO', # conflict with FREE Coin
|
817
844
|
'GAS': 'GASDAO',
|
818
845
|
'GASNEO': 'GAS',
|
819
|
-
'GMT': '
|
846
|
+
'GMT': 'GMTTOKEN', # Conflict with GMT(STEPN)
|
820
847
|
'STEPN': 'GMT', # Conflict with GMT Token
|
821
|
-
'HERO': '
|
822
|
-
'MIMO': '
|
823
|
-
'PROS': '
|
824
|
-
'SIN': '
|
825
|
-
'SOUL': '
|
848
|
+
'HERO': 'STEPHERO', # conflict with Metahero
|
849
|
+
'MIMO': 'MIMOSA',
|
850
|
+
'PROS': 'PROSFINANCE', # conflict with Prosper
|
851
|
+
'SIN': 'SINCITYTOKEN',
|
852
|
+
'SOUL': 'SOULSWAP',
|
826
853
|
},
|
827
854
|
'exceptions': {
|
828
855
|
'exact': {
|
@@ -899,8 +926,8 @@ class mexc(Exchange, ImplicitAPI):
|
|
899
926
|
'30032': InvalidOrder, # Cannot exceed the maximum position
|
900
927
|
'30041': InvalidOrder, # current order type can not place order
|
901
928
|
'60005': ExchangeError, # your account is abnormal
|
902
|
-
'700001': AuthenticationError, # API
|
903
|
-
'700002': AuthenticationError, # Signature for self request is not valid
|
929
|
+
'700001': AuthenticationError, # {"code":700002,"msg":"Signature for self request is not valid."} # same message for expired API keys
|
930
|
+
'700002': AuthenticationError, # Signature for self request is not valid # or the API secret is incorrect
|
904
931
|
'700004': BadRequest, # Param 'origClientOrderId' or 'orderId' must be sent, but both were empty/null
|
905
932
|
'700005': InvalidNonce, # recvWindow must less than 60000
|
906
933
|
'700006': BadRequest, # IP non white list
|
@@ -946,6 +973,10 @@ class mexc(Exchange, ImplicitAPI):
|
|
946
973
|
async def fetch_status(self, params={}):
|
947
974
|
"""
|
948
975
|
the latest known information on the availability of the exchange API
|
976
|
+
|
977
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#test-connectivity
|
978
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-server-time
|
979
|
+
|
949
980
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
950
981
|
:returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
|
951
982
|
"""
|
@@ -979,6 +1010,10 @@ class mexc(Exchange, ImplicitAPI):
|
|
979
1010
|
async def fetch_time(self, params={}):
|
980
1011
|
"""
|
981
1012
|
fetches the current integer timestamp in milliseconds from the exchange server
|
1013
|
+
|
1014
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#check-server-time
|
1015
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-server-time
|
1016
|
+
|
982
1017
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
983
1018
|
:returns int: the current integer timestamp in milliseconds from the exchange server
|
984
1019
|
"""
|
@@ -998,10 +1033,12 @@ class mexc(Exchange, ImplicitAPI):
|
|
998
1033
|
return self.safe_integer(response, 'data')
|
999
1034
|
return None
|
1000
1035
|
|
1001
|
-
async def fetch_currencies(self, params={}):
|
1036
|
+
async def fetch_currencies(self, params={}) -> Currencies:
|
1002
1037
|
"""
|
1003
1038
|
fetches all available currencies on an exchange
|
1004
|
-
|
1039
|
+
|
1040
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
|
1041
|
+
|
1005
1042
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1006
1043
|
:returns dict: an associative dictionary of currencies
|
1007
1044
|
"""
|
@@ -1050,7 +1087,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
1050
1087
|
# ]
|
1051
1088
|
# }
|
1052
1089
|
#
|
1053
|
-
result = {}
|
1090
|
+
result: dict = {}
|
1054
1091
|
for i in range(0, len(response)):
|
1055
1092
|
currency = response[i]
|
1056
1093
|
id = self.safe_string(currency, 'coin')
|
@@ -1062,11 +1099,11 @@ class mexc(Exchange, ImplicitAPI):
|
|
1062
1099
|
currencyWithdrawMax = None
|
1063
1100
|
depositEnabled = False
|
1064
1101
|
withdrawEnabled = False
|
1065
|
-
networks = {}
|
1102
|
+
networks: dict = {}
|
1066
1103
|
chains = self.safe_value(currency, 'networkList', [])
|
1067
1104
|
for j in range(0, len(chains)):
|
1068
1105
|
chain = chains[j]
|
1069
|
-
networkId = self.
|
1106
|
+
networkId = self.safe_string_2(chain, 'netWork', 'network')
|
1070
1107
|
network = self.network_id_to_code(networkId)
|
1071
1108
|
isDepositEnabled = self.safe_bool(chain, 'depositEnable', False)
|
1072
1109
|
isWithdrawEnabled = self.safe_bool(chain, 'withdrawEnable', False)
|
@@ -1132,17 +1169,33 @@ class mexc(Exchange, ImplicitAPI):
|
|
1132
1169
|
}
|
1133
1170
|
return result
|
1134
1171
|
|
1135
|
-
async def fetch_markets(self, params={}):
|
1172
|
+
async def fetch_markets(self, params={}) -> List[Market]:
|
1136
1173
|
"""
|
1137
1174
|
retrieves data on all markets for mexc
|
1175
|
+
|
1176
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#exchange-information
|
1177
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
|
1178
|
+
|
1138
1179
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1139
1180
|
:returns dict[]: an array of objects representing market data
|
1140
1181
|
"""
|
1141
|
-
|
1142
|
-
|
1182
|
+
if self.options['adjustForTimeDifference']:
|
1183
|
+
await self.load_time_difference()
|
1184
|
+
spotMarketPromise = self.fetch_spot_markets(params)
|
1185
|
+
swapMarketPromise = self.fetch_swap_markets(params)
|
1186
|
+
spotMarket, swapMarket = await asyncio.gather(*[spotMarketPromise, swapMarketPromise])
|
1143
1187
|
return self.array_concat(spotMarket, swapMarket)
|
1144
1188
|
|
1145
1189
|
async def fetch_spot_markets(self, params={}):
|
1190
|
+
"""
|
1191
|
+
@ignore
|
1192
|
+
retrieves data on all spot markets for mexc
|
1193
|
+
|
1194
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#exchange-information
|
1195
|
+
|
1196
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1197
|
+
:returns dict[]: an array of objects representing market data
|
1198
|
+
"""
|
1146
1199
|
response = await self.spotPublicGetExchangeInfo(params)
|
1147
1200
|
#
|
1148
1201
|
# {
|
@@ -1153,7 +1206,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
1153
1206
|
# "symbols": [
|
1154
1207
|
# {
|
1155
1208
|
# "symbol": "OGNUSDT",
|
1156
|
-
# "status": "
|
1209
|
+
# "status": "1",
|
1157
1210
|
# "baseAsset": "OGN",
|
1158
1211
|
# "baseAssetPrecision": "2",
|
1159
1212
|
# "quoteAsset": "USDT",
|
@@ -1198,7 +1251,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
1198
1251
|
status = self.safe_string(market, 'status')
|
1199
1252
|
isSpotTradingAllowed = self.safe_value(market, 'isSpotTradingAllowed')
|
1200
1253
|
active = False
|
1201
|
-
if (status == '
|
1254
|
+
if (status == '1') and (isSpotTradingAllowed):
|
1202
1255
|
active = True
|
1203
1256
|
isMarginTradingAllowed = self.safe_value(market, 'isMarginTradingAllowed')
|
1204
1257
|
makerCommission = self.safe_number(market, 'makerCommission')
|
@@ -1258,7 +1311,19 @@ class mexc(Exchange, ImplicitAPI):
|
|
1258
1311
|
return result
|
1259
1312
|
|
1260
1313
|
async def fetch_swap_markets(self, params={}):
|
1314
|
+
"""
|
1315
|
+
@ignore
|
1316
|
+
retrieves data on all swap markets for mexc
|
1317
|
+
|
1318
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
|
1319
|
+
|
1320
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1321
|
+
:returns dict[]: an array of objects representing market data
|
1322
|
+
"""
|
1323
|
+
currentRl: number = self.rateLimit
|
1324
|
+
self.set_property(self, 'rateLimit', 10) # see comment: https://github.com/ccxt/ccxt/pull/23698
|
1261
1325
|
response = await self.contractPublicGetDetail(params)
|
1326
|
+
self.set_property(self, 'rateLimit', currentRl)
|
1262
1327
|
#
|
1263
1328
|
# {
|
1264
1329
|
# "success":true,
|
@@ -1370,8 +1435,10 @@ class mexc(Exchange, ImplicitAPI):
|
|
1370
1435
|
|
1371
1436
|
async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
1372
1437
|
"""
|
1373
|
-
|
1374
|
-
|
1438
|
+
|
1439
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#order-book
|
1440
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-s-depth-information
|
1441
|
+
|
1375
1442
|
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
1376
1443
|
:param str symbol: unified symbol of the market to fetch the order book for
|
1377
1444
|
:param int [limit]: the maximum amount of order book entries to return
|
@@ -1380,7 +1447,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
1380
1447
|
"""
|
1381
1448
|
await self.load_markets()
|
1382
1449
|
market = self.market(symbol)
|
1383
|
-
request = {
|
1450
|
+
request: dict = {
|
1384
1451
|
'symbol': market['id'],
|
1385
1452
|
}
|
1386
1453
|
if limit is not None:
|
@@ -1441,9 +1508,11 @@ class mexc(Exchange, ImplicitAPI):
|
|
1441
1508
|
|
1442
1509
|
async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
1443
1510
|
"""
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1511
|
+
|
1512
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#recent-trades-list
|
1513
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#compressed-aggregate-trades-list
|
1514
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-transaction-data
|
1515
|
+
|
1447
1516
|
get the list of most recent trades for a particular symbol
|
1448
1517
|
:param str symbol: unified symbol of the market to fetch trades for
|
1449
1518
|
:param int [since]: timestamp in ms of the earliest trade to fetch
|
@@ -1454,14 +1523,14 @@ class mexc(Exchange, ImplicitAPI):
|
|
1454
1523
|
"""
|
1455
1524
|
await self.load_markets()
|
1456
1525
|
market = self.market(symbol)
|
1457
|
-
request = {
|
1526
|
+
request: dict = {
|
1458
1527
|
'symbol': market['id'],
|
1459
1528
|
}
|
1460
1529
|
if limit is not None:
|
1461
1530
|
request['limit'] = limit
|
1462
1531
|
trades = None
|
1463
1532
|
if market['spot']:
|
1464
|
-
until = self.safe_integer_n(params, ['endTime', 'until'
|
1533
|
+
until = self.safe_integer_n(params, ['endTime', 'until'])
|
1465
1534
|
if since is not None:
|
1466
1535
|
request['startTime'] = since
|
1467
1536
|
if until is None:
|
@@ -1532,7 +1601,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
1532
1601
|
trades = self.safe_value(response, 'data')
|
1533
1602
|
return self.parse_trades(trades, market, since, limit)
|
1534
1603
|
|
1535
|
-
def parse_trade(self, trade, market: Market = None) -> Trade:
|
1604
|
+
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
1536
1605
|
id = None
|
1537
1606
|
timestamp = None
|
1538
1607
|
orderId = None
|
@@ -1689,8 +1758,10 @@ class mexc(Exchange, ImplicitAPI):
|
|
1689
1758
|
|
1690
1759
|
async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
1691
1760
|
"""
|
1692
|
-
|
1693
|
-
|
1761
|
+
|
1762
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#kline-candlestick-data
|
1763
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#k-line-data
|
1764
|
+
|
1694
1765
|
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
1695
1766
|
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
1696
1767
|
:param str timeframe: the length of time each candle represents
|
@@ -1712,13 +1783,13 @@ class mexc(Exchange, ImplicitAPI):
|
|
1712
1783
|
timeframes = self.safe_value(options, market['type'], {})
|
1713
1784
|
timeframeValue = self.safe_string(timeframes, timeframe)
|
1714
1785
|
duration = self.parse_timeframe(timeframe) * 1000
|
1715
|
-
request = {
|
1786
|
+
request: dict = {
|
1716
1787
|
'symbol': market['id'],
|
1717
1788
|
'interval': timeframeValue,
|
1718
1789
|
}
|
1719
1790
|
candles = None
|
1720
1791
|
if market['spot']:
|
1721
|
-
until = self.safe_integer_n(params, ['until', 'endTime'
|
1792
|
+
until = self.safe_integer_n(params, ['until', 'endTime'])
|
1722
1793
|
if since is not None:
|
1723
1794
|
request['startTime'] = since
|
1724
1795
|
if until is None:
|
@@ -1729,7 +1800,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
1729
1800
|
if limit is not None:
|
1730
1801
|
request['limit'] = limit
|
1731
1802
|
if until is not None:
|
1732
|
-
params = self.omit(params, ['until'
|
1803
|
+
params = self.omit(params, ['until'])
|
1733
1804
|
request['endTime'] = until
|
1734
1805
|
response = await self.spotPublicGetKlines(self.extend(request, params))
|
1735
1806
|
#
|
@@ -1748,11 +1819,11 @@ class mexc(Exchange, ImplicitAPI):
|
|
1748
1819
|
#
|
1749
1820
|
candles = response
|
1750
1821
|
elif market['swap']:
|
1751
|
-
until = self.safe_integer_product_n(params, ['until', 'endTime'
|
1822
|
+
until = self.safe_integer_product_n(params, ['until', 'endTime'], 0.001)
|
1752
1823
|
if since is not None:
|
1753
1824
|
request['start'] = self.parse_to_int(since / 1000)
|
1754
1825
|
if until is not None:
|
1755
|
-
params = self.omit(params, ['until'
|
1826
|
+
params = self.omit(params, ['until'])
|
1756
1827
|
request['end'] = until
|
1757
1828
|
priceType = self.safe_string(params, 'price', 'default')
|
1758
1829
|
params = self.omit(params, 'price')
|
@@ -1797,12 +1868,16 @@ class mexc(Exchange, ImplicitAPI):
|
|
1797
1868
|
async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
1798
1869
|
"""
|
1799
1870
|
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
1871
|
+
|
1872
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
|
1873
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
|
1874
|
+
|
1800
1875
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
1801
1876
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1802
1877
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1803
1878
|
"""
|
1804
1879
|
await self.load_markets()
|
1805
|
-
request = {}
|
1880
|
+
request: dict = {}
|
1806
1881
|
market = None
|
1807
1882
|
isSingularMarket = False
|
1808
1883
|
if symbols is not None:
|
@@ -1878,6 +1953,10 @@ class mexc(Exchange, ImplicitAPI):
|
|
1878
1953
|
async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
1879
1954
|
"""
|
1880
1955
|
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
1956
|
+
|
1957
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
|
1958
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
|
1959
|
+
|
1881
1960
|
:param str symbol: unified symbol of the market to fetch the ticker for
|
1882
1961
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1883
1962
|
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
@@ -1886,7 +1965,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
1886
1965
|
market = self.market(symbol)
|
1887
1966
|
marketType, query = self.handle_market_type_and_params('fetchTicker', market, params)
|
1888
1967
|
ticker = None
|
1889
|
-
request = {
|
1968
|
+
request: dict = {
|
1890
1969
|
'symbol': market['id'],
|
1891
1970
|
}
|
1892
1971
|
if marketType == 'spot':
|
@@ -1944,7 +2023,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
1944
2023
|
# when it's single symbol request, the returned structure is different(singular object) for both spot & swap, thus we need to wrap inside array
|
1945
2024
|
return self.parse_ticker(ticker, market)
|
1946
2025
|
|
1947
|
-
def parse_ticker(self, ticker, market: Market = None) -> Ticker:
|
2026
|
+
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
1948
2027
|
marketId = self.safe_string(ticker, 'symbol')
|
1949
2028
|
market = self.safe_market(marketId, market)
|
1950
2029
|
timestamp = None
|
@@ -2060,6 +2139,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
2060
2139
|
async def fetch_bids_asks(self, symbols: Strings = None, params={}):
|
2061
2140
|
"""
|
2062
2141
|
fetches the bid and ask price and volume for multiple markets
|
2142
|
+
|
2143
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#symbol-order-book-ticker
|
2144
|
+
|
2063
2145
|
:param str[]|None symbols: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
|
2064
2146
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2065
2147
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
@@ -2096,7 +2178,29 @@ class mexc(Exchange, ImplicitAPI):
|
|
2096
2178
|
async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
|
2097
2179
|
"""
|
2098
2180
|
create a market buy order by providing the symbol and cost
|
2099
|
-
|
2181
|
+
|
2182
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
|
2183
|
+
|
2184
|
+
:param str symbol: unified symbol of the market to create an order in
|
2185
|
+
:param float cost: how much you want to trade in units of the quote currency
|
2186
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2187
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2188
|
+
"""
|
2189
|
+
await self.load_markets()
|
2190
|
+
market = self.market(symbol)
|
2191
|
+
if not market['spot']:
|
2192
|
+
raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
|
2193
|
+
req = {
|
2194
|
+
'cost': cost,
|
2195
|
+
}
|
2196
|
+
return await self.create_order(symbol, 'market', 'buy', 0, None, self.extend(req, params))
|
2197
|
+
|
2198
|
+
async def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
|
2199
|
+
"""
|
2200
|
+
create a market sell order by providing the symbol and cost
|
2201
|
+
|
2202
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
|
2203
|
+
|
2100
2204
|
:param str symbol: unified symbol of the market to create an order in
|
2101
2205
|
:param float cost: how much you want to trade in units of the quote currency
|
2102
2206
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -2106,31 +2210,37 @@ class mexc(Exchange, ImplicitAPI):
|
|
2106
2210
|
market = self.market(symbol)
|
2107
2211
|
if not market['spot']:
|
2108
2212
|
raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
|
2109
|
-
|
2110
|
-
|
2213
|
+
req = {
|
2214
|
+
'cost': cost,
|
2215
|
+
}
|
2216
|
+
return await self.create_order(symbol, 'market', 'sell', 0, None, self.extend(req, params))
|
2111
2217
|
|
2112
2218
|
async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
2113
2219
|
"""
|
2114
2220
|
create a trade order
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2221
|
+
|
2222
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
|
2223
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
|
2224
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
|
2225
|
+
|
2118
2226
|
:param str symbol: unified symbol of the market to create an order in
|
2119
2227
|
:param str type: 'market' or 'limit'
|
2120
2228
|
:param str side: 'buy' or 'sell'
|
2121
2229
|
:param float amount: how much of currency you want to trade in units of base currency
|
2122
|
-
:param float [price]: the price at which the order is to be
|
2230
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
2123
2231
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2124
2232
|
:param str [params.marginMode]: only 'isolated' is supported for spot-margin trading
|
2125
2233
|
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
|
2126
2234
|
:param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
|
2127
2235
|
:param bool [params.reduceOnly]: *contract only* indicates if self order is to reduce the size of a position
|
2128
|
-
|
2129
|
-
|
2236
|
+
:param bool [params.hedged]: *swap only* True for hedged mode, False for one way mode, default is False
|
2237
|
+
|
2238
|
+
EXCHANGE SPECIFIC PARAMETERS
|
2130
2239
|
:param int [params.leverage]: *contract only* leverage is necessary on isolated margin
|
2131
2240
|
:param long [params.positionId]: *contract only* it is recommended to hasattr(self, fill) parameter when closing a position
|
2132
2241
|
:param str [params.externalOid]: *contract only* external order ID
|
2133
2242
|
:param int [params.positionMode]: *contract only* 1:hedge, 2:one-way, default: the user's current config
|
2243
|
+
:param boolean [params.test]: *spot only* whether to use the test endpoint or not, default is False
|
2134
2244
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2135
2245
|
"""
|
2136
2246
|
await self.load_markets()
|
@@ -2144,27 +2254,26 @@ class mexc(Exchange, ImplicitAPI):
|
|
2144
2254
|
def create_spot_order_request(self, market, type, side, amount, price=None, marginMode=None, params={}):
|
2145
2255
|
symbol = market['symbol']
|
2146
2256
|
orderSide = side.upper()
|
2147
|
-
request = {
|
2257
|
+
request: dict = {
|
2148
2258
|
'symbol': market['id'],
|
2149
2259
|
'side': orderSide,
|
2150
2260
|
'type': type.upper(),
|
2151
2261
|
}
|
2152
|
-
if
|
2153
|
-
createMarketBuyOrderRequiresPrice = True
|
2154
|
-
createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True)
|
2262
|
+
if type == 'market':
|
2155
2263
|
cost = self.safe_number_2(params, 'cost', 'quoteOrderQty')
|
2156
2264
|
params = self.omit(params, 'cost')
|
2157
2265
|
if cost is not None:
|
2158
2266
|
amount = cost
|
2159
|
-
|
2267
|
+
request['quoteOrderQty'] = self.cost_to_precision(symbol, amount)
|
2268
|
+
else:
|
2160
2269
|
if price is None:
|
2161
|
-
|
2270
|
+
request['quantity'] = self.amount_to_precision(symbol, amount)
|
2162
2271
|
else:
|
2163
2272
|
amountString = self.number_to_string(amount)
|
2164
2273
|
priceString = self.number_to_string(price)
|
2165
2274
|
quoteAmount = Precise.string_mul(amountString, priceString)
|
2166
2275
|
amount = quoteAmount
|
2167
|
-
|
2276
|
+
request['quoteOrderQty'] = self.cost_to_precision(symbol, amount)
|
2168
2277
|
else:
|
2169
2278
|
request['quantity'] = self.amount_to_precision(symbol, amount)
|
2170
2279
|
if price is not None:
|
@@ -2183,9 +2292,31 @@ class mexc(Exchange, ImplicitAPI):
|
|
2183
2292
|
return self.extend(request, params)
|
2184
2293
|
|
2185
2294
|
async def create_spot_order(self, market, type, side, amount, price=None, marginMode=None, params={}):
|
2295
|
+
"""
|
2296
|
+
@ignore
|
2297
|
+
create a trade order
|
2298
|
+
|
2299
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
|
2300
|
+
|
2301
|
+
:param str market: unified symbol of the market to create an order in
|
2302
|
+
:param str type: 'market' or 'limit'
|
2303
|
+
:param str side: 'buy' or 'sell'
|
2304
|
+
:param float amount: how much of currency you want to trade in units of base currency
|
2305
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
2306
|
+
:param str [marginMode]: only 'isolated' is supported for spot-margin trading
|
2307
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2308
|
+
:param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
|
2309
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2310
|
+
"""
|
2186
2311
|
await self.load_markets()
|
2312
|
+
test = self.safe_bool(params, 'test', False)
|
2313
|
+
params = self.omit(params, 'test')
|
2187
2314
|
request = self.create_spot_order_request(market, type, side, amount, price, marginMode, params)
|
2188
|
-
response =
|
2315
|
+
response = None
|
2316
|
+
if test:
|
2317
|
+
response = await self.spotPrivatePostOrderTest(request)
|
2318
|
+
else:
|
2319
|
+
response = await self.spotPrivatePostOrder(request)
|
2189
2320
|
#
|
2190
2321
|
# spot
|
2191
2322
|
#
|
@@ -2208,11 +2339,40 @@ class mexc(Exchange, ImplicitAPI):
|
|
2208
2339
|
order = self.parse_order(response, market)
|
2209
2340
|
order['side'] = side
|
2210
2341
|
order['type'] = type
|
2211
|
-
order
|
2212
|
-
|
2342
|
+
if self.safe_string(order, 'price') is None:
|
2343
|
+
order['price'] = price
|
2344
|
+
if self.safe_string(order, 'amount') is None:
|
2345
|
+
order['amount'] = amount
|
2213
2346
|
return order
|
2214
2347
|
|
2215
2348
|
async def create_swap_order(self, market, type, side, amount, price=None, marginMode=None, params={}):
|
2349
|
+
"""
|
2350
|
+
@ignore
|
2351
|
+
create a trade order
|
2352
|
+
|
2353
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
|
2354
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
|
2355
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
|
2356
|
+
|
2357
|
+
:param str market: unified symbol of the market to create an order in
|
2358
|
+
:param str type: 'market' or 'limit'
|
2359
|
+
:param str side: 'buy' or 'sell'
|
2360
|
+
:param float amount: how much of currency you want to trade in units of base currency
|
2361
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
2362
|
+
:param str [marginMode]: only 'isolated' is supported for spot-margin trading
|
2363
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2364
|
+
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
|
2365
|
+
:param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
|
2366
|
+
:param bool [params.reduceOnly]: indicates if self order is to reduce the size of a position
|
2367
|
+
:param bool [params.hedged]: *swap only* True for hedged mode, False for one way mode, default is False
|
2368
|
+
|
2369
|
+
EXCHANGE SPECIFIC PARAMETERS
|
2370
|
+
:param int [params.leverage]: leverage is necessary on isolated margin
|
2371
|
+
:param long [params.positionId]: it is recommended to hasattr(self, fill) parameter when closing a position
|
2372
|
+
:param str [params.externalOid]: external order ID
|
2373
|
+
:param int [params.positionMode]: 1:hedge, 2:one-way, default: the user's current config
|
2374
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2375
|
+
"""
|
2216
2376
|
await self.load_markets()
|
2217
2377
|
symbol = market['symbol']
|
2218
2378
|
unavailableContracts = self.safe_value(self.options, 'unavailableContracts', {})
|
@@ -2239,7 +2399,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
2239
2399
|
type = 1
|
2240
2400
|
elif type == 'market':
|
2241
2401
|
type = 6
|
2242
|
-
request = {
|
2402
|
+
request: dict = {
|
2243
2403
|
'symbol': market['id'],
|
2244
2404
|
# 'price': float(self.price_to_precision(symbol, price)),
|
2245
2405
|
'vol': float(self.amount_to_precision(symbol, amount)),
|
@@ -2272,18 +2432,28 @@ class mexc(Exchange, ImplicitAPI):
|
|
2272
2432
|
if leverage is None:
|
2273
2433
|
raise ArgumentsRequired(self.id + ' createSwapOrder() requires a leverage parameter for isolated margin orders')
|
2274
2434
|
reduceOnly = self.safe_bool(params, 'reduceOnly', False)
|
2275
|
-
|
2276
|
-
|
2435
|
+
hedged = self.safe_bool(params, 'hedged', False)
|
2436
|
+
sideInteger = None
|
2437
|
+
if hedged:
|
2438
|
+
if reduceOnly:
|
2439
|
+
params = self.omit(params, 'reduceOnly') # hedged mode does not accept self parameter
|
2440
|
+
side = 'sell' if (side == 'buy') else 'buy'
|
2441
|
+
sideInteger = 1 if (side == 'buy') else 3
|
2442
|
+
request['positionMode'] = 1
|
2277
2443
|
else:
|
2278
|
-
|
2444
|
+
if reduceOnly:
|
2445
|
+
sideInteger = 2 if (side == 'buy') else 4
|
2446
|
+
else:
|
2447
|
+
sideInteger = 1 if (side == 'buy') else 3
|
2448
|
+
request['side'] = sideInteger
|
2279
2449
|
clientOrderId = self.safe_string_2(params, 'clientOrderId', 'externalOid')
|
2280
2450
|
if clientOrderId is not None:
|
2281
2451
|
request['externalOid'] = clientOrderId
|
2282
|
-
|
2283
|
-
params = self.omit(params, ['clientOrderId', 'externalOid', 'postOnly', 'stopPrice', 'triggerPrice'])
|
2452
|
+
triggerPrice = self.safe_number_2(params, 'triggerPrice', 'stopPrice')
|
2453
|
+
params = self.omit(params, ['clientOrderId', 'externalOid', 'postOnly', 'stopPrice', 'triggerPrice', 'hedged'])
|
2284
2454
|
response = None
|
2285
|
-
if
|
2286
|
-
request['triggerPrice'] = self.price_to_precision(symbol,
|
2455
|
+
if triggerPrice:
|
2456
|
+
request['triggerPrice'] = self.price_to_precision(symbol, triggerPrice)
|
2287
2457
|
request['triggerType'] = self.safe_integer(params, 'triggerType', 1)
|
2288
2458
|
request['executeCycle'] = self.safe_integer(params, 'executeCycle', 1)
|
2289
2459
|
request['trend'] = self.safe_integer(params, 'trend', 1)
|
@@ -2299,12 +2469,14 @@ class mexc(Exchange, ImplicitAPI):
|
|
2299
2469
|
# {"success":true,"code":0,"data":259208506303929856}
|
2300
2470
|
#
|
2301
2471
|
data = self.safe_string(response, 'data')
|
2302
|
-
return self.
|
2472
|
+
return self.safe_order({'id': data}, market)
|
2303
2473
|
|
2304
2474
|
async def create_orders(self, orders: List[OrderRequest], params={}):
|
2305
2475
|
"""
|
2306
2476
|
*spot only* *all orders must have the same symbol* create a list of trade orders
|
2307
|
-
|
2477
|
+
|
2478
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#batch-orders
|
2479
|
+
|
2308
2480
|
: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
|
2309
2481
|
:param dict [params]: extra parameters specific to api endpoint
|
2310
2482
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
@@ -2332,7 +2504,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
2332
2504
|
marginMode, params = self.handle_margin_mode_and_params('createOrder', params)
|
2333
2505
|
orderRequest = self.create_spot_order_request(market, type, side, amount, price, marginMode, orderParams)
|
2334
2506
|
ordersRequests.append(orderRequest)
|
2335
|
-
request = {
|
2507
|
+
request: dict = {
|
2336
2508
|
'batchOrders': self.json(ordersRequests),
|
2337
2509
|
}
|
2338
2510
|
response = await self.spotPrivatePostBatchOrders(request)
|
@@ -2361,6 +2533,11 @@ class mexc(Exchange, ImplicitAPI):
|
|
2361
2533
|
async def fetch_order(self, id: str, symbol: Str = None, params={}):
|
2362
2534
|
"""
|
2363
2535
|
fetches information on an order made by the user
|
2536
|
+
|
2537
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-order
|
2538
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
|
2539
|
+
|
2540
|
+
:param str id: order id
|
2364
2541
|
:param str symbol: unified symbol of the market the order was made in
|
2365
2542
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2366
2543
|
:param str [params.marginMode]: only 'isolated' is supported, for spot-margin trading
|
@@ -2370,7 +2547,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
2370
2547
|
raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
|
2371
2548
|
await self.load_markets()
|
2372
2549
|
market = self.market(symbol)
|
2373
|
-
request = {
|
2550
|
+
request: dict = {
|
2374
2551
|
'symbol': market['id'],
|
2375
2552
|
}
|
2376
2553
|
data = None
|
@@ -2473,19 +2650,27 @@ class mexc(Exchange, ImplicitAPI):
|
|
2473
2650
|
async def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
2474
2651
|
"""
|
2475
2652
|
fetches information on multiple orders made by the user
|
2653
|
+
|
2654
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#all-orders
|
2655
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
|
2656
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
|
2657
|
+
|
2476
2658
|
:param str symbol: unified market symbol of the market orders were made in
|
2477
2659
|
:param int [since]: the earliest time in ms to fetch orders for
|
2478
2660
|
:param int [limit]: the maximum number of order structures to retrieve
|
2479
2661
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2662
|
+
:param int [params.until]: the latest time in ms to fetch orders for
|
2480
2663
|
:param str [params.marginMode]: only 'isolated' is supported, for spot-margin trading
|
2481
2664
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2482
2665
|
"""
|
2483
2666
|
await self.load_markets()
|
2484
|
-
request = {}
|
2667
|
+
request: dict = {}
|
2485
2668
|
market = None
|
2486
2669
|
if symbol is not None:
|
2487
2670
|
market = self.market(symbol)
|
2488
2671
|
request['symbol'] = market['id']
|
2672
|
+
until = self.safe_integer(params, 'until')
|
2673
|
+
params = self.omit(params, 'until')
|
2489
2674
|
marketType, query = self.handle_market_type_and_params('fetchOrders', market, params)
|
2490
2675
|
if marketType == 'spot':
|
2491
2676
|
if symbol is None:
|
@@ -2493,6 +2678,8 @@ class mexc(Exchange, ImplicitAPI):
|
|
2493
2678
|
marginMode, queryInner = self.handle_margin_mode_and_params('fetchOrders', params)
|
2494
2679
|
if since is not None:
|
2495
2680
|
request['startTime'] = since
|
2681
|
+
if until is not None:
|
2682
|
+
request['endTime'] = until
|
2496
2683
|
if limit is not None:
|
2497
2684
|
request['limit'] = limit
|
2498
2685
|
response = None
|
@@ -2554,9 +2741,17 @@ class mexc(Exchange, ImplicitAPI):
|
|
2554
2741
|
else:
|
2555
2742
|
if since is not None:
|
2556
2743
|
request['start_time'] = since
|
2557
|
-
end = self.safe_integer(params, 'end_time')
|
2744
|
+
end = self.safe_integer(params, 'end_time', until)
|
2558
2745
|
if end is None:
|
2559
2746
|
request['end_time'] = self.sum(since, self.options['maxTimeTillEnd'])
|
2747
|
+
else:
|
2748
|
+
if (end - since) > self.options['maxTimeTillEnd']:
|
2749
|
+
raise BadRequest(self.id + ' end is invalid, i.e. exceeds allowed 90 days.')
|
2750
|
+
else:
|
2751
|
+
request['end_time'] = until
|
2752
|
+
elif until is not None:
|
2753
|
+
request['start_time'] = self.sum(until, self.options['maxTimeTillEnd'] * -1)
|
2754
|
+
request['end_time'] = until
|
2560
2755
|
if limit is not None:
|
2561
2756
|
request['page_size'] = limit
|
2562
2757
|
method = self.safe_string(self.options, 'fetchOrders', 'contractPrivateGetOrderListHistoryOrders')
|
@@ -2635,7 +2830,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
2635
2830
|
|
2636
2831
|
async def fetch_orders_by_ids(self, ids, symbol: Str = None, params={}):
|
2637
2832
|
await self.load_markets()
|
2638
|
-
request = {}
|
2833
|
+
request: dict = {}
|
2639
2834
|
market = None
|
2640
2835
|
if symbol is not None:
|
2641
2836
|
market = self.market(symbol)
|
@@ -2680,12 +2875,17 @@ class mexc(Exchange, ImplicitAPI):
|
|
2680
2875
|
# ]
|
2681
2876
|
# }
|
2682
2877
|
#
|
2683
|
-
data = self.
|
2878
|
+
data = self.safe_list(response, 'data')
|
2684
2879
|
return self.parse_orders(data, market)
|
2685
2880
|
|
2686
2881
|
async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
2687
2882
|
"""
|
2688
2883
|
fetch all unfilled currently open orders
|
2884
|
+
|
2885
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#current-open-orders
|
2886
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
|
2887
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
|
2888
|
+
|
2689
2889
|
:param str symbol: unified market symbol
|
2690
2890
|
:param int [since]: the earliest time in ms to fetch open orders for
|
2691
2891
|
:param int [limit]: the maximum number of open orders structures to retrieve
|
@@ -2694,7 +2894,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
2694
2894
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2695
2895
|
"""
|
2696
2896
|
await self.load_markets()
|
2697
|
-
request = {}
|
2897
|
+
request: dict = {}
|
2698
2898
|
market = None
|
2699
2899
|
marketType = None
|
2700
2900
|
if symbol is not None:
|
@@ -2768,6 +2968,11 @@ class mexc(Exchange, ImplicitAPI):
|
|
2768
2968
|
async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
2769
2969
|
"""
|
2770
2970
|
fetches information on multiple closed orders made by the user
|
2971
|
+
|
2972
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#all-orders
|
2973
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
|
2974
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
|
2975
|
+
|
2771
2976
|
:param str symbol: unified market symbol of the market orders were made in
|
2772
2977
|
:param int [since]: the earliest time in ms to fetch orders for
|
2773
2978
|
:param int [limit]: the maximum number of order structures to retrieve
|
@@ -2779,6 +2984,11 @@ class mexc(Exchange, ImplicitAPI):
|
|
2779
2984
|
async def fetch_canceled_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2780
2985
|
"""
|
2781
2986
|
fetches information on multiple canceled orders made by the user
|
2987
|
+
|
2988
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#all-orders
|
2989
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
|
2990
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
|
2991
|
+
|
2782
2992
|
:param str symbol: unified market symbol of the market orders were made in
|
2783
2993
|
:param int [since]: timestamp in ms of the earliest order, default is None
|
2784
2994
|
:param int [limit]: max number of orders to return, default is None
|
@@ -2789,7 +2999,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
2789
2999
|
|
2790
3000
|
async def fetch_orders_by_state(self, state, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2791
3001
|
await self.load_markets()
|
2792
|
-
request = {}
|
3002
|
+
request: dict = {}
|
2793
3003
|
market = None
|
2794
3004
|
if symbol is not None:
|
2795
3005
|
market = self.market(symbol)
|
@@ -2803,6 +3013,11 @@ class mexc(Exchange, ImplicitAPI):
|
|
2803
3013
|
async def cancel_order(self, id: str, symbol: Str = None, params={}):
|
2804
3014
|
"""
|
2805
3015
|
cancels an open order
|
3016
|
+
|
3017
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-order
|
3018
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-order-under-maintenance
|
3019
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-stop-limit-trigger-order-under-maintenance
|
3020
|
+
|
2806
3021
|
:param str id: order id
|
2807
3022
|
:param str symbol: unified symbol of the market the order was made in
|
2808
3023
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -2810,7 +3025,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
2810
3025
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2811
3026
|
"""
|
2812
3027
|
await self.load_markets()
|
2813
|
-
request = {}
|
3028
|
+
request: dict = {}
|
2814
3029
|
market = None
|
2815
3030
|
if symbol is not None:
|
2816
3031
|
market = self.market(symbol)
|
@@ -2822,7 +3037,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
2822
3037
|
if marketType == 'spot':
|
2823
3038
|
if symbol is None:
|
2824
3039
|
raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
|
2825
|
-
requestInner = {
|
3040
|
+
requestInner: dict = {
|
2826
3041
|
'symbol': market['id'],
|
2827
3042
|
}
|
2828
3043
|
clientOrderId = self.safe_string(params, 'clientOrderId')
|
@@ -2905,6 +3120,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
2905
3120
|
async def cancel_orders(self, ids, symbol: Str = None, params={}):
|
2906
3121
|
"""
|
2907
3122
|
cancel multiple orders
|
3123
|
+
|
3124
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-order-under-maintenance
|
3125
|
+
|
2908
3126
|
:param str[] ids: order ids
|
2909
3127
|
:param str symbol: unified market symbol, default is None
|
2910
3128
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -2930,12 +3148,17 @@ class mexc(Exchange, ImplicitAPI):
|
|
2930
3148
|
# ]
|
2931
3149
|
# }
|
2932
3150
|
#
|
2933
|
-
data = self.
|
3151
|
+
data = self.safe_list(response, 'data')
|
2934
3152
|
return self.parse_orders(data, market)
|
2935
3153
|
|
2936
3154
|
async def cancel_all_orders(self, symbol: Str = None, params={}):
|
2937
3155
|
"""
|
2938
3156
|
cancel all open orders
|
3157
|
+
|
3158
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-all-open-orders-on-a-symbol
|
3159
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-orders-under-a-contract-under-maintenance
|
3160
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-trigger-orders-under-maintenance
|
3161
|
+
|
2939
3162
|
:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
|
2940
3163
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2941
3164
|
:param str [params.marginMode]: only 'isolated' is supported for spot-margin trading
|
@@ -2943,7 +3166,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
2943
3166
|
"""
|
2944
3167
|
await self.load_markets()
|
2945
3168
|
market = self.market(symbol) if (symbol is not None) else None
|
2946
|
-
request = {}
|
3169
|
+
request: dict = {}
|
2947
3170
|
marketType = None
|
2948
3171
|
marketType, params = self.handle_market_type_and_params('cancelAllOrders', market, params)
|
2949
3172
|
marginMode, query = self.handle_margin_mode_and_params('cancelAllOrders', params)
|
@@ -3013,10 +3236,10 @@ class mexc(Exchange, ImplicitAPI):
|
|
3013
3236
|
# "code": "0"
|
3014
3237
|
# }
|
3015
3238
|
#
|
3016
|
-
data = self.
|
3239
|
+
data = self.safe_list(response, 'data', [])
|
3017
3240
|
return self.parse_orders(data, market)
|
3018
3241
|
|
3019
|
-
def parse_order(self, order, market: Market = None) -> Order:
|
3242
|
+
def parse_order(self, order: dict, market: Market = None) -> Order:
|
3020
3243
|
#
|
3021
3244
|
# spot: createOrder
|
3022
3245
|
#
|
@@ -3211,7 +3434,6 @@ class mexc(Exchange, ImplicitAPI):
|
|
3211
3434
|
'timeInForce': self.parse_order_time_in_force(self.safe_string(order, 'timeInForce')),
|
3212
3435
|
'side': self.parse_order_side(self.safe_string(order, 'side')),
|
3213
3436
|
'price': self.safe_number(order, 'price'),
|
3214
|
-
'stopPrice': self.safe_number_2(order, 'stopPrice', 'triggerPrice'),
|
3215
3437
|
'triggerPrice': self.safe_number_2(order, 'stopPrice', 'triggerPrice'),
|
3216
3438
|
'average': self.safe_number(order, 'dealAvgPrice'),
|
3217
3439
|
'amount': self.safe_number_2(order, 'origQty', 'vol'),
|
@@ -3224,7 +3446,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3224
3446
|
}, market)
|
3225
3447
|
|
3226
3448
|
def parse_order_side(self, status):
|
3227
|
-
statuses = {
|
3449
|
+
statuses: dict = {
|
3228
3450
|
'BUY': 'buy',
|
3229
3451
|
'SELL': 'sell',
|
3230
3452
|
'1': 'buy',
|
@@ -3234,15 +3456,15 @@ class mexc(Exchange, ImplicitAPI):
|
|
3234
3456
|
return self.safe_string(statuses, status, status)
|
3235
3457
|
|
3236
3458
|
def parse_order_type(self, status):
|
3237
|
-
statuses = {
|
3459
|
+
statuses: dict = {
|
3238
3460
|
'MARKET': 'market',
|
3239
3461
|
'LIMIT': 'limit',
|
3240
3462
|
'LIMIT_MAKER': 'limit',
|
3241
3463
|
}
|
3242
3464
|
return self.safe_string(statuses, status, status)
|
3243
3465
|
|
3244
|
-
def parse_order_status(self, status):
|
3245
|
-
statuses = {
|
3466
|
+
def parse_order_status(self, status: Str):
|
3467
|
+
statuses: dict = {
|
3246
3468
|
'NEW': 'open',
|
3247
3469
|
'FILLED': 'closed',
|
3248
3470
|
'CANCELED': 'canceled',
|
@@ -3258,7 +3480,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3258
3480
|
return self.safe_string(statuses, status, status)
|
3259
3481
|
|
3260
3482
|
def parse_order_time_in_force(self, status):
|
3261
|
-
statuses = {
|
3483
|
+
statuses: dict = {
|
3262
3484
|
'GTC': 'GTC',
|
3263
3485
|
'FOK': 'FOK',
|
3264
3486
|
'IOC': 'IOC',
|
@@ -3322,6 +3544,10 @@ class mexc(Exchange, ImplicitAPI):
|
|
3322
3544
|
async def fetch_accounts(self, params={}) -> List[Account]:
|
3323
3545
|
"""
|
3324
3546
|
fetch all the accounts associated with a profile
|
3547
|
+
|
3548
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
|
3549
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
|
3550
|
+
|
3325
3551
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3326
3552
|
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
|
3327
3553
|
"""
|
@@ -3343,30 +3569,44 @@ class mexc(Exchange, ImplicitAPI):
|
|
3343
3569
|
})
|
3344
3570
|
return result
|
3345
3571
|
|
3346
|
-
async def
|
3572
|
+
async def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
|
3347
3573
|
"""
|
3348
|
-
fetch the trading fees for
|
3574
|
+
fetch the trading fees for a market
|
3575
|
+
|
3576
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-mx-deduct-status
|
3577
|
+
|
3578
|
+
:param str symbol: unified market symbol
|
3349
3579
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3350
|
-
:returns dict: a
|
3580
|
+
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
|
3351
3581
|
"""
|
3352
3582
|
await self.load_markets()
|
3353
|
-
|
3354
|
-
|
3355
|
-
|
3356
|
-
|
3357
|
-
|
3358
|
-
|
3359
|
-
|
3360
|
-
|
3361
|
-
|
3362
|
-
|
3363
|
-
|
3364
|
-
|
3365
|
-
|
3366
|
-
|
3367
|
-
|
3368
|
-
|
3369
|
-
|
3583
|
+
market = self.market(symbol)
|
3584
|
+
if not market['spot']:
|
3585
|
+
raise BadRequest(self.id + ' fetchTradingFee() supports spot markets only')
|
3586
|
+
request: dict = {
|
3587
|
+
'symbol': market['id'],
|
3588
|
+
}
|
3589
|
+
response = await self.spotPrivateGetTradeFee(self.extend(request, params))
|
3590
|
+
#
|
3591
|
+
# {
|
3592
|
+
# "data":{
|
3593
|
+
# "makerCommission":0.003000000000000000,
|
3594
|
+
# "takerCommission":0.003000000000000000
|
3595
|
+
# },
|
3596
|
+
# "code":0,
|
3597
|
+
# "msg":"success",
|
3598
|
+
# "timestamp":1669109672717
|
3599
|
+
# }
|
3600
|
+
#
|
3601
|
+
data = self.safe_dict(response, 'data', {})
|
3602
|
+
return {
|
3603
|
+
'info': data,
|
3604
|
+
'symbol': symbol,
|
3605
|
+
'maker': self.safe_number(data, 'makerCommission'),
|
3606
|
+
'taker': self.safe_number(data, 'takerCommission'),
|
3607
|
+
'percentage': None,
|
3608
|
+
'tierBased': None,
|
3609
|
+
}
|
3370
3610
|
|
3371
3611
|
def custom_parse_balance(self, response, marketType) -> Balances:
|
3372
3612
|
#
|
@@ -3446,7 +3686,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3446
3686
|
quote = self.safe_value(entry, 'quoteAsset', {})
|
3447
3687
|
baseCode = self.safe_currency_code(self.safe_string(base, 'asset'))
|
3448
3688
|
quoteCode = self.safe_currency_code(self.safe_string(quote, 'asset'))
|
3449
|
-
subResult = {}
|
3689
|
+
subResult: dict = {}
|
3450
3690
|
subResult[baseCode] = self.parse_balance_helper(base)
|
3451
3691
|
subResult[quoteCode] = self.parse_balance_helper(quote)
|
3452
3692
|
result[symbol] = self.safe_balance(subResult)
|
@@ -3485,16 +3725,18 @@ class mexc(Exchange, ImplicitAPI):
|
|
3485
3725
|
async def fetch_balance(self, params={}) -> Balances:
|
3486
3726
|
"""
|
3487
3727
|
query for balance and get the amount of funds available for trading or funds locked in orders
|
3488
|
-
|
3489
|
-
|
3490
|
-
|
3728
|
+
|
3729
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
|
3730
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
|
3731
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#isolated-account
|
3732
|
+
|
3491
3733
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3492
3734
|
:param str [params.symbols]: # required for margin, market id's separated by commas
|
3493
3735
|
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
3494
3736
|
"""
|
3495
3737
|
await self.load_markets()
|
3496
3738
|
marketType = None
|
3497
|
-
request = {}
|
3739
|
+
request: dict = {}
|
3498
3740
|
marketType, params = self.handle_market_type_and_params('fetchBalance', None, params)
|
3499
3741
|
marginMode = self.safe_string(params, 'marginMode')
|
3500
3742
|
isMargin = self.safe_bool(params, 'margin', False)
|
@@ -3610,27 +3852,37 @@ class mexc(Exchange, ImplicitAPI):
|
|
3610
3852
|
async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3611
3853
|
"""
|
3612
3854
|
fetch all trades made by the user
|
3855
|
+
|
3856
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
|
3857
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-transaction-details-of-the-user-s-order
|
3858
|
+
|
3613
3859
|
:param str symbol: unified market symbol
|
3614
3860
|
:param int [since]: the earliest time in ms to fetch trades for
|
3615
3861
|
:param int [limit]: the maximum number of trades structures to retrieve
|
3616
3862
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3863
|
+
:param int [params.until]: the latest time in ms to fetch trades for
|
3617
3864
|
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
3618
3865
|
"""
|
3619
3866
|
if symbol is None:
|
3620
3867
|
raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol argument')
|
3621
3868
|
await self.load_markets()
|
3622
3869
|
market = self.market(symbol)
|
3623
|
-
marketType
|
3624
|
-
|
3870
|
+
marketType: Str = None
|
3871
|
+
marketType, params = self.handle_market_type_and_params('fetchMyTrades', market, params)
|
3872
|
+
request: dict = {
|
3625
3873
|
'symbol': market['id'],
|
3626
3874
|
}
|
3627
3875
|
trades = None
|
3628
3876
|
if marketType == 'spot':
|
3629
3877
|
if since is not None:
|
3630
|
-
request['
|
3878
|
+
request['startTime'] = since
|
3631
3879
|
if limit is not None:
|
3632
3880
|
request['limit'] = limit
|
3633
|
-
|
3881
|
+
until = self.safe_integer(params, 'until')
|
3882
|
+
if until is not None:
|
3883
|
+
params = self.omit(params, 'until')
|
3884
|
+
request['endTime'] = until
|
3885
|
+
trades = await self.spotPrivateGetMyTrades(self.extend(request, params))
|
3634
3886
|
#
|
3635
3887
|
# spot
|
3636
3888
|
#
|
@@ -3660,7 +3912,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3660
3912
|
request['end_time'] = self.sum(since, self.options['maxTimeTillEnd'])
|
3661
3913
|
if limit is not None:
|
3662
3914
|
request['page_size'] = limit
|
3663
|
-
response = await self.contractPrivateGetOrderListOrderDeals(self.extend(request,
|
3915
|
+
response = await self.contractPrivateGetOrderListOrderDeals(self.extend(request, params))
|
3664
3916
|
#
|
3665
3917
|
# {
|
3666
3918
|
# "success": True,
|
@@ -3690,6 +3942,10 @@ class mexc(Exchange, ImplicitAPI):
|
|
3690
3942
|
async def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3691
3943
|
"""
|
3692
3944
|
fetch all the trades made from a single order
|
3945
|
+
|
3946
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
|
3947
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
|
3948
|
+
|
3693
3949
|
:param str id: order id
|
3694
3950
|
:param str symbol: unified market symbol
|
3695
3951
|
:param int [since]: the earliest time in ms to fetch trades for
|
@@ -3698,7 +3954,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3698
3954
|
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
3699
3955
|
"""
|
3700
3956
|
await self.load_markets()
|
3701
|
-
request = {}
|
3957
|
+
request: dict = {}
|
3702
3958
|
market = None
|
3703
3959
|
if symbol is not None:
|
3704
3960
|
market = self.market(symbol)
|
@@ -3765,7 +4021,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3765
4021
|
if positionId is None:
|
3766
4022
|
raise ArgumentsRequired(self.id + ' modifyMarginHelper() requires a positionId parameter')
|
3767
4023
|
await self.load_markets()
|
3768
|
-
request = {
|
4024
|
+
request: dict = {
|
3769
4025
|
'positionId': positionId,
|
3770
4026
|
'amount': amount,
|
3771
4027
|
'type': addOrReduce,
|
@@ -3778,9 +4034,12 @@ class mexc(Exchange, ImplicitAPI):
|
|
3778
4034
|
# }
|
3779
4035
|
return response
|
3780
4036
|
|
3781
|
-
async def reduce_margin(self, symbol: str, amount, params={}):
|
4037
|
+
async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
3782
4038
|
"""
|
3783
4039
|
remove margin from a position
|
4040
|
+
|
4041
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin
|
4042
|
+
|
3784
4043
|
:param str symbol: unified market symbol
|
3785
4044
|
:param float amount: the amount of margin to remove
|
3786
4045
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -3788,9 +4047,12 @@ class mexc(Exchange, ImplicitAPI):
|
|
3788
4047
|
"""
|
3789
4048
|
return await self.modify_margin_helper(symbol, amount, 'SUB', params)
|
3790
4049
|
|
3791
|
-
async def add_margin(self, symbol: str, amount, params={}):
|
4050
|
+
async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
3792
4051
|
"""
|
3793
4052
|
add margin
|
4053
|
+
|
4054
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin
|
4055
|
+
|
3794
4056
|
:param str symbol: unified market symbol
|
3795
4057
|
:param float amount: amount of margin to add
|
3796
4058
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -3801,13 +4063,16 @@ class mexc(Exchange, ImplicitAPI):
|
|
3801
4063
|
async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
|
3802
4064
|
"""
|
3803
4065
|
set the level of leverage for a market
|
4066
|
+
|
4067
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#switch-leverage
|
4068
|
+
|
3804
4069
|
:param float leverage: the rate of leverage
|
3805
4070
|
:param str symbol: unified market symbol
|
3806
4071
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3807
4072
|
:returns dict: response from the exchange
|
3808
4073
|
"""
|
3809
4074
|
await self.load_markets()
|
3810
|
-
request = {
|
4075
|
+
request: dict = {
|
3811
4076
|
'leverage': leverage,
|
3812
4077
|
}
|
3813
4078
|
positionId = self.safe_integer(params, 'positionId')
|
@@ -3828,6 +4093,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
3828
4093
|
async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3829
4094
|
"""
|
3830
4095
|
fetch the history of funding payments paid and received on self account
|
4096
|
+
|
4097
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-details-of-user-s-funding-rate
|
4098
|
+
|
3831
4099
|
:param str symbol: unified market symbol
|
3832
4100
|
:param int [since]: the earliest time in ms to fetch funding history for
|
3833
4101
|
:param int [limit]: the maximum number of funding history structures to retrieve
|
@@ -3836,7 +4104,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3836
4104
|
"""
|
3837
4105
|
await self.load_markets()
|
3838
4106
|
market = None
|
3839
|
-
request = {
|
4107
|
+
request: dict = {
|
3840
4108
|
# 'symbol': market['id'],
|
3841
4109
|
# 'position_id': positionId,
|
3842
4110
|
# 'page_num': 1,
|
@@ -3897,7 +4165,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3897
4165
|
})
|
3898
4166
|
return result
|
3899
4167
|
|
3900
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
4168
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
3901
4169
|
#
|
3902
4170
|
# {
|
3903
4171
|
# "symbol": "BTC_USDT",
|
@@ -3912,9 +4180,12 @@ class mexc(Exchange, ImplicitAPI):
|
|
3912
4180
|
nextFundingRate = self.safe_number(contract, 'fundingRate')
|
3913
4181
|
nextFundingTimestamp = self.safe_integer(contract, 'nextSettleTime')
|
3914
4182
|
marketId = self.safe_string(contract, 'symbol')
|
3915
|
-
symbol = self.safe_symbol(marketId, market)
|
4183
|
+
symbol = self.safe_symbol(marketId, market, None, 'contract')
|
3916
4184
|
timestamp = self.safe_integer(contract, 'timestamp')
|
3917
|
-
|
4185
|
+
interval = self.safe_string(contract, 'collectCycle')
|
4186
|
+
intervalString = None
|
4187
|
+
if interval is not None:
|
4188
|
+
intervalString = interval + 'h'
|
3918
4189
|
return {
|
3919
4190
|
'info': contract,
|
3920
4191
|
'symbol': symbol,
|
@@ -3923,7 +4194,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3923
4194
|
'interestRate': None,
|
3924
4195
|
'estimatedSettlePrice': None,
|
3925
4196
|
'timestamp': timestamp,
|
3926
|
-
'datetime':
|
4197
|
+
'datetime': self.iso8601(timestamp),
|
3927
4198
|
'fundingRate': nextFundingRate,
|
3928
4199
|
'fundingTimestamp': nextFundingTimestamp,
|
3929
4200
|
'fundingDatetime': self.iso8601(nextFundingTimestamp),
|
@@ -3933,18 +4204,34 @@ class mexc(Exchange, ImplicitAPI):
|
|
3933
4204
|
'previousFundingRate': None,
|
3934
4205
|
'previousFundingTimestamp': None,
|
3935
4206
|
'previousFundingDatetime': None,
|
4207
|
+
'interval': intervalString,
|
3936
4208
|
}
|
3937
4209
|
|
3938
|
-
async def
|
4210
|
+
async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
4211
|
+
"""
|
4212
|
+
fetch the current funding rate interval
|
4213
|
+
|
4214
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
|
4215
|
+
|
4216
|
+
:param str symbol: unified market symbol
|
4217
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4218
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
4219
|
+
"""
|
4220
|
+
return await self.fetch_funding_rate(symbol, params)
|
4221
|
+
|
4222
|
+
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
3939
4223
|
"""
|
3940
4224
|
fetch the current funding rate
|
4225
|
+
|
4226
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
|
4227
|
+
|
3941
4228
|
:param str symbol: unified market symbol
|
3942
4229
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3943
4230
|
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
3944
4231
|
"""
|
3945
4232
|
await self.load_markets()
|
3946
4233
|
market = self.market(symbol)
|
3947
|
-
request = {
|
4234
|
+
request: dict = {
|
3948
4235
|
'symbol': market['id'],
|
3949
4236
|
}
|
3950
4237
|
response = await self.contractPublicGetFundingRateSymbol(self.extend(request, params))
|
@@ -3969,6 +4256,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
3969
4256
|
async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3970
4257
|
"""
|
3971
4258
|
fetches historical funding rate prices
|
4259
|
+
|
4260
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate-history
|
4261
|
+
|
3972
4262
|
:param str symbol: unified symbol of the market to fetch the funding rate history for
|
3973
4263
|
:param int [since]: not used by mexc, but filtered internally by ccxt
|
3974
4264
|
:param int [limit]: mexc limit is page_size default 20, maximum is 100
|
@@ -3979,7 +4269,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3979
4269
|
raise ArgumentsRequired(self.id + ' fetchFundingRateHistory() requires a symbol argument')
|
3980
4270
|
await self.load_markets()
|
3981
4271
|
market = self.market(symbol)
|
3982
|
-
request = {
|
4272
|
+
request: dict = {
|
3983
4273
|
'symbol': market['id'],
|
3984
4274
|
# 'page_size': limit, # optional
|
3985
4275
|
# 'page_num': 1, # optional, current page number, default is 1
|
@@ -4029,10 +4319,13 @@ class mexc(Exchange, ImplicitAPI):
|
|
4029
4319
|
sorted = self.sort_by(rates, 'timestamp')
|
4030
4320
|
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
4031
4321
|
|
4032
|
-
async def fetch_leverage_tiers(self, symbols: Strings = None, params={}):
|
4322
|
+
async def fetch_leverage_tiers(self, symbols: Strings = None, params={}) -> LeverageTiers:
|
4033
4323
|
"""
|
4034
|
-
retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
|
4035
|
-
|
4324
|
+
retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes, if a market has a leverage tier of 0, then the leverage tiers cannot be obtained for self market
|
4325
|
+
|
4326
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
|
4327
|
+
|
4328
|
+
:param str[] [symbols]: list of unified market symbols
|
4036
4329
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4037
4330
|
:returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
|
4038
4331
|
"""
|
@@ -4084,14 +4377,49 @@ class mexc(Exchange, ImplicitAPI):
|
|
4084
4377
|
# ]
|
4085
4378
|
# }
|
4086
4379
|
#
|
4087
|
-
data = self.
|
4380
|
+
data = self.safe_list(response, 'data')
|
4088
4381
|
return self.parse_leverage_tiers(data, symbols, 'symbol')
|
4089
4382
|
|
4090
|
-
def parse_market_leverage_tiers(self, info, market: Market = None):
|
4091
|
-
|
4092
|
-
|
4093
|
-
|
4094
|
-
"""
|
4383
|
+
def parse_market_leverage_tiers(self, info, market: Market = None) -> List[LeverageTier]:
|
4384
|
+
#
|
4385
|
+
# {
|
4386
|
+
# "symbol": "BTC_USDT",
|
4387
|
+
# "displayName": "BTC_USDT永续",
|
4388
|
+
# "displayNameEn": "BTC_USDT SWAP",
|
4389
|
+
# "positionOpenType": 3,
|
4390
|
+
# "baseCoin": "BTC",
|
4391
|
+
# "quoteCoin": "USDT",
|
4392
|
+
# "settleCoin": "USDT",
|
4393
|
+
# "contractSize": 0.0001,
|
4394
|
+
# "minLeverage": 1,
|
4395
|
+
# "maxLeverage": 125,
|
4396
|
+
# "priceScale": 2,
|
4397
|
+
# "volScale": 0,
|
4398
|
+
# "amountScale": 4,
|
4399
|
+
# "priceUnit": 0.5,
|
4400
|
+
# "volUnit": 1,
|
4401
|
+
# "minVol": 1,
|
4402
|
+
# "maxVol": 1000000,
|
4403
|
+
# "bidLimitPriceRate": 0.1,
|
4404
|
+
# "askLimitPriceRate": 0.1,
|
4405
|
+
# "takerFeeRate": 0.0006,
|
4406
|
+
# "makerFeeRate": 0.0002,
|
4407
|
+
# "maintenanceMarginRate": 0.004,
|
4408
|
+
# "initialMarginRate": 0.008,
|
4409
|
+
# "riskBaseVol": 10000,
|
4410
|
+
# "riskIncrVol": 200000,
|
4411
|
+
# "riskIncrMmr": 0.004,
|
4412
|
+
# "riskIncrImr": 0.004,
|
4413
|
+
# "riskLevelLimit": 5,
|
4414
|
+
# "priceCoefficientVariation": 0.1,
|
4415
|
+
# "indexOrigin": ["BINANCE","GATEIO","HUOBI","MXC"],
|
4416
|
+
# "state": 0, # 0 enabled, 1 delivery, 2 completed, 3 offline, 4 pause
|
4417
|
+
# "isNew": False,
|
4418
|
+
# "isHot": True,
|
4419
|
+
# "isHidden": False
|
4420
|
+
# }
|
4421
|
+
#
|
4422
|
+
marketId = self.safe_string(info, 'symbol')
|
4095
4423
|
maintenanceMarginRate = self.safe_string(info, 'maintenanceMarginRate')
|
4096
4424
|
initialMarginRate = self.safe_string(info, 'initialMarginRate')
|
4097
4425
|
maxVol = self.safe_string(info, 'maxVol')
|
@@ -4101,13 +4429,27 @@ class mexc(Exchange, ImplicitAPI):
|
|
4101
4429
|
floor = '0'
|
4102
4430
|
tiers = []
|
4103
4431
|
quoteId = self.safe_string(info, 'quoteCoin')
|
4432
|
+
if riskIncrVol == '0':
|
4433
|
+
return [
|
4434
|
+
{
|
4435
|
+
'tier': 0,
|
4436
|
+
'symbol': self.safe_symbol(marketId, market, None, 'contract'),
|
4437
|
+
'currency': self.safe_currency_code(quoteId),
|
4438
|
+
'minNotional': None,
|
4439
|
+
'maxNotional': None,
|
4440
|
+
'maintenanceMarginRate': None,
|
4441
|
+
'maxLeverage': self.safe_number(info, 'maxLeverage'),
|
4442
|
+
'info': info,
|
4443
|
+
},
|
4444
|
+
]
|
4104
4445
|
while(Precise.string_lt(floor, maxVol)):
|
4105
4446
|
cap = Precise.string_add(floor, riskIncrVol)
|
4106
4447
|
tiers.append({
|
4107
4448
|
'tier': self.parse_number(Precise.string_div(cap, riskIncrVol)),
|
4449
|
+
'symbol': self.safe_symbol(marketId, market, None, 'contract'),
|
4108
4450
|
'currency': self.safe_currency_code(quoteId),
|
4109
|
-
'
|
4110
|
-
'
|
4451
|
+
'minNotional': self.parse_number(floor),
|
4452
|
+
'maxNotional': self.parse_number(cap),
|
4111
4453
|
'maintenanceMarginRate': self.parse_number(maintenanceMarginRate),
|
4112
4454
|
'maxLeverage': self.parse_number(Precise.string_div('1', initialMarginRate)),
|
4113
4455
|
'info': info,
|
@@ -4117,7 +4459,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
4117
4459
|
floor = cap
|
4118
4460
|
return tiers
|
4119
4461
|
|
4120
|
-
def parse_deposit_address(self, depositAddress, currency: Currency = None):
|
4462
|
+
def parse_deposit_address(self, depositAddress, currency: Currency = None) -> DepositAddress:
|
4121
4463
|
#
|
4122
4464
|
# {
|
4123
4465
|
# coin: "USDT",
|
@@ -4128,33 +4470,43 @@ class mexc(Exchange, ImplicitAPI):
|
|
4128
4470
|
#
|
4129
4471
|
address = self.safe_string(depositAddress, 'address')
|
4130
4472
|
currencyId = self.safe_string(depositAddress, 'coin')
|
4131
|
-
networkId = self.safe_string(depositAddress, '
|
4473
|
+
networkId = self.safe_string(depositAddress, 'netWork')
|
4132
4474
|
self.check_address(address)
|
4133
4475
|
return {
|
4476
|
+
'info': depositAddress,
|
4134
4477
|
'currency': self.safe_currency_code(currencyId, currency),
|
4478
|
+
'network': self.network_id_to_code(networkId, currencyId),
|
4135
4479
|
'address': address,
|
4136
4480
|
'tag': self.safe_string(depositAddress, 'memo'),
|
4137
|
-
'network': self.network_id_to_code(networkId),
|
4138
|
-
'info': depositAddress,
|
4139
4481
|
}
|
4140
4482
|
|
4141
|
-
async def fetch_deposit_addresses_by_network(self, code: str, params={}):
|
4483
|
+
async def fetch_deposit_addresses_by_network(self, code: str, params={}) -> List[DepositAddress]:
|
4142
4484
|
"""
|
4143
4485
|
fetch a dictionary of addresses for a currency, indexed by network
|
4144
|
-
|
4486
|
+
|
4487
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
|
4488
|
+
|
4145
4489
|
:param str code: unified currency code of the currency for the deposit address
|
4146
4490
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4147
4491
|
:returns dict: a dictionary of `address structures <https://docs.ccxt.com/#/?id=address-structure>` indexed by the network
|
4148
4492
|
"""
|
4149
4493
|
await self.load_markets()
|
4150
4494
|
currency = self.currency(code)
|
4151
|
-
request = {
|
4495
|
+
request: dict = {
|
4152
4496
|
'coin': currency['id'],
|
4153
4497
|
}
|
4154
4498
|
networkCode = self.safe_string(params, 'network')
|
4155
4499
|
networkId = None
|
4156
4500
|
if networkCode is not None:
|
4157
|
-
|
4501
|
+
# createDepositAddress and fetchDepositAddress use a different network-id compared to withdraw
|
4502
|
+
networkUnified = self.network_id_to_code(networkCode, code)
|
4503
|
+
networks = self.safe_dict(currency, 'networks', {})
|
4504
|
+
if networkUnified in networks:
|
4505
|
+
network = self.safe_dict(networks, networkUnified, {})
|
4506
|
+
networkInfo = self.safe_value(network, 'info', {})
|
4507
|
+
networkId = self.safe_string(networkInfo, 'network')
|
4508
|
+
else:
|
4509
|
+
networkId = self.network_code_to_id(networkCode, code)
|
4158
4510
|
if networkId is not None:
|
4159
4511
|
request['network'] = networkId
|
4160
4512
|
params = self.omit(params, 'network')
|
@@ -4176,7 +4528,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
4176
4528
|
async def create_deposit_address(self, code: str, params={}):
|
4177
4529
|
"""
|
4178
4530
|
create a currency deposit address
|
4179
|
-
|
4531
|
+
|
4532
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#generate-deposit-address-supporting-network
|
4533
|
+
|
4180
4534
|
:param str code: unified currency code of the currency for the deposit address
|
4181
4535
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4182
4536
|
:param str [params.network]: the blockchain network name
|
@@ -4184,13 +4538,22 @@ class mexc(Exchange, ImplicitAPI):
|
|
4184
4538
|
"""
|
4185
4539
|
await self.load_markets()
|
4186
4540
|
currency = self.currency(code)
|
4187
|
-
request = {
|
4541
|
+
request: dict = {
|
4188
4542
|
'coin': currency['id'],
|
4189
4543
|
}
|
4190
4544
|
networkCode = self.safe_string(params, 'network')
|
4191
4545
|
if networkCode is None:
|
4192
4546
|
raise ArgumentsRequired(self.id + ' createDepositAddress requires a `network` parameter')
|
4193
|
-
|
4547
|
+
# createDepositAddress and fetchDepositAddress use a different network-id compared to withdraw
|
4548
|
+
networkId = None
|
4549
|
+
networkUnified = self.network_id_to_code(networkCode, code)
|
4550
|
+
networks = self.safe_dict(currency, 'networks', {})
|
4551
|
+
if networkUnified in networks:
|
4552
|
+
network = self.safe_dict(networks, networkUnified, {})
|
4553
|
+
networkInfo = self.safe_value(network, 'info', {})
|
4554
|
+
networkId = self.safe_string(networkInfo, 'network')
|
4555
|
+
else:
|
4556
|
+
networkId = self.network_code_to_id(networkCode, code)
|
4194
4557
|
if networkId is not None:
|
4195
4558
|
request['network'] = networkId
|
4196
4559
|
params = self.omit(params, 'network')
|
@@ -4203,17 +4566,18 @@ class mexc(Exchange, ImplicitAPI):
|
|
4203
4566
|
# }
|
4204
4567
|
return self.parse_deposit_address(response, currency)
|
4205
4568
|
|
4206
|
-
async def fetch_deposit_address(self, code: str, params={}):
|
4569
|
+
async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
|
4207
4570
|
"""
|
4208
4571
|
fetch the deposit address for a currency associated with self account
|
4209
|
-
|
4572
|
+
|
4573
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
|
4574
|
+
|
4210
4575
|
:param str code: unified currency code
|
4211
4576
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4212
4577
|
:param str [params.network]: the chain of currency, self only apply for multi-chain currency, and there is no need for single chain currency
|
4213
4578
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
4214
4579
|
"""
|
4215
4580
|
network = self.safe_string(params, 'network')
|
4216
|
-
params = self.omit(params, ['network'])
|
4217
4581
|
addressStructures = await self.fetch_deposit_addresses_by_network(code, params)
|
4218
4582
|
result = None
|
4219
4583
|
if network is not None:
|
@@ -4228,13 +4592,15 @@ class mexc(Exchange, ImplicitAPI):
|
|
4228
4592
|
key = self.safe_string(keys, 0)
|
4229
4593
|
result = self.safe_dict(addressStructures, key)
|
4230
4594
|
if result is None:
|
4231
|
-
raise InvalidAddress(self.id + ' fetchDepositAddress() cannot find a deposit address for ' + code + ', and network' + network + 'consider creating one using
|
4595
|
+
raise InvalidAddress(self.id + ' fetchDepositAddress() cannot find a deposit address for ' + code + ', and network' + network + 'consider creating one using .createDepositAddress() method or in MEXC website')
|
4232
4596
|
return result
|
4233
4597
|
|
4234
4598
|
async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
4235
4599
|
"""
|
4236
4600
|
fetch all deposits made to an account
|
4237
|
-
|
4601
|
+
|
4602
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-history-supporting-network
|
4603
|
+
|
4238
4604
|
:param str code: unified currency code
|
4239
4605
|
:param int [since]: the earliest time in ms to fetch deposits for
|
4240
4606
|
:param int [limit]: the maximum number of deposits structures to retrieve
|
@@ -4242,11 +4608,11 @@ class mexc(Exchange, ImplicitAPI):
|
|
4242
4608
|
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
|
4243
4609
|
"""
|
4244
4610
|
await self.load_markets()
|
4245
|
-
request = {
|
4611
|
+
request: dict = {
|
4246
4612
|
# 'coin': currency['id'] + network example: USDT-TRX,
|
4247
4613
|
# 'status': 'status',
|
4248
4614
|
# 'startTime': since, # default 90 days
|
4249
|
-
# 'endTime': self.
|
4615
|
+
# 'endTime': self.nonce(),
|
4250
4616
|
# 'limit': limit, # default 1000, maximum 1000
|
4251
4617
|
}
|
4252
4618
|
currency = None
|
@@ -4287,7 +4653,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
4287
4653
|
async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
4288
4654
|
"""
|
4289
4655
|
fetch all withdrawals made from an account
|
4290
|
-
|
4656
|
+
|
4657
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-history-supporting-network
|
4658
|
+
|
4291
4659
|
:param str code: unified currency code
|
4292
4660
|
:param int [since]: the earliest time in ms to fetch withdrawals for
|
4293
4661
|
:param int [limit]: the maximum number of withdrawals structures to retrieve
|
@@ -4295,11 +4663,11 @@ class mexc(Exchange, ImplicitAPI):
|
|
4295
4663
|
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
|
4296
4664
|
"""
|
4297
4665
|
await self.load_markets()
|
4298
|
-
request = {
|
4666
|
+
request: dict = {
|
4299
4667
|
# 'coin': currency['id'],
|
4300
4668
|
# 'status': 'status',
|
4301
4669
|
# 'startTime': since, # default 90 days
|
4302
|
-
# 'endTime': self.
|
4670
|
+
# 'endTime': self.nonce(),
|
4303
4671
|
# 'limit': limit, # default 1000, maximum 1000
|
4304
4672
|
}
|
4305
4673
|
currency = None
|
@@ -4334,7 +4702,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
4334
4702
|
#
|
4335
4703
|
return self.parse_transactions(response, currency, since, limit)
|
4336
4704
|
|
4337
|
-
def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
|
4705
|
+
def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
|
4338
4706
|
#
|
4339
4707
|
# fetchDeposits
|
4340
4708
|
#
|
@@ -4425,7 +4793,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
4425
4793
|
}
|
4426
4794
|
|
4427
4795
|
def parse_transaction_status_by_type(self, status, type=None):
|
4428
|
-
statusesByType = {
|
4796
|
+
statusesByType: dict = {
|
4429
4797
|
'deposit': {
|
4430
4798
|
'1': 'failed', # SMALL
|
4431
4799
|
'2': 'pending', # TIME_DELAY
|
@@ -4454,13 +4822,16 @@ class mexc(Exchange, ImplicitAPI):
|
|
4454
4822
|
async def fetch_position(self, symbol: str, params={}):
|
4455
4823
|
"""
|
4456
4824
|
fetch data on a single open contract trade position
|
4825
|
+
|
4826
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
|
4827
|
+
|
4457
4828
|
:param str symbol: unified market symbol of the market the position is held in, default is None
|
4458
4829
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4459
4830
|
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
4460
4831
|
"""
|
4461
4832
|
await self.load_markets()
|
4462
4833
|
market = self.market(symbol)
|
4463
|
-
request = {
|
4834
|
+
request: dict = {
|
4464
4835
|
'symbol': market['id'],
|
4465
4836
|
}
|
4466
4837
|
response = await self.fetch_positions(None, self.extend(request, params))
|
@@ -4469,6 +4840,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
4469
4840
|
async def fetch_positions(self, symbols: Strings = None, params={}):
|
4470
4841
|
"""
|
4471
4842
|
fetch all open positions
|
4843
|
+
|
4844
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
|
4845
|
+
|
4472
4846
|
:param str[]|None symbols: list of unified market symbols
|
4473
4847
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4474
4848
|
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
@@ -4505,10 +4879,12 @@ class mexc(Exchange, ImplicitAPI):
|
|
4505
4879
|
# ]
|
4506
4880
|
# }
|
4507
4881
|
#
|
4508
|
-
data = self.
|
4882
|
+
data = self.safe_list(response, 'data', [])
|
4509
4883
|
return self.parse_positions(data, symbols)
|
4510
4884
|
|
4511
|
-
def parse_position(self, position, market: Market = None):
|
4885
|
+
def parse_position(self, position: dict, market: Market = None):
|
4886
|
+
#
|
4887
|
+
# fetchPositions
|
4512
4888
|
#
|
4513
4889
|
# {
|
4514
4890
|
# "positionId": 1394650,
|
@@ -4533,6 +4909,40 @@ class mexc(Exchange, ImplicitAPI):
|
|
4533
4909
|
# "autoAddIm": False
|
4534
4910
|
# }
|
4535
4911
|
#
|
4912
|
+
# fetchPositionsHistory
|
4913
|
+
#
|
4914
|
+
# {
|
4915
|
+
# positionId: '390281084',
|
4916
|
+
# symbol: 'RVN_USDT',
|
4917
|
+
# positionType: '1',
|
4918
|
+
# openType: '2',
|
4919
|
+
# state: '3',
|
4920
|
+
# holdVol: '0',
|
4921
|
+
# frozenVol: '0',
|
4922
|
+
# closeVol: '1141',
|
4923
|
+
# holdAvgPrice: '0.03491',
|
4924
|
+
# holdAvgPriceFullyScale: '0.03491',
|
4925
|
+
# openAvgPrice: '0.03491',
|
4926
|
+
# openAvgPriceFullyScale: '0.03491',
|
4927
|
+
# closeAvgPrice: '0.03494',
|
4928
|
+
# liquidatePrice: '0.03433',
|
4929
|
+
# oim: '0',
|
4930
|
+
# im: '0',
|
4931
|
+
# holdFee: '0',
|
4932
|
+
# realised: '0.1829',
|
4933
|
+
# leverage: '50',
|
4934
|
+
# createTime: '1711512408000',
|
4935
|
+
# updateTime: '1711512553000',
|
4936
|
+
# autoAddIm: False,
|
4937
|
+
# version: '4',
|
4938
|
+
# profitRatio: '0.0227',
|
4939
|
+
# newOpenAvgPrice: '0.03491',
|
4940
|
+
# newCloseAvgPrice: '0.03494',
|
4941
|
+
# closeProfitLoss: '0.3423',
|
4942
|
+
# fee: '0.1593977',
|
4943
|
+
# positionShowStatus: 'CLOSED'
|
4944
|
+
# }
|
4945
|
+
#
|
4536
4946
|
market = self.safe_market(self.safe_string(position, 'symbol'), market)
|
4537
4947
|
symbol = market['symbol']
|
4538
4948
|
contracts = self.safe_string(position, 'holdVol')
|
@@ -4554,7 +4964,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
4554
4964
|
'entryPrice': entryPrice,
|
4555
4965
|
'collateral': None,
|
4556
4966
|
'side': side,
|
4557
|
-
'
|
4967
|
+
'unrealizedPnl': None,
|
4558
4968
|
'leverage': self.parse_number(leverage),
|
4559
4969
|
'percentage': None,
|
4560
4970
|
'marginMode': marginType,
|
@@ -4575,11 +4985,21 @@ class mexc(Exchange, ImplicitAPI):
|
|
4575
4985
|
'lastUpdateTimestamp': None,
|
4576
4986
|
})
|
4577
4987
|
|
4578
|
-
async def fetch_transfer(self, id: str,
|
4988
|
+
async def fetch_transfer(self, id: str, code: Str = None, params={}) -> TransferEntry:
|
4989
|
+
"""
|
4990
|
+
fetches a transfer
|
4991
|
+
|
4992
|
+
https://mexcdevelop.github.io/apidocs/spot_v2_en/#internal-assets-transfer-order-inquiry
|
4993
|
+
|
4994
|
+
:param str id: transfer id
|
4995
|
+
:param str [code]: not used by mexc fetchTransfer
|
4996
|
+
:param dict params: extra parameters specific to the exchange api endpoint
|
4997
|
+
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
|
4998
|
+
"""
|
4579
4999
|
marketType, query = self.handle_market_type_and_params('fetchTransfer', None, params)
|
4580
5000
|
await self.load_markets()
|
4581
5001
|
if marketType == 'spot':
|
4582
|
-
request = {
|
5002
|
+
request: dict = {
|
4583
5003
|
'transact_id': id,
|
4584
5004
|
}
|
4585
5005
|
response = await self.spot2PrivateGetAssetInternalTransferInfo(self.extend(request, query))
|
@@ -4596,15 +5016,19 @@ class mexc(Exchange, ImplicitAPI):
|
|
4596
5016
|
# }
|
4597
5017
|
# }
|
4598
5018
|
#
|
4599
|
-
data = self.
|
5019
|
+
data = self.safe_dict(response, 'data', {})
|
4600
5020
|
return self.parse_transfer(data)
|
4601
5021
|
elif marketType == 'swap':
|
4602
5022
|
raise BadRequest(self.id + ' fetchTransfer() is not supported for ' + marketType)
|
4603
5023
|
return None
|
4604
5024
|
|
4605
|
-
async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
5025
|
+
async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
|
4606
5026
|
"""
|
4607
5027
|
fetch a history of internal transfers made on an account
|
5028
|
+
|
5029
|
+
https://mexcdevelop.github.io/apidocs/spot_v2_en/#get-internal-assets-transfer-records
|
5030
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-asset-transfer-records
|
5031
|
+
|
4608
5032
|
:param str code: unified currency code of the currency transferred
|
4609
5033
|
:param int [since]: the earliest time in ms to fetch transfers for
|
4610
5034
|
:param int [limit]: the maximum number of transfers structures to retrieve
|
@@ -4613,7 +5037,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
4613
5037
|
"""
|
4614
5038
|
marketType, query = self.handle_market_type_and_params('fetchTransfers', None, params)
|
4615
5039
|
await self.load_markets()
|
4616
|
-
request = {}
|
5040
|
+
request: dict = {}
|
4617
5041
|
currency = None
|
4618
5042
|
resultList = None
|
4619
5043
|
if code is not None:
|
@@ -4683,7 +5107,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
4683
5107
|
async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
|
4684
5108
|
"""
|
4685
5109
|
transfer currency internally between wallets on the same account
|
4686
|
-
|
5110
|
+
|
5111
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#user-universal-transfer
|
5112
|
+
|
4687
5113
|
:param str code: unified currency code
|
4688
5114
|
:param float amount: amount to transfer
|
4689
5115
|
:param str fromAccount: account to transfer from
|
@@ -4694,7 +5120,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
4694
5120
|
"""
|
4695
5121
|
await self.load_markets()
|
4696
5122
|
currency = self.currency(code)
|
4697
|
-
accounts = {
|
5123
|
+
accounts: dict = {
|
4698
5124
|
'spot': 'SPOT',
|
4699
5125
|
'swap': 'FUTURES',
|
4700
5126
|
'margin': 'ISOLATED_MARGIN',
|
@@ -4707,7 +5133,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
4707
5133
|
if toId is None:
|
4708
5134
|
keys = list(accounts.keys())
|
4709
5135
|
raise ExchangeError(self.id + ' toAccount must be one of ' + ', '.join(keys))
|
4710
|
-
request = {
|
5136
|
+
request: dict = {
|
4711
5137
|
'asset': currency['id'],
|
4712
5138
|
'amount': amount,
|
4713
5139
|
'fromAccountType': fromId,
|
@@ -4733,7 +5159,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
4733
5159
|
'toAccount': toAccount,
|
4734
5160
|
})
|
4735
5161
|
|
4736
|
-
def parse_transfer(self, transfer, currency: Currency = None):
|
5162
|
+
def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
|
4737
5163
|
#
|
4738
5164
|
# spot: fetchTransfer
|
4739
5165
|
#
|
@@ -4791,24 +5217,26 @@ class mexc(Exchange, ImplicitAPI):
|
|
4791
5217
|
}
|
4792
5218
|
|
4793
5219
|
def parse_account_id(self, status):
|
4794
|
-
statuses = {
|
5220
|
+
statuses: dict = {
|
4795
5221
|
'MAIN': 'spot',
|
4796
5222
|
'CONTRACT': 'swap',
|
4797
5223
|
}
|
4798
5224
|
return self.safe_string(statuses, status, status)
|
4799
5225
|
|
4800
|
-
def parse_transfer_status(self, status):
|
4801
|
-
statuses = {
|
5226
|
+
def parse_transfer_status(self, status: Str) -> Str:
|
5227
|
+
statuses: dict = {
|
4802
5228
|
'SUCCESS': 'ok',
|
4803
5229
|
'FAILED': 'failed',
|
4804
5230
|
'WAIT': 'pending',
|
4805
5231
|
}
|
4806
5232
|
return self.safe_string(statuses, status, status)
|
4807
5233
|
|
4808
|
-
async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
|
5234
|
+
async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
|
4809
5235
|
"""
|
4810
5236
|
make a withdrawal
|
4811
|
-
|
5237
|
+
|
5238
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-new
|
5239
|
+
|
4812
5240
|
:param str code: unified currency code
|
4813
5241
|
:param float amount: the amount to withdraw
|
4814
5242
|
:param str address: the address to withdraw to
|
@@ -4816,14 +5244,15 @@ class mexc(Exchange, ImplicitAPI):
|
|
4816
5244
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4817
5245
|
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
|
4818
5246
|
"""
|
5247
|
+
await self.load_markets()
|
5248
|
+
currency = self.currency(code)
|
4819
5249
|
tag, params = self.handle_withdraw_tag_and_params(tag, params)
|
4820
|
-
networks = self.
|
4821
|
-
network = self.safe_string_2(params, 'network', '
|
5250
|
+
networks = self.safe_dict(self.options, 'networks', {})
|
5251
|
+
network = self.safe_string_2(params, 'network', 'netWork') # self line allows the user to specify either ERC20 or ETH
|
4822
5252
|
network = self.safe_string(networks, network, network) # handle ETH > ERC-20 alias
|
5253
|
+
network = self.network_code_to_id(network, currency['code'])
|
4823
5254
|
self.check_address(address)
|
4824
|
-
|
4825
|
-
currency = self.currency(code)
|
4826
|
-
request = {
|
5255
|
+
request: dict = {
|
4827
5256
|
'coin': currency['id'],
|
4828
5257
|
'address': address,
|
4829
5258
|
'amount': amount,
|
@@ -4831,9 +5260,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
4831
5260
|
if tag is not None:
|
4832
5261
|
request['memo'] = tag
|
4833
5262
|
if network is not None:
|
4834
|
-
request['
|
4835
|
-
params = self.omit(params, ['network', '
|
4836
|
-
response = await self.
|
5263
|
+
request['netWork'] = network
|
5264
|
+
params = self.omit(params, ['network', 'netWork'])
|
5265
|
+
response = await self.spotPrivatePostCapitalWithdraw(self.extend(request, params))
|
4837
5266
|
#
|
4838
5267
|
# {
|
4839
5268
|
# "id":"7213fea8e94b4a5593d507237e5a555b"
|
@@ -4842,7 +5271,17 @@ class mexc(Exchange, ImplicitAPI):
|
|
4842
5271
|
return self.parse_transaction(response, currency)
|
4843
5272
|
|
4844
5273
|
async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
|
4845
|
-
|
5274
|
+
"""
|
5275
|
+
set hedged to True or False for a market
|
5276
|
+
|
5277
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#change-position-mode
|
5278
|
+
|
5279
|
+
:param bool hedged: set to True to use dualSidePosition
|
5280
|
+
:param str symbol: not used by mexc setPositionMode()
|
5281
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5282
|
+
:returns dict: response from the exchange
|
5283
|
+
"""
|
5284
|
+
request: dict = {
|
4846
5285
|
'positionMode': 1 if hedged else 2, # 1 Hedge, 2 One-way, before changing position mode make sure that there are no active orders, planned orders, or open positions, the risk limit level will be reset to 1
|
4847
5286
|
}
|
4848
5287
|
response = await self.contractPrivatePostPositionChangePositionMode(self.extend(request, params))
|
@@ -4855,6 +5294,15 @@ class mexc(Exchange, ImplicitAPI):
|
|
4855
5294
|
return response
|
4856
5295
|
|
4857
5296
|
async def fetch_position_mode(self, symbol: Str = None, params={}):
|
5297
|
+
"""
|
5298
|
+
fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
|
5299
|
+
|
5300
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-position-mode
|
5301
|
+
|
5302
|
+
:param str symbol: not used by mexc fetchPositionMode
|
5303
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5304
|
+
:returns dict: an object detailing whether the market is in hedged or one-way mode
|
5305
|
+
"""
|
4858
5306
|
response = await self.contractPrivateGetPositionPositionMode(params)
|
4859
5307
|
#
|
4860
5308
|
# {
|
@@ -4869,10 +5317,12 @@ class mexc(Exchange, ImplicitAPI):
|
|
4869
5317
|
'hedged': (positionMode == 1),
|
4870
5318
|
}
|
4871
5319
|
|
4872
|
-
async def fetch_transaction_fees(self, codes:
|
5320
|
+
async def fetch_transaction_fees(self, codes: Strings = None, params={}):
|
4873
5321
|
"""
|
4874
5322
|
fetch deposit and withdrawal fees
|
4875
|
-
|
5323
|
+
|
5324
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
|
5325
|
+
|
4876
5326
|
:param str[]|None codes: returns fees for all currencies if None
|
4877
5327
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4878
5328
|
:returns dict[]: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
|
@@ -4911,7 +5361,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
4911
5361
|
return self.parse_transaction_fees(response, codes)
|
4912
5362
|
|
4913
5363
|
def parse_transaction_fees(self, response, codes=None):
|
4914
|
-
withdrawFees = {}
|
5364
|
+
withdrawFees: dict = {}
|
4915
5365
|
for i in range(0, len(response)):
|
4916
5366
|
entry = response[i]
|
4917
5367
|
currencyId = self.safe_string(entry, 'coin')
|
@@ -4953,7 +5403,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
4953
5403
|
# }
|
4954
5404
|
#
|
4955
5405
|
networkList = self.safe_value(transaction, 'networkList', [])
|
4956
|
-
result = {}
|
5406
|
+
result: dict = {}
|
4957
5407
|
for j in range(0, len(networkList)):
|
4958
5408
|
networkEntry = networkList[j]
|
4959
5409
|
networkId = self.safe_string(networkEntry, 'network')
|
@@ -4965,7 +5415,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
4965
5415
|
async def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
|
4966
5416
|
"""
|
4967
5417
|
fetch deposit and withdrawal fees
|
4968
|
-
|
5418
|
+
|
5419
|
+
https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
|
5420
|
+
|
4969
5421
|
:param str[]|None codes: returns fees for all currencies if None
|
4970
5422
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4971
5423
|
:returns dict[]: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
|
@@ -5051,14 +5503,16 @@ class mexc(Exchange, ImplicitAPI):
|
|
5051
5503
|
async def fetch_leverage(self, symbol: str, params={}) -> Leverage:
|
5052
5504
|
"""
|
5053
5505
|
fetch the set leverage for a market
|
5054
|
-
|
5506
|
+
|
5507
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-leverage
|
5508
|
+
|
5055
5509
|
:param str symbol: unified market symbol
|
5056
5510
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5057
5511
|
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
|
5058
5512
|
"""
|
5059
5513
|
await self.load_markets()
|
5060
5514
|
market = self.market(symbol)
|
5061
|
-
request = {
|
5515
|
+
request: dict = {
|
5062
5516
|
'symbol': market['id'],
|
5063
5517
|
}
|
5064
5518
|
response = await self.contractPrivateGetPositionLeverage(self.extend(request, params))
|
@@ -5095,7 +5549,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
5095
5549
|
data = self.safe_list(response, 'data', [])
|
5096
5550
|
return self.parse_leverage(data, market)
|
5097
5551
|
|
5098
|
-
def parse_leverage(self, leverage, market=None) -> Leverage:
|
5552
|
+
def parse_leverage(self, leverage: dict, market: Market = None) -> Leverage:
|
5099
5553
|
marginMode = None
|
5100
5554
|
longLeverage = None
|
5101
5555
|
shortLeverage = None
|
@@ -5118,7 +5572,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
5118
5572
|
|
5119
5573
|
def handle_margin_mode_and_params(self, methodName, params={}, defaultValue=None):
|
5120
5574
|
"""
|
5121
|
-
|
5575
|
+
@ignore
|
5122
5576
|
marginMode specified by params["marginMode"], self.options["marginMode"], self.options["defaultMarginMode"], params["margin"] = True or self.options["defaultType"] = 'margin'
|
5123
5577
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5124
5578
|
:param bool [params.margin]: True for trading spot-margin
|
@@ -5132,6 +5586,118 @@ class mexc(Exchange, ImplicitAPI):
|
|
5132
5586
|
marginMode = 'isolated'
|
5133
5587
|
return [marginMode, params]
|
5134
5588
|
|
5589
|
+
async def fetch_positions_history(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}) -> List[Position]:
|
5590
|
+
"""
|
5591
|
+
fetches historical positions
|
5592
|
+
|
5593
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
|
5594
|
+
|
5595
|
+
:param str[] [symbols]: unified contract symbols
|
5596
|
+
:param int [since]: not used by mexc fetchPositionsHistory
|
5597
|
+
:param int [limit]: the maximum amount of candles to fetch, default=1000
|
5598
|
+
:param dict [params]: extra parameters specific to the exchange api endpoint
|
5599
|
+
|
5600
|
+
EXCHANGE SPECIFIC PARAMETERS
|
5601
|
+
:param int [params.type]: position type,1: long, 2: short
|
5602
|
+
:param int [params.page_num]: current page number, default is 1
|
5603
|
+
:returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
|
5604
|
+
"""
|
5605
|
+
await self.load_markets()
|
5606
|
+
request: dict = {}
|
5607
|
+
if symbols is not None:
|
5608
|
+
symbolsLength = len(symbols)
|
5609
|
+
if symbolsLength == 1:
|
5610
|
+
market = self.market(symbols[0])
|
5611
|
+
request['symbol'] = market['id']
|
5612
|
+
if limit is not None:
|
5613
|
+
request['page_size'] = limit
|
5614
|
+
response = await self.contractPrivateGetPositionListHistoryPositions(self.extend(request, params))
|
5615
|
+
#
|
5616
|
+
# {
|
5617
|
+
# success: True,
|
5618
|
+
# code: '0',
|
5619
|
+
# data: [
|
5620
|
+
# {
|
5621
|
+
# positionId: '390281084',
|
5622
|
+
# symbol: 'RVN_USDT',
|
5623
|
+
# positionType: '1',
|
5624
|
+
# openType: '2',
|
5625
|
+
# state: '3',
|
5626
|
+
# holdVol: '0',
|
5627
|
+
# frozenVol: '0',
|
5628
|
+
# closeVol: '1141',
|
5629
|
+
# holdAvgPrice: '0.03491',
|
5630
|
+
# holdAvgPriceFullyScale: '0.03491',
|
5631
|
+
# openAvgPrice: '0.03491',
|
5632
|
+
# openAvgPriceFullyScale: '0.03491',
|
5633
|
+
# closeAvgPrice: '0.03494',
|
5634
|
+
# liquidatePrice: '0.03433',
|
5635
|
+
# oim: '0',
|
5636
|
+
# im: '0',
|
5637
|
+
# holdFee: '0',
|
5638
|
+
# realised: '0.1829',
|
5639
|
+
# leverage: '50',
|
5640
|
+
# createTime: '1711512408000',
|
5641
|
+
# updateTime: '1711512553000',
|
5642
|
+
# autoAddIm: False,
|
5643
|
+
# version: '4',
|
5644
|
+
# profitRatio: '0.0227',
|
5645
|
+
# newOpenAvgPrice: '0.03491',
|
5646
|
+
# newCloseAvgPrice: '0.03494',
|
5647
|
+
# closeProfitLoss: '0.3423',
|
5648
|
+
# fee: '0.1593977',
|
5649
|
+
# positionShowStatus: 'CLOSED'
|
5650
|
+
# },
|
5651
|
+
# ...
|
5652
|
+
# ]
|
5653
|
+
# }
|
5654
|
+
#
|
5655
|
+
data = self.safe_list(response, 'data')
|
5656
|
+
positions = self.parse_positions(data, symbols, params)
|
5657
|
+
return self.filter_by_since_limit(positions, since, limit)
|
5658
|
+
|
5659
|
+
async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
|
5660
|
+
"""
|
5661
|
+
set margin mode to 'cross' or 'isolated'
|
5662
|
+
|
5663
|
+
https://mexcdevelop.github.io/apidocs/contract_v1_en/#switch-leverage
|
5664
|
+
|
5665
|
+
:param str marginMode: 'cross' or 'isolated'
|
5666
|
+
:param str [symbol]: required when there is no position, else provide params["positionId"]
|
5667
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5668
|
+
:param str [params.positionId]: required when a position is set
|
5669
|
+
:param str [params.direction]: "long" or "short" required when there is no position
|
5670
|
+
:returns dict: response from the exchange
|
5671
|
+
"""
|
5672
|
+
await self.load_markets()
|
5673
|
+
market = self.market(symbol)
|
5674
|
+
if market['spot']:
|
5675
|
+
raise BadSymbol(self.id + ' setMarginMode() supports contract markets only')
|
5676
|
+
marginMode = marginMode.lower()
|
5677
|
+
if marginMode != 'isolated' and marginMode != 'cross':
|
5678
|
+
raise BadRequest(self.id + ' setMarginMode() marginMode argument should be isolated or cross')
|
5679
|
+
leverage = self.safe_integer(params, 'leverage')
|
5680
|
+
if leverage is None:
|
5681
|
+
raise ArgumentsRequired(self.id + ' setMarginMode() requires a leverage parameter')
|
5682
|
+
direction = self.safe_string_lower_2(params, 'direction', 'positionId')
|
5683
|
+
request: dict = {
|
5684
|
+
'leverage': leverage,
|
5685
|
+
'openType': 1 if (marginMode == 'isolated') else 2,
|
5686
|
+
}
|
5687
|
+
if symbol is not None:
|
5688
|
+
request['symbol'] = market['id']
|
5689
|
+
if direction is not None:
|
5690
|
+
request['positionType'] = 2 if (direction == 'short') else 1
|
5691
|
+
params = self.omit(params, 'direction')
|
5692
|
+
response = await self.contractPrivatePostPositionChangeLeverage(self.extend(request, params))
|
5693
|
+
#
|
5694
|
+
# {success: True, code: '0'}
|
5695
|
+
#
|
5696
|
+
return self.parse_leverage(response, market)
|
5697
|
+
|
5698
|
+
def nonce(self):
|
5699
|
+
return self.milliseconds() - self.safe_integer(self.options, 'timeDifference', 0)
|
5700
|
+
|
5135
5701
|
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
5136
5702
|
section = self.safe_string(api, 0)
|
5137
5703
|
access = self.safe_string(api, 1)
|
@@ -5144,7 +5710,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
5144
5710
|
url = self.urls['api'][section][access] + '/api/' + self.version + '/' + path
|
5145
5711
|
paramsEncoded = ''
|
5146
5712
|
if access == 'private':
|
5147
|
-
params['timestamp'] = self.
|
5713
|
+
params['timestamp'] = self.nonce()
|
5148
5714
|
params['recvWindow'] = self.safe_integer(self.options, 'recvWindow', 5000)
|
5149
5715
|
if params:
|
5150
5716
|
paramsEncoded = self.urlencode(params)
|
@@ -5167,7 +5733,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
5167
5733
|
url += '?' + self.urlencode(params)
|
5168
5734
|
else:
|
5169
5735
|
self.check_required_credentials()
|
5170
|
-
timestamp = str(self.
|
5736
|
+
timestamp = str(self.nonce())
|
5171
5737
|
auth = ''
|
5172
5738
|
headers = {
|
5173
5739
|
'ApiKey': self.apiKey,
|
@@ -5188,7 +5754,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
5188
5754
|
headers['Signature'] = signature
|
5189
5755
|
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
5190
5756
|
|
5191
|
-
def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
|
5757
|
+
def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
|
5192
5758
|
if response is None:
|
5193
5759
|
return None
|
5194
5760
|
# spot
|