天择量化公共接口文档
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

29 lines
1.1 KiB

import asyncio
import websockets
import json
# WebSocket URI
# URI: ws://192.168.34.9:8765
# 请求参数
# 平台 (platform): 指定交易平台的名称,gate_spot/gate_swap_u/binance_spot/binance_swap_u/bybit_spot/bybit_swap_u/okx_spot/okx_swap_u
# 基础货币 (base): 交易对中的基础货币,如 btc。
# 结算货币 (settle): 交易对中的结算货币,如 usdt。
# 开始时间 (start_data): 数据请求的开始时间(格式应为 YYYY-MM-DD-HH,但注意您代码中写的是 start_data 可能是 start_date 的笔误)。
# 结束时间 (end_data): 数据请求的结束时间(同上,格式应为 YYYY-MM-DD-HH,且可能应为 end_date)。
async def connect_to_server():
uri = "ws://192.168.34.9:8765"
async with websockets.connect(uri) as websocket:
msg = {'platform': 'gate_spot', 'base': 'btc', "settle": "usdt", "start_data": "2024-08-13-18",
"end_data": "2024-08-13-18"}
await websocket.send(f"{json.dumps(msg)}")
while True:
response = await websocket.recv()
print(json.loads(response))
if __name__ == "__main__":
asyncio.run(connect_to_server())