Cookie settings
We use essential cookies to keep you signed in and secure, and analytics cookies to improve the product. We never use them for ad tracking.Learn more
Building an AI agent? Start with /llms.txt for the full site index.
文件
以台股價格、成交量、技術指標與市場廣度建立可重跑的市場狀態觀測流程。
這篇適合需要每日追蹤台股市場狀態、建立篩選流程或監控流程的開發者與研究團隊。
Python 3.9+、requests、X-API-Key、symbol(例如 2330)。
import requests BASE_URL = "https://api.twmarketdata.com"HEADERS = { "X-API-Key": "your_api_key_here",} def get_dataset(path, params): response = requests.get( f"{BASE_URL}{path}", headers=HEADERS, params=params, ) response.raise_for_status() return response.json()prices = get_dataset( "/v2/datasets/twse-daily-price", { "symbol": "2330", "limit": 20, },)tpex_prices = get_dataset( "/v2/datasets/tpex-daily-price", { "symbol": "5483", "limit": 20, },)indices = get_dataset( "/v2/datasets/index-data", { "limit": 10, },)indicators = get_dataset( "/v2/datasets/technical-indicators", { "symbol": "2330", "limit": 20, },)breadth = get_dataset( "/v2/datasets/market-breadth", { "limit": 10, },)市場狀態資料依 snapshot / ingestion cadence 更新,建議與交易日資料一起判讀。
若 workflow 需要橫跨多資料集,請同步檢查 freshness 與 data_gaps,避免把不同更新時間的資料視為同一個時間點。
summary = { "twse_prices": prices.get("rows", []), "tpex_prices": tpex_prices.get("rows", []), "indices": indices.get("rows", []), "technical_indicators": indicators.get("rows", []), "market_breadth": breadth.get("rows", []),} print(summary)完成市場狀態摘要後,可延伸到: