MKoD - D Programming Language

A Financial Package for D

Financial Package in the Red-Orbs font
Well, I've decided to go ahead and take a dive forward with this idea of a D Financial Package that's to be compatible with MS Excel's VBA (and VB6's) financial functions. It should help make D more attractive to those who wish to create business-type applications. Plus if I get stuck...I can always ask for some help from others on the D user's forum ( at least that's the plan so far :)) ).

17.Jul.04 Added unittests to the nine finished functions, comparing that function's returned "real" value against VBA's function's returned "double" value to within 0.0000001 of precision...complied and ran the test .exe, all passed!

22.Jul.04 Well, with 11 of the 16 financial functions with unittests finished, I think it's time to share what I have at this point. In fact, the source code comes in two favors, one where the functions can be imported in / include into other D code, and a second one that can create a Windows' DLL that's explicitly loaded in (a D created Window's DLL, which only D Applications can use...at this point anyway! Maybe a first, but who knows?)

10.Dec.04 Completed 4 more functions, and retested with D v0.109.
14.Apr.05 Recompiled and tested with D v0.120.
10.Jun.05 Recompiled and tested with D v0.126.
30.Jun.05 License changed to GPL, 7 more functions added, project recompiled and tested with D v0.127.
26.Mar.06 Recompiled and tested with D v0.150, also I had to make one correction because the mangle name "D13financial_dll3vdbFeeeeeebZe" was changed when bool become its own data type in D v0.148 (so the b was replaced with x, and the mangle name became "D13financial_dll3vdbFeeeeeexZe)."


"D Financial Functions" (VB6 / Excel VBA Compatible) - financial.d and financial_dll.d

  • db( rCost, rSalvage, rLife, rPeriod, uiMonth = 12 ) - 100% Done, passed test.
    Calculates the depreciation of an assest for a period using the fixed-declining balance method.

  • ddb( rCost, rSalvage, rLife, rPeriod, rFactor = 2.0 ) - 100% Done, passed test.
    Calculates the deperciation of an asset for a period using the double-declining balance method.

  • fv( rRate, rNPer, rPmt, rPV = 0.0, uiType = 0 ) - 100% Done, passed test.
    Calculates the future value of an investment based on periodic, constant payments and a constant interest rate.

  • ipmt( rRate, rPer, rNPer, rPV, rFV = 0.0, uiType = 0 ) - 100% Done, passed test.
    Calculates the interest payment during a specific period of an investment.

  • irr( rValues(), rGuess = 0.1 ) - 100% Done, passed test.
    Calculates the internal rate of return for a series of cash flows represented by the numbers of values.

  • ispmt( rRate, rPer, rNPer, rPV ) - 100% Done, passed test.
    Calculates the interest paid during a specific period of an investment.

  • mirr( rValues(), rFinance_Rate, rReinvest_Rate ) - 100% Done, passed test.
    Calculates the modified intermal rate of return for a series of periodic cash flows.

  • nper( rRate, rPmt, rPV, rFV = 0.0, uiType = 0 ) - 100% Done, passed test.
    Returns the number of periods for an investment based on periodic, constant payments and a constant interest rate.

  • npv( rRate, rValue1, rValue2, ... ) - 100% Done, passed test.
    Calculates the net present value (rPV) of an investment by using a discount rate and a series of future payments (negative values) and income (positive values).

  • pmt( rRate, rNPer, rPV, rFV = 0.0, uiType = 0 ) - 100% Done, passed test.
    Calculates the payment for a loan based on constant payments and a constant interest rate.

  • ppmt( rRate, rNPer, rPV, rFV = 0.0, uiType = 0 ) - 100% Done, passed test.
    Calculates the payment on the principal for a given period for an investment based on periodic, constant payments and a constant interest rate.

  • pv( rRate, rNPer, rPV, rFV = 0.0, uiType = 0 ) - 100% Done, passed test.
    Calculates the present value of an investment.

  • rate( rNPer, rPmt, rPV, rFV = 0.0, uiType = 0, rGuess = 0.1 ) - 100% Done, passed test.
    Calculates the interest rate per period of an annuity.

  • sln( rCost, rSalvage, rLife ) - 100% Done, passed test.
    Calculates the straight-line depreciation of an asset for one period.

  • syd( rCost, rSalvage, rLife, rPer ) - 100% Done, passed test.
    Calculates the sum-ofyears' digits depreciation of an asset for a specified period.

  • vdb( rCost, rSalvage, rLife, rStart_Period, rEnd_Period, rFactor = 2.0, bNo_Switch = false ) - 100% Done, passed test.
    Calculates the variable declining balance (depreciation) of an asset.

  • xnpv( rRate, rPayments(), dtDates() ) - 100% Done, passed test.
  • xnpv( rRate, rPayments(), sDates() ) - 100% Done, passed test.
    Calculates the Net Present Value of an investment for a series of cash flow.

  • xirr( rPayments(), dtDates(), rGuess = 0.1 ) - 100% Done, passed test.
  • xirr( rPayments(), sDates(), rGuess = 0.1 ) - 100% Done, passed test.
    Calculates the Interest Rate for a series of cash flow.

  • effect( rNominalRate, rNumPerYr ) - 100% Done, passed test.
    Calculates the effective annual interest rate.

  • nominal( rEffectRate, rNumPerYr ) - 100% Done, passed test.
    Calculates the nominal annual interest rate.

  • dollarde( rFractionalDollar, uiFraction ) - 100% Done, passed test.
    Calculates dollar price expressed as a decimal number.

  • dollarfr( rDecimalDollar, uiFraction ) - 100% Done, passed test.
    Calculates dollar price expressed as a fraction.

  • D Financial Package v0.3 (83Kb updated 05.Jan.07 - D v1.0)
  • Discover Mars Magik