Skip to content

Add vectorized annual-rate and scheduled-compounding helpers - #163

Draft
lcrmorin wants to merge 2 commits into
numpy:mainfrom
lcrmorin:feature/compounding-helpers
Draft

lcrmorin wants to merge 2 commits into
numpy:mainfrom
lcrmorin:feature/compounding-helpers

Conversation

@lcrmorin

Copy link
Copy Markdown

Add three vectorized helpers for common compounding calculations:

  • effective_annual_rate: convert a nominal annual rate to an effective annual rate.
  • nominal_annual_rate: perform the inverse conversion.
  • compound_value: compound a principal through a schedule of changing rates, with a selectable time axis.

The implementation uses standard compounding formulas with log1p/expm1, descriptive names and no new runtime dependencies. Zero and negative rates are supported when each growth factor remains positive. Compounding frequencies must be positive integers. Invalid inputs raise ValueError; calculations use floating-point precision. compound_value preserves the principal's sign and does not model intervening cash flows.

This is a draft for discussion of the public API and validation conventions. It is not a claim of complete Excel compatibility. Includes API documentation, examples, installation wiring and tests.

Validation: 150 tests and three docstring examples pass. Tests include independent Decimal references, broadcasting, schedule recurrence and invalid inputs. Ruff, Pyright and Mypy pass.

Prepared with AI assistance.

This branch has not been deployed

No deployments
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