mcpField
S
stock-analysis

stock-analysis

github.com/rebyteai数据与数据库043 次安装4 周前更新
代码仓库

关于 stock-analysis

面向股票和公司的金融分析技能,结合近期价格数据、Rebyte 金融数据湖、研究资料和 SEC 文件。它为使用 Rebyte API 身份验证的 Agent 提供研究流程和策略回测指导。

主要功能

  1. 01分析价格、公司和基本面
  2. 02比较股票并查看新闻
  3. 03查询美国和中国金融数据
  4. 04使用 SEC 文件和内幕交易记录
  5. 05执行策略回测流程
  6. 06生成结构化分析报告

适用场景

  1. 01查看股票最新价格和趋势
  2. 02比较公司或研究基本面
  3. 03查看监管文件和内幕交易
  4. 04回测交易策略

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/rebyteai/rebyte-skills --skill stock-analysis

安装后在 Claude Code 中输入/stock-analysis确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

.gitignore
backtesting/
config.example.json
backtesting/evals/
evals.json
backtesting/references/
data_sources.md
domain_knowledge.md
nautilus_patterns.md
backtesting/scripts/
fetch_data.py
run_backtest.py
run_workflow.sh
setup.sh
backtesting/strategies/
sma_cross.py
data/
README.md
TEST_PLAN.md
data/data_builder/us_news/
build.py
README.md
data/scripts/
financial_cli.py
data/scripts/shared/
constants.json
financial-templates/
company-research.md
daily-market-review.html
industry-research.md
output-patterns.md
statement-analysis.md
valuation-analysis.md
references/
sec-edgar.md
report-style/
CHEATSHEET.md
design.md
README.md
report.css
styles.css

详细介绍

股票分析

使用直接近期价格数据源和 Rebyte 金融数据湖进行股票与公司分析,以及策略回测。

需要 Rebyte API 身份验证——按 Agent 的系统提示设置 $AUTH_TOKEN 和 $API_URL;将其分别用作 Bearer 令牌和基础 URL。

技能布局——按需加载相应模块

模块适用场景
本文件分析指南:价格检查、公司概览、比较、基本面、技术面
data/SKILL.md数据路由与机制:直接查询两个日期的价格、完整的 19 张表的数据湖目录(美国 + 中国)、SQL 模式、新闻 + 研究搜索、错误规则。获取数据前请先阅读。
backtesting/SKILL.md策略模拟:NautilusTrader 的 5 阶段工作流,最终生成回测结果包
financial-templates/SKILL.md分析结构(DCF、可比公司分析、备忘录格式),不调用数据
report-style/README.md本技能生成的所有 HTML 报告均使用 Kami 设计系统
references/sec-edgar.md通过 edgartools 获取 SEC 文件、完整 10-K/10-Q 文本、内部人士(Form 4)交易记录

价格/K 线图表:使用 financial-charts 技能(TradingView 风格的 Lightweight Charts)。

数据源

来源提供内容访问方式
直接近期价格 API当前和前一个交易所当地日历日的纯 OHLCV 价格柱。美国分钟线使用 stocks/bars,参数为 interval: "1min";中国分钟线使用 cn-stocks/bars_1min。POST $API_URL/api/data/stocks/bars、POST $API_URL/api/data/cn-stocks/bars 或 POST $API_URL/api/data/cn-stocks/bars_1min——参见 data/SKILL.md
Rebyte 金融数据湖美国:日线 + 1 分钟线、新闻、SEC 文件基本面、拆股、股息、卖空数据、股票代码全集、IPO。中国 A 股:日线 + 1 分钟线、估值快照、财务报表、资金流、异动披露。通过 POST $API_URL/api/data/financial/sql 执行只读 SQL——参见 data/SKILL.md
新闻档案可追溯至 2016 年的美国股票新闻报道,可按含义搜索POST $API_URL/api/data/research/news——参见 data/SKILL.md
研究资料库来自 13 家投资研究出版物的约 4,300 篇长篇文章(SemiAnalysis、SemiVision、MacroCharts、Capital Wars、Citrini、Doomberg、Michael J Burry 等),时间范围为 2020 年至今。由具名从业者撰写的一手分析——可用于研究投资论点、争论和运作机制。调用 POST $API_URL/api/data/research/search,然后使用 /context 或 /article——参见 data/SKILL.md
SEC EDGAR完整文件文本(10-K、10-Q、8-K)、文件章节、内部人士(Form 4)交易记录使用 edgartools Python 库——参见 references/sec-edgar.md

