feat: dynamic market ticker watchlist (Markets page)

Add ability to add/remove custom tickers (e.g. EURCHF=X) on the
Markets & Prices page without editing config. Tickers are validated
via yfinance, persisted in market_watchlist SQLite table, merged into
the quotes feed as a 'custom' group, and shown in a dedicated tab
with per-card remove buttons.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OpenSquared
2026-06-22 21:54:58 +02:00
parent 78c60d5254
commit c3ea0b7f8c
5 changed files with 224 additions and 19 deletions

View File

@@ -91,6 +91,12 @@ def init_db():
# Regime / counter-scenario architecture
"ALTER TABLE custom_patterns ADD COLUMN regime_tag TEXT",
"ALTER TABLE custom_patterns ADD COLUMN counter_of TEXT",
# Markets & Prices — user-defined watchlist
"""CREATE TABLE IF NOT EXISTS market_watchlist (
ticker TEXT PRIMARY KEY,
name TEXT,
added_at TEXT DEFAULT (datetime('now'))
)""",
]:
try:
c.execute(_sql)
@@ -2307,6 +2313,42 @@ def remove_watchlist_ticker(ticker: str) -> bool:
return changed
# ── Market Watchlist (user-added tickers for Markets page) ───────────────────
def get_market_custom_tickers() -> List[Dict]:
conn = get_conn()
rows = conn.execute(
"SELECT ticker, name, added_at FROM market_watchlist ORDER BY added_at ASC"
).fetchall()
conn.close()
return [dict(r) for r in rows]
def add_market_custom_ticker(ticker: str, name: str = "") -> bool:
conn = get_conn()
try:
conn.execute(
"INSERT OR IGNORE INTO market_watchlist (ticker, name) VALUES (?, ?)",
(ticker.upper(), name),
)
inserted = conn.total_changes > 0
conn.commit()
except Exception:
inserted = False
finally:
conn.close()
return inserted
def remove_market_custom_ticker(ticker: str) -> bool:
conn = get_conn()
conn.execute("DELETE FROM market_watchlist WHERE ticker=?", (ticker.upper(),))
changed = conn.total_changes > 0
conn.commit()
conn.close()
return changed
# ── System Logs ───────────────────────────────────────────────────────────────
def log_system_event(