sammchardy / python-binance

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

User_socket with ThreadedWebsocketManager not working #1239

Closed spackooo closed 2 years ago

spackooo commented 2 years ago

Hey, I want to get info on User Data for my Spot Account in form of a stream. If i use twm.start_user_socket i get an error message that my API-key format is invalid (APIError(code=-2014): API-key format invalid). But every other command through that same API works as intended, for example asset balance and also a TWM Stream for BTCBUSD. This is on a TestNet Account, i didn't test it on a real account.

Is there any way to fix this or is this a TestNet issue?

To Reproduce api_key = os.environ.get('binance_api') api_secret = os.environ.get('binance_secret') client = Client(api_key, api_secret, testnet=True) twm = ThreadedWebsocketManager() def main():

def handle_socket_message(msg):
    print(f"message type: {msg['e']}")
    print(msg)

twm.start()
twm.start_user_socket(callback=handle_socket_message)
twm.join()
twm.stop()

Expected behavior TWM Stream for Spot Account User Data will start working

Environment (please complete the following information):

Logs or Additional context Task exception was never retrieved future: <Task finished name='Task-5' coro=<ThreadedApiManager.start_listener() done, defined at . . . . . . binance.exceptions.BinanceAPIException: APIError(code=-2014): API-key format invalid.