fix: improve datetime for trade_list_to_dataframe

closes #12388
This commit is contained in:
Matthias
2025-10-15 19:36:06 +02:00
parent 642f24eba5
commit c878c673ab

View File

@@ -511,8 +511,8 @@ def trade_list_to_dataframe(trades: list[Trade] | list[LocalTrade]) -> pd.DataFr
"""
df = pd.DataFrame.from_records([t.to_json(True) for t in trades], columns=BT_DATA_COLUMNS)
if len(df) > 0:
df["close_date"] = pd.to_datetime(df["close_date"], utc=True)
df["open_date"] = pd.to_datetime(df["open_date"], utc=True)
df["close_date"] = pd.to_datetime(df["close_timestamp"], unit="ms", utc=True)
df["open_date"] = pd.to_datetime(df["open_timestamp"], unit="ms", utc=True)
df["close_rate"] = df["close_rate"].astype("float64")
return df