贷款还款计划计算器,支持等额本金、等额本息及浮动利率还款方式
Project description
loankit
贷款还款计划计算器,支持等额本金、等额本息,以及香港 H/P 利率联动场景下的浮动利率等额本息。
功能
- 等额本金 / 等额本息还款计划生成
- 两种方式并排对比,含逐期明细与利息节省比例
- 浮动利率等额本息:
--rate-changes按区间指定利率,区间外自动回退至封顶利率 - 浮动利率对比:
--compare --rate-changes同时输出封顶利率基准方案与实际方案的利息差 - 逐期明细含剩余本金列,方便核对银行账单
- Rich 彩色终端输出;
--no-color适合重定向到文件或管道
安装
推荐:pipx(隔离安装,全局可用)
pipx install loankit
pip(全局或虚拟环境)
pip install loankit
从源码安装
git clone https://github.com/gdufsh/loankit.git
cd loan
pip install .
快速上手
# 等额本息,100 万,年利率 3.25%,30 年
loan -p 1000000 -r 3.25 -m 360
# 等额本金
loan -p 1000000 -r 3.25 -m 360 -M equal-principal
# 两种方式对比(含逐期明细)
loan -p 1000000 -r 3.25 -m 360 --compare --compare-detail
# 浮动利率:前 24 期优惠利率 2.5%,之后回落至封顶利率 3.25%
loan -p 1000000 -r 3.25 -m 360 --rate-changes 1:24:2.5
# 浮动利率对比:封顶基准 vs 实际浮动方案
loan -p 1000000 -r 3.25 -m 360 --rate-changes 1:24:2.5 --compare
参数说明
| 参数 | 简写 | 说明 |
|---|---|---|
--principal |
-p |
贷款本金(元),如 1000000 |
--annual-rate |
-r |
年利率(百分比),如 3.25;浮动模式下为封顶利率 |
--months |
-m |
还款期数(月),如 360 |
--method |
-M |
还款方式:equal-installment(默认)、equal-principal;--compare 时忽略 |
--compare |
-c |
对比模式;与 --rate-changes 合用时输出浮动利率对比 |
--compare-detail |
-d |
对比模式下附加逐期明细(需配合 --compare) |
--rate-changes |
浮动利率区间,格式 x:y:rc[,x:y:rc,...],rc 不可超过 -r,区间不可重叠 |
|
--no-color |
-n |
禁用彩色输出(纯文本) |
--version |
-v |
显示版本号 |
示例输出
等额本息(12 期)
还款计划 — 等额本息 | 本金 ¥1,000,000.00 | 年利率 3.25% | 期限 12 期
--------------------------------------------------------------------------------
期数 月供 还本金 还利息 剩余本金
--------------------------------------------------------------------------------
1 84,807.62 82,099.29 2,708.33 917,900.71
2 84,807.62 82,321.64 2,485.98 835,579.07
...
12 84,807.63 84,578.56 229.07 0.00
--------------------------------------------------------------------------------
总还款额: ¥ 1,017,691.45
总利息: ¥ 17,691.45
首期月供: ¥ 84,807.62
末期月供: ¥ 84,807.63
浮动利率(前 6 期 2.5%,后 6 期 3.25%)
还款计划 — 浮动利率等额本息 | 本金 ¥1,000,000.00 | 封顶利率 3.25% | 期限 12 期
--------------------------------------------------------------------------------------------
期数 月供 还本金 还利息 剩余本金 年利率
--------------------------------------------------------------------------------------------
1 84,466.11 82,382.78 2,083.33 917,617.22 2.5%
...
7 84,650.27 83,287.65 1,362.62 419,834.06 3.25% <- 利率变更
...
12 84,650.28 84,421.64 228.64 0.00
--------------------------------------------------------------------------------------------
总还款额: ¥ 1,014,698.29
总利息: ¥ 14,698.29
两种方式对比
还款方式对比 | 本金 ¥1,000,000.00 | 年利率 3.25% | 期限 12 期
================================================================================
指标 等额本金 等额本息 差异(EI-EP)
--------------------------------------------------------------------------------
首月月供(元) 86,041.66 84,807.62 -1,234.04
末月月供(元) 83,559.06 84,807.63 1,248.57
月均月供(元) 84,800.35 84,807.62 7.27
总还款额(元) 1,017,604.16 1,017,691.45 87.29
总利息(元) 17,604.16 17,691.45 87.29
利息节省比例 0.49% 基准 —
================================================================================
算法说明
- 等额本金:每月还款本金固定,利息随剩余本金递减。
- 等额本息:按 PMT 公式一次性计算固定月供,末期本金取剩余余额以消除舍入误差。
- 浮动利率等额本息:每期按当期利率与剩余期数重新计算 PMT,期数固定不延长,末期同样取剩余余额归零。
- 所有金额使用
decimal.Decimal精确计算,舍入至分(ROUND_HALF_UP)。
开发
git clone https://github.com/gdufsh/loankit.git
cd loan
pip install -e ".[dev]"
# 运行测试
pytest
# 代码检查
ruff check src/ tests/
ruff format src/ tests/
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file loankit-0.1.0.tar.gz.
File metadata
- Download URL: loankit-0.1.0.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec69d51ae754122e9373526a9e140770c01355cb11d0722d860f44c03b7349b1
|
|
| MD5 |
6805363d3781f1a33ad2994df59abac2
|
|
| BLAKE2b-256 |
a57c740732c98ed60ab10b5ca1eeacc47eb4f5dcbb37304fe92509e0897e7a51
|
Provenance
The following attestation bundles were made for loankit-0.1.0.tar.gz:
Publisher:
publish.yml on gdufsh/loankit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
loankit-0.1.0.tar.gz -
Subject digest:
ec69d51ae754122e9373526a9e140770c01355cb11d0722d860f44c03b7349b1 - Sigstore transparency entry: 1519004854
- Sigstore integration time:
-
Permalink:
gdufsh/loankit@4d2a425d1cd1339db31fae8058603c0b6acbb9c4 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/gdufsh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4d2a425d1cd1339db31fae8058603c0b6acbb9c4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file loankit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: loankit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64904d5eedd6fc759cfee91acda74f4dad8b8d2acfe835f07c97f439ce9b3434
|
|
| MD5 |
84292f8bd5d966043476683afdec899b
|
|
| BLAKE2b-256 |
bc82eb3a9cf9d4c9a70446d979b1dfcdff08c4e35fd138cc8cd1519200d576c2
|
Provenance
The following attestation bundles were made for loankit-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on gdufsh/loankit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
loankit-0.1.0-py3-none-any.whl -
Subject digest:
64904d5eedd6fc759cfee91acda74f4dad8b8d2acfe835f07c97f439ce9b3434 - Sigstore transparency entry: 1519004895
- Sigstore integration time:
-
Permalink:
gdufsh/loankit@4d2a425d1cd1339db31fae8058603c0b6acbb9c4 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/gdufsh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4d2a425d1cd1339db31fae8058603c0b6acbb9c4 -
Trigger Event:
push
-
Statement type: