Skip to content

feat: add financial interest algorithms#262

Open
pierreoosthuizen wants to merge 1 commit into
TheAlgorithms:masterfrom
pierreoosthuizen:add-financial-interest-algorithms
Open

feat: add financial interest algorithms#262
pierreoosthuizen wants to merge 1 commit into
TheAlgorithms:masterfrom
pierreoosthuizen:add-financial-interest-algorithms

Conversation

@pierreoosthuizen
Copy link
Copy Markdown

Add financial/interest.dart implementing exact-arithmetic interest math:

  • calculateBulletInterest / calculateTotalInterestPaid
  • futureValue / presentValue (time value of money)
  • generateEqualPrincipalSchedule (straight-line amortisation)
  • DayCountConvention and FrequencyCode enums + periodFraction helper

Uses package:rational for exact fractional arithmetic (no float rounding), added to pubspec.yaml. Includes 18 co-located package:test cases covering period fractions, FV/PV round-trips, and amortisation balances.

Welcome to Dart community

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?
  • Add/Update/Fix test cases.

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Dart files are placed inside an existing directory.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

Add financial/interest.dart implementing exact-arithmetic interest math:

- calculateBulletInterest / calculateTotalInterestPaid
- futureValue / presentValue (time value of money)
- generateEqualPrincipalSchedule (straight-line amortisation)
- DayCountConvention and FrequencyCode enums + periodFraction helper

Uses package:rational for exact fractional arithmetic (no float rounding),
added to pubspec.yaml. Includes 18 co-located package:test cases covering
period fractions, FV/PV round-trips, and amortisation balances.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant