添加新的判断依据

This commit is contained in:
jackyu66git
2025-11-16 20:58:03 +08:00
parent 03c5148c29
commit d61cbbec21
8 changed files with 24 additions and 76 deletions
+5 -5
View File
@@ -29,10 +29,10 @@ TIMEFRAME_TO_MS: Dict[str, int] = {
"1w": 604_800_000,
}
DERIVED_TIMEFRAME_PLAN: Dict[str, List[str]] = {
"1m": ["2m", "3m", "4m", "5m", "10m", "15m", "20m", "25m", "30m"],
"1h": ["2h", "3h", "4h", "6h", "8h", "12h", "16h"],
"1m": ["2m", "3m", "4m", "5m", "10m", "15m", "20m", "25m", "30m", "45m"],
"1h": ["2h", "3h", "4h", "6h", "8h", "12h", "16h", "20h"],
"1d": ["2d", "3d", "4d", "5d", "6d"],
"1w": ["2w"],
"1w": ["2w", "3w"],
}
CSV_FIELDNAMES = ["timestamp", "datetime", "open", "high", "low", "close", "volume"]
DEFAULT_LIMIT = 500
@@ -583,14 +583,14 @@ class DataProvider:
resampled_df = resampled.copy()
if "date" in resampled_df.columns:
dates = pd.to_datetime(resampled_df["date"], utc=True, errors="coerce")
resampled_df["timestamp"] = (dates.view("int64") // 1_000_000).astype("int64")
resampled_df["timestamp"] = (dates.astype("int64", copy=False) // 1_000_000).astype("int64")
elif isinstance(resampled_df.index, pd.DatetimeIndex):
idx = resampled_df.index
if idx.tz is None:
idx = idx.tz_localize("UTC")
else:
idx = idx.tz_convert("UTC")
resampled_df["timestamp"] = (idx.view("int64") // 1_000_000).astype("int64")
resampled_df["timestamp"] = (idx.astype("int64", copy=False) // 1_000_000).astype("int64")
else:
raise HTTPException(status_code=500, detail=f"聚合结果缺少 timestamp 列 ({timeframe})")
resampled_df = resampled_df.dropna(subset=["timestamp"]).sort_values("timestamp")