24 lines
582 B
Python
24 lines
582 B
Python
import os
|
|
import sqlite3
|
|
from fastapi import APIRouter
|
|
|
|
DB_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "arb.db")
|
|
|
|
router = APIRouter(prefix="/api", tags=["signals"])
|
|
|
|
|
|
def get_conn():
|
|
conn = sqlite3.connect(DB_PATH)
|
|
conn.row_factory = sqlite3.Row
|
|
return conn
|
|
|
|
|
|
@router.get("/signals/history")
|
|
def signals_history():
|
|
conn = get_conn()
|
|
rows = conn.execute(
|
|
"SELECT id, symbol, rate, annualized, sent_at, message FROM signal_logs ORDER BY id DESC LIMIT 50"
|
|
).fetchall()
|
|
conn.close()
|
|
return {"items": [dict(r) for r in rows]}
|