sammchardy / python-kucoin

Kucoin REST and Websocket API python implementation
https://python-kucoin.readthedocs.io/en/latest/
MIT License
350 stars 148 forks source link

get_kline_data always returns candles from 1970 even with correct unix date parameters given #79

Closed IanFLee closed 3 years ago

IanFLee commented 3 years ago

klines = client.get_kline_data(self.coin, kline_type=self.interval, start=1613096100)

this should return data starting feb 11 of 2021, but i'm always getting unix 0 dates (jan 19, 1970)

is anyone else having this problem or understand why i'm getting this issue?

also, the python-binance wrapper converts timestamps from strings like "1 week ago UTC" and I love it. it would be great if we could get that functionality here as well.

laradave commented 3 years ago

Are you dividing by 1000? You shouldn't

IanFLee commented 3 years ago

No, I'm not dividing by 1000. My code looks like this:

for kline in klines:

                date = kline[0]
                int_date = int(date)
                y = datetime.datetime.fromtimestamp(int_date)
                z = y.isoformat()
               candle = { 'datetime':z, 'open':float(kline[1]), 'high':float(kline[3]), 'low':float(kline[4]),
                          'close':float(kline[2]), 'volume':float(kline[6]) }
laradave commented 3 years ago

What does y show if you print it out? That's exactly how I do it to get to a python datetime type, and it's exactly as it should be. Is something going wrong with z?

IanFLee commented 3 years ago

I'm not sure what the issue is here. My code block didn't change but now I'm getting correct values. Closing this issue.