From d461d6f8e86a508c1d006d1b06a64981cf9ffa07 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 5 Mar 2025 20:15:38 +0100 Subject: [PATCH] fix: spot data is in microseconds closes #11465 As announced in the documentation: https://github.com/binance/binance-public-data > Note: The timestamp for SPOT Data from January 1st 2025 onwards will be in microseconds. --- freqtrade/exchange/binance_public_data.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/freqtrade/exchange/binance_public_data.py b/freqtrade/exchange/binance_public_data.py index 48e022f2a..f61eb2a53 100644 --- a/freqtrade/exchange/binance_public_data.py +++ b/freqtrade/exchange/binance_public_data.py @@ -285,7 +285,11 @@ async def get_daily_ohlcv( names=["date", "open", "high", "low", "close", "volume"], header=header, ) - df["date"] = pd.to_datetime(df["date"], unit="ms", utc=True) + df["date"] = pd.to_datetime( + np.where(df["date"] > 1e13, df["date"] // 1000, df["date"]), + unit="ms", + utc=True, + ) return df elif resp.status == 404: logger.debug(f"Failed to download {url}") @@ -374,7 +378,7 @@ def parse_trades_from_zip(csvf): df.loc[:, "type"] = None # Convert timestamp to ms df.loc[:, "timestamp"] = np.where( - df["timestamp"] > 10000000000000, + df["timestamp"] > 1e13, df["timestamp"] // 1000, df["timestamp"], )