From 5f6c583a637789ae854741f15d004e4a3e1a4f1d Mon Sep 17 00:00:00 2001 From: "eddie.hsieh" Date: Fri, 12 Jan 2024 16:01:50 +0800 Subject: [PATCH 1/3] update python demo --- python/README.md | 32 +- python/run demo/ListenKey/CreateListenKey.py | 0 python/run demo/ListenKey/DeleteListenkey.py | 0 python/run demo/ListenKey/GetListenKey.py | 0 python/run demo/ListenKey/PutListenKey.py | 0 python/run demo/Market Data/AggTrades.py | 0 python/run demo/Market Data/ApiSymbol.py | 0 python/run demo/Market Data/AvgPrice.py | 0 python/run demo/Market Data/BookTicker.py | 0 python/run demo/Market Data/Depth.py | 0 python/run demo/Market Data/ETFInfo.py | 0 python/run demo/Market Data/ExchangeInfo.py | 0 python/run demo/Market Data/Kline.py | 0 python/run demo/Market Data/Ping.py | 0 python/run demo/Market Data/Price.py | 0 python/run demo/Market Data/ServerTime.py | 0 python/run demo/Market Data/Ticker24hr.py | 0 python/run demo/Market Data/Trades.py | 0 python/run demo/Rebate/AffiliateCommission.py | 0 .../Rebate/AffiliateCommissionDetail.py | 0 python/run demo/Rebate/AffiliateReferral.py | 0 python/run demo/Rebate/AffiliateWithdraw.py | 0 python/run demo/Rebate/RebateDetail.py | 0 python/run demo/Rebate/RebateHistory.py | 0 python/run demo/Rebate/ReferCode.py | 0 python/run demo/Rebate/SelfRecordsDetail.py | 0 python/run demo/Rebate/Subaffiliates.py | 0 python/run demo/Spot Trade/AccountInfo.py | 0 python/run demo/Spot Trade/AllOrders.py | 0 python/run demo/Spot Trade/BatchOrder.py | 0 python/run demo/Spot Trade/CancelAllOrders.py | 0 python/run demo/Spot Trade/CancelOrder.py | 0 python/run demo/Spot Trade/MxDeduct.py | 0 python/run demo/Spot Trade/MxDeductStatus.py | 0 python/run demo/Spot Trade/MyTrades.py | 0 python/run demo/Spot Trade/OpenOrder.py | 0 python/run demo/Spot Trade/PlaceOrder.py | 16 + python/run demo/Spot Trade/QueryOrder.py | 0 python/run demo/Spot Trade/SelfSymbols.py | 0 python/run demo/Spot Trade/TestOrder.py | 0 .../run demo/SubAccount/CreateSubAccount.py | 0 python/run demo/SubAccount/CreateSubApikey.py | 0 python/run demo/SubAccount/DeleteSubApikey.py | 0 .../run demo/SubAccount/SubAccountApikey.py | 0 python/run demo/SubAccount/SubAccountList.py | 0 python/run demo/SubAccount/UniTransfer.py | 17 + .../run demo/SubAccount/UniTransferHistory.py | 0 python/run demo/Wallet/CancelWithdraw.py | 0 python/run demo/Wallet/CoinList.py | 0 python/run demo/Wallet/Convert.py | 0 python/run demo/Wallet/ConvertHistory.py | 0 python/run demo/Wallet/ConvertList.py | 0 python/run demo/Wallet/DepositHistory.py | 0 .../run demo/Wallet/GenerateDepositAddress.py | 0 python/run demo/Wallet/GetDepositAddress.py | 0 python/run demo/Wallet/GetWithdrawAddress.py | 0 python/run demo/Wallet/InternalTransfer.py | 0 .../Wallet/InternalTransferHistory.py | 0 python/run demo/Wallet/Transfer.py | 0 python/run demo/Wallet/TransferHistory.py | 0 python/run demo/Wallet/TransferHistoryById.py | 0 python/run demo/Wallet/Withdraw.py | 0 python/run demo/Wallet/WithdrawHistory.py | 0 python/spot/__init__.py | 0 python/spot/config.py | 0 python/spot/{v3 => }/mexc_spot_v3.py | 0 python/spot/v2/mexc_spot_v2.py | 647 ------------------ python/spot/v3/demo_v3.py | 61 -- 68 files changed, 51 insertions(+), 722 deletions(-) create mode 100644 python/run demo/ListenKey/CreateListenKey.py create mode 100644 python/run demo/ListenKey/DeleteListenkey.py create mode 100644 python/run demo/ListenKey/GetListenKey.py create mode 100644 python/run demo/ListenKey/PutListenKey.py create mode 100644 python/run demo/Market Data/AggTrades.py create mode 100644 python/run demo/Market Data/ApiSymbol.py create mode 100644 python/run demo/Market Data/AvgPrice.py create mode 100644 python/run demo/Market Data/BookTicker.py create mode 100644 python/run demo/Market Data/Depth.py create mode 100644 python/run demo/Market Data/ETFInfo.py create mode 100644 python/run demo/Market Data/ExchangeInfo.py create mode 100644 python/run demo/Market Data/Kline.py create mode 100644 python/run demo/Market Data/Ping.py create mode 100644 python/run demo/Market Data/Price.py create mode 100644 python/run demo/Market Data/ServerTime.py create mode 100644 python/run demo/Market Data/Ticker24hr.py create mode 100644 python/run demo/Market Data/Trades.py create mode 100644 python/run demo/Rebate/AffiliateCommission.py create mode 100644 python/run demo/Rebate/AffiliateCommissionDetail.py create mode 100644 python/run demo/Rebate/AffiliateReferral.py create mode 100644 python/run demo/Rebate/AffiliateWithdraw.py create mode 100644 python/run demo/Rebate/RebateDetail.py create mode 100644 python/run demo/Rebate/RebateHistory.py create mode 100644 python/run demo/Rebate/ReferCode.py create mode 100644 python/run demo/Rebate/SelfRecordsDetail.py create mode 100644 python/run demo/Rebate/Subaffiliates.py create mode 100644 python/run demo/Spot Trade/AccountInfo.py create mode 100644 python/run demo/Spot Trade/AllOrders.py create mode 100644 python/run demo/Spot Trade/BatchOrder.py create mode 100644 python/run demo/Spot Trade/CancelAllOrders.py create mode 100644 python/run demo/Spot Trade/CancelOrder.py create mode 100644 python/run demo/Spot Trade/MxDeduct.py create mode 100644 python/run demo/Spot Trade/MxDeductStatus.py create mode 100644 python/run demo/Spot Trade/MyTrades.py create mode 100644 python/run demo/Spot Trade/OpenOrder.py create mode 100644 python/run demo/Spot Trade/PlaceOrder.py create mode 100644 python/run demo/Spot Trade/QueryOrder.py create mode 100644 python/run demo/Spot Trade/SelfSymbols.py create mode 100644 python/run demo/Spot Trade/TestOrder.py create mode 100644 python/run demo/SubAccount/CreateSubAccount.py create mode 100644 python/run demo/SubAccount/CreateSubApikey.py create mode 100644 python/run demo/SubAccount/DeleteSubApikey.py create mode 100644 python/run demo/SubAccount/SubAccountApikey.py create mode 100644 python/run demo/SubAccount/SubAccountList.py create mode 100644 python/run demo/SubAccount/UniTransfer.py create mode 100644 python/run demo/SubAccount/UniTransferHistory.py create mode 100644 python/run demo/Wallet/CancelWithdraw.py create mode 100644 python/run demo/Wallet/CoinList.py create mode 100644 python/run demo/Wallet/Convert.py create mode 100644 python/run demo/Wallet/ConvertHistory.py create mode 100644 python/run demo/Wallet/ConvertList.py create mode 100644 python/run demo/Wallet/DepositHistory.py create mode 100644 python/run demo/Wallet/GenerateDepositAddress.py create mode 100644 python/run demo/Wallet/GetDepositAddress.py create mode 100644 python/run demo/Wallet/GetWithdrawAddress.py create mode 100644 python/run demo/Wallet/InternalTransfer.py create mode 100644 python/run demo/Wallet/InternalTransferHistory.py create mode 100644 python/run demo/Wallet/Transfer.py create mode 100644 python/run demo/Wallet/TransferHistory.py create mode 100644 python/run demo/Wallet/TransferHistoryById.py create mode 100644 python/run demo/Wallet/Withdraw.py create mode 100644 python/run demo/Wallet/WithdrawHistory.py create mode 100644 python/spot/__init__.py create mode 100644 python/spot/config.py rename python/spot/{v3 => }/mexc_spot_v3.py (100%) delete mode 100644 python/spot/v2/mexc_spot_v2.py delete mode 100644 python/spot/v3/demo_v3.py diff --git a/python/README.md b/python/README.md index c497c272..e863d1c2 100644 --- a/python/README.md +++ b/python/README.md @@ -19,26 +19,30 @@ Fill in the corresponding function according to the parameters mentioned in the > ### Example(Spot V3) : -Use test_v3.py as a test example +Fill in your API key and Secret key in " python/spot/config.py " ```python -import mexc_spot_v3 -import time +mexc_host = "https://api.mexc.com" +api_key = "your apikey" +secret_key = "your secretkey" +``` + +Select the corresponding file in the " python/run demo " folder to execute + +Example " python/run demo/Market Data/ExchangeInfo.py " + +```python +from python.spot import mexc_spot_v3 -hosts = "https://api.mexc.com" -# mexc_key = "your apiKey" -# mexc_secret = "your secretKey" +market = mexc_spot_v3.mexc_market() -# Market Data -"""get kline""" -data = mexc_spot_v3.mexc_market(mexc_hosts=hosts) +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params params = { - 'symbol': 'BTCUSDT', - 'interval': '5m', - 'limit': 10 + "symbol": "BTCUSDT" } -response= data.get_kline(params) -print(response) +ExchangeInfo = market.get_exchangeInfo(params) +print(ExchangeInfo) ``` ## Spot Websocket Demo diff --git a/python/run demo/ListenKey/CreateListenKey.py b/python/run demo/ListenKey/CreateListenKey.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/ListenKey/DeleteListenkey.py b/python/run demo/ListenKey/DeleteListenkey.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/ListenKey/GetListenKey.py b/python/run demo/ListenKey/GetListenKey.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/ListenKey/PutListenKey.py b/python/run demo/ListenKey/PutListenKey.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/AggTrades.py b/python/run demo/Market Data/AggTrades.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/ApiSymbol.py b/python/run demo/Market Data/ApiSymbol.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/AvgPrice.py b/python/run demo/Market Data/AvgPrice.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/BookTicker.py b/python/run demo/Market Data/BookTicker.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/Depth.py b/python/run demo/Market Data/Depth.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/ETFInfo.py b/python/run demo/Market Data/ETFInfo.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/ExchangeInfo.py b/python/run demo/Market Data/ExchangeInfo.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/Kline.py b/python/run demo/Market Data/Kline.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/Ping.py b/python/run demo/Market Data/Ping.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/Price.py b/python/run demo/Market Data/Price.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/ServerTime.py b/python/run demo/Market Data/ServerTime.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/Ticker24hr.py b/python/run demo/Market Data/Ticker24hr.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Market Data/Trades.py b/python/run demo/Market Data/Trades.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Rebate/AffiliateCommission.py b/python/run demo/Rebate/AffiliateCommission.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Rebate/AffiliateCommissionDetail.py b/python/run demo/Rebate/AffiliateCommissionDetail.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Rebate/AffiliateReferral.py b/python/run demo/Rebate/AffiliateReferral.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Rebate/AffiliateWithdraw.py b/python/run demo/Rebate/AffiliateWithdraw.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Rebate/RebateDetail.py b/python/run demo/Rebate/RebateDetail.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Rebate/RebateHistory.py b/python/run demo/Rebate/RebateHistory.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Rebate/ReferCode.py b/python/run demo/Rebate/ReferCode.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Rebate/SelfRecordsDetail.py b/python/run demo/Rebate/SelfRecordsDetail.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Rebate/Subaffiliates.py b/python/run demo/Rebate/Subaffiliates.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/AccountInfo.py b/python/run demo/Spot Trade/AccountInfo.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/AllOrders.py b/python/run demo/Spot Trade/AllOrders.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/BatchOrder.py b/python/run demo/Spot Trade/BatchOrder.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/CancelAllOrders.py b/python/run demo/Spot Trade/CancelAllOrders.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/CancelOrder.py b/python/run demo/Spot Trade/CancelOrder.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/MxDeduct.py b/python/run demo/Spot Trade/MxDeduct.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/MxDeductStatus.py b/python/run demo/Spot Trade/MxDeductStatus.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/MyTrades.py b/python/run demo/Spot Trade/MyTrades.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/OpenOrder.py b/python/run demo/Spot Trade/OpenOrder.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/PlaceOrder.py b/python/run demo/Spot Trade/PlaceOrder.py new file mode 100644 index 00000000..ac8ea823 --- /dev/null +++ b/python/run demo/Spot Trade/PlaceOrder.py @@ -0,0 +1,16 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "MXUSDT", + "side": "BUY", + "type": "LIMIT", + "price": "1", + "quantity": "5" +} +OpenOrder = trade.post_order(params) +print(OpenOrder) \ No newline at end of file diff --git a/python/run demo/Spot Trade/QueryOrder.py b/python/run demo/Spot Trade/QueryOrder.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/SelfSymbols.py b/python/run demo/Spot Trade/SelfSymbols.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/TestOrder.py b/python/run demo/Spot Trade/TestOrder.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/SubAccount/CreateSubAccount.py b/python/run demo/SubAccount/CreateSubAccount.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/SubAccount/CreateSubApikey.py b/python/run demo/SubAccount/CreateSubApikey.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/SubAccount/DeleteSubApikey.py b/python/run demo/SubAccount/DeleteSubApikey.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/SubAccount/SubAccountApikey.py b/python/run demo/SubAccount/SubAccountApikey.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/SubAccount/SubAccountList.py b/python/run demo/SubAccount/SubAccountList.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/SubAccount/UniTransfer.py b/python/run demo/SubAccount/UniTransfer.py new file mode 100644 index 00000000..b0fa9c72 --- /dev/null +++ b/python/run demo/SubAccount/UniTransfer.py @@ -0,0 +1,17 @@ +from python.spot import mexc_spot_v3 + + +subaccount = mexc_spot_v3.mexc_subaccount() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "fromAccount": "xxx", + "toAccount": "xxx", + "fromAccountType": "SPOT", + "toAccountType": "SPOT", + "asset": "xxx", + "amount": "xxx" +} +UniservalTransfer = subaccount.post_universalTransfer(params) +print(UniservalTransfer) \ No newline at end of file diff --git a/python/run demo/SubAccount/UniTransferHistory.py b/python/run demo/SubAccount/UniTransferHistory.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/CancelWithdraw.py b/python/run demo/Wallet/CancelWithdraw.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/CoinList.py b/python/run demo/Wallet/CoinList.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/Convert.py b/python/run demo/Wallet/Convert.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/ConvertHistory.py b/python/run demo/Wallet/ConvertHistory.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/ConvertList.py b/python/run demo/Wallet/ConvertList.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/DepositHistory.py b/python/run demo/Wallet/DepositHistory.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/GenerateDepositAddress.py b/python/run demo/Wallet/GenerateDepositAddress.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/GetDepositAddress.py b/python/run demo/Wallet/GetDepositAddress.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/GetWithdrawAddress.py b/python/run demo/Wallet/GetWithdrawAddress.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/InternalTransfer.py b/python/run demo/Wallet/InternalTransfer.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/InternalTransferHistory.py b/python/run demo/Wallet/InternalTransferHistory.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/Transfer.py b/python/run demo/Wallet/Transfer.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/TransferHistory.py b/python/run demo/Wallet/TransferHistory.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/TransferHistoryById.py b/python/run demo/Wallet/TransferHistoryById.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/Withdraw.py b/python/run demo/Wallet/Withdraw.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Wallet/WithdrawHistory.py b/python/run demo/Wallet/WithdrawHistory.py new file mode 100644 index 00000000..e69de29b diff --git a/python/spot/__init__.py b/python/spot/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/spot/config.py b/python/spot/config.py new file mode 100644 index 00000000..e69de29b diff --git a/python/spot/v3/mexc_spot_v3.py b/python/spot/mexc_spot_v3.py similarity index 100% rename from python/spot/v3/mexc_spot_v3.py rename to python/spot/mexc_spot_v3.py diff --git a/python/spot/v2/mexc_spot_v2.py b/python/spot/v2/mexc_spot_v2.py deleted file mode 100644 index 5e65b8c2..00000000 --- a/python/spot/v2/mexc_spot_v2.py +++ /dev/null @@ -1,647 +0,0 @@ -import time -import json -import requests -import hmac -import hashlib - -BASE_URL = 'https://www.mexc.com' -API_KEY = 'your access key' -SECRET_KEY = 'your serect key' - - -def _get_server_time(): - return int(time.time()*1000) - - -def _sign_v2(sign_params=None): - params = (API_KEY, _get_server_time()) - if sign_params: - params = "%s%s%s" % (API_KEY, _get_server_time(), sign_params) - else: - params = "%s%s" % (API_KEY, _get_server_time()) - params = hmac.new(SECRET_KEY.encode(), params.encode(), - hashlib.sha256).hexdigest() - return params - - -def get_symbols(): - """get market data""" - method = 'GET' - path = '/open/api/v2/market/symbols' - url = '{}{}'.format(BASE_URL, path) - response = requests.request(method, url) - print(response.json()) - - -def get_timestamp(): - """get current timestamp""" - method = 'GET' - path = '/open/api/v2/common/timestamp' - url = '{}{}'.format(BASE_URL, path) - response = requests.request(method, url) - print(response.json()) - - -def get_ping(): - """get ping""" - method = 'GET' - path = '/open/api/v2/common/ping' - url = '{}{}'.format(BASE_URL, path) - response = requests.request(method, url) - print(response.json()) - - -def get_api_default_symbols(): - """get api default symbols""" - method = 'GET' - path = '/open/api/v2/market/api_default_symbols' - url = '{}{}'.format(BASE_URL, path) - response = requests.request(method, url) - print(response.json()) - - -def get_ticker(symbol): - """get symbol ticker information""" - method = 'GET' - path = '/open/api/v2/market/ticker' - url = '{}{}'.format(BASE_URL, path) - data = { - 'symbol': symbol, - } - response = requests.request(method, url, params=data) - print(response.json()) - - -def get_depth(symbol, depth): - """get symbol depth""" - method = 'GET' - path = '/open/api/v2/market/depth' - url = '{}{}'.format(BASE_URL, path) - data = { - 'symbol': symbol, - 'depth': depth, - } - response = requests.request(method, url, params=data) - print(response.json()) - - -def get_deals(symbol, limit=None): - """get deals records""" - method = 'GET' - path = '/open/api/v2/market/deals' - url = '{}{}'.format(BASE_URL, path) - data = { - 'symbol': symbol, - 'limit': limit, - } - response = requests.request(method, url, params=data) - print(response.json()) - - -def get_kline(symbol, interval, start_time=None, limit=None): - """get k-line data""" - method = 'GET' - path = '/open/api/v2/market/kline' - url = '{}{}'.format(BASE_URL, path) - data = { - 'symbol': symbol, - 'interval': interval, - } - if start_time: - data.update({'start_time': start_time}) - if limit: - data.update({'limit': limit}) - response = requests.request(method, url, params=data) - print(response.json()) - - -def get_currency_info(currency=None): - """get currency information""" - method = 'GET' - path = '/open/api/v2/market/coin/list' - url = '{}{}'.format(BASE_URL, path) - data = {} - if currency: - data.update({'currency': currency}) - response = requests.request(method, url, params=data) - print(response.json()) - - -def get_account_info(): - """get account information""" - method = 'GET' - path = '/open/api/v2/account/info' - url = '{}{}'.format(BASE_URL, path) - params = _sign_v2() - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - response = requests.request(method, url, headers=headers) - print(response.json()) - - -def get_account_symbols(): - """get symbols which account can trade""" - method = 'GET' - path = '/open/api/v2/market/api_symbols' - url = '{}{}'.format(BASE_URL, path) - params = _sign_v2() - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - response = requests.request(method, url, headers=headers) - print(response.json()) - - -def post_place(symbol, price, quantity, trade_type, order_type, client_order_id=None): - """place order""" - method = 'POST' - path = '/open/api/v2/order/place' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - 'symbol': symbol, - 'price': price, - 'quantity': quantity, - 'trade_type': trade_type, - 'order_type': order_type, - } - if client_order_id: - data_orignal.update({"client_order_id": client_order_id}) - data = json.dumps(data_orignal) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - response = requests.request( - method, url, data=data, headers=headers) - print(response.json()) - - -def delete_cancel(order_ids=None, client_order_ids=None): - """cancel order""" - method = 'DELETE' - path = '/open/api/v2/order/cancel' - url = '{}{}'.format(BASE_URL, path) - data_orignal = {} - if order_ids: - data_orignal.update({'order_ids':order_ids}) - if client_order_ids: - data_orignal.update({'client_order_ids':client_order_ids}) - - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request(method, url, headers=headers) - print(response.json()) - - -def post_place_batch(order_data): - """batch place oder""" - method = 'POST' - path = '/open/api/v2/order/place_batch' - url = '{}{}'.format(BASE_URL, path) - data_orignal = order_data - data = json.dumps(data_orignal) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - response = requests.request( - method, url, data=data, headers=headers) - print(response.json()) - - -def get_open_orders(symbol, trade_type=None, start_time=None, limit=None): - """get current order""" - method = 'GET' - path = '/open/api/v2/order/open_orders' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - "symbol": symbol, - } - if start_time: - data_orignal.update({"start_time": start_time}) - if trade_type: - data_orignal.update({"trade_type": trade_type}) - if limit: - data_orignal.update({"limit": limit}) - - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request(method, url, headers=headers) - print(response.json()) - - -def get_order_list(symbol, trade_type, states, start_time=None, limit=None): - """get order list""" - method = 'GET' - path = '/open/api/v2/order/list' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - "symbol": symbol, - "trade_type": trade_type, - "states": states, - } - if start_time: - data_orignal.update({"start_time": start_time}) - if limit: - data_orignal.update({"limit": limit}) - - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request(method, url, headers=headers) - print(response.json()) - - -def get_query_order(order_ids): - """get order query""" - method = 'GET' - path = '/open/api/v2/order/query' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - "order_ids": order_ids, - } - - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request(method, url, headers=headers) - print(response.json()) - - -def get_deals(symbol, limit=None, start_time=None): - """get order deals""" - method = 'GET' - path = '/open/api/v2/order/deals' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - "symbol": symbol, - } - if start_time: - data_orignal.update({"start_time": start_time}) - if limit: - data_orignal.update({"limit": limit}) - - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request(method, url, headers=headers) - print(response.json()) - - -def get_deal_detail(order_id): - """get order deal detail""" - method = 'GET' - path = '/open/api/v2/order/deal_detail' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - "order_id": order_id, - } - - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request(method, url, headers=headers) - print(response.json()) - - -def delete_cancel_symbol(symbol): - """cancel order""" - method = 'DELETE' - path = '/open/api/v2/order/cancel_by_symbol' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - "symbol": symbol, - } - - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request(method, url, headers=headers) - print(response.json()) - - -def get_deposit_address(currency): - """deposit address list""" - method = 'GET' - path = '/open/api/v2/asset/deposit/address/list' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - "currency": currency, - } - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request( - method, url, headers=headers) - print(response.json()) - - -def get_deposit_list(currency=None, startTime=None, endTime=None, pageSize=None, pagenum=None, state=None): - """deposit history list""" - method = 'GET' - path = '/open/api/v2/asset/deposit/list' - url = '{}{}'.format(BASE_URL, path) - data_orignal = {} - if currency: - data_orignal.update({"currency": currency}) - if pageSize: - data_orignal.update({"page_size": pageSize}) - if pagenum: - data_orignal.update({"page_unm": pagenum}) - if startTime: - data_orignal.update({"start_time": startTime}) - if endTime: - data_orignal.update({"end_time": endTime}) - if state: - data_orignal.update({"state": state}) - - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request( - method, url, headers=headers) - print(response.json()) - - -def get_address_list(currency=None, pageSize=None, pagenum=None): - """withdraw address list""" - method = 'GET' - path = '/open/api/v2/asset/address/list' - url = '{}{}'.format(BASE_URL, path) - data_orignal = {} - if currency: - data_orignal.update({"currency": currency}) - if pageSize: - data_orignal.update({"page_size": pageSize}) - if pagenum: - data_orignal.update({"page_unm": pagenum}) - - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request( - method, url, headers=headers) - print(response.json()) - - -def post_withdraw(currency, amount, address, chain=None, remark=None): - """withdraw""" - method = 'POST' - path = '/open/api/v2/asset/withdraw' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - "currency": currency, - "amount": amount, - "address": address, - } - if chain: - data_orignal.update({"chain": chain}) - if remark: - data_orignal.update({"remark": remark}) - data = json.dumps(data_orignal) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - response = requests.request( - method, url, data=data, headers=headers) - print(response.json()) - - -def delete_cancel(withdraw_id): - """cancel order""" - method = 'DELETE' - path = '/open/api/v2/asset/withdraw' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - "withdraw_id": withdraw_id, - } - - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request(method, url, headers=headers) - print(response.json()) - - -def get_withdraw_list(currency=None, withdraw_id=None, startTime=None, endTime=None, pageSize=None, pagenum=None, state=None): - """withdraw history list""" - method = 'GET' - path = '/open/api/v2/asset/withdraw/list' - url = '{}{}'.format(BASE_URL, path) - data_orignal = {} - if currency: - data_orignal.update({"currency": currency}) - if withdraw_id: - data_orignal.update({"withdraw_id": withdraw_id}) - if pageSize: - data_orignal.update({"page_size": pageSize}) - if pagenum: - data_orignal.update({"page_unm": pagenum}) - if startTime: - data_orignal.update({"start_time": startTime}) - if endTime: - data_orignal.update({"end_time": endTime}) - if state: - data_orignal.update({"state": state}) - - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request( - method, url, headers=headers) - print(response.json()) - - -def post_transfer(currency, amount, from_where, to_where): - """internal transfer""" - method = 'POST' - path = '/open/api/v2/asset/internal/transfer' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - "currency": currency, - "amount": amount, - "from": from_where, - "to": to_where, - } - data = json.dumps(data_orignal) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - response = requests.request( - method, url, data=data, headers=headers) - print(response.json()) - - -def get_transfer_list(): - """transfer history list""" - method = 'GET' - path = '/open/api/v2/asset/internal/transfer/record' - url = '{}{}'.format(BASE_URL, path) - params = _sign_v2() - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - response = requests.request( - method, url, headers=headers) - print(response.json()) - - -def get_account_blance(currency, account_type=None, sub_uid=None): - """account balance can be transfer""" - method = 'GET' - path = '/open/api/v2/account/balance' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - "currency": currency, - } - if account_type: - data_orignal.update({"account_type": account_type}) - if sub_uid: - data_orignal.update({"sub_uid": sub_uid}) - - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request( - method, url, headers=headers) - print(response.json()) - - -def get_transact_id(transact_id): - """get internal transfer order""" - method = 'GET' - path = '/open/api/v2/asset/internal/transfer/info' - url = '{}{}'.format(BASE_URL, path) - data_orignal = { - "transact_id": transact_id, - } - data = '&'.join('{}={}'.format( - i, data_orignal[i]) for i in sorted(data_orignal)) - params = _sign_v2(sign_params=data) - headers = { - "ApiKey": API_KEY, - "Request-Time": str(_get_server_time()), - "Signature": params, - "Content-Type": "application/json" - } - url = "%s%s%s" % (url, "?", data) - response = requests.request( - method, url, headers=headers) - print(response.json()) diff --git a/python/spot/v3/demo_v3.py b/python/spot/v3/demo_v3.py deleted file mode 100644 index 637ddb69..00000000 --- a/python/spot/v3/demo_v3.py +++ /dev/null @@ -1,61 +0,0 @@ -import mexc_spot_v3 - -hosts = "https://api.mexc.com" -mexc_key = "your apiKey" -mexc_secret = "your secretKey" - -# Market Data -"""get kline""" -data = mexc_spot_v3.mexc_market(mexc_hosts=hosts) -params = { - 'symbol': 'BTCUSDT', - 'interval': '5m', - 'limit': 10 -} -response = data.get_kline(params) -print(response) - - -# Spot Trade -"""place an order""" -trade = mexc_spot_v3.mexc_trade(mexc_key=mexc_key, mexc_secret=mexc_secret, mexc_hosts=hosts) -params = { - "symbol": "BTCUSDT", - "side": "BUY", - "type": "LIMIT", - "quantity": 0.005, - "price": "10000" -} -response = trade.post_order(params) -print(response) - -"""get account selfSymbols""" -response = trade.get_selfSymbols() -print(response) - -# Spot Account -"""get spot account information""" -account = mexc_spot_v3.mexc_account(mexc_key=mexc_key, mexc_secret=mexc_secret, mexc_hosts=hosts) -response = account.get_account_info() -print(response) - - -# Capital -"""get currency information""" -capital = mexc_spot_v3.mexc_capital(mexc_key=mexc_key, mexc_secret=mexc_secret, mexc_hosts=hosts) -response = capital.get_coinlist() -print(response) - - -# Sub-Account -"""get sub account information""" -sub_account = mexc_spot_v3.mexc_subaccount(mexc_key=mexc_key, mexc_secret=mexc_secret, mexc_hosts=hosts) -response = sub_account.get_SubAccountList() -print(response) - - -# Rebate -"""get rebate record details""" -margin = mexc_spot_v3.mexc_rebate(mexc_key=mexc_key, mexc_secret=mexc_secret, mexc_hosts=hosts) -response = margin.get_rebate_detail() -print(response) \ No newline at end of file From 3d714bfef89706572f8829371da91d5f1f97a1a8 Mon Sep 17 00:00:00 2001 From: "eddie.hsieh" Date: Fri, 12 Jan 2024 16:14:02 +0800 Subject: [PATCH 2/3] update demo --- python/run demo/ListenKey/CreateListenKey.py | 9 +++ python/run demo/ListenKey/DeleteListenkey.py | 12 ++++ python/run demo/ListenKey/GetListenKey.py | 9 +++ python/run demo/ListenKey/PutListenKey.py | 12 ++++ python/run demo/Market Data/AggTrades.py | 15 +++++ python/run demo/Market Data/ApiSymbol.py | 7 +++ python/run demo/Market Data/AvgPrice.py | 12 ++++ python/run demo/Market Data/BookTicker.py | 12 ++++ python/run demo/Market Data/Depth.py | 13 ++++ python/run demo/Market Data/ETFInfo.py | 12 ++++ python/run demo/Market Data/ExchangeInfo.py | 12 ++++ python/run demo/Market Data/Kline.py | 16 +++++ python/run demo/Market Data/Ping.py | 7 +++ python/run demo/Market Data/Price.py | 12 ++++ python/run demo/Market Data/ServerTime.py | 7 +++ python/run demo/Market Data/Ticker24hr.py | 12 ++++ python/run demo/Market Data/Trades.py | 13 ++++ python/run demo/Rebate/AffiliateCommission.py | 16 +++++ .../Rebate/AffiliateCommissionDetail.py | 17 +++++ python/run demo/Rebate/AffiliateReferral.py | 17 +++++ python/run demo/Rebate/AffiliateWithdraw.py | 15 +++++ python/run demo/Rebate/RebateDetail.py | 14 +++++ python/run demo/Rebate/RebateHistory.py | 14 +++++ python/run demo/Rebate/ReferCode.py | 9 +++ python/run demo/Rebate/SelfRecordsDetail.py | 14 +++++ python/run demo/Rebate/Subaffiliates.py | 16 +++++ python/run demo/Spot Trade/AccountInfo.py | 10 +++ python/run demo/Spot Trade/AllOrders.py | 15 +++++ python/run demo/Spot Trade/BatchOrder.py | 22 +++++++ python/run demo/Spot Trade/CancelAllOrders.py | 12 ++++ python/run demo/Spot Trade/CancelOrder.py | 13 ++++ python/run demo/Spot Trade/MxDeduct.py | 12 ++++ python/run demo/Spot Trade/MxDeductStatus.py | 12 ++++ python/run demo/Spot Trade/MyTrades.py | 16 +++++ python/run demo/Spot Trade/OpenOrder.py | 12 ++++ python/run demo/Spot Trade/PlaceOrder.py | 4 +- python/run demo/Spot Trade/QueryOrder.py | 14 +++++ python/run demo/Spot Trade/SelfSymbols.py | 10 +++ python/run demo/Spot Trade/TestOrder.py | 16 +++++ .../run demo/SubAccount/CreateSubAccount.py | 13 ++++ python/run demo/SubAccount/CreateSubApikey.py | 15 +++++ python/run demo/SubAccount/DeleteSubApikey.py | 13 ++++ .../run demo/SubAccount/SubAccountApikey.py | 12 ++++ python/run demo/SubAccount/SubAccountList.py | 15 +++++ .../run demo/SubAccount/UniTransferHistory.py | 19 ++++++ python/run demo/Wallet/CancelWithdraw.py | 12 ++++ python/run demo/Wallet/CoinList.py | 10 +++ python/run demo/Wallet/Convert.py | 12 ++++ python/run demo/Wallet/ConvertHistory.py | 15 +++++ python/run demo/Wallet/ConvertList.py | 10 +++ python/run demo/Wallet/DepositHistory.py | 15 +++++ .../run demo/Wallet/GenerateDepositAddress.py | 13 ++++ python/run demo/Wallet/GetDepositAddress.py | 13 ++++ python/run demo/Wallet/GetWithdrawAddress.py | 14 +++++ python/run demo/Wallet/InternalTransfer.py | 16 +++++ .../Wallet/InternalTransferHistory.py | 16 +++++ python/run demo/Wallet/Transfer.py | 15 +++++ python/run demo/Wallet/TransferHistory.py | 17 +++++ python/run demo/Wallet/TransferHistoryById.py | 12 ++++ python/run demo/Wallet/Withdraw.py | 18 ++++++ python/run demo/Wallet/WithdrawHistory.py | 15 +++++ python/spot/config.py | 3 + python/spot/mexc_spot_v3.py | 62 ++++++++----------- .../websocket/spotV2_websocket_python_demo.py | 1 - .../websocket/spotV3_websocket_python_demo.py | 21 ------- 65 files changed, 829 insertions(+), 60 deletions(-) diff --git a/python/run demo/ListenKey/CreateListenKey.py b/python/run demo/ListenKey/CreateListenKey.py index e69de29b..6fcc14ea 100644 --- a/python/run demo/ListenKey/CreateListenKey.py +++ b/python/run demo/ListenKey/CreateListenKey.py @@ -0,0 +1,9 @@ +from python.spot import mexc_spot_v3 + + +listenkey = mexc_spot_v3.mexc_listenkey() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +CreateListenKey = listenkey.post_listenKey() +print(CreateListenKey) \ No newline at end of file diff --git a/python/run demo/ListenKey/DeleteListenkey.py b/python/run demo/ListenKey/DeleteListenkey.py index e69de29b..7a7c1dd1 100644 --- a/python/run demo/ListenKey/DeleteListenkey.py +++ b/python/run demo/ListenKey/DeleteListenkey.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +listenkey = mexc_spot_v3.mexc_listenkey() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "listenKey": "xxx" +} +DeleteListenKey = listenkey.delete_listenKey(params) +print(DeleteListenKey) \ No newline at end of file diff --git a/python/run demo/ListenKey/GetListenKey.py b/python/run demo/ListenKey/GetListenKey.py index e69de29b..4daa268b 100644 --- a/python/run demo/ListenKey/GetListenKey.py +++ b/python/run demo/ListenKey/GetListenKey.py @@ -0,0 +1,9 @@ +from python.spot import mexc_spot_v3 + + +listenkey = mexc_spot_v3.mexc_listenkey() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +GetListenKey = listenkey.get_listenKey() +print(GetListenKey) \ No newline at end of file diff --git a/python/run demo/ListenKey/PutListenKey.py b/python/run demo/ListenKey/PutListenKey.py index e69de29b..aa4cbb85 100644 --- a/python/run demo/ListenKey/PutListenKey.py +++ b/python/run demo/ListenKey/PutListenKey.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +listenkey = mexc_spot_v3.mexc_listenkey() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "listenKey": "xxx" +} +PutListenKey = listenkey.put_listenKey(params) +print(PutListenKey) \ No newline at end of file diff --git a/python/run demo/Market Data/AggTrades.py b/python/run demo/Market Data/AggTrades.py index e69de29b..6e0abe43 100644 --- a/python/run demo/Market Data/AggTrades.py +++ b/python/run demo/Market Data/AggTrades.py @@ -0,0 +1,15 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "BTCUSDT", + "limit": "10", + # "startTime": "1705029500000", + # "endTime": "1705029599909" +} +AggTrades = market.get_aggtrades(params) +print(AggTrades) \ No newline at end of file diff --git a/python/run demo/Market Data/ApiSymbol.py b/python/run demo/Market Data/ApiSymbol.py index e69de29b..93e360b5 100644 --- a/python/run demo/Market Data/ApiSymbol.py +++ b/python/run demo/Market Data/ApiSymbol.py @@ -0,0 +1,7 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +ApiSymbol = market.get_defaultSymbols() +print(ApiSymbol) \ No newline at end of file diff --git a/python/run demo/Market Data/AvgPrice.py b/python/run demo/Market Data/AvgPrice.py index e69de29b..90ddada5 100644 --- a/python/run demo/Market Data/AvgPrice.py +++ b/python/run demo/Market Data/AvgPrice.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "BTCUSDT", +} +AvgPrice = market.get_avgprice(params) +print(AvgPrice) \ No newline at end of file diff --git a/python/run demo/Market Data/BookTicker.py b/python/run demo/Market Data/BookTicker.py index e69de29b..4f8a46fb 100644 --- a/python/run demo/Market Data/BookTicker.py +++ b/python/run demo/Market Data/BookTicker.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "BTCUSDT", +} +BookTicker = market.get_bookticker(params) +print(BookTicker) \ No newline at end of file diff --git a/python/run demo/Market Data/Depth.py b/python/run demo/Market Data/Depth.py index e69de29b..f2e51c60 100644 --- a/python/run demo/Market Data/Depth.py +++ b/python/run demo/Market Data/Depth.py @@ -0,0 +1,13 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"10"} +# If there are no parameters, input: "" +params = { + "symbol": "BTCUSDT", + "limit": "10" +} +Depth = market.get_depth(params) +print(Depth) \ No newline at end of file diff --git a/python/run demo/Market Data/ETFInfo.py b/python/run demo/Market Data/ETFInfo.py index e69de29b..3dfc7e06 100644 --- a/python/run demo/Market Data/ETFInfo.py +++ b/python/run demo/Market Data/ETFInfo.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "symbols": "" +} +ETFInfo = market.get_ETF_info(params) +print(ETFInfo) \ No newline at end of file diff --git a/python/run demo/Market Data/ExchangeInfo.py b/python/run demo/Market Data/ExchangeInfo.py index e69de29b..90ce9a74 100644 --- a/python/run demo/Market Data/ExchangeInfo.py +++ b/python/run demo/Market Data/ExchangeInfo.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbols": "ETHUSDT,BTCUSDT" +} +ExchangeInfo = market.get_exchangeInfo(params) +print(ExchangeInfo) \ No newline at end of file diff --git a/python/run demo/Market Data/Kline.py b/python/run demo/Market Data/Kline.py index e69de29b..723c016b 100644 --- a/python/run demo/Market Data/Kline.py +++ b/python/run demo/Market Data/Kline.py @@ -0,0 +1,16 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "BTCUSDT", + "interval": "5m", + "limit": "10", + # "startTime": "1705029500000", + # "endTime": "1705029599909" +} +Kline = market.get_kline(params) +print(Kline) \ No newline at end of file diff --git a/python/run demo/Market Data/Ping.py b/python/run demo/Market Data/Ping.py index e69de29b..4ec75208 100644 --- a/python/run demo/Market Data/Ping.py +++ b/python/run demo/Market Data/Ping.py @@ -0,0 +1,7 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +ping = market.get_ping() +print(ping) \ No newline at end of file diff --git a/python/run demo/Market Data/Price.py b/python/run demo/Market Data/Price.py index e69de29b..a02d8daa 100644 --- a/python/run demo/Market Data/Price.py +++ b/python/run demo/Market Data/Price.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "BTCUSDT", +} +Price = market.get_price(params) +print(Price) \ No newline at end of file diff --git a/python/run demo/Market Data/ServerTime.py b/python/run demo/Market Data/ServerTime.py index e69de29b..8d39aaff 100644 --- a/python/run demo/Market Data/ServerTime.py +++ b/python/run demo/Market Data/ServerTime.py @@ -0,0 +1,7 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +servertime = market.get_timestamp() +print(servertime) \ No newline at end of file diff --git a/python/run demo/Market Data/Ticker24hr.py b/python/run demo/Market Data/Ticker24hr.py index e69de29b..b5869319 100644 --- a/python/run demo/Market Data/Ticker24hr.py +++ b/python/run demo/Market Data/Ticker24hr.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "BTCUSDT", +} +Ticker24hr = market.get_24hr_ticker(params) +print(Ticker24hr) \ No newline at end of file diff --git a/python/run demo/Market Data/Trades.py b/python/run demo/Market Data/Trades.py index e69de29b..6a196df0 100644 --- a/python/run demo/Market Data/Trades.py +++ b/python/run demo/Market Data/Trades.py @@ -0,0 +1,13 @@ +from python.spot import mexc_spot_v3 + + +market = mexc_spot_v3.mexc_market() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "BTCUSDT", + "limit": "10" +} +Trades = market.get_deals(params) +print(Trades) \ No newline at end of file diff --git a/python/run demo/Rebate/AffiliateCommission.py b/python/run demo/Rebate/AffiliateCommission.py index e69de29b..05faf766 100644 --- a/python/run demo/Rebate/AffiliateCommission.py +++ b/python/run demo/Rebate/AffiliateCommission.py @@ -0,0 +1,16 @@ +from python.spot import mexc_spot_v3 + + +rebate = mexc_spot_v3.mexc_rebate() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "startTime": "xxx", + # "endTime": "xxx", + # "inviteCode": "xxx", + # "page": "xxx", + # "pageSize": "xxx" +} +AffiliateCommission = rebate.get_affiliate_commission(params) +print(AffiliateCommission) \ No newline at end of file diff --git a/python/run demo/Rebate/AffiliateCommissionDetail.py b/python/run demo/Rebate/AffiliateCommissionDetail.py index e69de29b..9df6523d 100644 --- a/python/run demo/Rebate/AffiliateCommissionDetail.py +++ b/python/run demo/Rebate/AffiliateCommissionDetail.py @@ -0,0 +1,17 @@ +from python.spot import mexc_spot_v3 + + +rebate = mexc_spot_v3.mexc_rebate() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "startTime": "xxx", + # "endTime": "xxx", + # "inviteCode": "xxx", + # "page": "xxx", + # "pageSize": "xxx", + # "type": "1" +} +AffiliateCommissionDetail = rebate.get_affiliate_commission_detail(params) +print(AffiliateCommissionDetail) \ No newline at end of file diff --git a/python/run demo/Rebate/AffiliateReferral.py b/python/run demo/Rebate/AffiliateReferral.py index e69de29b..fcb80970 100644 --- a/python/run demo/Rebate/AffiliateReferral.py +++ b/python/run demo/Rebate/AffiliateReferral.py @@ -0,0 +1,17 @@ +from python.spot import mexc_spot_v3 + + +rebate = mexc_spot_v3.mexc_rebate() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "startTime": "xxx", + # "endTime": "xxx", + # "uid": "xxx", + # "inviteCode": "xxx", + # "page": "xxx", + # "pageSize": "xxx" +} +AffiliateReferral = rebate.get_affiliate_referral(params) +print(AffiliateReferral) \ No newline at end of file diff --git a/python/run demo/Rebate/AffiliateWithdraw.py b/python/run demo/Rebate/AffiliateWithdraw.py index e69de29b..201b26c0 100644 --- a/python/run demo/Rebate/AffiliateWithdraw.py +++ b/python/run demo/Rebate/AffiliateWithdraw.py @@ -0,0 +1,15 @@ +from python.spot import mexc_spot_v3 + + +rebate = mexc_spot_v3.mexc_rebate() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "startTime": "xxx", + # "endTime": "xxx", + # "page": "xxx", + # "pageSize": "xxx" +} +AffiliateWithdraw = rebate.get_affiliate_withdraw(params) +print(AffiliateWithdraw) \ No newline at end of file diff --git a/python/run demo/Rebate/RebateDetail.py b/python/run demo/Rebate/RebateDetail.py index e69de29b..b7f84382 100644 --- a/python/run demo/Rebate/RebateDetail.py +++ b/python/run demo/Rebate/RebateDetail.py @@ -0,0 +1,14 @@ +from python.spot import mexc_spot_v3 + + +rebate = mexc_spot_v3.mexc_rebate() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "startTime": "xxx", + # "endTime": "xxx", + # "page": "xxx" +} +RebateDetail = rebate.get_rebate_detail(params) +print(RebateDetail) \ No newline at end of file diff --git a/python/run demo/Rebate/RebateHistory.py b/python/run demo/Rebate/RebateHistory.py index e69de29b..9a488b62 100644 --- a/python/run demo/Rebate/RebateHistory.py +++ b/python/run demo/Rebate/RebateHistory.py @@ -0,0 +1,14 @@ +from python.spot import mexc_spot_v3 + + +rebate = mexc_spot_v3.mexc_rebate() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "startTime": "xxx", + # "endTime": "xxx", + # "page": "xxx" +} +RebateHistory = rebate.get_taxQuery(params) +print(RebateHistory) \ No newline at end of file diff --git a/python/run demo/Rebate/ReferCode.py b/python/run demo/Rebate/ReferCode.py index e69de29b..bbb1da2e 100644 --- a/python/run demo/Rebate/ReferCode.py +++ b/python/run demo/Rebate/ReferCode.py @@ -0,0 +1,9 @@ +from python.spot import mexc_spot_v3 + + +rebate = mexc_spot_v3.mexc_rebate() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +ReferCode = rebate.get_inviter() +print(ReferCode) \ No newline at end of file diff --git a/python/run demo/Rebate/SelfRecordsDetail.py b/python/run demo/Rebate/SelfRecordsDetail.py index e69de29b..3dc67e01 100644 --- a/python/run demo/Rebate/SelfRecordsDetail.py +++ b/python/run demo/Rebate/SelfRecordsDetail.py @@ -0,0 +1,14 @@ +from python.spot import mexc_spot_v3 + + +rebate = mexc_spot_v3.mexc_rebate() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "startTime": "xxx", + # "endTime": "xxx", + # "page": "xxx" +} +SelfRecordsDetail = rebate.get_kickback_detail(params) +print(SelfRecordsDetail) \ No newline at end of file diff --git a/python/run demo/Rebate/Subaffiliates.py b/python/run demo/Rebate/Subaffiliates.py index e69de29b..03e35d3b 100644 --- a/python/run demo/Rebate/Subaffiliates.py +++ b/python/run demo/Rebate/Subaffiliates.py @@ -0,0 +1,16 @@ +from python.spot import mexc_spot_v3 + + +rebate = mexc_spot_v3.mexc_rebate() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "startTime": "xxx", + # "endTime": "xxx", + # "inviteCode": "xxx", + # "page": "xxx", + # "pageSize": "xxx" +} +Subaffiliates = rebate.get_affiliate_subaffiliates(params) +print(Subaffiliates) \ No newline at end of file diff --git a/python/run demo/Spot Trade/AccountInfo.py b/python/run demo/Spot Trade/AccountInfo.py index e69de29b..b004ecfa 100644 --- a/python/run demo/Spot Trade/AccountInfo.py +++ b/python/run demo/Spot Trade/AccountInfo.py @@ -0,0 +1,10 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params + +AccountInfo = trade.get_account_info() +print(AccountInfo) \ No newline at end of file diff --git a/python/run demo/Spot Trade/AllOrders.py b/python/run demo/Spot Trade/AllOrders.py index e69de29b..424a61b1 100644 --- a/python/run demo/Spot Trade/AllOrders.py +++ b/python/run demo/Spot Trade/AllOrders.py @@ -0,0 +1,15 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "MXUSDT", + "limit": "10", + # "startTime": "xxx", + # "endTime": "xxx" +} +AllOrders = trade.get_allorders(params) +print(AllOrders) \ No newline at end of file diff --git a/python/run demo/Spot Trade/BatchOrder.py b/python/run demo/Spot Trade/BatchOrder.py index e69de29b..c0420238 100644 --- a/python/run demo/Spot Trade/BatchOrder.py +++ b/python/run demo/Spot Trade/BatchOrder.py @@ -0,0 +1,22 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = [{ + "symbol": "MXUSDT", + "side": "BUY", + "type": "LIMIT_MAKER", + "quantity": 10, + "price": "0.5" + }, { + "symbol": "MXUSDT", + "side": "BUY", + "type": "LIMIT_MAKER", + "quantity": 10, + "price": "0.6" + }] +BatchOrder = trade.post_batchorders(params) +print(BatchOrder) \ No newline at end of file diff --git a/python/run demo/Spot Trade/CancelAllOrders.py b/python/run demo/Spot Trade/CancelAllOrders.py index e69de29b..489a7b80 100644 --- a/python/run demo/Spot Trade/CancelAllOrders.py +++ b/python/run demo/Spot Trade/CancelAllOrders.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "MXUSDT", +} +CancelAllOrders = trade.delete_openorders(params) +print(CancelAllOrders) \ No newline at end of file diff --git a/python/run demo/Spot Trade/CancelOrder.py b/python/run demo/Spot Trade/CancelOrder.py index e69de29b..d2d24e14 100644 --- a/python/run demo/Spot Trade/CancelOrder.py +++ b/python/run demo/Spot Trade/CancelOrder.py @@ -0,0 +1,13 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "MXUSDT", + "orderId": "C01__xxx" +} +CancelOrder = trade.delete_order(params) +print(CancelOrder) \ No newline at end of file diff --git a/python/run demo/Spot Trade/MxDeduct.py b/python/run demo/Spot Trade/MxDeduct.py index e69de29b..fbefc052 100644 --- a/python/run demo/Spot Trade/MxDeduct.py +++ b/python/run demo/Spot Trade/MxDeduct.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "mxDeductEnable": "true" +} +MxDeduct = trade.post_mxDeDuct(params) +print(MxDeduct) \ No newline at end of file diff --git a/python/run demo/Spot Trade/MxDeductStatus.py b/python/run demo/Spot Trade/MxDeductStatus.py index e69de29b..98fb5399 100644 --- a/python/run demo/Spot Trade/MxDeductStatus.py +++ b/python/run demo/Spot Trade/MxDeductStatus.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "mxDeductEnable": "true" +} +MxDeductStatus = trade.get_mxDeDuct() +print(MxDeductStatus) \ No newline at end of file diff --git a/python/run demo/Spot Trade/MyTrades.py b/python/run demo/Spot Trade/MyTrades.py index e69de29b..ec1cdc7e 100644 --- a/python/run demo/Spot Trade/MyTrades.py +++ b/python/run demo/Spot Trade/MyTrades.py @@ -0,0 +1,16 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "MXUSDT", + # "orderId": "C01_XXX", + "limit": "10", + # "startTime": "xxx", + # "endTime": "xxx" +} +AllOrders = trade.get_mytrades(params) +print(AllOrders) \ No newline at end of file diff --git a/python/run demo/Spot Trade/OpenOrder.py b/python/run demo/Spot Trade/OpenOrder.py index e69de29b..97d5b909 100644 --- a/python/run demo/Spot Trade/OpenOrder.py +++ b/python/run demo/Spot Trade/OpenOrder.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "MXUSDT,BTCUSDT" +} +OpenOrder = trade.get_openorders(params) +print(OpenOrder) \ No newline at end of file diff --git a/python/run demo/Spot Trade/PlaceOrder.py b/python/run demo/Spot Trade/PlaceOrder.py index ac8ea823..f5df33d6 100644 --- a/python/run demo/Spot Trade/PlaceOrder.py +++ b/python/run demo/Spot Trade/PlaceOrder.py @@ -12,5 +12,5 @@ "price": "1", "quantity": "5" } -OpenOrder = trade.post_order(params) -print(OpenOrder) \ No newline at end of file +PlaceOrder = trade.post_order(params) +print(PlaceOrder) \ No newline at end of file diff --git a/python/run demo/Spot Trade/QueryOrder.py b/python/run demo/Spot Trade/QueryOrder.py index e69de29b..af6bc613 100644 --- a/python/run demo/Spot Trade/QueryOrder.py +++ b/python/run demo/Spot Trade/QueryOrder.py @@ -0,0 +1,14 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "MXUSDT", + # "origClientOrderId": "xxx", + "orderId": "C01__xxx", +} +QueryOrder = trade.get_order(params) +print(QueryOrder) \ No newline at end of file diff --git a/python/run demo/Spot Trade/SelfSymbols.py b/python/run demo/Spot Trade/SelfSymbols.py index e69de29b..9d6d486f 100644 --- a/python/run demo/Spot Trade/SelfSymbols.py +++ b/python/run demo/Spot Trade/SelfSymbols.py @@ -0,0 +1,10 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params + +SelfSymbols = trade.get_selfSymbols() +print(SelfSymbols) \ No newline at end of file diff --git a/python/run demo/Spot Trade/TestOrder.py b/python/run demo/Spot Trade/TestOrder.py index e69de29b..7c50d099 100644 --- a/python/run demo/Spot Trade/TestOrder.py +++ b/python/run demo/Spot Trade/TestOrder.py @@ -0,0 +1,16 @@ +from python.spot import mexc_spot_v3 + + +trade = mexc_spot_v3.mexc_trade() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "symbol": "MXUSDT", + "side": "BUY", + "type": "LIMIT", + "price": "1", + "quantity": "5" +} +TestOrder = trade.post_order_test(params) +print(TestOrder) \ No newline at end of file diff --git a/python/run demo/SubAccount/CreateSubAccount.py b/python/run demo/SubAccount/CreateSubAccount.py index e69de29b..ac204384 100644 --- a/python/run demo/SubAccount/CreateSubAccount.py +++ b/python/run demo/SubAccount/CreateSubAccount.py @@ -0,0 +1,13 @@ +from python.spot import mexc_spot_v3 + + +subaccount = mexc_spot_v3.mexc_subaccount() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "subAccount": "xxx", + "note": "xxx" +} +CreateSubAccount = subaccount.post_virtualSubAccount(params) +print(CreateSubAccount) \ No newline at end of file diff --git a/python/run demo/SubAccount/CreateSubApikey.py b/python/run demo/SubAccount/CreateSubApikey.py index e69de29b..7c7cd5c1 100644 --- a/python/run demo/SubAccount/CreateSubApikey.py +++ b/python/run demo/SubAccount/CreateSubApikey.py @@ -0,0 +1,15 @@ +from python.spot import mexc_spot_v3 + + +subaccount = mexc_spot_v3.mexc_subaccount() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "subAccount": "xxx", + "note": "xxx", + "permissions": "xxx", + # "ip": "xxx" +} +CreateSubApikey = subaccount.post_virtualApiKey(params) +print(CreateSubApikey) \ No newline at end of file diff --git a/python/run demo/SubAccount/DeleteSubApikey.py b/python/run demo/SubAccount/DeleteSubApikey.py index e69de29b..b9b485f1 100644 --- a/python/run demo/SubAccount/DeleteSubApikey.py +++ b/python/run demo/SubAccount/DeleteSubApikey.py @@ -0,0 +1,13 @@ +from python.spot import mexc_spot_v3 + + +subaccount = mexc_spot_v3.mexc_subaccount() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "subAccount": "xxx", + "apikey": "xxx" +} +DeleteSubApikey = subaccount.delete_virtualApiKey(params) +print(DeleteSubApikey) \ No newline at end of file diff --git a/python/run demo/SubAccount/SubAccountApikey.py b/python/run demo/SubAccount/SubAccountApikey.py index e69de29b..f1549b18 100644 --- a/python/run demo/SubAccount/SubAccountApikey.py +++ b/python/run demo/SubAccount/SubAccountApikey.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +subaccount = mexc_spot_v3.mexc_subaccount() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "subAccount": "xxx" +} +SubAccountApikey = subaccount.get_virtualApiKey(params) +print(SubAccountApikey) \ No newline at end of file diff --git a/python/run demo/SubAccount/SubAccountList.py b/python/run demo/SubAccount/SubAccountList.py index e69de29b..a140f1e9 100644 --- a/python/run demo/SubAccount/SubAccountList.py +++ b/python/run demo/SubAccount/SubAccountList.py @@ -0,0 +1,15 @@ +from python.spot import mexc_spot_v3 + + +subaccount = mexc_spot_v3.mexc_subaccount() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "subAccount": "xxx", + # "isFreeze": "xxx", + # "page": "xxx", + # "limit": "xxx" +} +SubAccountList = subaccount.get_SubAccountList(params) +print(SubAccountList) \ No newline at end of file diff --git a/python/run demo/SubAccount/UniTransferHistory.py b/python/run demo/SubAccount/UniTransferHistory.py index e69de29b..3b1296a6 100644 --- a/python/run demo/SubAccount/UniTransferHistory.py +++ b/python/run demo/SubAccount/UniTransferHistory.py @@ -0,0 +1,19 @@ +from python.spot import mexc_spot_v3 + + +subaccount = mexc_spot_v3.mexc_subaccount() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "fromAccount": "xxx", + # "toAccount": "xxx", + "fromAccountType": "SPOT", + "toAccountType": "SPOT", + # "startTime": "xxx", + # "endTime": "xxx", + # "page": "xxx", + # "limit": "xxx" +} +UniTransferHistory = subaccount.get_universalTransfer(params) +print(UniTransferHistory) \ No newline at end of file diff --git a/python/run demo/Wallet/CancelWithdraw.py b/python/run demo/Wallet/CancelWithdraw.py index e69de29b..39b912ad 100644 --- a/python/run demo/Wallet/CancelWithdraw.py +++ b/python/run demo/Wallet/CancelWithdraw.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "id": "xxx", +} +CancelWithdraw = wallet.cancel_withdraw(params) +print(CancelWithdraw) \ No newline at end of file diff --git a/python/run demo/Wallet/CoinList.py b/python/run demo/Wallet/CoinList.py index e69de29b..3328b942 100644 --- a/python/run demo/Wallet/CoinList.py +++ b/python/run demo/Wallet/CoinList.py @@ -0,0 +1,10 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params + +CoinList = wallet.get_coinlist() +print(CoinList) \ No newline at end of file diff --git a/python/run demo/Wallet/Convert.py b/python/run demo/Wallet/Convert.py index e69de29b..70542d54 100644 --- a/python/run demo/Wallet/Convert.py +++ b/python/run demo/Wallet/Convert.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "asset": "xxx" +} +Convert = wallet.post_smallAssets_convert(params) +print(Convert) \ No newline at end of file diff --git a/python/run demo/Wallet/ConvertHistory.py b/python/run demo/Wallet/ConvertHistory.py index e69de29b..bb26cb82 100644 --- a/python/run demo/Wallet/ConvertHistory.py +++ b/python/run demo/Wallet/ConvertHistory.py @@ -0,0 +1,15 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "startTime": "xxx", + # "endTime": "xxx", + # "page": "xxx", + # "limit": "xxx" +} +ConvertHistory = wallet.get_smallAssets_history(params) +print(ConvertHistory) \ No newline at end of file diff --git a/python/run demo/Wallet/ConvertList.py b/python/run demo/Wallet/ConvertList.py index e69de29b..7d1b8a7b 100644 --- a/python/run demo/Wallet/ConvertList.py +++ b/python/run demo/Wallet/ConvertList.py @@ -0,0 +1,10 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params + +ConvertList = wallet.get_smallAssets_list() +print(ConvertList) \ No newline at end of file diff --git a/python/run demo/Wallet/DepositHistory.py b/python/run demo/Wallet/DepositHistory.py index e69de29b..a82ed731 100644 --- a/python/run demo/Wallet/DepositHistory.py +++ b/python/run demo/Wallet/DepositHistory.py @@ -0,0 +1,15 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "coin": "USDT", + "limit": "10", + # "startTime": "xxx", + # "endTime": "xxx" +} +DepositHistory = wallet.get_deposit_list(params) +print(DepositHistory) \ No newline at end of file diff --git a/python/run demo/Wallet/GenerateDepositAddress.py b/python/run demo/Wallet/GenerateDepositAddress.py index e69de29b..a22cfef4 100644 --- a/python/run demo/Wallet/GenerateDepositAddress.py +++ b/python/run demo/Wallet/GenerateDepositAddress.py @@ -0,0 +1,13 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "coin": "USDT", + "network": "Tron(TRC20)" +} +GenerateDepositAddress = wallet.post_deposit_address(params) +print(GenerateDepositAddress) \ No newline at end of file diff --git a/python/run demo/Wallet/GetDepositAddress.py b/python/run demo/Wallet/GetDepositAddress.py index e69de29b..9a4b1e37 100644 --- a/python/run demo/Wallet/GetDepositAddress.py +++ b/python/run demo/Wallet/GetDepositAddress.py @@ -0,0 +1,13 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "coin": "USDT", + "network": "Tron(TRC20)" +} +DepositAddress = wallet.get_deposit_address(params) +print(DepositAddress) \ No newline at end of file diff --git a/python/run demo/Wallet/GetWithdrawAddress.py b/python/run demo/Wallet/GetWithdrawAddress.py index e69de29b..e87c76c1 100644 --- a/python/run demo/Wallet/GetWithdrawAddress.py +++ b/python/run demo/Wallet/GetWithdrawAddress.py @@ -0,0 +1,14 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "coin": "USDT", + "network": "Tron(TRC20)", + # "page": "xxx", +} +WithdrawAddress = wallet.get_withdraw_address(params) +print(WithdrawAddress) \ No newline at end of file diff --git a/python/run demo/Wallet/InternalTransfer.py b/python/run demo/Wallet/InternalTransfer.py index e69de29b..451087bc 100644 --- a/python/run demo/Wallet/InternalTransfer.py +++ b/python/run demo/Wallet/InternalTransfer.py @@ -0,0 +1,16 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "toAccountType": "xxx", + "toAccount": "xxx", + # "areaCode": "xxx", + "asset": "xxx", + "amount": "xxx" +} +InternalTransfer = wallet.post_transfer_internal(params) +print(InternalTransfer) \ No newline at end of file diff --git a/python/run demo/Wallet/InternalTransferHistory.py b/python/run demo/Wallet/InternalTransferHistory.py index e69de29b..a0729c55 100644 --- a/python/run demo/Wallet/InternalTransferHistory.py +++ b/python/run demo/Wallet/InternalTransferHistory.py @@ -0,0 +1,16 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + # "startTime": "xxx", + # "endTime": "xxx", + # "page": "xxx", + # "limit": "xxx", + # "tranId": "xxx" +} +InternalTransferHistory = wallet.get_transfer_internal_list(params) +print(InternalTransferHistory) \ No newline at end of file diff --git a/python/run demo/Wallet/Transfer.py b/python/run demo/Wallet/Transfer.py index e69de29b..960c895e 100644 --- a/python/run demo/Wallet/Transfer.py +++ b/python/run demo/Wallet/Transfer.py @@ -0,0 +1,15 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "fromAccountType": "SPOT", + "toAccountType": "FUTURES", + "asset": "USDT", + "amount": "1000" +} +Transfer = wallet.post_transfer(params) +print(Transfer) \ No newline at end of file diff --git a/python/run demo/Wallet/TransferHistory.py b/python/run demo/Wallet/TransferHistory.py index e69de29b..fb27cf39 100644 --- a/python/run demo/Wallet/TransferHistory.py +++ b/python/run demo/Wallet/TransferHistory.py @@ -0,0 +1,17 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "fromAccountType": "SPOT", + "toAccountType": "FUTURES", + # "startTime": "xxx", + # "endTime": "xxx", + # "page": "xxx", + # "size": "xxx" +} +TransferHistory = wallet.get_transfer_list(params) +print(TransferHistory) \ No newline at end of file diff --git a/python/run demo/Wallet/TransferHistoryById.py b/python/run demo/Wallet/TransferHistoryById.py index e69de29b..f4455649 100644 --- a/python/run demo/Wallet/TransferHistoryById.py +++ b/python/run demo/Wallet/TransferHistoryById.py @@ -0,0 +1,12 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "tranId": "xxx" +} +TransferHistory = wallet.get_transfer_list_byId(params) +print(TransferHistory) \ No newline at end of file diff --git a/python/run demo/Wallet/Withdraw.py b/python/run demo/Wallet/Withdraw.py index e69de29b..e1958ed3 100644 --- a/python/run demo/Wallet/Withdraw.py +++ b/python/run demo/Wallet/Withdraw.py @@ -0,0 +1,18 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "coin": "USDT", + "network": "Tron(TRC20)", + "address": "xxx", + "amount": "1000", + # "memo": "xxx", + # "withdrawOrderId": "xxx", + # "remark": "xxx", +} +Withdraw = wallet.post_withdraw(params) +print(Withdraw) \ No newline at end of file diff --git a/python/run demo/Wallet/WithdrawHistory.py b/python/run demo/Wallet/WithdrawHistory.py index e69de29b..f681fabc 100644 --- a/python/run demo/Wallet/WithdrawHistory.py +++ b/python/run demo/Wallet/WithdrawHistory.py @@ -0,0 +1,15 @@ +from python.spot import mexc_spot_v3 + + +wallet = mexc_spot_v3.mexc_wallet() + +# Enter parameters in JSON format in the "params", for example: {"symbol":"BTCUSDT", "limit":"200"} +# If there are no parameters, no need to send params +params = { + "coin": "USDT", + "limit": "10", + # "startTime": "xxx", + # "endTime": "xxx" +} +WithdrawHistory = wallet.get_withdraw_list(params) +print(WithdrawHistory) \ No newline at end of file diff --git a/python/spot/config.py b/python/spot/config.py index e69de29b..eb4a3818 100644 --- a/python/spot/config.py +++ b/python/spot/config.py @@ -0,0 +1,3 @@ +mexc_host = "https://api.mexc.com" +api_key = "your apikey" +secret_key = "your secretkey" diff --git a/python/spot/mexc_spot_v3.py b/python/spot/mexc_spot_v3.py index 1125466f..77a751b0 100644 --- a/python/spot/mexc_spot_v3.py +++ b/python/spot/mexc_spot_v3.py @@ -2,7 +2,7 @@ import hmac import hashlib from urllib.parse import urlencode, quote - +import config # ServerTime、Signature class TOOL(object): @@ -42,9 +42,9 @@ def sign_request(self, method, url, params=None): # Market Data class mexc_market(TOOL): - def __init__(self, mexc_hosts): + def __init__(self): self.api = '/api/v3' - self.hosts = mexc_hosts + self.hosts = config.mexc_host self.method = 'GET' def get_ping(self): @@ -129,11 +129,11 @@ def get_ETF_info(self, params=None): # Spot Trade class mexc_trade(TOOL): - def __init__(self, mexc_hosts, mexc_key, mexc_secret): + def __init__(self): self.api = '/api/v3' - self.hosts = mexc_hosts - self.mexc_key = mexc_key - self.mexc_secret = mexc_secret + self.hosts = config.mexc_host + self.mexc_key = config.api_key + self.mexc_secret = config.secret_key def get_selfSymbols(self): """get currency information""" @@ -230,21 +230,11 @@ def post_mxDeDuct(self, params): def get_mxDeDuct(self): """MX DeDuct status""" - method = 'POST' + method = 'GET' url = '{}{}'.format(self.api, '/mxDeduct/enable') response = self.sign_request(method, url) return response.json() - -# Spot Account -class mexc_account(TOOL): - - def __init__(self, mexc_hosts, mexc_key, mexc_secret): - self.api = '/api/v3' - self.hosts = mexc_hosts - self.mexc_key = mexc_key - self.mexc_secret = mexc_secret - def get_account_info(self): """get account information""" method = 'GET' @@ -253,14 +243,14 @@ def get_account_info(self): return response.json() -# Capital -class mexc_capital(TOOL): +# Wallet +class mexc_wallet(TOOL): - def __init__(self, mexc_hosts, mexc_key, mexc_secret): + def __init__(self): self.api = '/api/v3/capital' - self.hosts = mexc_hosts - self.mexc_key = mexc_key - self.mexc_secret = mexc_secret + self.hosts = config.mexc_host + self.mexc_key = config.api_key + self.mexc_secret = config.secret_key def get_coinlist(self): """get currency information""" @@ -378,11 +368,11 @@ def get_smallAssets_history(self, params=None): # Sub-Account class mexc_subaccount(TOOL): - def __init__(self, mexc_hosts, mexc_key, mexc_secret): + def __init__(self): self.api = '/api/v3' - self.hosts = mexc_hosts - self.mexc_key = mexc_key - self.mexc_secret = mexc_secret + self.hosts = config.mexc_host + self.mexc_key = config.api_key + self.mexc_secret = config.secret_key def post_virtualSubAccount(self, params): """create a sub-account""" @@ -437,11 +427,11 @@ def get_universalTransfer(self, params): # Rebate class mexc_rebate(TOOL): - def __init__(self, mexc_hosts, mexc_key, mexc_secret): + def __init__(self): self.api = '/api/v3/rebate' - self.hosts = mexc_hosts - self.mexc_key = mexc_key - self.mexc_secret = mexc_secret + self.hosts = config.mexc_host + self.mexc_key = config.api_key + self.mexc_secret = config.secret_key def get_taxQuery(self, params=None): """get the rebate commission record""" @@ -510,11 +500,11 @@ def get_affiliate_subaffiliates(self, params=None): # WebSocket ListenKey class mexc_listenkey(TOOL): - def __init__(self, mexc_hosts, mexc_key, mexc_secret): + def __init__(self): self.api = '/api/v3' - self.hosts = mexc_hosts - self.mexc_key = mexc_key - self.mexc_secret = mexc_secret + self.hosts = config.mexc_host + self.mexc_key = config.api_key + self.mexc_secret = config.secret_key def post_listenKey(self): """ generate ListenKey """ diff --git a/python/websocket/spotV2_websocket_python_demo.py b/python/websocket/spotV2_websocket_python_demo.py index 7ccefdb4..cd8e80bc 100644 --- a/python/websocket/spotV2_websocket_python_demo.py +++ b/python/websocket/spotV2_websocket_python_demo.py @@ -52,7 +52,6 @@ def on_open(ws): del params['api_secret'] params["sign"] = sign_data print(json.dumps(params)) - # time.sleep(2) ws.send(json.dumps(params)) diff --git a/python/websocket/spotV3_websocket_python_demo.py b/python/websocket/spotV3_websocket_python_demo.py index 4be06c82..c762253d 100644 --- a/python/websocket/spotV3_websocket_python_demo.py +++ b/python/websocket/spotV3_websocket_python_demo.py @@ -1,30 +1,9 @@ import json import websocket -from python.spot.v3 import mexc_spot_v3 import threading, time BASE_URL = 'wss://wbs.mexc.com/ws' -hosts = 'https://api.mexc.com' -mexc_key = "your apiKey" -mexc_secret = "your secretKey" -# listenKey = mexc_spot_v3.mexc_listenkey(mexc_key=mexc_key, mexc_secret=mexc_secret, mexc_hosts=hosts) - -""" 建立 ListenKey """ -""" generate ListenKey """ -#ListenKey = listenKey.post_listenKey()['listenKey'] - -""" 延長 ListenKey 有效期 """ -""" Extend ListenKey validity """ -# params = {'listenKey': ListenKey} -# print(listenKey.put_listenKey(params)) - -""" 刪除 ListneKey """ -""" Delete ListenKey """ -# params = {'listenKey': ListenKey} -# print(listenKey.delete_listenKey(params)) - -#BASE_URL = 'wss://wbs.mexc.com/ws' + '?listenKey=' + ListenKey def on_message(ws, message): print(message) From 8373da657ea38f0c87aa7a68ac8585e1de4538a0 Mon Sep 17 00:00:00 2001 From: EddieAPI Date: Fri, 11 Apr 2025 11:18:12 +0800 Subject: [PATCH 3/3] update python and C# demo --- python/run demo/Rebate/AffiliateCampaign.py | 0 python/run demo/Spot Trade/KYC_status.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 python/run demo/Rebate/AffiliateCampaign.py create mode 100644 python/run demo/Spot Trade/KYC_status.py diff --git a/python/run demo/Rebate/AffiliateCampaign.py b/python/run demo/Rebate/AffiliateCampaign.py new file mode 100644 index 00000000..e69de29b diff --git a/python/run demo/Spot Trade/KYC_status.py b/python/run demo/Spot Trade/KYC_status.py new file mode 100644 index 00000000..e69de29b