|
|
@@ -422,27 +422,27 @@ if __name__ == '__main__':
|
|
|
print(f"初始化过程中发生意外错误: {e}")
|
|
|
exit()
|
|
|
|
|
|
- print("\n--- 测试公共接口 ---")
|
|
|
- try:
|
|
|
- print("Ping 服务器...")
|
|
|
- ping_response = client.market.get_ping()
|
|
|
- print(f"Ping 响应: {ping_response}")
|
|
|
-
|
|
|
- print("\n获取服务器时间...")
|
|
|
- time_response = client.market.get_timestamp()
|
|
|
- print(f"服务器时间响应: {time_response}")
|
|
|
- if isinstance(time_response, dict) and 'serverTime' in time_response:
|
|
|
- print(f"服务器时间: {time_response['serverTime']}")
|
|
|
+ # print("\n--- 测试公共接口 ---")
|
|
|
+ # try:
|
|
|
+ # print("Ping 服务器...")
|
|
|
+ # ping_response = client.market.get_ping()
|
|
|
+ # print(f"Ping 响应: {ping_response}")
|
|
|
+
|
|
|
+ # print("\n获取服务器时间...")
|
|
|
+ # time_response = client.market.get_timestamp()
|
|
|
+ # print(f"服务器时间响应: {time_response}")
|
|
|
+ # if isinstance(time_response, dict) and 'serverTime' in time_response:
|
|
|
+ # print(f"服务器时间: {time_response['serverTime']}")
|
|
|
|
|
|
- print("\n获取 BTCUSDT Ticker 价格...") # get_price 示例
|
|
|
- price_response = client.market.get_price(params={"symbol": "BTCUSDT"})
|
|
|
- print(f"BTCUSDT 价格响应: {price_response}")
|
|
|
+ # print("\n获取 BTCUSDT Ticker 价格...") # get_price 示例
|
|
|
+ # price_response = client.market.get_price(params={"symbol": "BTCUSDT"})
|
|
|
+ # print(f"BTCUSDT 价格响应: {price_response}")
|
|
|
|
|
|
|
|
|
- except requests.exceptions.RequestException as e:
|
|
|
- print(f" 公共 API 请求期间出错: {e}")
|
|
|
- except Exception as e:
|
|
|
- print(f" 发生意外错误: {e}")
|
|
|
+ # except requests.exceptions.RequestException as e:
|
|
|
+ # print(f" 公共 API 请求期间出错: {e}")
|
|
|
+ # except Exception as e:
|
|
|
+ # print(f" 发生意外错误: {e}")
|
|
|
|
|
|
|
|
|
print("\n--- 测试私有接口 (需要 API Key 和 Secret) ---")
|
|
|
@@ -450,18 +450,38 @@ if __name__ == '__main__':
|
|
|
print(" 在环境变量中未找到 API Key 或 Secret。跳过私有接口测试。")
|
|
|
else:
|
|
|
try:
|
|
|
- print("获取账户信息...")
|
|
|
+ # print("获取账户信息...")
|
|
|
account_info = client.trade.get_account_info()
|
|
|
- print("账户信息:")
|
|
|
- # 打印敏感数据时请小心。测试时,显示有限信息或结构。
|
|
|
- if isinstance(account_info, dict):
|
|
|
- print(f" 是否可以交易: {account_info.get('canTrade')}")
|
|
|
- print(f" 是否可以提现: {account_info.get('canWithdraw')}")
|
|
|
- print(f" 账户类型: {account_info.get('accountType')}")
|
|
|
- # print(json.dumps(account_info, indent=2, ensure_ascii=False)) # 取消注释以查看完整响应
|
|
|
- else:
|
|
|
- print(f" 意外的响应格式: {account_info}")
|
|
|
- print(account_info)
|
|
|
+ # # print("账户信息:")
|
|
|
+ # # # 打印敏感数据时请小心。测试时,显示有限信息或结构。
|
|
|
+ # # if isinstance(account_info, dict):
|
|
|
+ # # print(f" 是否可以交易: {account_info.get('canTrade')}")
|
|
|
+ # # print(f" 是否可以提现: {account_info.get('canWithdraw')}")
|
|
|
+ # # print(f" 账户类型: {account_info.get('accountType')}")
|
|
|
+ # # # print(json.dumps(account_info, indent=2, ensure_ascii=False)) # 取消注释以查看完整响应
|
|
|
+ # # else:
|
|
|
+ # # print(f" 意外的响应格式: {account_info}")
|
|
|
+ import time
|
|
|
+ import logging
|
|
|
+ # 配置日志
|
|
|
+ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
+
|
|
|
+ while True:
|
|
|
+ logging.info(account_info['balances'][0])
|
|
|
+ logging.info(client.wallet.get_deposit_list()[0])
|
|
|
+ logging.info('')
|
|
|
+
|
|
|
+ time.sleep(1)
|
|
|
+
|
|
|
+
|
|
|
+ # params = {
|
|
|
+ # 'coin': 'RATO',
|
|
|
+ # 'netWork': 'ETH',
|
|
|
+ # }
|
|
|
+ # # print(client.wallet.post_deposit_address(params))
|
|
|
+ # for deposit in client.wallet.get_deposit_address(params):
|
|
|
+ # if deposit['netWork'] == 'ETH':
|
|
|
+ # print(deposit)
|
|
|
|
|
|
|
|
|
# print("\n测试下单 (POST /order/test)...")
|
|
|
@@ -517,12 +537,10 @@ if __name__ == '__main__':
|
|
|
# else:
|
|
|
# print(f" 挂单响应: {open_orders}")
|
|
|
|
|
|
- coin_list = client.wallet.get_coinlist()
|
|
|
-
|
|
|
+ # coin_list = client.wallet.get_coinlist()
|
|
|
# for coin in coin_list:
|
|
|
# if 'USDT' in coin['coin']:
|
|
|
# networklist = coin['networkList']
|
|
|
-
|
|
|
# for network in networklist:
|
|
|
# print(network)
|
|
|
'''
|
|
|
@@ -546,21 +564,21 @@ if __name__ == '__main__':
|
|
|
}
|
|
|
'''
|
|
|
|
|
|
- print("\n提币测试...")
|
|
|
- withdraw_params = {
|
|
|
- 'coin': 'USDT',
|
|
|
- 'netWork': 'ETH',
|
|
|
- 'address': '0xb1f33026db86a86372493a3b124d7123e9045bb4',
|
|
|
- 'amount': 10
|
|
|
- }
|
|
|
- withdraw_rst = client.wallet.post_withdraw(withdraw_params)
|
|
|
- print(f" 提笔响应:{withdraw_rst}")
|
|
|
+ # print("\n提币测试...")
|
|
|
+ # withdraw_params = {
|
|
|
+ # 'coin': 'USDT',
|
|
|
+ # 'netWork': 'ETH',
|
|
|
+ # 'address': '0xb1f33026db86a86372493a3b124d7123e9045bb4',
|
|
|
+ # 'amount': 10
|
|
|
+ # }
|
|
|
+ # withdraw_rst = client.wallet.post_withdraw(withdraw_params)
|
|
|
+ # print(f" 提笔响应:{withdraw_rst}")
|
|
|
|
|
|
|
|
|
- print("\n获取提币历史信息...")
|
|
|
- withdraw_list = client.wallet.get_withdraw_list()
|
|
|
- print("历史信息:")
|
|
|
- print(f" {withdraw_list}")
|
|
|
+ # print("\n获取提币历史信息...")
|
|
|
+ # withdraw_list = client.wallet.get_withdraw_list()
|
|
|
+ # print("历史信息:")
|
|
|
+ # print(f" {withdraw_list}")
|
|
|
except requests.exceptions.RequestException as e:
|
|
|
print(f" 私有 API 请求期间出错: {e}")
|
|
|
if e.response is not None:
|