fix: add /api/signals/history endpoint

This commit is contained in:
root 2026-02-27 08:54:13 +00:00
parent ae1d1f18b3
commit 362c1f1e16

View File

@ -211,6 +211,22 @@ async def get_kline(symbol: str = "BTC", interval: str = "5m", limit: int = 500)
return {"symbol": symbol, "interval": interval, "count": len(data), "data": data} return {"symbol": symbol, "interval": interval, "count": len(data), "data": data}
@app.get("/api/signals/history")
async def get_signals_history(limit: int = 100):
"""查询信号推送历史"""
try:
conn = sqlite3.connect(DB_PATH)
conn.row_factory = sqlite3.Row
rows = conn.execute(
"SELECT id, symbol, rate, annualized, sent_at, message FROM signal_logs ORDER BY sent_at DESC LIMIT ?",
(limit,)
).fetchall()
conn.close()
return {"items": [dict(r) for r in rows]}
except Exception as e:
return {"items": [], "error": str(e)}
@app.get("/api/history") @app.get("/api/history")
async def get_history(): async def get_history():
cached = get_cache("history", 60) cached = get_cache("history", 60)