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

BinanceAPIException when using coin-m futures get_historical_klines #1265

Open dignitas123 opened 1 year ago

dignitas123 commented 1 year ago

Describe the bug Using COIN-M methods (using python-binance) is causing weird erros. Analogous USD-M with same parameters are working fine.

To Reproduce This works:

client.get_historical_klines( symbol="SOLBUSD", interval="1m", start_str="2022-09-27 11:54:17.480347+00:00", end_str="2022-09-27 13:54:17.480347+00:00", klines_type=HistoricalKlinesType.FUTURES, ) This throws error BinanceAPIException: APIError(code=-4088): Maximum time interval is 200 days.

client.get_historical_klines( symbol="SOLUSD_PERP", interval="1m", start_str="2022-09-27 11:54:17.480347+00:00", end_str="2022-09-27 12:54:17.480347+00:00", klines_type=HistoricalKlinesType.FUTURES_COIN, )

Expected behavior Don't throw error, get candlestick array.

Environment (please complete the following information):

halfelf commented 1 year ago

Bug confirmed.

Well, I have to say, since get_historical_klines() is not directly mapped into a binance API as most methods in this library do, it is buggy and has been reported several times, causing lots of trouble.

And here's why only coin futures method has this bug:

I'll try to fix this, no promise though.

Meanwhile, if you know what you're doing, I strongly suggest fetching klines directly by:

These methods are directly mapped to one corresponding binance API and will do nothing else.

halfelf commented 1 year ago

To anyone who concerns: