Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: make pull request items requirements
  • Loading branch information
tarcisiobruni committed Oct 24, 2021
commit ff0cde76e69efb1ee36b258d633009dce1fceeac
7 changes: 0 additions & 7 deletions financials/ABOUT.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
## About math calculations

### 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/)
*

### Average

//todo

Empty file added financials/__init__.py
Empty file.
5 changes: 0 additions & 5 deletions financials/average.py

This file was deleted.

19 changes: 17 additions & 2 deletions financials/interest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
def simple_interest(principle, daily_interest_rate, number_of_days_between_payment):
from __future__ import annotations

def simple_interest(principle, daily_interest_rate, number_of_days_between_payment) -> float:
Comment thread
tarcisiobruni marked this conversation as resolved.
Outdated
"""
>>> simple_interest(18000,0.06,3)
3240.0
Copy link
Copy Markdown
Member

@cclauss cclauss Oct 24, 2021

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cclauss done

"""
result = principle * daily_interest_rate * number_of_days_between_payment
return result

def compound_interest(principle, nominal_annual_interest_rate_percentage , number_of_compounding_periods):
def compound_interest(principle, nominal_annual_interest_rate_percentage , number_of_compounding_periods)-> float:
Comment thread
tarcisiobruni marked this conversation as resolved.
Outdated
"""
>>> compound_interest(10000,0.05,3)
1576.2500000000014
"""
result = principle * ((1 + nominal_annual_interest_rate_percentage) ** number_of_compounding_periods - 1)
Comment thread
tarcisiobruni marked this conversation as resolved.
Outdated
return result


if __name__ == "__main__":
import doctest

doctest.testmod()
Comment thread
tarcisiobruni marked this conversation as resolved.
Outdated