Futures Market
Alert Agent
期貨市場
警報代理
Continuously crawls 15+ global news sources, uses a local LLM to classify each story's market impact, and pushes high-risk events to Discord in real time — plus auto-generated pre/post-market briefings. 持續爬取 15+ 全球新聞源,用本地 LLM 判斷每篇新聞對期貨市場的衝擊,即時把高風險事件推送到 Discord,並在盤前/盤後自動生成市場摘要。
This agent has no web UI — it runs headless and pushes straight to a private Discord channel, which is currently switched off. Below is the actual data pipeline, not a mockup screen. 這個代理沒有網頁介面 —— 它是無頭執行,直接推到私人 Discord 頻道,目前該頻道處於停用狀態。以下是實際的資料處理流程,不是示意畫面。
Data Pipeline資料處理流程
01
News Sources新聞來源
15+ RSS feeds + Google News + Jin10 (金十數據) flash API & homepage scrape 15+ RSS 訂閱源+Google News+金十數據 Flash API 與首頁爬取
02
Crawl爬取
feedparser + httpx (async) + BeautifulSoup4/lxml for HTML extraction feedparser + httpx(非同步)+ BeautifulSoup4/lxml 解析 HTML
03
Local LLM Classify本地 LLM 分類
Ollama running Qwen2.5-14B-Instruct, structured JSON output via Pydantic, 8 event categories Ollama 跑 Qwen2.5-14B-Instruct,透過 Pydantic 輸出結構化 JSON,共 8 類事件
04
Hybrid Score混合評分
LLM relevance (.35) × severity (.25) × source weight (.15) × keyword hit (.15) × multi-source confirm (.10) LLM 相關性(.35) × 嚴重度(.25) × 來源權重(.15) × 關鍵字命中(.15) × 多來源確認(.10)
05
Push推播
Discord webhook for high-risk events, plus DST-aware scheduled pre/post-market briefings 高風險事件推 Discord Webhook,並有自動偵測日光節約時間的盤前/盤後排程摘要
Every stage reads/writes through SQLAlchemy (async) over SQLite — persistent dedup so the same story never re-triggers an alert. 每個階段都透過 SQLAlchemy(async)讀寫 SQLite —— 持久化去重,同一則新聞不會重複觸發警報。
Tech Stack技術工具
Engineering Notes工程筆記
Why a Local LLM為何用本地 LLM
Classifying a continuous news stream 24/7 through a paid API adds up fast and adds latency. Ollama running locally keeps this always-on loop free to run and fast to iterate on prompts. 24 小時不間斷分類新聞如果走付費 API,成本跟延遲都會迅速累積。本地跑 Ollama 讓這個常駐迴圈免費運行,改 prompt 也能快速迭代。
Score, Don't Just Classify不只分類,還要評分
A single LLM judgment call is noisy. Blending it with source credibility, keyword hit-rate, and cross-source confirmation into one weighted score cuts down false-positive alerts on a single sensational headline. 單靠 LLM 判斷一次雜訊很大。把來源可信度、關鍵字命中率、跨來源確認一起加權混合成一個分數,可以減少單一聳動標題就誤觸警報的情況。
No Framework Scheduler沒有用排程框架
Briefing times are a handful of fixed points (Taiwan pre/post-market, US pre-market) with DST handling — a plain asyncio polling loop with time checks was simpler and easier to reason about than pulling in APScheduler. 排程摘要就只有幾個固定時間點(台灣盤前/盤後、美股盤前),還要處理日光節約時間 —— 用單純的 asyncio 輪詢加時間判斷,比額外引入 APScheduler 更簡單也更好理解。