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.
This commit is contained in:
Matthias
2025-03-05 20:15:38 +01:00
parent 53f68a3834
commit d461d6f8e8

View File

@@ -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"],
)