diff --git a/app/api/__pycache__/data.cpython-311.pyc b/app/api/__pycache__/data.cpython-311.pyc index 936ded1..c75b420 100644 Binary files a/app/api/__pycache__/data.cpython-311.pyc and b/app/api/__pycache__/data.cpython-311.pyc differ diff --git a/app/api/data.py b/app/api/data.py index 8aac69a..5d36ea1 100644 --- a/app/api/data.py +++ b/app/api/data.py @@ -52,10 +52,18 @@ def batch_fetch(req: BatchFetchRequest, db: Session = Depends(get_db)): cached = get_cached_data(db, sym, data_type, periods) timeframes = [] for p, candles in cached["timeframes"].items(): + # 转换数据格式: time -> datetime + normalized_candles = [] + for c in candles: + candle_dict = dict(c) + if 'time' in candle_dict and 'datetime' not in candle_dict: + candle_dict['datetime'] = candle_dict.pop('time') + normalized_candles.append(candle_dict) + timeframes.append(TimeframeData( period=p, - candles=[CandleItem(**c) for c in candles], - candle_count=len(candles), + candles=[CandleItem(**c) for c in normalized_candles], + candle_count=len(normalized_candles), fetched_at=cached.get("timestamp", ""), )) details[sym] = SymbolDataResponse( @@ -88,10 +96,18 @@ def batch_fetch(req: BatchFetchRequest, db: Session = Depends(get_db)): for p in periods: candles = all_timeframes.get(p, []) if candles: + # 转换数据格式: time -> datetime + normalized_candles = [] + for c in candles: + candle_dict = dict(c) + if 'time' in candle_dict and 'datetime' not in candle_dict: + candle_dict['datetime'] = candle_dict.pop('time') + normalized_candles.append(candle_dict) + timeframes.append(TimeframeData( period=p, - candles=[CandleItem(**c) for c in candles], - candle_count=len(candles), + candles=[CandleItem(**c) for c in normalized_candles], + candle_count=len(normalized_candles), fetched_at=result.get("timestamp", ""), )) diff --git a/data/buffer.db b/data/buffer.db index 20cccf0..44a2cab 100644 Binary files a/data/buffer.db and b/data/buffer.db differ