# acctf
acctfは、銀行や証券会社をスクレイピングして入出金履歴、株や投信の保有数や取得価額、現在価格を取得するライブラリです。
下記の銀行や証券会社等に対応しています。
### 証券会社
* SBI証券
* 円建て
* 株式
* 株式(現物)
* 投信
* 投資信託(金額/特定預り)
* 投資信託(金額/NISA預り(つみたて投資枠))
* 投資信託(金額/旧つみたてNISA預り)
* 外貨建て(USのみ)
* 株式
* 株式(現物)
### 銀行
* みずほ銀行(円のみ)
* 預金
* 入出金履歴
* 住信SBIネット銀行
* 預金(ハイブリッド含む)(円のみ)
* 入出金履歴
* 代表口座
* ハイブリッド預金口座
* 目的別口座
### その他
* WealthNavi(円表示のみ)
* 各資産クラス
# 利用方法
## インストール
```console
pip install acctf
```
## サンプル
### 証券会社
```python
from acctf.securities.sbi import SBI
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
driver = webdriver.Chrome(options=options)
sbi = SBI(driver=driver).login("<ユーザID>", "<パスワード>")
stocks = sbi.get_stock_specific()
print("銘柄, 数量, 取得単価, 現在値")
for s in stocks:
print(f"{s.name}, {s.amount}, {s.acquisition_value}, {s.current_value}")
sbi.logout()
sbi.close()
```
```console
銘柄, 数量, 取得単価, 現在値
0000 銘柄1, 1000, 1234, 2345
1111 銘柄2, 1500, 789, 987
2222 銘柄3, 2000, 3450, 3456
```
### 銀行
#### 預金
```python
from acctf.bank.mizuho import Mizuho
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
driver = webdriver.Chrome(options=options)
mizuho = Mizuho(driver=driver).login("<ユーザID>", "<パスワード>")
b = mizuho.get_balance("7654321")
print(f"口座番号, 店舗, 残高, 口座タイプ")
print(f"{b[0].account_number}, {b[0].branch_name}, {b[0].value}, {b[0].deposit_type}")
mizuho.logout()
mizuho.close()
```
```console
口座番号, 店舗, 残高, 口座タイプ
7654321, 本店, 1234567.0, DepositType.ordinary
```
#### 入出金履歴
下記はみずほ銀行の例です。
```python
from acctf.bank.mizuho import Mizuho
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
driver = webdriver.Chrome(options=options)
mizuho = Mizuho(driver=driver).login("<ユーザID>", "<パスワード>")
hist = mizuho.get_transaction_history("7654321")
# You can also specify the start/end date.
# hist = mizuho.get_transaction_history("7654321", date(2023, 12, 1), date(2023, 12, 31))
print(f"日付, 取引内容, 金額")
for h in hist:
print(f"{h.date}, {h.content}, {h.value}")
mizuho.logout()
mizuho.close()
```
```console
日付, 取引内容, 金額
2023-12-01, ATM引き出し, -10000.0
2024-12-20, 給与, 200000.0
```
住信SBIネット銀行はUIの変更に伴い、履歴のCSVをダウンロードしてデータを取得する方式に変更しました。そのため、ドライバの設定時にダウンロードディレクトリを指定してください。
また、ダウンロードしたCSVファイルはデータ取得後に削除されます。
```python
from pathlib import Path
from acctf.bank.sbi import SBI
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from datetime import date
from acctf.bank.sbi import AccountName
from acctf.bank import CurrencyType
download_directory = str(Path.cwd()) + "/tmp"
options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_experimental_option("prefs", {
"download.default_directory": download_directory,
})
driver = webdriver.Chrome(options=options)
# Firefoxを利用する場合
# options = webdriver.FirefoxOptions()
# options.add_argument("-headless")
# options.set_preference("browser.download.folderList", 2)
# options.set_preference("browser.download.dir", download_directory)
# service = webdriver.FirefoxService()
# driver = webdriver.Firefox(service=service, options=options)
sbi = SBI(driver=driver).login("<ユーザID>", "<パスワード>")
hist = sbi.get_transaction_history(
"7654321",
date(2023, 12, 1),
date(2023, 12, 31),
download_directory=download_directory,
currency=CurrencyType.jpy,
account_name=AccountName.Representative # 代表口座
)
hist += sbi.get_transaction_history(
"7654321",
date(2023, 12, 1),
date(2023, 12, 31),
download_directory=download_directory,
currency=CurrencyType.jpy,
account_name=AccountName.Hybrid # ハイブリッド預金口座
)
print(f"日付, 取引内容, 金額")
for h in hist:
print(f"{h.date}, {h.content}, {h.value}")
sbi.logout()
sbi.close()
```
### その他
#### WealthNavi
```python
from acctf.other.wealthnavi import WealthNavi
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
driver = webdriver.Chrome(options=options)
w = WealthNavi(driver=driver).login("<ユーザID>", "<パスワード>", "<TOTP>")
# Time-based One Time Passwordを設定していない場合
# w = WealthNavi().login("<ユーザID>", "<パスワード>")
print("資産クラス, 現在価格, 損益")
for h in w.get_valuation():
print(f"{h.name}, {h.value}, {h.pl_value}")
w.logout()
w.close()
```
```console
資産クラス, 現在価格, 損益
米国株(VTI), 123456.0, 12345.0
日欧株(VEA), 123456.0, 12345.0
新興国株(VWO), 123456.0, 12345.0
債券(AGG), 123456.0, 12345.0
金(GLD), 123456.0, 12345.0
金(IAU), 123456.0, 12345.0
不動産(IYR), 123456.0, 12345.0
現金, 123456.0, 0.0
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hirano00o/acctf",
"name": "acctf",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "scrape, account, development",
"author": "hirano00o",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/e3/3b/dbb82bea3569e095c7672b95c040b8a8f36b8246b94eb553ca234696c52e/acctf-0.5.1.tar.gz",
"platform": null,
"description": "# acctf\n\nacctf\u306f\u3001\u9280\u884c\u3084\u8a3c\u5238\u4f1a\u793e\u3092\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u3057\u3066\u5165\u51fa\u91d1\u5c65\u6b74\u3001\u682a\u3084\u6295\u4fe1\u306e\u4fdd\u6709\u6570\u3084\u53d6\u5f97\u4fa1\u984d\u3001\u73fe\u5728\u4fa1\u683c\u3092\u53d6\u5f97\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002\n\n\u4e0b\u8a18\u306e\u9280\u884c\u3084\u8a3c\u5238\u4f1a\u793e\u7b49\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002\n### \u8a3c\u5238\u4f1a\u793e\n* SBI\u8a3c\u5238\n * \u5186\u5efa\u3066\n * \u682a\u5f0f\n * \u682a\u5f0f(\u73fe\u7269)\n * \u6295\u4fe1\n * \u6295\u8cc7\u4fe1\u8a17\uff08\u91d1\u984d/\u7279\u5b9a\u9810\u308a\uff09\n * \u6295\u8cc7\u4fe1\u8a17\uff08\u91d1\u984d/NISA\u9810\u308a\uff08\u3064\u307f\u305f\u3066\u6295\u8cc7\u67a0\uff09\uff09\n * \u6295\u8cc7\u4fe1\u8a17\uff08\u91d1\u984d/\u65e7\u3064\u307f\u305f\u3066NISA\u9810\u308a\uff09\n * \u5916\u8ca8\u5efa\u3066(US\u306e\u307f)\n * \u682a\u5f0f\n * \u682a\u5f0f(\u73fe\u7269)\n\n### \u9280\u884c\n* \u307f\u305a\u307b\u9280\u884c(\u5186\u306e\u307f)\n * \u9810\u91d1\n * \u5165\u51fa\u91d1\u5c65\u6b74\n* \u4f4f\u4fe1SBI\u30cd\u30c3\u30c8\u9280\u884c\n * \u9810\u91d1(\u30cf\u30a4\u30d6\u30ea\u30c3\u30c9\u542b\u3080)(\u5186\u306e\u307f)\n * \u5165\u51fa\u91d1\u5c65\u6b74\n * \u4ee3\u8868\u53e3\u5ea7\n * \u30cf\u30a4\u30d6\u30ea\u30c3\u30c9\u9810\u91d1\u53e3\u5ea7\n * \u76ee\u7684\u5225\u53e3\u5ea7\n\n### \u305d\u306e\u4ed6\n* WealthNavi(\u5186\u8868\u793a\u306e\u307f)\n * \u5404\u8cc7\u7523\u30af\u30e9\u30b9\n\n# \u5229\u7528\u65b9\u6cd5\n\n## \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\n\n```console\npip install acctf\n```\n\n## \u30b5\u30f3\u30d7\u30eb\n\n### \u8a3c\u5238\u4f1a\u793e\n\n```python\nfrom acctf.securities.sbi import SBI\nfrom selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\n\noptions = Options()\noptions.add_argument('--headless')\noptions.add_argument('--no-sandbox')\ndriver = webdriver.Chrome(options=options)\n\nsbi = SBI(driver=driver).login(\"<\u30e6\u30fc\u30b6ID>\", \"<\u30d1\u30b9\u30ef\u30fc\u30c9>\")\nstocks = sbi.get_stock_specific()\nprint(\"\u9298\u67c4, \u6570\u91cf, \u53d6\u5f97\u5358\u4fa1, \u73fe\u5728\u5024\")\nfor s in stocks:\n print(f\"{s.name}, {s.amount}, {s.acquisition_value}, {s.current_value}\")\n\nsbi.logout()\nsbi.close()\n```\n\n```console\n\u9298\u67c4, \u6570\u91cf, \u53d6\u5f97\u5358\u4fa1, \u73fe\u5728\u5024\n0000 \u9298\u67c41, 1000, 1234, 2345\n1111 \u9298\u67c42, 1500, 789, 987\n2222 \u9298\u67c43, 2000, 3450, 3456\n```\n\n### \u9280\u884c\n\n#### \u9810\u91d1\n\n```python\nfrom acctf.bank.mizuho import Mizuho\nfrom selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\n\noptions = Options()\noptions.add_argument('--headless')\noptions.add_argument('--no-sandbox')\ndriver = webdriver.Chrome(options=options)\n\nmizuho = Mizuho(driver=driver).login(\"<\u30e6\u30fc\u30b6ID>\", \"<\u30d1\u30b9\u30ef\u30fc\u30c9>\")\nb = mizuho.get_balance(\"7654321\")\nprint(f\"\u53e3\u5ea7\u756a\u53f7, \u5e97\u8217, \u6b8b\u9ad8, \u53e3\u5ea7\u30bf\u30a4\u30d7\")\nprint(f\"{b[0].account_number}, {b[0].branch_name}, {b[0].value}, {b[0].deposit_type}\")\n\nmizuho.logout()\nmizuho.close()\n```\n\n```console\n\u53e3\u5ea7\u756a\u53f7, \u5e97\u8217, \u6b8b\u9ad8, \u53e3\u5ea7\u30bf\u30a4\u30d7\n7654321, \u672c\u5e97, 1234567.0, DepositType.ordinary\n```\n\n#### \u5165\u51fa\u91d1\u5c65\u6b74\n\n\u4e0b\u8a18\u306f\u307f\u305a\u307b\u9280\u884c\u306e\u4f8b\u3067\u3059\u3002\n\n```python\nfrom acctf.bank.mizuho import Mizuho\nfrom selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\n\noptions = Options()\noptions.add_argument('--headless')\noptions.add_argument('--no-sandbox')\ndriver = webdriver.Chrome(options=options)\n\nmizuho = Mizuho(driver=driver).login(\"<\u30e6\u30fc\u30b6ID>\", \"<\u30d1\u30b9\u30ef\u30fc\u30c9>\")\nhist = mizuho.get_transaction_history(\"7654321\")\n# You can also specify the start/end date.\n# hist = mizuho.get_transaction_history(\"7654321\", date(2023, 12, 1), date(2023, 12, 31))\nprint(f\"\u65e5\u4ed8, \u53d6\u5f15\u5185\u5bb9, \u91d1\u984d\")\nfor h in hist:\n print(f\"{h.date}, {h.content}, {h.value}\")\n\nmizuho.logout()\nmizuho.close()\n```\n\n```console\n\u65e5\u4ed8, \u53d6\u5f15\u5185\u5bb9, \u91d1\u984d\n2023-12-01, \uff21\uff34\uff2d\u5f15\u304d\u51fa\u3057, -10000.0\n2024-12-20, \u7d66\u4e0e, 200000.0\n```\n\n\u4f4f\u4fe1SBI\u30cd\u30c3\u30c8\u9280\u884c\u306fUI\u306e\u5909\u66f4\u306b\u4f34\u3044\u3001\u5c65\u6b74\u306eCSV\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u65b9\u5f0f\u306b\u5909\u66f4\u3057\u307e\u3057\u305f\u3002\u305d\u306e\u305f\u3081\u3001\u30c9\u30e9\u30a4\u30d0\u306e\u8a2d\u5b9a\u6642\u306b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\u307e\u305f\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305fCSV\u30d5\u30a1\u30a4\u30eb\u306f\u30c7\u30fc\u30bf\u53d6\u5f97\u5f8c\u306b\u524a\u9664\u3055\u308c\u307e\u3059\u3002\n\n```python\nfrom pathlib import Path\n\nfrom acctf.bank.sbi import SBI\nfrom selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\nfrom datetime import date\n\nfrom acctf.bank.sbi import AccountName\nfrom acctf.bank import CurrencyType\n\ndownload_directory = str(Path.cwd()) + \"/tmp\"\noptions = Options()\noptions.add_argument('--headless')\noptions.add_argument('--no-sandbox')\noptions.add_experimental_option(\"prefs\", {\n \"download.default_directory\": download_directory,\n})\ndriver = webdriver.Chrome(options=options)\n\n# Firefox\u3092\u5229\u7528\u3059\u308b\u5834\u5408\n# options = webdriver.FirefoxOptions()\n# options.add_argument(\"-headless\")\n# options.set_preference(\"browser.download.folderList\", 2)\n# options.set_preference(\"browser.download.dir\", download_directory)\n# service = webdriver.FirefoxService()\n# driver = webdriver.Firefox(service=service, options=options)\n\nsbi = SBI(driver=driver).login(\"<\u30e6\u30fc\u30b6ID>\", \"<\u30d1\u30b9\u30ef\u30fc\u30c9>\")\nhist = sbi.get_transaction_history(\n \"7654321\",\n date(2023, 12, 1),\n date(2023, 12, 31),\n download_directory=download_directory,\n currency=CurrencyType.jpy,\n account_name=AccountName.Representative # \u4ee3\u8868\u53e3\u5ea7\n)\nhist += sbi.get_transaction_history(\n \"7654321\",\n date(2023, 12, 1),\n date(2023, 12, 31),\n download_directory=download_directory,\n currency=CurrencyType.jpy,\n account_name=AccountName.Hybrid # \u30cf\u30a4\u30d6\u30ea\u30c3\u30c9\u9810\u91d1\u53e3\u5ea7\n)\n\nprint(f\"\u65e5\u4ed8, \u53d6\u5f15\u5185\u5bb9, \u91d1\u984d\")\nfor h in hist:\n print(f\"{h.date}, {h.content}, {h.value}\")\n\nsbi.logout()\nsbi.close()\n```\n\n### \u305d\u306e\u4ed6\n\n#### WealthNavi\n\n```python\nfrom acctf.other.wealthnavi import WealthNavi\nfrom selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\n\noptions = Options()\noptions.add_argument('--headless')\noptions.add_argument('--no-sandbox')\ndriver = webdriver.Chrome(options=options)\n\nw = WealthNavi(driver=driver).login(\"<\u30e6\u30fc\u30b6ID>\", \"<\u30d1\u30b9\u30ef\u30fc\u30c9>\", \"<TOTP>\")\n# Time-based One Time Password\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u306a\u3044\u5834\u5408\n# w = WealthNavi().login(\"<\u30e6\u30fc\u30b6ID>\", \"<\u30d1\u30b9\u30ef\u30fc\u30c9>\")\nprint(\"\u8cc7\u7523\u30af\u30e9\u30b9, \u73fe\u5728\u4fa1\u683c, \u640d\u76ca\")\nfor h in w.get_valuation():\n print(f\"{h.name}, {h.value}, {h.pl_value}\")\n\nw.logout()\nw.close()\n```\n\n```console\n\u8cc7\u7523\u30af\u30e9\u30b9, \u73fe\u5728\u4fa1\u683c, \u640d\u76ca\n\u7c73\u56fd\u682a(VTI), 123456.0, 12345.0\n\u65e5\u6b27\u682a(VEA), 123456.0, 12345.0\n\u65b0\u8208\u56fd\u682a(VWO), 123456.0, 12345.0\n\u50b5\u5238(AGG), 123456.0, 12345.0\n\u91d1(GLD), 123456.0, 12345.0\n\u91d1(IAU), 123456.0, 12345.0\n\u4e0d\u52d5\u7523(IYR), 123456.0, 12345.0\n\u73fe\u91d1, 123456.0, 0.0\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "library that scrapes the data from an account such as securities, bank",
"version": "0.5.1",
"project_urls": {
"Homepage": "https://github.com/hirano00o/acctf"
},
"split_keywords": [
"scrape",
" account",
" development"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0b7d1468fc96854f86b405f6650e0ccc0e68fb55026228eb4fc6f59fe4f85555",
"md5": "a3f20a92c943a82f313586e81d315012",
"sha256": "cff9bf624c8f88003f828a145c7304fff39d8857d45a6015c2650fc0060292ef"
},
"downloads": -1,
"filename": "acctf-0.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a3f20a92c943a82f313586e81d315012",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 16455,
"upload_time": "2024-10-29T10:58:33",
"upload_time_iso_8601": "2024-10-29T10:58:33.541076Z",
"url": "https://files.pythonhosted.org/packages/0b/7d/1468fc96854f86b405f6650e0ccc0e68fb55026228eb4fc6f59fe4f85555/acctf-0.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e33bdbb82bea3569e095c7672b95c040b8a8f36b8246b94eb553ca234696c52e",
"md5": "70ee6b69af01e2faa62f9cf91a6d2736",
"sha256": "cce89b3c2df36611cf8651558dfef7469e0d9b7f49687006219bc92e636c87c3"
},
"downloads": -1,
"filename": "acctf-0.5.1.tar.gz",
"has_sig": false,
"md5_digest": "70ee6b69af01e2faa62f9cf91a6d2736",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 13671,
"upload_time": "2024-10-29T10:58:34",
"upload_time_iso_8601": "2024-10-29T10:58:34.971084Z",
"url": "https://files.pythonhosted.org/packages/e3/3b/dbb82bea3569e095c7672b95c040b8a8f36b8246b94eb553ca234696c52e/acctf-0.5.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-29 10:58:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hirano00o",
"github_project": "acctf",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "acctf"
}