kabukit 0.7.6__tar.gz → 0.8.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.
- kabukit-0.8.0/PKG-INFO +110 -0
- kabukit-0.8.0/README.md +50 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/pyproject.toml +11 -4
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/__init__.py +2 -4
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/cli/auth.py +1 -1
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/cli/cache.py +13 -1
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/cli/get.py +39 -57
- kabukit-0.7.6/src/kabukit/core/list.py → kabukit-0.8.0/src/kabukit/core/documents.py +1 -1
- kabukit-0.8.0/src/kabukit/edinet/__init__.py +3 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/edinet/client.py +20 -3
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/edinet/concurrent.py +6 -6
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/edinet/doc.py +3 -2
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/jquants/info.py +1 -0
- kabukit-0.7.6/PKG-INFO +0 -260
- kabukit-0.7.6/README.md +0 -200
- kabukit-0.7.6/src/kabukit/core/reports.py +0 -7
- kabukit-0.7.6/src/kabukit/edinet/__init__.py +0 -3
- {kabukit-0.7.6 → kabukit-0.8.0}/LICENSE +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/analysis/__init__.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/analysis/indicators.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/analysis/preprocess.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/analysis/screener.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/analysis/visualization/__init__.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/analysis/visualization/market.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/analysis/visualization/prices.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/cli/__init__.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/cli/app.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/core/__init__.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/core/base.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/core/client.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/core/info.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/core/prices.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/core/statements.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/jquants/__init__.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/jquants/calendar.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/jquants/client.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/jquants/concurrent.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/jquants/prices.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/jquants/schema.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/jquants/statements.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/jquants/topix.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/py.typed +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/utils/__init__.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/utils/concurrent.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/utils/config.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/utils/date.py +0 -0
- {kabukit-0.7.6 → kabukit-0.8.0}/src/kabukit/utils/params.py +0 -0
kabukit-0.8.0/PKG-INFO
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: kabukit
|
3
|
+
Version: 0.8.0
|
4
|
+
Summary: A Python toolkit for Japanese financial market data, supporting J-Quants and EDINET APIs.
|
5
|
+
Keywords: J-Quants,EDINET,financial data,stock market,investment,toolkit,finance,trading,data analysis,polars
|
6
|
+
Author: daizutabi
|
7
|
+
Author-email: daizutabi <daizutabi@gmail.com>
|
8
|
+
License: MIT License
|
9
|
+
|
10
|
+
Copyright (c) 2025 Daizu
|
11
|
+
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
14
|
+
in the Software without restriction, including without limitation the rights
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
17
|
+
furnished to do so, subject to the following conditions:
|
18
|
+
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
20
|
+
copies or substantial portions of the Software.
|
21
|
+
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
28
|
+
SOFTWARE.
|
29
|
+
Classifier: Development Status :: 4 - Beta
|
30
|
+
Classifier: Programming Language :: Python
|
31
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
32
|
+
Classifier: Programming Language :: Python :: 3.13
|
33
|
+
Classifier: Programming Language :: Python :: 3.14
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
35
|
+
Classifier: Operating System :: OS Independent
|
36
|
+
Classifier: Intended Audience :: Developers
|
37
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
38
|
+
Classifier: Intended Audience :: Science/Research
|
39
|
+
Classifier: Topic :: Office/Business :: Financial
|
40
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
41
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
42
|
+
Classifier: Topic :: Utilities
|
43
|
+
Requires-Dist: async-typer>=0.1.10
|
44
|
+
Requires-Dist: httpx>=0.28.1
|
45
|
+
Requires-Dist: platformdirs>=4.5.0
|
46
|
+
Requires-Dist: polars>=1.34.0
|
47
|
+
Requires-Dist: python-dotenv>=1.1.1
|
48
|
+
Requires-Dist: rich>=14.2.0
|
49
|
+
Requires-Dist: tenacity>=9.1.2
|
50
|
+
Requires-Dist: tqdm>=4.67.1
|
51
|
+
Requires-Dist: typer>=0.19.2
|
52
|
+
Requires-Dist: tzdata ; sys_platform == 'win32'
|
53
|
+
Requires-Python: >=3.13
|
54
|
+
Project-URL: Changelog, https://github.com/daizutabi/kabukit/releases
|
55
|
+
Project-URL: Documentation, https://daizutabi.github.io/kabukit/
|
56
|
+
Project-URL: Homepage, https://daizutabi.github.io/kabukit/
|
57
|
+
Project-URL: Issues, https://github.com/daizutabi/kabukit/issues
|
58
|
+
Project-URL: Source, https://github.com/daizutabi/kabukit
|
59
|
+
Description-Content-Type: text/markdown
|
60
|
+
|
61
|
+
# kabukit
|
62
|
+
|
63
|
+
[![PyPI Version][pypi-v-image]][pypi-v-link]
|
64
|
+
[![Python Version][python-v-image]][python-v-link]
|
65
|
+
[![Build Status][GHAction-image]][GHAction-link]
|
66
|
+
[![Coverage Status][codecov-image]][codecov-link]
|
67
|
+
[![Documentation Status][docs-image]][docs-link]
|
68
|
+
|
69
|
+
A Python toolkit for Japanese financial market data,
|
70
|
+
supporting J-Quants and EDINET APIs.
|
71
|
+
|
72
|
+
kabukit は、 [J-Quants API](https://jpx-jquants.com/) および [EDINET API](https://disclosure2dl.edinet-fsa.go.jp/guide/static/disclosure/WZEK0110.html) から、効率的に日本の金融市場データを取得するツールキットです。
|
73
|
+
|
74
|
+
高速なデータ処理ライブラリである [Polars](https://pola.rs/) と、モダンな非同期 HTTP クライアントである [httpx](https://www.python-httpx.org/) を基盤として構築されており、パフォーマンスを重視しています。
|
75
|
+
|
76
|
+
## インストール
|
77
|
+
|
78
|
+
`pip` または `uv` を使ってインストールします。Python バージョンは 3.13 以上が必要です。
|
79
|
+
|
80
|
+
```bash
|
81
|
+
pip install kabukit
|
82
|
+
```
|
83
|
+
|
84
|
+
## コマンドラインから使う
|
85
|
+
|
86
|
+
kabukit は、 [J-Quants API](https://jpx-jquants.com/) および [EDINET API](https://disclosure2dl.edinet-fsa.go.jp/guide/static/disclosure/WZEK0110.html) からデータを取得するための便利なコマンドラインインターフェース(CLI)を提供します。
|
87
|
+
|
88
|
+
詳しい使い方は、[**コマンドラインインターフェースの使い方**](https://daizutabi.github.io/kabukit/guides/cli/)を参照してください。
|
89
|
+
|
90
|
+
## ノートブックから使う
|
91
|
+
|
92
|
+
kabukit は、コマンドラインだけでなく、Python コードからも API として利用できます。httpx を使って非同期でデータを取得するため、[Jupyter](https://jupyter.org/) や [marimo](https://marimo.io/) のような非同期処理を直接扱えるノートブック環境と非常に相性が良いです。
|
93
|
+
|
94
|
+
具体的な使い方は、以下の利用ガイドを参照してください。
|
95
|
+
|
96
|
+
- [**J-Quants API 利用ガイド**](https://daizutabi.github.io/kabukit/guides/jquants/)
|
97
|
+
- [**EDINET API 利用ガイド**](https://daizutabi.github.io/kabukit/guides/edinet/)
|
98
|
+
|
99
|
+
<!-- Badges -->
|
100
|
+
|
101
|
+
[pypi-v-image]: https://img.shields.io/pypi/v/kabukit.svg
|
102
|
+
[pypi-v-link]: https://pypi.org/project/kabukit/
|
103
|
+
[python-v-image]: https://img.shields.io/pypi/pyversions/kabukit.svg
|
104
|
+
[python-v-link]: https://pypi.org/project/kabukit
|
105
|
+
[GHAction-image]: https://github.com/daizutabi/kabukit/actions/workflows/ci.yaml/badge.svg?branch=main&event=push
|
106
|
+
[GHAction-link]: https://github.com/daizutabi/kabukit/actions?query=event%3Apush+branch%3Amain
|
107
|
+
[codecov-image]: https://codecov.io/github/daizutabi/kabukit/graph/badge.svg?token=Yu6lAdVVnd
|
108
|
+
[codecov-link]: https://codecov.io/github/daizutabi/kabukit?branch=main
|
109
|
+
[docs-image]: https://img.shields.io/badge/docs-latest-blue.svg
|
110
|
+
[docs-link]: https://daizutabi.github.io/kabukit/
|
kabukit-0.8.0/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# kabukit
|
2
|
+
|
3
|
+
[![PyPI Version][pypi-v-image]][pypi-v-link]
|
4
|
+
[![Python Version][python-v-image]][python-v-link]
|
5
|
+
[![Build Status][GHAction-image]][GHAction-link]
|
6
|
+
[![Coverage Status][codecov-image]][codecov-link]
|
7
|
+
[![Documentation Status][docs-image]][docs-link]
|
8
|
+
|
9
|
+
A Python toolkit for Japanese financial market data,
|
10
|
+
supporting J-Quants and EDINET APIs.
|
11
|
+
|
12
|
+
kabukit は、 [J-Quants API](https://jpx-jquants.com/) および [EDINET API](https://disclosure2dl.edinet-fsa.go.jp/guide/static/disclosure/WZEK0110.html) から、効率的に日本の金融市場データを取得するツールキットです。
|
13
|
+
|
14
|
+
高速なデータ処理ライブラリである [Polars](https://pola.rs/) と、モダンな非同期 HTTP クライアントである [httpx](https://www.python-httpx.org/) を基盤として構築されており、パフォーマンスを重視しています。
|
15
|
+
|
16
|
+
## インストール
|
17
|
+
|
18
|
+
`pip` または `uv` を使ってインストールします。Python バージョンは 3.13 以上が必要です。
|
19
|
+
|
20
|
+
```bash
|
21
|
+
pip install kabukit
|
22
|
+
```
|
23
|
+
|
24
|
+
## コマンドラインから使う
|
25
|
+
|
26
|
+
kabukit は、 [J-Quants API](https://jpx-jquants.com/) および [EDINET API](https://disclosure2dl.edinet-fsa.go.jp/guide/static/disclosure/WZEK0110.html) からデータを取得するための便利なコマンドラインインターフェース(CLI)を提供します。
|
27
|
+
|
28
|
+
詳しい使い方は、[**コマンドラインインターフェースの使い方**](https://daizutabi.github.io/kabukit/guides/cli/)を参照してください。
|
29
|
+
|
30
|
+
## ノートブックから使う
|
31
|
+
|
32
|
+
kabukit は、コマンドラインだけでなく、Python コードからも API として利用できます。httpx を使って非同期でデータを取得するため、[Jupyter](https://jupyter.org/) や [marimo](https://marimo.io/) のような非同期処理を直接扱えるノートブック環境と非常に相性が良いです。
|
33
|
+
|
34
|
+
具体的な使い方は、以下の利用ガイドを参照してください。
|
35
|
+
|
36
|
+
- [**J-Quants API 利用ガイド**](https://daizutabi.github.io/kabukit/guides/jquants/)
|
37
|
+
- [**EDINET API 利用ガイド**](https://daizutabi.github.io/kabukit/guides/edinet/)
|
38
|
+
|
39
|
+
<!-- Badges -->
|
40
|
+
|
41
|
+
[pypi-v-image]: https://img.shields.io/pypi/v/kabukit.svg
|
42
|
+
[pypi-v-link]: https://pypi.org/project/kabukit/
|
43
|
+
[python-v-image]: https://img.shields.io/pypi/pyversions/kabukit.svg
|
44
|
+
[python-v-link]: https://pypi.org/project/kabukit
|
45
|
+
[GHAction-image]: https://github.com/daizutabi/kabukit/actions/workflows/ci.yaml/badge.svg?branch=main&event=push
|
46
|
+
[GHAction-link]: https://github.com/daizutabi/kabukit/actions?query=event%3Apush+branch%3Amain
|
47
|
+
[codecov-image]: https://codecov.io/github/daizutabi/kabukit/graph/badge.svg?token=Yu6lAdVVnd
|
48
|
+
[codecov-link]: https://codecov.io/github/daizutabi/kabukit?branch=main
|
49
|
+
[docs-image]: https://img.shields.io/badge/docs-latest-blue.svg
|
50
|
+
[docs-link]: https://daizutabi.github.io/kabukit/
|
@@ -4,7 +4,7 @@ build-backend = "uv_build"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "kabukit"
|
7
|
-
version = "0.
|
7
|
+
version = "0.8.0"
|
8
8
|
description = "A Python toolkit for Japanese financial market data, supporting J-Quants and EDINET APIs."
|
9
9
|
readme = "README.md"
|
10
10
|
license = { file = "LICENSE" }
|
@@ -65,8 +65,7 @@ Source = "https://github.com/daizutabi/kabukit"
|
|
65
65
|
dev = [
|
66
66
|
"altair @ git+https://github.com/vega/altair.git@main",
|
67
67
|
"basedpyright>=1.31.6",
|
68
|
-
"marimo[lsp]>=0.16.5",
|
69
|
-
"numpy>=2.3.3",
|
68
|
+
"marimo[lsp,mcp]>=0.16.5",
|
70
69
|
"pre-commit>=4.3.0",
|
71
70
|
"pytest-asyncio>=1.2.0",
|
72
71
|
"pytest-clarity>=1.0.1",
|
@@ -79,7 +78,15 @@ dev = [
|
|
79
78
|
"vegafusion>=2.0.3",
|
80
79
|
"vl-convert-python>=1.8.0",
|
81
80
|
]
|
82
|
-
docs = [
|
81
|
+
docs = [
|
82
|
+
"ipykernel>=6.30.1",
|
83
|
+
"mkapi>=4.5",
|
84
|
+
"mkdocs-material>=9.6.21",
|
85
|
+
"mkdocs-nbsync>=0.1.5",
|
86
|
+
"mkdocs-typer>=0.0.3",
|
87
|
+
"nbconvert>=7.16.6",
|
88
|
+
"pymdownx-cjk-autojoin>=0.2.1",
|
89
|
+
]
|
83
90
|
|
84
91
|
[tool.pytest.ini_options]
|
85
92
|
addopts = ["--cov=kabukit", "--cov-report=lcov:lcov.info", "--doctest-modules"]
|
@@ -1,17 +1,15 @@
|
|
1
|
+
from .core.documents import Documents
|
1
2
|
from .core.info import Info
|
2
|
-
from .core.list import List
|
3
3
|
from .core.prices import Prices
|
4
|
-
from .core.reports import Reports
|
5
4
|
from .core.statements import Statements
|
6
5
|
from .edinet.client import EdinetClient
|
7
6
|
from .jquants.client import JQuantsClient
|
8
7
|
|
9
8
|
__all__ = [
|
9
|
+
"Documents",
|
10
10
|
"EdinetClient",
|
11
11
|
"Info",
|
12
12
|
"JQuantsClient",
|
13
|
-
"List",
|
14
13
|
"Prices",
|
15
|
-
"Reports",
|
16
14
|
"Statements",
|
17
15
|
]
|
@@ -23,7 +23,9 @@ def add_to_tree(tree: Tree, path: Path) -> None:
|
|
23
23
|
branch = tree.add(p.name)
|
24
24
|
add_to_tree(branch, p)
|
25
25
|
else:
|
26
|
-
|
26
|
+
size = p.stat().st_size
|
27
|
+
formatted_size = format_size(size)
|
28
|
+
tree.add(f"{p.name} ({formatted_size})")
|
27
29
|
|
28
30
|
|
29
31
|
@app.command()
|
@@ -59,3 +61,13 @@ def clean() -> None:
|
|
59
61
|
msg += "エラーが発生しました。"
|
60
62
|
typer.secho(msg, fg=typer.colors.RED, bold=True)
|
61
63
|
raise typer.Exit(1) from None
|
64
|
+
|
65
|
+
|
66
|
+
def format_size(size_in_bytes: int) -> str:
|
67
|
+
if size_in_bytes < 1024:
|
68
|
+
return f"{size_in_bytes} B"
|
69
|
+
|
70
|
+
if size_in_bytes < 1024 * 1024:
|
71
|
+
return f"{size_in_bytes / 1024:.1f} KB"
|
72
|
+
|
73
|
+
return f"{size_in_bytes / (1024 * 1024):.1f} MB"
|
@@ -3,12 +3,15 @@ from __future__ import annotations
|
|
3
3
|
from typing import TYPE_CHECKING, Annotated, Any
|
4
4
|
|
5
5
|
import typer
|
6
|
-
from async_typer import AsyncTyper
|
7
|
-
from typer import Argument
|
6
|
+
from async_typer import AsyncTyper
|
7
|
+
from typer import Argument, Option
|
8
8
|
|
9
9
|
if TYPE_CHECKING:
|
10
10
|
from kabukit.core.base import Base
|
11
11
|
|
12
|
+
# pyright: reportMissingTypeStubs=false
|
13
|
+
# pyright: reportUnknownMemberType=false
|
14
|
+
|
12
15
|
app = AsyncTyper(
|
13
16
|
add_completion=False,
|
14
17
|
help="J-Quantsからデータを取得します。",
|
@@ -18,9 +21,13 @@ Code = Annotated[
|
|
18
21
|
str | None,
|
19
22
|
Argument(help="銘柄コード。指定しない場合は全銘柄の情報を取得します。"),
|
20
23
|
]
|
24
|
+
Quiet = Annotated[
|
25
|
+
bool,
|
26
|
+
Option("--quiet", "-q", help="プログレスバーを表示しません。"),
|
27
|
+
]
|
21
28
|
|
22
29
|
|
23
|
-
@app.async_command()
|
30
|
+
@app.async_command()
|
24
31
|
async def info(code: Code = None) -> None:
|
25
32
|
"""上場銘柄一覧を取得します。"""
|
26
33
|
from kabukit.core.info import Info
|
@@ -42,6 +49,8 @@ async def _fetch(
|
|
42
49
|
cls: type[Base],
|
43
50
|
fetch_func_name: str,
|
44
51
|
message: str,
|
52
|
+
*,
|
53
|
+
quiet: bool = False,
|
45
54
|
**kwargs: Any,
|
46
55
|
) -> None:
|
47
56
|
"""財務情報・株価情報を取得するための共通処理"""
|
@@ -57,8 +66,10 @@ async def _fetch(
|
|
57
66
|
|
58
67
|
from kabukit.jquants.concurrent import fetch_all
|
59
68
|
|
69
|
+
progress = None if quiet else tqdm.asyncio.tqdm
|
70
|
+
|
60
71
|
try:
|
61
|
-
df = await fetch_all(target, progress=
|
72
|
+
df = await fetch_all(target, progress=progress, **kwargs)
|
62
73
|
except KeyboardInterrupt:
|
63
74
|
typer.echo("中断しました。")
|
64
75
|
raise typer.Exit(1) from None
|
@@ -68,8 +79,8 @@ async def _fetch(
|
|
68
79
|
typer.echo(f"全銘柄の{message}を '{path}' に保存しました。")
|
69
80
|
|
70
81
|
|
71
|
-
@app.async_command()
|
72
|
-
async def statements(code: Code = None) -> None:
|
82
|
+
@app.async_command()
|
83
|
+
async def statements(code: Code = None, *, quiet: Quiet = False) -> None:
|
73
84
|
"""財務情報を取得します。"""
|
74
85
|
from kabukit.core.statements import Statements
|
75
86
|
|
@@ -79,12 +90,13 @@ async def statements(code: Code = None) -> None:
|
|
79
90
|
cls=Statements,
|
80
91
|
fetch_func_name="get_statements",
|
81
92
|
message="財務情報",
|
93
|
+
quiet=quiet,
|
82
94
|
)
|
83
95
|
|
84
96
|
|
85
|
-
@app.async_command()
|
86
|
-
async def prices(code: Code = None) -> None:
|
87
|
-
"""
|
97
|
+
@app.async_command()
|
98
|
+
async def prices(code: Code = None, *, quiet: Quiet = False) -> None:
|
99
|
+
"""株価情報を取得します。"""
|
88
100
|
from kabukit.core.prices import Prices
|
89
101
|
|
90
102
|
await _fetch(
|
@@ -93,77 +105,47 @@ async def prices(code: Code = None) -> None:
|
|
93
105
|
cls=Prices,
|
94
106
|
fetch_func_name="get_prices",
|
95
107
|
message="株価情報",
|
108
|
+
quiet=quiet,
|
96
109
|
max_concurrency=8,
|
97
110
|
)
|
98
111
|
|
99
112
|
|
100
|
-
@app.async_command(
|
101
|
-
async def
|
102
|
-
"""
|
113
|
+
@app.async_command()
|
114
|
+
async def documents(*, quiet: Quiet = False) -> None:
|
115
|
+
"""書類一覧を取得します。"""
|
103
116
|
import tqdm.asyncio
|
104
117
|
|
105
|
-
from kabukit.core.
|
106
|
-
from kabukit.edinet.concurrent import
|
118
|
+
from kabukit.core.documents import Documents
|
119
|
+
from kabukit.edinet.concurrent import fetch_documents
|
107
120
|
|
108
|
-
|
109
|
-
df = await fetch_list(years=10, progress=tqdm.asyncio.tqdm)
|
110
|
-
except (KeyboardInterrupt, RuntimeError):
|
111
|
-
typer.echo("中断しました。")
|
112
|
-
raise typer.Exit(1) from None
|
113
|
-
|
114
|
-
typer.echo(df)
|
115
|
-
path = List(df).write()
|
116
|
-
typer.echo(f"報告書一覧を '{path}' に保存しました。")
|
117
|
-
|
118
|
-
|
119
|
-
@app.async_command() # pyright: ignore[reportUnknownMemberType]
|
120
|
-
async def reports() -> None:
|
121
|
-
"""報告書を取得します。"""
|
122
|
-
import polars as pl
|
123
|
-
import tqdm.asyncio
|
124
|
-
|
125
|
-
from kabukit.core.list import List
|
126
|
-
from kabukit.core.reports import Reports
|
127
|
-
from kabukit.edinet.concurrent import fetch_csv
|
121
|
+
progress = None if quiet else tqdm.asyncio.tqdm
|
128
122
|
|
129
123
|
try:
|
130
|
-
df =
|
131
|
-
except FileNotFoundError:
|
132
|
-
await list_()
|
133
|
-
df = List.read().data
|
134
|
-
|
135
|
-
lst = df.filter(pl.col("csvFlag"), pl.col("secCode").is_not_null())
|
136
|
-
doc_ids = lst["docID"].unique()
|
137
|
-
|
138
|
-
try:
|
139
|
-
df = await fetch_csv(doc_ids, limit=1000, progress=tqdm.asyncio.tqdm)
|
124
|
+
df = await fetch_documents(years=10, progress=progress)
|
140
125
|
except (KeyboardInterrupt, RuntimeError):
|
141
126
|
typer.echo("中断しました。")
|
142
127
|
raise typer.Exit(1) from None
|
143
128
|
|
144
129
|
typer.echo(df)
|
145
|
-
path =
|
146
|
-
typer.echo(f"
|
130
|
+
path = Documents(df).write()
|
131
|
+
typer.echo(f"書類一覧を '{path}' に保存しました。")
|
147
132
|
|
148
133
|
|
149
|
-
@app.async_command(name="all")
|
150
|
-
async def all_(code: Code = None) -> None:
|
151
|
-
"""
|
134
|
+
@app.async_command(name="all")
|
135
|
+
async def all_(code: Code = None, *, quiet: Quiet = False) -> None:
|
136
|
+
"""上場銘柄一覧、財務情報、株価情報、書類一覧を連続して取得します。"""
|
152
137
|
typer.echo("上場銘柄一覧を取得します。")
|
153
138
|
await info(code)
|
154
139
|
|
155
140
|
typer.echo("---")
|
156
141
|
typer.echo("財務情報を取得します。")
|
157
|
-
await statements(code)
|
142
|
+
await statements(code, quiet=quiet)
|
158
143
|
|
159
144
|
typer.echo("---")
|
160
|
-
typer.echo("
|
161
|
-
await prices(code)
|
145
|
+
typer.echo("株価情報を取得します。")
|
146
|
+
await prices(code, quiet=quiet)
|
162
147
|
|
163
148
|
if code is None:
|
164
149
|
typer.echo("---")
|
165
|
-
typer.echo("
|
166
|
-
await
|
167
|
-
typer.echo("---")
|
168
|
-
typer.echo("報告書を取得します。")
|
169
|
-
await reports()
|
150
|
+
typer.echo("書類一覧を取得します。")
|
151
|
+
await documents(quiet=quiet)
|
@@ -14,7 +14,7 @@ from kabukit.core.client import Client
|
|
14
14
|
from kabukit.utils.config import load_dotenv
|
15
15
|
from kabukit.utils.params import get_params
|
16
16
|
|
17
|
-
from .doc import clean_csv,
|
17
|
+
from .doc import clean_csv, clean_documents, read_csv
|
18
18
|
|
19
19
|
if TYPE_CHECKING:
|
20
20
|
import datetime
|
@@ -62,6 +62,15 @@ class EdinetClient(Client):
|
|
62
62
|
return resp
|
63
63
|
|
64
64
|
async def get_count(self, date: str | datetime.date) -> int:
|
65
|
+
"""書類一覧 API を使い、特定の日付の提出書類数を取得する。
|
66
|
+
|
67
|
+
Args:
|
68
|
+
date (str | datetime.date): 取得対象の日付 (YYYY-MM-DD)
|
69
|
+
|
70
|
+
Returns:
|
71
|
+
int: 書類数
|
72
|
+
|
73
|
+
"""
|
65
74
|
params = get_params(date=date, type=1)
|
66
75
|
resp = await self.get("/documents.json", params)
|
67
76
|
data = resp.json()
|
@@ -72,7 +81,15 @@ class EdinetClient(Client):
|
|
72
81
|
|
73
82
|
return metadata["resultset"]["count"]
|
74
83
|
|
75
|
-
async def
|
84
|
+
async def get_documents(self, date: str | datetime.date) -> DataFrame:
|
85
|
+
"""書類一覧 API を使い、特定の日付の提出書類一覧を取得する。
|
86
|
+
|
87
|
+
Args:
|
88
|
+
date (str | datetime.date): 取得対象の日付 (YYYY-MM-DD)
|
89
|
+
|
90
|
+
Returns:
|
91
|
+
DataFrame: 提出書類一覧を格納した DataFrame
|
92
|
+
"""
|
76
93
|
params = get_params(date=date, type=2)
|
77
94
|
resp = await self.get("/documents.json", params)
|
78
95
|
data = resp.json()
|
@@ -85,7 +102,7 @@ class EdinetClient(Client):
|
|
85
102
|
if df.is_empty():
|
86
103
|
return df
|
87
104
|
|
88
|
-
return
|
105
|
+
return clean_documents(df, date)
|
89
106
|
|
90
107
|
async def get_document(self, doc_id: str, doc_type: int) -> Response:
|
91
108
|
params = get_params(type=doc_type)
|
@@ -52,7 +52,7 @@ async def fetch(
|
|
52
52
|
)
|
53
53
|
|
54
54
|
|
55
|
-
async def
|
55
|
+
async def fetch_documents(
|
56
56
|
days: int | None = None,
|
57
57
|
years: int | None = None,
|
58
58
|
limit: int | None = None,
|
@@ -60,11 +60,11 @@ async def fetch_list(
|
|
60
60
|
progress: Progress | None = None,
|
61
61
|
callback: Callback | None = None,
|
62
62
|
) -> DataFrame:
|
63
|
-
"""過去days日またはyears年の文書一覧を取得し、単一のDataFrameにまとめて返す。
|
63
|
+
"""過去 days 日または years 年の文書一覧を取得し、単一の DataFrame にまとめて返す。
|
64
64
|
|
65
65
|
Args:
|
66
|
-
days (int | None): 過去days日の日付リストを取得する。
|
67
|
-
years (int | None): 過去years年の日付リストを取得する。
|
66
|
+
days (int | None): 過去 days 日の日付リストを取得する。
|
67
|
+
years (int | None): 過去 years 年の日付リストを取得する。
|
68
68
|
daysが指定されている場合は無視される。
|
69
69
|
max_concurrency (int | None, optional): 同時に実行するリクエストの最大数。
|
70
70
|
指定しないときはデフォルト値が使用される。
|
@@ -84,13 +84,13 @@ async def fetch_list(
|
|
84
84
|
dates = dates[:limit]
|
85
85
|
|
86
86
|
df = await fetch(
|
87
|
-
"
|
87
|
+
"documents",
|
88
88
|
dates,
|
89
89
|
max_concurrency=max_concurrency,
|
90
90
|
progress=progress,
|
91
91
|
callback=callback,
|
92
92
|
)
|
93
|
-
return df.sort("Date")
|
93
|
+
return df.sort("Date", "Code")
|
94
94
|
|
95
95
|
|
96
96
|
async def fetch_csv(
|
@@ -10,7 +10,7 @@ if TYPE_CHECKING:
|
|
10
10
|
from polars import DataFrame
|
11
11
|
|
12
12
|
|
13
|
-
def
|
13
|
+
def clean_documents(df: DataFrame, date: str | datetime.date) -> DataFrame:
|
14
14
|
if isinstance(date, str):
|
15
15
|
date = (
|
16
16
|
datetime.datetime.strptime(date, "%Y-%m-%d")
|
@@ -35,7 +35,8 @@ def clean_list(df: DataFrame, date: str | datetime.date) -> DataFrame:
|
|
35
35
|
pl.col("^.+Flag$").cast(pl.Int8).cast(pl.Boolean),
|
36
36
|
pl.col("^.+Code$").cast(pl.String),
|
37
37
|
)
|
38
|
-
.
|
38
|
+
.rename({"secCode": "Code"})
|
39
|
+
.select("Date", "Code", pl.exclude("Date", "Code"))
|
39
40
|
)
|
40
41
|
|
41
42
|
|
kabukit-0.7.6/PKG-INFO
DELETED
@@ -1,260 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.3
|
2
|
-
Name: kabukit
|
3
|
-
Version: 0.7.6
|
4
|
-
Summary: A Python toolkit for Japanese financial market data, supporting J-Quants and EDINET APIs.
|
5
|
-
Keywords: J-Quants,EDINET,financial data,stock market,investment,toolkit,finance,trading,data analysis,polars
|
6
|
-
Author: daizutabi
|
7
|
-
Author-email: daizutabi <daizutabi@gmail.com>
|
8
|
-
License: MIT License
|
9
|
-
|
10
|
-
Copyright (c) 2025 Daizu
|
11
|
-
|
12
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
13
|
-
of this software and associated documentation files (the "Software"), to deal
|
14
|
-
in the Software without restriction, including without limitation the rights
|
15
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
16
|
-
copies of the Software, and to permit persons to whom the Software is
|
17
|
-
furnished to do so, subject to the following conditions:
|
18
|
-
|
19
|
-
The above copyright notice and this permission notice shall be included in all
|
20
|
-
copies or substantial portions of the Software.
|
21
|
-
|
22
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
23
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
24
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
25
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
26
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
27
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
28
|
-
SOFTWARE.
|
29
|
-
Classifier: Development Status :: 4 - Beta
|
30
|
-
Classifier: Programming Language :: Python
|
31
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
32
|
-
Classifier: Programming Language :: Python :: 3.13
|
33
|
-
Classifier: Programming Language :: Python :: 3.14
|
34
|
-
Classifier: License :: OSI Approved :: MIT License
|
35
|
-
Classifier: Operating System :: OS Independent
|
36
|
-
Classifier: Intended Audience :: Developers
|
37
|
-
Classifier: Intended Audience :: Financial and Insurance Industry
|
38
|
-
Classifier: Intended Audience :: Science/Research
|
39
|
-
Classifier: Topic :: Office/Business :: Financial
|
40
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
41
|
-
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
42
|
-
Classifier: Topic :: Utilities
|
43
|
-
Requires-Dist: async-typer>=0.1.10
|
44
|
-
Requires-Dist: httpx>=0.28.1
|
45
|
-
Requires-Dist: platformdirs>=4.5.0
|
46
|
-
Requires-Dist: polars>=1.34.0
|
47
|
-
Requires-Dist: python-dotenv>=1.1.1
|
48
|
-
Requires-Dist: rich>=14.2.0
|
49
|
-
Requires-Dist: tenacity>=9.1.2
|
50
|
-
Requires-Dist: tqdm>=4.67.1
|
51
|
-
Requires-Dist: typer>=0.19.2
|
52
|
-
Requires-Dist: tzdata ; sys_platform == 'win32'
|
53
|
-
Requires-Python: >=3.13
|
54
|
-
Project-URL: Changelog, https://github.com/daizutabi/kabukit/releases
|
55
|
-
Project-URL: Documentation, https://daizutabi.github.io/kabukit/
|
56
|
-
Project-URL: Homepage, https://daizutabi.github.io/kabukit/
|
57
|
-
Project-URL: Issues, https://github.com/daizutabi/kabukit/issues
|
58
|
-
Project-URL: Source, https://github.com/daizutabi/kabukit
|
59
|
-
Description-Content-Type: text/markdown
|
60
|
-
|
61
|
-
# kabukit
|
62
|
-
|
63
|
-
A Python toolkit for Japanese financial market data, supporting J-Quants and EDINET APIs.
|
64
|
-
|
65
|
-
[![PyPI Version][pypi-v-image]][pypi-v-link]
|
66
|
-
[![Python Version][python-v-image]][python-v-link]
|
67
|
-
[![Build Status][GHAction-image]][GHAction-link]
|
68
|
-
[![Coverage Status][codecov-image]][codecov-link]
|
69
|
-
[![Documentation Status][docs-image]][docs-link]
|
70
|
-
|
71
|
-
kabukitは、高速なデータ処理ライブラリである [Polars](https://pola.rs/) と、モダンな非同期HTTPクライアントである [httpx](https://www.python-httpx.org/) を基盤として構築されており、パフォーマンスを重視しています。
|
72
|
-
|
73
|
-
## インストール
|
74
|
-
|
75
|
-
`uv` または `pip` を使って、[Python Package Index (PyPI)](https://pypi.org/) からインストールします。Pythonバージョンは3.13以上が必要です。
|
76
|
-
|
77
|
-
```bash
|
78
|
-
uv pip install kabukit
|
79
|
-
```
|
80
|
-
|
81
|
-
## コマンドラインから使う
|
82
|
-
|
83
|
-
kabukitは、 [J-Quants](https://jpx-jquants.com/) および [EDINET](https://disclosure2.edinet-fsa.go.jp/) からデータを取得するための便利なコマンドラインインターフェース(CLI)を提供します。
|
84
|
-
|
85
|
-
コマンド名は `kabu` です。
|
86
|
-
|
87
|
-
### 認証
|
88
|
-
|
89
|
-
#### J-Quants
|
90
|
-
|
91
|
-
J-Quants APIを利用するには、事前にユーザー登録が必要です。`auth jquants` サブコマンドを使い、登録したメールアドレスとパスワードで認証し、IDトークンを取得します。IDトークンはユーザーの設定ディレクトリに保存されます。
|
92
|
-
|
93
|
-
```bash
|
94
|
-
❯ kabu auth jquants
|
95
|
-
Mailaddress: your_email@example.com
|
96
|
-
Password: your_password
|
97
|
-
J-QuantsのIDトークンを保存しました。
|
98
|
-
```
|
99
|
-
|
100
|
-
#### EDINET
|
101
|
-
|
102
|
-
EDINET APIを利用するには、事前にAPIキーの取得が必要です。`auth edinet` サブコマンド使い、取得したAPIキーをユーザーの設定ディレクトリに保存します。
|
103
|
-
|
104
|
-
```bash
|
105
|
-
❯ kabu auth edinet
|
106
|
-
Api key: your_api_key
|
107
|
-
EDINETのAPIキーを保存しました。
|
108
|
-
```
|
109
|
-
|
110
|
-
#### 認証データで確認
|
111
|
-
|
112
|
-
認証データの保存先と内容は、`auth show` サブコマンドで確認できます。
|
113
|
-
|
114
|
-
```bash
|
115
|
-
❯ kabu auth show
|
116
|
-
Configuration file: /home/your_name/.config/kabukit/.env
|
117
|
-
JQUANTS_ID_TOKEN: ******
|
118
|
-
EDINET_API_KEY: ******
|
119
|
-
```
|
120
|
-
|
121
|
-
### データ取得
|
122
|
-
|
123
|
-
`get` サブコマンドは、J-QuantsおよびEDINETから各種データを取得します。以下に、一例を示します。
|
124
|
-
|
125
|
-
#### 銘柄情報
|
126
|
-
|
127
|
-
```bash
|
128
|
-
❯ kabu get info 7203
|
129
|
-
shape: (1, 8)
|
130
|
-
┌────────────┬───────┬──────────────┬──────────────────┬─
|
131
|
-
│ Date ┆ Code ┆ CompanyName ┆ Sector17CodeName ┆
|
132
|
-
│ --- ┆ --- ┆ --- ┆ --- ┆
|
133
|
-
│ date ┆ str ┆ str ┆ cat ┆
|
134
|
-
╞════════════╪═══════╪══════════════╪══════════════════╪═
|
135
|
-
│ 2025-10-14 ┆ 72030 ┆ トヨタ自動車 ┆ 自動車・輸送機 ┆
|
136
|
-
└────────────┴───────┴──────────────┴──────────────────┴─
|
137
|
-
```
|
138
|
-
|
139
|
-
#### 財務情報
|
140
|
-
|
141
|
-
```bash
|
142
|
-
❯ kabu get statements 7203
|
143
|
-
shape: (41, 105)
|
144
|
-
(略)
|
145
|
-
```
|
146
|
-
|
147
|
-
#### 株価情報
|
148
|
-
|
149
|
-
```bash
|
150
|
-
❯ kabu get prices 7203
|
151
|
-
shape: (2_444, 16)
|
152
|
-
(略)
|
153
|
-
```
|
154
|
-
|
155
|
-
#### 全銘柄のデータ一括取得
|
156
|
-
|
157
|
-
各コマンドで銘柄コードを省力すると、全銘柄のデータを一度に取得できます。財務情報の場合は以下の通りです。
|
158
|
-
|
159
|
-
```bash
|
160
|
-
> kabu get statements
|
161
|
-
100%|███████████████████████████| 3787/3787 [01:18<00:00, 48.24it/s]
|
162
|
-
shape: (165_891, 105)
|
163
|
-
(略)
|
164
|
-
```
|
165
|
-
|
166
|
-
`get all` サブコマンドを使うと、全銘柄の各種データを一度に取得できます。
|
167
|
-
|
168
|
-
```bash
|
169
|
-
> kabu get all
|
170
|
-
```
|
171
|
-
|
172
|
-
これらのデータはキャッシュディレクトリに保存され、後で再利用できます。キャッシュデータを確認するには、`cache tree` サブコマンドを使います。
|
173
|
-
|
174
|
-
```bash
|
175
|
-
> kabu cache tree
|
176
|
-
/home/your_name/.cache/kabukit
|
177
|
-
├── info
|
178
|
-
│ └── 20251011.parquet
|
179
|
-
├── list
|
180
|
-
│ └── 20251011.parquet
|
181
|
-
├── prices
|
182
|
-
│ └── 20251011.parquet
|
183
|
-
├── reports
|
184
|
-
│ └── 20251011.parquet
|
185
|
-
└── statements
|
186
|
-
└── 20251011.parquet
|
187
|
-
```
|
188
|
-
|
189
|
-
キャッシュデータは、`cache clean` サブコマンドで消去できます。
|
190
|
-
|
191
|
-
## ノートブックから使う
|
192
|
-
|
193
|
-
kabukitは、コマンドラインだけでなく、PythonコードからもAPIとして利用できます。httpxを使って非同期でデータを取得するため、[Jupyter](https://jupyter.org/) や [marimo](https://marimo.io/) のような非同期処理を直接扱えるノートブック環境と非常に相性が良いです。
|
194
|
-
|
195
|
-
### データ取得
|
196
|
-
|
197
|
-
J-Quantsの例を示します。まず、`JQuantsClient`のインスタンスを作成します。事前に、コマンドラインで認証を済ませてください。
|
198
|
-
|
199
|
-
```python
|
200
|
-
from kabukit import JQuantsClient
|
201
|
-
|
202
|
-
client = JQuantsClient()
|
203
|
-
```
|
204
|
-
|
205
|
-
#### 銘柄情報
|
206
|
-
|
207
|
-
```python
|
208
|
-
info = await client.get_info("7203")
|
209
|
-
```
|
210
|
-
|
211
|
-
#### 財務情報
|
212
|
-
|
213
|
-
```python
|
214
|
-
statements = await client.get_statements("7203")
|
215
|
-
```
|
216
|
-
|
217
|
-
#### 株価情報
|
218
|
-
|
219
|
-
```python
|
220
|
-
prices = await client.get_prices("7203")
|
221
|
-
```
|
222
|
-
|
223
|
-
#### 全銘柄のデータ一括取得
|
224
|
-
|
225
|
-
`fetch_all`関数を使うと、全銘柄のデータを一度に取得できます。marimoノートブックを使っていれば、プログレスバーを簡単に表示できます。財務情報の場合は以下の通りです。
|
226
|
-
|
227
|
-
```python
|
228
|
-
import marimo as mo
|
229
|
-
from kabukit.jquants import fetch_all
|
230
|
-
|
231
|
-
statements = await fetch_all("statements", progress=mo.status.progress_bar)
|
232
|
-
```
|
233
|
-
|
234
|
-
株価情報の場合は、上記の `"statements"` を `"prices"` に変更してください。
|
235
|
-
|
236
|
-
### キャッシュデータの利用
|
237
|
-
|
238
|
-
コマンドラインで事前に保存しておいたキャッシュデータを再利用できます。ノートブックの起動ごとに、APIアクセスを行ってデータをダウンロードする必要がなくなります。
|
239
|
-
|
240
|
-
```python
|
241
|
-
from kabukit import Info, Statements, Prices
|
242
|
-
|
243
|
-
# data属性で、Polars DataFrameを取得できます。
|
244
|
-
info = Info.read().data
|
245
|
-
statements = Statements.read().data
|
246
|
-
prices = Prices.read().data
|
247
|
-
```
|
248
|
-
|
249
|
-
<!-- Badges -->
|
250
|
-
|
251
|
-
[pypi-v-image]: https://img.shields.io/pypi/v/kabukit.svg
|
252
|
-
[pypi-v-link]: https://pypi.org/project/kabukit/
|
253
|
-
[python-v-image]: https://img.shields.io/pypi/pyversions/kabukit.svg
|
254
|
-
[python-v-link]: https://pypi.org/project/kabukit
|
255
|
-
[GHAction-image]: https://github.com/daizutabi/kabukit/actions/workflows/ci.yaml/badge.svg?branch=main&event=push
|
256
|
-
[GHAction-link]: https://github.com/daizutabi/kabukit/actions?query=event%3Apush+branch%3Amain
|
257
|
-
[codecov-image]: https://codecov.io/github/daizutabi/kabukit/graph/badge.svg?token=Yu6lAdVVnd
|
258
|
-
[codecov-link]: https://codecov.io/github/daizutabi/kabukit?branch=main
|
259
|
-
[docs-image]: https://img.shields.io/badge/docs-latest-blue.svg
|
260
|
-
[docs-link]: https://daizutabi.github.io/kabukit/
|
kabukit-0.7.6/README.md
DELETED
@@ -1,200 +0,0 @@
|
|
1
|
-
# kabukit
|
2
|
-
|
3
|
-
A Python toolkit for Japanese financial market data, supporting J-Quants and EDINET APIs.
|
4
|
-
|
5
|
-
[![PyPI Version][pypi-v-image]][pypi-v-link]
|
6
|
-
[![Python Version][python-v-image]][python-v-link]
|
7
|
-
[![Build Status][GHAction-image]][GHAction-link]
|
8
|
-
[![Coverage Status][codecov-image]][codecov-link]
|
9
|
-
[![Documentation Status][docs-image]][docs-link]
|
10
|
-
|
11
|
-
kabukitは、高速なデータ処理ライブラリである [Polars](https://pola.rs/) と、モダンな非同期HTTPクライアントである [httpx](https://www.python-httpx.org/) を基盤として構築されており、パフォーマンスを重視しています。
|
12
|
-
|
13
|
-
## インストール
|
14
|
-
|
15
|
-
`uv` または `pip` を使って、[Python Package Index (PyPI)](https://pypi.org/) からインストールします。Pythonバージョンは3.13以上が必要です。
|
16
|
-
|
17
|
-
```bash
|
18
|
-
uv pip install kabukit
|
19
|
-
```
|
20
|
-
|
21
|
-
## コマンドラインから使う
|
22
|
-
|
23
|
-
kabukitは、 [J-Quants](https://jpx-jquants.com/) および [EDINET](https://disclosure2.edinet-fsa.go.jp/) からデータを取得するための便利なコマンドラインインターフェース(CLI)を提供します。
|
24
|
-
|
25
|
-
コマンド名は `kabu` です。
|
26
|
-
|
27
|
-
### 認証
|
28
|
-
|
29
|
-
#### J-Quants
|
30
|
-
|
31
|
-
J-Quants APIを利用するには、事前にユーザー登録が必要です。`auth jquants` サブコマンドを使い、登録したメールアドレスとパスワードで認証し、IDトークンを取得します。IDトークンはユーザーの設定ディレクトリに保存されます。
|
32
|
-
|
33
|
-
```bash
|
34
|
-
❯ kabu auth jquants
|
35
|
-
Mailaddress: your_email@example.com
|
36
|
-
Password: your_password
|
37
|
-
J-QuantsのIDトークンを保存しました。
|
38
|
-
```
|
39
|
-
|
40
|
-
#### EDINET
|
41
|
-
|
42
|
-
EDINET APIを利用するには、事前にAPIキーの取得が必要です。`auth edinet` サブコマンド使い、取得したAPIキーをユーザーの設定ディレクトリに保存します。
|
43
|
-
|
44
|
-
```bash
|
45
|
-
❯ kabu auth edinet
|
46
|
-
Api key: your_api_key
|
47
|
-
EDINETのAPIキーを保存しました。
|
48
|
-
```
|
49
|
-
|
50
|
-
#### 認証データで確認
|
51
|
-
|
52
|
-
認証データの保存先と内容は、`auth show` サブコマンドで確認できます。
|
53
|
-
|
54
|
-
```bash
|
55
|
-
❯ kabu auth show
|
56
|
-
Configuration file: /home/your_name/.config/kabukit/.env
|
57
|
-
JQUANTS_ID_TOKEN: ******
|
58
|
-
EDINET_API_KEY: ******
|
59
|
-
```
|
60
|
-
|
61
|
-
### データ取得
|
62
|
-
|
63
|
-
`get` サブコマンドは、J-QuantsおよびEDINETから各種データを取得します。以下に、一例を示します。
|
64
|
-
|
65
|
-
#### 銘柄情報
|
66
|
-
|
67
|
-
```bash
|
68
|
-
❯ kabu get info 7203
|
69
|
-
shape: (1, 8)
|
70
|
-
┌────────────┬───────┬──────────────┬──────────────────┬─
|
71
|
-
│ Date ┆ Code ┆ CompanyName ┆ Sector17CodeName ┆
|
72
|
-
│ --- ┆ --- ┆ --- ┆ --- ┆
|
73
|
-
│ date ┆ str ┆ str ┆ cat ┆
|
74
|
-
╞════════════╪═══════╪══════════════╪══════════════════╪═
|
75
|
-
│ 2025-10-14 ┆ 72030 ┆ トヨタ自動車 ┆ 自動車・輸送機 ┆
|
76
|
-
└────────────┴───────┴──────────────┴──────────────────┴─
|
77
|
-
```
|
78
|
-
|
79
|
-
#### 財務情報
|
80
|
-
|
81
|
-
```bash
|
82
|
-
❯ kabu get statements 7203
|
83
|
-
shape: (41, 105)
|
84
|
-
(略)
|
85
|
-
```
|
86
|
-
|
87
|
-
#### 株価情報
|
88
|
-
|
89
|
-
```bash
|
90
|
-
❯ kabu get prices 7203
|
91
|
-
shape: (2_444, 16)
|
92
|
-
(略)
|
93
|
-
```
|
94
|
-
|
95
|
-
#### 全銘柄のデータ一括取得
|
96
|
-
|
97
|
-
各コマンドで銘柄コードを省力すると、全銘柄のデータを一度に取得できます。財務情報の場合は以下の通りです。
|
98
|
-
|
99
|
-
```bash
|
100
|
-
> kabu get statements
|
101
|
-
100%|███████████████████████████| 3787/3787 [01:18<00:00, 48.24it/s]
|
102
|
-
shape: (165_891, 105)
|
103
|
-
(略)
|
104
|
-
```
|
105
|
-
|
106
|
-
`get all` サブコマンドを使うと、全銘柄の各種データを一度に取得できます。
|
107
|
-
|
108
|
-
```bash
|
109
|
-
> kabu get all
|
110
|
-
```
|
111
|
-
|
112
|
-
これらのデータはキャッシュディレクトリに保存され、後で再利用できます。キャッシュデータを確認するには、`cache tree` サブコマンドを使います。
|
113
|
-
|
114
|
-
```bash
|
115
|
-
> kabu cache tree
|
116
|
-
/home/your_name/.cache/kabukit
|
117
|
-
├── info
|
118
|
-
│ └── 20251011.parquet
|
119
|
-
├── list
|
120
|
-
│ └── 20251011.parquet
|
121
|
-
├── prices
|
122
|
-
│ └── 20251011.parquet
|
123
|
-
├── reports
|
124
|
-
│ └── 20251011.parquet
|
125
|
-
└── statements
|
126
|
-
└── 20251011.parquet
|
127
|
-
```
|
128
|
-
|
129
|
-
キャッシュデータは、`cache clean` サブコマンドで消去できます。
|
130
|
-
|
131
|
-
## ノートブックから使う
|
132
|
-
|
133
|
-
kabukitは、コマンドラインだけでなく、PythonコードからもAPIとして利用できます。httpxを使って非同期でデータを取得するため、[Jupyter](https://jupyter.org/) や [marimo](https://marimo.io/) のような非同期処理を直接扱えるノートブック環境と非常に相性が良いです。
|
134
|
-
|
135
|
-
### データ取得
|
136
|
-
|
137
|
-
J-Quantsの例を示します。まず、`JQuantsClient`のインスタンスを作成します。事前に、コマンドラインで認証を済ませてください。
|
138
|
-
|
139
|
-
```python
|
140
|
-
from kabukit import JQuantsClient
|
141
|
-
|
142
|
-
client = JQuantsClient()
|
143
|
-
```
|
144
|
-
|
145
|
-
#### 銘柄情報
|
146
|
-
|
147
|
-
```python
|
148
|
-
info = await client.get_info("7203")
|
149
|
-
```
|
150
|
-
|
151
|
-
#### 財務情報
|
152
|
-
|
153
|
-
```python
|
154
|
-
statements = await client.get_statements("7203")
|
155
|
-
```
|
156
|
-
|
157
|
-
#### 株価情報
|
158
|
-
|
159
|
-
```python
|
160
|
-
prices = await client.get_prices("7203")
|
161
|
-
```
|
162
|
-
|
163
|
-
#### 全銘柄のデータ一括取得
|
164
|
-
|
165
|
-
`fetch_all`関数を使うと、全銘柄のデータを一度に取得できます。marimoノートブックを使っていれば、プログレスバーを簡単に表示できます。財務情報の場合は以下の通りです。
|
166
|
-
|
167
|
-
```python
|
168
|
-
import marimo as mo
|
169
|
-
from kabukit.jquants import fetch_all
|
170
|
-
|
171
|
-
statements = await fetch_all("statements", progress=mo.status.progress_bar)
|
172
|
-
```
|
173
|
-
|
174
|
-
株価情報の場合は、上記の `"statements"` を `"prices"` に変更してください。
|
175
|
-
|
176
|
-
### キャッシュデータの利用
|
177
|
-
|
178
|
-
コマンドラインで事前に保存しておいたキャッシュデータを再利用できます。ノートブックの起動ごとに、APIアクセスを行ってデータをダウンロードする必要がなくなります。
|
179
|
-
|
180
|
-
```python
|
181
|
-
from kabukit import Info, Statements, Prices
|
182
|
-
|
183
|
-
# data属性で、Polars DataFrameを取得できます。
|
184
|
-
info = Info.read().data
|
185
|
-
statements = Statements.read().data
|
186
|
-
prices = Prices.read().data
|
187
|
-
```
|
188
|
-
|
189
|
-
<!-- Badges -->
|
190
|
-
|
191
|
-
[pypi-v-image]: https://img.shields.io/pypi/v/kabukit.svg
|
192
|
-
[pypi-v-link]: https://pypi.org/project/kabukit/
|
193
|
-
[python-v-image]: https://img.shields.io/pypi/pyversions/kabukit.svg
|
194
|
-
[python-v-link]: https://pypi.org/project/kabukit
|
195
|
-
[GHAction-image]: https://github.com/daizutabi/kabukit/actions/workflows/ci.yaml/badge.svg?branch=main&event=push
|
196
|
-
[GHAction-link]: https://github.com/daizutabi/kabukit/actions?query=event%3Apush+branch%3Amain
|
197
|
-
[codecov-image]: https://codecov.io/github/daizutabi/kabukit/graph/badge.svg?token=Yu6lAdVVnd
|
198
|
-
[codecov-link]: https://codecov.io/github/daizutabi/kabukit?branch=main
|
199
|
-
[docs-image]: https://img.shields.io/badge/docs-latest-blue.svg
|
200
|
-
[docs-link]: https://daizutabi.github.io/kabukit/
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|