mcpField
M
macrotrends

macrotrends

github.com/gauss314Data & databases252255 installsUpdated 19w ago
Repository

About macrotrends

A command-line skill that scrapes historical financial data from Macrotrends for US-listed tickers and ADRs. It retrieves statements, ratios, and employee counts from page data without an API key, with annual and some quarterly series spanning about 15 years.

Key features

  1. 01Income, balance sheet, and cash flow data
  2. 0220 financial ratios
  3. 03Annual employee counts
  4. 04Annual and quarterly statement options
  5. 05Ticker-to-slug lookup
  6. 06JSON output and request delay controls

Use cases

  1. 01Comparing a company’s financial statements over time
  2. 02Reviewing quarterly results and financial ratios
  3. 03Tracking annual employee counts
  4. 04Exporting financial data to JSON

Install

Copy the command and run it in a terminal.

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

After installing, type/macrotrendsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
MARKETS_REFERENCE.md
STATEMENTS_REFERENCE.md
scripts/
fetch_financials.py

Details

From the project README

Macrotrends — Financial Data Scraper

Scraper de Macrotrends que extrae datos financieros históricos: income statements, balance sheets, cash flow statements, financial ratios y employee count con hasta 15+ años de data para ~6,500 tickers de mercados US (NYSE, NASDAQ, AMEX), incluyendo ADRs internacionales de +30 países.

Los datos vienen en JSON embebido en la página (no requiere API key, solo requests + BeautifulSoup).


⚠️ Aviso Legal

  • Macrotrends no tiene API pública oficial. Este scraper accede a datos públicamente disponibles en la web.
  • Respetá los términos de servicio de Macrotrends.
  • Implementá rate limiting (mín 2 segundos entre requests, recomendado 3s).
  • El sitio puede cambiar su estructura HTML/JS, rompiendo el scraper.

Instalación

pip install requests beautifulsoup4

Scripts

ScriptDescripción
fetch_financials.pyScript principal: statements, ratios, employees

Uso rápido

# Income statement anual
python scripts/fetch_financials.py --ticker NVDA --income

# Todo lo disponible (income + balance + cashflow + ratios + employees)
python scripts/fetch_financials.py --ticker AAPL --all

# Statements trimestrales
python scripts/fetch_financials.py --ticker MSFT --income --quarterly
python scripts/fetch_financials.py --ticker MSFT --balance --quarterly

# Ratios anuales o trimestrales
python scripts/fetch_financials.py --ticker NVDA --ratios
python scripts/fetch_financials.py --ticker GGAL --ratios --quarterly

# Employee count
python scripts/fetch_financials.py --ticker NVDA --employees

# Output a archivo JSON
python scripts/fetch_financials.py --ticker AAPL --all --output data.json

# Silencioso (solo JSON)
python scripts/fetch_financials.py --ticker NVDA --all --quiet

Endpoints disponibles

FlagDataFrecuenciasPeríodos
--incomeIncome StatementAnual, Trimestral~15 años / ~60 quarters
--balanceBalance SheetAnual, Trimestral~15 años / ~60 quarters
--cashflowCash FlowSolo anual~15 años
--ratiosFinancial Ratios (20 ratios)Anual, Trimestral~15 años / ~60 quarters
--employeesEmployee CountAnual~15 años
--allTodos los anterioresSegún --quarterly-
Flags adicionales
FlagDescripción
--quarterlyUsa frecuencia trimestral (donde esté disponible)
--outputArchivo JSON de salida (default: stdout)
--slugSlug manual (si el search no funciona)
--delayDelay entre requests (default: 3.0s)
--quietModo silencioso

Resolución ticker → slug

Macrotrends usa URLs con el formato /stocks/charts/{TICKER}/{SLUG}/financial-statements.

El slug se resuelve automáticamente via el search endpoint interno. Ejemplos:

TickerSlug
AAPLapple
NVDAnvidia
MSFTmicrosoft
GGALgrupo-financiero-galicia-sa
TSLAtesla

Si el search falla, se puede pasar el slug manualmente:

python scripts/fetch_financials.py --ticker GGAL --slug grupo-financiero-galicia-sa --all

Datos disponibles por statement

Income Statement (22 campos)

Revenue, COGS, Gross Profit, R&D, SG&A, Operating Income, Net Income, EBITDA, EBIT, EPS, Shares Outstanding, etc.

Balance Sheet (23 campos)

Cash, Receivables, Inventory, Total Assets, Total Liabilities, Shareholders Equity, Debt, Retained Earnings, etc.

Cash Flow (29 campos)

Net Income, Depreciation, Working Capital Changes, Capex, Free Cash Flow, Dividends, Stock Repurchases, etc.

Financial Ratios (20 ratios)

Current Ratio, Debt/Equity, Gross/Operating/Net Margins, ROE, ROA, ROI, Book Value/Share, FCF/Share, etc.

Employee Count

Año a año, empleados totales.

Ver referencia completa de campos en references/STATEMENTS_REFERENCE.md.


Cobertura de Mercados

Macrotrends cubre ~6,500 tickers que cotizan en NYSE, NASDAQ y AMEX (incluyendo ADRs).

TipoCantidadEjemplos
US Common Stocks~5,300AAPL, NVDA, MSFT
ADRs Internacionales~276+GGAL (Argentina), BABA (China), TM (Japón), PBR (Brasil), SAN (España), BP (UK)
ETFs & Fondos~91SPY, QQQ, VTI
Class A/B Shares~22BRK.A, BRK.B

Ver detalle completo de mercados, ADRs por país y cómo buscar tickers en references/MARKETS_REFERENCE.md.


Rate Limits

ComportamientoRecomendación
Requests seguidos sin delay429 Too Many Requests
Delay recomendado3 segundos entre requests
Tickers por ejecución~5-6 como máximo (para evitar bloqueo)
BackoffSi recibís 429, esperá 30-60s

Errores comunes

ErrorCausaSolución
429 Too Many RequestsRate limitAumentar --delay o esperar
slug not foundNo se pudo resolver el tickerUsar --slug manualmente
No data found for XEndpoint no disponibleVerificar que el ticker existe en Macrotrends
originalData not foundPágina cambió estructuraReportar issue

Estructura del skill

skills/macrotrends/
├── SKILL.md                              # Este archivo
├── references/
│   ├── STATEMENTS_REFERENCE.md           # Referencia de campos
│   └── MARKETS_REFERENCE.md             # Cobertura de mercados y ADRs
└── scripts/
    └── fetch_financials.py               # Script principal

Comments

Markdown supported