Add Excel-compatible XIRR wrapper #31
                
     Open
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
All the finance people (and chatbots) seem to be madly in love with XIRR functions. So here you go...
This PR adds Excel-compatible XIRR (Extended Internal Rate of Return) functionality to the FSharp.Finance.Personal library, enabling calculation of annualized returns for irregular cash flow schedules.
Instead of re-inventing the wheel, this adds a new dependency to fsprojects/ExcelFinancialFunctions.
Features Added
Core XIRR Module (
src/Xirr.fs)Xirr.xirr: Calculate XIRR with Excel's default guess of 0.1 (10%)Xirr.xirrG: Calculate XIRR with custom initial guess parameterXirr.tryXirr: Safe calculation returningResult<decimal, string>for error handlingExcel Compatibility
Uses the
ExcelFinancialFunctionslibrary (v3.2.0) to ensure complete parity with Excel's XIRR function, including:Input Validation
All functions validate that:
ArgumentExceptionfor invalid inputs (excepttryXirrwhich returnsResult.Error)Usage Example
Testing
Comprehensive test suite (
tests/XirrTests.fs) covers:xirrandxirrGwith same guessAll 7 test cases pass successfully when run in isolation.
Documentation
docs/exampleXirr.fsxwith comprehensive usage examplesIntegration Notes
ExcelFinancialFunctionspackage dependencyThe implementation follows the repository's existing patterns and conventions, using
[<RequireQualifiedAccess>]module attributes and consistent error handling approaches.