Skip to main content

A clean, beginner-friendly Python library for scraping kabutan.jp

Project description

pykabutan

A clean, beginner-friendly Python library for scraping kabutan.jp (Japanese stock information site).

PyPI version Python versions License Documentation Open In Colab

Installation

pip install pykabutan

Quick Start

import pykabutan as pk

# Get stock information
ticker = pk.Ticker("7203")  # Toyota
print(ticker.profile.name)      # トヨタ自動車
print(ticker.profile.market)    # 東証P
print(ticker.profile.per)       # 10.5

# Get price history (yfinance-style), indexed by date
df = ticker.history(period="30d")
print(df)

# Get financial statements (dict of DataFrames, values in 百万円)
financials = ticker.financials()
print(financials["annual"])

# Search by industry
results = pk.search_by_industry("電気機器")
for t in results[:5]:
    print(t.code, t.profile.name)

# Search by theme (Japanese terms only)
results = pk.search_by_theme("人工知能")

Features

  • Simple, yfinance-style API
  • Lazy loading for performance
  • Works out of the box with sensible defaults
  • No Selenium dependency (lightweight)

What's New in 0.2.0

  • Real financials(): parses the finance page into a dict of DataFrames (annual, interim, quarterly, cashflow, profitability, financial_position, records), values in 百万円 (millions of yen).
  • Calendar-accurate history() periods: period="30d" / "6mo" / "1y" now mean actual calendar time, not a row count.
  • Connection reuse + retries: HTTP requests share a pooled requests session with automatic retries on transient errors (429/500/502/503).
  • ScrapingError: raised (with a .what attribute) when kabutan.jp's page structure changes and a page can't be parsed.

Development

# Install dependencies
uv sync

# Run tests
uv run pytest

# Run integration tests (real HTTP)
uv run pytest -m integration

# Format code
uv run ruff format .

# Lint
uv run ruff check .

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykabutan-0.2.0.tar.gz (435.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pykabutan-0.2.0-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file pykabutan-0.2.0.tar.gz.

File metadata

  • Download URL: pykabutan-0.2.0.tar.gz
  • Upload date:
  • Size: 435.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for pykabutan-0.2.0.tar.gz
Algorithm Hash digest
SHA256 496da5ee3e435b0b50600f48b45d450546d4e6cac0890eeb5911fa744aa2a4b1
MD5 1371d44faf3d823c3c1e2e4e8198a6f6
BLAKE2b-256 3227093b6490cb21ef643b6820941e6feab8fb525a57c89335ccd8a2bcf62205

See more details on using hashes here.

File details

Details for the file pykabutan-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pykabutan-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for pykabutan-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f9d0014092e9c96cf490e7f2dc45a9b3c114b2cd5e39f3946f37afc347eaa91
MD5 7a84e2e8bca09a1ab616b844e720e050
BLAKE2b-256 9ab97eab4fb05eb0f437d46dd418421b704b47be46386f1cbf60a48a0e65a6c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page