fix: 修复api接口访问问题

master
Lxy 2 weeks ago
parent 778a713591
commit 6e040618cc

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

Binary file not shown.
Loading…
Cancel
Save