请告诉我如何获取开盘价、收盘价等。不要严格评判,我只是在学习。获得交易所MEXC Ticker。
import asyncio
import json
import websockets
async def mrlsv_ws():
url = 'wss://wbs.mexc.com/ws'
async with websockets.connect(url) as ws:
print('Connected')
subs = dict(
method = 'SUBSCRIPTION',
params = [
'[email protected]@BTCUSDT@Min30'
]
)
await ws.send(json.dumps(subs))
async for msg in ws:
msg = json.loads(msg)
symbol = msg.get('s')
print(symbol)
if __name__ == '__main__':
asyncio.run(mrlsv_ws())
回复:
{
'd': {
'e': '[email protected]',
'k': {
't': 1732906800,
'o': '97176',
'c': '97047.99',
'h': '97190.48',
'l': '96879.53',
'v': '75.0161855',
'a': '7276917.78',
'T': 1732908600,
'i': 'Min30'
}
},
'c': '[email protected]@BTCUSDT@Min30',
't': 1732908001686,
's': 'BTCUSDT'
}
如何得到 d->k->o