Skip to main content

usdrate

usdrateは、七十七銀行の為替情報サイトからUSD/JPYの仲値データを取得・キャッシュし、指定した日付の為替レートを簡単に問い合わせるためのCLIツールです。RSUの申告の際に過去にVestされた際の仲値を一々調べるのが辛くなって作りました。

動作概要

  • キャッシュデータの確認をし、なかった場合は現在の西暦および過去7年分(合計8年分)の為替データを七十七銀行から取得します。
  • キャッシュデータはパッケージ内のキャッシュディレクトリに保存され、以降の実行で再利用されます。
  • 指定した日付のUSD/JPY仲値をコマンドラインから問い合わせができます。

インストール

以下のコマンドでインストールできます:

pip install usdrate

ChromeDriverについて

-pオプションを利用する場合はChromeDriverが必要になります。

ChromeDriverのインストール方法については、以下のURLを参照し、手動でインストールしてください:

https://developer.chrome.com/docs/chromedriver/downloads?hl=ja

使い方

基本的な使い方

指定した日付の為替仲値を取得するには、以下のようにコマンドを実行します:

usdrate 2024/08/27
The USD/JPY mid rate on 2024-08-27 is 144.86.

このコマンドは、2024年8月27日のUSD/JPY仲値を表示します。

キャッシュの更新

キャッシュを更新したい場合は、--updateまたは-uオプションを使用します:

usdrate 2024/01/01 --update

PDF出力機能

-p(または--pdfoutput)オプションを指定すると、確定申告時の根拠資料となるPDFもダウンロードします。

  • 過去の年度のPDFは、既に存在する場合はダウンロードされません。
  • 今年のデータに関しては毎日更新されるため、-pが指定された場合は既存のPDFがあっても最新のPDFに更新されます。

一括問い合わせ機能

-b(または--bulk)オプションを使用すると、Enter区切りで日付が記載されたファイルを指定できます。 この場合、ファイル内の各日付に対してUSD/JPYの仲値が順次表示されます。

一括問い合わせファイルの例

以下は、一括問い合わせ用のファイル例です。 各行に問い合わせたい日付を記入します:

2024/08/27
2024/08/28
2024/09/01

このようなファイルを用意し、-bオプションで指定してください。

Release情報

0.2.3リリース

以下の機能拡張が追加されています:

  • Retry処理の追加: 一時的に七十七銀行へのアクセスができなかったとしても3回retryするように変更。

0.2.2リリース

以下の機能拡張が追加されています:

  • loggerの導入: 一部print文をloggerに置き換えました。

0.2.0リリース

以下の機能拡張が追加されています:

  • PDF出力: HTMLからPDFを生成し、キャッシュディレクトリ内のpdfsフォルダに保存します。 特に、今年のデータは常に最新の状態に更新されます。

  • 一括問い合わせ: 複数の日付を1つのファイルに記載することで、一度に複数の日付の仲値を問い合わせることができます。

ライセンス

このプロジェクトはMITライセンスの下で公開されています。

作者

kon0n0 (kono@ms1.kononet.jp)

Metadata

Release files for usdrate 0.2.6

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

Source distribution (sdist)

Source distribution for usdrate 0.2.6
File Size Uploaded Provenance Actions
usdrate-0.2.6.tar.gz 7.4 kB Without provenance Details for usdrate-0.2.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for usdrate 0.2.6
File Interpreter ABI Platform Actions
usdrate-0.2.6-py3-none-any.whl Python 3 none any Details for usdrate-0.2.6-py3-none-any.whl

Total release size: 14.8 kB

Release files / usdrate-0.2.6.tar.gz

Download URL usdrate-0.2.6.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8f14905f332fe186f7707c99e44a20139cb487a63e9f07e7fe7bd681224e881b
BLAKE2b-256 checksum
How to use checksums
6fbc38b696cfda3557674de2dc254fe79710706906e79334528b9b15c727bb2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.5

Release files / usdrate-0.2.6-py3-none-any.whl

Download URL usdrate-0.2.6-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f602a407e91c0cf8e0f2b25783f13e1eebeccd005a6d55b2f896787076f7c96
BLAKE2b-256 checksum
How to use checksums
8e1362d2d9e79135e03a3ffab7adea57cc301f99fafab5bc415fc9da4427eb37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.5

Security for usdrate 0.2.6

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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