LUCIT-Systems-and-Development / unicorn-binance-rest-api

A Python SDK by LUCIT to use the Binance REST API`s (com+testnet, com-margin+testnet, com-isolated_margin+testnet, com-futures+testnet, us, tr) in a simple, fast, flexible, robust and fully-featured way.
https://unicorn-binance-rest-api.docs.lucit.tech
Other
60 stars 17 forks source link

Binance Future Testnet URLs are wrong #20

Closed Animouse31 closed 2 years ago

Animouse31 commented 2 years ago

Hi Oliver!

Thank you for the wonderful module, I love it very much.

I want to report a bug for the Futures Testnet URLs.

It takes me some time to figure out the problem, even contacting Binance customer service. It turns out the URLs for Binance Futures Testnet in the manager.py are wrong.

Here's the code:

elif self.exchange == "binance.com-futures-testnet":

Todo: Needs a test

self.API_URL = "https://testnet.binance.vision/api" self.MARGIN_API_URL = " https://api.binance.com/sapi" self.WEBSITE_URL = "https://testnet.binance.vision/" self.FUTURES_URL = "https://fapi.binance.com/fapi" self.FUTURES_DATA_URL = "https://fapi.binance.com/futures/data" self.FUTURES_COIN_URL = "https://fapi.binance.com/fapi" self.FUTURES_COIN_DATA_URL = "https://dapi.binance.com/futures/data"

It uses Binance Spot Testnet URLs instead of Binance Futures Testnet URLs. For the Binance Futures Testnet URLs, it's supposed to be: "https://testnet.binancefuture.com/fapi"

testnet.binancefutures.com instead of testnet.binance.vision

As shown in the documentation: https://python-binance.readthedocs.io/en/latest/binance.html

image

oliver-zehentleitner commented 2 years ago

There was a couple of URLs to adopt:

self.FUTURES_URL = "https://testnet.binancefuture.com/fapi"
self.FUTURES_DATA_URL = "https://testnet.binancefuture.com/futures/data"
self.FUTURES_COIN_URL = "https://testnet.binancefuture.com/dapi"
self.FUTURES_COIN_DATA_URL = "https://testnet.binancefuture.com/futures/data"
oliver-zehentleitner commented 2 years ago

Hi Animouse!

Thanks for reporting this. I tried to fix it, but was not able to test it.

A confirmation would be appreciated!

https://github.com/LUCIT-Systems-and-Development/unicorn-binance-rest-api/releases/tag/1.4.1

Best regards!

Animouse31 commented 2 years ago

Thank you for the fix!

Sorry for the late reading the post for 3 days.

Gonna check it, write the code, and will give you the result tomorrow.

Animouse31 commented 2 years ago

Tested and everything is working well!

Amazing!

I tested with all requests needed on my bot, and all of them are working well.

From the futures_klines, margin mode, leverage, account info, up to create order.

Thank you for the fix!

You are awesome!

Animouse31 commented 2 years ago

I notice, it seems Unicorn Rest API is faster than the other Rest APIs.

I try to download all futures klines, and the result was finished almost immediately.

The download speed is 5.13it/s which is 2-3 times faster.

Tested on several PCs and connections, all of them show similar behavior.

It's also very responsive, this is super amazing!

Animouse31 commented 2 years ago

I found a problem.

If you request multiple symbols in a loop, the future_klines skips several klines if you download big historical klines like 200-1000 minutes ago (aka 200-1000 lengths for indicator).

But it's not all, just in several symbols randomly.

The longer the length or historical klines, the more symbols are skipped.

oliver-zehentleitner commented 2 years ago

thanks for the feedback!

sure you have no race condition?

please open a new issue if you have more data about this issue!

best regards!