Skip to content

Instantly share code, notes, and snippets.

@gmertk
Created May 24, 2025 10:27
Show Gist options
  • Save gmertk/e4cd5f0401aafb5eedbbaca115f9a8e5 to your computer and use it in GitHub Desktop.
Save gmertk/e4cd5f0401aafb5eedbbaca115f9a8e5 to your computer and use it in GitHub Desktop.
Loads ETHUSDT futures data on a 30-minute timeframe from Bybit by using vectorbt and CCXT.
exchange = "bybit"
symbol = 'ETHUSDT'
timeframe = "30 minutes"
data_file = f'{exchange}_{symbol.replace(":", "_")}_{timeframe.replace(" ", "_")}.h5'
# Check if the local file exists
if os.path.isfile(data_file):
print(f"Loading data from local file: {data_file}")
data = vbt.HDFData.pull(data_file)
else:
print(f"Local file not found. Fetching data...")
data = vbt.CCXTData.pull(
[symbol],
exchange=exchange,
timeframe=timeframe,
start="2020-10-21",
end="2025-05-18",
exchange_config={
'defaultType': 'future'
}
)
# Save the fetched data to local file
print(f"Saving data to local file: {data_file}")
data.to_hdf(data_file)
data.to_csv(data_file.replace('.h5', '.csv'))
print(data.stats())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment