CCXT fetch_ohlcv - impossible to get latest values

380 Views Asked by At

I'm trying to write a Python bot (using CCXT Library and Exchange: Bitget), but I cannot get latest values of ETH/USDT. It seems I have a delay of couple hours.

I'm using the Library CCTX with the following code:

bars = bitget.fetch_ohlcv('ETH/USDT', timeframe='1m', since=startDate, limit=1000)

What can't I retrive the current values but I got values updated 2 hours ago?

1

There are 1 best solutions below

1
Phablo On
def dowloadPrice():
# below the code run at 08:19 PM
import datetime
import ccxt
import pandas as pd
import time
from datetime import datetime
symbol = "ETH/USDT"
startDate = "2023-04-23 17:00:00+00:00"
startDate = datetime.strptime(startDate, "%Y-%m-%d %H:%M:%S%z")
startDate = datetime.timestamp(startDate)
startDate = int(startDate) * 1000
bars = bitget.fetch_ohlcv(symbol, timeframe='1m', since=startDate, limit=1000)
df = pd.DataFrame(bars[:-1], columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
print(df)