Spaces:
Running
Running
File size: 371 Bytes
a739560 3230292 a739560 | 1 2 3 4 5 6 7 8 9 10 | import ccxt
import pandas as pd
def fetch_ohlcv(symbol='BTC/USDT', timeframe='1h', limit=100):
exchange = ccxt.mexc()
ohlcv = exchange.fetch_ohlcv(symbol, timeframe=timeframe, limit=limit)
df = pd.DataFrame(ohlcv, columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
return df
|