klines = client.get_historical_klines(sym, Client.KLINE_INTERVAL_1HOUR, '10 hour ago UTC', 'now UTC')
raises:
BinanceAPIException: APIError(code=-1100): Illegal characters found in parameter 'endTime'; legal range is '^[0-9]{1,20}$'.
And the error is the same no matter how I change start_time and end_time strings.
Yeah, I got the same error this morning. The reason I believe is because python-binance is sending endTime as None in Client.get_klines(), so binance thinks endTime parameter exists on the request and validates the None values against its regex. I believe this pull request addresses this, it strips the None from the parameters so that it doesn't trigger validation from binance's api server.
Related to this. #417
I have confirmed that the PR fixes the issue.
https://github.com/sammchardy/python-binance/pull/415
Same problem here.
If somebody got here looking for a fix:
I encountered the same issue today. I downgraded from 0.7.3 to 0.7.2 and it fixed it.
i downgrade from 0.7.3 to 0.7.2 but it is not working yet...
downgrade python-binance from 0.7.3 to 0.7.2 and restart your kernel. it worked for me.
It is possible fix it:
In the file: client.py, on line 733, change:
kline = self.get_klines(
symbol=symbol,
interval=interval,
limit=1,
startTime=0,
endTime=None
)
to:
kline = self.get_klines(
symbol=symbol,
interval=interval,
limit=1,
startTime=0
)
Obs: Remove the "endTime" property
It is possible fix it:
In the file: client.py, on line 733, change:
kline = self.get_klines(
symbol=symbol,
interval=interval,
limit=1,
startTime=0,
endTime=None
)
to:
kline = self.get_klines(
symbol=symbol,
interval=interval,
limit=1,
startTime=0
)Obs: Remove the "endTime" property
This worked for me.
In my case im interested in getting Kline data with endTime now, so here's a fix:
def _get_earliest_valid_timestamp(self, symbol, interval):
"""Get earliest valid open timestamp from Binance
:param symbol: Name of symbol pair e.g BNBBTC
:type symbol: str
:param interval: Binance Kline interval
:type interval: str
:return: first valid timestamp
"""
kline = self.get_klines(
symbol=symbol,
interval=interval,
limit=1,
startTime=0,
endTime=int(round(time.time() * 1000)) <---------------------------------------
)
return kline[0][0]
Have pushed python-binance v0.7.4 with this PR
anyone have found the solution ???
Most helpful comment
If somebody got here looking for a fix:
I encountered the same issue today. I downgraded from 0.7.3 to 0.7.2 and it fixed it.