按数据新鲜度选择数据源。 对于“当前”“今天”“最新价格”和近期盘中问题,使用直接 API。其日期范围由服务器固定为 America/New_York(美国)或 Asia/Shanghai(中国)的当前和前一个日历日;调用方无法扩大范围。其他所有较早的数据或非价格信息均使用数据湖。美国响应会显示 Polygon 的 upstreamStatus(例如 DELAYED),因此切勿声称数据达到逐笔实时级别。存在这些信息时,请说明数据来源、返回的日期范围、最新价格柱的时间戳和数据源状态。市场交易时段内,两地市场都使用分钟线;只有在相应市场收盘后,才能将当日的日线视为最终数据。


分析工作流

两个日期的价格边界查询使用直接价格数据;历史或非价格步骤使用数据湖 SQL。具体路由和请求格式见 data/SKILL.md。

1. 快速股票检查
User: "What's AAPL doing?" / "AAPL price"
→ Direct recent bars — quote the latest close, timestamp, date range, feed status
→ Lake daily bars (last 1 month) + ticker details for context
→ Present: latest direct price + recent trend + basic company info
2. 公司概览
User: "Tell me about NVDA" / "What does Tesla do?"
→ Ticker details + latest fundamentals period (revenue, net income)
→ Daily bars (last 3 months)
→ Direct recent bars when presenting a latest/current price
→ Recent news (5 headlines) — semantic search for themes if needed
→ Present: business summary, market position, recent performance, news themes
3. 技术分析
User: "Is TSLA a good buy?" / "AAPL technical analysis"
→ Daily bars (last 6 months) — trend, support/resistance
→ Direct recent intraday bars — current short-term momentum
→ Lake 1-minute bars aggregated to hourly when more than two dates are needed
→ Recent news (10 articles) — read and judge the tone yourself
→ Compute: moving averages, price range, volume trends
→ Present: trend direction, key levels, volume analysis, sentiment, outlook
4. 多股票比较
User: "Compare AAPL vs MSFT vs GOOGL"
→ One SQL per dataset covering all tickers (WHERE ticker IN (...))
→ Direct recent bars for each ticker when current prices are part of the comparison
→ Compare: price performance, fundamentals, news flow
→ Present: side-by-side table, relative performance
5. 基本面深入分析
User: "AAPL financials" / "NVDA revenue trend"
→ Fundamentals: annual (5 periods) + quarterly (4 periods)
→ Dividends (last 12) — history and implied yield vs latest direct close
→ Weekly-aggregated bars (last 2 years) — long-term price context
→ Compute: revenue growth, margin trends, EPS trend, payout ratio
→ Optional: SEC EDGAR for full 10-K text
6. 内部人士活动
User: "Insider trading for TSLA" / "Are executives buying NVDA?"
→ SEC EDGAR: Form 4 filings (the lake does not carry insider trades)
→ Daily bars (last 3 months) — price context around the trades
→ Present: recent transactions, insider sentiment, correlation with price
7. 尽职调查资料包
User: "Full analysis of MSFT" / "Due diligence on AMD"
→ Ticker details, 1y daily bars, annual + quarterly fundamentals,
  dividends, splits, 20 recent news items
→ Direct recent bars for the current price snapshot
→ SEC EDGAR: latest 10-K, recent 8-Ks, Form 4 insider trades
→ Present: comprehensive report (Kami-styled HTML per report-style/)
8. 行业研究
User: "Compare cloud stocks" / "Best semiconductor stocks"
→ Identify tickers (us.tickers can filter by name/type/exchange)
→ Batch daily bars + fundamentals across the set
→ Semantic news search on the sector theme
→ Present: sector overview, leaders, relative performance
9. 策略回测
User: "Backtest an SMA crossover on AAPL" / "验证我的策略"
→ Switch to backtesting/SKILL.md and run its 5 phases end-to-end
→ Deliverable is the backtest bundle at /code/backtests/<slug>/

