rust_finprim

Crates.iorust_finprim
lib.rsrust_finprim
version0.3.1
sourcesrc
created_at2024-06-05 01:35:55.117501
updated_at2024-06-07 04:34:36.070806
descriptionVarious finance and accounting calculations/formulas implemented Rust
homepage
repositoryhttps://github.com/daneski13/rust-finprim
max_upload_size
id1262273
size96,852
Dane Skalski (daneski13)

documentation

https://daneski13.github.io/rust-finprim/rust_finprim/index.html

README

Financial Calculation Primitives

This is a minimal library providing various primitive functions to perform financial calculations.

Built on top of the rust_decimal crate, providing high precision while maintaining respectable performance. The Decimal type provides a fixed-point decimal number of up to 28 significant digits. Offering much more precision than calculations using an f64 and implementations in spreadsheet programs.

Some functions and their args mimic those found in Excel and Google Sheets.

Functionality

Time Value of Money (TVM) Calculations

rust_finprim::tvm module.

  • Present Value
    • Common Uses: Bond Pricing, Discounted Cash Flow, Annuities, etc.
  • Future Value
    • Common Uses: Compound Interest/Growth, Annuities etc.
  • Net Present Value (NPV)
    • Common Uses: Capital Budgeting, Investment Analysis, etc.
  • Net Present Value with differing discount rates
  • Net Present Value for irregular cash flows (XNPV)
  • Payment (PMT)
    • Common Uses: Bonds, Loan/Mortgage Payments, Annuities, etc.

Interest Rate Calculations

rust_finprim::rate module.

  • APR (Annual Percentage Rate) and EAR (Effective Annual Rate) conversions
  • IRR (Internal Rate of Return)
    • Common Uses: Investment Analysis, Capital Budgeting, Bond Yields (YTM, YTC), etc.
  • Internal Rate of Return for irregular cash flows (XIRR)
  • MIRR (Modified Internal Rate of Return)
  • Modified Internal Rate of Return for irregular cash flows (XMIRR)

Amortization, Depreciation, and Tax Calculations

rust_finprim::amort_dep_tax module.

  • Amortization Schedule
    • Common Uses: Loan/Mortgage Amortization
  • Depreciation Schedules for various methods
    • Straight line
    • Declining balance (e.g. double declining balance)
    • Sum of years digits
    • MACRS (Modified Accelerated Cost Recovery System) for US tax purposes
  • Progressive Income Tax

Derivatives

rust_finprim::derivatives module.

  • 1st and 2nd derivative of present value with respect to interest rate
    • Useful for calculating duration, convexity and various optimization problems

Features

There are a few features that can be enabled:

  • std - Enabled by default. You can use the library in a no_std environment with default-features = false in your Cargo.toml.
  • serde - Enables serialization and deserialization of the provided structs using serde.

Installation

Add the following to your Cargo.toml:

[dependencies]
rust_finprim = "0.3.1"

Or

cargo add rust_finprim
Commit count: 10

cargo fmt