python-binance icon indicating copy to clipboard operation
python-binance copied to clipboard

Fixed threaded stream and futures user socket

Open casper-hansen opened this issue 3 years ago • 0 comments

Fix #1200 and #1174 with Python 3.8.13

The stream does not work anymore with the standard code presented. We have to change the threading approach to run it successfully. Additionally, we should also be able to use the testnet for the futures stream in combination with the threaded approach, so that has also been fixed. @sammchardy

Minimal testing example:

import time
from binance.streams import ThreadedWebsocketManager

def handler(order_data):
    print(order_data)

manager = ThreadedWebsocketManager(
    API_KEY, 
    API_SECRET, 
    testnet=True
)

manager.daemon = True # ctrl-c works
manager.start()
manager.start_futures_user_socket(handler)

while True:
    # run your other code here
    time.sleep(0.1)

casper-hansen avatar Aug 14 '22 19:08 casper-hansen