File contents HK+US 数据能力
目标
以 Python 脚本直接拉数,不依赖 MCP。默认免密可运行,并提供多渠道兜底策略。
目录
scripts/fetch_realtime_hkus.py
scripts/fetch_history_hkus.py
scripts/fetch_technical_hkus.py
scripts/fetch_fundamental_hkus.py
scripts/fetch_sector_hkus.py
scripts/fetch_macro_us.py
scripts/fetch_universe_hkus.py
scripts/fetch_market_realtime_hkus.py
scripts/healthcheck_sources.py
安装依赖
pip3 install yfinance pandas numpy requests pandas_datareader yahooquery pytest
代码规范
US 代码统一输出为 EXCHANGE:TICKER,如 NASDAQ:AAPL
HK 代码统一输出为 NNNN.HK,如 0700.HK
结果统一包含:
source_primary
source_actual
fallback_used
fallback_chain
渠道优先级
US / HK(行情与K线)
实时:tencent_quote -> sina_quote -> yahooquery_realtime -> yfinance -> yahoo_chart
历史/技术:tencent_history -> sina_history -> yfinance -> yahooquery_history -> yahoo_chart
腾讯、新浪均区分港/美代码。实时用 usAAPL / hk00700;K 线用 fqkline/get,美股需带交易所后缀(如 usAAPL.OQ、usJPM.N、usSPY.AM,由 qt 行情自动解析)。分钟 K 港股走 minute/query;美股盘中仅返回当前分钟快照,历史分钟由 Yahoo 兜底。实时结果含 market_state 与 premarket;盘中若主源未带盘前,会用 Yahoo 补齐。
其他
基本面(US):yfinance -> yahooquery
宏观:fred_reader -> fred_csv
快速命令
# 实时
python3 scripts/fetch_realtime_hkus.py --symbol AAPL --json
python3 scripts/fetch_realtime_hkus.py --batch AAPL,TSLA,0700.HK --json
# 历史
python3 scripts/fetch_history_hkus.py --symbol AAPL --interval 1d --days 180 --json
python3 scripts/fetch_history_hkus.py --batch AAPL,MSFT,0700.HK --workers 8 --json
# 技术
python3 scripts/fetch_technical_hkus.py AAPL --days 180 --interval 1d --json
# 基本面
python3 scripts/fetch_fundamental_hkus.py --symbol AAPL --json
# 行业与ETF
python3 scripts/fetch_sector_hkus.py --sector-name 半导体 --days 60 --json
python3 scripts/fetch_sector_hkus.py --symbol 0700.HK --json
# 美国宏观
python3 scripts/fetch_macro_us.py --interest-rates --days 365 --json
python3 scripts/fetch_macro_us.py --inflation-employment --months 36 --json
python3 scripts/fetch_macro_us.py --economic-growth --quarters 24 --json
# 渠道健康检查
python3 scripts/healthcheck_sources.py --us-symbol AAPL --hk-symbol 0700.HK
# 拉全市场股票清单
python3 scripts/fetch_universe_hkus.py --market all --json
python3 scripts/fetch_universe_hkus.py --market us --json
python3 scripts/fetch_universe_hkus.py --market hk --json
# 拉市场当前交易数据(可全市场)
python3 scripts/fetch_market_realtime_hkus.py --market all --universe-limit 800 --top 200 --json
python3 scripts/fetch_market_realtime_hkus.py --market us --universe-limit 1000 --top 100 --sort volume_desc --json
python3 scripts/fetch_market_realtime_hkus.py --symbols NASDAQ:AAPL,NYSE:MSFT,0700.HK --json
输出规则
默认输出简版摘要
带 --json 时输出完整结构
若主备源都失败,返回错误标识 source_unavailable
1 --- 2 name: market-data 3 description: 港股与美股数据能力。支持实时、历史K线、技术指标、估值与机构持仓、行业ETF与美国宏观,且具备多渠道兜底。 4 --- 5 6 # HK+US 数据能力 7 8 ## 目标 9 10 以 Python 脚本直接拉数,不依赖 MCP。默认免密可运行,并提供多渠道兜底策略。 11 12 ## 目录 13 14 - `scripts/fetch_realtime_hkus.py` 15 - `scripts/fetch_history_hkus.py` 16 - `scripts/fetch_technical_hkus.py` 17 - `scripts/fetch_fundamental_hkus.py` 18 - `scripts/fetch_sector_hkus.py` 19 - `scripts/fetch_macro_us.py` 20 - `scripts/fetch_universe_hkus.py` 21 - `scripts/fetch_market_realtime_hkus.py` 22 - `scripts/healthcheck_sources.py` 23 24 ## 安装依赖 25 26 ```bash 27 pip3 install yfinance pandas numpy requests pandas_datareader yahooquery pytest 28 ``` 29 30 ## 代码规范 31 32 - US 代码统一输出为 `EXCHANGE:TICKER`,如 `NASDAQ:AAPL` 33 - HK 代码统一输出为 `NNNN.HK`,如 `0700.HK` 34 - 结果统一包含: 35 - `source_primary` 36 - `source_actual` 37 - `fallback_used` 38 - `fallback_chain` 39 40 ## 渠道优先级 41 42 ### US / HK(行情与K线) 43 44 - 实时:`tencent_quote -> sina_quote -> yahooquery_realtime -> yfinance -> yahoo_chart` 45 - 历史/技术:`tencent_history -> sina_history -> yfinance -> yahooquery_history -> yahoo_chart` 46 47 腾讯、新浪均区分港/美代码。实时用 `usAAPL` / `hk00700`;K 线用 `fqkline/get`,美股需带交易所后缀(如 `usAAPL.OQ`、`usJPM.N`、`usSPY.AM`,由 qt 行情自动解析)。分钟 K 港股走 `minute/query`;美股盘中仅返回当前分钟快照,历史分钟由 Yahoo 兜底。实时结果含 `market_state` 与 `premarket`;盘中若主源未带盘前,会用 Yahoo 补齐。 48 49 ### 其他 50 51 - 基本面(US):`yfinance -> yahooquery` 52 - 宏观:`fred_reader -> fred_csv` 53 54 ## 快速命令 55 56 ```bash 57 # 实时 58 python3 scripts/fetch_realtime_hkus.py --symbol AAPL --json 59 python3 scripts/fetch_realtime_hkus.py --batch AAPL,TSLA,0700.HK --json 60 61 # 历史 62 python3 scripts/fetch_history_hkus.py --symbol AAPL --interval 1d --days 180 --json 63 python3 scripts/fetch_history_hkus.py --batch AAPL,MSFT,0700.HK --workers 8 --json 64 65 # 技术 66 python3 scripts/fetch_technical_hkus.py AAPL --days 180 --interval 1d --json 67 68 # 基本面 69 python3 scripts/fetch_fundamental_hkus.py --symbol AAPL --json 70 71 # 行业与ETF 72 python3 scripts/fetch_sector_hkus.py --sector-name 半导体 --days 60 --json 73 python3 scripts/fetch_sector_hkus.py --symbol 0700.HK --json 74 75 # 美国宏观 76 python3 scripts/fetch_macro_us.py --interest-rates --days 365 --json 77 python3 scripts/fetch_macro_us.py --inflation-employment --months 36 --json 78 python3 scripts/fetch_macro_us.py --economic-growth --quarters 24 --json 79 80 # 渠道健康检查 81 python3 scripts/healthcheck_sources.py --us-symbol AAPL --hk-symbol 0700.HK 82 83 # 拉全市场股票清单 84 python3 scripts/fetch_universe_hkus.py --market all --json 85 python3 scripts/fetch_universe_hkus.py --market us --json 86 python3 scripts/fetch_universe_hkus.py --market hk --json 87 88 # 拉市场当前交易数据(可全市场) 89 python3 scripts/fetch_market_realtime_hkus.py --market all --universe-limit 800 --top 200 --json 90 python3 scripts/fetch_market_realtime_hkus.py --market us --universe-limit 1000 --top 100 --sort volume_desc --json 91 python3 scripts/fetch_market_realtime_hkus.py --symbols NASDAQ:AAPL,NYSE:MSFT,0700.HK --json 92 ``` 93 94 ## 输出规则 95 96 - 默认输出简版摘要 97 - 带 `--json` 时输出完整结构 98 - 若主备源都失败,返回错误标识 `source_unavailable`
shouldnotappearcalm/hk-us-market-skill/tree/main/market-data commit 132b796540
Frequently asked questions How do I install the Market Data skill? Run npx skillmds@latest add shouldnotappearcalm/market-data in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Market Data skill do? 港股与美股数据能力。支持实时、历史K线、技术指标、估值与机构持仓、行业ETF与美国宏观,且具备多渠道兜底。 It is listed under Coding & Dev Tools on SkillMD.
Is Market Data safe to use? This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Market Data? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Market Data free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Market Data? shouldnotappearcalm (@shouldnotappearcalm) published this skill. Their other Agent Skills are listed on their SkillMD profile.