添加本地文件
This commit is contained in:
29
bitmart/test_api.py
Normal file
29
bitmart/test_api.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""测试 BitMart API K线获取"""
|
||||
import time
|
||||
from bitmart.api_contract import APIContract
|
||||
|
||||
api_key = "a0fb7b98464fd9bcce67e7c519d58ec10d0c38a8"
|
||||
secret_key = "4eaeba78e77aeaab1c2027f846a276d164f264a44c2c1bb1c5f3be50c8de1ca5"
|
||||
memo = "数据抓取"
|
||||
|
||||
contractAPI = APIContract(api_key, secret_key, memo, timeout=(5, 15))
|
||||
|
||||
# 测试获取最近1小时的15分钟K线
|
||||
end_time = int(time.time())
|
||||
start_time = end_time - 3600 # 1小时前
|
||||
|
||||
print(f"当前时间戳: {end_time}")
|
||||
print(f"开始时间戳: {start_time}")
|
||||
print(f"当前时间: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))}")
|
||||
print(f"开始时间: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))}")
|
||||
|
||||
try:
|
||||
response = contractAPI.get_kline(
|
||||
contract_symbol="ETHUSDT",
|
||||
step=15,
|
||||
start_time=start_time,
|
||||
end_time=end_time
|
||||
)
|
||||
print(f"\n响应: {response}")
|
||||
except Exception as e:
|
||||
print(f"\n错误: {e}")
|
||||
Reference in New Issue
Block a user