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

Binanse.US: start_kline_socket returns nothing for ???-USD pairs #733

Open Bob12345 opened 3 years ago

Bob12345 commented 3 years ago

Describe the bug I do get the historical klines but the interval updates are not working -- complete silence conn_key = bm.start_kline_socket(pair, process_message, interval=my_interval)

To Reproduce use "BNBUSD" as your pair, 1 minute interval conn_key = bm.start_kline_socket(pair, process_message, interval=my_interval)

Expected behavior I should be getting inteval klines as with all the non-USD pairs

Environment (please complete the following information):

Logs or Additional context no logs, no errors.

Thanks! P.S. I'm fully verified for trading by Binance.US and can trade -USD pairs on Binance.US manually. My non-USD pairs work with python-binance just fine.

Bob12345 commented 3 years ago

Let me put it this way: is anyone reading this able to trade USD on Binance.US using this API or any other API?

gitsmash commented 3 years ago

I am having similar issue as you, you won't find BNBUSD listed when querying ExchangeInfo, however you can find it via Binance web, I'm not sure why. I'm finding similar case with other *USD cryptos. I was also looking at Bitsgap and was able to connect Binance exchange via API integrations, and there they had no problem pulling that info from Binance via API, I dont know how

gitsmash commented 3 years ago

found solution, by default its using Binance.com exchange, if you want to use .us pass this to client: client = Client(api_key, api_secret, tld='us')

Bob12345 commented 3 years ago

found solution, by default its using Binance.com exchange, if you want to use .us pass this to client: client = Client(api_key, api_secret, tld='us')

I've been using tld='us' all along, because I only trade on .US now.

calebpitts commented 3 years ago

@gitsmash thank you sir. was getting api authentication issues for hours

Haakam21 commented 3 years ago

@Bob12345 I have the same issue and I have also been using tld='us'. Does anyone know if this is an issue with the python-binance client library or with the binance.us API?

Haakam21 commented 3 years ago

Alright, I found the solution to get sockets for USD pairs on binance.us:

client = Client(api_key, api_secret, tld='us')
socket_manager = BinanceSocketManager(client)
socket_manager.STREAM_URL = 'wss://stream.binance.us:9443/
...

I tried out a different binance python client (unicorn-binance-websocket-api) and saw that it was correctly returning USD pair sockets. So after looking at the source code for python-binance I realized that setting tld in the Client does not carry over to the BinanceSocketManager. So one must do it manually.

Bob12345 commented 3 years ago

Alright, I found the solution to get sockets for USD pairs on binance.us:

client = Client(api_key, api_secret, tld='us')
socket_manager = BinanceSocketManager(client)
socket_manager.STREAM_URL = 'wss://stream.binance.us:9443/
...

I tried out a different binance python client (unicorn-binance-websocket-api) and saw that it was correctly returning USD pair sockets. So after looking at the source code for python-binance I realized that setting tld in the Client does not carry over to the BinanceSocketManager. So one must do it manually.

Fantastic, that worked!!!! Thank you very much.