[英]Fetching the order depth with python-binance, but the code does not complete
我正在運行一個 python 腳本來獲取所有以 USDT 結尾的符號的所有當前訂單簿。
每當我嘗試運行它時,它都會獲取前三個符號的訂單簿(在本例中為 BTCUSDT、ETHUSDT 和 BNBUSDT)。 對我在這里搞砸的事情有任何看法嗎?
我正在使用此邏輯來獲取交易品種列表和訂單簿;
import asyncio
import config as c #from config.py
import infinity as inf #userdefined function for infinity (probably not needed)
from binance import AsyncClient, DepthCacheManager, Client
client = Client(c.API_KEY, c.API_SECRET, tld = 'com')
info = client.get_exchange_info()
symbols = info['symbols']
ls = []
for s in symbols:
if 'USDT' in s['symbol']:
#if 'BUSD' not in s['symbol']:
ls.append(s['symbol'])
async def main():
# initialise the client
client = await AsyncClient.create()
for i in ls:
async with DepthCacheManager(client, symbol= i, limit = 10000) as dcm_socket:
depth_cache = await dcm_socket.recv()
symbol = i
asks = depth_cache.get_asks()[:5]
bids = depth_cache.get_bids()[:5]
full = [symbol, asks, bids]
print(full)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
它不會完成,因為它不應該完成。 DepthCacheManager 旨在建立連接(WebSockets),獲取訂單信息的快照,然后訂閱當前未完成訂單的更新流,它在“DepthCache”中本地應用。 每次更新時,它都會提供更新后的當前要/出價集,如您所見。
交易和訂單從未停止,為什么會停止?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.