eqlx-bankmath 0.1.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.
- eqlx_bankmath-0.1.0/LICENSE +176 -0
- eqlx_bankmath-0.1.0/PKG-INFO +184 -0
- eqlx_bankmath-0.1.0/README.md +163 -0
- eqlx_bankmath-0.1.0/pyproject.toml +89 -0
- eqlx_bankmath-0.1.0/pyproject.toml.orig +61 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/__init__.py +11 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/adat.py +132 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/card.py +633 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/cli.py +129 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/costrate.py +125 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/daycount.py +85 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/discount.py +218 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/errors.py +5 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/floating.py +290 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/guarantee.py +545 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/installment.py +481 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/mcp_server.py +38 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/money.py +102 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/overdraft.py +196 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/prepayment_fee.py +250 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/py.typed +0 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/revolving.py +493 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/tools.py +563 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/tr/__init__.py +0 -0
- eqlx_bankmath-0.1.0/src/eqlx_bankmath/tr/rates.py +108 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: eqlx-bankmath
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deterministic bank product arithmetic for Türkiye: instalment plans with KKDF and BSMV, annual cost rate, overdraft and revolving interest, credit card statements, guarantee commissions. Exact to the kuruş. Read-only MCP server for AI agents.
|
|
5
|
+
Keywords: loan,amortization,apr,kredi,kkdf,bsmv,overdraft,credit card,letter of guarantee,turkey,mcp
|
|
6
|
+
Author: Can Demir
|
|
7
|
+
Author-email: Can Demir <can.demir@eqlx.ai>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
15
|
+
Requires-Dist: mcp>=2.3.0 ; extra == 'mcp'
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Project-URL: Homepage, https://eqlx.org
|
|
18
|
+
Project-URL: Source, https://github.com/eqlx-ai/eqlx-bankmath
|
|
19
|
+
Provides-Extra: mcp
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# eqlx-bankmath
|
|
23
|
+
|
|
24
|
+
Deterministic arithmetic for bank products in Türkiye, exact to the kuruş. A Python library, a
|
|
25
|
+
command line tool and an MCP server, so that an AI agent asks for the number instead of working it
|
|
26
|
+
out itself.
|
|
27
|
+
|
|
28
|
+
- **Instalment loans** (consumer, housing, commercial): the repayment plan with KKDF and BSMV on
|
|
29
|
+
interest, the annual cost rate the regulation defines, early repayment, partial prepayment, late
|
|
30
|
+
interest, and the questions asked backwards ("what can I borrow for 5,000 a month?").
|
|
31
|
+
- **Daily-balance products**: retail overdraft (KMH), revolving lines and current accounts
|
|
32
|
+
(rotatif, borçlu cari hesap), spot loans.
|
|
33
|
+
- **Credit cards**: minimum payment, rate ceilings, and the interest one statement puts on the next.
|
|
34
|
+
- **Bills and variable rates**: discounting of bills and cheques, plans that reprice, a compounded
|
|
35
|
+
reference rate.
|
|
36
|
+
- **Letters of guarantee**: commission period by period, under the convention you choose.
|
|
37
|
+
- **Ceilings**: is a fee or a rate within the regulated maximum, and under which rule?
|
|
38
|
+
|
|
39
|
+
Same input, same output. No model inside, no network, no data leaves the machine.
|
|
40
|
+
|
|
41
|
+
## Why not let the model do the arithmetic
|
|
42
|
+
|
|
43
|
+
A consumer loan of 100,000 TL at 3.99 % a month for 24 months, disbursed on 10 November 2026 with a
|
|
44
|
+
500 TL allocation fee:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
bankmath plan 100000 0.0399 24 --product consumer --date 2026-11-10 --fee 500
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
instalment 7,379.48 last 7,379.72 total repayment 177,607.76 total cost 77,607.76
|
|
52
|
+
annual cost rate 84.5548 % (monthly rate alone: 59.9186 % a year)
|
|
53
|
+
KKDF 15.00% BSMV 15.00% levies: Council of Ministers Decision 2010/974; Presidential Decision 7345 (Official Gazette 07.07.2023)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The rate on the poster is 59.92 % a year; what the borrower pays is 84.55 %. The difference is two
|
|
57
|
+
levies on interest and a fee. A language model asked for the instalment will produce a plausible
|
|
58
|
+
number; this produces the number, the levy rates that applied on that date, and the decree behind each.
|
|
59
|
+
|
|
60
|
+
## Install
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install eqlx-bankmath # library and command line; no dependencies
|
|
64
|
+
pip install "eqlx-bankmath[mcp]" # with the MCP server
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Python 3.10 or later.
|
|
68
|
+
|
|
69
|
+
## For AI agents (MCP)
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
claude mcp add bankmath -- bankmath mcp
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Eighteen read-only tools; none reads or writes a file. `bankmath tools` lists them with their
|
|
76
|
+
arguments, and `bankmath call <tool> '<json>'` runs any of them from a terminal.
|
|
77
|
+
|
|
78
|
+
| Tool | What it returns |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `loan_plan` | instalment, every row split into interest, KKDF, BSMV, principal; total cost; annual cost rate |
|
|
81
|
+
| `loan_early_repayment` | payoff amount and saving, or the new instalment after a partial prepayment |
|
|
82
|
+
| `loan_affordability` | largest loan for an instalment, shortest term, or the instalment |
|
|
83
|
+
| `late_payment_interest` | default interest on a late instalment, within the 1.3 x ceiling |
|
|
84
|
+
| `annual_cost_rate` | the regulation's rate for any set of cash flows |
|
|
85
|
+
| `levies` | KKDF and BSMV in force for a product on a date, with the legal basis |
|
|
86
|
+
| `overdraft_interest` | a period of retail overdraft use on daily balances |
|
|
87
|
+
| `revolving_line` | a commercial line over several accrual periods, with rate changes |
|
|
88
|
+
| `spot_loan` | simple interest to maturity, levies, annual cost |
|
|
89
|
+
| `balance_interest` | the interest-number (adat) method on any list of balances and days |
|
|
90
|
+
| `bill_discount` | interest taken up front, net proceeds, the rate really paid |
|
|
91
|
+
| `floating_rate_plan` | an instalment plan that reprices |
|
|
92
|
+
| `compounded_reference_rate` | an overnight rate compounded over a period |
|
|
93
|
+
| `card_minimum_payment` | minimum payment under the BDDK decision in force |
|
|
94
|
+
| `card_rate_caps` | monthly rate ceilings from the TCMB reference rate |
|
|
95
|
+
| `card_statement_interest` | what one statement adds to the next |
|
|
96
|
+
| `guarantee_commission` | commission schedule of a letter of guarantee |
|
|
97
|
+
| `fee_cap_check` | a quoted fee against the regulated ceiling |
|
|
98
|
+
|
|
99
|
+
## Conventions are arguments, and results say which were used
|
|
100
|
+
|
|
101
|
+
For instalment loans the regulation fixes almost everything, and its annexes print worked examples.
|
|
102
|
+
For overdrafts, revolving lines, cards and letters of guarantee much is bank practice: the day
|
|
103
|
+
basis, the accrual dates, whether a started period is charged in full. Those choices change the
|
|
104
|
+
answer, so each is an explicit argument and every result lists the conventions it used.
|
|
105
|
+
|
|
106
|
+
A letter of guarantee of 10,000,000 TL at 2.40 % a year, issued 15 January, reduced by 4,000,000 on
|
|
107
|
+
15 June, returned on 2 November:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from eqlx_bankmath import tools
|
|
111
|
+
|
|
112
|
+
letter = dict(
|
|
113
|
+
amount=10_000_000,
|
|
114
|
+
commission_rate="0.024",
|
|
115
|
+
issue_date="2026-01-15",
|
|
116
|
+
bsmv="0.05",
|
|
117
|
+
expiry_date="2027-01-15",
|
|
118
|
+
return_date="2026-11-02",
|
|
119
|
+
)
|
|
120
|
+
reductions = [["2026-06-15", 4_000_000]]
|
|
121
|
+
|
|
122
|
+
full = tools.guarantee_commission(**letter, options={"reductions": reductions})
|
|
123
|
+
by_days = tools.guarantee_commission(**letter, options={"reductions": reductions, "started_period": "pro_rata"})
|
|
124
|
+
|
|
125
|
+
full["totals"]["cost"], full["effective_annual_cost_percent"] # 201600.0, 3.0883
|
|
126
|
+
by_days["totals"]["cost"], by_days["effective_annual_cost_percent"] # 164500.0, 2.52
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The same letter costs 201,600.00 TL when started quarters are charged in full without refund, and
|
|
130
|
+
164,500.00 TL when the commission follows the days outstanding. Neither is "the" answer; the tool
|
|
131
|
+
says which one it computed.
|
|
132
|
+
|
|
133
|
+
A card statement of 12,000 TL with a minimum of 2,400 TL, of which only 1,000 TL is paid: the
|
|
134
|
+
Regulation charges default interest on the unpaid part of the minimum, the Law's wording on the
|
|
135
|
+
whole remaining balance. `card_statement_interest` returns 372.36 TL of interest under the first
|
|
136
|
+
reading and 392.52 TL under the second (`shortfall_basis`).
|
|
137
|
+
|
|
138
|
+
## How it is verified
|
|
139
|
+
|
|
140
|
+
| What | Checked against |
|
|
141
|
+
|---|---|
|
|
142
|
+
| Consumer instalment plan, 12 and 36 months | Tüketici Kredisi Sözleşmeleri Yönetmeliği, Ek-1 and Ek-2: every figure, to the kuruş |
|
|
143
|
+
| Housing loan plan | Konut Finansmanı Sözleşmeleri Yönetmeliği, Ek-1 |
|
|
144
|
+
| Early repayment, partial prepayment, late interest | the same regulation, Ek-2, Ek-4, Ek-5 |
|
|
145
|
+
| Annual cost rate | the two annexes; Directive 98/7/EC Annex III (eight examples) |
|
|
146
|
+
| Levy rates by date | Presidential Decisions 5729, 7345, 10094; Decision 2010/974 |
|
|
147
|
+
| Commercial early repayment fee | TCMB implementation instruction: its two worked examples |
|
|
148
|
+
| Card rate ceilings | TCMB table valid from 1 November 2026 |
|
|
149
|
+
| Card minimum payment, overdraft limit | BDDK decisions 10222, 10970, 11581 and 11365 |
|
|
150
|
+
| Compounded reference rate | Borsa İstanbul's published TLREF example |
|
|
151
|
+
| Card statements, overdraft months | published bank examples, and arithmetic shown in the tests |
|
|
152
|
+
| Daily-balance interest, discounting, guarantees | textbook examples and arithmetic shown in the tests |
|
|
153
|
+
|
|
154
|
+
Where a printed official figure is itself inconsistent, the test asserts the correct value and says
|
|
155
|
+
why. Example: the regulation's early repayment example prints KKDF as 45.23 where 301.59 x 15 % is
|
|
156
|
+
45.24, and its annual rate as 16.4870 % where its own cash flows give 16.4872 %.
|
|
157
|
+
|
|
158
|
+
The first rows of the table are official worked examples. The last two are not: no regulator
|
|
159
|
+
publishes a full card statement or a commission schedule, so those parts are checked against their
|
|
160
|
+
definitions, not against an official number.
|
|
161
|
+
|
|
162
|
+
## Limits
|
|
163
|
+
|
|
164
|
+
A calculation, not an offer, a quote or legal advice. Levy rates and ceilings change by decree; the
|
|
165
|
+
tables carry the date they were last checked. Not covered: letters of credit, KGF guarantees, card
|
|
166
|
+
debt restructuring, instalment cash advances, FX revaluation, BDDK maturity and loan-to-value
|
|
167
|
+
tables. See [LIMITS.md](LIMITS.md).
|
|
168
|
+
|
|
169
|
+
## References
|
|
170
|
+
|
|
171
|
+
- Tüketici Kredisi Sözleşmeleri Yönetmeliği (Official Gazette 22.05.2015, no. 29363) and its annexes;
|
|
172
|
+
Konut Finansmanı Sözleşmeleri Yönetmeliği (28.05.2015, no. 29369); Law 6502.
|
|
173
|
+
- Law 6802 (BSMV); KKDF decisions 88/12944, 2010/974 and Presidential Decision 10094.
|
|
174
|
+
- TCMB Communiqués 2020/3, 2020/4, 2020/7, 2020/16 and their implementation instructions.
|
|
175
|
+
- Law 5464 and the Regulation on Bank Cards and Credit Cards; BDDK Board decisions on minimum
|
|
176
|
+
payments and overdraft limits.
|
|
177
|
+
- Turkish Commercial Code Article 8; Law 3095; Turkish Code of Obligations Articles 121 and 388.
|
|
178
|
+
- Directive 98/7/EC, Annex III; Directive 2008/48/EC, Annex I.
|
|
179
|
+
- Borsa İstanbul, TLREF rules.
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
Apache-2.0. Part of [eqlx.org](https://eqlx.org): deterministic tools for AI agents in credit and
|
|
184
|
+
finance. Questions: research@eqlx.ai.
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# eqlx-bankmath
|
|
2
|
+
|
|
3
|
+
Deterministic arithmetic for bank products in Türkiye, exact to the kuruş. A Python library, a
|
|
4
|
+
command line tool and an MCP server, so that an AI agent asks for the number instead of working it
|
|
5
|
+
out itself.
|
|
6
|
+
|
|
7
|
+
- **Instalment loans** (consumer, housing, commercial): the repayment plan with KKDF and BSMV on
|
|
8
|
+
interest, the annual cost rate the regulation defines, early repayment, partial prepayment, late
|
|
9
|
+
interest, and the questions asked backwards ("what can I borrow for 5,000 a month?").
|
|
10
|
+
- **Daily-balance products**: retail overdraft (KMH), revolving lines and current accounts
|
|
11
|
+
(rotatif, borçlu cari hesap), spot loans.
|
|
12
|
+
- **Credit cards**: minimum payment, rate ceilings, and the interest one statement puts on the next.
|
|
13
|
+
- **Bills and variable rates**: discounting of bills and cheques, plans that reprice, a compounded
|
|
14
|
+
reference rate.
|
|
15
|
+
- **Letters of guarantee**: commission period by period, under the convention you choose.
|
|
16
|
+
- **Ceilings**: is a fee or a rate within the regulated maximum, and under which rule?
|
|
17
|
+
|
|
18
|
+
Same input, same output. No model inside, no network, no data leaves the machine.
|
|
19
|
+
|
|
20
|
+
## Why not let the model do the arithmetic
|
|
21
|
+
|
|
22
|
+
A consumer loan of 100,000 TL at 3.99 % a month for 24 months, disbursed on 10 November 2026 with a
|
|
23
|
+
500 TL allocation fee:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
bankmath plan 100000 0.0399 24 --product consumer --date 2026-11-10 --fee 500
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
instalment 7,379.48 last 7,379.72 total repayment 177,607.76 total cost 77,607.76
|
|
31
|
+
annual cost rate 84.5548 % (monthly rate alone: 59.9186 % a year)
|
|
32
|
+
KKDF 15.00% BSMV 15.00% levies: Council of Ministers Decision 2010/974; Presidential Decision 7345 (Official Gazette 07.07.2023)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The rate on the poster is 59.92 % a year; what the borrower pays is 84.55 %. The difference is two
|
|
36
|
+
levies on interest and a fee. A language model asked for the instalment will produce a plausible
|
|
37
|
+
number; this produces the number, the levy rates that applied on that date, and the decree behind each.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install eqlx-bankmath # library and command line; no dependencies
|
|
43
|
+
pip install "eqlx-bankmath[mcp]" # with the MCP server
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Python 3.10 or later.
|
|
47
|
+
|
|
48
|
+
## For AI agents (MCP)
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
claude mcp add bankmath -- bankmath mcp
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Eighteen read-only tools; none reads or writes a file. `bankmath tools` lists them with their
|
|
55
|
+
arguments, and `bankmath call <tool> '<json>'` runs any of them from a terminal.
|
|
56
|
+
|
|
57
|
+
| Tool | What it returns |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `loan_plan` | instalment, every row split into interest, KKDF, BSMV, principal; total cost; annual cost rate |
|
|
60
|
+
| `loan_early_repayment` | payoff amount and saving, or the new instalment after a partial prepayment |
|
|
61
|
+
| `loan_affordability` | largest loan for an instalment, shortest term, or the instalment |
|
|
62
|
+
| `late_payment_interest` | default interest on a late instalment, within the 1.3 x ceiling |
|
|
63
|
+
| `annual_cost_rate` | the regulation's rate for any set of cash flows |
|
|
64
|
+
| `levies` | KKDF and BSMV in force for a product on a date, with the legal basis |
|
|
65
|
+
| `overdraft_interest` | a period of retail overdraft use on daily balances |
|
|
66
|
+
| `revolving_line` | a commercial line over several accrual periods, with rate changes |
|
|
67
|
+
| `spot_loan` | simple interest to maturity, levies, annual cost |
|
|
68
|
+
| `balance_interest` | the interest-number (adat) method on any list of balances and days |
|
|
69
|
+
| `bill_discount` | interest taken up front, net proceeds, the rate really paid |
|
|
70
|
+
| `floating_rate_plan` | an instalment plan that reprices |
|
|
71
|
+
| `compounded_reference_rate` | an overnight rate compounded over a period |
|
|
72
|
+
| `card_minimum_payment` | minimum payment under the BDDK decision in force |
|
|
73
|
+
| `card_rate_caps` | monthly rate ceilings from the TCMB reference rate |
|
|
74
|
+
| `card_statement_interest` | what one statement adds to the next |
|
|
75
|
+
| `guarantee_commission` | commission schedule of a letter of guarantee |
|
|
76
|
+
| `fee_cap_check` | a quoted fee against the regulated ceiling |
|
|
77
|
+
|
|
78
|
+
## Conventions are arguments, and results say which were used
|
|
79
|
+
|
|
80
|
+
For instalment loans the regulation fixes almost everything, and its annexes print worked examples.
|
|
81
|
+
For overdrafts, revolving lines, cards and letters of guarantee much is bank practice: the day
|
|
82
|
+
basis, the accrual dates, whether a started period is charged in full. Those choices change the
|
|
83
|
+
answer, so each is an explicit argument and every result lists the conventions it used.
|
|
84
|
+
|
|
85
|
+
A letter of guarantee of 10,000,000 TL at 2.40 % a year, issued 15 January, reduced by 4,000,000 on
|
|
86
|
+
15 June, returned on 2 November:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from eqlx_bankmath import tools
|
|
90
|
+
|
|
91
|
+
letter = dict(
|
|
92
|
+
amount=10_000_000,
|
|
93
|
+
commission_rate="0.024",
|
|
94
|
+
issue_date="2026-01-15",
|
|
95
|
+
bsmv="0.05",
|
|
96
|
+
expiry_date="2027-01-15",
|
|
97
|
+
return_date="2026-11-02",
|
|
98
|
+
)
|
|
99
|
+
reductions = [["2026-06-15", 4_000_000]]
|
|
100
|
+
|
|
101
|
+
full = tools.guarantee_commission(**letter, options={"reductions": reductions})
|
|
102
|
+
by_days = tools.guarantee_commission(**letter, options={"reductions": reductions, "started_period": "pro_rata"})
|
|
103
|
+
|
|
104
|
+
full["totals"]["cost"], full["effective_annual_cost_percent"] # 201600.0, 3.0883
|
|
105
|
+
by_days["totals"]["cost"], by_days["effective_annual_cost_percent"] # 164500.0, 2.52
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The same letter costs 201,600.00 TL when started quarters are charged in full without refund, and
|
|
109
|
+
164,500.00 TL when the commission follows the days outstanding. Neither is "the" answer; the tool
|
|
110
|
+
says which one it computed.
|
|
111
|
+
|
|
112
|
+
A card statement of 12,000 TL with a minimum of 2,400 TL, of which only 1,000 TL is paid: the
|
|
113
|
+
Regulation charges default interest on the unpaid part of the minimum, the Law's wording on the
|
|
114
|
+
whole remaining balance. `card_statement_interest` returns 372.36 TL of interest under the first
|
|
115
|
+
reading and 392.52 TL under the second (`shortfall_basis`).
|
|
116
|
+
|
|
117
|
+
## How it is verified
|
|
118
|
+
|
|
119
|
+
| What | Checked against |
|
|
120
|
+
|---|---|
|
|
121
|
+
| Consumer instalment plan, 12 and 36 months | Tüketici Kredisi Sözleşmeleri Yönetmeliği, Ek-1 and Ek-2: every figure, to the kuruş |
|
|
122
|
+
| Housing loan plan | Konut Finansmanı Sözleşmeleri Yönetmeliği, Ek-1 |
|
|
123
|
+
| Early repayment, partial prepayment, late interest | the same regulation, Ek-2, Ek-4, Ek-5 |
|
|
124
|
+
| Annual cost rate | the two annexes; Directive 98/7/EC Annex III (eight examples) |
|
|
125
|
+
| Levy rates by date | Presidential Decisions 5729, 7345, 10094; Decision 2010/974 |
|
|
126
|
+
| Commercial early repayment fee | TCMB implementation instruction: its two worked examples |
|
|
127
|
+
| Card rate ceilings | TCMB table valid from 1 November 2026 |
|
|
128
|
+
| Card minimum payment, overdraft limit | BDDK decisions 10222, 10970, 11581 and 11365 |
|
|
129
|
+
| Compounded reference rate | Borsa İstanbul's published TLREF example |
|
|
130
|
+
| Card statements, overdraft months | published bank examples, and arithmetic shown in the tests |
|
|
131
|
+
| Daily-balance interest, discounting, guarantees | textbook examples and arithmetic shown in the tests |
|
|
132
|
+
|
|
133
|
+
Where a printed official figure is itself inconsistent, the test asserts the correct value and says
|
|
134
|
+
why. Example: the regulation's early repayment example prints KKDF as 45.23 where 301.59 x 15 % is
|
|
135
|
+
45.24, and its annual rate as 16.4870 % where its own cash flows give 16.4872 %.
|
|
136
|
+
|
|
137
|
+
The first rows of the table are official worked examples. The last two are not: no regulator
|
|
138
|
+
publishes a full card statement or a commission schedule, so those parts are checked against their
|
|
139
|
+
definitions, not against an official number.
|
|
140
|
+
|
|
141
|
+
## Limits
|
|
142
|
+
|
|
143
|
+
A calculation, not an offer, a quote or legal advice. Levy rates and ceilings change by decree; the
|
|
144
|
+
tables carry the date they were last checked. Not covered: letters of credit, KGF guarantees, card
|
|
145
|
+
debt restructuring, instalment cash advances, FX revaluation, BDDK maturity and loan-to-value
|
|
146
|
+
tables. See [LIMITS.md](LIMITS.md).
|
|
147
|
+
|
|
148
|
+
## References
|
|
149
|
+
|
|
150
|
+
- Tüketici Kredisi Sözleşmeleri Yönetmeliği (Official Gazette 22.05.2015, no. 29363) and its annexes;
|
|
151
|
+
Konut Finansmanı Sözleşmeleri Yönetmeliği (28.05.2015, no. 29369); Law 6502.
|
|
152
|
+
- Law 6802 (BSMV); KKDF decisions 88/12944, 2010/974 and Presidential Decision 10094.
|
|
153
|
+
- TCMB Communiqués 2020/3, 2020/4, 2020/7, 2020/16 and their implementation instructions.
|
|
154
|
+
- Law 5464 and the Regulation on Bank Cards and Credit Cards; BDDK Board decisions on minimum
|
|
155
|
+
payments and overdraft limits.
|
|
156
|
+
- Turkish Commercial Code Article 8; Law 3095; Turkish Code of Obligations Articles 121 and 388.
|
|
157
|
+
- Directive 98/7/EC, Annex III; Directive 2008/48/EC, Annex I.
|
|
158
|
+
- Borsa İstanbul, TLREF rules.
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
Apache-2.0. Part of [eqlx.org](https://eqlx.org): deterministic tools for AI agents in credit and
|
|
163
|
+
finance. Questions: research@eqlx.ai.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "eqlx-bankmath"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Deterministic bank product arithmetic for Türkiye: instalment plans with KKDF and BSMV, annual cost rate, overdraft and revolving interest, credit card statements, guarantee commissions. Exact to the kuruş. Read-only MCP server for AI agents."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
keywords = [
|
|
10
|
+
"loan",
|
|
11
|
+
"amortization",
|
|
12
|
+
"apr",
|
|
13
|
+
"kredi",
|
|
14
|
+
"kkdf",
|
|
15
|
+
"bsmv",
|
|
16
|
+
"overdraft",
|
|
17
|
+
"credit card",
|
|
18
|
+
"letter of guarantee",
|
|
19
|
+
"turkey",
|
|
20
|
+
"mcp",
|
|
21
|
+
]
|
|
22
|
+
classifiers = [
|
|
23
|
+
"Development Status :: 3 - Alpha",
|
|
24
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
"Topic :: Office/Business :: Financial",
|
|
28
|
+
]
|
|
29
|
+
dependencies = []
|
|
30
|
+
|
|
31
|
+
[[project.authors]]
|
|
32
|
+
name = "Can Demir"
|
|
33
|
+
email = "can.demir@eqlx.ai"
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
mcp = ["mcp>=2.3.0"]
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
bankmath = "eqlx_bankmath.cli:main"
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://eqlx.org"
|
|
43
|
+
Source = "https://github.com/eqlx-ai/eqlx-bankmath"
|
|
44
|
+
|
|
45
|
+
[build-system]
|
|
46
|
+
requires = ["uv_build>=0.12.16,<0.13.0"]
|
|
47
|
+
build-backend = "uv_build"
|
|
48
|
+
|
|
49
|
+
[dependency-groups]
|
|
50
|
+
dev = [
|
|
51
|
+
"mypy>=2.4.1",
|
|
52
|
+
"pytest>=9.2.0",
|
|
53
|
+
"ruff>=0.17.4",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[tool.ruff]
|
|
57
|
+
line-length = 120
|
|
58
|
+
target-version = "py310"
|
|
59
|
+
|
|
60
|
+
[tool.ruff.lint]
|
|
61
|
+
select = [
|
|
62
|
+
"E",
|
|
63
|
+
"F",
|
|
64
|
+
"W",
|
|
65
|
+
"I",
|
|
66
|
+
"B",
|
|
67
|
+
"UP",
|
|
68
|
+
"N",
|
|
69
|
+
"SIM",
|
|
70
|
+
"RUF",
|
|
71
|
+
]
|
|
72
|
+
ignore = [
|
|
73
|
+
"RUF001",
|
|
74
|
+
"RUF002",
|
|
75
|
+
"RUF003",
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
[tool.ruff.lint.per-file-ignores]
|
|
79
|
+
"tests/*" = [
|
|
80
|
+
"E501",
|
|
81
|
+
"N817",
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
[tool.mypy]
|
|
85
|
+
strict = true
|
|
86
|
+
|
|
87
|
+
[[tool.mypy.overrides]]
|
|
88
|
+
module = ["mcp.*"]
|
|
89
|
+
ignore_missing_imports = true
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "eqlx-bankmath"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Deterministic bank product arithmetic for Türkiye: instalment plans with KKDF and BSMV, annual cost rate, overdraft and revolving interest, credit card statements, guarantee commissions. Exact to the kuruş. Read-only MCP server for AI agents."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Can Demir", email = "can.demir@eqlx.ai" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
keywords = ["loan", "amortization", "apr", "kredi", "kkdf", "bsmv", "overdraft", "credit card", "letter of guarantee", "turkey", "mcp"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Topic :: Office/Business :: Financial",
|
|
19
|
+
]
|
|
20
|
+
dependencies = []
|
|
21
|
+
|
|
22
|
+
[project.optional-dependencies]
|
|
23
|
+
mcp = [
|
|
24
|
+
"mcp>=2.3.0",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["uv_build>=0.12.16,<0.13.0"]
|
|
29
|
+
build-backend = "uv_build"
|
|
30
|
+
|
|
31
|
+
[dependency-groups]
|
|
32
|
+
dev = [
|
|
33
|
+
"mypy>=2.4.1",
|
|
34
|
+
"pytest>=9.2.0",
|
|
35
|
+
"ruff>=0.17.4",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
bankmath = "eqlx_bankmath.cli:main"
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://eqlx.org"
|
|
43
|
+
Source = "https://github.com/eqlx-ai/eqlx-bankmath"
|
|
44
|
+
|
|
45
|
+
[tool.ruff]
|
|
46
|
+
line-length = 120
|
|
47
|
+
target-version = "py310"
|
|
48
|
+
|
|
49
|
+
[tool.ruff.lint]
|
|
50
|
+
select = ["E", "F", "W", "I", "B", "UP", "N", "SIM", "RUF"]
|
|
51
|
+
ignore = ["RUF001", "RUF002", "RUF003"] # Turkish letters in names of laws and products
|
|
52
|
+
|
|
53
|
+
[tool.ruff.lint.per-file-ignores]
|
|
54
|
+
"tests/*" = ["E501", "N817"]
|
|
55
|
+
|
|
56
|
+
[tool.mypy]
|
|
57
|
+
strict = true
|
|
58
|
+
|
|
59
|
+
[[tool.mypy.overrides]]
|
|
60
|
+
module = ["mcp.*"]
|
|
61
|
+
ignore_missing_imports = true
|