python-binance
python-binance copied to clipboard
Fixed threaded stream and futures user socket
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)