Merge branch 'main' of https://github.com/brokermr810/QuantDinger
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user