sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
5.91k stars 2.19k forks source link

How to perform asynchronous futures Depth Cache? #1283

Open 1163849662 opened 1 year ago

1163849662 commented 1 year ago

image My code doesn't have any output, can you give a correct example thanks

from binance import ThreadedWebsocketManager

def main(): dcm = ThreadedWebsocketManager()

start is required to initialise its internal loop

dcm.start()

def handle_depth_cache(depth_cache):
    print(f"symbol {depth_cache.symbol}")
    print("top 5 bids")
    print(depth_cache.get_bids()[:5])
    print("top 5 asks")
    print(depth_cache.get_asks()[:5])
    print("last update time {}".format(depth_cache.update_time))

dcm_name = dcm.start_futures_depth_socket(handle_depth_cache, symbol='BNBBTC')

dcm.join()

if name == "main": main()

Mrfranken commented 1 year ago

what is depth cache, could u explain what it aimed for?