mirror of
https://github.com/aljazceru/hummingbot-dashboard.git
synced 2026-01-16 20:04:22 +01:00
(feat) add function to get the candles
This commit is contained in:
22
quants_lab/utils/data_management.py
Normal file
22
quants_lab/utils/data_management.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def get_dataframe(exchange: str, trading_pair: str, interval: str) -> pd.DataFrame:
|
||||
"""
|
||||
Get a dataframe of market data from the database.
|
||||
:param exchange: Exchange name
|
||||
:param trading_pair: Trading pair
|
||||
:param interval: Interval of the data
|
||||
:return: Dataframe of market data
|
||||
"""
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
data_dir = os.path.join(script_dir, "../../data/candles")
|
||||
filename = f"candles_{exchange}_{trading_pair.upper()}_{interval}.csv"
|
||||
file_path = os.path.join(data_dir, filename)
|
||||
if not os.path.exists(file_path):
|
||||
raise FileNotFoundError(f"File '{file_path}' does not exist.")
|
||||
df = pd.read_csv(file_path)
|
||||
df["timestamp"] = pd.to_datetime(df["timestamp"], unit="ms")
|
||||
return df
|
||||
Reference in New Issue
Block a user