A flexible compound interest calculator.
Project description
PyCIClib – Python Compound Interest Calculator
PyCIClib is a small Python package offering a versatile compound interest calculator for realistic investment analysis and personal finance applications. It supports variable interest rates and compounding frequencies, periodic contributions with flexible frequencies, 2 different contribution timings and tax adjustments. Additionally, the timeline() method returns a detailed pandas DataFrame that lets you visualize your growth scenarios and export the results to CSV or Excel files.
Calculation Details
For compounding purposes, the effective interest_rate is converted to an equivalent daily rate (p.d.) which is used internally for enhanced calculation accuracy. The system dynamically computes dates starting from the specified start_date; if no date is provided, today’s date datetime.today() is used by default. Interest is applied at the end of each period according to the selected frequency. Contributions are applied at the beginning of the period when contribution_timing is set to "start" and at the end when set to "end". If no value is provided, but there is an input for contribution and contribution_freq, then the default value is "end". For both comp_freq and contribution_freq, you can choose from the following options: "annually", "semiannually", "quarterly", "monthly", "biweekly", "weekly", and "daily". If no comp_freq is provided, it is automatically determined based on the given rate_basis.
Installation
pip install pyciclib
Example Usage
import pyciclib as pc
# creating an instance
calc = pc.CompoundInterest(
init_value=10_000,
interest_rate=0.05,
rate_basis="p.a.",
years=2,
start_date="21.02.2025",
comp_freq="annually",
contribution=100,
contribution_freq="monthly",
contribution_timing="start",
tax_rate=0.25,
)
# overview of all methods
print(calc.timeline())
print(calc.summary()) # you can also format this nicely with the json package
print(calc.future_value())
print(calc.total_contributions())
print(calc.total_gross_interest())
print(calc.total_tax_paid())
print(calc.total_net_interest())
# you can also write the detailed investment table to csv or excel with pandas
calc.timeline().to_csv("investment_details.csv", index=False)
calc.timeline().to_excel("investment_details.xlsx", index=False, engine="openpyxl")
Class Parameters
Required Parameters:
-
init_value: Initial investment -
interest_rate: Effective interest rate as decimal (e.g. 0.05 for 5%) -
rate_basis: Interest rate basis ("p.a.","p.m.", ...) -
years: Duration in years
Optional Parameters:
-
start_date: Starting date of the investment (datetime(),"YYYY-MM-DD"or"DD.MM.YYYY") -
comp_freq: Compounding frequency ("annually","semiannually", ...) -
contribution: Amount added each interval -
contribution_freq: Frequency of contributions ("annually","semiannually", ...) -
contribution_timing: Payment at start/end of period. ("start","end") -
tax_rate: Tax rate applied to interest immediately after compounding.
Available Methods
-
timeline(): Returns a detailed pandas dataframe of the investment (see table below) -
future_value(): Returns the future value of the investment -
summary(): Returns a dictonary of the inputs/outputs of the investment -
total_contributions(): Returns the total amount of contributions -
total_gross_interest(): Returns the total amount of gross interest earned -
total_tax_paid(): Returns the total amount of tax paid -
total_net_interest(): Returns the total amount of net interest earned
Sample table output
| date | weekday | start_balance | contribution | gross_interest | tax | net_interest | end_balance |
|---|---|---|---|---|---|---|---|
| 21.02.2025 | Fri | 10000.00 | 100.0 | 0.00 | 0.00 | 0.00 | 10100.00 |
| 21.03.2025 | Fri | 10100.00 | 100.0 | 0.00 | 0.00 | 0.00 | 10200.00 |
| 21.04.2025 | Mon | 10200.00 | 100.0 | 0.00 | 0.00 | 0.00 | 10300.00 |
| 21.05.2025 | Wed | 10300.00 | 100.0 | 0.00 | 0.00 | 0.00 | 10400.00 |
| 21.06.2025 | Sat | 10400.00 | 100.0 | 0.00 | 0.00 | 0.00 | 10500.00 |
| 21.07.2025 | Mon | 10500.00 | 100.0 | 0.00 | 0.00 | 0.00 | 10600.00 |
| 21.08.2025 | Thu | 10600.00 | 100.0 | 0.00 | 0.00 | 0.00 | 10700.00 |
| 21.09.2025 | Sun | 10700.00 | 100.0 | 0.00 | 0.00 | 0.00 | 10800.00 |
| 21.10.2025 | Tue | 10800.00 | 100.0 | 0.00 | 0.00 | 0.00 | 10900.00 |
| 21.11.2025 | Fri | 10900.00 | 100.0 | 0.00 | 0.00 | 0.00 | 11000.00 |
| 21.12.2025 | Sun | 11000.00 | 100.0 | 0.00 | 0.00 | 0.00 | 11100.00 |
| 21.01.2026 | Wed | 11100.00 | 100.0 | 0.00 | 0.00 | 0.00 | 11200.00 |
| 20.02.2026 | Fri | 11200.00 | 0.0 | 558.43 | 139.61 | 418.82 | 11618.82 |
| 21.02.2026 | Sat | 11618.82 | 100.0 | 0.00 | 0.00 | 0.00 | 11718.82 |
| 21.03.2026 | Sat | 11718.82 | 100.0 | 0.00 | 0.00 | 0.00 | 11818.82 |
| 21.04.2026 | Tue | 11818.82 | 100.0 | 0.00 | 0.00 | 0.00 | 11918.82 |
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 pyciclib-0.2.0.tar.gz.
File metadata
- Download URL: pyciclib-0.2.0.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
958bc5696c531ede1095f367f89f4286af90a20830eac5d5a47e1b7108a83ac7
|
|
| MD5 |
27995a31b51a598b8bdf83f2383d2c86
|
|
| BLAKE2b-256 |
c20454513a5ee3f8363698b6e24234c7890c4e8f263a2a345d14011e61ff90e6
|
File details
Details for the file pyciclib-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pyciclib-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42acea580a7f4140293986ccbe0fd396685fa24cea9a3542b81c7476d34e122c
|
|
| MD5 |
28f34737ee42fd52579df32cb652e244
|
|
| BLAKE2b-256 |
4081395b525fd3521491a95eb528076de15e1b11168d1a0c9cfde8a69adadb39
|