async-jquants-api-client
Async Python client for JQuants API v2.
jquants-api-client-python の以下の点を改善したライブラリです:
- スレッドセーフでない・
requests.Sessionベース →httpx+asyncioによる完全非同期実装 - v2 のレートリミット未対応 →
aiolimiterによるプラン別レートリミット対応
要件
- Python 3.10+
- JQuants API キー(JQuants で取得)
インストール
pip install async-jquants-api-client
GitHubからの開発版インストール
pip install git+https://github.com/getumen/async-jquants-api-client.git
設定
API キーは以下の優先順位で読み込まれます:
- コード内で直接指定
- 環境変数
JQUANTS_API_KEY - 設定ファイル
jquants-api.toml(カレントディレクトリ →~/.jquants-api/の順)
設定ファイルの例
[jquants-api-client]
api_key = "your_api_key_here"
基本的な使い方
import asyncio
from async_jquants_api_client import JQuantsClientV2, Plan
async def main():
async with JQuantsClientV2(api_key="your_api_key", plan=Plan.STANDARD) as client:
# 株価日足(1日分)
df = await client.get_eq_bars_daily(code="86970", date_yyyymmdd="2024-01-05")
print(df)
# 株価日足(期間指定、全銘柄を並列取得)
df = await client.get_eq_bars_daily_range("20240101", "20240131")
print(df)
asyncio.run(main())
プラン別レートリミット
| プラン | リクエスト数/分 |
|---|---|
| FREE | 5 |
| LIGHT | 60 |
| STANDARD | 120 |
| PREMIUM | 500 |
| fins/summary (全プラン共通) | 60 |
| fins/details (全プラン共通) | 60 |
from async_jquants_api_client import JQuantsClientV2, Plan
async with JQuantsClientV2(api_key="your_api_key", plan=Plan.PREMIUM) as client:
...
API リファレンス
株式マスター
# 上場銘柄一覧
df = await client.get_eq_master(code="86970", date="20240105")
# 上場銘柄一覧(業種・市場区分の英語名付き)
df = await client.get_list()
株価
# 日足
df = await client.get_eq_bars_daily(code="86970", date_yyyymmdd="2024-01-05")
df = await client.get_eq_bars_daily(code="86970", from_yyyymmdd="20240101", to_yyyymmdd="20240131")
# 日足(日付範囲、全銘柄を並列取得)
df = await client.get_eq_bars_daily_range("20240101", "20240131")
# 前場四本値
df = await client.get_eq_bars_daily_am(code="86970")
# 分足・5分足・15分足
df = await client.get_eq_bars_minute(code="86970", date_yyyymmdd="2024-01-05")
df = await client.get_eq_bars_5minute(code="86970", date_yyyymmdd="2024-01-05")
df = await client.get_eq_bars_15minute(code="86970", date_yyyymmdd="2024-01-05")
# バリュエーション指標 (EPS, BPS, PER, PBR, ROE 等)
df = await client.get_eq_valuation(code="86970", date_yyyymmdd="2024-01-05")
df = await client.get_eq_valuation_range("20240101", "20240131", cache_dir="/path/to/cache")
財務情報
# 財務情報サマリ
df = await client.get_fin_summary(code="86970")
df = await client.get_fin_summary_range("20240101", "20240131", cache_dir="/path/to/cache")
# 財務諸表詳細
df = await client.get_fin_details(date_yyyymmdd="2024-01-05")
df = await client.get_fin_details_range("20240101", "20240131", cache_dir="/path/to/cache")
# 配当金情報
df = await client.get_fin_dividend(code="86970")
# 決算発表予定
df = await client.get_eq_earnings_cal()
市場統計
# 空売り比率
df = await client.get_mkt_short_ratio(date_yyyymmdd="2024-01-05")
df = await client.get_mkt_short_ratio_range("20240101", "20240131")
# 空売り残高報告
df = await client.get_mkt_short_sale_report(disclosed_date="2024-01-05")
df = await client.get_mkt_short_sale_report_range("20240101", "20240131")
# 信用取引週末残高
df = await client.get_mkt_margin_interest(date_yyyymmdd="2024-01-05")
df = await client.get_mkt_margin_interest_range("20240101", "20240131")
# 日々公表信用取引残高
df = await client.get_mkt_margin_alert(date_yyyymmdd="2024-01-05")
df = await client.get_mkt_margin_alert_range("20240101", "20240131")
# 売買内訳
df = await client.get_mkt_breakdown(date_yyyymmdd="2024-01-05")
df = await client.get_mkt_breakdown_range("20240101", "20240131")
# 取引カレンダー
df = await client.get_mkt_calendar(from_yyyymmdd="20240101", to_yyyymmdd="20240131")
# 投資部門別売買状況
df = await client.get_eq_investor_types(section="TSEPrime")
EDINET
# 大株主状況
df = await client.get_edinet_major_shareholders(code="86970")
df = await client.get_edinet_major_shareholders_range("20240101", "20240131")
# 政策保有株式
df = await client.get_edinet_cross_shareholdings(code="86970")
df = await client.get_edinet_cross_shareholdings_range("20240101", "20240131")
# 大量保有報告書
df = await client.get_edinet_large_volume_shareholders(code="86970")
df = await client.get_edinet_large_volume_shareholders_range("20240101", "20240131")
指数
# 指数四本値
df = await client.get_idx_bars_daily(code="0000", date_yyyymmdd="2024-01-05")
# TOPIX
df = await client.get_idx_bars_daily_topix(from_yyyymmdd="20240101", to_yyyymmdd="20240131")
デリバティブ
# 先物四本値
df = await client.get_drv_bars_daily_fut(date_yyyymmdd="2024-01-05")
df = await client.get_drv_bars_daily_fut_range("20240101", "20240131")
# オプション四本値
df = await client.get_drv_bars_daily_opt(date_yyyymmdd="2024-01-05")
df = await client.get_drv_bars_daily_opt_range("20240101", "20240131")
# 日経225オプション四本値
df = await client.get_drv_bars_daily_opt_225(date_yyyymmdd="2024-01-05")
df = await client.get_drv_bars_daily_opt_225_range("20240101", "20240131")
マスターデータ(ローカル)
# 17業種・33業種・市場区分(APIリクエストなし)
df = client.get_17_sectors()
df = client.get_33_sectors()
df = client.get_market_segments()
キャッシュ
get_fin_summary_range と get_fin_details_range は cache_dir を指定することで日付ごとにキャッシュできます。
df = await client.get_fin_summary_range(
"20200101", "20240131",
cache_dir="/path/to/cache"
)
df = await client.get_fin_details_range(
"20200101", "20240131",
cache_dir="/path/to/cache"
)
キャッシュファイルのパス形式:
| メソッド | 形式 | パス |
|---|---|---|
get_fin_summary_range |
CSV.gz | {cache_dir}/{yyyy}/v2_fin_summary_{yyyymmdd}.csv.gz |
get_fin_details_range |
Parquet | {cache_dir}/{yyyy}/v2_fin_details_{yyyymmdd}.parquet |
エラーハンドリング
from async_jquants_api_client import JQuantsAuthError, JQuantsAPIError
try:
df = await client.get_eq_bars_daily(code="86970", date_yyyymmdd="2024-01-05")
except JQuantsAuthError:
# 401/403: APIキーが無効
...
except JQuantsAPIError as e:
# その他のAPIエラー(リトライ済み)
print(e.status_code, e.message)
429/500/502/503/504 は指数バックオフで最大3回自動リトライします。
ライセンス
Apache License 2.0
Metadata
Release files for async-jquants-api-client 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| async_jquants_api_client-0.6.0.tar.gz | 99.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| async_jquants_api_client-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 125.4 kB
Release files / async_jquants_api_client-0.6.0.tar.gz
| Download URL | async_jquants_api_client-0.6.0.tar.gz |
|---|---|
| Size | 99.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d462f3a957774397d15ea6d6499616b9570bf1d581c8ef852a19a0a183601b01
|
|
BLAKE2b-256 checksum How to use checksums |
20b964afea05b45a82ea76ce0473267a78f84e628258430502f3914cd9fdaf55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logRelease files / async_jquants_api_client-0.6.0-py3-none-any.whl
| Download URL | async_jquants_api_client-0.6.0-py3-none-any.whl |
|---|---|
| Size | 26.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e14e063638491c68e0810c19be2f668a37eab5731b32e6e41a8115b3a2c730b5
|
|
BLAKE2b-256 checksum How to use checksums |
cc6a981c7d03467181d9148c9c19cc621107d84916994d1763ad0c4f3913fffa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logSecurity for async-jquants-api-client 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for async_jquants_api_client-0.6.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.