cookbook icon indicating copy to clipboard operation
cookbook copied to clipboard

Add calculate_net_profit_percentage utility and tests

Open Mwessc opened this issue 6 months ago • 1 comments

This commit introduces a new utility function, calculate_net_profit_percentage, located in utils.py. This function calculates the net profit percentage of an investment given the initial investment and its current value. It includes error handling for invalid initial investment values (zero or negative).

Comprehensive unit tests have been added in test_utils.py using the unittest framework. These tests cover various scenarios, including:

  • Positive profit margins
  • Loss-making scenarios
  • Break-even situations
  • Edge cases such as zero or negative initial investment (raising ValueError)
  • Floating-point precision considerations using assertAlmostEqual.

All tests pass, ensuring the reliability of the utility function.

Mwessc avatar Jun 24 '25 22:06 Mwessc

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

I'm sorry but I have to close this PR as your are reverting weeks or work on all the files from the repo.

Giom-V avatar Jul 08 '25 17:07 Giom-V