sammchardy / python-binance

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

The limit parameter setting of ThreadedDepthCacheManager.start_futures_depth_socket don't work #1210

Open yclsl opened 2 years ago

yclsl commented 2 years ago

Describe the bug The limit parameter setting is invalid, no matter how I set the limit, the returned bid and ask lengths are 10.

To Reproduce

from binance.depthcache import DepthCache
from binance import ThreadedDepthCacheManager

api_key = 'XX'
api_secret = 'XX'

def main():

    dcm = ThreadedDepthCacheManager(api_key=api_key, api_secret=api_secret)
    # start is required to initialise its internal loop
    dcm.start()

    def handle_depth_cache(depth_cache: DepthCache):
        print("type(depth_cache) =", type(depth_cache))
        print(f"symbol {depth_cache.symbol}")
        print("size of bids = {}".format(len(depth_cache.get_bids())))
        print(depth_cache.get_bids()[:len(depth_cache.get_bids())])
        print("size of asks = {}".format(len(depth_cache.get_asks())))
        print(depth_cache.get_asks()[:len(depth_cache.get_asks())])
        print("last update time {}".format(depth_cache.update_time))

    dcm_name = dcm.start_futures_depth_socket(handle_depth_cache, symbol='BTCUSDT', limit=50)
    dcm.join()

if __name__ == "__main__":
   main()

Expected behavior I expect both bid and ask lengths to be returned to be 50.

Environment (please complete the following information):