Signed-off-by: Dinger <quantdinger@gmail.com>
This commit is contained in:
Dinger
2026-04-07 22:47:07 +08:00
parent baa3182eca
commit 8563e4ea53
116 changed files with 3189 additions and 356 deletions
@@ -116,6 +116,7 @@ def load_addon_config() -> Dict[str, Any]:
('AKSHARE_TIMEOUT', 'akshare.timeout', 'int'),
('TIINGO_API_KEY', 'tiingo.api_key', 'string'),
('TIINGO_TIMEOUT', 'tiingo.timeout', 'int'),
('TWELVE_DATA_API_KEY', 'twelve_data.api_key', 'string'),
# Search (Google CSE / Bing)
('SEARCH_PROVIDER', 'search.provider', 'string'),
@@ -0,0 +1,29 @@
"""Persist strategy runtime lines for the strategy management UI (`qd_strategy_logs`)."""
from __future__ import annotations
from app.utils.db import get_db_connection
from app.utils.logger import get_logger
logger = get_logger(__name__)
def append_strategy_log(strategy_id: int, level: str, message: str) -> None:
"""Best-effort insert; never raises to caller."""
try:
sid = int(strategy_id)
lv = (level or "info").strip().lower()[:20]
msg = str(message or "").strip()
if not msg:
return
msg = msg[:8000]
with get_db_connection() as db:
cur = db.cursor()
cur.execute(
"INSERT INTO qd_strategy_logs (strategy_id, level, message) VALUES (?, ?, ?)",
(sid, lv, msg),
)
db.commit()
cur.close()
except Exception as e:
logger.debug("append_strategy_log skip: %s", e)