banktools 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.
@@ -0,0 +1 @@
1
+ MIT License
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.4
2
+ Name: banktools
3
+ Version: 0.1.0
4
+ Summary: A Python library for banking calculations and currency utilities.
5
+ License: MIT License
6
+ Project-URL: Homepage, https://pypi.org/project/banktools/
7
+ Keywords: bank,finance,interest,currency,loan,tax,emi
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: Office/Business :: Financial
12
+ Requires-Python: >=3.7
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: license-file
16
+
17
+ # banktools
18
+
19
+ A Python library for banking calculations and currency utilities.
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ pip install banktools
25
+ ```
26
+
27
+ ## Modules
28
+
29
+ ### 1. calculator
30
+ Banking and finance calculation functions.
31
+
32
+ - `simple_interest(principal, rate, time)` — Calculate simple interest
33
+ - `compound_interest(principal, rate, time, n)` — Calculate compound interest
34
+ - `loan_emi(principal, annual_rate, months)` — Calculate monthly loan EMI
35
+ - `tax_calculator(income, tax_rate)` — Calculate tax and net income
36
+
37
+ ### 2. currencytools
38
+ Currency conversion and exchange utilities.
39
+
40
+ - `convert_currency(amount, exchange_rate)` — Convert amount using exchange rate
41
+ - `format_currency(amount, symbol)` — Format number as currency string
42
+ - `currency_difference(amount1, amount2)` — Find difference between two amounts
43
+ - `is_profitable(bought_at, sold_at)` — Check if currency exchange was profitable
44
+
45
+ ## Usage
46
+
47
+ ```python
48
+ from banktools.calculator import simple_interest, loan_emi
49
+ from banktools.currencytools import convert_currency, format_currency
50
+
51
+ # Simple interest
52
+ result = simple_interest(1000, 5, 3)
53
+ print(result) # {'interest': 150.0, 'total_amount': 1150.0}
54
+
55
+ # Loan EMI
56
+ emi = loan_emi(100000, 8, 24)
57
+ print(emi) # {'emi': 4523.01, 'total_payment': 108552.24, 'total_interest': 8552.24}
58
+
59
+ # Currency conversion
60
+ pkr = convert_currency(100, 280)
61
+ print(pkr) # 28000.0
62
+
63
+ # Format currency
64
+ print(format_currency(1500.5, '$')) # $1,500.50
65
+ ```
66
+
67
+ ## License
68
+ MIT License
@@ -0,0 +1,52 @@
1
+ # banktools
2
+
3
+ A Python library for banking calculations and currency utilities.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install banktools
9
+ ```
10
+
11
+ ## Modules
12
+
13
+ ### 1. calculator
14
+ Banking and finance calculation functions.
15
+
16
+ - `simple_interest(principal, rate, time)` — Calculate simple interest
17
+ - `compound_interest(principal, rate, time, n)` — Calculate compound interest
18
+ - `loan_emi(principal, annual_rate, months)` — Calculate monthly loan EMI
19
+ - `tax_calculator(income, tax_rate)` — Calculate tax and net income
20
+
21
+ ### 2. currencytools
22
+ Currency conversion and exchange utilities.
23
+
24
+ - `convert_currency(amount, exchange_rate)` — Convert amount using exchange rate
25
+ - `format_currency(amount, symbol)` — Format number as currency string
26
+ - `currency_difference(amount1, amount2)` — Find difference between two amounts
27
+ - `is_profitable(bought_at, sold_at)` — Check if currency exchange was profitable
28
+
29
+ ## Usage
30
+
31
+ ```python
32
+ from banktools.calculator import simple_interest, loan_emi
33
+ from banktools.currencytools import convert_currency, format_currency
34
+
35
+ # Simple interest
36
+ result = simple_interest(1000, 5, 3)
37
+ print(result) # {'interest': 150.0, 'total_amount': 1150.0}
38
+
39
+ # Loan EMI
40
+ emi = loan_emi(100000, 8, 24)
41
+ print(emi) # {'emi': 4523.01, 'total_payment': 108552.24, 'total_interest': 8552.24}
42
+
43
+ # Currency conversion
44
+ pkr = convert_currency(100, 280)
45
+ print(pkr) # 28000.0
46
+
47
+ # Format currency
48
+ print(format_currency(1500.5, '$')) # $1,500.50
49
+ ```
50
+
51
+ ## License
52
+ MIT License
@@ -0,0 +1,23 @@
1
+ """
2
+ banktools - A Python library for banking calculations and currency utilities.
3
+
4
+ Modules:
5
+ calculator - Simple interest, compound interest, EMI, tax calculations
6
+ currencytools - Currency conversion, formatting, comparison, profit check
7
+ """
8
+
9
+ from .calculator import simple_interest, compound_interest, loan_emi, tax_calculator
10
+ from .currencytools import convert_currency, format_currency, currency_difference, is_profitable
11
+
12
+ __version__ = "0.1.0"
13
+ __author__ = "Your Group Name"
14
+ __all__ = [
15
+ "simple_interest",
16
+ "compound_interest",
17
+ "loan_emi",
18
+ "tax_calculator",
19
+ "convert_currency",
20
+ "format_currency",
21
+ "currency_difference",
22
+ "is_profitable",
23
+ ]
@@ -0,0 +1,118 @@
1
+ """
2
+ calculator.py - Banking calculation utilities for banktools library.
3
+ Provides functions for simple interest, compound interest, loan EMI, and tax.
4
+ """
5
+
6
+
7
+ def simple_interest(principal, rate, time):
8
+ """
9
+ Calculate simple interest.
10
+
11
+ Args:
12
+ principal (float): The initial amount of money.
13
+ rate (float): Annual interest rate in percentage (e.g. 5 for 5%).
14
+ time (float): Time period in years.
15
+
16
+ Returns:
17
+ dict: Contains 'interest' and 'total_amount'.
18
+
19
+ Example:
20
+ >>> simple_interest(1000, 5, 3)
21
+ {'interest': 150.0, 'total_amount': 1150.0}
22
+ """
23
+ if principal < 0 or rate < 0 or time < 0:
24
+ raise ValueError("Principal, rate, and time must be non-negative.")
25
+ interest = (principal * rate * time) / 100
26
+ total = principal + interest
27
+ return {
28
+ "interest": round(interest, 2),
29
+ "total_amount": round(total, 2)
30
+ }
31
+
32
+
33
+ def compound_interest(principal, rate, time, n=1):
34
+ """
35
+ Calculate compound interest.
36
+
37
+ Args:
38
+ principal (float): The initial amount of money.
39
+ rate (float): Annual interest rate in percentage (e.g. 5 for 5%).
40
+ time (float): Time period in years.
41
+ n (int): Number of times interest is compounded per year (default 1).
42
+
43
+ Returns:
44
+ dict: Contains 'interest' and 'total_amount'.
45
+
46
+ Example:
47
+ >>> compound_interest(1000, 5, 3, 12)
48
+ {'interest': 161.62, 'total_amount': 1161.62}
49
+ """
50
+ if principal < 0 or rate < 0 or time < 0 or n <= 0:
51
+ raise ValueError("All values must be positive.")
52
+ total = principal * (1 + (rate / 100) / n) ** (n * time)
53
+ interest = total - principal
54
+ return {
55
+ "interest": round(interest, 2),
56
+ "total_amount": round(total, 2)
57
+ }
58
+
59
+
60
+ def loan_emi(principal, annual_rate, months):
61
+ """
62
+ Calculate the monthly EMI (Equated Monthly Installment) for a loan.
63
+
64
+ Args:
65
+ principal (float): Loan amount.
66
+ annual_rate (float): Annual interest rate in percentage.
67
+ months (int): Loan tenure in months.
68
+
69
+ Returns:
70
+ dict: Contains 'emi', 'total_payment', and 'total_interest'.
71
+
72
+ Example:
73
+ >>> loan_emi(100000, 8, 24)
74
+ {'emi': 4523.01, 'total_payment': 108552.24, 'total_interest': 8552.24}
75
+ """
76
+ if principal <= 0 or annual_rate < 0 or months <= 0:
77
+ raise ValueError("Principal and months must be positive; rate must be non-negative.")
78
+ if annual_rate == 0:
79
+ emi = principal / months
80
+ return {
81
+ "emi": round(emi, 2),
82
+ "total_payment": round(principal, 2),
83
+ "total_interest": 0.0
84
+ }
85
+ monthly_rate = (annual_rate / 100) / 12
86
+ emi = principal * monthly_rate * (1 + monthly_rate) ** months / ((1 + monthly_rate) ** months - 1)
87
+ total_payment = emi * months
88
+ total_interest = total_payment - principal
89
+ return {
90
+ "emi": round(emi, 2),
91
+ "total_payment": round(total_payment, 2),
92
+ "total_interest": round(total_interest, 2)
93
+ }
94
+
95
+
96
+ def tax_calculator(income, tax_rate):
97
+ """
98
+ Calculate tax and net income after tax.
99
+
100
+ Args:
101
+ income (float): Gross income amount.
102
+ tax_rate (float): Tax rate in percentage (e.g. 20 for 20%).
103
+
104
+ Returns:
105
+ dict: Contains 'tax_amount' and 'net_income'.
106
+
107
+ Example:
108
+ >>> tax_calculator(50000, 20)
109
+ {'tax_amount': 10000.0, 'net_income': 40000.0}
110
+ """
111
+ if income < 0 or tax_rate < 0 or tax_rate > 100:
112
+ raise ValueError("Income must be non-negative and tax rate must be between 0 and 100.")
113
+ tax = (income * tax_rate) / 100
114
+ net = income - tax
115
+ return {
116
+ "tax_amount": round(tax, 2),
117
+ "net_income": round(net, 2)
118
+ }
@@ -0,0 +1,105 @@
1
+ """
2
+ currencytools.py - Currency conversion and exchange utilities for banktools library.
3
+ Provides functions for currency conversion, formatting, comparison, and profit checking.
4
+ """
5
+
6
+
7
+ def convert_currency(amount, exchange_rate):
8
+ """
9
+ Convert an amount from one currency to another using an exchange rate.
10
+
11
+ Args:
12
+ amount (float): The amount to convert.
13
+ exchange_rate (float): The exchange rate to apply (e.g. 1 USD = 280 PKR -> rate=280).
14
+
15
+ Returns:
16
+ float: The converted amount.
17
+
18
+ Example:
19
+ >>> convert_currency(100, 280)
20
+ 28000.0
21
+ """
22
+ if amount < 0:
23
+ raise ValueError("Amount must be non-negative.")
24
+ if exchange_rate <= 0:
25
+ raise ValueError("Exchange rate must be greater than zero.")
26
+ return round(amount * exchange_rate, 2)
27
+
28
+
29
+ def format_currency(amount, symbol="$"):
30
+ """
31
+ Format a number as a currency string with commas and 2 decimal places.
32
+
33
+ Args:
34
+ amount (float): The monetary amount to format.
35
+ symbol (str): Currency symbol to prepend (default '$').
36
+
37
+ Returns:
38
+ str: Formatted currency string (e.g. '$1,000.00').
39
+
40
+ Example:
41
+ >>> format_currency(1500.5, '$')
42
+ '$1,500.50'
43
+ """
44
+ if amount < 0:
45
+ raise ValueError("Amount must be non-negative.")
46
+ return f"{symbol}{amount:,.2f}"
47
+
48
+
49
+ def currency_difference(amount1, amount2):
50
+ """
51
+ Calculate the absolute difference between two currency values.
52
+
53
+ Args:
54
+ amount1 (float): First currency amount.
55
+ amount2 (float): Second currency amount.
56
+
57
+ Returns:
58
+ dict: Contains 'difference' and 'higher_amount'.
59
+
60
+ Example:
61
+ >>> currency_difference(500, 350)
62
+ {'difference': 150.0, 'higher_amount': 500}
63
+ """
64
+ if amount1 < 0 or amount2 < 0:
65
+ raise ValueError("Amounts must be non-negative.")
66
+ diff = abs(amount1 - amount2)
67
+ higher = max(amount1, amount2)
68
+ return {
69
+ "difference": round(diff, 2),
70
+ "higher_amount": higher
71
+ }
72
+
73
+
74
+ def is_profitable(bought_at, sold_at):
75
+ """
76
+ Check whether a currency exchange transaction was profitable.
77
+
78
+ Args:
79
+ bought_at (float): Exchange rate when currency was bought.
80
+ sold_at (float): Exchange rate when currency was sold.
81
+
82
+ Returns:
83
+ dict: Contains 'profitable' (bool), 'profit_or_loss', and 'status' message.
84
+
85
+ Example:
86
+ >>> is_profitable(1.10, 1.25)
87
+ {'profitable': True, 'profit_or_loss': 0.15, 'status': 'Profit'}
88
+ """
89
+ if bought_at <= 0 or sold_at <= 0:
90
+ raise ValueError("Exchange rates must be greater than zero.")
91
+ difference = sold_at - bought_at
92
+ if difference > 0:
93
+ status = "Profit"
94
+ profitable = True
95
+ elif difference < 0:
96
+ status = "Loss"
97
+ profitable = False
98
+ else:
99
+ status = "Break Even"
100
+ profitable = False
101
+ return {
102
+ "profitable": profitable,
103
+ "profit_or_loss": round(abs(difference), 4),
104
+ "status": status
105
+ }
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.4
2
+ Name: banktools
3
+ Version: 0.1.0
4
+ Summary: A Python library for banking calculations and currency utilities.
5
+ License: MIT License
6
+ Project-URL: Homepage, https://pypi.org/project/banktools/
7
+ Keywords: bank,finance,interest,currency,loan,tax,emi
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: Office/Business :: Financial
12
+ Requires-Python: >=3.7
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: license-file
16
+
17
+ # banktools
18
+
19
+ A Python library for banking calculations and currency utilities.
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ pip install banktools
25
+ ```
26
+
27
+ ## Modules
28
+
29
+ ### 1. calculator
30
+ Banking and finance calculation functions.
31
+
32
+ - `simple_interest(principal, rate, time)` — Calculate simple interest
33
+ - `compound_interest(principal, rate, time, n)` — Calculate compound interest
34
+ - `loan_emi(principal, annual_rate, months)` — Calculate monthly loan EMI
35
+ - `tax_calculator(income, tax_rate)` — Calculate tax and net income
36
+
37
+ ### 2. currencytools
38
+ Currency conversion and exchange utilities.
39
+
40
+ - `convert_currency(amount, exchange_rate)` — Convert amount using exchange rate
41
+ - `format_currency(amount, symbol)` — Format number as currency string
42
+ - `currency_difference(amount1, amount2)` — Find difference between two amounts
43
+ - `is_profitable(bought_at, sold_at)` — Check if currency exchange was profitable
44
+
45
+ ## Usage
46
+
47
+ ```python
48
+ from banktools.calculator import simple_interest, loan_emi
49
+ from banktools.currencytools import convert_currency, format_currency
50
+
51
+ # Simple interest
52
+ result = simple_interest(1000, 5, 3)
53
+ print(result) # {'interest': 150.0, 'total_amount': 1150.0}
54
+
55
+ # Loan EMI
56
+ emi = loan_emi(100000, 8, 24)
57
+ print(emi) # {'emi': 4523.01, 'total_payment': 108552.24, 'total_interest': 8552.24}
58
+
59
+ # Currency conversion
60
+ pkr = convert_currency(100, 280)
61
+ print(pkr) # 28000.0
62
+
63
+ # Format currency
64
+ print(format_currency(1500.5, '$')) # $1,500.50
65
+ ```
66
+
67
+ ## License
68
+ MIT License
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ banktools/__init__.py
5
+ banktools/calculator.py
6
+ banktools/currencytools.py
7
+ banktools.egg-info/PKG-INFO
8
+ banktools.egg-info/SOURCES.txt
9
+ banktools.egg-info/dependency_links.txt
10
+ banktools.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ banktools
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "banktools"
7
+ version = "0.1.0"
8
+ description = "A Python library for banking calculations and currency utilities."
9
+ readme = "README.md"
10
+ license = { file = "LICENSE" }
11
+ requires-python = ">=3.7"
12
+ keywords = ["bank", "finance", "interest", "currency", "loan", "tax", "emi"]
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Operating System :: OS Independent",
17
+ "Topic :: Office/Business :: Financial",
18
+ ]
19
+
20
+ [project.urls]
21
+ Homepage = "https://pypi.org/project/banktools/"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+