mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-09 16:28:06 +00:00
docs: 更新 lighter-python-main 文档,添加示例代码和 API 说明,重构部分内容以提高可读性
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import json
|
||||
import logging
|
||||
import asyncio
|
||||
import lighter
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
def on_order_book_update(market_id, order_book):
|
||||
logging.info(f"Order book {market_id}:\n{json.dumps(order_book, indent=2)}")
|
||||
|
||||
|
||||
def on_account_update(account_id, account):
|
||||
logging.info(f"Account {account_id}:\n{json.dumps(account, indent=2)}")
|
||||
|
||||
|
||||
client = lighter.WsClient(
|
||||
order_book_ids=[0, 1],
|
||||
account_ids=[1, 2],
|
||||
on_order_book_update=on_order_book_update,
|
||||
on_account_update=on_account_update,
|
||||
)
|
||||
|
||||
asyncio.run(client.run_async())
|
||||
Reference in New Issue
Block a user