Skip to main content

insighta-sbi-parser

PyPI Python License

SBI証券からダウンロードした取引データ(HTML/CSV)を構造化されたPythonオブジェクトに変換するライブラリです。

インストール

pip install insighta-sbi-parser

使い方

ディレクトリ一括パース

from insighta_sbi_parser import process_sbi_dir

result = process_sbi_dir("path/to/sbi_files/")

for trade in result.trades:
    print(f"{trade.dt} {trade.ticker} {trade.qty}株 @{trade.price}")

for holding in result.holdings:
    print(f"{holding.ticker} {holding.qty}株 損益:{holding.pnl}")

for deposit in result.deposits:
    print(f"{deposit.dt} {deposit.amount} {deposit.cur} ({deposit.type})")

為替レート付きパース

result = process_sbi_dir("path/to/sbi_files/", rate_file="rate.csv")

rate.csv 形式:

date,rate
2024/01/15,148.50
2024/01/16,149.20

ファイル個別パース

from insighta_sbi_parser import classify, parse_history_html, parse_yakujo_csv

# ファイル種類を自動判定
file_type = classify("some_file.csv")  # → "history_csv", "deposit_transfer", etc.

# 個別パーサー
trades, skipped = parse_history_html("order_history.html")

対応フォーマット

種類 形式 関数
注文履歴 HTML parse_history_html()
保有銘柄一覧 HTML parse_summary_html()
約定履歴 CSV (Shift_JIS) parse_yakujo_csv()
国内投信取引 CSV (Shift_JIS) parse_domestic_fund()
入出金振替 CSV (UTF-8) parse_transfer()
外貨入出金 CSV (UTF-8) parse_gaika_nyushukkin()
為替取引 CSV (Shift_JIS) parse_exchange()
配当金 CSV (Shift_JIS) parse_distribution()

データモデル

@dataclass
class Trade:
    dt: str          # ISO 8601 (JST)
    ticker: str      # ティッカーシンボル
    qty: int         # 数量 (売りはマイナス)
    acct: str        # 口座区分 ("TT"=特定, "NISA")
    price: Decimal   # 現在値
    avg: Decimal     # 平均約定単価
    cur: str         # 決済通貨
    base: str        # 基準通貨

@dataclass
class Holding:
    ticker: str
    acct: str
    qty: int
    cost: Decimal    # 取得単価
    price: Decimal   # 現在値
    pnl: Decimal     # 損益

@dataclass
class Deposit:
    dt: str
    amount: Decimal  # 金額 (出金はマイナス)
    cur: str         # 通貨
    type: str        # "budget" | "dividend"
    ticker: str      # 関連銘柄 (任意)
    rate: Decimal | None  # 為替レート (任意)

ファイルの取得方法

SBI証券のWebサイトから以下の手順でダウンロードできます:

  1. 注文履歴HTML: 外国株式 → 注文照会 → ページをHTMLとして保存
  2. 保有銘柄HTML: 外国株式 → 口座管理 → ページをHTMLとして保存
  3. 約定履歴CSV: 外国株式 → 取引履歴 → CSVダウンロード
  4. 入出金CSV: 入出金・振替 → 操作履歴 → CSVダウンロード

Contributing

git clone https://github.com/insighta-cloud/insighta-sbi-parser.git
cd insighta-sbi-parser
pip install -e ".[dev]"
pytest

License

MIT

Metadata

Release files for insighta-sbi-parser 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for insighta-sbi-parser 0.1.0
File Size Uploaded Provenance Actions
insighta_sbi_parser-0.1.0.tar.gz 12.7 kB With provenance Details for insighta_sbi_parser-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for insighta-sbi-parser 0.1.0
File Interpreter ABI Platform Actions
insighta_sbi_parser-0.1.0-py3-none-any.whl Python 3 none any Details for insighta_sbi_parser-0.1.0-py3-none-any.whl

Total release size: 25.8 kB

Release files / insighta_sbi_parser-0.1.0.tar.gz

Download URL insighta_sbi_parser-0.1.0.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f61bc8ea90b6f8183d9b63af6f3f7c8e25f7a0d5016bbac55486b0bf4bcd57a5
BLAKE2b-256 checksum
How to use checksums
737b72f5c41be187d087eaa6b02b1bbbee05d5f7d739f23844098620362afd29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 31, 2026.

Transparency log

Release files / insighta_sbi_parser-0.1.0-py3-none-any.whl

Download URL insighta_sbi_parser-0.1.0-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0dd8b95618968ddd0b433e5504722e266e647808597d418c5da20ed910a678b2
BLAKE2b-256 checksum
How to use checksums
f7817f124ac939f3bae05c9e6c9971d129dfd1aaede95c2a871344979a57e8ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 31, 2026.

Transparency log

Security for insighta-sbi-parser 0.1.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.

Select from 2 files

Attestation for insighta_sbi_parser-0.1.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 May 31, 2026.

Transparency log

A 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page