触发模式

用户提及以下任何内容时,务必获取数据。不要凭记忆作答——按指定要求调用直接价格 API 和/或数据湖。

用户意图必需操作
提及股票代码(AAPL、$TSLA、000001.SZ)获取直接近期行情 + 数据湖股票详情
“current”“today”“latest price”“how is X doing”优先获取直接近期行情;包含 marketDateRange、最新时间戳和数据源状态
历史“price”或“chart”获取所请求范围的数据湖行情;仅当最新边界很重要时,才添加直接行情
“news”“what's happening with”新闻查询(至少 10 条)或语义搜索
“analyze”“research”“tell me about”详情 + 行情 + 新闻
“compare”“vs”“versus”获取每只股票的所有数据集,并排比较
“buy”“sell”“good investment”行情 + 新闻 + 基本面(年度 + 季度)
“financials”“revenue”“earnings”基本面(年度 + 季度)
“dividend”“yield”“payout”us.dividends
“split”“stock split”us.splits
“short interest”“shorts”us.short_interest / us.short_volume
“insider”“who's buying/selling”SEC EDGAR Form 4 文件
“10-K”“10-Q”“SEC filing”SEC EDGAR 文件
“backtest”“回测”“strategy performance”backtesting/SKILL.md

数据湖 SQL 示例

身份验证与请求格式、DataFusion 风格的 SQL 模式、错误处理规则,以及完整的表目录,均见 data/SKILL.md。以下示例对应常见分析需求;美国股票代码使用大写字母,中国股票代码使用 NNNNNN.SZ/NNNNNN.SH。

-- Price bars, daily (raw, unadjusted; check us.splits before spanning a split)
SELECT t, o, h, l, c, v FROM us.eod
WHERE ticker = 'AAPL' AND t >= to_timestamp('2026-01-01')
ORDER BY t

-- Intraday / custom intervals: aggregate 1-minute bars
SELECT date_bin(INTERVAL '1 hour', t, TIMESTAMP '1970-01-01') AS bucket,
       min(t) AS t_open, max(h) AS h, min(l) AS l, sum(v) AS v
FROM us.bars_1m
WHERE ticker = 'AAPL' AND t >= now() - INTERVAL '5 days'
GROUP BY bucket ORDER BY bucket

-- News for a ticker (tickers is an array column)
SELECT published_utc, title, tickers FROM us.news
WHERE array_has(tickers, 'AAPL')
ORDER BY published_utc DESC LIMIT 10
-- Thematic retrieval ("news about AI chip demand"): use research/news instead
-- of ILIKE; for theses and mechanisms use research/search — see data/SKILL.md.

-- Fundamentals (SEC-filing derived; is_* income, bs_* balance, cf_* cashflow)
SELECT fiscal_year, fiscal_period, is_revenues, is_gross_profit,
       is_operating_income_loss, is_net_income_loss,
       is_diluted_earnings_per_share, bs_assets, bs_liabilities, bs_equity,
       cf_net_cash_flow_from_operating_activities
FROM us.fundamentals
WHERE array_has(tickers, 'AAPL') AND timeframe = 'annual'
ORDER BY fiscal_year DESC LIMIT 5

-- Dividends / splits
SELECT ex_dividend_date, cash_amount, frequency FROM us.dividends
WHERE ticker = 'AAPL' ORDER BY ex_dividend_date DESC LIMIT 12;
SELECT execution_date, split_from, split_to FROM us.splits
WHERE ticker = 'AAPL' ORDER BY execution_date DESC

-- Ticker details / universe screen
SELECT ticker, name, primary_exchange, type, active, cik FROM us.tickers
WHERE ticker = 'AAPL'

-- CN A-share daily bars (adj_factor included for adjusted series)
SELECT t, o, h, l, c, v, pct_chg, adj_factor FROM cn.bars_day
WHERE ts_code = '000001.SZ' AND t >= to_timestamp('2026-01-01')
ORDER BY t

-- CN valuation snapshot / financial indicators
SELECT trade_date, pe_ttm, pb, turnover_rate, total_mv FROM cn.daily_basic
WHERE ts_code = '000001.SZ' ORDER BY trade_date DESC LIMIT 20

data/scripts/financial_cli.py 辅助脚本封装了身份验证和 SQL 端点:

python3 data/scripts/financial_cli.py catalog
python3 data/scripts/financial_cli.py schema us.eod
python3 data/scripts/financial_cli.py query "SELECT ... LIMIT 10"
python3 data/scripts/financial_cli.py news "Fed rate cut expectations" --ticker NVDA
python3 data/scripts/financial_cli.py research "global liquidity and central bank balance sheets"

SEC EDGAR 参考资料

如需完整文件文本、文件章节和内幕交易数据,请参阅 references/sec-edgar.md。

快速入门:

pip install edgartools
from edgar import Company, set_identity
set_identity("Rebyte Agent [email protected]")

company = Company("AAPL")
filings = company.get_filings(form="10-K")      # Annual reports
insider = company.get_filings(form="4")         # Insider trades

分析指南

根据价格行情计算技术指标

数据湖返回原始 OHLCV 数据。请自行计算指标(或使用 SQL 计算):

  • 简单移动平均线(SMA):最近 N 个收盘价的平均值(20 日和 50 日)
  • 价格趋势:当前收盘价与 20 日和 50 日 SMA 的对比
  • 支撑位/阻力位:根据近期日线行情确定低点/高点
  • 成交量趋势:近期成交量与 20 日平均成交量的对比
  • 52 周区间:一年日线行情中的最低价/最高价
  • 公司行动:us.eod 未经复权——如果时间范围跨越拆股日期,请使用 us.splits 进行调整;中国日线行情直接包含 adj_factor
解读新闻

数据湖新闻不包含预先计算的情绪分析——请阅读标题/内容,自行判断倾向,并考虑发布方权重和时效性。对于主题类问题,优先使用语义搜索端点,而非关键词 ILIKE。

财务报表分析
  • 营收增长:各期间之间的同比变化
  • 利润率趋势:毛利率/营业利润率/净利率随时间的变化
  • 现金状况:现金及等价物与总债务的对比
  • 盈利质量:经营现金流与净利润的对比(两者应接近)
呈现结果
  • 开篇先给出答案(看涨/看跌/中性、最新有来源的收盘价及时间戳、关键指标)
  • 多只股票比较时使用表格
  • 附上具体数字和日期——不要使用含糊的表述
  • 区分事实(来自数据)与分析(你的解读)
  • 明确注明每个来源和日期范围;报告直接数据源状态,并将数据湖数据标记为 T+1
  • 长篇报告:按照 report-style/ 的要求使用 Kami 风格的 HTML

重要说明

  • 美股代码使用大写(AAPL);A 股代码带后缀(000001.SZ、600519.SH)
  • 所有时间戳均为 UTC
  • 直接价格数据仅覆盖两个交易所本地日历日期——周末和节假日可能导致日期无数据;不要扩大直接请求的范围
  • Lake 数据为 T+1——每日数据表会在前一个交易日生成
  • 直接数据表示近期数据,并不保证为实时逐笔数据——交易时段内,美股使用 stocks/bars 并设置 interval: "1min",A 股使用 cn-stocks/bars_1min;报告 Polygon 的 upstreamStatus,收盘后使用已完成的日线数据
  • 覆盖范围:美股自 2021-06 起提供(K 线),参考数据的历史更长(拆股数据始于 1978 年,股息数据始于 2000 年);A 股日线数据始于 1990-12——完整目录见 data/SKILL.md
  • SEC EDGAR 免费使用——无需 API 密钥,但需要提供身份字符串

不要使用此技能的情况

  • 简单的网络查询(“Apple 的网站是什么?”)→ 使用网络搜索
  • 实时交易、逐笔成交、买卖报价或流式报价 → 不支持;直接价格数据为 OHLCV K 线,且可能有延迟
  • 个人财务建议 → 不具备相关资质

评论

支持 Markdown