ExcelFinancialFunctions

repository·master·Indexed 42 days ago

https://github.com/fsprojects/excelfinancialfunctions

A .NET Standard 2.0 library providing a set of Excel-compatible financial functions implemented in managed code. It allows developers to perform complex financial calculations in C# and F# without requiring Excel to be installed on the system.

Tokens
610
Snippets
3
Records
4
Agent score
3%

What's inside ExcelFinancialFunctions

  1. Known deviations from Excel behavior

    master

    While the primary goal is to match Excel's behavior exactly, there are two specific areas where this library deviates to correct Excel's logic:

    1. CoupDays: The library ensures that coupDays = coupDaysBS + coupDaysNC. Excel's implementation can differ by +/- one or two days when a date spans a leap year.
    2. VDB (Variable Depreciation): In Excel, the depreciation in period (0,1) is not equal to the sum of depreciations in sub-periods (0,0.5) and (0.5,1). This library aims for mathematical consistency where the sum of sub-periods equals the total period depreciation.
  2. Install ExcelFinancialFunctions via NuGet

    master

    ExcelFinancialFunctions is a .NET Standard 2.0 library. You can add it to any project that supports .NET Standard 2.0, including .NET Framework 4.6.1 or later and .NET Core 2.0 or later. Use the dotnet add package command to install it.

    dotnet add package ExcelFinancialFunctions
  3. Use Excel Financial Functions in C#

    master

    The library provides financial functions as static methods on the Financial class within the Excel.FinancialFunctions namespace. Although the library is written in F#, it is fully compatible with C#.

    using Excel.FinancialFunctions;
    
    Console.WriteLine( Financial.IPmt(rate: 0.005, per: 53, nper: 180, pv: 200000, fv: 0, typ: PaymentDue.EndOfPeriod) );
    // Displays -796.3747578439793
    
    Console.WriteLine( Financial.Pmt(rate: 0.005, nper: 180, pv: 200000, fv: 0, typ: PaymentDue.EndOfPeriod) );
    // Displays -1687.7136560969248
  4. Use Excel Financial Functions in F#

    master

    In F#, open the Excel.FinancialFunctions namespace to access the Financial class methods.

    open Excel.FinancialFunctions
    
    printfn "%f" <| Financial.IPmt (0.005, 53., 180., 200000., 0., PaymentDue.EndOfPeriod) 
    // Displays -796.374758
    
    printfn "%f" <| Financial.Pmt (0.005, 180., 200000., 0., PaymentDue.EndOfPeriod) 
    // Displays -1687.713656