Skip to content

feat(signal): per-ticker 3-factor early-outlier detector #3

Description

@leehao921

Motivation

2026-04 聯發科 (+100%) 與 4985 臻鼎-KY (+100%) 的拉升若能在 2-3 日前看到「資金流 + 新聞密度 + 題材熱度」同時異常,就能提前佈局。目前平台只有事後分析,無事前訊號層。

Proposed signal (3 independent factors, 2-of-3 trigger)

  1. 資金流 z-score — 近 5 日 (外資 + 投信) 累計買超,相對過去 60 日 5d-rolling-sum 分布的 z。|z| ≥ 2.0 觸發。
  2. 新聞密度 z-score — 近 7 日 news_items 中該 ticker 出現次數,相對過去 90 日基準的 z。z ≥ +2.0 觸發 (只取上尾)。
  3. Wikilink 共現熱度 — 近 7 日 news_items 中與該 ticker 同時出現的 distinct [[wikilink]] 數。>= 5 觸發。

任一 ticker 2/3 因子同時觸發 → 寫入 signal_alerts 表 + 當日 markdown 摘要 (analysis/signals/YYYY-MM-DD.md),並 upsert 到 news_items (source='ticker_signal') 讓 MCP/Claude.ai 查得到。

Design

完整計畫見 docs/plans/2026-05-05-signal-layer.md。摘要:

  • 新表: `signal_alerts (trade_date, ticker, flow_z, news_z, wikilink_heat, factors_hit, composite, details JSONB)` — migration 004。
  • 新模組: `ingestion/snapshots/ticker_signal.py` (參照現有 `overnight_signal.py` 與 `tpu.py` 的 builder pattern)。
  • Cron: `0 17 * * 1-5` Asia/Taipei,盤後 30 分;institutional_stock 應已 ingest 完。
  • Reuse: `scripts/verify_flow_zscore.py` 的 z-score 公式 (single source of truth) + `mcp_server/tools/market.py` 的 trading-timescaledb 連線。

Acceptance criteria

  • migration 004 applies cleanly
  • `compute_factors('4985')` 在 2026-04 末區間計算結果出現 `factors_hit >= 2`
  • `ticker_signal_daily` 排程在 scheduler container 載入
  • backtest 2024-01 → 2026-03 alert ≥ 50 次,10d hit rate ≥ 55% (低於則 tune thresholds 再 promote)
  • 每日 markdown 摘要落到 `analysis/signals/YYYY-MM-DD.md`

Out of scope

  • Push 通知 (Slack/email/iOS) — 待 signal 穩定後另開 issue
  • Intraday cadence — 等日線層先驗證有效再考慮
  • 圖譜版 wikilink heat — `news_items.wikilinks` TEXT[] 已足夠,圖譜版延後

Reference

  • 起源討論: 2026-05-05 conversation about MediaTek / 4985 missed setups
  • 計畫文件: `docs/plans/2026-05-05-signal-layer.md`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions