Skip to content

Search Guide

pykabutan provides functions to search for stocks by industry or theme.

Search by Industry

Find stocks in a specific industry:

import pykabutan as pk

# Search electronics industry
results = pk.search_by_industry("電気機器")

print(f"Found {len(results)} stocks")
for t in results[:5]:
    print(f"{t.code}: {t.profile.name}")

Available Industries

Japan has 33 standard industry classifications. List them with:

industries = pk.list_industries()
for industry in industries:
    print(industry)

Common industries include:

Japanese English
電気機器 Electronics
輸送用機器 Transportation Equipment
情報・通信業 Information & Communication
銀行業 Banking
医薬品 Pharmaceuticals
小売業 Retail
サービス業 Services
化学 Chemicals
機械 Machinery
建設業 Construction

Filter by Market

# Prime market only
results = pk.search_by_industry("電気機器", market="Prime")

# Standard market only
results = pk.search_by_industry("電気機器", market="Standard")

# Growth market only
results = pk.search_by_industry("電気機器", market="Growth")

Market options:

Value Description
"Prime" or "東証P" Tokyo Stock Exchange Prime
"Standard" or "東証S" Tokyo Stock Exchange Standard
"Growth" or "東証G" Tokyo Stock Exchange Growth

Search by Theme

Find stocks related to a specific theme or keyword:

# Search for AI-related stocks
results = pk.search_by_theme("人工知能")

# Search for EV-related stocks
results = pk.search_by_theme("EV関連")

# Search for semiconductor stocks
results = pk.search_by_theme("半導体")

Theme must be Japanese

theme must be a Japanese term. English terms like "AI" won't match and return an empty list rather than raising an error.

Filter by Market

# Prime market only
results = pk.search_by_theme("人工知能", market="Prime")

Return Value

Both search functions return a list of Ticker objects:

results = pk.search_by_industry("電気機器")

for t in results[:5]:
    print(t.code)          # Stock code (no HTTP request)
    print(t.profile.name)  # Company name (HTTP request)

Accessing Profile Data

results = pk.search_by_industry("電気機器")

# Each result is a Ticker object
ticker = results[0]

# Access full profile (triggers HTTP request)
print(ticker.profile.name)
print(ticker.profile.per)
print(ticker.profile.market)

Error Handling

# Invalid industry raises ValueError
try:
    results = pk.search_by_industry("invalid_industry")
except ValueError as e:
    print(e)
    # "Unknown industry: invalid_industry. Available: ..."

Rate Limiting

Search functions respect the configured rate limit:

# Increase delay between requests if needed
pk.config.request_delay = 1.0

# Then perform searches
results1 = pk.search_by_industry("電気機器")
results2 = pk.search_by_industry("銀行業")  # Waits 1 second before request