0

I'm running this Python code to get historical candlestick data from the Binance API:

from binance.client import Client

api_key = "my api key"
api_secret = "my secret key"

client = Client(api_key, api_secret)

klines = client.get_historical_klines("BTCUSDT", Client.KLINE_INTERVAL_1MINUTE, "1 Hour ago")

print(klines)

and it gets data going up to one hour ago. By default it's set on the UTC time zone, but since my systems time zone is UTC+1, it doesn't work, and I get this error:

ValueError: Timezone offset does not match system offset: -25200 != -28800. Please, check your config files.

so instead of using "1 Hour ago", I use "1 Hour ago UTC+1" which works... but it doesn't get the data of the last hour (which is the data I need), I figured it was somehow because of the 1 hour offset between UTC and UTC+1, and one solution would be to change my Computers timezone to UTC, but I don't want to do that.

So... I really don't know what to do, I've searched about this issue online, but I've found no solutions, Stack Overflow is my last hope.

Edit: just tried changing my systems timezone to see if it would make any difference, but it doesn't.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
JÄGER
  • 9
  • 1
  • 4
  • Looks more like a problem with the api. You may want to check if there is a way to set the timezone in the client. – monkut Apr 03 '20 at 01:48
  • Does this answer help you? https://stackoverflow.com/questions/7065164/how-to-make-an-unaware-datetime-timezone-aware-in-python – Oliver May 02 '20 at 10:07
  • @Oliver Thank you for your help, but I've already solved my issue by changing my systems timezone, I initially didn't want to do that, but since I had no other options, I did it anyway. I'll still try your suggestion to see if it solves that issue ... – JÄGER May 02 '20 at 12:23

0 Answers0