-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Financials #5585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Financials #5585
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ed89816
feat: creates math calculations for financials
tarcisiobruni ff0cde7
refactor: make pull request items requirements
tarcisiobruni e00a875
refactor: provides type hint for parameters
tarcisiobruni 1e5cc30
refactor: applies code review suggestions
tarcisiobruni 522dcbf
refactor: adds more examples tests
tarcisiobruni 5234d8d
refactor: throws ValueError instead of Exception
tarcisiobruni 980f40d
refactor: fix formatting
tarcisiobruni 3de2457
refactor: fix formatting
tarcisiobruni 110da41
Update interest.py
cclauss c3dd88b
Update and rename financials/ABOUT.md to financial/ABOUT.md
cclauss c1fb8d0
Rename financials/__init__.py to financial/__init__.py
cclauss 4807cac
Rename financials/interest.py to financial/interest.py
cclauss bc6304e
https://www.investopedia.com
cclauss d953fa3
Update __init__.py
cclauss f6e7408
pre-commit: Disable end-of-file-fixer
cclauss d551e4e
Revert change to pre-commit
cclauss 787a9b5
Update __init__.py
poyea 34a2b72
__init__.py
poyea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### Interest | ||
|
||
* Compound Interest: "Compound interest is calculated by multiplying the initial principal amount by one plus the annual interest rate raised to the number of compound periods minus one." [Compound Interest](https://www.investopedia.com/) | ||
* Simple Interest: "Simple interest paid or received over a certain period is a fixed percentage of the principal amount that was borrowed or lent. " [Simple Interest](https://www.investopedia.com/) | ||
* |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from __future__ import annotations | ||
|
||
def simple_interest(principle:float, daily_interest_rate:float, number_of_days_between_payment:int) -> float: | ||
""" | ||
>>> simple_interest(18000,0.06,3) | ||
3240.0 | ||
""" | ||
result = principle * daily_interest_rate * number_of_days_between_payment | ||
return result | ||
tarcisiobruni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def compound_interest(principle:float, nominal_annual_interest_rate_percentage:float, number_of_compounding_periods:int)-> float: | ||
""" | ||
>>> compound_interest(10000,0.05,3) | ||
1576.2500000000014 | ||
""" | ||
result = principle * ((1 + nominal_annual_interest_rate_percentage) ** number_of_compounding_periods - 1) | ||
tarcisiobruni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return result | ||
|
||
|
||
if __name__ == "__main__": | ||
import doctest | ||
|
||
doctest.testmod() | ||
tarcisiobruni marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests dealing with zero principle, negative principle, zero interest rate, negative interest rate, zero days, negative days, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cclauss done