Skip to content

Ticker

The Ticker class provides a yfinance-style API for accessing Japanese stock data.

Basic Usage

import pyjquants as pjq

ticker = pjq.Ticker("7203")  # Toyota

# Stock info (lazy-loaded)
ticker.info.name           # "トヨタ自動車"
ticker.info.sector         # "輸送用機器"

# Price history
df = ticker.history("30d")        # Recent 30 days
df = ticker.history("1y")         # Last year
df = ticker.history(start="2024-01-01", end="2024-12-31")  # Custom range

API Reference

pyjquants.domain.ticker.Ticker

Bases: DomainEntity

Stock ticker for J-Quants API (yfinance-style API).

Example

ticker = Ticker("7203") print(ticker.info.name) # トヨタ自動車 df = ticker.history(period="30d")

info property

Stock information (lazy loaded, cached).

戻り値:

タイプ デスクリプション
TickerInfo

TickerInfo object with name, sector, market, etc.

financials property

Financial statements.

financial_details property

Full financial statement data (BS/PL/CF) (Premium tier).

Provides detailed balance sheet, income statement, and cash flow data. More comprehensive than the financials property.

dividends property

Dividend history (Premium tier).

__init__(code, session=None)

Initialize ticker with stock code.

引数:

名前 タイプ デスクリプション デフォルト
code str

Stock code (e.g., "7203" for Toyota)

必須

history(period='30d', start=None, end=None)

Get price history (yfinance-style).

引数:

名前 タイプ デスクリプション デフォルト
period str | None

Time period (e.g., "30d", "1y"). Ignored if start/end provided.

'30d'
start str | date | None

Start date (YYYY-MM-DD string or date object)

None
end str | date | None

End date (YYYY-MM-DD string or date object)

None

戻り値:

タイプ デスクリプション
DataFrame

DataFrame with columns: date, open, high, low, close, volume, adjusted_close

history_am(period='30d', start=None, end=None)

Get morning session (AM) price history.

Returns prices from the morning trading session only (9:00-11:30 JST). Useful for intraday analysis or when you need morning-only prices.

引数:

名前 タイプ デスクリプション デフォルト
period str | None

Time period (e.g., "30d", "1y"). Ignored if start/end provided.

'30d'
start str | date | None

Start date (YYYY-MM-DD string or date object)

None
end str | date | None

End date (YYYY-MM-DD string or date object)

None

戻り値:

タイプ デスクリプション
DataFrame

DataFrame with columns: date, open, high, low, close, volume, adjusted_close

refresh()

Clear cached data to force fresh fetch on next access.

Module Functions

download

Download price data for multiple tickers:

df = pjq.download(["7203", "6758"], period="1y")

pyjquants.domain.ticker.download(codes, period='30d', start=None, end=None, session=None, threads=True)

Download price data for multiple tickers (yfinance-style).

引数:

名前 タイプ デスクリプション デフォルト
codes list[str]

List of stock codes

必須
period str | None

Time period (e.g., "30d", "1y")

'30d'
start str | date | None

Start date

None
end str | date | None

End date

None
session Session | None

Optional session

None
threads bool | int

Use threading for faster downloads. - True: Use optimal thread count (min of cpu_count or len(codes)) - False: Sequential download (useful for debugging) - int: Use specified number of threads

True

戻り値:

タイプ デスクリプション
DataFrame

Wide-format DataFrame with date index and columns for each ticker's close price

Example

df = pjq.download(["7203", "6758", "9984"], period="30d") df = pjq.download(["7203", "6758"], threads=False) # Sequential df = pjq.download(["7203", "6758"], threads=4) # 4 threads

Search for tickers by name or code:

tickers = pjq.search("トヨタ")

pyjquants.domain.ticker.search(query, session=None)

Search for tickers by name or code.

引数:

名前 タイプ デスクリプション デフォルト
query str

Search query (matches company name or code)

必須
session Session | None

Optional session

None

戻り値:

タイプ デスクリプション
list[Ticker]

List of matching Ticker objects

Examples

Stock Info

ticker = pjq.Ticker("7203")

print(ticker.info.code)            # "7203"
print(ticker.info.name)            # "トヨタ自動車"
print(ticker.info.name_english)    # "Toyota Motor Corporation"
print(ticker.info.sector)          # "輸送用機器"
print(ticker.info.market)          # "Prime"

Price History

# Recent 30 days (default)
df = ticker.history()

# Specific period
df = ticker.history("1y")    # 1 year
df = ticker.history("6mo")   # 6 months
df = ticker.history("30d")   # 30 days

# Custom date range
df = ticker.history(start="2024-01-01", end="2024-06-30")

# With date objects
from datetime import date
df = ticker.history(start=date(2024, 1, 1), end=date(2024, 6, 30))

Multi-Ticker Download

# Download close prices for multiple tickers
df = pjq.download(["7203", "6758", "9984"], period="1y")
print(df.head())
#         date     7203     6758     9984
# 0 2024-01-04  2530.0  1245.0  5678.0
# 1 2024-01-05  2545.0  1256.0  5690.0

Financial Data

# Financial statements (summary)
financials = ticker.financials

# Full financial details (BS/PL/CF)
details = ticker.financial_details

# Dividend history
dividends = ticker.dividends

Morning Session Prices

# Get morning session (AM) prices only
df = ticker.history_am("30d")
df = ticker.history_am(start="2024-01-01", end="2024-06-30")

Search

# Search by Japanese name
tickers = pjq.search("トヨタ")
for t in tickers:
    print(f"{t.code}: {t.info.name}")

# Search by English name
tickers = pjq.search("Toyota")

# Search by code prefix
tickers = pjq.search("72")  # All codes starting with 72