investing について
investingは、APIキーや認証なしでInvesting.comの公開ページを解析し、市場・企業データを取得するコマンドラインスキルです。HTML解析により、価格、履歴、財務諸表などを調べられます。
主な機能
- 01複数種類の金融商品の価格取得
- 02金融商品の検索とサイトマップ取得
- 03過去のOHLCVデータの取得
- 04企業概要と財務諸表の解析
- 05比率、配当、決算履歴の取得
活用シーン
- 01株式や通貨ペアの価格確認
- 02金融商品の過去価格の確認
- 03企業財務と配当履歴の調査
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ gauss314/ skills --skill investingインストール後、Claude Code で/investingを入力して読み込まれたか確認します。
同梱ファイルreferences/REFERENCE.mdscripts/fetch_investing.py
詳細
Investing.com — HTML スクレイピングによるデータ取得
公開 HTML を解析して Investing.com からデータを抽出するスキルです。API キーも認証も不要です。
⚠️ 法的および技術的な注意事項
- Investing.com は公開 API を提供していません。データは Cloudflare のボット対策が適用された HTML ページから抽出します。
- 必須の依存関係:
curl_cffi(TLS レベルで Chrome 120 になりすまします。純粋なrequestsではデータではなく Cloudflare のチャレンジが返されます)。 - 厳しいレート制限: リクエストの間隔を 1~2 秒空けてください。リクエストを短時間に多数送信すると、Cloudflare から 429/403 が返されます。スクリプトは自動バックオフで再試行します。
- 遅延データ: ページに表示される価格は、直近の利用可能な終値です(米国株式では 15~20 分遅延し、ほかの市場でも同程度です)。
- Investing.com の利用規約を遵守してください。リクエストは 1 秒あたり 1~2 回を超えないようにしてください。大規模な再配布には使用しないでください。
- Investing.com は IP 範囲をブロックする権利を留保しています。このスキルはいつでも動作しなくなる可能性があります。
スクリプト
| スクリプト | 説明 |
|---|---|
| fetch_investing.py | メインスクリプト:利用可能なすべてのモード |
依存関係のインストール
pip install curl_cffi
純粋な
requestsでは動作しません。Cloudflare に検出され、ブロックされます。
クイックスタート
# === COTIZACIONES (auto-detect tipo) ===
python scripts/fetch_investing.py quote gold
python scripts/fetch_investing.py quote eur-usd
python scripts/fetch_investing.py quote us-spx-500
python scripts/fetch_investing.py quote bitcoin
python scripts/fetch_investing.py quote ypf-sa --type equities
python scripts/fetch_investing.py quote apple-computer-inc -q
# === BUSQUEDA EN SITEMAPS ===
python scripts/fetch_investing.py search YPF
python scripts/fetch_investing.py search gold --category commodities
python scripts/fetch_investing.py search MERVAL --category indices
python scripts/fetch_investing.py search AR --category currencies --limit 30
# === SITEMAPS COMPLETOS ===
python scripts/fetch_investing.py sitemap commodities # 344 instrumentos
python scripts/fetch_investing.py sitemap currencies # 2,394 cruces
python scripts/fetch_investing.py sitemap indices # 20K+ indices
python scripts/fetch_investing.py sitemap equities # 81K+ acciones
python scripts/fetch_investing.py sitemap etfs # 30K+ ETFs
# === HISTORICO OHLCV ===
python scripts/fetch_investing.py historical gold
python scripts/fetch_investing.py historical eur-usd
python scripts/fetch_investing.py historical ypf-sa --pages 5 # ~115 dias
python scripts/fetch_investing.py historical apple-computer-inc
# === FUNDAMENTALS ===
python scripts/fetch_investing.py profile apple-computer-inc
python scripts/fetch_investing.py financials apple-computer-inc --ftype income
python scripts/fetch_investing.py financials apple-computer-inc --ftype balance
python scripts/fetch_investing.py financials apple-computer-inc --ftype cashflow
python scripts/fetch_investing.py ratios apple-computer-inc
python scripts/fetch_investing.py dividends apple-computer-inc
python scripts/fetch_investing.py earnings apple-computer-inc
# === GUARDAR A ARCHIVO ===
python scripts/fetch_investing.py quote gold -o gold_quote.json
python scripts/fetch_investing.py historical ypf-sa -o ypf_hist.json
# === MODO SILENCIOSO (solo JSON, sin logs) ===
python scripts/fetch_investing.py quote gold -q
利用可能なモード
| モード | データ | エンドポイント |
|---|---|---|
quote | 相場(価格、変動、OHLC、出来高、pair_id) | www.investing.com/{type}/{slug} |
search | 公開サイトマップを対象にしたあいまい検索 | Sitemap XMLs |
sitemap | サイトマップ全体をダウンロード(金融商品の URL) | Sitemap XMLs |
historical | HTML テーブルから取得する OHLCV の履歴 | /{type}/{slug}-historical-data |
profile | 説明、セクター、業種、国、本社、従業員数 | /{type}/{slug}-company-profile |
financials | 損益計算書/貸借対照表/キャッシュフロー(TTM+直近 5 年) | /{type}/{slug}-income-statement etc. |
ratios | 利益率、リターン、バリュエーション比率 | /{type}/{slug}-ratios |
dividends | 配当履歴全体 | /{type}/{slug}-dividends |
earnings | 決算履歴(実際の EPS と予想 EPS) | /{type}/{slug}-earnings |
金融商品の種類
| 種類 | --type | スラッグの例 | 対象数 |
|---|---|---|---|
| 株式(普通株/ADR) | equities | apple-computer-inc、ypf-sa、ggal | 81,518 |
| コモディティ | commodities | gold、crude-oil、brent-oil | 344 |
| 指数 | indices | us-spx-500、ibovespa、dax | 20,000+ |
| 通貨ペア(FX) | currencies | eur-usd、usd-ars、brl-usd | 2,394 |
| ETF | etfs | spdr-s-p-500、vanguard-ftse-all-world | 30,000+ |
| 暗号資産 | crypto | bitcoin、ethereum | 4,135+ コイン、20K+ ペア |
| 金利/債券 | rates-bonds | (サイトマップに直接掲載されていません) | 20,000+ |
| ファンド | funds | (サイトマップに直接掲載されていません) | 100K+ |
| 証明書 | certificates | (サイトマップに直接掲載されていません) | 6,222 |
自動検出:
--typeを指定しない場合、スクリプトは commodities → currencies → indices → etfs → crypto → equities の順に試します。株式は最も遅く、レート制限も厳しいため、最後に試します。
便利なスラッグ(アルゼンチン/ラテンアメリカ)
| Slug | 名前 | シンボル | 種類 |
|---|---|---|---|
ypf-sa | YPF Sociedad Anonima | YPF | equities |
ypf-sociedad | YPF Sociedad(バリエーション) | YPF | equities |
pampa-energia | Pampa Energia SA | PAMPm | equities |
pampa-energia-sa | Pampa Energia ADR | PAM | equities |
central-puerto | Central Puerto S.A. | CEPUm | equities |
central-puerto-adr | Central Puerto ADR | CEPU | equities |
tenaris | Tenaris SA | TENR | equities |
tenaris-sa | Tenaris ADR | TS | equities |
bbva | Banco Bilbao Vizcaya Argentaria | BBVA | equities |
banco-macro-sa | Banco Macro SA | BMA | equities |
mercadolibre | MercadoLibre | MELI | equities |
mercadolibre-inc | MercadoLibre Inc | MELI | equities |
globant-sa | Globant SA | GLOB | equities |
globant-cedear | Globant CEDEAR | GLOBm | equities |
despegar-com | Despegar | DESP | equities |
despegar-ba | Despegar Buenos Aires | DESPm | equities |
galicia-b | Grupo Financiero Galicia(BA) | GGALm | equities |
grupo-financiero-galicia-sa-adr | Grupo Financiero Galicia ADR | GGAL | equities |
edenor | Edenor | EDNm | equities |
transportadora-de-gas-del-sur-sa | TGS SA | TGSm | equities |
siderar | Ternium / Siderar | TXR | equities |
aluar | Aluar | ALUA | equities |
mirgor | Mirgor | MIRG | equities |
loma-negra | Loma Negra | LOMA | equities |
cresud | Cresud | CRESY | equities |
transener | Transener | TRAN | equities |
capex | Capex | CAPX | equities |
solvay | Solvay | SOLB | equities |
holcim | Holcim | HCMLY | equities |
consultatio-s. | Consultatio | CONO | equities |
garovaglio | Garovaglio | GCLA | equities |
laboratorios-richmond | Laboratorios Richmond | RICH | equities |
longvie | Longvie | LONG | equities |
rigolleau | Rigolleau | RIGO | equities |
通貨(FX)
| Slug | 通貨ペア | 備考 |
|---|---|---|
usd-ars | USD/ARS(公式) | 公式ドル |
eur-usd | EUR/USD | 主要通貨ペア |
brl-usd | BRL/USD(公式) | ブラジルの公式ドル |
mxn-usd | MXN/USD(公式) | メキシコペソ |
ars-brl | ARS/BRL | アルゼンチンペソ対レアル |
ars-mxn | ARS/MXN | アルゼンチンペソ対メキシコペソ |
aed-ars | AED/ARS | ディルハム → ペソ |
MEP / CCL / Blue: Investing.com では、これらの派生通貨ペアは公開されていません。MEP/CCL/blue については、対応している data912 を使用してください。
返されるデータ
quote
{
"last": "4,501.47", // precio formateado (con separadores)
"last_raw": 4501.47, // precio como float
"change": -0.78, // cambio absoluto vs last_close
"change_pct": -0.02, // (no siempre presente)
"last_close": 4502.25, // (no siempre presente)
"bid": 4500.74, // bid (commodities, currencies)
"ask": 4501.19, // ask
"open": 4502.5, // apertura del dia
"high": 4508.75, // maximo del dia
"low": 4499.97, // minimo del dia
"volume": 1633, // volumen
"avg_volume": 0, // volumen promedio
"prev_close": null, // cierre anterior
"pair_id": 1057391, // ID interno de investing.com
"name": "Gold Futures", // nombre completo
"symbol": "GC", // ticker
"currency": "USD", // moneda
"exchange": null, // exchange
"country": null, // pais
"updated_epoch": 1749091200, // timestamp ultima actualizacion
"page_title": "Gold Futures - Investing.com",
"slug": "gold",
"type": "commodities",
"url": "https://www.investing.com/commodities/gold"
}
注: すべての銘柄ですべてのフィールドが表示されるわけではありません。株式では通常、
last、last_raw、change、bid、ask、open、high、low、volume、prev_close、pair_id、name、symbol、currency、exchangeが含まれます。コモディティには、さらにupdated_epochが含まれることがあります。
historical
{
"slug": "gold",
"type": "commodities",
"count": 23,
"rows": [
{
"date": "Jun 04, 2026",
"price": "4,497.70",
"open": "4,481.76",
"high": "4,543.12",
"low": "4,470.55",
"vol": "3.16K",
"change_pct": "+0.69%"
},
...
]
}
デフォルトでは23日分(1ページ)です。約115日分などを取得するには、
--pages 5を使用してください。
financials
期間(TTM、2024、2023、2022、2021、2020)と、ラベルおよび値を含む行で構成されるデータを返します。
{
"slug": "apple-computer-inc",
"type": "equities",
"ftype": "income",
"periods": ["TTM", "2024", "2023", "2022", "2021", "2020"],
"count": 23,
"rows": [
{"label": "Total Revenue", "values": ["394,328", "385,100", "383,285", "394,328", "365,817", "274,515"]},
{"label": "Gross Profit", "values": ["170,000", ...]},
...
]
}
--ftype income|balance|cashflow
ratios
financials と同じ構造ですが、各種比率(利益率、リターン、バリュエーションなど)が含まれます。
dividends
セル(日時、配当、利回りなど)を含む行の配列です。
{
"slug": "apple-computer-inc",
"type": "equities",
"count": 18,
"rows": [
["Ex-Dividend Date", "May 09, 2025", "Quarterly", "0.26", "..."],
...
]
}
earnings
行(日時、実績EPS、予想EPS、サプライズなど)の配列です。
{
"slug": "apple-computer-inc",
"type": "equities",
"count": 20,
"rows": [
["Aug 01, 2024", "Q3 2024", "1.40", "1.35", "+3.70%", "..."],
...
]
}
技術的な考慮事項
requests ではなく curl_cffi を使う理由
Investing.com は、TLS レベルのボット対策保護に Cloudflare を使用しています。User-Agent は関係ありません。Cloudflare はTLS フィンガープリンティングを行い、実際のブラウザーではないクライアントを拒否します。
requests(純粋な Python、Python urllib3 の TLS フィンガープリント):ブロックされ、チャレンジ HTML が返されます。curl_cffi.requests.Session(impersonate="chrome120"):Chrome 120 の TLS フィンガープリントを偽装するため、チャレンジを通過します。
curl_cffi は curl-impersonate(フィンガープリントがあらかじめ読み込まれた libcurl のフォーク)のラッパーです。Windows/Mac/Linux 用のコンパイル済み wheel が提供されているライブラリなので、コンパイルせずにインストールして使用できます。
レート制限と Cloudflare
Cloudflare は厳しいレート制限を適用します。
- /equities/ は最もレート制限が厳しいパスです(リクエスト数が多く、保護も強力です)。
- /commodities/、/currencies/、/indices/ はより制限が緩やかです。
- 数秒間に 10 件以上リクエストすると、429 または「Just a moment...」を伴う 403 が返されます。
- 推奨されるバックオフ:リクエスト間に 2~3 秒
- 429 を受け取った場合は、1~2 分待ってください。
スクリプトでは、リトライと指数バックオフでこの問題に対処します。IP が強くマークされている場合、唯一の解決策は待つか、住宅用プロキシを使用することです。
タイプの自動検出
--type が指定されていない場合、スクリプトは 6 つのパスを 1 つずつ試します。これにより 6 件のリクエストが発生し、レート制限にかかる可能性があります。推奨: 分かっている場合は、必ず --type を指定してください。
試行順(速いものから):
commodities(344 銘柄)currencies(2,394)indices(20K+)etfs(30K+)crypto(4K+)equities(81K+、レート制限あり)
サイトマップ
サイトマップは完全に公開されており、レート制限もない唯一の情報源です。次の用途に役立ちます。
- 銘柄のスラッグを見つける(公開されている「search」API はありません)
- ローカルカタログを作成する
- 上場銘柄のバックアップを作成する
サイトマップごとの銘柄数(2026-06-04 確認):
- equities:81,518(9 ファイル)
- commodities:344(1 ファイル)
- indices:20,000+(2 ファイル)
- currencies:2,394(2 ファイル)
- etfs:30,000+(3 ファイル)
- crypto coins:4,135
- crypto pairs:20,000+(2 ファイル)
- rates/bonds:20,000+(2 ファイル)
- funds:100K+(11 ファイル)
- certificates:6,222
制限事項
- 厳しいレート制限: 頻繁に使用すると、CF によって IP がブロックされることがあります。これはサイト側の問題であり、スクリプトの問題ではありません。
- Cloudflare はチャレンジを変更することで、いつでもこのスキルを動作しなくする可能性があります。
- 履歴データはページ分割されています: デフォルトでは 23 日分です。それ以上取得するには
--pagesを指定する必要があります。
スキルの構成
skills/investing/
├── SKILL.md # Este archivo (guia rapida)
├── references/
│ └── REFERENCE.md # Documentacion completa + endpoints
└── scripts/
└── fetch_investing.py # Script principal
詳細なドキュメント: エンドポイント、JSON 構造、使用例、トラブルシューティングの詳細については、references/REFERENCE.md を参照してください。