mcpField
B
barchart

barchart

github.com/gauss314数据与数据库252245 次安装20 周前更新
代码仓库

关于 barchart

barchart 是一个 Python 抓取工具,从 Barchart 静态 HTML 页面提取报价和公司数据。适用于无需 API 密钥、需要市场基本面、分析师与盈利预期、财务报表或公司简介的用户。

主要功能

  1. 01报价与 27 项基本面数据
  2. 02内部人士交易摘要
  3. 03分析师评级和盈利预期
  4. 04年度及季度财务报表
  5. 05公司简介与关键统计数据
  6. 06支持查询多个股票代码

适用场景

  1. 01查询上市公司的报价和基本面
  2. 02查看内部人士交易与分析师评级
  3. 03比较不同期间的盈利预期
  4. 04获取财务报表用于分析

MCP 相关

这是技能而非 MCP 服务;输入未说明任何 MCP 集成。

安装

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

$npx skills add https://github.com/gauss314/skills --skill barchart

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

包含的文件

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

references/
API.md
REFERENCE.md
scripts/
fetch_barchart.py

详细介绍

Barchart 抓取工具

通过 HTML 抓取从 Barchart 提取数据。无需 bs4、无需 lxml、无需 API key。


⚠️ 关键数据

概念答案
数据类型报价 + 基本面 + 内部人士交易 + 分析师评级 + 盈利预估 + 财务摘要 + 损益表/资产负债表/现金流量表详情 + 公司简介
延迟❌ 延迟 15-20 分钟(标准交易所延迟)。期货:10 分钟。并非实时数据
覆盖范围~30,000+ 个美国代码:NYSE、NASDAQ、AMEX、OTC-US。也包括全球 ADR(GGAL、BABA、SUPV 等)
需要注册/API key否
依赖项仅需 pip install requests
方法静态 HTML 抓取。Barchart 使用 AngularJS——客户端渲染的数据不可用

安装

pip install requests

脚本

脚本说明
fetch_barchart.py抓取工具:报价 + 基本面 + 内部人士交易 + 分析师 + 盈利预估 + 损益表/资产负债表/现金流量表详情 + 公司简介

快速使用

# Quote + fundamentals (27 campos) — sin flags extra
py fetch_barchart.py AAPL
py fetch_barchart.py AAPL,MSFT,GGAL         # Multi-ticker

# Insider summary (--insider)
py fetch_barchart.py AAPL --insider

# Analyst ratings (--analysts)
py fetch_barchart.py AAPL --analysts

# Earnings estimates (--estimates)
py fetch_barchart.py AAPL --estimates

# Financial summary annual (--financials)
py fetch_barchart.py GGAL --financials

# Financial summary quarterly (--financials quarterly)
py fetch_barchart.py GGAL --financials quarterly

# Income statement detail (--income)
py fetch_barchart.py GGAL --income                    # trimestral (default)
py fetch_barchart.py GGAL --income annual

# Balance sheet detail (--balance)
py fetch_barchart.py GGAL --balance                    # trimestral (default)
py fetch_barchart.py GGAL --balance annual

# Cash flow detail (--cashflow)
py fetch_barchart.py GGAL --cashflow                   # trimestral (default)
py fetch_barchart.py GGAL --cashflow annual

# Company profile (--profile)
py fetch_barchart.py GGAL --profile

# Combinar flags
py fetch_barchart.py GGAL --insider --analysts --estimates --income --balance --cashflow

# Output
py fetch_barchart.py AAPL -o aapl.json      # Guardar JSON
py fetch_barchart.py AAPL -q                # JSON a stdout

各标志的实际输出

py fetch_barchart.py AAPL(报价 + 基本面)
  ticker: AAPL
  symbol: AAPL
  name: Apple Inc
  lastPrice: 310.26
  netChange: -4.94
  percentChange: -1.57%
  bid: 313.88
  ask: 313.97
  exchange: NASDAQ
  tradeTime: 06/03/26
  marketCap: 4,629,454,720          # en $K (dividir /1000)
  sharesOutstanding: 14,687,355      # en K
  annualSales: 416,161 M
  annualIncome: 112,010 M
  ebit: 147,366 M
  ebitda: 159,064 M
  beta: 1.09
  priceSales: 10.81
  priceCashFlow: 36.59
  priceBook: 42.25
  peRatio: 37.04
  eps: 8.27
  mostRecentEarnings: $2.01 on 04/30/26
  nextEarningsDate: 07/30/26
  dividend: 1.08 (0.35%)             # monto anual + yield
  mostRecentDividend: 0.270 on 05/11/26
py fetch_barchart.py GGAL(ADR 的相同字段)
  ticker: GGAL
  symbol: GGAL
  name: Grupo Fin Galicia ADR
  lastPrice: 48.33
  netChange: -2.00
  percentChange: -3.97%
  bid: 47.15 / ask: 49.99
  exchange: NASDAQ
  marketCap: 8,084,256 $K
  sharesOutstanding: 160,625 K
  annualSales: 10,559 M
  annualIncome: 170,020 K            # utilidad negativa
  ebit: -1,178 M
  ebitda: -934 M
  beta: 1.32
  priceSales: 0.78
  priceBook: 1.37
  peRatio: 0.00
  eps: 2.27
  dividend: 4.86 (9.50%)
  nextEarningsDate: 08/25/26
--insider(添加)
  --- insider ---
  summaryLast3M:
    buys: 0
    buyShares: 0
    sells: 6
    sellShares: 397759

**含义:**过去 3 个月,公司内部人士进行了 0 笔买入和 6 笔卖出,共卖出 397,759 股。

--analysts(添加)
  --- analysts ---
  current:     Moderate Buy (4.12) - 42 analysts
  1_mth_ago:   Moderate Buy (4.12) - 42 analysts
  2_mths_ago:  Moderate Buy (4.07) - 42 analysts
  3_mths_ago:  Moderate Buy (4.07) - 42 analysts

**含义:**当前评级 = Moderate Buy,得分为 4.12/5,基于 42 位分析师的意见。评分范围为 1(Strong Sell)至 5(Strong Buy)。同时显示最近 3 个月的历史记录。

--estimates(添加)
  --- earnings estimates ---
  Average Earnings Estimate: $0.82 | $1.11 | $3.69 | $6.42
  Number of Estimates: 3 | 2 | 3 | 3
  High Estimate: $1.02 | $1.30 | $4.45 | $8.12
  Low Estimate: $0.69 | $0.92 | $3.29 | $5.21
  Prior Year: $0.94 | $0.08 | N/A | $3.69
  Growth Rate Est. (yoy): -12.77% | +1,287.50% | -99.63% | +73.98%

**表格列:**当前季度 (06/2026) | 下一季度 (09/2026) | 财年 (12/2026) | 财年 (12/2027)

含义:

  • Average Earnings Estimate = 分析师的平均 EPS 预估
  • Number of Estimates = 对该期间给出预估的分析师人数
  • High/Low Estimate = 最乐观和最悲观的预估
  • Prior Year = 去年同期报告的 EPS
  • Growth Rate Est. = 相较去年同期的预估增长率
--financials annual(添加)
  --- financial summary (annual) ---

  incomeStatement:
    Periods: 12-2025 | 12-2024 | 12-2023 | 12-2022 | 12-2021
    Sales: $10.56B | $11.64B | $24.99B | $9.99B | $5.11B
    Net Income: $170.02M | $1.79B | $1.28B | $374.52M | $326.49M

  balanceSheet:
    Periods: 12-2025 | 12-2024 | 12-2023 | 12-2022 | 12-2021
    Assets: $36.54B | $35.77B | $38.82B | $25.96B | $17.62B
    Liabilities: $30.33B | $29.10B | $31.16B | $21.27B | $14.42B

  cashFlow:
    Periods: 12-2025 | 12-2024 | 12-2023 | 12-2022 | 12-2021
    Cash (Operating): $-1.28B | $3.85B | $6.34B | $4.47B | $2.97B
    Net Cash Flow: $423.52M | $320.47M | $-3.28B | $588.02M | $736.72M

**含义:**损益表包含最近 5 年的 Sales 和 Net Income,资产负债表包含 Assets 和 Liabilities,现金流量表包含 Operating Cash Flow 和 Net Cash Flow。每个值均以 B(十亿)或 M(百万)格式显示。期间格式为 MM-YYYY。

--financials quarterly(添加)
  --- financial summary (quarterly) ---

  incomeStatement:
    Periods: 03-2026 | 09-2025 | 06-2025 | 03-2025 | 12-2024
    Sales: $672.00M | $409.98M | $2.24B | $2.18B | $8.58B
    Net Income: $46.54M | $-70.17M | $150.71M | $146.32M | $846.01M

  balanceSheet:
    Periods: 03-2026 | 09-2025 | 06-2025 | 03-2025 | 12-2024
    Assets: $31.61B | $36.54B | $33.60B | $31.33B | $35.77B
    Liabilities: $25.60B | $30.33B | $27.92B | $25.26B | $29.10B

  cashFlow:
    Periods: 03-2026 | 09-2025 | 06-2025 | 03-2025 | 12-2024
    Cash (Operating): $-1.28B | $-966.19M | $3.85B | $5.32B | $0.00
    Net Cash Flow: $423.52M | $-1.16B | $320.47M | $1.14B | $0.00

**含义:**字段与 annual 相同,但显示最近 5 个季度,而非最近 5 年。

--income quarterly(添加详细损益表)
  --- income statement detail (quarterly) ---
    Periods: 09-2025 | 03-2025 | 12-2024 | 09-2024 | 06-2024
    Interest Income: N/A | 1,590,672 | 7,624,088 | 1,444,576 | N/A
    Interest Expense: 0 | 628,468 | 2,797,842 | 606,029 | 0
    Interest Income (Net of Interest Expense): 996,333 | 962,204 | 1,774,389 | 838,547 | 1,400,136
    Non-Interest Income: 409,984 | 589,955 | 959,292 | 576,923 | 526,451
    Sales: 1,406,317 | 1,552,158 | 2,997,404 | 1,415,470 | 1,926,588
    Credit Losses Provision: N/A | N/A | N/A | N/A | 160,058
    Non Interest Expenses: 1,545,414 | 1,340,467 | 2,005,786 | 1,132,053 | 1,074,184
    Pre-tax Income: -139,097 | 211,692 | 991,619 | 283,417 | 692,346
    Income Tax: -68,924 | 65,327 | 145,681 | 98,683 | 242,396
    Other Income: -139,097 | 840,160 | 3,789,461 | 889,446 | 692,346
    Net Income: $-70,168 | $146,321 | $846,011 | $184,766 | $449,884
    EPS Basic Continuous Ops: -0.44 | 0.92 | 4.62 | 1.25 | 3.05
    EPS Basic Total Ops: -0.44 | 0.92 | 5.67 | 1.25 | 3.05
    EPS Diluted Continuous Ops: -0.44 | 0.92 | 4.62 | 1.25 | 3.05
    EPS Diluted Total Ops: -0.44 | 0.92 | 5.67 | 1.25 | 3.05
    EPS Diluted Before Non-Recurring Items: 0.08 | 0.96 | N/A | N/A | N/A
    EBITDA(a): $N/A | $N/A | $N/A | $N/A | $N/A

使用 --income annual 时,期间格式会改为 12-YYYY,数值为年度数据。

--balance quarterly(添加详细资产负债表)
  --- balance sheet detail (quarterly) ---
    Periods: 09-2025 | 03-2025 | 12-2024 | 09-2024 | 06-2024
    Assets:
    Cash & Cash Equivalents: 6,955,327 | 5,545,430 | 7,419,325 | 7,422,673 | 2,853,684
    Securities And Investments: 676,711 | 6,598,840 | 8,225,726 | 6,138,255 | 1,748,708
    Loans Gross: 17,647,550 | 15,687,540 | 16,561,370 | 10,078,030 | 7,070,364
    PPE Net: 936,089 | 989,632 | 1,095,073 | 810,412 | 720,216
    Total Assets: $33,596,770 | $31,332,270 | $35,769,780 | $25,272,940 | $19,191,830
    Total deposits: 19,632,510 | 17,298,760 | 20,497,760 | 15,073,540 | 9,613,379
    Long Term Debt: N/A | 1,421,175 | 1,110,457 | 507,279 | N/A
    Total Liabilities: $27,922,710 | $25,256,920 | $29,099,660 | $20,389,730 | $15,007,280
    Retained earnings: N/A | 558,626 | 464,154 | -172,847 | N/A
    Total Liabilities And Equity: $33,596,766 | $31,332,267 | $35,769,779 | $25,272,935 | $19,191,833
--cashflow quarterly(添加详细现金流量表)
  --- cash flow detail (quarterly) ---
    Periods: 09-2025 | 03-2025 | 12-2024 | 09-2024 | 06-2024
    Net Income: N/A | 211,692 | 2,432,345 | 1,610,563 | N/A
    Depreciation Amortization: N/A | 55,824 | 206,874 | 125,586 | N/A
    Operating Cash Flow: $N/A | $-966,190 | $3,853,060 | $5,324,640 | $N/A
    Investing Cash Flow: $N/A | $-65,007 | $951,697 | $-142,836 | $N/A
    Financing Cash Flow: $N/A | $147,569 | $454,877 | $-490,960 | $N/A
    End Cash Position: N/A | 6,077,983 | 8,147,057 | 8,384,714 | N/A
    Net Cash Flow: $N/A | $-1,158,989 | $320,472 | $1,140,003 | $N/A
    Free Cash Flow: 0 | -1,056,768 | 3,616,886 | 5,176,481 | 0
--profile(添加公司简介 + 关键统计数据)
  --- profile ---
    Name: Grupo Fin Galicia ADR
    Address: TTE. GRAL. JUAN D. PERON 430 25TH FLOOR BUENOS AIRES C1 CP1038AAJ ARG
    Website: http://www.gfgsa.com
    Employees: 10,079
    Phone: 54-11-4343-7528
    Fax: 114-331-9183
    Sector: Finance
    Industries: SIC-6029 Commercial Banks, NEC, Banks - Foreign, Indices Nasdaq Composite
    Description: Grupo Financiero Galicia SA. is involved in the Financial Services Industry...

    --- overview ---
      Market Capitalization, $K: 8,084,256
      Enterprise Value, $K: 2,012,866
      Shares Outstanding, K: 160,625
      Float, K: 160,625
      % Float: 100.00%
      Short Interest, K: 6,552
      Short Float: 4.08%
      Days to Cover: 6.72
      Short Volume Ratio: 0.53
      % of Institutional Shareholders: 0.00%

    --- financials ---
      Annual Sales, $: 10,559 M
      Annual Net Income, $: 170,020 K
      Last Quarter Sales, $: 672,000 K
      Last Quarter Net Income, $: 46,540 K
      EBIT, $: -1,178 M
      EBITDA, $: -934,100 K

    --- growth ---
      1-Year Return: -14.61%
      3-Year Return: 226.33%
      5-Year Return: 387.69%
      5-Year Revenue Growth: 141.77%
      5-Year Earnings Growth: -100.00%
      5-Year Dividend Growth: 2,725.00%

    --- perShareInfo ---
      Most Recent Earnings: 0.29 on 05/26/26
      Next Earnings Date: 08/25/26
      Earnings Per Share ttm: 2.27
      EPS Growth vs. Prev Year: -69.79%
      Annual Dividend & Yield (Paid): 2.16 (4.28%)
      Annual Dividend & Yield (Fwd): 4.86 (9.50%)
      Most Recent Dividend: 0.405 on 05/11/26
      Next Ex-Dividends Date: 05/11/26
      Dividend Payable Date: 05/29/26
      Dividend Payout Ratio: 51.43%

    --- ratios ---
      Price/Earnings ttm: 0.00
      Price/Earnings forward: 13.85
      Price/Earnings to Growth: 0.36
      Return-on-Equity %: 0.00%
      Return-on-Assets %: 0.00%
      Profit Margin %: 1.61%
      Debt/Equity: 0.00
      Price/Sales: 0.78
      Price/Cash Flow: 19.86
      Price/Book: 1.37
      Book Value/Share: 37.43
      Interest Coverage: -1.21
      60-Month Beta: 1.32

    --- dividendHistory ---
      Date: Value
      05/11/26: $0.4050
      05/04/26: $0.1640
      03/30/26: $0.1600
      ... (12+ entries)

各标志包含的内容(摘要)

py fetch_barchart.py TICKER — 始终:27 个报价 + 基本面字段
#字段描述AAPL 示例备注
1ticker用户输入AAPL
2symbolBarchart 上的代码AAPL
3name公司名称Apple Inc
4lastPrice最新价格310.26延迟 15-20 分钟
5netChange净变动(美元)-4.94
6percentChange百分比变动-1.57%
7bid当前买价313.88
8ask当前卖价313.97
9exchange上市交易所NASDAQ
10tradeTime最近一笔交易的时间06/03/26
11marketCap市值(千美元)4,629,454,720除以 1000 得到美元
12sharesOutstanding流通股数(千股)14,687,355单位为千
13annualSales年销售额416,161 MM = 百万
14annualIncome年净收入112,010 M
15ebitEBIT147,366 M
16ebitdaEBITDA159,064 M
17beta60 个月 Beta1.09
18priceSales市销率10.81
19priceCashFlow市现率36.59
20priceBook市净率42.25
21peRatio市盈率(TTM)37.04
22eps每股收益(TTM)8.27
23mostRecentEarnings最近一次公布的财报$2.01 on 04/30/26
24nextEarningsDate下次财报日期07/30/26
25dividend年度股息 + 股息率1.08 (0.35%)
26mostRecentDividend最近一次支付的股息0.270 on 05/11/26
27sector公司所属行业Technology
--insider 增加:4 个字段
#字段描述AAPL 示例
28summaryLast3M.buys内部人士买入交易次数(3 个月)0
29summaryLast3M.buyShares内部人士买入股数0
30summaryLast3M.sells卖出交易次数6
31summaryLast3M.sellShares内部人士卖出股数397,759
--analysts 增加:4 个时期 × 3 个字段 = 12 个字段
时期字段AAPL 示例
currentrating(文本)、value(1-5)、analysts(人数)Moderate Buy, 4.12, 42
1_mth_agorating、value、analystsModerate Buy, 4.12, 42
2_mths_agorating、value、analystsModerate Buy, 4.07, 42
3_mths_agorating、value、analystsModerate Buy, 4.07, 42
--estimates 增加:5 行以上 × 4 个时期
行描述GGAL 本季度示例
Average Earnings Estimate平均预估 EPS$0.82
Number of Estimates提供预估的分析师人数3
High Estimate最乐观的预估 EPS$1.02
Low Estimate最悲观的预估 EPS$0.69
Prior Year上一年同期的 EPS$0.94
Growth Rate Est.相比上一年的预估增长率-12.77%

脚本无法获取的数据

所有这些数据均由 AngularJS 渲染,在静态 HTML 中不可用。必须使用无头浏览器(Playwright、Selenium 等)。

页面无法获取的数据
/stocks/quotes/{TICKER}/financial-summary只有 income/balance/cash flow 可通过 --financials 获取。不包含增长率(%)
/stocks/quotes/{TICKER}/options期权链
/stocks/quotes/{TICKER}/technical-analysisRSI、Stochastic、ATR、ADX、移动平均线、波动率
/stocks/quotes/{TICKER}/analyst-ratings目标价(高位/平均/低位)、评级明细(各类别人数)
/stocks/quotes/{TICKER}/insider-trades详细交易记录(仅提供汇总数据)
/stocks/quotes/{TICKER}/related-etfs相关 ETF 表格(symbol、name、weight)——全部由 AngularJS 渲染
/stocks/signals/top-bottom/top筛选器 / 排行榜

工作原理 — endpoints

报价 + 基本面
GET https://www.barchart.com/stocks/quotes/{TICKER}
  1. 从 data-ng-init='init({...})' 属性中提取 JSON(symbol、lastPrice、bid/ask、exchange、tradeTime)
  2. 提取 <span class="left">Label</span> + <span class="right">Value</span> 键值对,获取基本面数据
内部人士交易
GET https://www.barchart.com/stocks/quotes/{TICKER}/insider-trades
  • 从纯文本中提取摘要:"Last 3 Months: X Buys, Y Shares; Z Sells, W Shares"
分析师评级
GET https://www.barchart.com/stocks/quotes/{TICKER}/analyst-ratings
  • 从纯文本中提取以下模式:{Período}\n{Rating}\n{Valor}\nBased on\n{Cantidad}
盈利预估
GET https://www.barchart.com/stocks/quotes/{TICKER}/earnings-estimates
  • 提取 EPS 预估 HTML 表格
财务摘要
GET https://www.barchart.com/stocks/quotes/{TICKER}/financial-summary/{annual|quarterly}
  • 从 data-content 属性中提取 JSON,其中包含 5 个时期的损益表(Sales、Net Income)、资产负债表(Assets、Liabilities)和现金流量表(Operating Cash Flow、Net Cash Flow)
损益表详情
GET https://www.barchart.com/stocks/quotes/{TICKER}/income-statement/{quarterly|annual}
  • 提取详细损益表 HTML 表格:Interest Income/Expense、Sales、Net Income、EPS(Basic/Diluted)、EBITDA 等(约 17 行)
资产负债表详情
GET https://www.barchart.com/stocks/quotes/{TICKER}/balance-sheet/{quarterly|annual}
  • 提取详细资产负债表 HTML 表格:Cash、Securities、Loans、Total Assets/Liabilities、Shareholders' Equity 等(约 23 行)
现金流量表详情
GET https://www.barchart.com/stocks/quotes/{TICKER}/cash-flow/{quarterly|annual}
  • 提取详细现金流量表 HTML 表格:Operating、Investing、Financing Cash Flow、Free Cash Flow、Net Cash Flow、End Cash Position 等(约 27 行)
公司概况
GET https://www.barchart.com/stocks/quotes/{TICKER}/profile
  • 从 Company Info 部分提取公司信息(address、website、employees、phone、fax、sector、industries、description)
  • 提取 6 个关键统计数据表:概览(enterprise value、float、short interest)、财务数据(上季度数据)、增长(回报率、CAGR)、每股信息(EPS 增长、payout ratio、ex-div date)、比率(P/E forward、PEG、ROE、ROA、profit margin、book value/share)、股息历史

脚本标志

标志描述Endpoint
TICKER以逗号分隔的股票代码(例如:AAPL,MSFT,GGAL)始终
--insider过去 3 个月的内部人士交易摘要/insider-trades
--analysts当前及过去 3 个月的分析师评级/analyst-ratings
--estimates盈利预估(4 个时期)/earnings-estimates
--financials年度财务摘要(默认)/financial-summary/annual
--financials quarterly季度财务摘要/financial-summary/quarterly
--income季度详细损益表(默认)/income-statement/quarterly
--income annual年度详细损益表/income-statement/annual
--balance季度详细资产负债表(默认)/balance-sheet/quarterly
--balance annual年度详细资产负债表/balance-sheet/annual
--cashflow季度详细现金流量表(默认)/cash-flow/quarterly
--cashflow annual年度详细现金流量表/cash-flow/annual
--profile公司概况 + 关键统计数据/profile
--output / -o将输出保存到 JSON 文件-
--quiet / -q仅将 JSON 输出到 stdout(管道模式)-

可以组合使用:py fetch_barchart.py AAPL --insider --analysts --estimates --financials --income --balance --cashflow -o aapl_full.json


技术说明

  • marketCap 的单位是 $K(千)。AAPL = 4,629,454,720 → $4.6T
  • sharesOutstanding 的单位是 K(千)
  • annualSales/Income 使用后缀:M = millions,K = thousands
  • 数据相对于实时市场行情延迟 15-20 分钟
  • 覆盖在 NYSE/NASDAQ 上市的全球 ADR(GGAL、SUPV、BABA 等)
  • 需要使用浏览器 User-Agent(脚本中已包含)
  • **速率限制:**请求间隔约为 300ms(可在脚本中配置)

skill 结构

skills/barchart/
├── SKILL.md                       # Este archivo — documentación principal
├── references/
│   └── REFERENCE.md               # Referencia técnica detallada
├── scripts/
│   └── fetch_barchart.py          # Script principal (sin dependencias extra)
└── assets/

📖 技术参考:references/REFERENCE.md — 逐字段表格、提取详情、技术说明

评论

支持 Markdown