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