I'm trying to get some historical data on crypto pairs via the binace api. I tried a tutorial i found online. This is my code:
# valid intervals - 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M
# get timestamp of earliest date data is available
timestamp = client._get_earliest_valid_timestamp('BTCUSDT', '1M')
print(timestamp)
timestamp1 = datetime.fromtimestamp(int(timestamp)/1000)
print(timestamp1)
# request historical candle (or klines) data
bars = client.get_historical_klines('BTCUSDT', '1h', timestamp, limit=1000)
print(bars)
btc_df = pd.DataFrame(bars)
print(btc_df.head())
The output i get for timestamp1 is 2022-01-01 01:00:00. That's 15 days ago. Is there anything i'm doing wrong? I assumed the timestamp would be going back 2 years or something.
Thanks!
I got here from this link : Compute Date out of Timestamp from Binance-API (Python)