async-jquants-api-client 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,43 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ permissions:
7
+ contents: read
8
+
9
+ jobs:
10
+ build-test-precommit:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
16
+
17
+ steps:
18
+ - name: Checkout
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+
26
+ - name: Set up uv
27
+ uses: astral-sh/setup-uv@v3
28
+ with:
29
+ enable-cache: true
30
+
31
+ - name: Install dependencies
32
+ run: uv sync --all-extras --dev --frozen
33
+
34
+ - name: Build
35
+ run: uv build
36
+ if: matrix.python-version == '3.14'
37
+
38
+ - name: Test
39
+ run: uv run pytest
40
+
41
+ - name: Pre-commit
42
+ run: uv run pre-commit run --all-files
43
+ if: matrix.python-version == '3.14'
@@ -0,0 +1,70 @@
1
+ # This workflow will upload a Python Package to PyPI when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3
+
4
+ # This workflow uses actions that are not certified by GitHub.
5
+ # They are provided by a third-party and are governed by
6
+ # separate terms of service, privacy policy, and support
7
+ # documentation.
8
+
9
+ name: Upload Python Package
10
+
11
+ on:
12
+ release:
13
+ types: [published]
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ release-build:
20
+ runs-on: ubuntu-latest
21
+
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+
25
+ - uses: actions/setup-python@v5
26
+ with:
27
+ python-version: "3.x"
28
+
29
+ - name: Build release distributions
30
+ run: |
31
+ # NOTE: put your own distribution build steps here.
32
+ python -m pip install build
33
+ python -m build
34
+
35
+ - name: Upload distributions
36
+ uses: actions/upload-artifact@v4
37
+ with:
38
+ name: release-dists
39
+ path: dist/
40
+
41
+ pypi-publish:
42
+ runs-on: ubuntu-latest
43
+ needs:
44
+ - release-build
45
+ permissions:
46
+ # IMPORTANT: this permission is mandatory for trusted publishing
47
+ id-token: write
48
+
49
+ # Dedicated environments with protections for publishing are strongly recommended.
50
+ # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
51
+ environment:
52
+ name: pypi
53
+ # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
54
+ # url: https://pypi.org/p/YOURPROJECT
55
+ #
56
+ # ALTERNATIVE: if your GitHub Release name is the PyPI project version string
57
+ # ALTERNATIVE: exactly, uncomment the following line instead:
58
+ # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
59
+
60
+ steps:
61
+ - name: Retrieve release distributions
62
+ uses: actions/download-artifact@v4
63
+ with:
64
+ name: release-dists
65
+ path: dist/
66
+
67
+ - name: Publish release distributions to PyPI
68
+ uses: pypa/gh-action-pypi-publish@release/v1
69
+ with:
70
+ packages-dir: dist/
@@ -0,0 +1,15 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ .python-version
13
+
14
+ .pytest_cache/
15
+ .mypy_cache/
@@ -0,0 +1,15 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.9.10
4
+ hooks:
5
+ - id: ruff
6
+ args: [--fix]
7
+ - id: ruff-format
8
+
9
+ - repo: https://github.com/pre-commit/mirrors-mypy
10
+ rev: v1.15.0
11
+ hooks:
12
+ - id: mypy
13
+ additional_dependencies:
14
+ - pandas-stubs
15
+ - types-python-dateutil
@@ -0,0 +1,53 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Commands
6
+
7
+ This project uses `uv` for dependency management.
8
+
9
+ ```bash
10
+ # Install dependencies
11
+ uv sync --all-extras --dev --frozen
12
+
13
+ # Run all tests
14
+ uv run pytest
15
+
16
+ # Run a single test
17
+ uv run pytest tests/test_client.py::test_get_eq_bars_daily_returns_dataframe
18
+
19
+ # Lint and format (ruff)
20
+ uv run ruff check --fix .
21
+ uv run ruff format .
22
+
23
+ # Type check
24
+ uv run mypy src/
25
+
26
+ # Run all pre-commit checks
27
+ uv run pre-commit run --all-files
28
+
29
+ # Build
30
+ uv build
31
+ ```
32
+
33
+ ## Architecture
34
+
35
+ This is a single-file async Python client (`src/async_jquants_api_client/client.py`) wrapping the JQuants API v2. It is intentionally minimal — no abstraction layers, no base classes beyond `JQuantsClientV2`.
36
+
37
+ **Key design decisions:**
38
+
39
+ - **Rate limiting**: `aiolimiter.AsyncLimiter` is configured per `Plan` enum (FREE/LIGHT/STANDARD/PREMIUM). The limiter is held in `self._limiter` and wraps every HTTP call in `_get_with_retry`. Rate limits are `_RATE_LIMITS[plan]` requests/minute.
40
+ - **Retry logic**: `tenacity` handles 429/500/502/503/504 and network errors with exponential backoff (3 attempts max). Auth errors (401/403) raise `JQuantsAuthError` immediately without retry.
41
+ - **Pagination**: `_paginate()` is an async generator that follows `pagination_key` across pages. All `get_*` methods consume it with `[item async for item in self._paginate(...)]`.
42
+ - **Range methods**: Methods named `get_*_range()` use `asyncio.gather` to fetch all dates in the range concurrently (each date as a separate API call). This can fire many simultaneous requests — the rate limiter throttles them.
43
+ - **5/15-minute bars**: Computed client-side by aggregating 1-minute data via `_aggregate_bars_n_minute()`. The API only provides 1-minute data.
44
+ - **Cache**: `get_fin_summary_range` and `get_fin_details_range` accept `cache_dir`; files are stored as `{cache_dir}/{yyyy}/v2_{endpoint}_{yyyymmdd}.csv.gz`.
45
+ - **Config loading priority**: argument > `JQUANTS_API_KEY` env var > `JQUANTS_API_CLIENT_CONFIG_FILE` env var > `jquants-api.toml` (cwd) > `~/.jquants-api/jquants-api.toml` > Google Colab path. TOML key must be under `[jquants-api-client]`.
46
+
47
+ **Module layout:**
48
+ - `client.py` — `JQuantsClientV2` class, all API methods
49
+ - `plans.py` — `Plan` enum
50
+ - `exceptions.py` — `JQuantsError`, `JQuantsAuthError`, `JQuantsAPIError`
51
+ - `constants.py` — column name lists for each endpoint (used to define empty DataFrame schemas and enforce column ordering)
52
+
53
+ **Tests** use `pytest-httpx` (`HTTPXMock`) to intercept `httpx.AsyncClient` calls. The `conftest.py` fixture creates a `Plan.PREMIUM` client (bypasses rate limiting in tests). `asyncio_mode = "auto"` is set in `pyproject.toml` so `@pytest.mark.asyncio` is not required but still present in some tests.
@@ -0,0 +1,193 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or otherwise designated in writing by the copyright owner as
57
+ "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any Contribution
81
+ embodied within the Work constitutes direct or contributory patent
82
+ infringement, then any patent licenses granted to You under this License
83
+ for that Work shall terminate as of the date such litigation is filed.
84
+
85
+ 4. Redistribution. You may reproduce and distribute copies of the
86
+ Work or Derivative Works thereof in any medium, with or without
87
+ modifications, and in Source or Object form, provided that You
88
+ meet the following conditions:
89
+
90
+ (a) You must give any other recipients of the Work or Derivative Works
91
+ a copy of this License; and
92
+
93
+ (b) You must cause any modified files to carry prominent notices
94
+ stating that You changed the files; and
95
+
96
+ (c) You must retain, in the Source form of any Derivative Works
97
+ that You distribute, all copyright, patent, trademark, and
98
+ attribution notices from the Source form of the Work,
99
+ excluding those notices that do not pertain to any part of
100
+ the Derivative Works; and
101
+
102
+ (d) If the Work includes a "NOTICE" text file as part of its
103
+ distribution, You must include a readable copy of the attribution
104
+ notices contained within such NOTICE file, in at least one
105
+ of the following places: within a NOTICE text file distributed
106
+ as part of the Derivative Works; within the Source form or
107
+ documentation, if provided along with the Derivative Works; or,
108
+ within a display generated by the Derivative Works, if and
109
+ wherever such third-party notices normally appear. The contents
110
+ of the NOTICE file are for informational purposes only and
111
+ do not modify the License. You may add Your own attribution
112
+ notices within Derivative Works that You distribute, alongside
113
+ or as an addendum to the NOTICE text from the Work, provided
114
+ that such additional attribution notices cannot be construed
115
+ as modifying the License.
116
+
117
+ You may add Your own license statement for Your modifications and
118
+ may provide additional grant of rights to use, copy, modify, merge,
119
+ publish, distribute, sublicense, and/or sell copies of the
120
+ Contribution, either alone or with the Work, provided Your use,
121
+ reproduction, and distribution of the Work otherwise complies with
122
+ the conditions stated in this License.
123
+
124
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
125
+ any Contribution intentionally submitted for inclusion in the Work
126
+ by You to the Licensor shall be under the terms and conditions of
127
+ this License, without any additional terms or conditions.
128
+ Notwithstanding the above, nothing herein shall supersede or modify
129
+ the terms of any separate license agreement you may have executed
130
+ with Licensor regarding such Contributions.
131
+
132
+ 6. Trademarks. This License does not grant permission to use the trade
133
+ names, trademarks, service marks, or product names of the Licensor,
134
+ except as required for reasonable and customary use in describing the
135
+ origin of the Work and reproducing the content of the NOTICE file.
136
+
137
+ 7. Disclaimer of Warranty. Unless required by applicable law or
138
+ agreed to in writing, Licensor provides the Work (and each
139
+ Contributor provides its Contributions) on an "AS IS" BASIS,
140
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
141
+ implied, including, without limitation, any warranties or conditions
142
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
143
+ PARTICULAR PURPOSE. You are solely responsible for determining the
144
+ appropriateness of using or reproducing the Work and assume any
145
+ risks associated with Your exercise of permissions under this License.
146
+
147
+ 8. Limitation of Liability. In no event and under no legal theory,
148
+ whether in tort (including negligence), strict liability, or otherwise,
149
+ and unless required by applicable law (such as deliberate and grossly
150
+ negligent acts) or agreed to in writing, shall any Contributor be
151
+ liable to You for damages, including any direct, indirect, special,
152
+ incidental, or exemplary damages of any character arising as a result
153
+ of this License or out of the use or inability to use the Work
154
+ (including but not limited to damages for loss of goodwill, work
155
+ stoppage, computer failure or malfunction, or all other commercial
156
+ damages or losses), even if such Contributor has been advised of the
157
+ possibility of such damages.
158
+
159
+ 9. Accepting Warranty or Liability. While redistributing the Work or
160
+ Derivative Works thereof, You may choose to offer, and charge a fee
161
+ for, acceptance of support, warranty, indemnity, or other liability
162
+ obligations and/or rights consistent with this License. However, in
163
+ accepting such obligations, You may offer such obligations only on
164
+ Your own behalf and on Your sole responsibility, not on behalf of
165
+ any other Contributor, and only if You agree to indemnify, defend,
166
+ and hold each Contributor harmless for any liability incurred by, or
167
+ claims asserted against, such Contributor by reason of your accepting
168
+ any such warranty or additional liability.
169
+
170
+ END OF TERMS AND CONDITIONS
171
+
172
+ APPENDIX: How to apply the Apache License to your work.
173
+
174
+ To apply the Apache License to your work, attach the following
175
+ boilerplate notice, with the fields enclosed by brackets "[]"
176
+ replaced with your own identifying information. (Don't include
177
+ the brackets!) The text should be enclosed in the appropriate
178
+ comment syntax for the format in question. It may also be appropriate
179
+ to include a "legal entity" name along with the copyright notice.
180
+
181
+ Copyright 2025 getumen
182
+
183
+ Licensed under the Apache License, Version 2.0 (the "License");
184
+ you may not use this file except in compliance with the License.
185
+ You may obtain a copy of the License at
186
+
187
+ http://www.apache.org/licenses/LICENSE-2.0
188
+
189
+ Unless required by applicable law or agreed to in writing, software
190
+ distributed under the License is distributed on an "AS IS" BASIS,
191
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
192
+ See the License for the specific language governing permissions and
193
+ limitations under the License.
@@ -0,0 +1,261 @@
1
+ Metadata-Version: 2.4
2
+ Name: async-jquants-api-client
3
+ Version: 0.1.0
4
+ Summary: Async Python client for JQuants API
5
+ Project-URL: Repository, https://github.com/getumen/async-jquants-api-client
6
+ Author: getumen
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Financial and Insurance Industry
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Office/Business :: Financial
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: aiolimiter>=1.1.0
22
+ Requires-Dist: httpx>=0.23.0
23
+ Requires-Dist: pandas>=2.2.0
24
+ Requires-Dist: pyarrow>=14.0.0
25
+ Requires-Dist: tenacity>=8.2.0
26
+ Description-Content-Type: text/markdown
27
+
28
+ # async-jquants-api-client
29
+
30
+ Async Python client for [JQuants API v2](https://jpx-jquants.com/).
31
+
32
+ [jquants-api-client-python](https://github.com/J-Quants/jquants-api-client-python) の以下の点を改善したライブラリです:
33
+
34
+ - **スレッドセーフでない・`requests.Session` ベース** → `httpx` + `asyncio` による完全非同期実装
35
+ - **v2 のレートリミット未対応** → `aiolimiter` によるプラン別レートリミット対応
36
+
37
+ ## 要件
38
+
39
+ - Python 3.10+
40
+ - JQuants API キー([JQuants](https://jpx-jquants.com/) で取得)
41
+
42
+ ## インストール
43
+
44
+ ```bash
45
+ pip install async-jquants-api-client
46
+ ```
47
+
48
+ ### GitHubからの開発版インストール
49
+
50
+ ```bash
51
+ pip install git+https://github.com/getumen/async-jquants-api-client.git
52
+ ```
53
+
54
+ ## 設定
55
+
56
+ API キーは以下の優先順位で読み込まれます:
57
+
58
+ 1. コード内で直接指定
59
+ 2. 環境変数 `JQUANTS_API_KEY`
60
+ 3. 設定ファイル `jquants-api.toml`(カレントディレクトリ → `~/.jquants-api/` の順)
61
+
62
+ ### 設定ファイルの例
63
+
64
+ ```toml
65
+ [jquants-api-client]
66
+ api_key = "your_api_key_here"
67
+ ```
68
+
69
+ ## 基本的な使い方
70
+
71
+ ```python
72
+ import asyncio
73
+ from async_jquants_api_client import JQuantsClientV2, Plan
74
+
75
+ async def main():
76
+ async with JQuantsClientV2(api_key="your_api_key", plan=Plan.STANDARD) as client:
77
+ # 株価日足(1日分)
78
+ df = await client.get_eq_bars_daily(code="86970", date_yyyymmdd="2024-01-05")
79
+ print(df)
80
+
81
+ # 株価日足(期間指定、全銘柄を並列取得)
82
+ df = await client.get_eq_bars_daily_range("20240101", "20240131")
83
+ print(df)
84
+
85
+ asyncio.run(main())
86
+ ```
87
+
88
+ ## プラン別レートリミット
89
+
90
+ | プラン | リクエスト数/分 |
91
+ |--------|---------------|
92
+ | FREE | 5 |
93
+ | LIGHT | 60 |
94
+ | STANDARD | 120 |
95
+ | PREMIUM | 500 |
96
+ | fins/summary (全プラン共通) | 60 |
97
+ | fins/details (全プラン共通) | 60 |
98
+
99
+ ```python
100
+ from async_jquants_api_client import JQuantsClientV2, Plan
101
+
102
+ async with JQuantsClientV2(api_key="your_api_key", plan=Plan.PREMIUM) as client:
103
+ ...
104
+ ```
105
+
106
+ ## API リファレンス
107
+
108
+ ### 株式マスター
109
+
110
+ ```python
111
+ # 上場銘柄一覧
112
+ df = await client.get_eq_master(code="86970", date="20240105")
113
+
114
+ # 上場銘柄一覧(業種・市場区分の英語名付き)
115
+ df = await client.get_list()
116
+ ```
117
+
118
+ ### 株価
119
+
120
+ ```python
121
+ # 日足
122
+ df = await client.get_eq_bars_daily(code="86970", date_yyyymmdd="2024-01-05")
123
+ df = await client.get_eq_bars_daily(code="86970", from_yyyymmdd="20240101", to_yyyymmdd="20240131")
124
+
125
+ # 日足(日付範囲、全銘柄を並列取得)
126
+ df = await client.get_eq_bars_daily_range("20240101", "20240131")
127
+
128
+ # 前場四本値
129
+ df = await client.get_eq_bars_daily_am(code="86970")
130
+
131
+ # 分足・5分足・15分足
132
+ df = await client.get_eq_bars_minute(code="86970", date_yyyymmdd="2024-01-05")
133
+ df = await client.get_eq_bars_5minute(code="86970", date_yyyymmdd="2024-01-05")
134
+ df = await client.get_eq_bars_15minute(code="86970", date_yyyymmdd="2024-01-05")
135
+ ```
136
+
137
+ ### 財務情報
138
+
139
+ ```python
140
+ # 財務情報サマリ
141
+ df = await client.get_fin_summary(code="86970")
142
+ df = await client.get_fin_summary_range("20240101", "20240131", cache_dir="/path/to/cache")
143
+
144
+ # 財務諸表詳細
145
+ df = await client.get_fin_details(date_yyyymmdd="2024-01-05")
146
+ df = await client.get_fin_details_range("20240101", "20240131", cache_dir="/path/to/cache")
147
+
148
+ # 配当金情報
149
+ df = await client.get_fin_dividend(code="86970")
150
+
151
+ # 決算発表予定
152
+ df = await client.get_eq_earnings_cal()
153
+ ```
154
+
155
+ ### 市場統計
156
+
157
+ ```python
158
+ # 空売り比率
159
+ df = await client.get_mkt_short_ratio(date_yyyymmdd="2024-01-05")
160
+ df = await client.get_mkt_short_ratio_range("20240101", "20240131")
161
+
162
+ # 空売り残高報告
163
+ df = await client.get_mkt_short_sale_report(disclosed_date="2024-01-05")
164
+ df = await client.get_mkt_short_sale_report_range("20240101", "20240131")
165
+
166
+ # 信用取引週末残高
167
+ df = await client.get_mkt_margin_interest(date_yyyymmdd="2024-01-05")
168
+ df = await client.get_mkt_margin_interest_range("20240101", "20240131")
169
+
170
+ # 日々公表信用取引残高
171
+ df = await client.get_mkt_margin_alert(date_yyyymmdd="2024-01-05")
172
+ df = await client.get_mkt_margin_alert_range("20240101", "20240131")
173
+
174
+ # 売買内訳
175
+ df = await client.get_mkt_breakdown(date_yyyymmdd="2024-01-05")
176
+ df = await client.get_mkt_breakdown_range("20240101", "20240131")
177
+
178
+ # 取引カレンダー
179
+ df = await client.get_mkt_calendar(from_yyyymmdd="20240101", to_yyyymmdd="20240131")
180
+
181
+ # 投資部門別売買状況
182
+ df = await client.get_eq_investor_types(section="TSEPrime")
183
+ ```
184
+
185
+ ### 指数
186
+
187
+ ```python
188
+ # 指数四本値
189
+ df = await client.get_idx_bars_daily(code="0000", date_yyyymmdd="2024-01-05")
190
+
191
+ # TOPIX
192
+ df = await client.get_idx_bars_daily_topix(from_yyyymmdd="20240101", to_yyyymmdd="20240131")
193
+ ```
194
+
195
+ ### デリバティブ
196
+
197
+ ```python
198
+ # 先物四本値
199
+ df = await client.get_drv_bars_daily_fut(date_yyyymmdd="2024-01-05")
200
+ df = await client.get_drv_bars_daily_fut_range("20240101", "20240131")
201
+
202
+ # オプション四本値
203
+ df = await client.get_drv_bars_daily_opt(date_yyyymmdd="2024-01-05")
204
+ df = await client.get_drv_bars_daily_opt_range("20240101", "20240131")
205
+
206
+ # 日経225オプション四本値
207
+ df = await client.get_drv_bars_daily_opt_225(date_yyyymmdd="2024-01-05")
208
+ df = await client.get_drv_bars_daily_opt_225_range("20240101", "20240131")
209
+ ```
210
+
211
+ ### マスターデータ(ローカル)
212
+
213
+ ```python
214
+ # 17業種・33業種・市場区分(APIリクエストなし)
215
+ df = client.get_17_sectors()
216
+ df = client.get_33_sectors()
217
+ df = client.get_market_segments()
218
+ ```
219
+
220
+ ## キャッシュ
221
+
222
+ `get_fin_summary_range` と `get_fin_details_range` は `cache_dir` を指定することで日付ごとにキャッシュできます。
223
+
224
+ ```python
225
+ df = await client.get_fin_summary_range(
226
+ "20200101", "20240131",
227
+ cache_dir="/path/to/cache"
228
+ )
229
+ df = await client.get_fin_details_range(
230
+ "20200101", "20240131",
231
+ cache_dir="/path/to/cache"
232
+ )
233
+ ```
234
+
235
+ キャッシュファイルのパス形式:
236
+
237
+ | メソッド | 形式 | パス |
238
+ |---------|------|------|
239
+ | `get_fin_summary_range` | CSV.gz | `{cache_dir}/{yyyy}/v2_fin_summary_{yyyymmdd}.csv.gz` |
240
+ | `get_fin_details_range` | Parquet | `{cache_dir}/{yyyy}/v2_fin_details_{yyyymmdd}.parquet` |
241
+
242
+ ## エラーハンドリング
243
+
244
+ ```python
245
+ from async_jquants_api_client import JQuantsAuthError, JQuantsAPIError
246
+
247
+ try:
248
+ df = await client.get_eq_bars_daily(code="86970", date_yyyymmdd="2024-01-05")
249
+ except JQuantsAuthError:
250
+ # 401/403: APIキーが無効
251
+ ...
252
+ except JQuantsAPIError as e:
253
+ # その他のAPIエラー(リトライ済み)
254
+ print(e.status_code, e.message)
255
+ ```
256
+
257
+ 429/500/502/503/504 は指数バックオフで最大3回自動リトライします。
258
+
259
+ ## ライセンス
260
+
261
+ Apache License 2.0